Skip to content

Commit

Permalink
civ traffic fixed and missing privates
Browse files Browse the repository at this point in the history
  • Loading branch information
Giallustio committed Oct 8, 2015
1 parent c8d49d0 commit d63d7af
Show file tree
Hide file tree
Showing 15 changed files with 124 additions and 137 deletions.
Expand Up @@ -41,6 +41,6 @@ _unit_type createUnit [_pos, _group, "this moveinDriver _veh;this assignAsDriver
_veh setVariable ["driver",leader _group];
_veh addEventHandler ["HandleDamage", btc_fnc_civ_traffic_hd];

{_x call BTC_fnc_rep_add_eh;_x setVariable ["traffic",_veh];} foreach units _group;
{_x call btc_fnc_rep_add_eh;_x setVariable ["traffic",_veh];} foreach units _group;

[_group,_area] call btc_fnc_civ_traffic_add_WP;
Expand Up @@ -5,10 +5,10 @@ _veh = _this select 0;
_damage = _this select 2;

if !(canMove _veh) then {
btc_civ_veh_active = btc_civ_veh_active - 1;
[_veh,(_veh getVariable ["driver",_veh])] spawn {
waitUntil {sleep 5; ({_x distance (_this select 0) < 600} count playableUnits == 0)};
{deleteVehicle _x;} foreach _this;
btc_civ_veh_active = btc_civ_veh_active - 1;
};
};

Expand Down
22 changes: 10 additions & 12 deletions =BTC=co@22_Hearts_and_Minds.Altis/core/fnc/mil/addWP.sqf
@@ -1,13 +1,15 @@
//[_group,_city,600] call btc_fnc_addWP;

private ["_group","_city","_area","_wp","_pos","_rpos","_in_house"];

_group = _this select 0;
_city = _this select 1;
_area = _this select 2;
_wp = _this select 3;

_pos = [];

switch (typeName _city) do
{
switch (typeName _city) do {
case "ARRAY" :{_pos = _city;};
case "STRING":{_pos = getMarkerPos _city;};
case "OBJECT":{_pos = position _city;};
Expand All @@ -17,26 +19,21 @@ _rpos = [_pos, _area] call btc_fnc_randomize_pos;

_in_house = false;

switch (true) do
{
case (_wp < 0.3) :
{
switch (true) do {
case (_wp < 0.3) : {
private ["_houses","_house","_n_pos","_max_pos","_unit"];
_houses = [_city,_area] call btc_fnc_getHouses;
if (count _houses > 0) then
{
if (count _houses > 0) then {
_in_house = true;
_house = _houses select (floor random count _houses);
[_group,_house] spawn btc_fnc_house_addWP;
_group setVariable ["inHouse",_house];
} else {[_group,_rpos,_area,"SAFE"] call btc_fnc_task_patrol;};
};
case (_wp > 0.3 && _wp < 0.75) :
{
case (_wp > 0.3 && _wp < 0.75) : {
[_group,_rpos,(_area*2),"AWARE"] call btc_fnc_task_patrol;
};
case (_wp > 0.75) :
{
case (_wp > 0.75) : {
private ["_wpa"];
_wpa = _group addWaypoint [_rpos, 0];
_wpa setWaypointType "SENTRY";
Expand All @@ -45,4 +42,5 @@ switch (true) do
_wpa setWaypointFormation "WEDGE";
};
};

true
19 changes: 10 additions & 9 deletions =BTC=co@22_Hearts_and_Minds.Altis/core/fnc/mil/check_cap.sqf
@@ -1,4 +1,6 @@

private ["_cap_to"];

if (btc_hideout_cap_checking) exitWith {};

btc_hideout_cap_checking = true;
Expand All @@ -17,27 +19,26 @@ if (count _cap_to == 0) exitWith {if (btc_debug_log) then {diag_log "btc_fnc_mil
private ["_hd","_in_range"];
_hd = _x;
_in_range = [];
{
if (_hd distance _x < btc_hideout_range) then {_in_range = _in_range + [_x];};
} foreach btc_city_all;
{if (_hd distance _x < btc_hideout_range) then {_in_range = _in_range + [_x];};} foreach btc_city_all;

if (count _in_range == 0) exitWith {if (btc_debug_log) then {diag_log format ["btc_fnc_mil_check_cap: exit no in range = %1",_hd getVariable "id"];};};

private ["_closest","_dist","_pos"];

_closest = objNull;
_dist = 999999;
_pos = getPos _hd;
{
if (_x distance _pos < _dist && {!(_x getVariable ["occupied",false])}) then {_closest = _x;_dist = _x distance _pos;};
} foreach _in_range;diag_log format ["btc_fnc_mil_check_cap: _in_range = %1",_in_range];

{if (_x distance _pos < _dist && {!(_x getVariable ["occupied",false])}) then {_closest = _x;_dist = _x distance _pos;};} foreach _in_range;

if (btc_debug_log) then {diag_log format ["btc_fnc_mil_check_cap: _in_range = %1",_in_range];};
if (isNull _closest) exitWith {if (btc_debug_log) then {diag_log format ["btc_fnc_mil_check_cap: exit null _closest = %1",_hd getVariable "id"];};};

if (btc_debug_log) then {diag_log format ["btc_fnc_mil_check_cap: SEND FROM = %1 TO %2 [int %3]",_hd getVariable "id",_closest getVariable ["name","error"],_closest getVariable ["initialized",false]];};

_hd setVariable ["cap_time",time];

if (_closest getVariable ["initialized",false]) then
{
if (_closest getVariable ["initialized",false]) then {
/*[_hd,_closest,1,"I_Truck_02_transport_F"] spawn btc_fnc_mil_send;
sleep 1;
[_hd,_closest,1,"I_Truck_02_transport_F"] spawn btc_fnc_mil_send;
Expand Down
25 changes: 15 additions & 10 deletions =BTC=co@22_Hearts_and_Minds.Altis/core/fnc/mil/check_rinf.sqf
@@ -1,12 +1,21 @@

private ["_city","_pos","_hideout"];

_city = objNull;

if (count _this > 0) then {_city = _this;} else
{
if (count _this > 0) then {_city = _this;} else {
private ["_useful","_id"];
_useful = [];
//"NameVillage","NameCity","NameCityCapital","NameLocal","Hill"
{
//"NameVillage","NameCity","NameCityCapital","NameLocal","Hill"
if (!(_x getVariable ["active",false]) && {_x distance (getMarkerPos btc_respawn_marker) > btc_hideout_safezone} && {!(_x getVariable ["has_ho",false])} && (_x getVariable ["type",""] == "NameLocal" || {_x getVariable ["type",""] == "Hill"} || {_x getVariable ["type",""] == "NameVillage"})) then {_useful = _useful + [_x];};
if (
!(_x getVariable ["active",false]) && {_x distance (getMarkerPos btc_respawn_marker) > btc_hideout_safezone} &&
{!(_x getVariable ["has_ho",false])} &&
(
_x getVariable ["type",""] == "NameLocal" ||
{_x getVariable ["type",""] == "Hill"} || {_x getVariable ["type",""] == "NameVillage"}
)
) then {_useful = _useful + [_x];};
} foreach btc_city_all;
_id = floor random count _useful;
_city = _useful select _id;
Expand All @@ -32,8 +41,7 @@ _city setVariable ["has_ho",true];
_city setVariable ["ho_pos",_pos];
_city setVariable ["ho_units_spawned",false];

if (btc_debug) then
{
if (btc_debug) then {
//Marker
_marker = createmarker [format ["btc_hideout_%1", _pos], _pos];
format ["btc_hideout_%1", _pos] setmarkertypelocal "mil_unknown";
Expand All @@ -42,10 +50,7 @@ if (btc_debug) then

};

if (btc_debug_log) then
{
diag_log format ["btc_fnc_mil_create_hideout: _this = %1 ; POS %2 ID %3",_this,_pos,btc_hideouts_id];
};
if (btc_debug_log) then {diag_log format ["btc_fnc_mil_create_hideout: _this = %1 ; POS %2 ID %3",_this,_pos,btc_hideouts_id];};

btc_hideouts_id = btc_hideouts_id + 1;
btc_hideouts = btc_hideouts + [_hideout];
36 changes: 12 additions & 24 deletions =BTC=co@22_Hearts_and_Minds.Altis/core/fnc/mil/create_group.sqf
@@ -1,13 +1,14 @@

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

_city = _this select 0;
_area = _this select 1;
_n = _this select 2;
_wp = _this select 3;

_pos = [];

switch (typeName _city) do
{
switch (typeName _city) do {
case "ARRAY" :{_pos = _city;};
case "STRING":{_pos = getMarkerPos _city;};
case "OBJECT":{_pos = position _city;};
Expand All @@ -22,54 +23,41 @@ _group createUnit [_unit_type, _rpos, [], 0, "NONE"];
(leader _group) setpos _rpos;
_in_house = false;

switch (true) do
{
case (_wp < 0.3) :
{
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
{
if (count _houses > 0) then {
_in_house = true;
_house = _houses select (floor random count _houses);
[_group,_house] spawn btc_fnc_house_addWP;
_group setVariable ["inHouse",_house];
} else {[_group,_rpos,_area,"SAFE"] spawn btc_fnc_task_patrol;};
};
case (_wp > 0.3 && _wp < 0.75) :
{
case (_wp > 0.3 && _wp < 0.75) : {
[_group,_rpos,(_area*2),"AWARE"] spawn btc_fnc_task_patrol;
};
case (_wp > 0.75) :
{
case (_wp > 0.75) : {
private ["_wpa"];
_wpa = _group addWaypoint [_rpos, 0];
_wpa setWaypointType "SENTRY";
_wpa setWaypointCombatMode "RED";
_wpa setWaypointBehaviour "AWARE";
};
};
if (!_in_house) then
{
for "_i" from 0 to _n do
{
if (!_in_house) then {
for "_i" from 0 to _n do {
_unit_type = btc_type_units select (floor random count btc_type_units);
_group createUnit [_unit_type, _rpos, [], 0, "NONE"];
sleep 0.5;
};
//_group createUnit [btc_type_medic, _pos, [], 0, "NONE"];
};

if ((position leader _group) distance [0,0,0] < 50) then
{
{_x setpos _rpos;} foreach units _group;
};
if ((position leader _group) distance [0,0,0] < 50) then {{_x setpos _rpos;} foreach units _group;};

{_x call btc_fnc_mil_unit_create;} foreach units _group;

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];
};
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
16 changes: 14 additions & 2 deletions =BTC=co@22_Hearts_and_Minds.Altis/core/fnc/mil/create_hideout.sqf
@@ -1,11 +1,23 @@

private ["_city","_pos","_hideout"];

_city = objNull;

if (count _this > 0) then {_city = _this;} else {
private ["_useful","_id"];
_useful = [];
{
//"NameVillage","NameCity","NameCityCapital","NameLocal","Hill"
if (!(_x getVariable ["active",false]) && {_x distance (getMarkerPos btc_respawn_marker) > btc_hideout_safezone} && {!(_x getVariable ["has_ho",false])} && (_x getVariable ["type",""] == "NameLocal" || {_x getVariable ["type",""] == "Hill"} || {_x getVariable ["type",""] == "NameVillage"})) then {_useful = _useful + [_x];};
if (
!(_x getVariable ["active",false]) &&
{_x distance (getMarkerPos btc_respawn_marker) > btc_hideout_safezone} &&
{!(_x getVariable ["has_ho",false])} &&
(
_x getVariable ["type",""] == "NameLocal" ||
{_x getVariable ["type",""] == "Hill"} ||
{_x getVariable ["type",""] == "NameVillage"}
)
) then {_useful = _useful + [_x];};
} foreach btc_city_all;
_id = floor random count _useful;
_city = _useful select _id;
Expand Down Expand Up @@ -35,7 +47,7 @@ _city setVariable ["ho_units_spawned",false];

if (btc_debug) then {
//Marker
_marker = createmarker [format ["btc_hideout_%1", _pos], _pos];
createmarker [format ["btc_hideout_%1", _pos], _pos];
format ["btc_hideout_%1", _pos] setmarkertypelocal "mil_unknown";
format ["btc_hideout_%1", _pos] setMarkerTextLocal format ["Hideout %1", btc_hideouts_id];
format ["btc_hideout_%1", _pos] setMarkerSizeLocal [0.8, 0.8];
Expand Down
@@ -1,3 +1,6 @@

private ["_pos","_type","_dir","_static","_group","_unit_type","_gunner"];

_pos = _this select 0;
_type = _this select 1;
_dir = 0; if (count _this > 2) then {_dir = _this select 2;};
Expand All @@ -16,7 +19,4 @@ _gunner setCombatMode "RED";

_gunner call btc_fnc_mil_unit_create;

if (btc_debug_log) then
{
diag_log format ["btc_fnc_mil_create_static: _this = %1 ; POS %2 _type %3",_this,_pos,_type];
};
if (btc_debug_log) then {diag_log format ["btc_fnc_mil_create_static: _this = %1 ; POS %2 _type %3",_this,_pos,_type];};
3 changes: 3 additions & 0 deletions =BTC=co@22_Hearts_and_Minds.Altis/core/fnc/mil/hd_hideout.sqf
@@ -1,3 +1,6 @@

private ["_hideout","_damage","_ammo","_explosive"];

_hideout = _this select 0;
_damage = _this select 2;
_ammo = _this select 4;
Expand Down
31 changes: 10 additions & 21 deletions =BTC=co@22_Hearts_and_Minds.Altis/core/fnc/mil/patrol_addWP.sqf
@@ -1,12 +1,13 @@

private ["_group","_city","_area","_players"];

_group = _this select 0;
_city = _group getVariable ["city",objNull];
_area = _this select 1;

_players = if (isMultiplayer) then {playableUnits} else {switchableUnits};

if ({_x distance _city < (_area/2) || _x distance leader _group < (_area/2)} count _players == 0) exitWith //playableUnits
{
if ({_x distance _city < (_area/2) || _x distance leader _group < (_area/2)} count _players == 0) exitWith {
if (vehicle leader _group != leader _group) then {deleteVehicle (vehicle leader _group)};
{deleteVehicle _x;} foreach units _group;deleteGroup _group;
btc_patrol_active = btc_patrol_active - 1;
Expand All @@ -15,17 +16,13 @@ if ({_x distance _city < (_area/2) || _x distance leader _group < (_area/2)} cou
_cities = [];
{if (_x distance _city < _area) then {_cities = _cities + [_x];};} foreach btc_city_all;
_pos = [];
if (count _cities == 0) then {_pos = getPos _city;} else
{
if (count _cities == 0) then {_pos = getPos _city;} else {
_pos = getPos (_cities select (floor random count _cities));
};

private ["_wp","_wp_1"];

while {(count (waypoints _group)) > 0} do
{
deleteWaypoint ((waypoints _group) select 0);
};
while {(count (waypoints _group)) > 0} do {deleteWaypoint ((waypoints _group) select 0);};

if ((vehicle leader _group) isKindOf "Air" || (vehicle leader _group) isKindOf "LandVehicle") then {(vehicle leader _group) setFuel 1;};
_group setBehaviour "SAFE";
Expand All @@ -36,10 +33,8 @@ _wp setWaypointCombatMode "RED";
_wp setWaypointSpeed "LIMITED";
_wp setWaypointFormation "STAG COLUMN";

if !((vehicle leader _group) isKindOf "Air") then
{
for "_i" from 0 to (2 + (floor (random 3))) do
{
if !((vehicle leader _group) isKindOf "Air") then {
for "_i" from 0 to (2 + (floor (random 3))) do {
private ["_wp", "_newPos"];

_newPos = [(_pos select 0) + (random 150 - random 150),(_pos select 1) + (random 150 - random 150),0];
Expand All @@ -53,15 +48,9 @@ if !((vehicle leader _group) isKindOf "Air") then
_wp_1 setWaypointType "MOVE";
_wp_1 setWaypointCompletionRadius 20;
_wp_1 setWaypointStatements ["true", format ["_spawn = [group this,%1] spawn btc_fnc_mil_patrol_addWP;",_area]];
}
else
{
_wp setWaypointStatements ["true", format ["_spawn = [group this,%1] spawn btc_fnc_mil_patrol_addWP;",_area]];
};
if (btc_debug) then
{
if (!isNil {_group getVariable "btc_patrol_id"}) then
{
} else {_wp setWaypointStatements ["true", format ["_spawn = [group this,%1] spawn btc_fnc_mil_patrol_addWP;",_area]];};
if (btc_debug) then {
if (!isNil {_group getVariable "btc_patrol_id"}) then {
_marker = createmarker [format ["Patrol_fant_%1", _group getVariable "btc_patrol_id"] , [(_pos select 0) + random 30,(_pos select 1) + random 30,0]];
format ["Patrol_fant_%1", _group getVariable "btc_patrol_id"] setmarkertype "mil_dot";
format ["Patrol_fant_%1", _group getVariable "btc_patrol_id"] setMarkerText format ["P %1", _group getVariable "btc_patrol_id"];
Expand Down

0 comments on commit d63d7af

Please sign in to comment.