vallfield 10 Posted April 27, 2017 Hi, I wanted to use in my code something like this: if (damage x > 0) then {//code }; But seems like it doesn't work like that, someone could explain? Share this post Link to post Share on other sites
pierremgi 4906 Posted April 27, 2017 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... Share this post Link to post Share on other sites
7erra 629 Posted April 27, 2017 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!"; }; Share this post Link to post Share on other sites
vallfield 10 Posted April 27, 2017 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. :/ Share this post Link to post Share on other sites
7erra 629 Posted April 28, 2017 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 1 Share this post Link to post Share on other sites
vallfield 10 Posted April 29, 2017 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! Share this post Link to post Share on other sites