Jump to content
Sign in to follow this  
Kolmain

Detect If Explosive Nearby

Recommended Posts

I'm trying to make a radio tower only destructible via explosives. The latest update broke this code for me, but I'd like to change it to include, dynamically, all placeable explosives. Is there some config magic we could work to do so?

[color="#FF8040"][color="#191970"][b]private[/b][/color] [color="#8B3E2F"][b][[/b][/color][color="#7A7A7A"]"_radio"[/color][color="#8B3E2F"][b],[/b][/color][color="#7A7A7A"]"_loop"[/color][color="#8B3E2F"][b],[/b][/color][color="#7A7A7A"]"_bombs"[/color][color="#8B3E2F"][b]][/b][/color][color="#8B3E2F"][b];[/b][/color]




[color="#1874CD"]_radio[/color] [color="#8B3E2F"][b]=[/b][/color] [color="#000000"]_this[/color] [color="#191970"][b]select[/b][/color] [color="#FF0000"]0[/color][color="#8B3E2F"][b];[/b][/color]
[color="#1874CD"]_radio[/color] [color="#191970"][b]allowDamage[/b][/color] [color="#000000"]false[/color][color="#8B3E2F"][b];[/b][/color]
[color="#1874CD"]_loop[/color] [color="#8B3E2F"][b]=[/b][/color] [color="#000000"]true[/color][color="#8B3E2F"][b];[/b][/color]
[color="#1874CD"]_bombs[/color] [color="#8B3E2F"][b]=[/b][/color] [color="#8B3E2F"][b][[/b][/color][color="#8B3E2F"][b]][/b][/color][color="#8B3E2F"][b];[/b][/color]


[color="#191970"][b]while[/b][/color] [color="#8B3E2F"][b]{[/b][/color][color="#1874CD"]_loop[/color][color="#8B3E2F"][b]}[/b][/color] [color="#191970"][b]do[/b][/color]
[color="#8B3E2F"][b]{[/b][/color]
[color="#191970"][b]sleep[/b][/color] [color="#FF0000"]1[/color][color="#8B3E2F"][b];[/b][/color]
[color="#1874CD"]_bombs[/color] [color="#8B3E2F"][b]=[/b][/color] [color="#1874CD"]_radio[/color] [color="#191970"][b]nearObjects[/b][/color] [color="#8B3E2F"][b][[/b][/color][color="#7A7A7A"]"DemoCharge_Remote_Mag"[/color][color="#8B3E2F"][b],[/b][/color] [color="#FF0000"]10[/color][color="#8B3E2F"][b]][/b][/color][color="#8B3E2F"][b];[/b][/color]
[color="#191970"][b]if[/b][/color][color="#8B3E2F"][b]([/b][/color][color="#191970"][b]count[/b][/color] [color="#8B3E2F"][b]([/b][/color][color="#1874CD"]_bombs[/color][color="#8B3E2F"][b])[/b][/color] [color="#8B3E2F"][b]>[/b][/color] [color="#FF0000"]0[/color][color="#8B3E2F"][b])[/b][/color] [color="#191970"][b]then[/b][/color]
[color="#8B3E2F"][b]{[/b][/color]
	[color="#1874CD"]_radio[/color] [color="#191970"][b]allowDamage[/b][/color] [color="#000000"]true[/color][color="#8B3E2F"][b];[/b][/color]
	[color="#1874CD"]_loop[/color] [color="#8B3E2F"][b]=[/b][/color] [color="#000000"]false[/color][color="#8B3E2F"][b];[/b][/color]
[color="#8B3E2F"][b]}[/b][/color][color="#8B3E2F"][b];[/b][/color]
[color="#8B3E2F"][b]}[/b][/color][color="#8B3E2F"][b];[/b][/color][/color]

Made with KK's SQF to BBCode Converter

Share this post


Link to post
Share on other sites

You can use an eventhandler instead of allowDamage and loop.

Checking the projectile that caused the damage and comparing it to "PipeBombBase" should allow Demo Charges,Explosive Charges and IED's.

private ["_radio"];

_radio = _this select 0;

_radio addEventHandler [ "HandleDamage", {
_tower = _this select 0;
_projectile = _this select 4;

if !( _projectile isKindOf "PipeBombBase" ) then {
	damage _tower;
};
}];

If you want to include the smaller explosives like Slams and Claymores use "TimeBombCore" instead.

Edited by Larrow

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  

×