Jump to content
Sign in to follow this  
beako

Help with ammunition position with "Fired" EH

Recommended Posts

HI All,

 

I'm trying to get the final position of a guided bomb that is dropped from a plane with the following:

_plane addEventHandler ["Fired", {
 _projectile = nearestObject [_this select 0,_this select 4];	
     waitUntil {
	if !(isNull _projectile) then {
	   sleep 0.1;
           hint format ["BOMB _plane nearEntities \n\n _projectile: %1 \n\n getPosATL: %2", _projectile, getPosATL _projectile];};
	   isNull _projectile;
	};
}];

but it only returns the position the bomb was dropped from and does not seem to loop.

 

Then I get an "Error generic error in expression" message with |#|isNull _projectile ?

 

Any suggestion for finding the final bomb position where it explodes?

Share this post


Link to post
Share on other sites
Guest

I don't get it ? There is no loop in your code ??

Share this post


Link to post
Share on other sites

Like harmdhast said, your code is very wonky.

Eventhandlers won't allow sleep unless you use spawn inside them.

Why are you using a fired eventhandler but are using nearestObject to get the bomb? I don't get it.

 

Something like this could do the trick:

_plane addEventHandler ["Fired", {

    params ["_firer","_weapon","_muzzle","_mode","_ammo","_magazine","_projectile"];

    _check = [_projectile] spawn {

        params ["_projectile"];
        _bombPos = getposATL _projectile;

        waituntil {if (alive _projectile) then {_bombPos = getposatl _projectile};!alive _projectile};
        systemchat str _bombPos;
        
    }

}];

Cheers

Share this post


Link to post
Share on other sites

I don't get it ? There is no loop in your code ??

waituntil is a perfectly good loop in some situations.

Share this post


Link to post
Share on other sites
Guest

waituntil is a perfectly good loop in some situations.

In this case it does not act as a loop for the bomb pos because it is only executed once anyway.

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  

×