From 6d1e98ab6ceac6d5f77bc6cee2de6f6378e7cda3 Mon Sep 17 00:00:00 2001 From: second_coming Date: Thu, 14 Apr 2016 15:09:04 +0100 Subject: [PATCH] v18 fixes & tweaks --- config.sqf | 8 +++--- initServer.sqf | 4 ++- scripts/occupationPlaces.sqf | 50 +++++++++++++++++---------------- scripts/occupationPublicBus.sqf | 24 ++++++++-------- scripts/reactions/getOffBus.sqf | 9 ++++++ scripts/reactions/getOnBus.sqf | 10 +++++++ scripts/reactions/unitMPHit.sqf | 2 ++ 7 files changed, 66 insertions(+), 41 deletions(-) create mode 100644 scripts/reactions/getOffBus.sqf create mode 100644 scripts/reactions/getOnBus.sqf diff --git a/config.sqf b/config.sqf index 86dffcf..29728f9 100644 --- a/config.sqf +++ b/config.sqf @@ -120,8 +120,6 @@ if (worldName == 'Namalsk') then SC_occupyPublicBusClass = "Exile_Car_LandRover_Urban"; // the ikarus bus gets stuck on Namalsk }; - - // Don't alter anything below this point SC_liveVehicles = 0; SC_liveVehiclesArray = []; @@ -129,7 +127,8 @@ SC_liveHelis = 0; SC_liveHelisArray = []; SC_liveBoats = 0; SC_liveBoatsArray = []; -SC_publicBusArray = []; +SC_publicBusArray = []; +SC_StopTheBus = false; publicVariable "SC_liveVehicles"; publicVariable "SC_liveVehiclesArray"; @@ -138,4 +137,5 @@ publicVariable "SC_liveHelisArray"; publicVariable "SC_liveBoats"; publicVariable "SC_liveBoatsArray"; publicVariable "SC_numberofLootCrates"; -publicVariable "SC_publicBusArray"; \ No newline at end of file +publicVariable "SC_publicBusArray"; +publicVariable "SC_StopTheBus"; \ No newline at end of file diff --git a/initServer.sqf b/initServer.sqf index 6677bba..aca1e3a 100644 --- a/initServer.sqf +++ b/initServer.sqf @@ -2,7 +2,7 @@ // // Server Occupation script by second_coming // -SC_occupationVersion = "v16 (14-04-2016)"; +SC_occupationVersion = "v18 (14-04-2016)"; // // http://www.exilemod.com/profile/60-second_coming/ // @@ -44,6 +44,8 @@ SC_occupationVersion = "v16 (14-04-2016)"; SC_fnc_refuel = compile preprocessFileLineNumbers "\x\addons\a3_exile_occupation\scripts\reactions\refuel.sqf"; SC_fnc_comeUnstuck = compile preprocessFileLineNumbers "\x\addons\a3_exile_occupation\scripts\reactions\comeUnstuck.sqf"; SC_fnc_unitMPHit = compile preprocessFileLineNumbers "\x\addons\a3_exile_occupation\scripts\reactions\unitMPHit.sqf"; + SC_fnc_getOnBus = compile preprocessFileLineNumbers "\x\addons\a3_exile_occupation\scripts\reactions\getOnBus.sqf"; + SC_fnc_getOffBus = compile preprocessFileLineNumbers "\x\addons\a3_exile_occupation\scripts\reactions\getOffBus.sqf"; _logDetail = "============================================================================================================="; [_logDetail] call SC_fnc_log; diff --git a/scripts/occupationPlaces.sqf b/scripts/occupationPlaces.sqf index 5783fdc..979cd70 100644 --- a/scripts/occupationPlaces.sqf +++ b/scripts/occupationPlaces.sqf @@ -121,12 +121,21 @@ _locations = (nearestLocations [_spawnCenter, ["NameVillage","NameCity", "NameCi // Don't spawn additional AI if there are already AI in range - _aiNear = count(_pos nearEntities ["O_recon_F", 500]); - if(_aiNear > 0) then + + _nearEastAI = { side _x == EAST AND _x distance _pos < 500 } count allUnits; + _nearWestAI = { side _x == WEST AND _x distance _pos < 500 } count allUnits; + + if(_nearEastAI > 0 AND _nearWestAI > 0) then { - _nearEastAI = { side _x == EAST AND _x distance _pos < 500 } count allUnits; - _nearWestAI = { side _x == WEST AND _x distance _pos < 500 } count allUnits; - + _okToSpawn = false; + if(SC_extendedLogging) then + { + _logDetail = format ["[OCCUPATION:Places]:: %1 already has %2 active AI patrolling",_locationName,_aiNear]; + [_logDetail] call SC_fnc_log; + }; + } + else + { if(_nearEastAI == 0 AND _nearWestAI == 0) then { _sideToSpawn = random 100; @@ -138,27 +147,20 @@ _locations = (nearestLocations [_spawnCenter, ["NameVillage","NameCity", "NameCi { _side = "bandit"; }; - }; - if(_nearEastAI > 0 AND _nearWestAI == 0) then - { - _side = "survivor"; - }; - if(_nearEastAI == 0 AND _nearWestAI > 0) then - { - _side = "bandit"; - }; - if(_nearEastAI > 0 AND _nearWestAI > 0) then - { - _okToSpawn = false; - if(SC_extendedLogging) then + } + else + { + if(_nearWestAI == 0) then { - _logDetail = format ["[OCCUPATION:Places]:: %1 already has %2 active AI patrolling",_locationName,_aiNear]; - [_logDetail] call SC_fnc_log; - }; - }; - + _side = "survivor"; + } + else + { + _side = "bandit"; + }; + }; }; - + if(_okToSpawn) then { if(!SC_occupyPlacesSurvivors) then { _side = "bandit"; }; diff --git a/scripts/occupationPublicBus.sqf b/scripts/occupationPublicBus.sqf index 8d0c46b..e09f51e 100644 --- a/scripts/occupationPublicBus.sqf +++ b/scripts/occupationPublicBus.sqf @@ -31,7 +31,8 @@ _publicBus = createVehicle [SC_occupyPublicBusClass, _spawnLocation, [], 0, "CAN SC_publicBusArray = SC_publicBusArray + [_publicBus]; _publicBus setVariable ["SC_assignedDriver", busDriver,true]; _publicBus setVariable ["SC_vehicleSpawnLocation", _spawnLocation,true]; -_publicBus addEventHandler ["getin", "_this call SC_fnc_getInBus;"]; +_publicBus addEventHandler ["getin", "_this call SC_fnc_getOnBus;"]; +_publicBus addEventHandler ["getout", "_this call SC_fnc_getOffBus;"]; _group addVehicle _publicBus; clearBackpackCargoGlobal _publicBus; @@ -102,17 +103,16 @@ while {true} do busDriver enableAI "MOVE"; if(!Alive busDriver) exitWith {}; }; + + if(SC_StopTheBus) then + { + uiSleep 0.5; + _publicBus setFuel 0; + busDriver disableAI "MOVE"; + uiSleep 5; + SC_StopTheBus = false; + }; + uiSleep 5; }; -{ - // Check for nearby missions - _missionPos = missionNamespace getVariable [format ["%1_pos",_x], []]; - _missionDistance = _missionPos distance2D _pos; - if (_missionDistance<=500) then - { - // DMS Mission in range - _logDetail = format['[OCCUPATION:publicBus] Vehicle near DMS Mission @ %1 (%2 metres away)',_missionPos,(_missionPos distance2D _pos)]; - [_logDetail] call SC_fnc_log; - }; -} forEach allMapMarkers; \ No newline at end of file diff --git a/scripts/reactions/getOffBus.sqf b/scripts/reactions/getOffBus.sqf new file mode 100644 index 0000000..e945815 --- /dev/null +++ b/scripts/reactions/getOffBus.sqf @@ -0,0 +1,9 @@ +// Triggered if a player gets off the public bus +// removes the addaction to stop the bus +_bus = _this select 0; +_unit = _this select 2; + +if(isPlayer _unit) then +{ + _unit removeAction _bustop; +}; \ No newline at end of file diff --git a/scripts/reactions/getOnBus.sqf b/scripts/reactions/getOnBus.sqf new file mode 100644 index 0000000..2474745 --- /dev/null +++ b/scripts/reactions/getOnBus.sqf @@ -0,0 +1,10 @@ +// Triggered if a player gets on the public bus +// adds an addaction to stop the bus +_bus = _this select 0; +_unit = _this select 2; + +if(isPlayer _unit) then +{ + _bustop = _unit addAction ["Stop the bus", { SC_StopTheBus = true } ]; +}; + diff --git a/scripts/reactions/unitMPHit.sqf b/scripts/reactions/unitMPHit.sqf index 6b82239..6f9e6b5 100644 --- a/scripts/reactions/unitMPHit.sqf +++ b/scripts/reactions/unitMPHit.sqf @@ -10,8 +10,10 @@ if (side _aggressor == RESISTANCE) then { // Make victim and his group aggressive to their attacker _group = group _unit; + _unit addRating -999999; _group reveal [_aggressor, 2.5]; _group move (position _aggressor); + diag_log format["::testing:: unit %1 damaged by %2",_unit,_aggressor]; };