Need ai player to attack vehicle
by Katrina Rose · in Torque Game Engine · 01/18/2005 (6:06 am) · 7 replies
How do I get an ai player to fire upon a wheeled vehicle? When a player mounts the vehicle, %player is changed to $vehicle[$currentVehicle]?
As it is now, the ai player will not attack unless the player gets out of the vehicle.
Thanks for your help,
Mike
As it is now, the ai player will not attack unless the player gets out of the vehicle.
Thanks for your help,
Mike
About the author
#2
When the player enters the vehicle, I set :
...in defaultbind.cs
$bots[%count].setAttackTargetObject($vehicle[$currentvehicle]);
$bots[%count].setScanningPlayers(false);
In car.cs, I put:
function DefaultCar::damage( %this, %obj, %sourceObject, %position, %damage, %damageType )
function DefaultCar::onDamage( %this, %obj, %delta )
What else do I have to do?
01/19/2005 (7:41 am)
I still can't get the bots to fire upon the vehicle like they do on localconnection.player.When the player enters the vehicle, I set :
...in defaultbind.cs
$bots[%count].setAttackTargetObject($vehicle[$currentvehicle]);
$bots[%count].setScanningPlayers(false);
In car.cs, I put:
function DefaultCar::damage( %this, %obj, %sourceObject, %position, %damage, %damageType )
function DefaultCar::onDamage( %this, %obj, %delta )
What else do I have to do?
#3
01/19/2005 (8:18 am)
Just a question : Have you tried setting the bot to attack a vehicle with out the player inside ? Just for a test ? what happens ?
#4
01/19/2005 (10:23 am)
SetAttackTargetObject desires a PlayerObjectType if I recall correctly, change the hard code to something like a shapebase object and you should be ok. Besure to change any other referances so that they are all shapebase and not players.
#5
Max
01/19/2005 (10:35 am)
Um... My bots that I made will run after the car when you or another bot is in it and try and kill them/you... I'll take a look through my code and see if I can find what I did to fix this.Max
#6
It was Bruno's post that alerted me to this finding.
Anthony, I looked in aiplayer.cc and it looks like the SetAttackTargetObject method takes a ShapeBase as its argument.
I should note that I have been working with Torgue now for about 1 week when I was tasked with completing this game.
I would appreciate any pointers you can give me.
01/19/2005 (4:15 pm)
Sorry, my first post was not accurate. The player does not actually mount the vehicle. When the user hits the key to mount the vehicle, the player position is moved away (setTransform("0 0 0 0 0 0") ) and SetControlObject is used to switch control to the vehicle. When "dismounting", the player position is set adjacent to the vehicle.It was Bruno's post that alerted me to this finding.
Anthony, I looked in aiplayer.cc and it looks like the SetAttackTargetObject method takes a ShapeBase as its argument.
I should note that I have been working with Torgue now for about 1 week when I was tasked with completing this game.
I would appreciate any pointers you can give me.
#7
The bot probably has it's target set as the player obejct and this would need updating when you switch control to the vehicle and vice versa when you exit the vehicle.
I'm a Troque newbie also, so I could be talking rubbish, but from experience it might be something along those lines.
01/26/2005 (3:12 pm)
Is it possible that the AI bot is still trying to attack the player object which has been teleported away? The bot probably has it's target set as the player obejct and this would need updating when you switch control to the vehicle and vice versa when you exit the vehicle.
I'm a Troque newbie also, so I could be talking rubbish, but from experience it might be something along those lines.
Torque Owner Bruno Grieco
After that you would have to check some threads about transfering the vehicle damage to the player.