Jump to content
JohnKalo

Destroying a Vehicle Part

Recommended Posts

So what I need is to destroy the engine of a vehicle so as to make it unable to move. This must be kinda simple but hard to find. So I did my research and found the:

 

vehicle player setHit ["motor", 1];

which did not work because of the name of the part that needed to be destroyed. Trying to find how to figure the name of a vehicle's part was to no avail. So I then searched some more and found this:

 

myTank setHit [getText (configfile >> "CfgVehicles" >> typeOf myTank >> "HitPoints" >> "HitRTrack" >> "name"), 1];

which was not for the engine but turning it into this:

 

myTank setHit [getText (configfile >> "CfgVehicles" >> typeOf myTank >> "HitPoints" >> "HitEngine" >> "name"), 1];

made it work. However does the above work in an MP environment or just in the editor? Because in a server I do not know what goes on with config files and such.

 

Trying to figure the name of the part like this did not work:

 

hint "getText (configfile >> "CfgVehicles" >> typeOf myTank >> "HitPoints" >> "HitRTrack" >> "name")";

trying to follow the above path was impossible since in the config file there was no HitPoints tab. Guessing the vehicle's part name with "motor", "engine", "machine" and "damnyou" did not work either. So how can you find a vehicle's part name in general? I suppose other people are looking for that answer as well.

Share this post


Link to post
Share on other sites

Wow! You're at the exact point I resolved for my new mission FurYouS to be issued soon (today, I hope)! A crew tank stuck in middle of Zagrabad.

For tracks:

yourVehicle setHitPointDamage ["hitRTrack",1];

for engine:

yourVehicle setHitPointDamage ["hitEngine",1];

 

Note: You can have engine part set to 0.7 (my case), that's not a problem for starting the engine on, or even moving if tracks are OK !  there are two ways for some consequences with a "damaged engine":

- setMass of the tank * x (x ~ 100 to be efficient enough) but the result is not really fine (skid).

- cut off / cut on , playing with setFuel

 

 

 

 

  • Thanks 1

Share this post


Link to post
Share on other sites

Thanks! The above will do the trick. Just checked FurYouS thread out. Seems like a cool mission. Can't test it since I do not use CUP.

Share this post


Link to post
Share on other sites
On 11/9/2018 at 2:29 PM, JohnKalo said:

However does the above work in an MP environment or just in the editor?

Both setHit and setHitPointDamage are arguments_local.gif so need to be run where the vehicle is local. If your executing the command in the vehicles init field or in the same code where you spawn the vehicle then it will be local.

If you are doing it at some other time where the vehicle may have changed locality( a player has entered the vehicle causing it to change locality to the players machine ) then you may need to remoteExec the command.

_hitPointName = getText( configFile >> "CfgVehicles" >> typeOf myTank >> "HitPoints" >> "HitEngine" >> "name" );
// myTank setHit[ _hitPointName, 1 ];
// [ pre param(myTank), post param([_hitPontName,1]) ] remoteExec [ command, where to run( where myTank is local ) ]
[ myTank, [ _hitPointName, 1 ]] remoteExec [ "setHit", myTank ];

 

On 11/9/2018 at 2:29 PM, JohnKalo said:

So how can you find a vehicle's part name in general?

GetAllHitPointsDamage will return an array of [ hintpoint names, selection names, damage ]

If a hitpoint does not have a name or there are hitpoints on the object that have the same name, you may need to use setHitIndex where the index is the index of the hitpoint name in the hitpoint names array returned by getAllHitPointsDamage.

  • Like 2
  • Thanks 1

Share this post


Link to post
Share on other sites

It is run via a trigger sometime in-game. As far as I am aware, triggers are applied to the host and to the clients so do I need the remoteExec? If yes I will use it. Thanks.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×