Skip to content

Commit

Permalink
Merge pull request #83 from Vdauphin/FIX-btc_patrol_active_negative
Browse files Browse the repository at this point in the history
FIX: btc_patrol_active and btc_civ_veh_active negative
  • Loading branch information
Giallustio committed Jan 28, 2016
2 parents 5988a30 + 1321efe commit ac2ae75
Show file tree
Hide file tree
Showing 9 changed files with 16 additions and 20 deletions.
4 changes: 2 additions & 2 deletions =BTC=co@22_Hearts_and_Minds.Altis/core/def/mission.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ if (isServer) then {
btc_city_blacklist = [];//NAME FROM CFG

//Civ
btc_civ_veh_active = 0;
btc_civ_veh_active = [];

//Database
btc_db_is_saving = false;
Expand Down Expand Up @@ -83,7 +83,7 @@ if (isServer) then {

//Patrol
btc_patrol_max = 5;
btc_patrol_active = 0;
btc_patrol_active = [];
btc_patrol_area = 2500;

//Rep
Expand Down
14 changes: 9 additions & 5 deletions =BTC=co@22_Hearts_and_Minds.Altis/core/fnc/city/activate.sqf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

private ["_city","_is_init","_data_units","_type","_radius_x","_radius_y","_has_en","_has_ho","_ieds","_radius"];
private ["_city","_is_init","_data_units","_type","_radius_x","_radius_y","_has_en","_has_ho","_ieds","_radius","_number_patrol_active","_number_civ_veh_active"];

hint ("Activate " + str(_this));

Expand Down Expand Up @@ -139,11 +139,13 @@ if (count _ieds > 0) then {
};

//Patrol
if (btc_patrol_active < btc_patrol_max) then {
btc_patrol_active = btc_patrol_active - [grpNull];
_number_patrol_active = count btc_patrol_active;
if (_number_patrol_active < btc_patrol_max) then {
private ["_n","_av","_d","_r"];
_n = 0;_r = 0;
if (_has_en) then {_n = round (random 3 + (3/2));} else {_n = round random 2;};
_av = btc_patrol_max - btc_patrol_active;
_av = btc_patrol_max - _number_patrol_active;
_d = _n - _av;
if (_d > 0) then {_r = _n - _d;} else {_r = _n;};
for "_i" from 1 to _r do
Expand All @@ -154,11 +156,13 @@ if (btc_patrol_active < btc_patrol_max) then {
};

//Traffic
if (btc_civ_veh_active < btc_civ_max_veh) then {
btc_civ_veh_active = btc_civ_veh_active - [grpNull];
_number_civ_veh_active = count btc_civ_veh_active;
if (_number_civ_veh_active < btc_civ_max_veh) then {
private ["_n","_av","_d","_r"];
_n = 0;_r = 0;
_n = round (random 3 + (3/2));
_av = btc_civ_max_veh - btc_civ_veh_active;
_av = btc_civ_max_veh - _number_civ_veh_active;
_d = _n - _av;
if (_d > 0) then {_r = _n - _d;} else {_r = _n;};
for "_i" from 1 to _r do {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ if ({_x distance _city < (_area/2) || _x distance leader _group < (_area/2)} cou
diag_log text "DELETE TRAFFIC GROUP";
if (vehicle leader _group != leader _group) then {deleteVehicle (vehicle leader _group)};
{deleteVehicle _x;} foreach units _group;deleteGroup _group;
btc_civ_veh_active = btc_civ_veh_active - 1;
};

_cities = [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ private ["_city","_area","_cities","_useful","_unit_type","_veh_type","_group","
_city = _this select 0;
_area = _this select 1;

btc_civ_veh_active = btc_civ_veh_active + 1;
if (isNil "btc_traffic_id") then {btc_traffic_id = 0;};

_cities = [];
Expand Down Expand Up @@ -61,6 +60,8 @@ _3 = _veh addEventHandler ["GetOut", {_this call btc_fnc_civ_traffic_eh}];
_veh setVariable ["eh", [_1,_2,_3/*,4,5*/]];
_veh setVariable ["driver", leader _group];

btc_civ_veh_active pushBack _group;

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

[_group,_area,_iswater] call btc_fnc_civ_traffic_add_WP;
2 changes: 0 additions & 2 deletions =BTC=co@22_Hearts_and_Minds.Altis/core/fnc/civ/traffic_eh.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,4 @@ _veh call btc_fnc_civ_traffic_eh_remove;
[_veh,(_veh getVariable ["driver",_veh])] spawn {
waitUntil {sleep 5; ({_x distance (_this select 0) < 600} count playableUnits == 0)};
{deleteVehicle _x;} foreach _this;
if (isNull (_this select 0)) exitWith {};//Just to be sure
btc_civ_veh_active = btc_civ_veh_active - 1;
};
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ _players = if (isMultiplayer) then {playableUnits} else {switchableUnits};
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;
};

_cities = [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@ _area = _this select 2;

if (isNil "btc_patrol_id") then {btc_patrol_id = 0;};

btc_patrol_active = btc_patrol_active + 1;

if (btc_debug_log) then {diag_log format ["btc_fnc_mil_patrol_create: _random = %1 _city %2 _area %3 btc_patrol_active = %4",_random,_city,_area,btc_patrol_active];};
if (btc_debug_log) then {diag_log format ["btc_fnc_mil_patrol_create: _random = %1 _city %2 _area %3 btc_patrol_active = %4",_random,_city,_area,count(btc_patrol_active)];};

if (_random == 0) then {
private ["_n"];
Expand Down Expand Up @@ -90,4 +88,6 @@ switch (true) do {
};
};

btc_patrol_active pushBack _group;

{_x call btc_fnc_mil_unit_create} foreach units _group;
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,4 @@ if (isPlayer (_this select 1)) then {
if (isServer) then {btc_rep_bonus_mil_killed call btc_fnc_rep_change;} else {[btc_rep_bonus_mil_killed,"btc_fnc_rep_change",false] spawn BIS_fnc_MP;};
};

if ((group (_this select 0)) getVariable ["btc_patrol",false] && {({Alive _x} count units (group (_this select 0)) == 0)}) then {
btc_patrol_active = btc_patrol_active - 1;
};

//(_this select 0) spawn {sleep 0.5;{deleteVehicle _x} foreach (nearestObjects [_this, ["WeaponHolderSimulated"], 5]);};
1 change: 0 additions & 1 deletion =BTC=co@22_Hearts_and_Minds.Altis/core/fnc/rep/killed.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,5 @@ if !(isNil {_unit getVariable ["traffic",objNull]}) then {
[getPos _unit,(_unit getVariable ["traffic",objNull])] spawn {
waitUntil {sleep 5; ({_x distance (_this select 0) < 300} count playableUnits == 0)};
deleteVehicle (_this select 1);
btc_civ_veh_active = btc_civ_veh_active - 1;
};
};

0 comments on commit ac2ae75

Please sign in to comment.