Skip to content

Commit

Permalink
Merge pull request #464 from Vdauphin/Add-composition_side_mines
Browse files Browse the repository at this point in the history
Add: Dynamic composition for the side mission clear mines field
  • Loading branch information
Vdauphin authored Jan 16, 2018
2 parents 2cc77d7 + a14512f commit cc9f6b2
Show file tree
Hide file tree
Showing 3 changed files with 105 additions and 47 deletions.
22 changes: 18 additions & 4 deletions =BTC=co@30_Hearts_and_Minds.Altis/core/def/mission.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ if (!isMultiplayer) then {btc_debug_log = true;btc_debug = true;};
if (isServer) then {
btc_final_phase = false;

private _allclass = ("true" configClasses (configFile >> "CfgVehicles")) apply {configName _x};
_allclass = _allclass select {getNumber(configfile >> "CfgVehicles" >> _x >> "scope") isEqualTo 2};

//City
btc_city_radius = _p_city_radius;
btc_city_blacklist = [];//NAME FROM CFG
Expand Down Expand Up @@ -144,6 +147,18 @@ if (isServer) then {
btc_type_mines = ["APERSMine","APERSBoundingMine","APERSTripMine"];
btc_type_power = ["WaterPump_01_sand_F","WaterPump_01_forest_F","Land_PressureWasher_01_F","Land_DieselGroundPowerUnit_01_F","Land_JetEngineStarter_01_F","Land_PowerGenerator_F","Land_PortableGenerator_01_F"];
btc_type_cord = ["Land_ExtensionCord_F"];
btc_type_cones = ["Land_RoadCone_01_F", "RoadCone_F"];
btc_type_fences = ["Land_PlasticNetFence_01_long_F", "Land_PlasticNetFence_01_long_d_F", "RoadBarrier_F", "TapeSign_F"];
btc_type_portable_light = ["Land_PortableLight_double_F", "Land_PortableLight_single_F"];
btc_type_first_aid_kits = ["Land_FirstAidKit_01_open_F", "Land_FirstAidKit_01_closed_F"];
btc_type_body_bags = _allclass select {
(_x isKindOf "Land_Bodybag_01_base_F") ||
(_x isKindOf "Land_Bodybag_01_empty_base_F") ||
(_x isKindOf "Land_Bodybag_01_folded_base_F")
};
btc_type_signs = _allclass select {_x isKindOf "Land_Sign_Mines_F"};
btc_type_bloods = _allclass select {_x isKindOf "Blood_01_Base_F"};
btc_type_medicals = _allclass select {_x isKindOf "MedicalGarbage_01_Base_F"};

//BTC Vehicles in missions.sqm
btc_vehicles = [btc_veh_1,btc_veh_2,btc_veh_3,btc_veh_4,btc_veh_5,btc_veh_6,btc_veh_7,btc_veh_8,btc_veh_9,btc_veh_10,btc_veh_11,btc_veh_12,btc_veh_13,btc_veh_14,btc_veh_15];
Expand Down Expand Up @@ -240,6 +255,9 @@ btc_respawn_marker = "respawn_west";
if (isServer) then {
#define REARM_TURRET_PATHS [[-1], [0], [0,0], [0,1], [1], [2], [0,2]]

private _allclass = ("true" configClasses (configFile >> "CfgVehicles")) apply {configName _x};
_allclass = _allclass select {getNumber(configfile >> "CfgVehicles" >> _x >> "scope") isEqualTo 2};

_rearming_vehicles = [btc_vehicles + btc_helo,[]] call btc_fnc_find_veh_with_turret;
private _rearming_magazines = [];
{
Expand All @@ -249,10 +267,6 @@ if (isServer) then {
_rearming_magazines pushBack _magazines;
} forEach _rearming_vehicles;


private _allclass = ("true" configClasses (configFile >> "CfgVehicles")) apply {configName _x};
_allclass = _allclass select {(getNumber(configfile >> "CfgVehicles" >> _x >> "scope") isEqualTo 2)};

_rearming_static =
[
//"Static"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,25 +1,19 @@

private ["_pos","_setdir","_array","_type","_dir","_rel_pos","_rel_x","_rel_y","_rel_z","_pos_z","_pos_x","_pos_y","_obj","_pos_obj"];
params ["_pos", "_setdir", "_array"];
_pos params ["_pos_x", "_pos_y", ["_pos_z", 0]];

_pos = _this select 0;
//// Direction parameter is align with compass \\\\
_setdir = -(_this select 1);
_array = _this select 2;
_pos_x = _pos select 0;
_pos_y = _pos select 1;
_pos_z = 0;if (count _pos > 2) then {_pos_z = _pos select 2;};
_array apply {
_type = _x select 0;
//// Determine direction function of setdir \\\\
_dir = ((_x select 1) - _setdir);
_rel_pos = _x select 2;
_rel_x = _rel_pos select 0;
_rel_y = _rel_pos select 1;
_rel_z = _rel_pos select 2;
_x params ["_type", "_dir", "_rel_pos"];
_rel_pos params ["_rel_x", "_rel_y", ["_rel_z", 0]];

//// Determine position function of setdir \\\\
_pos_obj = [(_pos_x + _rel_x*cos(_setdir) - _rel_y*sin(_setdir)),(_pos_y + _rel_y*cos(_setdir) + _rel_x*sin(_setdir)),(_pos_z + _rel_z)];
_obj = createVehicle [_type, _pos_obj, [], 0, "CAN_COLLIDE"];
_obj setDir _dir;
_obj setPos _pos_obj;
private _final = [_pos_x + _rel_x*cos(_setdir) - _rel_y*sin(- _setdir), _pos_y + _rel_y*cos(_setdir) + _rel_x*sin(- _setdir)];
_final pushBack (_pos_z + _rel_z + getTerrainHeightASL _final);
private _obj = createVehicle [_type, ASLToATL _final, [], 0, "CAN_COLLIDE"];
//// Determine direction function of setdir \\\\
_obj setDir (_dir + _setdir);

_obj setVectorUp surfaceNormal position _obj;
_obj setPosWorld getPosWorld _obj;
_obj;
};
98 changes: 74 additions & 24 deletions =BTC=co@30_Hearts_and_Minds.Altis/core/fnc/side/mines.sqf
Original file line number Diff line number Diff line change
@@ -1,64 +1,114 @@

private ["_useful","_city","_pos","_area","_marker","_mines","_closest"];

_useful = btc_city_all select {((_x getVariable ["type",""] != "NameLocal") && {_x getVariable ["type",""] != "Hill"} && (_x getVariable ["type",""] != "NameMarine"))};
private _useful = btc_city_all select {(_x getVariable ["type",""] != "NameLocal") && {_x getVariable ["type",""] != "Hill"} && (_x getVariable ["type",""] != "NameMarine")};

if (_useful isEqualTo []) then {_useful = + btc_city_all;};

_city = selectRandom _useful;

//_pos = [getPos _city, 100] call btc_fnc_randomize_pos;
private _city = selectRandom _useful;
private _pos = [getPos _city, 0, 500, 30, 0, 60 * (pi / 180), 0] call BIS_fnc_findSafePos;

_pos = [getPos _city, 0, 500, 30, 0, 60 * (pi / 180), 0] call BIS_fnc_findSafePos;
btc_side_aborted = false;
btc_side_done = false;
btc_side_failed = false;
btc_side_assigned = true;publicVariable "btc_side_assigned";

[4,_pos,_city getVariable "name"] remoteExec ["btc_fnc_task_create", 0];
[4, _pos, _city getVariable "name"] remoteExec ["btc_fnc_task_create", 0];

btc_side_jip_data = [4, _pos, _city getVariable "name"];

btc_side_jip_data = [4,_pos,_city getVariable "name"];
private _distance_between_fences = 8.1;
private _number_of_fences = 3 + floor random 4;
private _area_size = _distance_between_fences * _number_of_fences;
private _offset = _area_size + _distance_between_fences/2;

_area = createmarker [format ["sm_%1",_pos],_pos];
private _area = createmarker [format ["sm_%1", _pos], _pos];
_area setMarkerShape "RECTANGLE";
_area setMarkerBrush "SolidBorder";
_area setMarkerSize [60, 60];
_area setMarkerSize [_offset, _offset];
_area setMarkerAlpha 0.3;
_area setmarkercolor "colorBlue";

_marker = createmarker [format ["sm_2_%1",_pos],_pos];
private _marker = createmarker [format ["sm_2_%1", _pos], _pos];
_marker setmarkertype "hd_flag";
[_marker,"STR_BTC_HAM_SIDE_MINES_MRK"] remoteExec ["btc_fnc_set_markerTextLocal", [0, -2] select isDedicated, _marker]; //Mines
[_marker, "STR_BTC_HAM_SIDE_MINES_MRK"] remoteExec ["btc_fnc_set_markerTextLocal", [0, -2] select isDedicated, _marker]; //Mines
_marker setMarkerSize [0.6, 0.6];

_mines = [];
//// Randomise composition \\\\
private _cone = selectRandom btc_type_cones;
private _fences = + btc_type_fences;
_fences pushBack _cone;
private _fence = selectRandom _fences;

private _offset_door = - 60 + _offset;
private _composition_pattern = [
[selectRandom btc_type_bloods,81,[56.0991 + _offset_door,5.71729,0]],
[_cone,0,[60.3545 + _offset_door,5.86768,0]],
[_cone,0,[60.3755 + _offset_door,9.47217,0]],
[selectRandom btc_type_portable_light,101,[61.1982 + _offset_door,3.28906,0]],
[selectRandom btc_type_portable_light,37,[60.7373 + _offset_door,11.856,0]],
[selectRandom btc_type_bloods,131,[61.9722 + _offset_door,5.49609,0]],
[selectRandom btc_type_body_bags,332,[62.4473 + _offset_door,0.76416,0]],
[selectRandom btc_type_bloods,94,[62.3799 + _offset_door,8.66309,0]],
[selectRandom btc_type_bloods,0,[65.3276 + _offset_door,1.97803,0]],
[selectRandom btc_type_medicals,0,[65.4448 + _offset_door,1.52734,0]],
[selectRandom btc_type_first_aid_kits,0,[65.6187 + _offset_door,0.109863,0]],
[selectRandom btc_type_power,223,[63.9292 + _offset_door,14.8687,0]],
[selectRandom (btc_type_barrel + btc_type_canister),0,[66.4707 + _offset_door,0.0717773,0]]
];

for "_i" from -_number_of_fences to _number_of_fences do {
_composition_pattern append [
[_fence, 0, [_i * _distance_between_fences, -_offset, 0]],
[_fence, 0, [_i * _distance_between_fences, _offset, 0]],
[_fence, 90, [ -_offset, _i * _distance_between_fences, 0]]
];
if !(_i isEqualTo 1) then {
_composition_pattern pushBack [_fence, 90, [ _offset, _i * _distance_between_fences, 0]];
};

if (random 1 > 0.7) then {
_composition_pattern append [
[selectRandom btc_type_signs, 180, [_i * _distance_between_fences, _offset - 1, 0]],
[selectRandom btc_type_signs, 0, [_i * _distance_between_fences, -_offset + 1, 0]],
[selectRandom btc_type_signs, 270, [ _offset - 1, _i * _distance_between_fences, 0]],
[selectRandom btc_type_signs, 90, [ -_offset + 1, _i * _distance_between_fences, 0]]
];
};
};

private _composition_objects = [_pos, selectRandom [0, 90, 180, 270], _composition_pattern] call btc_fnc_create_composition;

private _mines = [];
for "_i" from 1 to (5 + round random 5) do {
private ["_type","_m_pos"];
_type = "ATMine";
private _type = "ATMine";
if (random 1 > 0.6) then {_type = selectRandom btc_type_mines;};
_m_pos = [_pos, 50] call btc_fnc_randomize_pos;
_m = createMine [_type, _m_pos, [], 0];
_mines pushBack _m;
private _m_pos = [_pos, _area_size - 10] call btc_fnc_randomize_pos;
_mines pushBack createMine [_type, _m_pos, [], 0];

if (random 1 > 0.8) then {
_m_pos = [_pos, _area_size - 10] call btc_fnc_randomize_pos;
private _s = createVehicle [selectRandom btc_type_signs, _m_pos, [], 10, "CAN_COLLIDE"];
_s setDir random 360;
_composition_objects pushBack _s;
};
};

waitUntil {sleep 5; (btc_side_aborted || btc_side_failed || ({_x distance _pos < 200} count playableUnits > 0))};
waitUntil {sleep 5; (btc_side_aborted || btc_side_failed || ({_x distance _pos < 100} count playableUnits > 0))};

_closest = [_city,btc_city_all select {!(_x getVariable ["active",false])},false] call btc_fnc_find_closecity;
private _closest = [_city,btc_city_all select {!(_x getVariable ["active",false])}, false] call btc_fnc_find_closecity;
for "_i" from 1 to (round random 2) do {
[_closest,_pos,1,selectRandom btc_type_motorized] spawn btc_fnc_mil_send;
[_closest, _pos, 1, selectRandom btc_type_motorized] spawn btc_fnc_mil_send;
};

waitUntil {sleep 5; (btc_side_aborted || btc_side_failed || ({!isNull _x} count _mines == 0))};

btc_side_assigned = false;publicVariable "btc_side_assigned";
if (btc_side_aborted || btc_side_failed) exitWith {
4 remoteExec ["btc_fnc_task_fail", 0];
[[_area,_marker], _mines, [], []] call btc_fnc_delete;
[[_area,_marker], _mines + _composition_objects, [], []] call btc_fnc_delete;
};

30 call btc_fnc_rep_change;

4 remoteExec ["btc_fnc_task_set_done", 0];

[[_area,_marker], [], [], []] call btc_fnc_delete;
[[_area,_marker], _composition_objects, [], []] call btc_fnc_delete;

0 comments on commit cc9f6b2

Please sign in to comment.