Jump to content

Recommended Posts

Hi

is it possible to create mines that do not explode on certain side?

 

Like create mine from script but it only explodes if east unit drives over it.

 

I think this was possible in arma 2 but don't know how

 

thx!

 

Edited by gc8
arma 2

Share this post


Link to post
Share on other sites

You could do it with a trigger and use explosives that are command detonated only. 

Share this post


Link to post
Share on other sites

Yes it is, i forgot the line but check out phronks ied spawn script. 

It has all the code you might need. 

 

Good luck;) 

Share this post


Link to post
Share on other sites
37 minutes ago, Vandeanson said:

Yes it is, i forgot the line but check out phronks ied spawn script. 

It has all the code you might need. 

 

Where can I find this epic script you speak of? I tried google but didn't really find anything

Share this post


Link to post
Share on other sites

Thanks @EO. Well I dived it to the code but it seems the IED script does not use mines but it creates an explosion by spawning some explosive ammunition. So this is not really what I'm looking for 😕

Share this post


Link to post
Share on other sites

Hello there gc8 !

 

I liked your idea so this is an example :

The mines will be enabled when the player is on the current distance :

GF_allPlayers = allUnits select {isPlayer _x && {!(_x isKindOf "HeadlessClient_F")}};
GF_distance = 5;


[]spawn {
while {true} do {

	waituntil{sleep 1;

	{
	_this_Mine = _x;
		if (({_x distance _this_Mine > GF_distance}count GF_allPlayers > 0)

			) then {	
			
			_x enableSimulation false;
			hint "disarmed";
		}else{
			_x enableSimulation true;
			hint "armed";
		};
	}forEach allmines;
	
	};
};	
};	

 

Share this post


Link to post
Share on other sites

So after some tests ,

trying to add this instead, i don't know why , it doesn't work with the code below and i tried a lot of different examples :

GF_Enemy = allUnits select {!isPlayer _x && side _x isEqualTo east};

 

Share this post


Link to post
Share on other sites
13 minutes ago, GEORGE FLOROS GR said:

So after some tests ,

trying to add this instead, i don't know why , it doesn't work with the code below and i tried a lot of different examples :


GF_Enemy = allUnits select {!isPlayer _x && side _x isEqualTo east};

 

 

# Still no idea !

 

though ,

this is fixed for both SP and MP

GF_allPlayers = [];
{if (isPlayer _x) then{GF_allPlayers pushBack _x;};}forEach playableUnits;			

GF_distance = 10;
			
			
[]spawn {
while {true} do {


if (isMultiplayer) then {	
	
	waituntil{sleep 1;

		{
		_this_Mine = _x;
			if (
			
				({_x distance _this_Mine > GF_distance}count GF_allPlayers > 0)
							
				) then {	
				
				_x enableSimulationGlobal false;
				hint "disarmed";
			}else{
				_x enableSimulationGlobal true;
				hint "armed";
			};
		}forEach allmines;
	
	};
	
	}else{
	
		waituntil{sleep 1;

		{
		_this_Mine = _x;
			if (
				((_this_Mine distance player) > GF_distance)
							
				) then {	
				
				_x enableSimulation false;
				hint "disarmed";
			}else{
				_x enableSimulation true;
				hint "armed";
			};
		}forEach allmines;
	
		};
	
		};	
	};
};

 

  • Like 1

Share this post


Link to post
Share on other sites

Thanks @GEORGE FLOROS GR, using the enablesimulation is a good idea (Assuming it works). I will try that if all else fails

  • Thanks 1

Share this post


Link to post
Share on other sites

Problem with checking distance to mine is that vehicles of different length detonate the mine from different distances.

 

Edit: I used boundingBoxReal to put the length of the vehicle to the calculations

  • Like 1

Share this post


Link to post
Share on other sites

I tried the enable/disable simulation of the mines in eachFrame EH but it became too laggy too fast. with just 10 mines FPS drops to around 15 because the mines have to be checked against all mission vehicles.

 

So I'm still looking for a solution for this.

 

I think in arma2 in the BeCTI there was friendly mine option but don't know if there's code for that. Looked already in the mission but couldn't find it

Share this post


Link to post
Share on other sites
49 minutes ago, gc8 said:

enable/disable simulation

 

Did you test my script above , with a big amount of mines ?

Share this post


Link to post
Share on other sites
7 hours ago, gc8 said:

I tried the enable/disable simulation of the mines in eachFrame EH but it became too laggy too fast. with just 10 mines FPS drops to around 15 because the mines have to be checked against all mission vehicles.

 

So I'm still looking for a solution for this.

 

I think in arma2 in the BeCTI there was friendly mine option but don't know if there's code for that. Looked already in the mission but couldn't find it

Use a combination of trigger + enableSim.

Set the trigger activation side to player side. And for the activation code, use:

[thisTrigger] spawn {
 params ["_trig"];
 waitUntil {
  _friendlies = list _trig;
  /*
   put the enableSim code here
  */
  !(triggerActivated _trig)
 }
}

And obviously, for trigger deactivation code, you only need to re-enableSim.

This code is more performance friendly (it only uses trigger units, faster than allVehicles, and waitUntil, which is faster than onEachFrame)

 

P.S: Plz forgive any typos. I typed this on my phone! 

  • Like 1
  • Thanks 1

Share this post


Link to post
Share on other sites
14 hours ago, GEORGE FLOROS GR said:

