Jump to content
Sign in to follow this  
simicsko

If I hit an unit, then die

Recommended Posts

Hi all!

There is an enemy infantry group.

What I want to do is that if I hit any enemy soldiers and their injury is higher than 0.8, for example, they should die.

It would be important that the players are not affected.

How to handle this event? Does anyone have any ideas?

Share this post


Link to post
Share on other sites

You can look at the "handledamage" eventhandler:

Quote

 

unit_affected addEventHandler ["HandleDamage", {

params ["_unit", "_selection", "_damage", "_source", "_projectile", "_hitIndex", "_instigator", "_hitPoint", "_directHit"];

If !( isPlayer _unit) then { // check if the unit is not a player

If (_damage > 0.8) then { // check damage

_unit setdamage 1 //kill the unit

};

};

}];

 

Something like that but I'm a bit rusted.

  • Like 1

Share this post


Link to post
Share on other sites
3 hours ago, cool=azroul13 said:

unit_affected addEventHandler ["HandleDamage", {

params ["_unit", "_selection", "_damage", "_source", "_projectile", "_hitIndex", "_instigator", "_hitPoint", "_directHit"];

If !( isPlayer _unit) then { // check if the unit is not a player

If (_damage > 0.8) then { // check damage

_unit setdamage 1 //kill the unit

};

};

}];

 

It works! Thank you very much; 😉

Share this post


Link to post
Share on other sites

My son and I (to avoid shooting soldiers) downloaded the Max Terminator MOD. Since you have to shoot a lot at these robots to destroy them, they are also too accurate, so I thought of this solution. So their accuracy is maintained, but they take fewer shots to destroy. This was the final solution:

 

{   
        _x addEventHandler ["HandleDamage",

           {
            params ["_unit", "_selection", "_damage", "_source", "_projectile", "_hitIndex", "_instigator", "_hitPoint", "_directHit"];
               If (typeOf _unit == "Max_terminator_skeleton") then

                   {
                   If (_damage > 0.3) then { _unit setdamage 1};
                   };
           }
        
       ];

}foreach allunits

 

 

cool=azroul13, Thanks for your help! 😉

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
Sign in to follow this  

×