AI Guard Unit
by Mark Holcomb · 11/27/2004 (5:18 pm) · 335 comments
Download Code File
This is my second attempt at making an AI controlled character. The first was an
AIPlayer that would follow paths. This character is a guard unit. The guard will
wait at it's post (spawn point) until it sees a target. It will then attack that
target while trying to close with it.
If the target is lost the bot will wait at the last place it saw the character and
look around for a little bit, and then it will try to return to it's post.
There is a chance the bot will get stuck trying to return, but there is a simple
routine that has the bot try to move in random directions to try and clear itself
of any obstacles between it and it's post. It's not perfect.
The thinking routine is a simple state machine - which can be expanded on to give the bot more responses and actions.
As with my first ai character, I am using a simple system that allows the designer to drop
markers in the game map that will mark where the bots will start out. When the mission is loaded, the markers are detected and bots are spawned at the marker locations. The markers are then hidden from view. (The markers can be left visible to help in map editing.)
The markers for the guards can be given a dynamic variable called respawn. (Assigned to the marker during map editing.) 'Respawn' will determine whether a bot respawns or not upon death.
The bots have an attention setting. How often they scan is determined by their attention level. The bots get more sluggish (freeing up processor time) when targets are too far away. Conversely, the bot becomes incrementally more attentive as targets come within range, and further aware as targets come into sight.
When a target is found in range and in sight the bot will shoot at the target. The firing sequence is a step of scheduled calls that call for a firing cycle, a trigger down cycle, and a firing delay to control bot rate of fire.
When a bot is attacked it will attempt to sideatep and it's field of vision is temporarily increased to a 360deg field of vision - to emulate looking around to see what happened. The bot's attention level is also set to make it think at it's fastest rate when attacked.
To use the AIGuard...the following changes need to be made.
1. Back up your original game.cs, player.cs, and your current build of Torque. To install AIGuard will require a recompile, since I have created a new class cloned by copying AIPlayer.cc and AIPlayer.h and renaming all references to AIPlayer to AIGuard.
(I did this because I wanted to be able to run both my AIPatroller and AIGuards in the same maps and did not want to have any confusion between them.)
2. Add the files AIGuard.cc and AIGuard.h to your Torque project. (In my instance I saved them to my c:\Torque\engine\game directory and then added them into my project.)
3. Recompile your project and copy your new executable to the appropriate directory for your app.
4. Copy the file AIGuard.cs into your server/scripts directory.
5. Modify game.cs to add the line
to the function onServerCreated().
6. Also in game.cs: The section for function StartGame needs to modified the following ways:
Below the lines that read:
add this:
(If you followed my previous resource you may not have any reference to AImanager. Don't fret... just look for the place in game.cs where you have
and put in
right underneath it.
7. In player.cs in the code for Armor::Damage modify the lines
to read:
*** If you followed my previous resource there should be no need to change this code.
8. Load your map - Stronghold as an example.
9. Go into the map editor. (F11) Then go into the Editor Creator (F4)
10. Under Shapes there should be a drop down called AIMarker, under that a new item called AIGuard.
11. Create a new AIGuard marker.
12. Select your marker, position it where you like and hit (F3) to modify the marker.
13. If you want to override the default respawn value - create a dynamic variable called respawn and set it's value to true or false.
14. Update your item by clicking 'APPLY'- very important and easy to miss step.
15. Save your mission and reload it.
A bot called Guard1 should appear at the spot of your marker.
If you come within range of the guard he should shoot at you and try to hunt you down.
If you get away, or when you die, he should return to his post.
I hope the resource helps other people get up and running with some AI code in their game.
And again, I'd like to thank the other members of this website whose code has been used in several places in the scripting to make this all work.
Mark H.
P.S. I've also included my AIPatrol class files with this - to install it follow the same instructions as for AIGuard, just substitute AIPatrol where AIGuard appears in the instructions. They can both be run at the same times with no problems.
P.S.S. 11/28/04 - I modified the AIPatrol.cs file to correct for a couple of typos.
P.S.S.S 12/3/04 - Added ammo and health seeking capabilities and fixed some errors. (Read posts below - or file in .zip for full details.)
This is my second attempt at making an AI controlled character. The first was an
AIPlayer that would follow paths. This character is a guard unit. The guard will
wait at it's post (spawn point) until it sees a target. It will then attack that
target while trying to close with it.
If the target is lost the bot will wait at the last place it saw the character and
look around for a little bit, and then it will try to return to it's post.
There is a chance the bot will get stuck trying to return, but there is a simple
routine that has the bot try to move in random directions to try and clear itself
of any obstacles between it and it's post. It's not perfect.
The thinking routine is a simple state machine - which can be expanded on to give the bot more responses and actions.
As with my first ai character, I am using a simple system that allows the designer to drop
markers in the game map that will mark where the bots will start out. When the mission is loaded, the markers are detected and bots are spawned at the marker locations. The markers are then hidden from view. (The markers can be left visible to help in map editing.)
The markers for the guards can be given a dynamic variable called respawn. (Assigned to the marker during map editing.) 'Respawn' will determine whether a bot respawns or not upon death.
The bots have an attention setting. How often they scan is determined by their attention level. The bots get more sluggish (freeing up processor time) when targets are too far away. Conversely, the bot becomes incrementally more attentive as targets come within range, and further aware as targets come into sight.
When a target is found in range and in sight the bot will shoot at the target. The firing sequence is a step of scheduled calls that call for a firing cycle, a trigger down cycle, and a firing delay to control bot rate of fire.
When a bot is attacked it will attempt to sideatep and it's field of vision is temporarily increased to a 360deg field of vision - to emulate looking around to see what happened. The bot's attention level is also set to make it think at it's fastest rate when attacked.
To use the AIGuard...the following changes need to be made.
1. Back up your original game.cs, player.cs, and your current build of Torque. To install AIGuard will require a recompile, since I have created a new class cloned by copying AIPlayer.cc and AIPlayer.h and renaming all references to AIPlayer to AIGuard.
(I did this because I wanted to be able to run both my AIPatroller and AIGuards in the same maps and did not want to have any confusion between them.)
2. Add the files AIGuard.cc and AIGuard.h to your Torque project. (In my instance I saved them to my c:\Torque\engine\game directory and then added them into my project.)
3. Recompile your project and copy your new executable to the appropriate directory for your app.
4. Copy the file AIGuard.cs into your server/scripts directory.
5. Modify game.cs to add the line
exec("./aiGuard.cs"); to the function onServerCreated().
6. Also in game.cs: The section for function StartGame needs to modified the following ways:
Below the lines that read:
// Start the AIManager
new ScriptObject(AIManager) {};
MissionCleanup.add(AIManager);
AIManager.think();add this:
AIGuard::LoadEntities();
(If you followed my previous resource you may not have any reference to AImanager. Don't fret... just look for the place in game.cs where you have
AIPlayer::LoadEntities
and put in
AIGuard::LoadEntities();
right underneath it.
7. In player.cs in the code for Armor::Damage modify the lines
// Deal with client callbacks here because we don't have this
// information in the onDamage or onDisable methods
%client = %obj.client;
%sourceClient = %sourceObject ? %sourceObject.client : 0;
if (%obj.getState() $= "Dead")
%client.onDeath(%sourceObject, %sourceClient, %damageType, %location);to read:
// Deal with client callbacks here because we don't have this
// information in the onDamage or onDisable methods
%client = %obj.client;
%sourceClient = %sourceObject ? %sourceObject.client : 0; if (%obj.isbot == true)
{
%obj.attentionlevel=1;
%obj.enhancefov(%obj);
}
if (%obj.getState() $= "Dead")
{
if (%obj.isbot == true)
{
if (%obj.respawn == true)
{
%obj.delaybeforerespawn(%obj.botname, %obj.markerpos, %obj.marker);
%this.player=0;
}
}
else
{
%client.onDeath(%sourceObject, %sourceClient, %damageType, %location);
}
}*** If you followed my previous resource there should be no need to change this code.
8. Load your map - Stronghold as an example.
9. Go into the map editor. (F11) Then go into the Editor Creator (F4)
10. Under Shapes there should be a drop down called AIMarker, under that a new item called AIGuard.
11. Create a new AIGuard marker.
12. Select your marker, position it where you like and hit (F3) to modify the marker.
13. If you want to override the default respawn value - create a dynamic variable called respawn and set it's value to true or false.
14. Update your item by clicking 'APPLY'- very important and easy to miss step.
15. Save your mission and reload it.
A bot called Guard1 should appear at the spot of your marker.
If you come within range of the guard he should shoot at you and try to hunt you down.
If you get away, or when you die, he should return to his post.
I hope the resource helps other people get up and running with some AI code in their game.
And again, I'd like to thank the other members of this website whose code has been used in several places in the scripting to make this all work.
Mark H.
P.S. I've also included my AIPatrol class files with this - to install it follow the same instructions as for AIGuard, just substitute AIPatrol where AIGuard appears in the instructions. They can both be run at the same times with no problems.
P.S.S. 11/28/04 - I modified the AIPatrol.cs file to correct for a couple of typos.
P.S.S.S 12/3/04 - Added ammo and health seeking capabilities and fixed some errors. (Read posts below - or file in .zip for full details.)
#2
The guard is assigned a post - his marker - he then will stay at his post looking for targets. When a target comes into range and view he will attack and close in. When the target is dead or gets away the guard will attempt to return to his post.
So in effect you can create guards on patrol with AIPatrol and stationary guard with AIGuard.
The AI in AIGuard is a lot better than AIPatrol. I chucked almost all of the code from AIPatrol except for the code to spot and locate a target.
I also feel that AIGuard provides a good open platform for an AI character because if you want to add a new activity to him, then you add a new 'action' and code a new case for it.
So in effect if you want to add a 'Look for health' routine you just assign 'LookforHealth' with:
%obj.action="LookforHealth";
somewhere in the code - like in 'ondamage' if the health is below a certain level, then in the 'Think' code add a new case like...
case "LookforHealth":
{
code to find nearest health.
send bot to move toward health
schedule a think cycle
}
I hope that clears things up and shows you a way to expand on the AIGuard.
Mark
P.S. I updated AIPatrol - there was a misnamed variable that was not allowing the bots to respawn correctly.
11/27/2004 (8:07 pm)
Patroller is the one in the last resource - and it follows paths and makes circuits around them.The guard is assigned a post - his marker - he then will stay at his post looking for targets. When a target comes into range and view he will attack and close in. When the target is dead or gets away the guard will attempt to return to his post.
So in effect you can create guards on patrol with AIPatrol and stationary guard with AIGuard.
The AI in AIGuard is a lot better than AIPatrol. I chucked almost all of the code from AIPatrol except for the code to spot and locate a target.
I also feel that AIGuard provides a good open platform for an AI character because if you want to add a new activity to him, then you add a new 'action' and code a new case for it.
So in effect if you want to add a 'Look for health' routine you just assign 'LookforHealth' with:
%obj.action="LookforHealth";
somewhere in the code - like in 'ondamage' if the health is below a certain level, then in the 'Think' code add a new case like...
case "LookforHealth":
{
code to find nearest health.
send bot to move toward health
schedule a think cycle
}
I hope that clears things up and shows you a way to expand on the AIGuard.
Mark
P.S. I updated AIPatrol - there was a misnamed variable that was not allowing the bots to respawn correctly.
#3
Cheers mate!
11/28/2004 (1:00 pm)
Cool, I'm in the middle of going through the AI section in Core Techniques and Alogorithms, so I'll be using this as a base. Cheers mate!
#4
11/29/2004 (1:05 am)
Code works real good! Love the way AIGuard chases you. And they are a real good shot ! Thanks Mark .....
#5
11/29/2004 (9:02 am)
Alright, thats what i figured, thanks again. Hey these two tutorials remind of the mysterious AI editor that got scrapped from torque.
#6
11/29/2004 (1:37 pm)
How do you get AIPatrol workin , i could get him placed but he wouldn't move...i had multiple markers set up, no success
#7
AIPatrol follows paths. Place a path in your map that you want an AIPatrol to follow, then go into the map editor and assign a dynamic variable called 'pathname' on the marker and type in the name of the path for the bot to follow.
If you read the documentation on my first resource:
www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=6742
it documents how to make the AIPatrol work - since AIPatrol is simply a slightly modified version of the same thing.
11/29/2004 (3:53 pm)
Alfredo,AIPatrol follows paths. Place a path in your map that you want an AIPatrol to follow, then go into the map editor and assign a dynamic variable called 'pathname' on the marker and type in the name of the path for the bot to follow.
If you read the documentation on my first resource:
www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=6742
it documents how to make the AIPatrol work - since AIPatrol is simply a slightly modified version of the same thing.
#8
11/30/2004 (8:38 am)
Great job, Mark. These units will be a great base for creating other game specific AI.
#9
11/30/2004 (9:22 am)
Alfred: by marker he means the one that spawns the AI player
#10
11/30/2004 (11:53 am)
Thanks for clarifying that Eric. I was kind of in a rush last night when I posted.
#11
I sat down today with my kid and tried running multiplayer with the bots and I ran into a few oddities. First the bots would not shoot at you unless you were the first client. The second client got off scot free... which made for a very unfair fight.
I hunted down the problem and found a few errors that I corrected in the function
GetClosestHumanInSight...
I have posted the new code for both AIGuard and AIPatrol below.
(I have also uploaded the new versions of the files into the resource, so if you download it, you'll get the corrected versions automatically.)
The fix consisted of setting the %dist variable to 0, and then changing the if-then comparisons at the end of the function to swap out the values for the nearest target.
I also changed the if-then at the top of the function that would kick back a -1 if the client $="" or client.player == 0. I had to do this because the bots would quit shooting at the second client while the first client was dead and in limbo. Due to the fact that the bots were kicking out of the routine when the first client reported back as being non existent.
Below is the code fragments.
AIGUARD (cut and paste this over the old function)
and for AIPATROL.CS
Sorry bout that gents...
11/30/2004 (4:59 pm)
Hey everyone,I sat down today with my kid and tried running multiplayer with the bots and I ran into a few oddities. First the bots would not shoot at you unless you were the first client. The second client got off scot free... which made for a very unfair fight.
I hunted down the problem and found a few errors that I corrected in the function
GetClosestHumanInSight...
I have posted the new code for both AIGuard and AIPatrol below.
(I have also uploaded the new versions of the files into the resource, so if you download it, you'll get the corrected versions automatically.)
The fix consisted of setting the %dist variable to 0, and then changing the if-then comparisons at the end of the function to swap out the values for the nearest target.
I also changed the if-then at the top of the function that would kick back a -1 if the client $="" or client.player == 0. I had to do this because the bots would quit shooting at the second client while the first client was dead and in limbo. Due to the fact that the bots were kicking out of the routine when the first client reported back as being non existent.
Below is the code fragments.
AIGUARD (cut and paste this over the old function)
function AIGuard::GetClosestHumanInSightandRange(%this, %obj)
{
%dist=0;
%index = -1; //sets the initial index value to -1 The index is the id number of the nearest
//human target found
%botpos = %this.getposition(); //The bots current position
%count = ClientGroup.getCount(); //The number of clients to check
//The for-next loop cycles through all of the valid clients
for(%i=0; %i < %count; %i++)
{
%client = ClientGroup.getobject(%i); //Get the client info for the client at index %i
//If the client is invalid then the function bails out returning a -1 value, for no
//target found.
if (%client.player !$= "" || %client.player > 0)
{
//The following line just changes the %client to %tgt to make it easier to follow the code below
%tgt = %client;
%playpos = %client.player.getposition(); //Assigns the player position to a variable
%tempdist = vectorDist(%playpos, %botpos); //Determine the distance from the bot to the target
//The first test we perform is to see if the target is within the bots range
//Is target in range? If not bail out of checking to see if its in view.
if (%tempdist <= $AI_GUARD_DETECT_DISTANCE)
{
//Lower attentionlevel to increase response time...
%this.attentionlevel--;
//Prevent the attention level from dropping below 1
if(%this.attentionlevel < 1) %this.attentionlevel=1;
//The second check is to see if the target is within the FOV of the bot.
//Is the target within the fov field of vision of the bot?
if(%this.Istargetinview(%obj, %tgt, %obj.fov))
{
//Lower attentionlevel to increase response time...
%this.attentionlevel--;
//Prevent the attention level from dropping below 1
if(%this.attentionlevel < 1) %this.attentionlevel=1;
//The third check we run is to see if there is anything blocking the
//target from the bot.
if(%this.CheckLOS(%obj, %tgt))
{
//We lower the bots attention level again, to further increase it's
//response time, this effectively means that the bot will respnd faster to
//objects that are both in range and in plain sight.
%this.attentionlevel--;
//Prevent the attention level from dropping below 1
if(%this.attentionlevel < 1) %this.attentionlevel=1;
//If there is a current target, then check the distance to the new target as
//compared to the current set target. If the new target is closest, then set
//the index and tempdistance to the new target.
if(%tempdist < %dist || %this.dist == 0)
{
%dist = %tempdist;
%index = %i;
}
}
}
}
}
else
{
//If there are no targets in view, then the bots attention will slowly lapse and increase
//This will slow down how fast the bot thinks and how often it checks for threats.
%this.attentionlevel = %this.attentionlevel + 0.5;
if(%this.attentionlevel > $AI_GUARD_MAX_ATTENTION) %this.attentionlevel=$AI_GUARD_MAX_ATTENTION;
}
}
return %index;
}and for AIPATROL.CS
function AIPatrol::GetClosestHumanInSightandRange(%this, %obj)
{
%dist=0;
%index = -1;
%botpos = %this.getposition();
%count = ClientGroup.getCount();
for(%i=0; %i < %count; %i++)
{
%client = ClientGroup.getobject(%i);
if (%client.player !$= "" || %client.player >0)
{
%tgt = %client;
%playpos = %client.player.getposition();
%tempdist = vectorDist(%playpos, %botpos);
//Is target in range? If not bail out of checking to see if its in view.
if (%tempdist <= $AI_PATROL_DETECT_DISTANCE)
{
//Lower attentionlevel to increase response time...
%this.attentionlevel--;
if(%this.attentionlevel < 1) %this.attentionlevel=1;
//Is the target within the fov field of vision of the bot?
if(%this.Istargetinview(%obj, %tgt, %obj.fov))
{
//Lower attentionlevel to increase response time...
%this.attentionlevel--;
if(%this.attentionlevel < 1) %this.attentionlevel=1;
if(%this.CheckLOS(%obj, %tgt))
{
%this.attentionlevel--;
if(%this.attentionlevel < 1) %this.attentionlevel=1;
if(%tempdist < %dist || %dist== 0)
{
%dist = %tempdist;
%index = %i;
}
}
}
}
}
else
{
%this.attentionlevel = %this.attentionlevel + 0.5;
if(%this.attentionlevel > $AI_PATROL_MAX_ATTENTION) %this.attentionlevel=$AI_PATROL_MAX_ATTENTION;
}
}
return %index;
}Sorry bout that gents...
#12
12/02/2004 (8:43 pm)
Hey Mark, I am coming up to speed on TGE and I'm curious: why the change from ItemShapeDate to StaticShapeData for the bot markers? Is there something special in the way they are handled by the engine?
#13
So I converted from Items to StaticShapes for that reason.
Now after poking around some more I found out that I could probably have just set the static property for the Item and that would have stopped the rotating. (I haven't tried it, since I have a method that works.)
And for the record I'm still coming up to speed on TGE as well, so there may be better ways to do some of the things that I'm doing, and I'm constantly revising my code to fix mistakes I find in it. I'm just willing to make my mistakes publicly in the hopes that they'll help some of the other people out there learn a little bit more.
P.S. I've got a few more mods to the AIGuard that I'll be posting in the next day or two - such as being able to set the default weapon via a global variable, fixed the console error messages when loading the entities, the bot will seek out visible health packs when it's health drops below a set variable, and you'll be able to set whether the bot's ammo stays constantly full, or if it uses ammo and will hunt for visible ammo when it runs low.
12/02/2004 (8:58 pm)
No real reason for the change, other than the StaticShapes didn't rotate all the time in the map editor, and I use the exact positioning of the markers to set the bots in the post position.So I converted from Items to StaticShapes for that reason.
Now after poking around some more I found out that I could probably have just set the static property for the Item and that would have stopped the rotating. (I haven't tried it, since I have a method that works.)
And for the record I'm still coming up to speed on TGE as well, so there may be better ways to do some of the things that I'm doing, and I'm constantly revising my code to fix mistakes I find in it. I'm just willing to make my mistakes publicly in the hopes that they'll help some of the other people out there learn a little bit more.
P.S. I've got a few more mods to the AIGuard that I'll be posting in the next day or two - such as being able to set the default weapon via a global variable, fixed the console error messages when loading the entities, the bot will seek out visible health packs when it's health drops below a set variable, and you'll be able to set whether the bot's ammo stays constantly full, or if it uses ammo and will hunt for visible ammo when it runs low.
#14
12/02/2004 (9:44 pm)
Hmm I must be doing something very wrong here, I cant seem to get aiguard to work..Firstly I followed the scripting directions to the letter - added to project / recompiled, added scripts and so-forth, then added in the AIGuard marker, which is just korg, added dynamic property respawn and value true, then hit apply, Saved mission, exited and restated mission, but seems there is no AIGuard.. has anyone had this same problem?, could you let me know how to fix it.. I have done this 3 times from step 1 to finnish and still no luck.
#15
Well, lets go through the basics and we'll see if we can get you going.
First things first. Go through your console.log file and look for any lines in red that show errors in AIGuard.cs. If you don't find any then look for the line in your log file that says...
Loading Guard entities...
If you see a line that says:
Guard entities disabled...
then you need to edit aiguard.cs and change
to
If you don't see either of these lines in your log file, then you need to make sure that game.cs has the line:
in there along with all the other lines to exec scripts.
Then you need to make sure that you have the line:
Another thing to check - which happened to one guy.
Check the top part of AIGuard.cs, there is a list of global variables that set all the bot parameters. There has been one case where the file got whacked and the globals were messed up.
The global variables if needed are:
and should be pasted at the top of the file.
Try those things out, and if those don't help - post back.
Mark
12/02/2004 (10:07 pm)
ebee t,Well, lets go through the basics and we'll see if we can get you going.
First things first. Go through your console.log file and look for any lines in red that show errors in AIGuard.cs. If you don't find any then look for the line in your log file that says...
Loading Guard entities...
If you see a line that says:
Guard entities disabled...
then you need to edit aiguard.cs and change
$AI_GUARD_ENABLED = false;
to
$AI_GUARD_ENABLED = true;
If you don't see either of these lines in your log file, then you need to make sure that game.cs has the line:
exec("./aiGuard.cs");in there along with all the other lines to exec scripts.
Then you need to make sure that you have the line:
AIGuard::LoadEntitiesin the function 'startgame' in game.cs
Another thing to check - which happened to one guy.
Check the top part of AIGuard.cs, there is a list of global variables that set all the bot parameters. There has been one case where the file got whacked and the globals were messed up.
The global variables if needed are:
$AI_GUARD_ENABLED = true; //Whether Guard bots are loaded during mission loading. $AI_GUARD_MARKER_HIDE = true; //Turns marker hiding on or off - useful when editing maps. $AI_GUARD_SIDESTEP = 50; //This value helps determine how far a bot sidesteps when he is stuck. //The computer picks a random number between 1 and $AI_GUARD_SIDESTEP //The value is then subtracted by half it's value to create a left/right //and forward/back component. So the effective range is really -25 to +25 //with the default setting $AI_GUARD_HOLDCNT_MAX = 5; //The number of think cycles that the bot will 'hold' for before trying to //return to his post. $AI_GUARD_FIREDELAY = 500; //How long the bot waits between firing bursts. $AI_GUARD_ENHANCED_FOV_TIME =2000; //How long the bots field of vision is enhanced to 360 for. $AI_GUARD_FOV =240; //The guards field of vision $AI_GUARD_DETECT_DISTANCE =100; //The range at which a guardbot will start reacting to a client target $AI_GUARD_IGNORE_DISTANCE = 100; //The range at which the bot ignores a client and will not fire on it. $AI_GUARD_SCANTIME =500; //The quickest time between think cycles. $AI_GUARD_MAX_ATTENTION = 10; //This number and $AI_GUARD_SCANTIME are multiplied to set the delay in the //thinking loop. Used to free up processor time on bots out of the mix. $AI_GUARD_CREATION_DELAY =5000; //How long a bot waits after creation before his think cycles are controlled by //his attention rate. (Used to help free up think cycles on bots while misison //finishes loading. $AI_GUARD_TRIGGER_DOWN = 100; //How long the bot holds down the trigger when firing. Use longer pulses for //pray and spray type weapons. $AI_GUARD_DEFAULTRESPAWN = true; //Controls whether guards respawn automatically or not if their marker does not have //dynamice 'respawn' variable set in it. $AI_GUARD_RESPAWN_DELAY = 20000; //Determines how long a bot goes in between death and respawning. $AI_GUARD_ENHANCEFOV_CHANCE = 10; //There is a 1 in x chance that guard will see 360 deg vision to prevent it //from being snuck up on.
and should be pasted at the top of the file.
Try those things out, and if those don't help - post back.
Mark
#16
find ~/.garagegames/torqueDemo/ -type f -name "*.dso" | xargs rm
12/02/2004 (10:18 pm)
@ebee: you might want to delete your dso files and re-run. Under Linux, this will remove all dso's (substitute dir as needed): find ~/.garagegames/torqueDemo/ -type f -name "*.dso" | xargs rm
#17
12/02/2004 (11:06 pm)
Thanks Jerry, I gave that a try, and yes it is working too well now, appears I added about 6 of them before, this time when i loaded, a ANGRY mob attacked me, Great resource...thankyou for you help.
#18
12/02/2004 (11:13 pm)
Glad you got it working. Now run like ......
#19
12/03/2004 (12:34 am)
Actualy I have another question for anyone who has the time to answer it, how would one add in ability for the Bot to mount and control a vehicle, & would this work?? , Originaly i was just thinking about a car ai that chases the player, but havent been able to find a resource.. anyway if anyone has some ideas on this please let me know, Thanks In Advance.
#20
but I have 2 problems but before I list my problems I like to say that AIGard work fine with me.
now first problem:
AIPatrol is not spawn on my level(I add the AIPatrolMarker and restart the mission but nothing happen, Im sure that AIPatrol::LoadEntities(); exsist on my game.cs, and aipatrol.cs is compiled to .dso file)
so what can I do to solve this any suggestions?
the second problem is:
call me stupied but when the AI player (AIGard) spaw he have no weapons to shoot on me, so how can I add weapons to him?
thanks
12/03/2004 (12:41 am)
Mark greate workbut I have 2 problems but before I list my problems I like to say that AIGard work fine with me.
now first problem:
AIPatrol is not spawn on my level(I add the AIPatrolMarker and restart the mission but nothing happen, Im sure that AIPatrol::LoadEntities(); exsist on my game.cs, and aipatrol.cs is compiled to .dso file)
so what can I do to solve this any suggestions?
the second problem is:
call me stupied but when the AI player (AIGard) spaw he have no weapons to shoot on me, so how can I add weapons to him?
thanks

Torque Owner Eric Prem