mad_cheese 593 Posted September 25, 2013 Does anyone have any info on the BIS_fnc_saa_handleDamage function? I couldn't find any info in the function browser, the function is also not defined anywhere inside of the mission folder. I spotted it in "Showcase_Arma.Altis" while I was looking for BIS way to be able to destroy armored vehicles with only one satchel. The init code contains a "handledamage" eventhandler that calls the function. this addEventhandler ["HandleDamage", {[b] _this call BIS_fnc_saa_handleDamage[/b]; }]; If I add that eventhandler to a armored vehicle in another mission of mine, it doesn't do anything, a satchel will still not destroy it. I know there's other workarounds to increase the damage, but those are very likely to prevent the vehicle from showing up in the player's statistics. Share this post Link to post Share on other sites
kylania 568 Posted September 25, 2013 This is that function: //Parameters private ["_object", "_selectionName", "_damage", "_source", "_projectile"]; _object = [_this, 0, objNull, [objNull]] call BIS_fnc_param; _selectionName = [_this, 1, "", [""]] call BIS_fnc_param; _damage = [_this, 2, 0, [0]] call BIS_fnc_param; _source = [_this, 3, objNull, [objNull]] call BIS_fnc_param; _projectile = [_this, 4, "", [""]] call BIS_fnc_param; if (_object isKindOf "Man" || _object isKindOf "B_APC_Tracked_01_rcws_F" || _object isKindOf "B_MBT_01_cannon_F" || _object isKindOf "O_MBT_02_cannon_F") then { //Only allow damage if caused by the player if (_source == player || _source == vehicle player) then { _damage; } else { 0; }; } else { //Enemy batteries //If damage is caused by satchel charge we manually destroy it if (_source == player || _source == vehicle player) then { //Make sure it was a satchel charge causing the damage if (_projectile == "DemoCharge_Remote_Ammo" && _damage > 0.15) then { 1; } else { _damage; }; } else { _damage; }; }; Share this post Link to post Share on other sites
mad_cheese 593 Posted September 26, 2013 Awesome! thanks Kylania. I also found out how you got that, so I learned two things today :D Share this post Link to post Share on other sites
Pac Man 10 Posted September 26, 2013 (edited) here's a simple version. It will completely destroy the vehicle with only one charge. Object / vehicle Init: this addEventHandler ["handleDamage", {if ((_this select 4) == ("DemoCharge_Remote_Ammo")) then {(_this Select 0) setdamage 1} Else {(_this Select 0) setdamage (_this select 2)}}]; Edited September 26, 2013 by Pac Man included the ELSE statement so the vehicle can recieve other, normal damage aswell. IE; RPGs Share this post Link to post Share on other sites
2nd ranger 282 Posted September 26, 2013 this addEventHandler ["handleDamage", {if ((_this select 4) == ("DemoCharge_Remote_Ammo")) then {(_this Select 0) setdamage 1} Else {(_this Select 0) setdamage (_this select 2)}}]; The problem with this is that the vehicle will be destroyed when it takes any amount of damage from that ammo type, no matter how small. So a charge could be detonated 20 metres away from a tank and it would still be totally destroyed. That's why the BIS function has a check for initial damage being greater than 0.15. Easily added though. Share this post Link to post Share on other sites
mad_cheese 593 Posted September 26, 2013 The problem with this is that the vehicle will be destroyed when it takes any amount of damage from that ammo type, no matter how small. So a charge could be detonated 20 metres away from a tank and it would still be totally destroyed. That's why the BIS function has a check for initial damage being greater than 0.15. Easily added though. that's true, also the destroyed vehicle will not show up in the player's statistics (in sp missions that's a bummer imo) Share this post Link to post Share on other sites
celery 8 Posted September 26, 2013 You don't use setDamage in the HandleDamage event handler, you just provide a damage value. unit addEventHandler ["HandleDamage", {1}]; Share this post Link to post Share on other sites
CJoke 11 Posted September 26, 2013 if you use setdamage, you should return 0 to disable the arma-internal handledamage processing unit addEventHandler ["HandleDamage", {(_this Select 0) setDamage 0.5;0}]; Share this post Link to post Share on other sites
celery 8 Posted September 26, 2013 if you use setdamage, you should return 0 to disable the arma-internal handledamage processingunit addEventHandler ["HandleDamage", {(_this Select 0) setDamage 0.5;0}]; Returning 0 just makes the unit's damage 0 after every hit. You disable the handling by returning nothing. setDamage has no place in the handler, it might mess up damage ownership and it offers nothing that returning a damage value doesn't unless you want equal damage distribution across all parts for some reason. Share this post Link to post Share on other sites
mad_cheese 593 Posted September 26, 2013 (edited) this works nicely: unitname addEventHandler [ "HandleDamage", { if (((_this select 4) == "DemoCharge_Remote_Ammo" && (_this select 2) > 0.15) OR ((_this select 4) == "SatchelCharge_Remote_Ammo" && (_this select 2) > 0.15)) then {1;} else {_this select 2}; } ]; The damage is only increased when caused by satchel or democharge, otherwise it returns the normal damage value. The killed/destroyed vehicle will show up in the statistics of the satchel's owner. Edited September 26, 2013 by Mad_Cheese Share this post Link to post Share on other sites
kylania 568 Posted September 26, 2013 Even shorter: if (((_this select 4) in ["DemoCharge_Remote_Ammo", "SatchelCharge_Remote_Ammo"]) && ((_this select 2) > 0.15) ) then {1} else {_this select 2}; Share this post Link to post Share on other sites