From 13f3198e2d4e3e3504816bab3abfc714d4e24a9a Mon Sep 17 00:00:00 2001 From: second_coming Date: Tue, 3 May 2016 01:05:51 +0100 Subject: [PATCH] v34 tweaks --- changeLog.txt | 5 +++ config.sqf | 6 +-- initServer.sqf | 2 +- scripts/functions/fnc_addMarker.sqf | 22 +--------- scripts/functions/fnc_selectGear.sqf | 4 +- scripts/occupationMonitor.sqf | 61 ++++++++++++++++---------- scripts/reactions/airHit.sqf | 35 +++------------ scripts/reactions/comeUnstuck.sqf | 14 +++--- scripts/reactions/driverKilled.sqf | 6 --- scripts/reactions/getIn.sqf | 6 --- scripts/reactions/getOut.sqf | 32 -------------- scripts/reactions/refuel.sqf | 18 -------- scripts/reactions/repairVehicle.sqf | 35 ++++++++------- scripts/reactions/unitMPHit.sqf | 2 +- scripts/reactions/unitMPKilled.sqf | 12 ----- scripts/reactions/vehicleDestroyed.sqf | 47 +++++++++++--------- scripts/startOccupation.sqf | 1 + 17 files changed, 113 insertions(+), 195 deletions(-) diff --git a/changeLog.txt b/changeLog.txt index e5d9974..1506c3b 100644 --- a/changeLog.txt +++ b/changeLog.txt @@ -1,3 +1,8 @@ +================================================================================= +V34 (03-05-2016) +================================================================================= +Altered a lot of the eventhandler in an attempt to stop the out of memory errors + ================================================================================= V33 (30-04-2016) ================================================================================= diff --git a/config.sqf b/config.sqf index 4867569..578f8e3 100644 --- a/config.sqf +++ b/config.sqf @@ -13,8 +13,8 @@ // Shared Config for each occupation monitor -SC_debug = false; // set to true to turn on debug features (not for live servers) -SC_extendedLogging = false; // set to true for additional logging +SC_debug = true; // set to true to turn on debug features (not for live servers) +SC_extendedLogging = true; // set to true for additional logging SC_processReporter = true; // true if you want to log server threads every 60 seconds (useful to spot problems on the server) SC_infiSTAR_log = true; // true Use infiSTAR logging, false logs to server rpt SC_maxAIcount = 100; // the maximum amount of AI, if the AI count is above this then additional AI won't spawn @@ -208,7 +208,7 @@ SC_VehicleClassToUseRare = [ ]; // Settings for roaming airborne AI (non armed helis will just fly around) -SC_maxNumberofHelis = 1; +SC_maxNumberofHelis = 7; // Array of aircraft which can be used by AI patrols SC_HeliClassToUse = [ "Exile_Chopper_Huey_Armed_Green" ]; diff --git a/initServer.sqf b/initServer.sqf index 0091579..c2c2589 100644 --- a/initServer.sqf +++ b/initServer.sqf @@ -2,7 +2,7 @@ // // Server Occupation script by second_coming // -SC_occupationVersion = "v33 (30-04-2016)"; +SC_occupationVersion = "v34 (03-05-2016)"; // // http://www.exilemod.com/profile/60-second_coming/ // diff --git a/scripts/functions/fnc_addMarker.sqf b/scripts/functions/fnc_addMarker.sqf index ea22adc..c515574 100644 --- a/scripts/functions/fnc_addMarker.sqf +++ b/scripts/functions/fnc_addMarker.sqf @@ -3,25 +3,7 @@ private["_newUniform","_newVest","_newHeadgear","_arrowClass"]; _side = _this select 0; _unit = _this select 1; -_unit removeAllMPEventHandlers "mphit"; - - -switch (_side) do +if(_side == "survivor") then { - case "survivor": - { - _arrowClass = "Sign_Arrow_Green_F"; - _unit addMPEventHandler ["mphit", "_this call SC_fnc_unitMPHit;"]; - }; - case "bandit": - { - _arrowClass = "Sign_Arrow_F"; - }; + _unit addMPEventHandler ["mphit", "_this call SC_fnc_unitMPHit;"]; }; - -if(SC_debug) then -{ - _tag = createVehicle [_arrowClass, position _unit, [], 0, "CAN_COLLIDE"]; - _tag attachTo [_unit,[0,0,0.6],"Head"]; -}; -_unit addMPEventHandler ["mpkilled", "_this call SC_fnc_unitMPKilled;"]; \ No newline at end of file diff --git a/scripts/functions/fnc_selectGear.sqf b/scripts/functions/fnc_selectGear.sqf index 68061e2..8f23298 100644 --- a/scripts/functions/fnc_selectGear.sqf +++ b/scripts/functions/fnc_selectGear.sqf @@ -24,7 +24,7 @@ switch (_side) do for "_i" from 1 to _amountOfMagazines do { _newMagazine = SC_SurvivorMagazines call BIS_fnc_selectRandom; - _quantity = 1 + round random (2); + _quantity = 1; _magazines pushBack [_newMagazine,_quantity]; }; }; @@ -63,7 +63,7 @@ _pistolAttachmentsChance = round (random 100); if(_pistolAttachmentsChance < 50) then { _pistolAttachments = [""]; }; _backpackChance = round (random 100); -if(_backpackChance < 40) then { _backpack = ""; }; +if(_backpackChance < 20) then { _backpack = ""; }; _launcherChance = round (random 100); if(_launcherChance < 40 OR isNil "_launcher") then { _launcher = ""; }; diff --git a/scripts/occupationMonitor.sqf b/scripts/occupationMonitor.sqf index dab107f..e2283ee 100644 --- a/scripts/occupationMonitor.sqf +++ b/scripts/occupationMonitor.sqf @@ -2,35 +2,52 @@ _logDetail = format ["[OCCUPATION:Unstick]:: Initialised at %1",time]; [_logDetail] call SC_fnc_log; { - _logDetail = format ["[OCCUPATION:Unstick]:: Air: %1 is active",_x]; - [_logDetail] call SC_fnc_log; - _x setFuel 1; - sleep 5; - _originalSpawnLocation = _x getVariable "SC_vehicleSpawnLocation"; - _pos = position _x; - _nearestMarker = [allMapMarkers, _pos] call BIS_fnc_nearestPosition; // Nearest Marker to the Location - _posNearestMarker = getMarkerPos _nearestMarker; - if(_pos distance _posNearestMarker < 750) then + if(!isNull _x) then { - _GroupLeader = leader (group _x); - _GroupLeader doMove _originalSpawnLocation; - }; + _logDetail = format ["[OCCUPATION:Unstick]:: Air: %1 is active",_x]; + [_logDetail] call SC_fnc_log; + _x setFuel 1; + [_x] call SC_fnc_comeUnstuck; + sleep 5; + } + else + { + SC_liveHelis = SC_liveHelis - 1; + SC_liveHelisArray = SC_liveHelisArray - [_x]; + }; + }forEach SC_liveHelisArray; { - _logDetail = format ["[OCCUPATION:Unstick]:: Land: %1 is active",_x]; - [_logDetail] call SC_fnc_log; - _x setFuel 1; - [_x] call SC_fnc_comeUnstuck; - sleep 5; + if(!isNull _x) then + { + _logDetail = format ["[OCCUPATION:Unstick]:: Land: %1 is active",_x]; + [_logDetail] call SC_fnc_log; + _x setFuel 1; + [_x] call SC_fnc_comeUnstuck; + sleep 5; + } + else + { + SC_liveVehicles = SC_liveVehicles - 1; + SC_liveVehiclesArray = SC_liveVehiclesArray - [_x]; + }; }forEach SC_liveVehiclesArray; { - _logDetail = format ["[OCCUPATION:Unstick]:: Sea: %1 is active",_x]; - [_logDetail] call SC_fnc_log; - _x setFuel 1; - [_x] call SC_fnc_comeUnstuck; - sleep 5; + if(!isNull _x) then + { + _logDetail = format ["[OCCUPATION:Unstick]:: Sea: %1 is active",_x]; + [_logDetail] call SC_fnc_log; + _x setFuel 1; + [_x] call SC_fnc_comeUnstuck; + sleep 5; + } + else + { + SC_liveBoats = SC_liveBoats - 1; + SC_liveBoatsArray = SC_liveBoatsArray - [_x]; + }; }forEach SC_liveBoatsArray; diff --git a/scripts/reactions/airHit.sqf b/scripts/reactions/airHit.sqf index 0d377b6..0693ab0 100644 --- a/scripts/reactions/airHit.sqf +++ b/scripts/reactions/airHit.sqf @@ -16,31 +16,7 @@ if(SC_extendedLogging) then }; _ejectChance = round (random 100) + (_heliDamage * 100); - -_essentials = [ "HitAvionics","HitEngine1","HitEngine2","HitEngine","HitHRotor","HitVRotor","HitTransmission", - "HitHydraulics","HitGear","HitHStabilizerL1","HitHStabilizerR1","HitVStabilizer1","HitFuel"]; - -_damagedEssentials = 0; -{ - if ((_heli getHitPointDamage _x) > 0) then - { - if(_x == "HitFuel" && _heliDamage < 1) then - { - _heli setHitPointDamage ["HitFuel", 0]; - _heli setFuel 1; - }; - _damage = _heli getHitPointDamage _x; - if(SC_extendedLogging) then - { - _logDetail = format ["[OCCUPATION:Sky]:: Heli %1 checking part %2 (damage: %4) @ %3",_heli, _x, time,_damage]; - [_logDetail] call SC_fnc_log; - }; - if(_damage > 0) then { _damagedEssentials = _damagedEssentials + 1; }; - }; -} forEach _essentials; - - -if(_heliDamage > 0.2 && _damagedEssentials > 0 && !_crewEjected && _ejectChance > 100) then +if(_heliDamage > 0.2 && !_crewEjected && _ejectChance > 100) then { _target = _this select 1; [_heli, _target] spawn @@ -81,7 +57,7 @@ if(_heliDamage > 0.2 && _damagedEssentials > 0 && !_crewEjected && _ejectChance }; -if(_heliDamage > 0.7 && _damagedEssentials > 0) then +if(_heliDamage > 0.7) then { if(SC_extendedLogging) then { @@ -109,11 +85,14 @@ if(_heliDamage > 0.7 && _damagedEssentials > 0) then _wp setWaypointBehaviour "COMBAT"; _wp setWaypointCombatMode "RED"; _wp setWaypointCompletionRadius 10; - _wp setWaypointType "GETOUT"; + _wp setWaypointType ""TR UNLOAD""; [_group2, _destination, 250] call bis_fnc_taskPatrol; _group2 setBehaviour "COMBAT"; _group2 setCombatMode "RED"; }; -_heli addMPEventHandler ["mphit", "_this call SC_fnc_airHit;"]; \ No newline at end of file +if(_heliDamage <= 0.7) then +{ + _heli addMPEventHandler ["mphit", "_this call SC_fnc_airHit;"]; +}; \ No newline at end of file diff --git a/scripts/reactions/comeUnstuck.sqf b/scripts/reactions/comeUnstuck.sqf index bdbf9c4..477071f 100644 --- a/scripts/reactions/comeUnstuck.sqf +++ b/scripts/reactions/comeUnstuck.sqf @@ -33,6 +33,11 @@ if(count(crew _vehicle) > 0)then _vehicle setVectorUp [0,0,1]; _originalSpawnLocation = _vehicle getVariable "SC_vehicleSpawnLocation"; + + if(isNil "_originalSpawnLocation") then + { + _originalSpawnLocation = [_curPos, 50, 1000, 3, 2, 20, 0] call BIS_fnc_findSafePos; + }; _group = group _vehicle; _vehClass = typeOf _vehicle; @@ -68,17 +73,14 @@ if(count(crew _vehicle) > 0)then _vehicle setVariable["vehPos",_newPos]; }; -_group = group _vehicle; - // Remove dead units from the group +_group = group _vehicle; { if(!alive _x) then { [_x] join grpNull; }; }forEach units _group; -if(count units _group > 0) then +if(count units _group < 1) then { - _vehicle lock 0; - _vehicle setVehicleLock "UNLOCKED"; - _vehicle setVariable ["ExileIsLocked", 0, true]; + _vehicle call SC_fnc_vehicleDestroyed; }; diff --git a/scripts/reactions/driverKilled.sqf b/scripts/reactions/driverKilled.sqf index deaf3be..1ef1541 100644 --- a/scripts/reactions/driverKilled.sqf +++ b/scripts/reactions/driverKilled.sqf @@ -50,12 +50,6 @@ if(count units _group > 0) then _driver removeAllMPEventHandlers "mphit"; _driver addMPEventHandler ["mpkilled", "_this call SC_fnc_driverKilled;"]; - if(SC_debug) then - { - _tag = createVehicle ["Sign_Arrow_Yellow_F", position _driver, [], 0, "CAN_COLLIDE"]; - _tag attachTo [_driver,[0,0,0.6],"Head"]; - }; - _driver doMove (position _vehicle); _driver action ["movetodriver", _vehicle]; diff --git a/scripts/reactions/getIn.sqf b/scripts/reactions/getIn.sqf index e70bd22..20260de 100644 --- a/scripts/reactions/getIn.sqf +++ b/scripts/reactions/getIn.sqf @@ -16,12 +16,6 @@ if(isPlayer _unit) then } else { - if(SC_debug) then - { - { deleteVehicle _x; } forEach attachedObjects _unit; - }; - - if(damage _vehicle > 0) then { [_vehicle] call SC_fnc_repairVehicle; diff --git a/scripts/reactions/getOut.sqf b/scripts/reactions/getOut.sqf index 3ec52bb..e69de29 100644 --- a/scripts/reactions/getOut.sqf +++ b/scripts/reactions/getOut.sqf @@ -1,32 +0,0 @@ -// Triggered if an AI unit leaves an AI vehicle - -_unit = _this select 0; -_vehicle = _this select 2; -_driver = _vehicle getVariable "SC_assignedDriver"; -_arrowClass = "Sign_Arrow_F"; - -if(!alive _unit) exitWith {}; - -if(side _unit == SC_SurvivorSide) then -{ - _arrowClass = "Sign_Arrow_Green_F"; -} -else -{ - _arrowClass = "Sign_Arrow_F"; -}; - -if(_unit == _driver) then -{ - _arrowClass = "Sign_Arrow_Yellow_F"; -}; - -if(SC_debug && alive _unit && vehicle _unit != _unit) then -{ - _tag = createVehicle [_arrowClass, position _unit, [], 0, "CAN_COLLIDE"]; - _tag attachTo [_unit,[0,0,0.6],"Head"]; -} -else -{ - { deleteVehicle _x; } forEach attachedObjects _unit; -}; \ No newline at end of file diff --git a/scripts/reactions/refuel.sqf b/scripts/reactions/refuel.sqf index 06ad962..e69de29 100644 --- a/scripts/reactions/refuel.sqf +++ b/scripts/reactions/refuel.sqf @@ -1,18 +0,0 @@ -// Triggered when a vehicle runs out of fuel but only if not damaged - -_vehicle = _this select 0; -_fuel = _this select 1; - -diag_log format["[OCCUPATION:refuelcheck] _vehicle: %1 ---- _fuel: %2 ",_vehicle,_fuel]; -/* -if(!isNil "_vehicle" && !isNil "_fuel") then -{ - _damage = getdammage _vehicle; - - if(_damage <> 0 && !_fuel) then - { - _vehicle setFuel 1; - _vehicle engineOn true; - }; -}; -*/ diff --git a/scripts/reactions/repairVehicle.sqf b/scripts/reactions/repairVehicle.sqf index 402211e..57c1756 100644 --- a/scripts/reactions/repairVehicle.sqf +++ b/scripts/reactions/repairVehicle.sqf @@ -64,28 +64,29 @@ if(_damagedWheels > 0 OR _engineDamage OR _fueltankDamage) then _driver playMoveNow "Acts_carFixingWheel"; sleep 8; _driver switchMove ""; - if(alive _driver) then - { - _vehicle setDamage 0; - _driver playMoveNow "Acts_carFixingWheel"; - sleep 2; - _driver switchMove ""; - _driver assignAsDriver _vehicle; - _driver moveInDriver _vehicle; - _driver action ["movetodriver", _vehicle]; - }; + if(!alive _driver) exitWith{}; + _driver playMoveNow "Acts_carFixingWheel"; + sleep 2; + _vehicle setDamage 0; + _driver switchMove ""; + _driver assignAsDriver _vehicle; + _driver moveInDriver _vehicle; + _driver action ["movetodriver", _vehicle]; + _wp = _group addWaypoint [position _vehicle, 0] ; _wp setWaypointFormation "Column"; _wp setWaypointCompletionRadius 1; _wp setWaypointType "GETIN"; sleep 5; - _spawnLocation = _vehicle getVariable "SC_vehicleSpawnLocation"; - _driver action ["movetodriver", _vehicle]; - _vehicle forceSpeed -1; - [_group, _spawnLocation, 2000] call bis_fnc_taskPatrol; - _group setBehaviour "SAFE"; - _group setCombatMode "RED"; - + _spawnLocation = _vehicle getVariable "SC_vehicleSpawnLocation"; + if(!isNil "_spawnLocation") then + { + _driver action ["movetodriver", _vehicle]; + _vehicle forceSpeed -1; + [_group, _spawnLocation, 2000] call bis_fnc_taskPatrol; + _group setBehaviour "SAFE"; + _group setCombatMode "RED"; + }; }; } else diff --git a/scripts/reactions/unitMPHit.sqf b/scripts/reactions/unitMPHit.sqf index 3eb7f28..3cab843 100644 --- a/scripts/reactions/unitMPHit.sqf +++ b/scripts/reactions/unitMPHit.sqf @@ -13,7 +13,7 @@ if (side _aggressor == RESISTANCE) then _group = createGroup WEST; { _unit = _x; - //[_unit] joinSilent grpNull; + [_unit] joinSilent grpNull; [_unit] joinSilent _group; _unit removeAllMPEventHandlers "mphit"; }foreach units _initialGroup; diff --git a/scripts/reactions/unitMPKilled.sqf b/scripts/reactions/unitMPKilled.sqf index 363dcda..e69de29 100644 --- a/scripts/reactions/unitMPKilled.sqf +++ b/scripts/reactions/unitMPKilled.sqf @@ -1,12 +0,0 @@ -// Get the variables from the event handler -_unit = _this select 0; -_killer = _this select 1; - -// remove all eventhandlers from the dead unit -_unit removeAllMPEventHandlers "mphit"; -[_unit] join grpNull; - -if(SC_debug) then -{ - { deleteVehicle _x; } forEach attachedObjects _unit; -}; diff --git a/scripts/reactions/vehicleDestroyed.sqf b/scripts/reactions/vehicleDestroyed.sqf index 71d91e5..fa8a703 100644 --- a/scripts/reactions/vehicleDestroyed.sqf +++ b/scripts/reactions/vehicleDestroyed.sqf @@ -1,26 +1,31 @@ // SC_liveVehicles = count of vehicle // SC_liveVehiclesArray = array of active vehicles - -_vehicle = _this select 0; -_vehicle removeAllMPEventHandlers "mphit"; -_vehicle removeAllMPEventHandlers "mpkilled"; -_vehicle removeAllEventHandlers "getin"; -_vehicle removeAllEventHandlers "getout"; - -if(_vehicle isKindOf "LandVehicle") then +if(!isNil "_this") then { - SC_liveVehicles = SC_liveVehicles - 1; - SC_liveVehiclesArray = SC_liveVehiclesArray - [_vehicle]; -}; + _vehicle = _this select 0; + _vehicle removeAllMPEventHandlers "mphit"; + _vehicle removeAllMPEventHandlers "mpkilled"; + _vehicle removeAllEventHandlers "getin"; + _vehicle removeAllEventHandlers "getout"; + _vehicle lock 0; + _vehicle setVehicleLock "UNLOCKED"; + _vehicle setVariable ["ExileIsLocked", 0, true]; + + if(_vehicle isKindOf "LandVehicle") then + { + SC_liveVehicles = SC_liveVehicles - 1; + SC_liveVehiclesArray = SC_liveVehiclesArray - [_vehicle]; + }; -if(_vehicle isKindOf "Air") then -{ - SC_liveHelis = SC_liveHelis - 1; - SC_liveHelisArray = SC_liveHelisArray - [_vehicle]; -}; + if(_vehicle isKindOf "Air") then + { + SC_liveHelis = SC_liveHelis - 1; + SC_liveHelisArray = SC_liveHelisArray - [_vehicle]; + }; -if(_vehicle isKindOf "Ship") then -{ - SC_liveBoatss = SC_liveBoatss - 1; - SC_liveBoatsArray = SC_liveBoatsArray - [_vehicle]; -}; + if(_vehicle isKindOf "Ship") then + { + SC_liveBoats = SC_liveBoats - 1; + SC_liveBoatsArray = SC_liveBoatsArray - [_vehicle]; + }; +}; \ No newline at end of file diff --git a/scripts/startOccupation.sqf b/scripts/startOccupation.sqf index e099a39..f91539c 100644 --- a/scripts/startOccupation.sqf +++ b/scripts/startOccupation.sqf @@ -21,6 +21,7 @@ if(SC_processReporter) then if (SC_fastNights) then { fnc_checkMultiplier = compile preprocessFileLineNumbers "\x\addons\a3_exile_occupation\scripts\occupationFastNights.sqf"; + diag_log format ["[OCCUPATION:FastNights]:: Initialised at %1",time]; [60, fnc_checkMultiplier, [], true] call ExileServer_system_thread_addTask; };