Did you test my script above , with a big amount of mines ?

 

I think in order for this to work the check has to be made in EachFrame EH. If not the player will simply in fast vehicle drive over the mines without the mine exploding

 

7 hours ago, Leopard20 said:

Use a combination of trigger + enableSim.

 

Tried that just now but player can drive over the mine without triggering it if in fast enough vehicle

 

Edit: Being able to drive over the mines seems to happen with normal non scripted mines as well

Share this post


Link to post
Share on other sites
7 hours ago, Leopard20 said:

and waitUntil, which is faster than onEachFrame)

 

4 minutes ago, gc8 said:

I think in order for this to work the check has to be made in EachFrame EH. If not the player will simply in fast vehicle drive over the mines without the mine exploding

 

Isn't it faster?

 

Share this post


Link to post
Share on other sites

eachframe runs at each frame like the name says but waituntil doesn't run on each frame

Share this post


Link to post
Share on other sites
3 minutes ago, GEORGE FLOROS GR said:

You can also change the distance activation.

 

Yep tried that already

 

What I'm using:

 

_trigger setTriggerArea [4,4, 0, false];

Tested with Ifrit, and it works ok

  • Like 1

Share this post


Link to post
Share on other sites
10 hours ago, gc8 said:

eachframe runs at each frame like the name says but waituntil doesn't run on each frame

WaitUntil does run on each frame (it may miss a frame or two but it's not that important) but terminates the script if it gets too long. That's why it's faster. onEachFrame, however, runs the script completely and it may hurt performance. I had a semi heavy script running using onEachFrame and it caused nearly 7~8 FPS drops compared to waitUntil without any significant difference in terms of its effects.

 

10 hours ago, gc8 said:

 

Yep tried that already

 

What I'm using:

 


_trigger setTriggerArea [4,4, 0, false];

Tested with Ifrit, and it works ok

You can go with even bigger radius. 10 or 15 m should be fine, that way, the trigger will get activated in time.

Share this post


Link to post
Share on other sites
14 hours ago, Leopard20 said:

WaitUntil does run on each frame (it may miss a frame or two but it's not that important) but terminates the script if it gets too long.

 

I think it depends on how many scripts you have in total and how heavy they are. Because according to my knowledge waituntil runs in scheduled environment, and the more scripts you have the fewer times is the waituntil processed.

 

14 hours ago, Leopard20 said:

I had a semi heavy script running using onEachFrame and it caused nearly 7~8 FPS drops compared to waitUntil

 

Yeah I have ran to this problem many times. You just have to use the eachFrame wisely so it wont create lag.

 

14 hours ago, Leopard20 said:

You can go with even bigger radius. 10 or 15 m should be fine, that way, the trigger will get activated in time.

 

Problem with that I think is that somebody maybe sitting on the mine and when enemy gets 15m close it will enable the mine... aaand bad result 🙂

 

 

Share this post


Link to post
Share on other sites
34 minutes ago, gc8 said:

think it depends on how many scripts you have in total and how heavy they are. Because according to my knowledge waituntil runs in scheduled environment, and the more scripts you have the fewer times is the waituntil processed.

that's wrong waitUntil runs in that environment where it is executed. Scheduler page helps to clarify.

 

Also it doesn't matter how much scripts are in scheduled environment. Every script get 3ms per frame for execution there...

This means if the waitUntil runs scheduled then it will be processed in one frame if its executed in 3 ms. if it takes longer then it gets a break until next frame and continues there. In that case it can't executed completely on each frame.

  • Like 1

Share this post


Link to post
Share on other sites
1 hour ago, gc8 said:

 

I think it depends on how many scripts you have in total and how heavy they are. Because according to my knowledge waituntil runs in scheduled environment, and the more scripts you have the fewer times is the waituntil processed.

 

 

Yeah I have ran to this problem many times. You just have to use the eachFrame wisely so it wont create lag.

 

 

Problem with that I think is that somebody maybe sitting on the mine and when enemy gets 15m close it will enable the mine... aaand bad result 🙂

 

 

Good point. Try this instead.

Set the activation side to all sides. Then the trigger units (list _trigger) gives all units on trigger area. You just have to use a "select {side _x == side player}" to see how many of them are on your side and how many of those units' bounding boxes are within the mine activation radius. This one should be the best.

If you'd like to use oneachframe and have many mines, I recommend something like this:

When creating the trigger:

_trigg setVariable ["gc_mine", _mine];

 

As for activation code:

[thisTrigger] call {

 params ["_trig"];

gc_trigs pushBackUnique _trig;

 ["gc_onEachF", "onEachFrame", {

  if (count gc_trigs == 0) exitWith {

    ["gc_onEachF", "onEachFrame"] call BIS_fnc_removeStackedEventHandler;

  };

  {

   _trig = _x;

   if !(triggerActivated _trig) then {

    gc_trigs = gc_trigs - [_x]

   } else {

      _mine = _trig getVariable ["gc_mine", objNull];

     /*

      put the enableSim code here

     */

   }

  } forEach gc_trigs;

 }] call BIS_fnc_addStackedEventHandler

}

 

Share this post


Link to post
Share on other sites

@Leopard20 thanks, not sure I understand the example correctly , could have used some code tags to make it easier to read. But anyway I did come up with solution to this, I think the delay with the mine explosion is in the game engine it self and not in the script activating the mine (if using trigger approach).

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

×