Jump to content
Sign in to follow this  
Bladesfist

Detect if mine has been placed

Recommended Posts

I want to detect if the player has placed an AT Mine on the road before I send a convoy in. I have tried using a trigger and putting count (nearestObjects [position this, ["ATMine_Range_Mag"], 10]) > 0 but without any luck. This method would also give me a circular check when I want to know if the mine is inside the triggers rect. Does anyone have any ideas?

Share this post


Link to post
Share on other sites

Does anybody know how to resolve this? I have exactly the same problem. I want to have a trigger fire when a mine is placed on (not around or near) a certain stretch of road.

Share this post


Link to post
Share on other sites

Could use the "FIRED" eventHandler ?

this addEventHandler ["FIRED", {if ( (_this select 4) isKindOf "TimeBombCore") then { hint "mine planted"};  }];

This placed in the players init will hint everytime you place a mine. Then just check the players location.

or

({(typeOf _x) isKindOf "TimeBombCore"}count (nearestObjects [thistrigger,[],1]) > 0)

in a trigger condition will fire when a mine has been planted within 1m of the trigger.

Edited by Larrow

Share this post


Link to post
Share on other sites

Thanks Larrow - trouble is, the 'within 1m of the trigger'. I don't know if it's even possible to do, but I was looking for a way to detect the mine within the boundaries of a road. A square trigger works - but the within 1m etc. creates a circular trigger effect. Any ideas? Thanks for your suggestion though. As I said, I may well be looking for the impossible!

Share this post


Link to post
Share on other sites
({ ((typeOf _x) isKindOf "TimeBombCore") && {[thisTrigger, _x] call BIS_fnc_inTrigger}}count (nearestObjects [thistrigger, [], ( ((((triggerArea thisTrigger) select 0)/2)*(((triggerArea thisTrigger) select 0)/2)) + ((((triggerArea thisTrigger) select 1)/2)*(((triggerArea thisTrigger) select 1)/2)) ) ]) > 0)

Looks long and complicated but is a cover all condition. Basically it will look for all "TimeBombCore" objects with in a radius of the corner distance of the trigger, then check whether this object is actually within the triggers area. No need to change anything just chuck it in any size/shape trigger and it should be good to go. A little bit of overscan maybe on the nearestObjects but its late and im too tired to think up a better solution atm. :D

Share this post


Link to post
Share on other sites

Thanks man - seems to do the job perfectly! Guess if I want to set a specific mine, I'd just need to change "TimeBombCore" to the relevant classname? Again, many thanks!

Share this post


Link to post
Share on other sites
Guess if I want to set a specific mine, I'd just need to change "TimeBombCore" to the relevant classname?

Correct. "TimeBombCore" is a parent class that i used for testing as it catches the majority of mines/charges.

Share this post


Link to post
Share on other sites

Nice one Larrow! Spectacular help - really, really appreciated!

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  

×