Aiplayer Jumping and Firing
by Ryan Ackley · in Torque Game Engine · 02/26/2002 (8:19 pm) · 5 replies
Ok, heres what I have found to be the stumbling blocks to have bots fire (And jump for that matter)
An AiPlayer doesnt have an 'inventory' by default. In my demo, i have every player spawn with the basic pistol and 50 ammo. When i spawn a bot, it gets the shapefile mounted at its mount0 joint, but i get an error (the grey text) in the console window. I cant increase its inventory to 1 pistol... or ammo to 50.
Now, can i create a player inventory for an AiPlayer in aiplayer.cs just like is done in player.cs? It is my take on AiPlayer that it had everything a player did, only aicontrolled.
second: how to trigger a fire
I suppose you could set a target, and catch the callback ontargetenterlos() and have the bot face and fire. but, how do we have the AiPlayer fire? i cant see any function in the ai player's dump() function that would do the firing... any ideas?
Same for jumping (needed to a lesser extent, for getting unstuck and other pathfinding uses)
Anyone have any ideas on the above?
ryan
An AiPlayer doesnt have an 'inventory' by default. In my demo, i have every player spawn with the basic pistol and 50 ammo. When i spawn a bot, it gets the shapefile mounted at its mount0 joint, but i get an error (the grey text) in the console window. I cant increase its inventory to 1 pistol... or ammo to 50.
Now, can i create a player inventory for an AiPlayer in aiplayer.cs just like is done in player.cs? It is my take on AiPlayer that it had everything a player did, only aicontrolled.
second: how to trigger a fire
I suppose you could set a target, and catch the callback ontargetenterlos() and have the bot face and fire. but, how do we have the AiPlayer fire? i cant see any function in the ai player's dump() function that would do the firing... any ideas?
Same for jumping (needed to a lesser extent, for getting unstuck and other pathfinding uses)
Anyone have any ideas on the above?
ryan
About the author
#2
%weapon = new Item()
{
// Let this point to the type of weapon
// (Rifle and Crossbow being the defalt)
dataBlock = Rifle;
};
%ammo = new Item()
{
dataBlock = RifleAmmo;
};
MissionCleanup.add(%weapon);
MissionCleanup.add(%ammo);
%player.pickup(%weapon, 1);
%player.pickup(%ammo, 1);
This should start things with both rifle and ammo.
02/27/2002 (10:30 am)
In my game I put these lines of code atthe end of the createPlayer function in game.cs%weapon = new Item()
{
// Let this point to the type of weapon
// (Rifle and Crossbow being the defalt)
dataBlock = Rifle;
};
%ammo = new Item()
{
dataBlock = RifleAmmo;
};
MissionCleanup.add(%weapon);
MissionCleanup.add(%ammo);
%player.pickup(%weapon, 1);
%player.pickup(%ammo, 1);
This should start things with both rifle and ammo.
#3
ryan
02/27/2002 (11:13 am)
Yeah, i have that sort of thing for everyone. the problem is, the AiPlayer cant "posses" anything (as far as i can tell), all i get is the actual dts mounted on the mount0 joint of the aiplayer. Ive done a bit of digging around and am going to do some more later today. Im interested in what you cook up pat. Other than this and basic pathfinding (which i have a pretty sweet algorithm for) i should have some real cool Ai for all my deathmatching needs.ryan
#4
So you're saying they aren't allowed to use the objects (aka, no "inventory"?) wouldn't some sort of errors appear in console when the bot picks up the object (and mounts it) ?
02/27/2002 (5:59 pm)
I've got my bots to run around with objects and weapons, but I haven't really tried to get them to use them.So you're saying they aren't allowed to use the objects (aka, no "inventory"?) wouldn't some sort of errors appear in console when the bot picks up the object (and mounts it) ?
#5
ryan
02/27/2002 (7:59 pm)
yeah, thats exactly what I get, but im working on that. If i cant get the current inventory to work, ive heard that one of those nifty tutorials might :)ryan
Torque 3D Owner Pat Wilson
You need to add a console interface to the mTriggers boolean array in aiPlayer. The triggers are what make the AI jump, fire, drop mines, jet, etc.