Jump to content
Sign in to follow this  
dikkeduif

grenade detection within trigger area

Recommended Posts

Hey guys,

I'm trying to detect a grenade within a trigger area.

The thing I want to do is:

* BLUFOR soldier throws a grenade (he's outside the trigger area) into the trigger area

* The trigger detects this grenade and all OPFOR in this area play an animation

The reason why I want to do this is because the ACE_Flashbang does not always trigger the 'stunned' animation of the AI's...

How can I achieve this? Any help is appreciated

Share this post


Link to post
Share on other sites

Track the position of the grenade using a fired eventhandler. When projectile (_this select 6 in recent betas) is no longer alive, the last position update is what you're looking for. As you now have the position, use BIS own fn_InTrigger (something like that, not 100% sure what it is called) function (place functions manager module) to check if it is within the trigger area. If true, assign the animations.

Share this post


Link to post
Share on other sites

Ok I kinda understand thanks :)

But what do you mean in recent betas? Is _this select 6 not working in OA 1.54?

> nm, I know what you mean, I checked the fire event in the wiki :)

Share this post


Link to post
Share on other sites

Well I managed to get the grenade object when it's being thrown with select 6.

The problem is when I do _pos = getPos _grenade; it gives me the position at the beginning of the throw.

I tried delaying the getPos function with

while {alive _grenade} do { };

_pos = getPos _grenade;

But by then the _grenade object doesn't exist anymore I think, so I can't get a position from an object which isn't there anymore.

I tried the 'sleep' function, but it doesn't allow me to delay in my addEventHandler...

Share this post


Link to post
Share on other sites

Spawned or execVM'ed code will allow sleep and waitUntil, but not a called code.

Not properly tested and might be better methods, but try something like this:

player addEventHandler ["fired",{_this call test}];
myHeliObject = "HeliH" createVehicle getPos player;
player addMagazine "HandGrenade";

test = {
if (_this select 1 == "THROW") then {
	if (_this select 5 == "HandGrenade") then {
		_this spawn {
			_bul = _this select 6;
			_pos = getPos player;
			_newpos = getPos _bul;
			while{alive _bul} do {
				_newpos = getPos _bul;
				_pos = _newpos;
				sleep 0.025;
				hint format ["dist: %1", _pos distance player];
				myHeliObject setPos _pos;
			};
		};
	};
};
};

Messed up my initial reply so I removed it.

Note that the above will not work until you throw the "correct" handgrenade (the last one), since that class is the only one that triggers the script. Replace with whatever you're using for a flashbang.

Edited by CarlGustaffa

Share this post


Link to post
Share on other sites

Hmm well I can't seem to find any decent stun / knockback animation... I wanted to use the one from the ACE mod, but I can't figure out how this works...

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  

×