Jump to content
nomadd

Detecting any explosion in a defined area

Recommended Posts

I am stuck on this. I am making a stealth coop mission. (Making the AI play nice for a stealth mission has been a real challenge). At the moment, using EventHandlers I have the area of operations pretty well covered. If a player throws a grenade, or smoke or fires an un-suppressed weapon(yes, this is "Hollywood" style silenced weapons) it will alert the enemy kick the AI out of safe mode spawn reinforcements and everything goes sideways. When testing I found I could detonate any type of explosive and the AI goes about their day like nothing happened. I have looked at the explosion EH but it needs to be attached to an object to detect damage. I need to be able to detect any explosion with in the AO then execute code that will sound the alarm.

Quote

Triggered when a vehicle or unit is damaged by a nearby explosion. It can be assigned to a remote unit or vehicle but will only fire on the PC where EH is added and explosion is local, i.e. it really needs to be added on every PC and JIP and will fire only where the explosion is originated.

 

this is the code I use to detect silencers and thrown weapons ie. grenades, smoke etc. the inarea is a trigger covering the the AO

Fnc_Nearbase = {

private ["_eh_1"];

_eh_1 = player addEventHandler ["firedman",{ 
									params ["_unit","_weapon","_muzzle","_mode","_ammo","_magazine","_projectile","_vehicle","_hassilencer"];
									
							if (_unit inArea trg_NB) then 
							{
									_hassilencer = (_this select 0) call Hassilencer;
									if !(_hassilencer) then 
									{										
										[format ["%1 did not equip a silencer and just alerted the enemy",name _unit]] remoteExec ["hint",[0,-2] select isDedicated];
										if (isnil {obj_alarm getvariable "alarm"}) then 
										{
											if (isnil {obj_alarm getvariable "alarm"}) then 
											{
												obj_alarm setvariable ["alarm",true,true];
													
											};
										};
									};
								if (configname (inheritsFrom (configFile >> "cfgWeapons" >> "throw" >>(_this select 2) )) isEqualTo "ThrowMuzzle") then 
									{
										[_unit,_ammo] spawn 
										{
											params ["_unit","_ammo"];
											sleep 6;
											[format ["%1 just threw a %2 and has alerted the enemy", name _unit, _ammo]] remoteExec ["hint",[0,-2] select isDedicated];	
											if (isnil {obj_alarm getvariable "alarm"}) then 
											{
											if (isnil {obj_alarm getvariable "alarm"}) then 
											{
												obj_alarm setvariable ["alarm",true,true];
													
											};
											};
										}; 
									};	
							};		
				}];

};

I know this is probably simple but for some reason I just cannot find a solution that works

Share this post


Link to post
Share on other sites

In a repeatable trigger, covering the area you want:

condition:

{_x inArea thisTrigger} count allMissionObjects "#explosion" > 0

 

Note: the trigger acts and deacts quickly, in other words the trigger doesn't stay activated for a long time (0.5 sec. ?). That doesn't matter here.

  • Like 2

Share this post


Link to post
Share on other sites

@pierremgi

 

Thanks, I will try that out as soon as I can. I have never seen "#explosion" before, didn't realize that was even a thing. I have been out of arma for about a year. I will try and do some research. 

Share this post


Link to post
Share on other sites

Hi

 

Is there another way of detecting explosions in an area that isn't so demanding on your system?

 

Thanks

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

×