Page 1 of 1

script reader error

Posted: Thu Jun 28, 2007 8:46 pm
by darksmaster923
sup all, i was testing my script, but i had a script reader error. can anyone help me?
CODE

Code: Select all

{
	// Allied Bot Script
	// Please Note that WEAPON3 IS THE SNIPING WEAPON OF THE BOT!

	// ===========================================================================
	// VARIABLES
	// ===========================================================================

	SCALE			[1.4]		// Set the scale of the actor(Relative)
	FOV			[150]		// Field of View aka FOV
	RUNSPEED		[300]		// How fast the bot runs
	WALKSPEED		[200]
	FIRSTPOINT		[NULL]
	SPAWNPOINT		[spawn_good]
	SPAWNPOINT2		[spawn_good2]
	GROUP			[guy]

	//Death
	DIEHOLD			[4]
	
	//Health
	HEALTH			[100]
	HEALTHATTRIBUTE		[playerhealth]
	DAMAGEATTRIBUTE		[enemy_health]

	//Lost
	LOSTTIME		[10]
	SEARCHTIME		[5]

	//Animations
	Idle			[idle]
	Reload			[reload]
	Walk			[walk]
	Run			[run]
	Pain			[pain]
	Shoot			[shoot]
	Shootup			[shoot1]
	Shootdown		[shoot2]
	ShootStrafeRight	[ShootstrafeR]
	ShootStrafeLeft		[ShootstrafeL]
	DIE			[die]
	DIE2			[die2]

	//Weapons
	WEAPON1			[M16_bot]
	WEAP1MAG		[30]
	WEAPON2			[FAMAS_bot]
	WEAP2MAG		[25]
	WEAPON3			[AWP_BOT]	// Sniper Weapon
	WEAP3MAG		[10]
	WEAPON4			[MP7_BOT]
	WEAP4MAG		[30]
	WEAPON5			[ump_bot]
	WEAP5MAG		[25]

	CURRENTWEAP		[NULL]
	ATTACKRANGE		[3000]
	SIGHTRANGE		[3400]
	RELOADTIME		[2]
	BULLET			[bad_shell]
	FIREBONE		[BIP01]
	WEAPON			[-1]

	//Sounds
	Runsound		[breath.wav]
	Shootsound		[good.wav]
	Diesound		[speak/imdieing.wav]
	Diesound2		[death1.wav]
	Reloadsound		[weapon/rifle_reload.wav]
	

	//Functions
	DEATHORDER		[Death]
	PAINORDER		[hurted]
	ALERTORDER		[Alert]
	AVOIDORDER		[Avoid]
	FOUNDORDER		[FoundTarget]
	RUNORDER		[FollowTarget]
	LOSTORDER		[SearchTarget]
	lost_time		[0]
	exist			[0]

	// ===================================================================
	// ORDERS
	// ===================================================================

	Spawn[ ()
	{
		Console(true);
		AttributeOrder(HEALTHATTRIBUTE, HEALTH, DEATHORDER);	// Sets HEALTH order
		Scale(SCALE);			// Scales the actor to the Var SCALE
		SetFOV(FOV);			// Sets FOV
		AvoidOrder(AVOIDORDER);		// Avoid obsticles
		AddPainOrder(PAINORDER, 75 );	// If the bot is hurted
		FIRSTPOINT = self.point_name;
		PlayAnimation(Idle, false, "");
		switch(random(1,5))		// lets bot choose between 5 weapons
		{
			case 1
			{
				SetWeapon(WEAPON1);
				CURRENTWEAP = WEAPON1;
				WEAPON = 1;			// Weapon Number. Used in Attack cmds.
			}
			case 2
			{
				SetWeapon(WEAPON2);
				CURRENTWEAP = WEAPON2;
				WEAPON = 2;			// Weapon Number. Used in Attack cmds.
			}
			case 3
			{
				SetWeapon(WEAPON3);		// Sets Sniping Weapon
				CURRENTWEAP = WEAPON3;
				WEAPON = 3;			// Weapon Number. Used in Attack cmds.
			}
			case 4
			{
				SetWeapon(WEAPON4);
				CURRENTWEAP = WEAPON4;
				WEAPON = 4;			// Weapon Number. Used in Attack cmds.
			}
			case 5
			{
				SetWeapon(WEAPON5);
				CURRENTWEAP = WEAPON5;
				WEAPON = 5;			// Weapon Number. Used in Attack cmds.
			}
		}
		if(random(1,10) < 5)
		{
			NewOrder("Patrol");
		}
		else
		{
			FindPointOrder("Patrol");
		}
	} ]

	Avoid[ ()
	{
		if(random(1,10) < 5)
		{
			MoveForward(Run, RUNSPEED, 100, Runsound);		// Runs forward
			MoveRight(Run, RUNSPEED, 100, Runsound );
			if(random(1,10) < 5)
			{
				SetFOV(360);
				FindPointOrder("Patrol");
			}
		}
		else
		{
			MoveForward(Run, RUNSPEED, 100, Runsound);		// Run forward
			MoveLeft(Run, RUNSPEED, 100, Runsound );
			if(random(1,10) < 5)
			{
				SetFOV(360);
				FindPointOrder("Patrol");
			}
		}
		Return();
	} ]	

	Patrol[ ()
	{
		SetFOV(FOV);
		AvoidOrder(AVOIDORDER);
		AddPainOrder(PAINORDER,100 );
		FindTargetOrder(SIGHTRANGE, FOUNDORDER, DAMAGEATTRIBUTE );
		RotateMoveToPoint(Run, RUNSPEED, RUNSPEED ,false, Runsound );	// Rotates to script point
		MoveToPoint(Run, RUNSPEED, Runsound );				// moces to script point
		NextPoint();
		RestartOrder();
	} ]

	IdlePain[ ()
	{
		LowLevel(PAINORDER);
	} ]

	hurted[ ()
	{
		if(GetLastBoneHit() = "BIP01 HEAD")			// if headshot
		{
			PlaySound(Diesound2,1000);
			AddExplosion("blood2",GetLastBoneHit(),0,50,0);
			AddExplosion("blood",GetLastBoneHit(),0,0,0);
			HighLevel(DEATHORDER);
		}
		else
		{
			Animate(PAIN);
			SetTargetPoint(0,0,25);
			AddExplosion("blood",GetLastBoneHit(),0,0,0);	// makes gore effect
			PlaySound(Diesound, 500);
			HighLevel(FOUNDORDER);
		}
	} ]	
	
	FoundTarget[ ()
	{
		SetFOV(270,"Bip01 Head");	// set field of view
		LowLevel(RUNORDER);		// attack functions are low level
	} ]

	FollowTarget[ ()
	{
		UpdateEnemyVis();
		UpdateTarget();
		Animate(Run);	
		self.think = "Target";		// 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;
	} ]

	Target[ ()
	{
		if(self.health<=0)
		{
			HighLevel(DEATHORDER); 			// dead
			return 0;
		}
		if((self.in_pain = true) and (random(1,100)<PAINPERCENT))
		{
			self.think = PAINORDER; 		// in pain
			return 0;
		}
		if(EnemyExist(DAMAGEATTRIBUTE) < 3)
		{
			HighLevel("LostTarget"); 		// enemy is gone or dead
			return 0;
		}
		if(enemy_vis = false)
		{
			self.think = "LostTarget"; 		// 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 + 1;
				PlaySound(RUNSOUND);
			}
		}
		ai_run(random((RUNSPEED-2)*SCALE,(RUNSPEED+2)*SCALE)); // run toward enemy
	} ]

	LostTarget[ ()
	{
		FindTargetOrder(SIGHTDIST, "FoundTarget", DAMAGEATTRIBUTE);	// seen a target to chase
		FindPointOrder("Patrol");					// moves to point
		NewOrder("Patrol");
	} ]

	Death[ ()
	{
		AddExplosion("blood",FIREBONE,0,0,0);
		AddExplosion("blood2",FIREBONE,0,25,0);
		AnimateStop(DIE,DIEHOLD, DIESOUND);
		ModifyAttribute("terr", 1, "Player");
		if(random(1,10) < 6)
		{			
                	TeleportToPoint(SPAWNPOINT,0,0,0);
		}
		else
		{			
                	TeleportToPoint(SPAWNPOINT2,0,0,0);
		}
        	SetAttribute(HEALTHATTRIBUTE,HEALTH); 
		NewOrder("DieSpawn");
	} ]
		
	AttackStart[ ()
	{
		Animate(SHOOT); 			// play shoot attack animation
		SetHoldAtEnd(true);
		self.ThinkTime = 0;
		UpdateTarget();				// update target location
		self.think = "Shoot";
	} ]

	// attack target with projectile

	Shoot[ ()
	{	
		if(self.health<=0)
		{
			SetHoldAtEnd(false);
			HighLevel(DEATHORDER); 	// dead
			return 0;
		}
		exist = EnemyExist(DAMAGEATTRIBUTE);
		if(self.in_pain = true)
		{
			if(GetLastBoneHit() = "BIP01 HEAD")
			{
				PlaySound(Diesound2,1000);
				AddExplosion("blood2",GetLastBoneHit(),0,50,0);
				AddExplosion("blood",GetLastBoneHit(),0,0,0);
				HighLevel(DEATHORDER);
			}
			else
			{
				Animate(PAIN);
				SetTargetPoint(0,0,25);
				AddExplosion("blood",GetLastBoneHit(),0,0,0);	// makes gore effect
				PlaySound(Diesound, 500);
				return 0;
			}
		}
		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(self.enemy_vis = false)
		{
			self.think = LOSTORDER; 	// lost sight of enemy
			lost_time = self.time + LOSTTIME;
			SetHoldAtEnd(false);
			return 0;
		}
		if(self.enemy_range>ATTACKRANGE)
		{
			self.think = RUNORDER; 	// too far away so run toward
			SetHoldAtEnd(false);
			return 0;
		}
		else
		{		
			UpdateEnemyVis();
			UpdateTarget();
			LookAtPawn(self.target_name,0);
			PlaySound(Shootsound);
			FireProjectile(BULLET, FIREBONE, 0, 0, 0, DAMAGEATTRIBUTE);
			if(random(1,10) < 6)
			{
				ForceLeft(random(1,50));
				ForceUp(30);
				ForceBackward(random(1,50));
			}
			else
			{
				ForceRight(random(1,50));
				ForceUp(30);
				ForceForward(random(1,50));
			}
		}
	} ]

	SearchTarget[ ()
	{
		if(lost_time<time)
		{
			HighLevel("LostTarget"); 			// timed out while looking
			return 0;
		}
		self.ThinkTime = 0;
		if(self.health<=0)
		{
			HighLevel(DEATHORDER);	 // died
			return 0;
		}
		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;
		}
	} ]
}
		

Posted: Thu Jun 28, 2007 9:30 pm
by QuestOfDreams
From the docs:
Comments
C and C++ style comments can be placed in the script file to comment the Orders but there appears to be problems associated with them in the Script Engine and they sometimes can cause an error to occur. To avoid errors do the following:

Never start a line with the // , /* or */. Place a space or a tab first.

Don't put the name of an order at the start of the comment.

Don't use ( or ) in a comment

If you get a Reader Script error then it probably is a problem with a comment in the script.

Posted: Fri Jun 29, 2007 11:53 pm
by darksmaster923
oh. whoops, thanks quest