Page 1 of 1

UGLY CRASH

Posted: Thu Apr 12, 2007 1:24 am
by darksmaster923
okay, after an enemy dies the game crashes after i added some attribute changes to the enemy script. i deleted them, even changed the scripts with an older one, but it still crashes
LOG

Initializing Game Shell...
--------------------------------------
--- Reality Factory 0.75C ---
--- For more Information, visit: ---
--- http://www.realityfactory.info ---
--------------------------------------

Parsed RealityFactory.ini file

Genesis3D Initialized

*INFO* VFS detected (not encrypted)...

Initializing Camera Manager...
Initializing User Input Subsystem...
Initializing Audio Manager Subsystem...
Initializing CD Audio Manager Subsystem...
Initializing Midi Audio Manager Subsystem...
Initializing RF Menu Manager Subsystem...
Initializing Network...
Loading Menu.ini...
Parsing Menu.ini...
Loading Character.ini...
Initializing Menu
Initializing Collision Manager Subsystem...
Initializing Network Manager Subsystem...
Initializing AVIFile Video Subsystem...
Launching Reality Factory Game Shell...
Launching Preview from Editor, bypassing Genesis3D Logo for DEBUG purposes ONLY...
Previewing Level as SinglePlayer Client...
Entering CRFMenu::ProcessMenu
Entering Windows Message Loop, Rendering Game Menu
Entering CRFMenu::ProcessMenu
Entering Windows Message Loop, Rendering Game Menu
Initializing Level: beach attack.bsp
Configuring Camera Defaults...
Initializing Entity Registry...
Initializing Terrain Manager...
Initializing Effects Manager...
Initializing Actor Manager...
Parsing Environment Setup Entity...
Initializing Model Manager...
Creating Player Avatar...
Loading Player Avatar...
Initializing HUD...
Initializing Damage Subsystem...
Initializing FixedCamera Manager Subsystem...
Loading Player Configuration...
Loading Attributes and Player Configuration from PlayerSetup.ini
Loading Environmental Audio
Parsing PlayerSetup Entity
Initialize Player Data
Parsing EnvironmentSetup Entity
Initializing Automatic Door Manager Subsystem...
Initializing Moving Platform Manager Subsystem...
Initializing Teleport Manager Subsystem...
Initializing MorphingField Effects Manager Subsystem...
Initializing 3d AudioSource Manager Subsystem...
Initializing Particle Effects Manager Subsystem...
Initializing Static Entity Props Subsystem...
Initializing Static Mesh Subsystem...
Initializing Soundtrack Toggle Subsystem...
Initializing Streaming Audio Manager Subsystem...
Initializing Video Texture Manager Subsystem...
Initializing Corona Manager Subsystem...
Initializing Dynamic Light Manager Subsystem...
Initializing ElectricBolt Manager Subsystem...
Initializing Procedural Texture Manager Subsystem...
Initializing Path Database...
Initializing Path Followers...
Initializing Rain Effects Manager...
Initializing Spout Effects Manager...
Initializing ActorSpout Effects Manager...
Initializing Floating Particle Effects Manager...
Initializing eChaos Effects Manager...
Initializing Flame Effects Manager...
Initializing ScriptPoint Manager Subsystem...
Initializing Pawn Manager Subsystem...
Initializing ChangeAttribute Manager Subsystem...
Initializing Countdown Manager Subsystem...
Initializing Trigger Manager Subsystem...
Initializing LogicHandler Subsystem...
Initializing Message Manager Subsystem...
Initializing Effect Manager Subsystem...
Initializing Weapon Manager Subsystem...
Initializing FirePoint Manager Subsystem...
Initializing Flipbook Manager Subsystem...
Initializing AreaCheck Manager Subsystem...
Initializing Foliage Manager Subsystem...
Initializing Tree Manager Subsystem...
Initializing PWXImage Manager Subsystem...
Initializing Shadow Manager Subsystem...
Initializing Decal Manager Subsystem...
Initializing WallDecal Manager Subsystem...
Initializing LevelController Manager Subsystem...
Initializing Attribute Manager Subsystem...
Initializing Explosion Manager Subsystem...
Initializing Explosion Subsystem...
Initializing ChangeLevel Manager Subsystem...
Initializing ScreenShake Subsystem...
Initializing ViewSwitch Subsystem...
Initializing Inventory Subsystem...
Initializing Liquid Subsystem...
Initializing Overlay Subsystem...
Initializing TextureMorph Subsystem...
Initializing CutScene Subsystem...
Initializing ActorMaterial Subsystem...
Initializing Armour Subsystem...
Initializing LiftBelt Manager...
Initializing CDSpotlight Manager...
Initializing CurvedSurfaces Manager...
Initializing Fonts...
Preparing to Launch Game...
Runtime Script Error for SkyDome script
scripts\Sky2.s:Start:8-Field sky04 not found

CRFMenu::GameLoop() - Setup and Run Level

*WARNING* OpenRFFile: file open attempt failed on type '2', file 'media\video\'

CRFMenu::GameLevel() - Entering Inner Game Loop

Posted: Thu Apr 12, 2007 3:29 am
by BLACK_PHOENIX
i believe its not the scripts but something in your video folder.

i noticed that thats from the editor preveiw. you should try running it from the rf exe. or check whats gone wrong in your media/videos folder.

Posted: Thu Apr 12, 2007 4:20 am
by darksmaster923
well, ran from rf.exe
same ol log cept for some parts

Initializing Game Shell...
--------------------------------------
--- Reality Factory 0.75C ---
--- For more Information, visit: ---
--- http://www.realityfactory.info ---
--------------------------------------

Parsed RealityFactory.ini file

Genesis3D Initialized

*INFO* VFS detected (not encrypted)...

