Enemies/animals
by AzraelK · in General Discussion · 01/17/2002 (6:53 am) · 15 replies
Is there someone working on how to add enemies/animals to the engine? per example lets suppose you want to add monsters to your one player game (with very simplistic AI to follow the player) or somekind of animal like a flock of birds or fishes. how could this be done?
#2
p.s. Herding will be really interesting =) I have always been interested in flocking AI that would be make a great addition to the engine.
01/17/2002 (7:51 am)
Thanks for the quick replay Phil! however I wasnt talking about the AI, I think I can handle very, very simple AI (follow and retreat), what I was wondering is how could I add a critter to the engine as it is? I add it as a bot? or as a vehicle? or as a shapebase? (can I animate it if its only a shapebase? maybe for birds that wont be needed) Im pretty sure I have to create a new datablock but based on what? sorry Im probably still too much of a newbie on this.p.s. Herding will be really interesting =) I have always been interested in flocking AI that would be make a great addition to the engine.
#3
It spawns the default player model and then chases the player around. If the bot happens to walk over a gun it'll attack the player ruthelessly (very hard to kill).
01/17/2002 (9:33 am)
Also Josh Albrecht (I can never spell his last name properly) has some great bot code.It spawns the default player model and then chases the player around. If the bot happens to walk over a gun it'll attack the player ruthelessly (very hard to kill).
#4
01/18/2002 (6:49 am)
That sounds great! where can I find this code?
#5
Ryan
01/18/2002 (9:02 am)
yeah, i also am looking to get even simple AI... any idea if josh is sharing his code? thanksRyan
#6
To do "proper" AI, its going to take more than just hacking a "bot" in (i.e. spawning a player model in and just moving him around), stuff like target management, pathing, threat assesment, inter-AI messaging etc. You also need to take into account the cost of the AI in terms of speed.
Right now, the engine aint the fastest, so adding loads of bots will require some careful optimisation.
Phil.
01/18/2002 (9:29 am)
I think in the longer term, Pats code is going to become the basis for more AI functionality, so I'd take a look at what he's doing first.To do "proper" AI, its going to take more than just hacking a "bot" in (i.e. spawning a player model in and just moving him around), stuff like target management, pathing, threat assesment, inter-AI messaging etc. You also need to take into account the cost of the AI in terms of speed.
Right now, the engine aint the fastest, so adding loads of bots will require some careful optimisation.
Phil.
#7
We have the same problem, so any insight into this would be appreciated.
01/10/2003 (5:42 am)
Ahem, he isn't talking about AI, but rather how to add non player characters to the game.We have the same problem, so any insight into this would be appreciated.
#8
My team also has the same problem: how the heck do you add single-play enemies. Not bots. Not AI's. Not vehicles. Just good old plain single play cannon fooder bad guys!
Now, once again, does anyone know how to do that.
I've tried messing around a bit with both code and scripting, but to no avail.
My theories:
- Enemies should be run on the server (as opposed to players), since any player should be able to kill them and making them die.
- Enemies should be like items: you place them in the editor, when they are killed they may or may not respawn (depends on setting).
Help plz?!
01/10/2003 (5:43 am)
For the love of Test Guy, the man isn't talking about Ai code or bots!My team also has the same problem: how the heck do you add single-play enemies. Not bots. Not AI's. Not vehicles. Just good old plain single play cannon fooder bad guys!
Now, once again, does anyone know how to do that.
I've tried messing around a bit with both code and scripting, but to no avail.
My theories:
- Enemies should be run on the server (as opposed to players), since any player should be able to kill them and making them die.
- Enemies should be like items: you place them in the editor, when they are killed they may or may not respawn (depends on setting).
Help plz?!
#9
Pssst if you add something to the game that moves around on it's own and acts as "cannon fodder" you ARE talking about AI and bots. Otherwise you'd be talking about a static shape or something.
That having been said use the search tool and look for "bots".
01/10/2003 (5:52 am)
"My team also has the same problem: how the heck do you add single-play enemies. Not bots. Not AI's. Not vehicles. Just good old plain single play cannon fooder bad guys! "Pssst if you add something to the game that moves around on it's own and acts as "cannon fodder" you ARE talking about AI and bots. Otherwise you'd be talking about a static shape or something.
That having been said use the search tool and look for "bots".
#10
So you have to use aiPlayer.cc/.h/.cs or derive from it to get your own NPCs... and, of course, NPCs *need* AI, they have to have objectives, destinations, they have to interact, etc.
Check out our site at tork.zenkel.com, there are some VERY basic script tutorials how to spawn and move standard AIs/NPCs...
I'm working on a new tutorial at the moment, doing stuff like hunting the player, flee from the player, finding items, etc. mainly in C++...
01/10/2003 (5:56 am)
Well, NPCs *are* AI (or *have* AI, if you want...)So you have to use aiPlayer.cc/.h/.cs or derive from it to get your own NPCs... and, of course, NPCs *need* AI, they have to have objectives, destinations, they have to interact, etc.
Check out our site at tork.zenkel.com, there are some VERY basic script tutorials how to spawn and move standard AIs/NPCs...
I'm working on a new tutorial at the moment, doing stuff like hunting the player, flee from the player, finding items, etc. mainly in C++...
#11
01/10/2003 (6:09 am)
right, we'll look into it
#12
01/10/2003 (6:18 am)
Well, get the HEAD and use the new AIPlayer class as a base ... it doesn't use a "player slot"/client connection anymore and it doesn't *do* anything yet besides character animation or very basic stuff like running to specified positions... It doesn't HAVE any AI yet, so to speak... what else do you want? (or what less... ;)
#13
Well, thanks for the input, we played around a bit with the AI players, bullying them around and telling them to go there and there for no apparent reason and such. Basically, the problem as we saw it was that the AI was connected to the player slot/connection thingie (at least according to mr. programming wizard man here next to me), so it solved itself in the HEAD I guess.
We have another team member working on the AI separately, so that's another matter, but ultimately we wish to have some rudimentary AI (shooty-takecover-search&destroy fun time lucky hour).
01/10/2003 (7:21 am)
Aahhh, I now see my previous error. Or, actually, the error of my programmer, the insolent fool.Well, thanks for the input, we played around a bit with the AI players, bullying them around and telling them to go there and there for no apparent reason and such. Basically, the problem as we saw it was that the AI was connected to the player slot/connection thingie (at least according to mr. programming wizard man here next to me), so it solved itself in the HEAD I guess.
We have another team member working on the AI separately, so that's another matter, but ultimately we wish to have some rudimentary AI (shooty-takecover-search&destroy fun time lucky hour).
#14
//===================== SETUP THE TOWN PATROLLING BOT AND 2 SCOUTS ==========================
//SET THE PATH TO BE townPath BECAUSE WE WANT THE BOT TO FOLLOW THE TOWN PATHS
//THE NAME townPath WAS SET IN THE FILE stronghold.mis AT THE BOTTOM.
//THE BOT WILL BEGIN AT THE NODE $TorkStartNode. $TorkStartNode IS INITIALIZED WITH THE GLOBALS
%path = "MissionGroup/Paths/townPath";
%player = AIPlayer::spawnOnPath("Tork","patrol",%path,$TorkStartNode);
//MAKE THE BOT BEGIN FOLLOWING ITS RESPECTIVE PATH
%player.followPath(%path,-1);
//SET THE CROSSBOW IMAGE IN THE BOTS HANDS AND INITIALIZE HIS CrossbowAmmo TO 1000 BOLTS.
%player.mountImage(CrossbowImage,0);
%player.setInventory(CrossbowAmmo,1000);
//LOAD THE PATROLLER'S TABLE OF NODE DATA DIRECTLY INTO THE BOT. THIS TABLE IS INITIALIZED WITH THE GLOBALS.
//HERE WE ARE LOADING tpath BECAUSE WE WANT HIM TO FOLLOW THE TOWN TABLE
//EXAMPLE: HERE IS THE DATA FOR TOWN NODE 0 ($tpath[0]) AND TOWN NODE 1 ($tpath[1])
// $tpath[0] = "regular 66 18 83 5 99 1";
// $tpath[1] = "door 66 4 99 15";
//bottable[0] will equal $tpath[0], bottable[1] will equal $tpath[1], etc.
//bottable WILL BE USED IN moveToNextNode. IT CAN BE ACCESSED THERE AND WITHIN OTHER FUNCTIONS
//BY USING THE FOLLOWING: %this.bottable[%x] WHERE %x IS THE NODE YOU WANT TO ACCESS
for(%i=0; %i<$TownNumberNodes; %i++)
{
%player.bottable[%i] = $tpath[%i];
}
echo("is this ggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggg");
//SETUP THE TWO SCOUTS AT THEIR RESPECTIVE STARTING NODES. $TorkScout1Node AND $TorkScout2Node ARE INITIALIZED WITH THE GLOBALS
%player = AIPlayer::spawnOnPath("TorkScout1","sleep",%path,$TorkScout1Node);
%player = AIPlayer::spawnOnPath("TorkScout2","sleep",%path,$TorkScout2Node);
09/11/2006 (11:16 pm)
How do u get a aiplayer see a player as a threat and chase after him?????//===================== SETUP THE TOWN PATROLLING BOT AND 2 SCOUTS ==========================
//SET THE PATH TO BE townPath BECAUSE WE WANT THE BOT TO FOLLOW THE TOWN PATHS
//THE NAME townPath WAS SET IN THE FILE stronghold.mis AT THE BOTTOM.
//THE BOT WILL BEGIN AT THE NODE $TorkStartNode. $TorkStartNode IS INITIALIZED WITH THE GLOBALS
%path = "MissionGroup/Paths/townPath";
%player = AIPlayer::spawnOnPath("Tork","patrol",%path,$TorkStartNode);
//MAKE THE BOT BEGIN FOLLOWING ITS RESPECTIVE PATH
%player.followPath(%path,-1);
//SET THE CROSSBOW IMAGE IN THE BOTS HANDS AND INITIALIZE HIS CrossbowAmmo TO 1000 BOLTS.
%player.mountImage(CrossbowImage,0);
%player.setInventory(CrossbowAmmo,1000);
//LOAD THE PATROLLER'S TABLE OF NODE DATA DIRECTLY INTO THE BOT. THIS TABLE IS INITIALIZED WITH THE GLOBALS.
//HERE WE ARE LOADING tpath BECAUSE WE WANT HIM TO FOLLOW THE TOWN TABLE
//EXAMPLE: HERE IS THE DATA FOR TOWN NODE 0 ($tpath[0]) AND TOWN NODE 1 ($tpath[1])
// $tpath[0] = "regular 66 18 83 5 99 1";
// $tpath[1] = "door 66 4 99 15";
//bottable[0] will equal $tpath[0], bottable[1] will equal $tpath[1], etc.
//bottable WILL BE USED IN moveToNextNode. IT CAN BE ACCESSED THERE AND WITHIN OTHER FUNCTIONS
//BY USING THE FOLLOWING: %this.bottable[%x] WHERE %x IS THE NODE YOU WANT TO ACCESS
for(%i=0; %i<$TownNumberNodes; %i++)
{
%player.bottable[%i] = $tpath[%i];
}
echo("is this ggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggg");
//SETUP THE TWO SCOUTS AT THEIR RESPECTIVE STARTING NODES. $TorkScout1Node AND $TorkScout2Node ARE INITIALIZED WITH THE GLOBALS
%player = AIPlayer::spawnOnPath("TorkScout1","sleep",%path,$TorkScout1Node);
%player = AIPlayer::spawnOnPath("TorkScout2","sleep",%path,$TorkScout2Node);
#15
09/12/2006 (2:07 am)
WoW this is an old thread. Look up the aiGuard or aiPatrol resources. Both have exactly what you are looking for.
Torque 3D Owner Phil Carlisle
I'd do something as an example of herding etc, but without models, I'm kind of stumped.
Basically, once Pats in a good position with the overall AI code, then it shouldnt be hard to extend it to other kinds of creature.
Phil.