Game Development Community

Mark Halcomb's AIPatroller revisited

by Andy Hawkins · in Torque Game Engine · 11/11/2005 (2:41 am) · 0 replies

I've made a new thread to focus on one issue about this resource...
www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=6742

The problem I am having with it, is no matter what I set the $AI_PLAYER_FIREDELAY value to, the guard just keeps firing based on it's own firing rate - I have no clue where it's derived from - it's when I get up close enough to fire. It seems to fire at the right rate I set say every 5 seconds, but then just blasts me at 1 second intervals. Any help would be appreciated.

The way I understood it, once the trigger was pulled the ceasefire was launched which scheduled the delayFire function to allow the ai to fire again after $AI_PLAYER_FIREDELAY miliseconds using this code...

...
	%this.trigger = %this.schedule(%obj.triggerDown,"ceasefire", %obj);
}

//CeaseFire - this makes the AIPlayer lift off the trigger
function AIPlayer::ceasefire(%this, %obj)
{
   //Makes the AIPlayer lift off the trigger   
   %obj.setImageTrigger(0,false);
   //This schedule is created to implement a delay between the AIPlayer's
   //shots. This can be used to help set how aggressive the bot is.
   
   
      %this.trigger = %this.schedule($AI_PLAYER_FIREDELAY,"delayfire", %obj); // old value $AI_PLAYER_FIREDELAY
   
}

function AIPlayer::delayfire(%this, %obj)
{
	//This clears the AIPlayer's 'firing' flag.
	//This allows the player to shoot again the next time it
	//sees and selects a target within range.
	%firing = false;
}