Initializing Camera Manager...
Initializing User Input Subsystem...
Initializing Audio Manager Subsystem...
Initializing CD Audio Manager Subsystem...
Initializing Midi Audio Manager Subsystem...
Initializing RF Menu Manager Subsystem...
Initializing Network...
Loading Menu.ini...
Parsing Menu.ini...
Loading Character.ini...
Initializing Menu
Initializing Collision Manager Subsystem...
Initializing Network Manager Subsystem...
Initializing AVIFile Video Subsystem...
Launching Reality Factory Game Shell...
Entering CRFMenu::DoMenu()
Entering CRFMenu::ProcessMenu
Entering Windows Message Loop, Rendering Game Menu
Entering CRFMenu::ProcessMenu
Entering Windows Message Loop, Rendering Game Menu
Entering CRFMenu::ProcessMenu
Entering Windows Message Loop, Rendering Game Menu
Initializing Level: BA-ARMORY.bsp
Configuring Camera Defaults...
Initializing Entity Registry...
Initializing Terrain Manager...
Initializing Effects Manager...
Initializing Actor Manager...
Parsing Environment Setup Entity...
Initializing Model Manager...
Creating Player Avatar...
Loading Player Avatar...
Initializing HUD...
Initializing Damage Subsystem...
Initializing FixedCamera Manager Subsystem...
Loading Player Configuration...
Loading Attributes and Player Configuration from PlayerSetup.ini
Loading Environmental Audio
Parsing PlayerSetup Entity
Initialize Player Data
Parsing EnvironmentSetup Entity
Initializing Automatic Door Manager Subsystem...
Initializing Moving Platform Manager Subsystem...
Initializing Teleport Manager Subsystem...
Initializing MorphingField Effects Manager Subsystem...
Initializing 3d AudioSource Manager Subsystem...
Initializing Particle Effects Manager Subsystem...
Initializing Static Entity Props Subsystem...
Initializing Static Mesh Subsystem...
Initializing Soundtrack Toggle Subsystem...
Initializing Streaming Audio Manager Subsystem...
Initializing Video Texture Manager Subsystem...
Initializing Corona Manager Subsystem...
Initializing Dynamic Light Manager Subsystem...
Initializing ElectricBolt Manager Subsystem...
Initializing Procedural Texture Manager Subsystem...
Initializing Path Database...
Initializing Path Followers...
Initializing Rain Effects Manager...
Initializing Spout Effects Manager...
Initializing ActorSpout Effects Manager...
Initializing Floating Particle Effects Manager...
Initializing eChaos Effects Manager...
Initializing Flame Effects Manager...
Initializing ScriptPoint Manager Subsystem...
Initializing Pawn Manager Subsystem...
Initializing ChangeAttribute Manager Subsystem...
Initializing Countdown Manager Subsystem...
Initializing Trigger Manager Subsystem...
Initializing LogicHandler Subsystem...
Initializing Message Manager Subsystem...
Initializing Effect Manager Subsystem...
Initializing Weapon Manager Subsystem...
Initializing FirePoint Manager Subsystem...
Initializing Flipbook Manager Subsystem...
Initializing AreaCheck Manager Subsystem...
Initializing Foliage Manager Subsystem...
Initializing Tree Manager Subsystem...
Initializing PWXImage Manager Subsystem...
Initializing Shadow Manager Subsystem...
Initializing Decal Manager Subsystem...
Initializing WallDecal Manager Subsystem...
Initializing LevelController Manager Subsystem...
Initializing Attribute Manager Subsystem...
Initializing Explosion Manager Subsystem...
Initializing Explosion Subsystem...
Initializing ChangeLevel Manager Subsystem...
Initializing ScreenShake Subsystem...
Initializing ViewSwitch Subsystem...
Initializing Inventory Subsystem...
Initializing Liquid Subsystem...
Initializing Overlay Subsystem...
Initializing TextureMorph Subsystem...
Initializing CutScene Subsystem...
Initializing ActorMaterial Subsystem...
Initializing Armour Subsystem...
Initializing LiftBelt Manager...
Initializing CDSpotlight Manager...
Initializing CurvedSurfaces Manager...
Initializing Fonts...
Preparing to Launch Game...
CRFMenu::GameLoop() - Setup and Run Level

*WARNING* OpenRFFile: file open attempt failed on type '2', file 'media\video\'

CRFMenu::GameLevel() - Entering Inner Game Loop
CRFMenu::GameLevel() - ChangeLevel Triggered, begin Changelevel Process...
Initializing Level: beach attack.bsp
Configuring Camera Defaults...
Initializing Entity Registry...
Initializing Terrain Manager...
Initializing Effects Manager...
Initializing Actor Manager...
Parsing Environment Setup Entity...
Initializing Model Manager...
Creating Player Avatar...
Loading Player Avatar...
Initializing HUD...
Initializing Damage Subsystem...
Initializing FixedCamera Manager Subsystem...
Loading Player Configuration...
Loading Attributes and Player Configuration from PlayerSetup.ini
Loading Environmental Audio
Parsing PlayerSetup Entity
Initialize Player Data
Parsing EnvironmentSetup Entity
Initializing Automatic Door Manager Subsystem...
Initializing Moving Platform Manager Subsystem...
Initializing Teleport Manager Subsystem...
Initializing MorphingField Effects Manager Subsystem...
Initializing 3d AudioSource Manager Subsystem...
Initializing Particle Effects Manager Subsystem...
Initializing Static Entity Props Subsystem...
Initializing Static Mesh Subsystem...
Initializing Soundtrack Toggle Subsystem...
Initializing Streaming Audio Manager Subsystem...
Initializing Video Texture Manager Subsystem...
Initializing Corona Manager Subsystem...
Initializing Dynamic Light Manager Subsystem...
Initializing ElectricBolt Manager Subsystem...
Initializing Procedural Texture Manager Subsystem...
Initializing Path Database...
Initializing Path Followers...
Initializing Rain Effects Manager...
Initializing Spout Effects Manager...
Initializing ActorSpout Effects Manager...
Initializing Floating Particle Effects Manager...
Initializing eChaos Effects Manager...
Initializing Flame Effects Manager...
Initializing ScriptPoint Manager Subsystem...
Initializing Pawn Manager Subsystem...
Initializing ChangeAttribute Manager Subsystem...
Initializing Countdown Manager Subsystem...
Initializing Trigger Manager Subsystem...
Initializing LogicHandler Subsystem...
Initializing Message Manager Subsystem...
Initializing Effect Manager Subsystem...
Initializing Weapon Manager Subsystem...
Initializing FirePoint Manager Subsystem...
Initializing Flipbook Manager Subsystem...
Initializing AreaCheck Manager Subsystem...
Initializing Foliage Manager Subsystem...
Initializing Tree Manager Subsystem...
Initializing PWXImage Manager Subsystem...
Initializing Shadow Manager Subsystem...
Initializing Decal Manager Subsystem...
Initializing WallDecal Manager Subsystem...
Initializing LevelController Manager Subsystem...
Initializing Attribute Manager Subsystem...
Initializing Explosion Manager Subsystem...
Initializing Explosion Subsystem...
Initializing ChangeLevel Manager Subsystem...
Initializing ScreenShake Subsystem...
Initializing ViewSwitch Subsystem...
Initializing Inventory Subsystem...
Initializing Liquid Subsystem...
Initializing Overlay Subsystem...
Initializing TextureMorph Subsystem...
Initializing CutScene Subsystem...
Initializing ActorMaterial Subsystem...
Initializing Armour Subsystem...
Initializing LiftBelt Manager...
Initializing CDSpotlight Manager...
Initializing CurvedSurfaces Manager...
Initializing Fonts...
Preparing to Launch Game...

