Skip to content

Commit

Permalink
Merge pull request #383 from Vdauphin/Add-detect_military_building
Browse files Browse the repository at this point in the history
Add: Detect military building
  • Loading branch information
Vdauphin authored Sep 17, 2017
2 parents 045be96 + cce40f4 commit 44e23ea
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 28 deletions.
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@

private ["_group","_house","_wp"];
params ["_group","_house"];

_group = _this select 0;
_house = _this select 1;
private _allpositions = [_group,_house] call btc_fnc_house_addWP_loop;

[_group,_house] call btc_fnc_house_addWP_loop;

_wp = _group addWaypoint [getPos _house, 0];
private _wp = _group addWaypoint [_allpositions select 0, 0.2];
_wp setWaypointType "CYCLE";
_wp waypointAttachObject _house;
_wp setWaypointHousePosition 0;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@

private ["_group","_house","_wp","_allpositions"];
params ["_group","_house"];

_group = _this select 0;
_house = _this select 1;
private _allpositions = _house buildingPos -1;
private _copyallpositions = +_allpositions;

_allpositions = _house buildingPos -1;
if (btc_debug_log) then {diag_log format ["setWaypoint : count all pos %1 in %2 ", count _allpositions,_house];};
{
_wp = _group addWaypoint [_x, 0];
private _index = _copyallpositions find selectRandom(_copyallpositions);

private _wp = _group addWaypoint [_copyallpositions deleteAt _index, 0.2];
_wp setWaypointType "MOVE";
_wp setWaypointCompletionRadius 0;
_wp waypointAttachObject _house;
_wp setWaypointHousePosition _foreachindex;
_wp setWaypointHousePosition _index;
_wp setWaypointTimeout [15, 20, 30];
} forEach _allpositions;
} forEach _allpositions;

_allpositions
1 change: 1 addition & 0 deletions =BTC=co@30_Hearts_and_Minds.Altis/core/fnc/compile.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ if (isServer) then {
btc_fnc_mil_patrol_eh = compile preprocessFileLineNumbers "core\fnc\mil\patrol_eh.sqf";
btc_fnc_mil_patrol_eh_remove = compile preprocessFileLineNumbers "core\fnc\mil\patrol_eh_remove.sqf";
btc_fnc_mil_CuratorMilPlaced_s = compile preprocessFileLineNumbers "core\fnc\mil\CuratorMilPlaced_s.sqf";
btc_fnc_mil_getStructures = compile preprocessFileLineNumbers "core\fnc\mil\getStructures.sqf";

//REP
btc_fnc_rep_add_eh = compile preprocessFileLineNumbers "core\fnc\rep\add_eh.sqf";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ if (_type == 2) then {
};
if (_type == 3) then {
while {(count (waypoints _group)) > 0} do { deleteWaypoint ((waypoints _group) select 0); };
[_group, nearestObject[(units _group) select 0, _array_veh]] spawn btc_fnc_house_addWP;
[_group, nearestObject [(units _group) select 0, _array_veh]] spawn btc_fnc_house_addWP;
_group setVariable ["inHouse", _array_veh];
};
if (_type == 4) then {[[0,0,0],0,units _group] spawn btc_fnc_civ_get_weapons;};
Expand Down
48 changes: 34 additions & 14 deletions =BTC=co@30_Hearts_and_Minds.Altis/core/fnc/mil/create_group.sqf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

private ["_city","_area","_n","_wp","_pos","_rpos","_unit_type","_group","_in_house","_pos_iswater","_newpos"];
private ["_city","_area","_n","_wp","_pos","_rpos","_unit_type","_group","_pos_iswater","_newpos"];

_city = _this select 0;
_area = _this select 1;
Expand Down Expand Up @@ -28,37 +28,57 @@ if (_pos_iswater) then {
_group = createGroup btc_enemy_side;
[_group createUnit [_unit_type, _rpos, [], 0, "NONE"]] joinSilent _group;
(leader _group) setpos _rpos;
_in_house = false;
private _groups = [];
_groups pushBack _group;
private _structure = objNull;

switch (true) do {
case (_wp < 0.3) : {
private ["_houses","_house","_n_pos","_max_pos","_unit"];
_houses = [_rpos,50] call btc_fnc_getHouses;
if (count _houses > 0) then {
_in_house = true;
_house = selectRandom _houses;
[_group,_house] spawn btc_fnc_house_addWP;
_group setVariable ["inHouse", typeOf _house];
} else {[_group,_rpos,_area,"SAFE",_pos_iswater] spawn btc_fnc_task_patrol;};
private _structures = [_rpos,70] call btc_fnc_mil_getStructures;
if !(_structures isEqualTo []) then {
_structure = selectRandom _structures;
_n = count (_structure buildingPos -1);
if (_n > 8) then {
_n = 2;
} else {
_n = floor(_n/2);
};
for "_i" from 0 to _n do {
[_group createUnit [selectRandom btc_type_units, _rpos, [], 0, "NONE"]] joinSilent _group;
sleep 0.5;
};
} else {
private _houses = [_rpos,50] call btc_fnc_getHouses;
if !(_houses isEqualTo []) then {
_structure = selectRandom _houses;
} else {[_group,_rpos,_area,"SAFE",_pos_iswater] spawn btc_fnc_task_patrol;};
};
};
case (_wp > 0.3 && _wp < 0.75) : {
[_group,_rpos,_area,"AWARE",_pos_iswater] spawn btc_fnc_task_patrol;
};
case (_wp > 0.75) : {
private ["_wpa"];
_wpa = _group addWaypoint [_rpos, 0];
private _wpa = _group addWaypoint [_rpos, 0];
_wpa setWaypointType "SENTRY";
_wpa setWaypointCombatMode "RED";
_wpa setWaypointBehaviour "AWARE";
};
};
if (!_in_house) then {
if (_structure isEqualTo objNull) then {
for "_i" from 0 to _n do {
_unit_type = [selectRandom btc_type_units, selectRandom btc_type_divers ] select _pos_iswater;
[_group createUnit [_unit_type, _rpos, [], 0, "NONE"]] joinSilent _group;
sleep 0.5;
};
//_group createUnit [btc_type_medic, _pos, [], 0, "NONE"];
} else {
{
private _grp = createGroup btc_enemy_side;
[_x] joinSilent _grp;
_grp setVariable ["inHouse", typeOf _structure];
[_grp,_structure] spawn btc_fnc_house_addWP;
_groups pushBack _grp;
} forEach units _group;
};

//if ((position leader _group) distance [0,0,0] < 50) then {{_x setpos _rpos;} foreach units _group;};
Expand All @@ -67,4 +87,4 @@ if (!_in_house) then {

if (btc_debug_log) then {diag_log format ["btc_fnc_mil_create_group: _this = %1 ; POS %2 UNITS N %3",_this,_rpos,count units _group];};

_group
_groups
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

params ["_pos","_radius"];

private _structures = (nearestTerrainObjects [_pos, ["House", "BUNKER", "FORTRESS"], _radius]) select {gettext(configfile >> "CfgVehicles" >> typeof _x >> "editorSubcategory") isEqualTo "EdSubcat_Military"};
private _useful = _structures select {(format["%1", _x buildingPos 1] != "[0,0,0]" && {damage _x == 0} && {isNil {_x getVariable "btc_house_taken"}})};
_useful

0 comments on commit 44e23ea

Please sign in to comment.