Jump to content
Sign in to follow this  
Cpt_Robertson

Ap mine distance/detection problem.

Recommended Posts

Hi there.

I'm needing some help with a simple AP mine script that detects when ANY game object that enters into a 1M radius of the mine i.e. :-

? (Any unit regardless of side or type) distance _APmine <1 :goto "detonate"

The idea is I want any vehicle or unit, regardless of it's side, class 'etc' to be able to trigger the mine to detonate - I've already successfully added some code into the script so only units flying under 2M can set them off - to stop helo's from exploding the mines at high altitude.

I can do a simple 'unit1 distance unit2 <10' script and it works fine, but its for specific units and I'm stumped as to how I can get the thing (Anti-personnel mine in this case) to detonate when ANY unit comes within 1M of it.

 

I've already done a simple 1M radius trigger in the in-game editor that detects 'any' unit that enters it, but I'd prefer to make a script that does this instead, outwith the editor - this would make it easier to implement another script that will allow players to place their own mines during a game, and not have to worry about placing hundreds of those little blue triggers via the editor.

Thanks for any help anyone can offer on this. :-)

Share this post


Link to post
Share on other sites

Thanks Walker.

I've taken a look at an older version of the CoC Mines pack - that came with the Nam Pack I think - and it had some excellent triggers, unfortunately most of them were added via the editor rather than scripted into the addon itself (except for the placeable Claymores - which were detonated via the action menu), but I'll download this new one and examine it thoroughly.  Who knows, I might be pleasantly surprised.  smile.gif

Share this post


Link to post
Share on other sites

Hi Cpt Robertson,

I understand your problem.  You want a triggerless proximity detonation system for infantry.

Triggers have to be placed by the mission editor, and a whole bunch of triggers can cause undesirable performance side-effects.

Well, here's the bad news.  If there were an obvious way to do it, I would have included it in CoC_mines.

That doesn't mean it's not possible.  One solution is to write a nearestobject scan routine: poll a grid spaced about 1 meter from the mine and record every object that's not the mine.  Using CountType, filter out those that are of class "MAN" or below, take those, measure their distance to the mine: if the distance is less than one or a format of the distance is -1.#IND (or something like that), set off the mine.

The problem is that such a method uses even more overhead than a trigger does.

Another solution is to put a bunch of triggers on the map, named sequentially (if you name one, and copy it, it will number by itself).  Then you make an array with the names of all those triggers, and you rattle them off as needed in the game.

Another solution is to make one master trigger, use thislist to get the list of of players, and check their distances to each of the mines on the map.

Good Luck

Dinger/Cfit

Share this post


Link to post
Share on other sites

Just stomp on the the thing. biggrin.gif

Sorry couldn't resist.

Share this post


Link to post
Share on other sites
Guest jacobaby

I dont know if its any help, but you can use a bunch of lines to check the type of nearest object and explode it accordingly,

If you unpbo the BAS_Cargo.pbo that comes with the MH47 you will see a script called helocargo.sqs

That detects the nearest objects of a set type and will demonstrate it.

For the sake of the servers performance, whatever method you use be sure to limit the number placed, as all methods are fairly cpu intense.

TJ

Share this post


Link to post
Share on other sites

Hi all

Sorry Cpt_Robertson I did not realise you were on about the ability to plant mines in game; remind me to READ THE QUESTION! hits own head with joystick.

Dinger's suggestion about the array of triggers is the best solution.

For the record at CoC other options we thought of were:-

*   An unstable invisible colision detection LOD (an upside down cone with more mass at the top) but soldiers would run through it or bounce off it even if its mass was minute. It would only fall over if a tank bumped it.

*   Using getin events but they only trigger at the man not the mine. (Sudden thought make the mine a vehicle with a driver hmm?!~)

We are open to suggetions community and BIS

OFP2 I guess confused.gif

Kind Regards walker

Share this post


Link to post
Share on other sites
Guest

</span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Quote (jacobaby @ 02 May 2003,13:50)</td></tr><tr><td id="QUOTE">I dont know if its any help, but you can use a bunch of lines to check the type of nearest object and explode it accordingly,<span id='postcolor'>

In principle yes. I use it for the torpedo addon guidance system. The problem is that nearestObject has a fixed radius it checks which means that it is very CPU-unfriendly.

While this may not be a problem for choppers or torpedoes, it certainly is for mines since you want lots of them.

If you still want to try it, the principle is very simple.

1) Get the nearest object to the mine (nearestObject function)

2) Get the type of the object (typeOf command)

3) Check that the object fulfills your boundary conditions (i.e that it's on the ground, within a certain radius, that it doesn't move faster than a certain velocity, that it isn't a game logic or trigger etc etc etc)

Share this post


Link to post
Share on other sites

Excellent feedback from everyone so far, thanks.

I did think of using the nearestObject method to scan for units near each mine, but again I realised that this method would put shedloads of work on the cpu, especially for lower end machines or games where large minefields were being placed, and would make online play almost impossible with the lag it would create - Deep down I was hoping that there was an easier method or command I'd missed somehow, oh well, lol

Just out of curiosity - I noticed that triggers can be added by creating the vehicle 'Detector' in a script.  Has anyone figured out if there's a way of making one with a radius 'etc'?

Probably clutching at straws now, but what the heck, at least we can say we tried. wink.gif

Thanks again for the feedback and ideas put forward - some really good ones in this post.

P.S - Nice work on the BAS MH-47 Jacobaby.  Pass on my congrats to the rest of the team for that gem, some phenominal scripting went into that one. smile.gif

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  

×