Page MenuHomeFeedback Tracker

Update minefield site module function
New, NormalPublic

Description

Update the minefield site module function (\a3\modules_f\sites\site_inits\minefield.sqf) so the mines created are referenced on the module.

private _minesType = _this getVariable "minesType";
private _minesCnt = parseNumber (_this getVariable "minesCount");
private _axisA = parseNumber (_this getVariable "axisA");
private _axisB = parseNumber (_this getVariable "axisB");
private _dir = direction _this;
private _shape = _this getVariable "shape";

private _h = 0;

if (_minesType == "UnderwaterMine") then {_h = -2};

_getPos = {};

if (_shape == "rectangle") then {
	_getPos = {
		_pos = [0,0,0];
		_coef = 1; if (random 1 >= 0.5) then {_coef = -1};
		_hpos = [_this, (random _axisB) * _coef, _dir] call BIS_fnc_relPos;
		_coef = 1; if (random 1 >= 0.5) then {_coef = -1};
		_pos = [_hpos, (random _axisA) * _coef, _dir + 90] call BIS_fnc_relPos;
		[_pos select 0, _pos select 1, _h];
	};
} else {
	_getPos = {
		_dir2 = random 360;
		_dir3 = _dir2 - _dir;
		_line1 = sqrt (((_axisA^2) * (_axisB^2)) / ((_axisB^2) + ((_axisA^2) * ((1/(tan _dir3))^2))));
		_line2 = _line1 * (1/(tan _dir3));
		_line = sqrt ((_line1^2) + (_line2)^2);
		_pos = [_this, random _line, _dir2] call BIS_fnc_relPos;
		[_pos select 0, _pos select 1, _h];
	};
};

// check if minefield should be randomized
private _randomizeMines = false;
if(_minesType in ["BombCluster_01_UXO1_F","BombCluster_02_UXO1_F","BombCluster_03_UXO1_F"])then
{
	_randomizeMines = true;
};

//Store references to created mines
_mines = [];

for [{_x = 0}, {_x < _minesCnt}, {_x = _x + 1}] do
{
	// randomize minefield if UXO is detected
	if(_randomizeMines)then
	{
		_minesType = (_minesType select [0,18]) + str(ceil(random(4))) + "_F";
	};

	_pos = call _getPos;
	if (_minesType == "UnderwaterMineAB") then {_pos = [_pos select 0, _pos select 1, getTerrainHeightASL _pos]};
	_mine = createMine [_minesType, _pos, [], 0];
	_mine setDir (random(360));
	
	//Store created mine
	_mines pushBack _mine;
	
	{_side = _x; if (_side getFriend (_this call BIS_getCorrectSiteSide) == 1 || (_this getVariable "marked") == "Everyone") then {_side revealMine _mine}} forEach [WEST, EAST, RESISTANCE];
};

//Place reference to created mines on module
_this setVariable[ "mines", _mines, true ];

Details

Severity
Tweak
Resolution
Open
Reproducibility
N/A
Operating System
Windows 10 x64
Category
Scripting

Event Timeline

Larrow created this task.Nov 8 2020, 3:36 AM
Larrow updated the task description. (Show Details)Nov 8 2020, 3:41 AM