Orc Theft Auto
by Nmuta Jones · in Torque Game Engine · 06/19/2009 (9:52 am) · 12 replies
I used this simple resource to integrate driving into my FPS:
http://www.garagegames.com/community/resources/view/16237
CAN I tell you how much I love Torque? Implemented this in AFX 1.5.2 for TGE and not only does it work beautifully, but some serendipitous stuff....
I have a pathfinding resource in my engine version, and an orc who was on his way somewhere else ran into my car while my human player was driving it. Since the Armor:onCollision handler allows ANY player to take control of the vehicle, the Orc essentially hijacked my car from me.
I think he was dragging me for a while underneath the car because I could not move. Finally I jumped and I was released from this awful form of abuse.
This engine is so fun to work with. I will have to modify my code to make sure that NPCs cannot hijack vehicles.
http://www.garagegames.com/community/resources/view/16237
CAN I tell you how much I love Torque? Implemented this in AFX 1.5.2 for TGE and not only does it work beautifully, but some serendipitous stuff....
I have a pathfinding resource in my engine version, and an orc who was on his way somewhere else ran into my car while my human player was driving it. Since the Armor:onCollision handler allows ANY player to take control of the vehicle, the Orc essentially hijacked my car from me.
I think he was dragging me for a while underneath the car because I could not move. Finally I jumped and I was released from this awful form of abuse.
This engine is so fun to work with. I will have to modify my code to make sure that NPCs cannot hijack vehicles.
About the author
Lead Developer for MediaBreeze Multimedia
#2
I noticed the ai hijacking thing a while back, and noticed how bad the ai are at driving.
a hack is when an ai jacks a vehicle, call a function that deletes the ai, deletes the vehicle, and spawns an ai vehicle, all at the same time.
there is a resource for dynamicaly reloading a vehicle datablock, so there are no hicups, then when the ai vehicle gets jacked back by you, the whole proccess happens again in reverse.
06/20/2009 (9:50 am)
you should be able to melee attack him out othe car, more fun.I noticed the ai hijacking thing a while back, and noticed how bad the ai are at driving.
a hack is when an ai jacks a vehicle, call a function that deletes the ai, deletes the vehicle, and spawns an ai vehicle, all at the same time.
there is a resource for dynamicaly reloading a vehicle datablock, so there are no hicups, then when the ai vehicle gets jacked back by you, the whole proccess happens again in reverse.
#3
There are several ways to prevent this behavior -- if you're so inclined.
You can use a "use/enter" method to take control of the vehicle instead of upon simple collision.
Since bots don't have a client you can throw this at the beginning in your onCollision code:
You could even write an AIPlayer class onAdd() replacement that set the canMount bool to false instead of true. Like many things in Torque there is no one set way to do things and there are often many alternatives that you would never think of.
In my codebase you can shoot people (players and bots) inside of vehicles, and if there is a driver when you attempt to "use/enter" the vehicle it does a mass comparison to see if you can pull them out. Some bots are "smart" enough to know they can yank you out of the car -- others just get run over :D
06/20/2009 (10:36 am)
Noticed that did ya? Just wait until the first time you have an antelope or even a butterfly run over (and pickup) a weapon :DThere are several ways to prevent this behavior -- if you're so inclined.
You can use a "use/enter" method to take control of the vehicle instead of upon simple collision.
Since bots don't have a client you can throw this at the beginning in your onCollision code:
if (!isObject(%obj.client))
return;Or even test explicitely for bots:%className = %col.getClassName();
if(%className $= "AIPlayer")
return;You could even write an AIPlayer class onAdd() replacement that set the canMount bool to false instead of true. Like many things in Torque there is no one set way to do things and there are often many alternatives that you would never think of.
In my codebase you can shoot people (players and bots) inside of vehicles, and if there is a driver when you attempt to "use/enter" the vehicle it does a mass comparison to see if you can pull them out. Some bots are "smart" enough to know they can yank you out of the car -- others just get run over :D
#4
A few years back I had also coded something when a bullet someone, it would detect WHO the bullet came from, so it would not allow AI character bullets to do any damage to other AI players. This way when AI players ended up in a single file line shooting and chasing me, they would not "do each other in".
Torque is just a lot of fun to play with. These suggestions are great and I think I may implement DeepScratch and Michael's suggestions.
06/20/2009 (10:41 am)
Yeah, it's pretty awesome. Those are great ideas.A few years back I had also coded something when a bullet someone, it would detect WHO the bullet came from, so it would not allow AI character bullets to do any damage to other AI players. This way when AI players ended up in a single file line shooting and chasing me, they would not "do each other in".
Torque is just a lot of fun to play with. These suggestions are great and I think I may implement DeepScratch and Michael's suggestions.
#5
shooting at players/bots inside vehicles?
how did you get that working?
06/20/2009 (11:04 am)
@Michael,shooting at players/bots inside vehicles?
how did you get that working?
#6
At some point I was thinking of maybe having protected and unprotected mountpoints for passengers with possible hitboxes (theory only). Another of my untested theories is that if the players' collision box protrudes outside of the vehicle convex then you might/should be able to shoot them -- I remember in Tribes (might have been a mod) being able to snipe the pilot and also shooting weapons out of the passengers' hands in an APC or a LPC.
06/20/2009 (11:24 am)
@deepscratch: it's more of a gimmick than a feature, really. When the vehicle is damaged I just do a check to see if there is a pilot, if so then pass some damage on to him based on armor rating, with an increasing random chance to kick him out. Most of my vehicles are one man hovertanks (think "A Boy And His Tank") so that works out ok. It is kind of hacky with passengers though. At some point I was thinking of maybe having protected and unprotected mountpoints for passengers with possible hitboxes (theory only). Another of my untested theories is that if the players' collision box protrudes outside of the vehicle convex then you might/should be able to shoot them -- I remember in Tribes (might have been a mod) being able to snipe the pilot and also shooting weapons out of the passengers' hands in an APC or a LPC.
#7
Then maybe you can help me with this: I want the vehicle to have three lights. green, yellow and red to represent the health of the driver.
How would you go about doing this, since from what you're saying, you can access a driver through his vehicle and vice versa.
06/20/2009 (11:33 am)
@MichaelThen maybe you can help me with this: I want the vehicle to have three lights. green, yellow and red to represent the health of the driver.
How would you go about doing this, since from what you're saying, you can access a driver through his vehicle and vice versa.
#8
I suppose you could do much the same, but also call getDamageLevel() to see how damaged the player is and attach the appropriate color light to the vehicle -- that's a nifty idea by the way!
06/21/2009 (9:14 am)
@Nmuta: I'm just storing the player's body as the "driver" in a dynamic field of the vehicle when one is first mounted. Then in vehicle::Damage() I can do something like %obj.driver.damage() to affect the "driver".I suppose you could do much the same, but also call getDamageLevel() to see how damaged the player is and attach the appropriate color light to the vehicle -- that's a nifty idea by the way!
#9
I am trying to write a function that allows you to "eject" an AiPlayer from a car.
In the console I am accessing the car from its number, for example
4085.engineTorque ; gives me my engine Torque from the datablock,
so I know I'm accessing the objects correctly,
but
4085.unmountImage(0);
4085.unmount();
4085.unmountImage();
4085.unmount(0);
all of these fail to eject my AiPlayer from the car after he's hijacked it from me. I only have one mount point, which is zero.
Any ideas?
06/25/2009 (11:28 pm)
This question is for anyone:I am trying to write a function that allows you to "eject" an AiPlayer from a car.
In the console I am accessing the car from its number, for example
4085.engineTorque ; gives me my engine Torque from the datablock,
so I know I'm accessing the objects correctly,
but
4085.unmountImage(0);
4085.unmount();
4085.unmountImage();
4085.unmount(0);
all of these fail to eject my AiPlayer from the car after he's hijacked it from me. I only have one mount point, which is zero.
Any ideas?
#10
That's the closest thing to the functionality you're wanting.... there is no automatic kicking to the curb of players from a vehicle function, though you could write one.
Maybe something like this, just keep in mind this is off the top of my head and I haven't tried it myself:
%vehicleData = vehicle datablock (reference to # of mountpoints should go there)
Honestly I don't know if that will work but in theory... :D
06/26/2009 (9:09 pm)
doPlayerDismount(%vehicle, %player, 1);Where %vehicle is the vehicle in question, and %player would be the player or AI.
That's the closest thing to the functionality you're wanting.... there is no automatic kicking to the curb of players from a vehicle function, though you could write one.
Maybe something like this, just keep in mind this is off the top of my head and I haven't tried it myself:
function kickToTheCurb(%vehicle, %vehicleData)
{
for (%slot = 0; %slot < %vehicleData.numMountPoints; %slot++)
{
%onBoard = %vehicle.getMountedObject(%slot);
if (%onBoard.getClassName() $= "AIPlayer")
doPlayerDismount(%vehicle, %onBoard, 1);
}
}%vehicle = the vehicle object%vehicleData = vehicle datablock (reference to # of mountpoints should go there)
Honestly I don't know if that will work but in theory... :D
#11
06/28/2009 (10:40 pm)
Ok, at first I thought "doPlayerDismount" was an existing function, but now I see that I also need to write the "doPlayerDismount" function myself. I think I saw one already written on these forums somewhere. Thanks for the pointers.
#12
But hey, I was close for doing that from memory... what can I say, it was late and I had had too much jager ;)
06/29/2009 (2:03 am)
Oh! There is, I misquoted. Sorry about that!function Armor::doDismount(%this, %obj, %forced)
But hey, I was close for doing that from memory... what can I say, it was late and I had had too much jager ;)
Torque Owner Mike Rowley
Mike Rowley