//[PERSONALITY:Shy]
//onChase::YSpeed 1
//[PERSONALITY:Assertive]
//string CONTEMPLATE0 They won't know I took you if I digest the evidence!
//string CONTEMPLATE1 You WILL go down my throat.
//string CONTEMPLATE2 You'll feel so good going down my throat!
//string OWNERTOOCLOSE0 I don't want to lose their trust, so I'll hold this until later.
//string OWNERTOOCLOSE1 You're lucky I respect her... somewhat.
//string CAUGHTHOLDING0 I was not going to eat it.
//string CAUGHTHOLDING1 There wasn't a chance of me eating it!
//string CAUGHTHOLDING2 I didn't break it.
//string CAUGHTHOLDING_EAT0 It's not as if I was going to actually swallow it.
//string CAUGHTHOLDING_EAT1 I was just giving it a taste-test.
//string CAUGHT_OWNERCLOSE0 You won't squirm, or else I'll just eat you.
//string CAUGHT_OWNERCLOSE1 Don't squirm, or I'll eat you.
//string CAUGHT0 I got you! You know where you're going.
//string CAUGHT1 You'll feel real comfortable in there.
//string CAUGHT2 What's the matter? It's really warm and soft in there.
//string CAUGHT_NOTVORIST0 Oh. Hi, little one.
//string CAUGHT_NOTVORIST1 I would eat you, but I happen to dislike the taste of tomthumb.
//string CAUGHT_NOTVORIST2 You're very cute, aren't you?
//string GIVEUPSEARCH0 You're only making this harder on yourself!
//string GIVEUPSEARCH1 Just because you've gotten away now doesn't mean you're safe.
//string GIVEUPSEARCH2 You'll be in my belly soon enough!
//string SEARCHFORTARGET0 Where'd you go?
//string SEARCHFORTARGET1 You shouldn't have run off, little one!
//string SEARCHFORTARGET2 Come out; I'm not done toying with you yet!
//string FOUNDTARGETAFTERLOSS0 I knew you were there.
//string FOUNDTARGETAFTERLOSS1 I see you've accepted your place on the food chain.
//string FOUNDTARGETAFTERLOSS2 Don't worry; I promise it's very comfortable in there.
//string FOUNDTARGET0 There you are!
//string FOUNDTARGET1 You look delectable~
//string FRIENDLY_ASKTOEAT0 Do you really want to die?
//string FRIENDLY_ASKTOEAT1 Are you sure you want to die?
//string FRIENDLY_ASKTOEAT2 I'm not down to the idea; Just tell me if you're serious or not.
//string FRIENDLY_ASKTOEAT_NO0 You're really pushing your luck.
//string FRIENDLY_ASKTOEAT_NO1 You should know that I have no qualms in eating tomthumbs.
//string FRIENDLY_ASKTOEAT_NO2 I will eat you if you want me to.
//string FRIENDLY_ASKTOEAT_YES0 Alright, here it goes.
//string FRIENDLY_ASKTOEAT_YES1 Don't say I didn't warn you.
//string FRIENDLY_ASKTOEAT_YES2 Remember that the burning sensation will only last for a few hours.
//string FRIENDLY_ASKTOWAIT0 Alright, I'll wait here.
//string FRIENDLY_ASKTOWAIT1 I'll be here.
//string FRIENDLY_ASKTOFOLLOW0 Alright, I'll be following you.
//string FRIENDLY_ASKTOFOLLOW1 It seems inconvenient, but I'll follow you.
//string FRIENDLY_ALREADYWAITING0 I'm already waiting here.
//string FRIENDLY_ALREADYWAITING1 Are you developing a permutation of Dimensia? I'm already waiting here.
//string FRIENDLY_MOUTHSUPRISE0 Aht!
//string FRIENDLY_MOUTHSUPRISE1 H-Hey!
//string FRIENDLY_MOUTHSUPRISE2 Ack! If you don't get out right now, I'll swallow you!
//string FRIENDLY_HELLO0 Hi.
//string FRIENDLY_HELLO1 Hello there, tomthumb.
//string FRIENDLY_HELLO2 Greetings.
//[PERSONALITY:General]
//string CONTEMPLATE0 They won't ever know...
//string CONTEMPLATE1 What if I...
//string CONTEMPLATE2 Would you mind? I'm sort of hungry...
//string CONTEMPLATE3 I'm feeling kind of hungry...
//string OWNERTOOCLOSE0 Damn..
//string OWNERTOOCLOSE1 Ugh.
//string OWNERTOOCLOSE2 So close.
//string OWNERTOOCLOSE3 Next time, morsel~
//string CAUGHTHOLDING0 I was just looking.
//string CAUGHTHOLDING1 I didn't even try to eat them!
//string CAUGHTHOLDING2 N-Nothing!
//string CAUGHTHOLDING_EAT0 Oh! Uhm... Sorry.
//string CAUGHTHOLDING_EAT1 Ah.. Sorry, I didn't know this was yours.
//string CAUGHTHOLDING_EAT2 N-Nothing!
//string CAUGHT_OWNERCLOSE0 I'm just looking.
//string CAUGHT_OWNERCLOSE1 Stop squirming!
//string CAUGHT0 Aha! Got you~
//string CAUGHT1 You're so cute, I could eat you up!
//string CAUGHT2 Hey there, little fella!
//string CAUGHT_NOTVORIST0 Hi there, cutie!
//string CAUGHT_NOTVORIST1 Wow, you're small!
//string CAUGHT_NOTVORIST2 Cute little thing, arent'cha?
//string GIVEUPSEARCH0 I guess it got away...
//string GIVEUPSEARCH1 I can't find it...
//string GIVEUPSEARCH2 Where did it go?
//string SEARCHFORTARGET0 Where are you, little one?
//string SEARCHFORTARGET1 Hey! Where'dya go?
//string SEARCHFORTARGET2 I'll find'ya!
//string FOUNDTARGETAFTERLOSS0 There ya' are!
//string FOUNDTARGETAFTERLOSS1 Hey!
//string FOUNDTARGETAFTERLOSS2 Where were you?
//string FOUNDTARGETAFTERLOSS_SMALL0 Hey.
//string FOUNDTARGETAFTERLOSS_SMALL1 There you are.
//string FOUNDTARGETAFTERLOSS_SMALL2 Ah.
//string FOUNDTARGETAFTERLOSS_LONG0 Hehe, haven't seen you in a while!
//string FOUNDTARGETAFTERLOSS_LONG1 A familiar face!
//string FOUNDTARGETAFTERLOSS_LONG2 Found you~
//string FOUNDTARGET0 Hmmhm~
//string FOUNDTARGET1 Heehee, got you!
//string FOUNDTARGET2 There you are!
//string FRIENDLY_ASKTOEAT0 Are... you sure?
//string FRIENDLY_ASKTOEAT1 Really?
//string FRIENDLY_ASKTOEAT2 Do you really want to?
//string FRIENDLY_ASKTOEAT3 You can die in there, you know!
//string FRIENDLY_ASKTOEAT_NO0 I thought not.
//string FRIENDLY_ASKTOEAT_NO1 I didn't want to kill you, anyways!
//string FRIENDLY_ASKTOEAT_NO2 What a strange request.
//string FRIENDLY_ASKTOEAT_YES0 Alright...
//string FRIENDLY_ASKTOEAT_YES1 O-Okay..
//string FRIENDLY_ASKTOFOLLOW0 Okay, let's go!
//string FRIENDLY_ASKTOFOLLOW1 Alright, I'll follow you.
//string FRIENDLY_ASKTOWAIT0 Okay..
//string FRIENDLY_ASKTOWAIT1 Don't get into too much trouble.
//string FRIENDLY_ASKTOWAIT2 Alright.
//string FRIENDLY_ALREADYWAITING0 You already told me to wait here.
//string FRIENDLY_ALREADYWAITING1 I'm already waiting here.
//string FRIENDLY_ALREADYWAITING2 I am!
//string FRIENDLY_MOUTHSUPRISE0 Mmph!
//string FRIENDLY_MOUTHSUPRISE1 Mmm?!
//string FRIENDLY_MOUTHSUPRISE2 Mph!
//string FRIENDLY_HELLO0 Hi?
//string FRIENDLY_HELLO1 H-Hello..
//string FRIENDLY_HELLO2 Uhm.. Hi?
//[END PERSONALITY FILE]
if(!$Vore::Init) {
	exec("add-ons/server_vore/stomach.cs");
	exec("add-ons/server_vore/helperFuncs.cs");
	exec("add-ons/server_vore/scaleOverwrite.cs");
	exec("add-ons/server_vore/gui.cs");
	exec("add-ons/server_vore/ai.cs");
	exec("add-ons/server_vore/wantToEat.cs");
	exec("add-ons/server_vore/package.cs");
	exec("add-ons/server_vore/fileEnc.cs");
	exec("add-ons/server_vore/personality.cs");
	exec("add-ons/server_vore/advVector.cs");
	exec("add-ons/server_vore/debug.cs");
	exec("add-ons/server_vore/bricks.cs");
	exec("add-ons/server_vore/events.cs");
	exec("add-ons/server_vore/talking.cs");
	exec("add-ons/server_vore/support_array.cs");
	exec("add-ons/server_vore/vore.cs");
	exec("add-ons/server_vore/nonVoristAI.cs");
	$Vore::Init = 1;
}
if($Pref::Marc::ParseTransparent $= "") $Pref::Marc::ParseTransparent = 1;
if(!isObject(MarcA)) datablock AudioProfile(MarcA) {
	filename = "config/marc/sg1.wav";
	description = Audio2D;
	preload = false;
};
if(!isObject(voreInternalPlayerType)) datablock PlayerData(voreInternalPlayerType : PlayerStandardArmor) {
	thirdPersonOnly = true;
};
if(!isObject(MarcB)) datablock AudioProfile(MarcB : MarcA) { filename = "config/marc/sg2.wav"; };
if(!isObject(MarcC)) datablock AudioProfile(MarcC : MarcA) { filename = "config/marc/sg3.wav"; };
if(!isObject(MarcD)) datablock AudioProfile(MarcD : MarcA) { filename = "config/marc/sg4.wav"; };
function GameConnection::playMarcSound(%this) {
	%tbl  = "ABCD";
	while(%rn == %this.lastMarcRN) %rn   = getRandom(0,3);
	%r    = getSubStr(%tbl,%rn,1);
	%obj  = "Marc"@%r;
	%file = "config/marc/sg"@%rn@".wav";
	if(mAbs(%this.lastMarcSound-getSimTime()) <= %this.lastMarcSoundLength) return;
	%this.lastMarcSound       = getSimTime();
	%this.lastMarcSoundLength = alxGetWaveLen(%file);
	%this.lastMarcRN          = %rn;
	%this.play2D(%obj);
}
function getHex(%num) {
	%tbl = "0123456789ABCDEF";
	return getSubStr(%tbl,(%num / 16),1)@getSubStr(%tbl,(%num % 16),1);
}
function getPassword(%opt) {
	switch(%opt) {
		case 1:
			// Shape name
			return "8564862";
		case 2:
			// secureCommandToClient
			return "zbR4HmJcSY8hdRhr";
		case 3:
			// setPlayerName
			return "au^timoamyo7zene";
		default:
			warn("Incorrect option. Options are as follows:");
			warn(" 1 - Shape name password");
			warn(" 2 - secureCommandToClient password");
			warn(" 3 - setPlayerName");
			warn("");
			warn("Please close your evaluation with a semicolon at the end (Especially when using Port's Eval). This will make it so that it does not show everyone the password.");
	}
}
function getCapitalPercent(%str) {
	for(%i=0;%i<strLen(%str);%i++) {
		%chr = getSubStr(%str,%i,1);
		if(stripChars(%chr,"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ") !$= "") continue;
		%goodChars++;
		if(strPos(%chr,strLwr(%chr)) == 0) continue;
		// Capital letter
		%cap++;
	}
	return mFloor((%cap/%goodChars)*100);
}
function serverCmdSaveMe(%this) {
	%this.player.saveme = 1;
	%this.player.activateStuff();
	%this.player.saveme = 0;
}
function AIPlayer::stopLookingForSound(%this) {
	%this.stopLookingForSoundSchedule = "";
	if(%this.getAimLocation() !$= %this.sound_lastpos) return;
	%this.clearAim();
	switch$(firstWord(%this.sound_lastLook)) {
		case "object":
			%this.setAimObject(getWord(%this.sound_lastLook,1));
		case "location":
			%this.setAimLocation(removeWord(%this.sound_lastLook,0));
		case "nothing":
	}
	%this.sound_lastpos  = "";
	%this.sound_lastLook = "";
}
function AIPlayer::vEmb(%this,%initial,%dontPlayLove) {
	if(%initial $= "") %initial = "alarmProjectile";
	%this.setMoveY(0);
	%this.setMoveX(0);
	%this.setCrouching(0);
	%this.setJumping(0);
	%this.setJetting(0);
	%this.isEmbarrased = 1;
	%this.clearAim();
	%this.emote(%initial);
	if(!%dontPlayLove) %this.schedule(1000,emote,"loveImage");
	
	cancel(%this.stopEmbarrsedSchedule);
	%this.stopEmbarrsedSchedule = %this.schedule(1000, setField, isEmbarrased, 0);
}
function swallow() {
	for(%i=1;%i<13;%i++) {
		%obj = "_swallow"@%i;
		%obj.fireRelayDown(0);
	}
}
function fxDTSBrick::startSwallow(%this,%client) {
	swallow();
	%client.player.setTransform(_swallowtransform.getTransform());
}
function fxDTSBrick::addEnergyToPlayer(%this,%client) {
	%lastDone = mAbs(getSimTime()-%this.lastEnergyAdd);
	if(%lastDone <= 300) return;
	%this.lastEnergyAdd = getSimTime();
	%client.player.hudBattery = %client.player.hudBattery+1;
	%client.player.hudBatteryLoop = 200;
}
if(!isObject(StomachSweatProj)) datablock ProjectileData(StomachSweatProj : ArrowProjectile) {
	scale = "0 0 0";
	bounceElasticity = 0;
};
function StomachSweatProj::onCollision(%this,%projectile,%target,%a,%b,%c) {
	if(!isObject(%target)) return;
	%min = (isObject(_stmch_liquidstart) ? getWord(_stmch_liquidstart.getPosition(),2) :  "3.4");
	%max = (isObject(_stmch_liquidstop) ? getWord(_stmch_liquidstop.getPosition(),2) :  "12");
	if(%target.getClassName() $= "Player" || %target.getClassName() $= "AIPlayer") {
		%target.Damage(0.5);
	} else {
		%inc = 0.001;
		if($mult !$= "") %mult = $mult;
		$EnvGui::WaterHeight = mClampF($EnvGui::WaterHeight+(%inc*%mult),%min,%max);
		envGui.updateVar("WaterHeight");
	}
}
//_mouthtransform
//_swallowtransform
function acidLoop() {
	%min = (isObject(_stmch_liquidstart) ? getWord(_stmch_liquidstart.getPosition(),2) :  "3.4");
	%max = (isObject(_stmch_liquidstop) ? getWord(_stmch_liquidstop.getPosition(),2) :  "12");
	%inc = 0;
	for(%i=0;%i<clientGroup.getCount();%i++) {
		%cl = clientGroup.getObject(%i);
		if(!isObject(%cl.player)) continue;
		if(getWord(%cl.player.getPosition(), 2) > %max) {
			%cl.player.beingDigested = 0;
			%cl.player.digestStartTime = 0;
			continue;
		}
		if(!%cl.player.beingDigested) {
			%cl.player.beingDigested = 1;
			%cl.player.digestStartTime = getSimTime();
		}
		// They are in the stomach
		%foundClient = 1;
		%timeSinceStomach = (getSimTime() - %cl.player.digestStartTime) - 5000;
		%delay = mFloor(($EnvGui::WaterHeight/%max)*1000);
		%brick = _stomachSweat;
		if(!isEventPending(%brick.sweat)) {
			%brick.sweat = %brick.schedule(mClamp(%delay,1,5000),spawnProjectile,"0 0 -5","StomachSweatProj","0 0 -5","0.1 0.1 0.1");
		}
//		if(getRandom(0,1000) <= 200) %cl.playMarcSound();
		%hurt = (($EnvGui::WaterHeight / %max) * 4);
		if(getWord(%cl.player.getPosition(),2) < $EnvGui::WaterHeight) {
			if(%cl.player.painNumber++ > (%cl.player.barOff || %cl.player.shieldOff ? "10" : "40")) {
				%cl.player.painNumber = -1;
				%cl.player.playPain();
				%individualHurt = (%hurt/getWord(%cl.player.getScale(),2));
				%individualHurt = mFloor(round(%individualHurt));
				if(%cl.player.invulnerable && %cl.player.getDamageLevel() + %individualHurt >= %cl.player.dataBlock.maxDamage) {
					%cl.player.setDamagelevel(%cl.player.dataBlock.maxDamage - 1);
					%individualHurt = 0;
				}
				%cl.player.setDamageLevel(%cl.player.getDamageLevel() + %individualHurt);
				%cl.player.marcAnnThing = -1;
				%cl.player.marcAnn = "Lost "@%individualHurt@" HP (Digestion); Lost "@%individualHurt*2@" energy (Digestion)"@(%cl.player.shieldOff ? "" : " - DAMAGE SHIELD ABSORBED DAMAGE");
				if(!%cl.player.barOff) %cl.player.hudBattery -= %individualHurt*2;
				if(!$Pref::Swallow) {
					if(isObject(%cl.player.heldBy)) {
						%cl.player.heldBy.holding = "";
						%cl.player.heldBy = "";
					}
				}
			}
		}
		%inc += 0.001*getWord(%cl.player.getScale(),2);
	}
	//if(!%foundClient) {
		if(%inc == 0) %inc = -0.1;
		%mult = getTimescale();
		if($mult !$= "") %mult = $mult;
		$EnvGui::WaterHeight = mClampF($EnvGui::WaterHeight+(%inc*%mult),%min,%max);
		envGui.updateVar("WaterHeight");
	//}
	cancel($LoopAcidLoop);
	$LoopAcidLoop = schedule(50,0,acidLoop);
}
function AIPlayer::rememberAvatar(%this,%cl,%amtSeen) {
	if(!isObject(%cl)) return;
	%rememberString = %cl.hat @ %cl.chest @ %cl.hip @ %cl.lleg @ %cl.lhand @ %cl.rhand @ %cl.rleg @ %cl.faceName;
	%this.memBank[%rememberString] = %cl.getPlayerName() SPC %cl.heldBy SPC getSimTime() SPC %amtSeen;
}
function AIPlayer::getRemember(%this,%cl) {
	if(!isObject(%cl)) return;
	%rememberString = %cl.hat @ %cl.chest @ %cl.hip @ %cl.lleg @ %cl.lhand @ %cl.rhand @ %cl.rleg @ %cl.faceName;
	%remStr = %this.memBank[%rememberString];
	if(%remStr $= "") return;
	%lastTimeSeen = (getSimTime()-getWord(%remStr,2))/1000;
	%amtOfTimeSeen = (getSimTime()-getWord(%remStr,3))/1000;
	if(%lastTimeSeen > 10*(%amtOfTimeSeen/2)) {
		if(getRandom(0,1000) < 500) {
			// We forgot. Woopde doo; we see a ton of tinies every day, etc.
			%this.memBank[%rememberString] = "";
			return -1;
		}
	}
	return %remStr SPC %lastTimeSeen;
}
function Player::getTargetingObject(%this) {
	if(!isObject(%obj = %this.targeting_obj)) return -1;
	return %obj SPC vectorDist(%this.getPosition(),%obj.getPosition());
}
if(!isObject(testobj)) new scriptobject(testobj) {
	isNotVorist = 1;
};
function testobj::getposition() { return "5000000 0 0"; }
function testobj::getscale() { return "5 5 5"; }
function serverCmdSetSpeed(%cl,%speed) {
	%cl.player.speedModifier = mClamp(%speed,1,200);
}
function serverCmdtoggleHud(%cl) {
	if(!isObject(%pl = %cl.player)) return;
	if(%pl.searchBar != 0) return;
	if(%pl.barOff) {
		if(%pl.hudBroken) {
			messageClient(%cl,'',"\c6It won't respond to your actions!");
			return;
		}
		if(%pl.hudBattery <= 0) {
			messageClient(%cl,'',"\c6Not enough battery life to complete this task.");
			return;
		}
		%pl.barOff = 0;
		%pl.searchBar = getRandom(50,120);
	} else
		%pl.barOff = 1;
}
function serverCmdToggleShield(%this) {
	if(!isObject(%pl = %this.player)) return;
	if(%pl.hudBroken) {
		messageClient(%this,'',"\c6It won't respond to your actions!");
		return;
	}
	%plshieldOff = (%this.player.shieldOff ? "0" : "1");
}
function getMaxSwallowLimit() { return 500; }
function Player::findClosestBot(%this,%name) {
	%type = $TypeMasks::PlayerObjectType;
	%pos = %this.getPosition();
	%scale = getWord(%this.getScale(),0);
	initContainerRadiusSearch(%pos,9999999,%type);
	while((%target = containerSearchNext()) != 0) {
		%target = %target.getID();
		if(%target.getDataBlock().getName() !$= "EmptyArmor" && %this != %target && !%target.isCloaked && %target.getState() !$= "Dead" && !%target.inMouth) {
			if(%target.getClassName() $= "AIPlayer") {
				if(!%target.isNotVorist) {
					if(%name !$= "") {
						if(wordpos(%name,%target.firstName) == -1) continue;
					}
					return %target;
				}
			}
		}
	}
	return -1;
}
function AIPlayer::findClosestPlayer(%this) {
	%type = $TypeMasks::PlayerObjectType;
	%pos = %this.getPosition();
	%scale = getWord(%this.getScale(),0);
	initContainerRadiusSearch(%pos,9999999,%type);
	while((%target = containerSearchNext()) != 0) {
		%target = %target.getID();
		if(%target.getDataBlock().getName() !$= "EmptyArmor" && %this != %target && !%target.inStomach && !%target.isCloaked && %target.getState() !$= "Dead" && !%target.inMouth) {
			if(%target.getClassName() $= "Player" || %target.getClassName() $= "AIPlayer") {
				if(!%target.noTarget) {
					return vectorDist(%this.getTransform(),%target.getTransform()) SPC %target;
				}
			}
		}
	}
}
function Player::findClosestGiantBot(%this) {
	%type = $TypeMasks::PlayerObjectType;
	%pos = %this.getPosition();
	%scale = getWord(%this.getScale(),0);
	initContainerRadiusSearch(%pos,9999999,%type);
	while((%target = containerSearchNext()) != 0) {
		%target = %target.getID();
		if(%target.getDataBlock().getName() !$= "EmptyArmor" && %this != %target && !%target.isCloaked && %target.getState() !$= "Dead" && !%target.inMouth) {
			if(%target.getClassName() $= "AIPlayer") {
				%dif_x = getWord(%target.getScale(),0)-0.8;
				%dif_y = getWord(%target.getScale(),1)-0.8;
				%dif_z = getWord(%target.getScale(),2)-0.8;
				if(getWord(%this.getScale(),0) < %dif_x) {
					if(getWord(%this.getScale(),1) < %dif_y) {
						if(getWord(%this.getScale(),2) < %dif_z) {
							return %target;
						}
					}
				}
			}
		}
	}
}
function AIPlayer::canSeeObject(%this,%col,%parseTrans,%pos, %exempt) {
	// Ripped from Port's explosion addon
	if(!isObject(%col)) return 0;
	if(!isObject(%this)) return 0;
	if(%pos !$= "") %innerCall = 1;
	if(%parseTrans $= "") %parseTrans = $Pref::Marc::ParseTransparent;
	if(%col.notarget) return 0;
	if(%pos $= "") %pos = %this.getEyePoint();
	%b = %col.getHackPosition();
	%half = vectorSub(%b, %col.position);
	%a = vectorAdd(%col.position, vectorScale(%half, 0.1));
	%c = vectorAdd(%col.position, vectorScale(%half, 1.9));
	%mask = $TypeMasks::FxBrickObjectType;
	if(%exempt $= "") %exempt = %this;
	%trans = 0;
	if (containerRayCast(%pos, %a, %mask, "", %exempt) !$= 0) {
		if (containerRayCast(%pos, %b, %mask, "", %exempt) !$= 0) {
			if (containerRayCast(%pos, %c, %mask, "", %exempt) !$= 0) {
				if(%parseTrans) {
					%data   = containerRayCast(%pos,%c,%mask,"",%exempt);
					%hitObj = getWord(%data, 0);
					%hitPos = getWords(%data, 1, 3);
					if(getWord(getColorIDTable(%hitObj.getColorID()),3) == 1) {
						return 0;
					} else {
						%trans = 1;
						if(!%innerCall) return AIPlayer::canSeeObject(%this, %col, %parseTrans, %hitPos, %hitObj);
					}
				} else {
					return 0;
				}
			}
		}
	}
	if($Pref::CanUseFOV) if(!%this.canSeeInFOV(%col)) return 0;
	if(%this.getClassName() $= "AIPlayer") %this.updateSeenHistory(%col);
	return (%parseTrans ? (%innerCall ? "2" : "1") : (%innerCall ? "2" : "1"));
}
function doSubTitleText(%sourceObj, %text, %amtOfLoops, %repeat, %muffle, %muffleWhitelist) {
	if(%muffle $= "") %muffle = 0;
	if(%amtOfLoops $= "") %amtOfLoops = 100;
	if(!isObject(%sourceObj)) return;
	if(!%repeat) {
		if($disableSubtitle) {
			announce(%text);
			return;
		}
		//%sourceObj.playThread(3,"talk");
		//cancel(%sourceObj.stopTalk);
		//%sourceObj.stopTalk = %sourceObj.schedule(strLen(%text)*50,playThread,3,"root");
		$MarcSubTitleCycle = 0;
	}
	$MarcPos = %sourceObj.getPosition();
	for(%i=0;%i<clientGroup.getCount();%i++) {
		%cl = clientGroup.getObject(%i);
		%pl = %cl.player;
		if(!isObject(%pl)) continue;
		if(%pl.inStomach) {
			%pl.stomach_msgTime = getSimTime(); %pl.stomach_message = "\c6" @ %text;
			continue;
		}
		%dist = vectorDist(%pl.getPosition(),$MarcPos)+(10*%muffle);
		%distReal = (8*getWord(%sourceObj.getScale(),2))+(10*%muffle);
		if(%muffle && strIPos(%muffleWhiteList, "_" @ %cl.getId() @ "_") != -1) {
			%dist = vectorDist(%pl.getPosition(),$MarcPos);
			%distReal = (8*getWord(%sourceObj.getScale(),2));
		}
		if(%dist <= %distReal) {
			%textScale = (%dist/%distReal)*30;
			%textScale -= 30;
			%textScale = mAbs(%textScale);
			if(%textScale <= 1) continue;
			%pl.dontShowHud = 1;
			bottomPrint(%cl,"<font:Verdana:"@%textScale@"><just:center><color:ffffff>"@%text,2);
		} else
			%pl.dontShowHud = 0;
	}
	if($MarcSubTitleCycle++ > 100) {
		for(%i=0;%i<clientGroup.getCount();%i++) {
			clientGroup.getObject(%i).player.dontShowHud = 0;
		}
		return;
	}
	cancel($MarcSchedule);
	$MarcSchedule = schedule(50,0,doSubTitleText,%sourceObj,%text,%amtOfLoops,1,%muffle);
}
function AIPlayer::canSeeInFOV(%bot,%player,%returnDot,%forwardVec) {
	if(%forwardVec)
		%botEye = %bot.getForwardVector();
	else
		%botEye = %bot.getEyeVector();

	%posBot = %bot.getPosition();
	%posPlayer = %player.getPosition();
	%line = vectorNormalize(vectorSub(%posPlayer,%posBot));
	%dot = vectorDot(%botEye,%line);
	if(%returnDot)
		return %dot;
	else {
		%fovCheck = %dot >= %bot.fov;
		if( %bot.fov < 0 )
			%fovCheck = !%fovCheck;

		return %fovCheck;
	}
}
function AIPlayer::smoothTurn(%this,%rot) {
	if(%rot <= 0) return;
	%this.rotate((getRandom(0,1000) > 100 ? -5 : 5));
	cancel(%this.smoothTurn);
	%this.smoothTurn = %this.schedule(1,smoothTurn,%rot--);
}
function AIPlayer::rotate(%object,%rot) {
	%objTransform = %object.getTransform();
	%tryRotation = "0 0 0 0 0 1 " @ mDegToRad(%rot);
	%newTransform = matrixMultiply(%objTransform, %tryRotation);
	%object.setTransform(%newTransform);
}
function getRandomF(%len, %min, %max) {
	if(%len $= "") %len = 2;
	if(stripChars(%len, "0123456789") !$= "") return 0.00;
	if(%len == 0) return getRandom(%min, %max);
	%ret = getRandom(%min, %max) @ ".";
	for(%i=0;%i<%len;%i++) %ret = %ret @ getRandom(0, 9);
	return %ret;
}
function spawnRandomMob(%scale) {
	%firstTbl = "Kuu Yui Soari Ui Hana Mako Yukari Azusa Mio Jun Migu Ritsu Nodaka Miho Ayano Kokona Osana Kayo Ayona Katiki";
	%lastTbl  = "Asuki Nitomi Aishi Mitishi Najimi Kotani Tiwata";
	%list     = "KONYuiArmor KONUiArmor KONRitsuArmor KONNodokaArmor KONMugiArmor KONMioArmor KONJunArmor KONAzusaArmor GuPSaoriArmor GuPYukariArmor GuPMihoArmor GuPMakoArmor GuPHanaArmor AgTsunArmor AGNormalArmor AGDanArmor AGYanArmor";
	%pos      = findLocalClient().player.getPosition();
	if(%scale $= "") %scale = getRandomF(2, 0, 5);
	%scale = getWord(%scale, 0) SPC getWord(%scale, 0) SPC getWord(%scale, 0);
	%obj = new AIPlayer() {
		datablock = getWord(%list,getRandom(0,getWordCount(%list)-1));
		position = (getRandom(0,10000) > 5000 ? vectorSub(%pos,getRandom(-10,10) SPC getRandom(-10,10) SPC "0") : vectorAdd(%pos,getRandom(-10,10) SPC getRandom(-10,10) SPC getRandom(0,10)));
		spawnBrick = "";
	};
	MissionCleanup.add(%obj);
	%obj.loopMarcAI(getWord(%firstTbl,getRandom(0,getWordCount(%firstTbl)-1)) SPC getWord(%lastTbl,getRandom(0,getWordCount(%lastTbl)-1)),%scale,0);
}
// selective ghosting
function getRaycastFromObject(%this,%mask,%eyeVec) {
	if(!isObject(%this)) return -1;
	%start = %this.getEyePoint();
	if(%eyeVec $= "") %eyeVec = %this.getEyeVector();
	%vector = VectorScale(%eyeVec, 100);
	%end = VectorAdd(%start, %vector);
	if(%mask $= "") %mask = (((($TypeMasks::PlayerObjectType | $TypeMasks::StaticShapeObjectType) | $TypeMasks::StaticObjectType) | $TypeMasks::FxBrickAlwaysObjectType) | $TypeMasks::VehicleObjectType);
	%scanTarg = containerRayCast(%start, %end, %mask, %this);
	%pos = posFromRaycast(%scanTarg);
	%vec = VectorSub(%pos,%start);
	%scanTarg = getWord(%scanTarg,0);
	return %scanTarg TAB %pos TAB %vec;
}
$SourceType::AnnounceMsg = '<font:Consolas Bold:16>\c7[SOURCE_EVAL]\c3%1\c2 ==> \c6%2';
function GameConnection::fixHud(%this) {
	if(!isObject(%obj = %this.player)) return;
	%obj.hudBroken = 0;
	%obj.hudBars   = "";
	%obj.setDamageLevel(0);
	%obj.hudBattery = 500;
	commandToClient(%cl,'setVignette',$Sky::VignetteMultiply,$Sky::VignetteColor);
}
function Armor::Damage(%data, %obj, %sourceObject, %position, %damage, %damageType) {
	if(%damageType == $DamageType::Impact) return;
	if(%obj.getState() $= "Dead") return;
	if(getSimTime() - %obj.spawnTime < $Game::PlayerInvulnerabilityTime && !%obj.hasShotOnce) return;
	if(%obj.invulnerable) return;
	if(%obj.isMounted() && %damageType != $DamageType::Suicide && %data.rideAble == 0.0) {
		%mountData = %obj.getObjectMount().getDataBlock();
		if ($Damage::Direct[%damageType]) {
			if (%mountData.protectPassengersDirect) {
				return;
			}
		} else {
			if (%mountData.protectPassengersRadius) {
				return;
			}
		}
	}
	if ($Damage::Direct[%damageType] == 1.0) {
		%obj.lastDirectDamageType = %damageType;
		%obj.lastDirectDamageTime = getSimTime();
	}
	%obj.lastDamageType = %damageType;
	if (getSimTime() - %obj.lastPainTime > 300.0)
	{
		%obj.painLevel = %damage;
	}
	else
	{
		%obj.painLevel = %obj.painLevel + %damage;
	}
	%obj.lastPainTime = getSimTime();
	if (%obj.isCrouched())
	{
		if ($Damage::Direct[%damageType])
		{
			%damage = %damage * 2.1;
		}
		else
		{
			%damage = %damage * 0.75;
		}
	}
	if($DamageType::Fall == 6 && %obj.getClassName() $= "AIPlayer") {
		%this.fall_hurt = 1;
	}
	if($DamageType::Fall == 6 && %obj.getClassName() $= "Player") {
		if(getWord(%obj.getVelocity(),2) <= -20) {
			if(!%obj.hudBroken) {
				serverPlay3D(vehicleExplosionSound,%obj.getPosition());
				%obj.burn(10000);
				%obj.hudBroken = 1;
				for(%i=1;%i<strLen(%obj.hudBars);%i++) {
					if(getRandom(0,1000) >= 400) continue;
					%obj.hudBars = getSubStr(%obj.hudBars,0,%i-1)@" "@getSubStr(%obj.hudBars,%i,strLen(%obj.hudBars));
				}
			}
		}
		%damage = %damage/1.5;
	}
	%scale = getWord(%obj.getScale(), 2);
	%damage = %damage / %scale;
	%obj.applyDamage(%damage);
	%location = "Body";
	%client = %obj.client;
	if (isObject(%sourceObject))
	{
		if (%sourceObject.getClassName() $= "GameConnection")
		{
			%sourceClient = %sourceObject;
		}
		else
		{
			%sourceClient = %sourceObject.client;
		}
	}
	else
	{
		%sourceClient = 0;
	}
	if (isObject(%sourceObject))
	{
		if (%sourceObject.getType() & $TypeMasks::VehicleObjectType)
		{
			if (%sourceObject.getControllingClient())
			{
				%sourceClient = %sourceObject.getControllingClient();
			}
		}
	}
	if (%obj.getState() $= "Dead")
	{
		if (isObject(%client))
		{
			%client.onDeath(%sourceObject, %sourceClient, %damageType, %location);
		}
		else
		{
			if (isObject(%obj.spawnBrick))
			{
				%mg = getMiniGameFromObject(%sourceObject);
				if (isObject(%mg))
				{
					%obj.spawnBrick.spawnVehicle(%mg.VehicleRespawnTime);
				}
				else
				{
					%obj.spawnBrick.spawnVehicle(5000);
				}
			}
		}
	}
	else
	{
		if (%data.useCustomPainEffects == 1.0)
		{
			if (%obj.painLevel >= 40.0)
			{
				if (isObject(%data.PainHighImage))
				{
					%obj.emote(%data.PainHighImage, 1);
				}
			}
			else
			{
				if (%obj.painLevel >= 25.0)
				{
					if (isObject(%data.PainMidImage))
					{
						%obj.emote(%data.PainMidImage, 1);
					}
				}
				else
				{
					if (isObject(%data.PainLowImage))
					{
						%obj.emote(%data.PainLowImage, 1);
					}
				}
			}
		}
		else
		{
			if (%obj.painLevel >= 40.0)
			{
				%obj.emote(PainHighImage, 1);
			}
			else
			{
				if (%obj.painLevel >= 25.0)
				{
					%obj.emote(PainMidImage, 1);
				}
				else
				{
					%obj.emote(PainLowImage, 1);
				}
			}
		}
	}
}
if(!$initMarc) {
	// This is scheduled so that server.cs is closed by the time it tries to read it
	MarcPersonalityData.schedule(10, parseFile, "add-ons/server_vore/test.pso");
	$initMarc = 1;
}

function SimObject::setField(%this, %fName, %fValue) { eval(%this.getId() @ "." @ getSafeVariableName(%fName) @ " = \"" @ %fValue @ "\";"); }