Jump to content

Recommended Posts

Hey guys,

 

I am working on a training site for my group which will feature, among other things, an explosive specialist/mine defusal training. In order to do so I would like to create a kind of a course which has to be finished without the mines exploding.

 

The help that I'm looking for concerns a script, obviously. I would like to have the option to spawn random(?) mines and explosives in random(?) areas within the designated course. Let's say it will be a fenced-out passage through a few buildings + a bit of grassy terrain.

 

I would like to have the option to spawn, respawn randomly or at the very least restart the placed explosives within that course with probably a simple addAction command that would be attached to some object at the beginning of the course. I can handle the addAction button but I am almost completely unaware how to write the script which would respawn the explosives if the participant died and wanted to retry the course. That respawn option would also be used by the next person in the queue who would want to complete the course.

 

I appreciate your help a lot.

 

Cheers!

Adam

Share this post


Link to post
Share on other sites

Hey George,

 

Thanks a lot. I will take a look at those two and see if I can rework those a bit to my needs. If in the meantime anyone has any more suggestions as to how it could be done, I would be grateful : )

 

Cheers!

Adam

Share this post


Link to post
Share on other sites

Here is one approach: 

 

I assume your training course is in a preset location, with an area designated for mines.   In the editor you could place many invisible markers in the mine area...say for example 30 markers.   At the top of your script, put the 30 markers in an array.  Then you shuffle the array, and place a mine at the position of each of the first 10 markers.    Every time you run the script 10 mines would be created in different locations.

 

https://community.bistudio.com/wiki/BIS_fnc_arrayShuffle

  • Like 2

Share this post


Link to post
Share on other sites

so simple, all is already done in the createvehicle command


 

private _markers = ["marker1", "marker2", "marker3"];
private _randomtypeofmine = selectRandom ["blabla", "blabla","blabla"];
private _randomdistance = 50;

{
	_mine = createVehicle [_randomtypeofmine, getMarkerPos "marker1", ["marker2","marker3"], _randomdistance, "NONE"];
}foreach _markers;

you can do same things with a for loop to create more mine on the same spot.

  • Like 2

Share this post


Link to post
Share on other sites

Not sure exactly what you are looking for, so this may or may not worth considering...

 

You can simply just place ALL Mines, and IEDs, and then set the 'probability' setting in each one in the Editor. This would be the simplest setup. Example, place 100 explosives, and set each one to 5-10% probability of spawning in. Use Copy/Paste to setup your maps, settings, templates, etc quickly.

Share this post


Link to post
Share on other sites

Hey guys, thanks a lot for all your suggestions. I think I found out that @code34's suggestion works almost fine for what I need. Unfortunately there is a problem. It seems that whenever I spawn the mines, all of the markers spawn the same type of mine. It is chosen randomly, yes, but once it's chosen, it spawns the same mine for all markers at once.

 

This is how it looks right now:

private _markers = ["marker_0", "marker_1", "marker_2", "marker_3", "marker_4", "marker_5", "marker_6", "marker_7", "marker_8"];
private _randomtypeofmine = selectRandom ["APERSMine_Range_Ammo", "APERSBoundingMine_Range_Ammo"];
private _randomdistance = 5;

{
	_mine = createVehicle [_randomtypeofmine, getMarkerPos "marker_0", ["marker_1","marker_2","marker_3","marker_4","marker_5","marker_6","marker_7","marker_8"], _randomdistance, "NONE"];
}foreach _markers;

 

I also managed to remove mines with this line triggered for each marker. Probably could be done easier, but seems to be working.

{ deleteVehicle _x; } forEach nearestObjects [getMarkerPos "marker_0",["APERSMine_Range_Ammo", "APERSBoundingMine_Range_Ammo"],15];

If you can advise on how to randomise those fields, I will be grateful.

 

Thanks again for your help,

Adam 

Share this post


Link to post
Share on other sites

To make the mine type random, move that code inside the foreach loop.  Currently its chosen once only before the loop.

private _markers = ["marker_0", "marker_1", "marker_2", "marker_3", "marker_4", "marker_5", "marker_6", "marker_7", "marker_8"];
private _randomdistance = 5;

{
	_mine = createVehicle [(selectRandom ["APERSMine_Range_Ammo", "APERSBoundingMine_Range_Ammo"]), getMarkerPos "marker_0", ["marker_1","marker_2","marker_3","marker_4","marker_5","marker_6","marker_7","marker_8"], _randomdistance, "NONE"];
}foreach _markers;

 

  • Like 2

Share this post


Link to post
Share on other sites

Hey,
 

Thanks for the solution - works like a charm.

 

However, as things are in Arma, there is always something that will go wrong. While the sole spawning works just as it should, I am now unable to remove the spawned mines with the line I pasted above. I believe the thing with mines is that they are somewhat interactive objects which change their state? Basically running the deleteVehicle command does nothing (no error as well). Plus, I cannot add the planted mines as editable Objects to Zeus. I also cannot add mines planted by players. I can, however, create mines as Zeus and remove them as I please.

 

Is there any way to delete the mines spawned this way?

 

Cheers for your help guys!

Adam

Share this post


Link to post
Share on other sites

Bumping the topic.

 

Is there anyone who could help me figure out the mine spawner and the ability to delete the created mines afterwards?

 

Thanks in advance,

Adam

Share this post


Link to post
Share on other sites

The issue has been resolved with the help of @davidoss who was extremely kind to spend some of his time on it with me - live, coding together :)

The solution is this:

1. Create a file in the mission root directory called functions.sqf add this code to it

fnc_spawnMines = {
  
  private _markers = ["marker_0", "marker_1", "marker_2", "marker_3", "marker_4", "marker_5", "marker_6", "marker_7", "marker_8"];
  private _mines = ["APERSMine_Range_Ammo", "APERSBoundingMine_Range_Ammo","ATMine_Range_Ammo","SLAMDirectionalMine_Wire_Ammo","APERSTripMine_Wire_Ammo"];
	private _randomdistance = floor (random [2,4,6]);

  {
    minesarray pushback (createVehicle [

      selectRandom _mines,
      getMarkerPos _x,
      [],
      _randomdistance,
      "NONE"
    ]);
  } foreach _markers;
};


fnc_removeMines = {

	{if (!isNull _x) then {deleteVehicle _x}} forEach minesarray;

};

2. Add this code to the player's or any desired object's init field:

this addaction ["spawn mines",{null = [] remoteExec ["fnc_spawnMines",2,false]}];
this addaction ["remove mines",{null = [] remoteExec ["fnc_removeMines",2,false]}];

3. Add this code to init.sqf:

if (isServer) then {
 	[] call compile preprocessFileLineNumbers "functions.sqf";
	minesarray = [];
};

Thanks everyone who posted their suggestions and thanks again for your time @davidoss !!

 

  • Thanks 3

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

×