*WARNING* OpenRFFile: file open attempt failed on type '2', file 'media\video\'

Runtime Script Error for SkyDome script
scripts\Sky2.s:Start:8-Field sky04 not found

And i dont do anything in videos folder....

Posted: Thu Apr 12, 2007 11:41 am
by Juutis
The problem seems to be in your SkyDome script
Runtime Script Error for SkyDome script
scripts\Sky2.s:Start:8-Field sky04 not found

Posted: Thu Apr 12, 2007 1:08 pm
by Jay
You may have written 'sky04' without the ""s (i mean like sky04 instead of "sky04")

or just post your skydome script...

Posted: Thu Apr 12, 2007 10:51 pm
by darksmaster923
i added quotation marks, but it still crashes.

Posted: Fri Apr 13, 2007 2:23 am
by darksmaster923
after much testing, it seems as if it crashes once i go a certain distance to an enemy and he tries to melee me
HIS SCRIPT

Code: Select all

{
	SCALE				[1.4]		// scale of actor
	GROUP				[enemy]		// name of monster group
	BOXWIDTH			[25]		// width and depth of bounding box
	BOXHEIGHT			[100]		// hieght of box
	HOSTILEPLAYER			[true]		// hostile to player
	HOSTILEDIFFERENT		[true]		// hostile to different Pawn group
	HOSTILESAME			[false]		// hostile to same Pawn group
	HOSTILETOGROUP			[guy]		// hostile to this group
	HEALTHATTRIBUTE			[enemy_health]		// name of health attribute
	HEALTH				[100]		// initial amount of health
	HEAR				[1]
	SIGHTDIST			[3500]		// max distance monster can see at idle
	ALERTSIGHTDIST			[3500]		// max distance monster can see when alert
	FOV				[180]		// field of view in degrees
	ATTACKFOV			[180]		// attacking field of view
	YAWSPEED			[360]		// speed of rotation in deg/sec
	DAMAGEATTRIBUTE			[playerhealth]		// attribute damaged by attack
	ALERTTRIGGER			[AlertG]		// name of alert trigger
	SPAWNPOINT			[spawn_enemy]
	SPAWNPOINT2			[spawn_enemy2]

	// define the type of monster this will be

	ATTACKTYPE			[missile]		// type of attack - melee or missile
	PATROL			[true]		// false - ambush or true - patrol
	PC				[0]		// make any visible point the next point

	// idling and turning

	STAND				[idle]		// idle animation
	TURNL				[idle]		// turn left animation
	TURNR				[idle]		// turn right animation

	// when in pain

	PAIN				[pain]		// pain animations
	PAIN1				[pain]
	PAIN2				[pain]
	PAIN3				[pain]
	PAINPERCENT			[50]			// percentage of time pain is shown
	PAINSOUND			[uuh.wav]		// sounds played when in pain
	PAINSOUND1			[injury1.wav]
	PAINSOUND2			[injury.wav]
	PAINSOUND3			[injury1.wav]

	// when dying

	DIE				[die]		// dying animations
	DIE1				[die]
	DIE2				[die]
	DIE3				[die]
	DIEHOLD			[10]			// time corpse still appears
	DIEFADE			[10]			// fadeout time of corpse
	DIESOUND			[death1.wav]		// sounds played when dying
	DIESOUND1			[die1.wav]
	DIESOUND2			[speak/imdieing.wav]
	DIESOUND3			[uooula.wav]

	// when running to attack

	RUN				[run]			// running animation
	RUNSPEED			[250]			// average run speed
	RUNSOUNDDELAY		[2]			// delay between making sounds when running to attack
	RUNSOUND			[breath.wav]		// sound played while running to attack

	// when walking while patroling

	WALK				[walk]			// walking animation
	WALKSPEED			[200]			// average walking speed
	WALKSOUND			[breath.wav]		// walking sound

	// the projectile attack mode

	MISSILEATTACK		[shoot]	// missile attacking animations
	MISSILEATTACK1		[shoot]
	MISSILEATTACK2		[shoot]
	STRAFEATTACKLEFT	[StrafeShootL]
	STRAFEATTACKRIGHT	[StrafeShootR]
	SHOOTUP				[shoot2]
	SHOOTDOWN			[shoot1]
	FIREDELAY			[0.3]				// delay after animation starts before projectile launch
	FIREDELAY1			[0.3]
	FIREDELAY2			[0.3]
	MISSILESOUND			[bad.wav]			// sounds played when shooting
	MISSILESOUND1		[bad.wav]
	MISSILESOUND2		[shoot1.wav]
	ACCURACY		[10]
	ARMORWEAR		[10]
	MISSILERANGE			[3400]				// max distance to start missile attack
	PROJECTILE			[bad_shell]			// projectile name
	BLOOD				[blood]				// blood proj
	FIREBONE			[BONE08]			// projectile launch bone
	OFFSETX			[0]				// launch offsets
	OFFSETY			[0]
	OFFSETZ			[30]
	OFFSETXMAX		[10]				// unaccuracy offsets
	OFFSETYMAX		[20]
	ATTACKDELAY			[0.3]				// time between shots
	SKILL				[10]				// skill level 1 to 10

	// the melee attack mode

	MELEEATTACK			[punch]	// melee attacking animations
	MELEEATTACK1		[punch2]
	MELEEATTACK2		[punch]
	MELEESOUND			[uuh.wav]		// sounds played when melee attacking
	MELEESOUND1			[uuh.wav]
	MELEESOUND2			[uuh.wav]
	MELEERANGE			[55]			// max distance to start melee attack
	//MAXMELEERANGE		[100]			// max distance for melee mode
	MINMELEEDAMAGE		[10]			// minimum amount of damage per melee attack
	MAXMELEEDAMAGE		[50]			// maximum amount of damage per melee attack
	MELEEDELAY			[1]			// number of seconds between melee damages
	MELEEDAMAGESOUND		[melee2.wav]		// sound played when damage is done

	// search for enemy

	LOSTTIME			[20]	// time to search for enemy before giving up
	POINTRADIUS			[20]	// radius from point when considered there

	// obstacle avoidance forces for jumping

	FORCEUP			[50]	// obstacle avoidance jump speed
	FORCEFORWARD		[50]	// obstacle avoidance forward speed
	FORCESIDE			[50]	// obstacle avoidance sideways speed

	// local variables - do not change

	
	RUNFUNC			[monster_run_start]		// monster run to attack function
	MISSILEFUNC			[monster_missile_start]		// monster missile function
	MELEEFUNC			[monster_melee_start]		// monster melee function
	LOSTFUNC			[monster_lost_target_start]	// monster lost target function

	AS_NONE			[0]
	AS_MELEE			[1]
	AS_MISSILE			[2]
	AS_STRAIGHT			[3]
	attack_delay			[0]
	melee_time			[0]
	lost_time			[0]
	back_up				[false]
	back_time			[0]
	left_time				[0]
	back_flag			[false]
	fire_delay			[0]
	skill_time			[0]
	attack_state			[0]
	run_sound_time			[0]
	missile_sound			[NULL]

	// spawn pawn and do setup work

	Spawn[ ()
	{
		Console(true);
		Scale(SCALE);	// scale the actor
		if(BOXWIDTH > 0)
		{
			BoxWidth(BOXWIDTH*SCALE);	// set bounding box width/depth
			BoxHeight(BOXHEIGHT*SCALE);
		}
		AttributeOrder(HEALTHATTRIBUTE, HEALTH, "Death");	// give monster health
		HostilePlayer(HOSTILEPLAYER);						// set who monster is hostile to
		HostileSame(HOSTILESAME);
		HostileDifferent(HOSTILEDIFFERENT);
		TargetGroup(HOSTILETOGROUP);
		SetFOV(160,"Bip01 Head");							// set field of view
		SetGroup(GROUP);									// assign a group to belong to
		FindTargetOrder(SIGHTDIST, "FoundTarget", DAMAGEATTRIBUTE);	// seen a target to chase
		AddPainOrder("IdlePain", 100);							// show pain and trigger alert
		AvoidOrder("Avoidance"); 								// avoid obstacles
		AddTriggerOrder("IdleToAlert", ALERTTRIGGER, 0);	// go to alert when triggered								// give the monster a big gun
		RotateToPoint(STAND, YAWSPEED, false, ""); 			// go to point if any specified
		MoveToPoint(WALK, WALKSPEED*SCALE, WALKSOUND);
		if(PATROL = true)
		{
			NewOrder("Patrol");
		}
		else
		{
			NewOrder("Idle");
		}
	} ]

	DieSpawn[ ()
	{
		Console(true);
		if(BOXWIDTH > 0)
		{
			BoxWidth(BOXWIDTH*SCALE);	// set bounding box width/depth
			BoxHeight(BOXHEIGHT*SCALE);
		}
		AttributeOrder(HEALTHATTRIBUTE, HEALTH, "Death");	// give monster health
		HostilePlayer(HOSTILEPLAYER);						// set who monster is hostile to
		HostileSame(HOSTILESAME);
		HostileDifferent(HOSTILEDIFFERENT);
		TargetGroup(HOSTILETOGROUP);
		SetFOV(160,"Bip01 Head");							// set field of view
		SetGroup(GROUP);									// assign a group to belong to
		FindTargetOrder(SIGHTDIST, "FoundTarget", DAMAGEATTRIBUTE);	// seen a target to chase
		AddPainOrder("IdlePain", 100);							// show pain and trigger alert
		AvoidOrder("Avoidance"); 								// avoid obstacles
		AddTriggerOrder("IdleToAlert", ALERTTRIGGER, 0);	// go to alert when triggered								// give the monster a big gun
		RotateToPoint(STAND, YAWSPEED, false, ""); 			// go to point if any specified
		MoveToPoint(WALK, WALKSPEED*SCALE, WALKSOUND);
		if(PATROL = true)
		{
			NewOrder("Patrol");
		}
		else
		{
			NewOrder("Idle");
		}
	} ]
	// avoid objects when doing a MoveToPoint

	Avoidance[ ()
	{
		if(random(1,10)<3)	// backup and move sideways sometimes
		{
			MoveBackward(WALK, WALKSPEED*SCALE, (WALKSPEED/2)*SCALE, "");
			MoveRight(WALK, WALKSPEED*SCALE, (WALKSPEED/2)*SCALE, "");
		}
		else
		{
			if(random(1,20)<14
			{
				Jump(RUN, FORCEUP*SCALE, true, "");
				if(random(1,10)<6)
				{
					Move("", FORCEFORWARD*SCALE, (FORCEFORWARD/2)*SCALE, 0, 90, 0, "");
				}
				else
				{
					Move("", FORCEFORWARD*SCALE, (FORCEFORWARD/2)*SCALE, 0, -90, 0, "");
				}
			}
			else
			{	
				BoxHeight(BOXHEIGHT*SCALE/2);
			}
		}
		Return();
	} ]

	// idle in place waiting for something to happen

	Idle[ ()
	{
		PlayAnimation(STAND, true, "");
		RestartOrder();
	} ]	

	// walk the beat from point to point

	Patrol[ ()
	{
		NextPoint();
		RotateMoveToPoint(WALK, YAWSPEED, WALKSPEED*SCALE, false, WALKSOUND);
		MoveToPoint(WALK, WALKSPEED*SCALE, WALKSOUND);
		FindTargetOrder(4000, "FoundTarget", "playerhealth" );
		AddPainOrder("IdlePain", 100);
		RestartOrder();
	} ]

	CheckForPoints[()
	{
		self.ThinkTime=0; // Process every frame
		if(self.point_vis)
		{
			// point is visible - go to high level for nav and targetting
			HighLevel("Patrol");
			return 0;
		}
		else
		{
			// Point not visible - cycle points
			PC=PC+1; // Increment point counter variable
			if(PC > 100)
			{
				// Point count has exceeded max - set to 0. (Max 100)
				PC=1;
			}
		NewPoint("SP" # Integer(PC)); // Set new point
		}
	}]

	// show pain at idle then trigger to alert

	IdlePain[ ()
	{
	LowLevel("Hurted");
	} ]	


	Hurted[ ()
	{
		if(GetLastBoneHit() = "BIP01 HEAD")
		{
			PlaySound("speak/imdieing.wav",1000);
			AddExplosion("blood2",GetLastBoneHit(),0,50,0);
			AddExplosion("blood",GetLastBoneHit(),0,0,0);
			HighLevel("Death");
		}
		else
		{
			Animate(PAIN);
			SetTargetPoint(0,0,25);
			AddExplosion("blood",GetLastBoneHit(),0,0,0);
			FireProjectile("blood",GetLastBoneHit(),0,0,0,DAMAGEATTRIBUTE);
			PlaySound("injury1.wav", 500);
			HighLevel("FoundTarget");
		}
	} ]
	// start shifting from idle to alert

	IdleToAlert[ ()
	{
		NewOrder("FoundTarget");
	} ]

	// look around at alert looking for enemy

	Alert[ ()
	{
		NewOrder("FoundTarget");
	} ]	

	// show pain at alert

	AlertPain[ ()
	{
		NewOrder("FoundTarget");
	} ]	

	// timed out at alert

	AlertToIdle[ ()
	{
		NewOrder("FoundTarget");
	} ]

	// found a target to attack

	FoundTarget[ ()
	{
		SetFOV(270,"Bip01 Head");	// set field of view
		LowLevel(RUNFUNC);		// attack functions are low level
	} ]

	// lost target while attacking so go back to idle again

	LostTarget[ ()
	{
		FindTargetOrder(SIGHTDIST, "FoundTarget", DAMAGEATTRIBUTE);	// seen a target to chase
		FindPointOrder("Patrol");							// do point stuff
		if(PATROL = true)
		{
			NewOrder("Patrol");
		}
		else
		{
			NewOrder("CheckForPoints");
		}
	} ]

	// you died

	Death[ ()
	{
		AddExplosion("blood",FIREBONE,0,0,0);
		AddExplosion("blood2",FIREBONE,0,-25,0);
		AnimateStop(DIE,DIEHOLD, "die.wav");
		if(random(1,10) < 6)
		{			
                	TeleportToPoint(SPAWNPOINT,0,0,0);
		}
		else
		{
                	TeleportToPoint(SPAWNPOINT2,0,0,0);
		}
        	SetAttribute(HEALTHATTRIBUTE,HEALTH); 
		NewOrder("DieSpawn");
	}]

	// Low level attack routines

	// Start of run to attack

	monster_run_start[ ()
	{
		UpdateEnemyVis(true); 			//always aware of player position
		UpdateTarget();
		Animate(RUN);				// play run animation
		self.ThinkTime = 0;			// start thinking on next frame
		self.think = "monster_run";		// go to run attack routine
		self.ideal_yaw = enemy_yaw;		// set direction to run
		self.yaw_speed = YAWSPEED;		// set rotation speed
		back_up = false;				// initialize obstacle avoidance
		attack_state = AS_NONE;			// not attacking yet
		melee_time = time;
		run_sound_time = time;
	} ]

	// run to enemy to attack

	monster_run[ ()
	{
		self.ThinkTime = 0;
		if(self.health<=0)
		{
			HighLevel("Death"); 			// dead
			return 0;
		}
		if((self.in_pain = true) and (random(1,100)<PAINPERCENT))
		{
			self.think = "monster_run_pain_start"; 	// in pain
			return 0;
		}
		if(EnemyExist(DAMAGEATTRIBUTE) < 3)
		{
			HighLevel("LostTarget"); 			// enemy is gone or dead
			return 0;
		}
		if(enemy_vis = false)
		{
			self.think = LOSTFUNC; 			// lost sight of enemy
			lost_time = time + LOSTTIME;
			return 0;
		}
		if(run_sound_time < time)
		{
			if(random(1,10)>7)
			{
				PlaySound("speak/wehavehostiles.wav",1000);
				run_sound_time = time + RUNSOUNDDELAY;
				PlaySound(RUNSOUND);
			}
		}
		ai_run(random((RUNSPEED-2)*SCALE,(RUNSPEED+2)*SCALE)); // run toward enemy
	} ]

	// start of pain while running

	monster_run_pain_start[ ()
	{
		if(GetLastBoneHit() = "BIP01 HEAD")
		{
			AddExplosion("blood2",GetLastBoneHit(),0,-50,0);
			AddExplosion("blood",GetLastBoneHit(),0,0,0);
			HighLevel("Death");
		}
		else 		
		{
			switch(random(1,4))
			{
				case 1
				{
					Animate(PAIN);
					SetTargetPoint(0,0,25);
					AddExplosion("blood",GetLastBoneHit(),0,0,0);
					PlaySound("injury1.wav", 500);
				}
				case 2
				{
					Animate(PAIN1);
					SetTargetPoint(0,0,25);
					AddExplosion("blood2",GetLastBoneHit(),0,0,0);
					PlaySound("speak/backup.wav", 1000);
				}
				case 3
				{
					Animate(PAIN2);
					SetTargetPoint(0,0,25);
					AddExplosion("blood",GetLastBoneHit(),0,0,0);
					PlaySound("injury.wav", 500);
				}
				case 4
				{
					Animate(PAIN3);
					SetTargetPoint(0,0,25);
					AddExplosion("blood2",GetLastBoneHit(),0,0,0);
					PlaySound("uuh.wav", 500);
				}
			}
		}
		SetHoldAtEnd(true);					// set to stop at animation end
		self.ThinkTime = 0;
		self.think = "monster_run_pain";
	} ]

	// wait for animation to stop

	monster_run_pain[ ()
	{
		self.ThinkTime = 0;
		if(self.animate_at_end = true) 		// wait for end of animation
		{
			self.think = "monster_run_start"; 	// start running again
			SetHoldAtEnd(false); 		// remove animation stop
			self.ThinkTime = 0;
		}
	} ]

	// start of lost sight of enemy routine

	monster_lost_target_start[ ()
	{
		Animate(RUN); 				// play run animation
		self.ThinkTime = 0;			// start thinking on next frame
		self.think = "monster_lost_target";
		run_sound_time = time + RUNSOUNDDELAY;
	} ]

	// go to last known location of enemy

	monster_lost_target[ ()
	{
		self.ThinkTime = 0;
		if(lost_time<time)
		{
			HighLevel("LostTarget"); 			// timed out while looking
			return 0;
		}
		self.ThinkTime = 0;
		if(self.health<=0)
		{
			HighLevel("Death");	 // died
			return 0;
		}
		if(HEAR<=0)
		{
			SetFOV(360, "Bip01 Head");
		}
		if((self.in_pain = true) and (random(1,100)<PAINPERCENT))
		{
			self.think = "monster_lost_pain_start"; 	// in pain
			return 0;
		}
		if(EnemyExist(DAMAGEATTRIBUTE) < 3)
		{
			HighLevel("LostTarget"); 			// enemy died or was removed
			return 0;
		}
		if(enemy_vis = true)
		{
			if(random(1,10)>5)
			{
				PlaySound("speak/attack.wav", 1000);
			}
			else
			{
				PlaySound("speak/wehavehostiles.wav", 1000);
			}
			self.think = "monster_run_start"; 		// seen again so run to attack
			self.ThinkTime = 0;
			return 0;
		} 
		if(run_sound_time < time)
		{
			if(random(1,10)>7)
			{
				run_sound_time = time + RUNSOUNDDELAY;
				PlaySound(RUNSOUND);
			}
		}
		if((enemy_range>POINTRADIUS) and (RUNSPEED > 0)) // get close to last known location
		{
			walk_movetogoal(random((RUNSPEED-2)*SCALE,(RUNSPEED+2)*SCALE));
		} 
		else
		{
			HighLevel("LostTarget"); // can't find at last known location
			return 0;
		}
	} ]

	// start of showing pain while searching

	monster_lost_pain_start[ ()
	{
		if(GetLastBoneHit() = "BIP01 HEAD")
		{
			AddExplosion("blood2",GetLastBoneHit(),0,50,0);
			AddExplosion("blood",GetLastBoneHit(),0,0,0);
			switch(random(1,4))
			{
				case 1
				{
					PlaySound(DIESOUND, 2000);
				}
				case 2
				{
					PlaySound(DIESOUND1, 2000);
				}
				case 3
				{
					PlaySound(DIESOUND2, 2000);
				}
				case 1
				{
					PlaySound(DIESOUND3, 2000);
				}
			}
			HighLevel("Death");
		}
		else 		
		{
			switch(random(1,4))
			{
				case 1
				{
					Animate(PAIN);
					SetTargetPoint(0,0,25);
					AddExplosion("blood",GetLastBoneHit(),0,0,0);
					PlaySound("injury.wav", 500);
				}
				case 2
				{
					Animate(PAIN1);
					SetTargetPoint(0,0,25);
					AddExplosion("blood2",GetLastBoneHit(),0,0,0);
					PlaySound("injury1.wav", 500);
				}
				case 3
				{
					Animate(PAIN2);
					SetTargetPoint(0,0,25);
					AddExplosion("blood",GetLastBoneHit(),0,0,0);
					PlaySound("uuh.wav", 500);
				}
				case 4
				{
					Animate(PAIN3);
					SetTargetPoint(0,0,25);
					AddExplosion("blood2",GetLastBoneHit(),0,0,0);
					PlaySound("uooul.wav", 500);
				}
			}
		}
		SetHoldAtEnd(true);	// set to stop at end
		self.ThinkTime = 0;
		self.think = "monster_lost_pain";
	} ]

	// wait till animation is done

	monster_lost_pain[ ()
	{
		self.ThinkTime = 0;
		if(self.animate_at_end = true)			 // animation done
		{
			self.think = "monster_lost_target_start"; 	// go back to finding target
			SetHoldAtEnd(false); 			// remove stop at end
			self.ThinkTime = 0;
		}
	} ]
	
	CheckForPoints[()
	{
		self.ThinkTime=0; // Process every frame
		if(self.point_vis)	
		{
			// point is visible - go to high level for nav and targetting
			HighLevel("LostTarget");
			return 0;
		}
		else
		{
			// Point not visible - cycle points
			PC=PC+1; // Increment point counter variable
			if(PC > 110)
			{
				// Point count has exceeded max - set to 0. (Max 110)
				PC=1;
			}
			NextPoint();
		}
	}]
	
	// start of missile attack

	monster_missile_start[ ()
	{
		switch(random(1,3)) // play one of 3 missile animations
		{
			case 1
			{
				Animate(MISSILEATTACK);
				fire_delay = time + FIREDELAY; // set firing delay
				PlaySound("bad.wav", 500);
			}
			case 2
			{
				Animate(MISSILEATTACK1);
				fire_delay = time + FIREDELAY1; // set firing delay
				PlaySound("bad.wav", 500);
			}
			case 3
			{
				Animate(STRAFEATTACKLEFT);
				if(DifficultyLevel = 1)
				{
					fire_delay = time + FIREDELAY2 + 10; // set firing delay
				}
				if(DifficultyLevel = 2)
				{
					fire_delay = time + FIREDELAY2 + 5; // set firing delay
				}
				if(DifficultyLevel = 3)
				{
					fire_delay = time + FIREDELAY2; // set firing delay
				}
				ForceLeft(50);
				PlaySound("bad.wav", 500);
			}
		}
		UpdateEnemyVis(true); 			//always aware of player position
		UpdateTarget();
		self.ideal_yaw = enemy_yaw;		// set direction to run
		SetHoldAtEnd(true);
		self.ThinkTime = 0.3;
		self.think = "monster_missile";
		skill_time = time + (SKILL*0.1);		// calculate next update time
		attack_delay = time + ATTACKDELAY;	// delay until next shot
	} ]

	// attack target with projectile

	monster_missile[ ()
	{
		self.ThinkTime = 0.3;
		if(self.health<=0)
		{
			HighLevel("Death");
			return 0;
		}
		if((self.in_pain = true) and (random(1,100)<PAINPERCENT))
		{
			self.think = "monster_missile_pain_start"; 	// in pain
			SetHoldAtEnd(false);
			return 0;
		}
		exist = EnemyExist(DAMAGEATTRIBUTE);
		if(exist < 2)
		{
			SetHoldAtEnd(false);
			HighLevel("LostTarget"); 			// enemy is dead and gone
			return 0;
		}
		if(exist = 2)
		{
			SetHoldAtEnd(false);
			HighLevel("LostTarget"); 			// enemy is dead but body remains
			return 0;
		}
		if(enemy_vis = false)
		{
			self.think = LOSTFUNC; 			// lost sight of enemy
			lost_time = time + LOSTTIME;
			SetHoldAtEnd(false);
			return 0;
		}
		if(self.enemy_Y>(self.current_Y+10))
		{
			Animate(SHOOTUP);
			if(random(1,20) < 3)
			{
				ForceRight(100);
			}
			else
			{
				ForceLeft(100);
			}
			FireProjectile("bad_shell", "BIP 01", 0, 0, 25, "playerhealth");
			AddExplosion("Muzzleflash2","BIP 01 R HAND",0,0,0);
			PlaySound("bad.wav", 500);
			SetHoldAtEnd(false);
			self.ThinkTime = 0.3;
			checkplayer();
		}
		if(self.enemy_Y<(self.current_Y-10))
		{
			Animate(SHOOTDOWN);
			if(random(1,20) < 3)
			{
				ForceRight(100);
			}
			else
			{
				ForceLeft(100);
			}
			FireProjectile(PROJECTILE, FIREBONE, OFFSETX, OFFSETY, OFFSETZ, DAMAGEATTRIBUTE);
			AddExplosion("Muzzleflash2","BIP01 R HAND",0,0,0);
			PlaySound("bad.wav", 500);
			SetHoldAtEnd(false);
			self.ThinkTime = 0.3;
			checkplayer();
		}
		if(enemy_range>MISSILERANGE)
		{
			if(random(1,20)<3)
			{
				if(DifficultyLevel = 1)
				{
					Animate(STRAFEATTACKRIGHT);
					ForceRight(100);
				}
				if(DifficultyLevel = 2)
				{
					Animate(STRAFEATTACKRIGHT);
					ForceRight(150);
				}
				if(DifficultyLevel = 3)
				{
					Animate(STRAFEATTACKRIGHT);
					ForceRight(200);
				}
			}
			else
			{
				if(DifficultyLevel = 1)
				{
				Animate(STRAFEATTACKLEFT);			
				ForceLeft(100);
				}
				if(DifficultyLevel = 2)
				{
				Animate(STRAFEATTACKLEFT);			
				ForceLeft(150);
				}
				if(DifficultyLevel = 3)
				{
				Animate(STRAFEATTACKLEFT);			
				ForceLeft(200);
				}
			}
			if(DifficultyLevel = 1)
			{
				fire_delay = time + FIREDELAY + random(1,20); 
			}
			if(DifficultyLevel = 2)
			{
				fire_delay = time + FIREDELAY + random(1,10); 
			}
			if(DifficultyLevel = 3)
			{
				fire_delay = time + FIREDELAY; 
			}
			FireProjectile(PROJECTILE, FIREBONE, OFFSETX, OFFSETY, OFFSETZ, DAMAGEATTRIBUTE);
			PlaySound("bad.wav", 500);
			AddExplosion("Muzzleflash2","BIP01 R HAND",0,0,0);
			checkplayer();
			self.think = RUNFUNC; 			// too far away so run toward
			SetHoldAtEnd(false);
			return 0;
		}
		if(skill_time<time) 				// update according to skill level
		{
			UpdateTarget();				// update target location
			skill_time = time + (SKILL*0);
			ai_face();				// face enemy while attacking
		}

		if(fire_delay<time) 				// delay after animation starts before firing
		{
			if(random(1,10) < 5)
			{
				ForceRight(10);
			}
			else
			{
				ForceLeft(10);
			}
			FireProjectile(PROJECTILE, FIREBONE, OFFSETX, OFFSETY, OFFSETZ, DAMAGEATTRIBUTE);
			fire_delay = time + 1000; 			// set delay well ahead so it is ignored
			AddExplosion("Muzzleflash2","BIP01 R HAND",0,0,0);
			PlaySound("bad.wav", 500);
		}
		if(self.animate_at_end = true)
		{
			if(attack_delay < time)
			{
				//self.think = RUNFUNC; 		// no
				self.think = "monster_missile_start"; 
				SetHoldAtEnd(false);
				self.ThinkTime = 0;
			}
		}
	} ]
		
	// start of showing pain

	monster_missile_pain_start[ ()
	{
		if(GetLastBoneHit() = "BIP01 HEAD")
		{
			switch(random(1,4))
			{
				case 1
				{
					PlaySound(DIESOUND, 2000);
				}
				case 2
				{
					PlaySound(DIESOUND1, 2000);
				}
				case 3
				{
					PlaySound(DIESOUND2, 2000);
				}
				case 1
				{
					PlaySound(DIESOUND3, 2000);
				}
			}
			AddExplosion("blood2",GetLastBoneHit(),0,50,0);
			AddExplosion("blood",GetLastBoneHit(),0,0,0);
			HighLevel("Death");
		}
		else
		{
			switch(random(1,4)) // play one of 4 pain animations
			{
				case 1
				{
					Animate(PAIN);
					SetTargetPoint(0,-10000,-10000);
					AddExplosion("blood",GetLastBoneHit(),0,0,0);
					PlaySound("injury1.wav", 500);
				}
				case 2
				{
					Animate(PAIN1);
					SetTargetPoint(0,-10000,-10000);
					PlaySound("speak/backup.wav", 500);
				}
				case 3
				{
					Animate(PAIN2);
					SetTargetPoint(0,-10000,-10000);
					AddExplosion("blood",GetLastBoneHit(),0,0,0);
					PlaySound("uooul.wav", 500);
				}
				case 4
				{
					Animate(PAIN3);
					SetTargetPoint(0,-10000,-10000);
					AddExplosion("blood2",GetLastBoneHit(),0,0,0);
					PlaySound("uooula.wav", 500);
				}
			}
		}
		SetHoldAtEnd(true);	// set to stop at end
		self.ThinkTime = 0;
		self.think = "monster_missile_pain";
	} ]

	// wait until animation is done

	monster_missile_pain[ ()
	{
		self.ThinkTime = 0;
		if(self.animate_at_end = true) 			// animation is done
		{
			self.think = "monster_missile_start"; 	// go back to missile attack
			SetHoldAtEnd(false);
			self.ThinkTime = 0;
		}
	} ]

	// start of melee attack

	monster_melee_start[ ()
	{
		switch(random(1,3)) 	// play one of 3 melee animations
		{
			case 1
			{
				Animate(MELEEATTACK);
			}
			case 2
			{
				Animate(MELEEATTACK1);
			}
			case 3
			{
				Animate(MELEEATTACK2);
			}
		}
		SetHoldAtEnd(true);			// set to stop at end
		self.ThinkTime = 0.1;
		self.think = "monster_melee";
	} ]

	// melee attack

	monster_melee[ ()
	{
		self.ThinkTime = 0;
		if(self.health<=0)
		{
			PlaySound("die1.wav", 500);
			HighLevel("Death"); 	// in pain
			return 0;
		}
		if((self.in_pain = true) and (random(1,100)<PAINPERCENT))
		{
			SetHoldAtEnd(false);
			self.think = "monster_melee_pain_start"; 		// in pain
			return 0.1;
		}
		exist = EnemyExist(DAMAGEATTRIBUTE); 			// see if target is around
		if(exist < 2)
		{
			SetHoldAtEnd(false);
			HighLevel("LostTarget"); 				// enemy is dead and gone
			return 0;
		}
		if(exist = 2)
		{
			SetHoldAtEnd(false);
			HighLevel("DeadTarget"); 			// enemy is dead but body remains
			return 0;
		}
		if(enemy_vis = false)
		{
			SetHoldAtEnd(false);
			self.think = LOSTFUNC; 				// lost sight of enemy
			lost_time = time + LOSTTIME;
			return 0;
		}
		if(enemy_range>(MELEERANGE*SCALE))
		{
			SetHoldAtEnd(false);
			self.think = RUNFUNC; 				// too far away so run toward
			return 0;
		}
		ai_face();						// face enemy while attacking
		if(self.animate_at_end = true) 				// animation is done
		{
			SetHoldAtEnd(false);
			switch(random(1,3)) 				// play one of 3 melee animations
			{
				case 1
				{
					Animate(MELEEATTACK);
				}
				case 2
				{
					Animate(MELEEATTACK1);
				}	
				case 3
				{
					Animate(MELEEATTACK2);
				}
			}
			SetHoldAtEnd(true);									// set to stop at end
		}
		if(time>melee_time) 							// if time then damage
		{
			damage = random(MINMELEEDAMAGE, MAXMELEEDAMAGE); 	// get damage amount
			Damage(damage, DAMAGEATTRIBUTE); 				// damage target
			melee_time = time + MELEEDELAY; 				// reset time until next damage
		}
	} ]

	// start of showing pain

	monster_melee_pain_start[ ()
	{
		if(GetLastBoneHit() = "BIP01 HEAD")
		{
			AddExplosion("blood2",GetLastBoneHit(),0,50,0);
			AddExplosion("blood",GetLastBoneHit(),0,0,0);
			HighLevel("Death");
		}
		else 		
		{
			switch(random(1,4))
			{
				case 1
				{
					Animate(PAIN);
					SetTargetPoint(0,-10000,-10000);
					AddExplosion("blood",GetLastBoneHit(),0,0,0);
					FireProjectile(BLOOD, FIREBONE, OFFSETX, OFFSETY, OFFSETZ, DAMAGEATTRIBUTE);
					PlaySound("injury.wav", 500);
				}
				case 2
				{
					Animate(PAIN1);
					SetTargetPoint(0,-10000,-10000);
					FireProjectile(BLOOD, FIREBONE, OFFSETX, OFFSETY, OFFSETZ, DAMAGEATTRIBUTE);
					PlaySound("injury1.wav", 500);
				}
				case 3
				{
					Animate(PAIN2);
					SetTargetPoint(0,-10000,-10000);
					AddExplosion("blood",GetLastBoneHit(),0,0,0);
					FireProjectile(BLOOD, FIREBONE, OFFSETX, OFFSETY, OFFSETZ, DAMAGEATTRIBUTE);
					PlaySound("uuh.wav", 500);
				}
				case 4
				{
					Animate(PAIN3);
					SetTargetPoint(0,-10000,-10000);
					AddExplosion("blood2",GetLastBoneHit(),0,0,0);
					FireProjectile(BLOOD, FIREBONE, OFFSETX, OFFSETY, OFFSETZ, DAMAGEATTRIBUTE);
					PlaySound("die1.wav", 500);
				}
			}
		}
		SetHoldAtEnd(true);	// set to stop at end
		self.ThinkTime = 0.1;
		self.think = "monster_melee_pain";
	} ]

	// wait until animation is done

	monster_melee_pain[ ()
	{
		self.ThinkTime = 0.1;
		if(self.animate_at_end = true) 		// animation is done
		{
			self.think = "monster_melee_start"; // go back to melee attack
			SetHoldAtEnd(false);
			self.ThinkTime = 0.1;
			melee_time = time + MELEEDELAY; // reset attack deley
		}
	} ]

	// basic AI routines

	// run toward enemy and see if you are ready to attack

	ai_run[ (dist)
	{
		if (attack_state = AS_MELEE) 			// do melee attack
		{
			ai_run_melee();
		}
		if (attack_state = AS_MISSILE) 			// do missile attack
		{
			ai_run_missile();
		}

		attack_state = AS_NONE;

		if (CheckAnyAttack()) 				// check if you can start the actual attack
		{
			return 0;
		}
		if(RUNSPEED > 0)
		{
			walk_movetogoal(dist); 			// else move toward the enemy
		}
	} ]

	// check if ready to do actual attacking

	CheckAnyAttack[ ()
	{
		if(enemy_range<MELEERANGE)
		{
			if(enemy_range<(MELEERANGE*SCALE)) 		// inside melee range
			{
				attack_state = AS_MELEE; 		// do a melee attack
				return true;
			}
			return false;
		}

		if(enemy_range<MISSILERANGE)
		{
			if(attack_delay>time)
			{
				return false;
			}
			if(enemy_range<MISSILERANGE) 
			{
				attack_state = AS_MISSILE; 		// do a missile attack
				return true;
			}
		}
		return false;
	} ]

	// missile attack setup

	ai_run_missile[ ()
	{
		ai_face();
		if(FacingIdeal()) 				// got close enough
		{
			self.think = MISSILEFUNC;	// start missile attack
			attack_state = AS_STRAIGHT;
			UpdateTarget();
			skill_time = time + (SKILL*0.1);
		}
	} ]

	// melee attack setup

	ai_run_melee[ ()
	{
		ai_face(); 			// turn to face target
		if(FacingIdeal()) 			// got close enough
		{
			self.think = MELEEFUNC;	// start melee attack
			self.attack_state = AS_STRAIGHT;
		}
	} ]

	// face enemy

	ai_face[ ()
	{
		self.ideal_yaw = enemy_yaw;
		ChangeYaw(); // rotate to face enemy
	} ]

	// use walkmove to naviagte to enemy

	walk_movetogoal[ (dist)
	{
		if(IsFalling = true)
		{
			return 0;	// don't move while falling
		} 
		if(dist < 0)
		{
			return 0;
		}
		if(back_up = false)
		{
			ai_face();				// turn to face enemy
			if(FacingIdeal())
			{
				if(walkmove(self.current_yaw, dist) = true)
				{
					return 0;			// can move in current direction
				}
				else
				{
					if(random(1,10)<3)	// backup and move sideways
					{
						back_up = true;
						back_time = time + 0.5;
						back_flag = false;
						return 0;
					}
					else 
					{ 
						ForceUp(FORCEUP*SCALE);	// jump up, forward and to side
						ForceForward(FORCEFORWARD*SCALE);
						if(random(1,10)<6)
						{
							ForceRight(FORCESIDE*SCALE);
						}
						else
						{
							ForceLeft(FORCESIDE*SCALE);
						} 
					} 
				} 
			}
		}
		else
		{
			if(back_flag = false) 		// go backward 1/2 sec
			{
				if(back_time > time)
				{
					walkmove((self.current_yaw-(180*0.0174532925199433)), dist);
					return 0;
				}
				else
				{
					back_time = time + 0.5;
					back_flag = true;
				}
			}
			if(back_time > time) 		// go sideways 1/2 sec
			{
				walkmove((self.current_yaw-(90*0.0174532925199433)), dist);
				return 0;
			}
			back_up = false;
		}
	} ]

	// check if nearly facing enemy

	FacingIdeal[ ()
	{
		selfangle = self.current_yaw/0.0174532925199433; 	// your direction in degrees
		idealangle = self.ideal_yaw/0.0174532925199433;	// his direction in degrees
		delta = selfangle - idealangle; 			// difference in directions
		if (delta > -20 and delta < 20) 			// within 20 degrees is close enough
		{
			return true;
		}
		return false;
	} ]

	checkplayer[ ()
	{
		if(self.target_name = "Player")
		{
			if(GetAttribute("armor", "Player") > 0)
			{
				ModifyAttribute("armor", -5, "Player" );
				ModifyAttribute("playerhealth", 5, "Player" );
			}
		}
	} ]

}


Posted: Fri Apr 13, 2007 6:39 am
by darksmaster923
OMG YES!!!!! I FOUND THE PROBLEM!!!!!! It was a messed up LOD mesh. w00tage. im sooo happy