Jump to content

vallfield

Member
  • Content Count

    5
  • Joined

  • Last visited

  • Medals

Posts posted by vallfield


  1. 17 hours ago, 7erra said:
    
    tower addEventHandler ["Explosion", {if (_this select 1 > 0.7) then {(_this select 0) setDamage 1;}}];

    https://community.bistudio.com/wiki/Arma_3:_Event_Handlers#Explosion

     

    The arguments used are:

    _this select 0: The tower itself

    _this select 1: Damage done to the tower by an explosion (for Explosive Charge and Explosive Satchel roughly 0.8)

     

    If the tower is a map object you have to do the following:

    
    // Transmitter tower
    _tower = nearestObject [position, "Land_TTowerBig_1_F"];
    _tower addEventHandler ["Explosion", {if (_this select 1 > 0.7) then {(_this select 0) setDamage 1;}}];
    
    // Transmitter tower (tall)
    _tower = nearestObject [position, "Land_TTowerBig_2_F"];
    _tower addEventHandler ["Explosion", {if (_this select 1 > 0.7) then {(_this select 0) setDamage 1;}}];

    https://community.bistudio.com/wiki/nearestObject

     

     

    It works! Thanks! And now I know how the EH arrays works! Thank you very much!


  2. 56 minutes ago, pierremgi said:

    This work if you call the code in due time. In other word, a if.. then.. check once, not repeatedly like in a loop.

    You can use a loop like while {something true} do { waitUntil {damage..};  or if (damage ...] then {...} ... };

     

    or better, use an event handler ("hit" or "handleDamage"...)

     

    NB: x is not an accurate variable like in math. use _x in a foreach loop or something defined before: player, myUnit...

     

    52 minutes ago, 7erra said:

    If you are referring to the magic variable _x then you'd have to use _x instead of x.

    Also only the damage of objects that can be damaged can be returned. I'd need some more information on what you are doing.

    Try to use brackets ():

    
    if ((damage x) > 0) then {/*CODE*/};

    Example from the wiki:

    
    if ((damage player) > 0.1) then { 
        player groupChat "I'm hurt! Medic!"; 
    };

     

     

    I wanted to use it on a transmitter tower, to get to blow it up with just one normal charge, the brackets didn't work.

    Also tried with a while loop but same result. It seems like  it doesn't read it if you use damage x.

    I don't really understand how the event handler work.  :/

×