forked from Giallustio/HeartsAndMinds
-
-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #464 from Vdauphin/Add-composition_side_mines
Add: Dynamic composition for the side mission clear mines field
- Loading branch information
Showing
3 changed files
with
105 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 13 additions & 19 deletions
32
=BTC=co@30_Hearts_and_Minds.Altis/core/fnc/common/create_composition.sqf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
98
=BTC=co@30_Hearts_and_Minds.Altis/core/fnc/side/mines.sqf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |