From d7fbd39a4be286a54944900ba473437962233e9b Mon Sep 17 00:00:00 2001 From: second_coming Date: Mon, 11 Apr 2016 13:59:33 +0100 Subject: [PATCH] public bus service added bug fix: attempt to sort the issue where AI groups kill each other on spawning --- config.sqf | 10 +-- scripts/occupationMilitary.sqf | 6 ++ scripts/occupationMonitor.sqf | 8 +++ scripts/occupationPlaces.sqf | 6 ++ scripts/occupationPublicBus.sqf | 113 ++++++++++++++++++++++++++++++++ scripts/occupationSea.sqf | 5 ++ scripts/occupationSky.sqf | 5 ++ scripts/occupationStatic.sqf | 9 ++- scripts/occupationVehicle.sqf | 10 ++- scripts/startOccupation.sqf | 7 ++ 10 files changed, 172 insertions(+), 7 deletions(-) create mode 100644 scripts/occupationPublicBus.sqf diff --git a/config.sqf b/config.sqf index 04e258e..61b816a 100644 --- a/config.sqf +++ b/config.sqf @@ -13,9 +13,9 @@ // Shared Config for each occupation monitor -SC_debug = false; // set to true to turn on debug features (not for live servers) +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_infiSTAR_log = false; // true Use infiSTAR logging, false logs to server rpt +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 SC_mapMarkers = false; // Place map markers at the occupied areas (occupyPlaces and occupyMilitary only) true/false @@ -47,7 +47,7 @@ SC_occupyVehicle = true; // true if you want to have roaming AI vehicles SC_occupySky = true; // true if you want to have roaming AI helis SC_occupySea = false; // true if you want to have roaming AI boats - +SC_occupyPublicBus = true; // true if you want a roaming bus service SC_occupyLootCrates = true; // true if you want to have random loot crates with guards SC_numberofLootCrates = 6; // if SC_occupyLootCrates = true spawn this many loot crates (overrided below for Namalsk) @@ -97,6 +97,7 @@ SC_liveHelis = 0; SC_liveHelisArray = []; SC_liveBoats = 0; SC_liveBoatsArray = []; +SC_publicBusArray = []; publicVariable "SC_liveVehicles"; publicVariable "SC_liveVehiclesArray"; @@ -104,4 +105,5 @@ publicVariable "SC_liveHelis"; publicVariable "SC_liveHelisArray"; publicVariable "SC_liveBoats"; publicVariable "SC_liveBoatsArray"; -publicVariable "SC_numberofLootCrates"; \ No newline at end of file +publicVariable "SC_numberofLootCrates"; +publicVariable "SC_publicBusArray"; \ No newline at end of file diff --git a/scripts/occupationMilitary.sqf b/scripts/occupationMilitary.sqf index 3f94742..b4e17d4 100644 --- a/scripts/occupationMilitary.sqf +++ b/scripts/occupationMilitary.sqf @@ -156,6 +156,12 @@ for [{_i = 0},{_i < (count _buildings)},{_i =_i + 1}] do _group = [_spawnPosition, _aiCount, _difficulty, "random", _side] call DMS_fnc_SpawnAIGroup; DMS_ai_use_launchers = true; + { + _unit = _x; + [_unit] joinSilent grpNull; + [_unit] joinSilent _group; + }foreach units _group; + [ _group,_pos,_difficulty,"COMBAT" ] call DMS_fnc_SetGroupBehavior; _buildings = _pos nearObjects ["house", _groupRadius]; diff --git a/scripts/occupationMonitor.sqf b/scripts/occupationMonitor.sqf index f49d1f2..189d532 100644 --- a/scripts/occupationMonitor.sqf +++ b/scripts/occupationMonitor.sqf @@ -24,5 +24,13 @@ _logDetail = format ["[OCCUPATION:Unstick]:: Initialised at %1",time]; sleep 5; }forEach SC_liveBoatsArray; +{ + _logDetail = format ["[OCCUPATION:Unstick]:: publicBus: %1 is active",_x]; + [_logDetail] call SC_fnc_log; + _x setFuel 1; + [_x] call SC_fnc_comeUnstuck; + sleep 5; +}forEach SC_publicBusArray; + _logDetail = format ["[OCCUPATION:Unstick]:: Finished at %1",time]; [_logDetail] call SC_fnc_log; \ No newline at end of file diff --git a/scripts/occupationPlaces.sqf b/scripts/occupationPlaces.sqf index f89f322..fe73adf 100644 --- a/scripts/occupationPlaces.sqf +++ b/scripts/occupationPlaces.sqf @@ -151,6 +151,12 @@ _locations = (nearestLocations [_spawnCenter, ["NameVillage","NameCity", "NameCi DMS_ai_use_launchers = false; _group = [_spawnPosition, _aiCount, "randomEasy", "assault", _side] call DMS_fnc_SpawnAIGroup; DMS_ai_use_launchers = _useLaunchers; + + { + _unit = _x; + [_unit] joinSilent grpNull; + [_unit] joinSilent _group; + }foreach units _group; // Get the AI to shut the fuck up :) enableSentences false; diff --git a/scripts/occupationPublicBus.sqf b/scripts/occupationPublicBus.sqf new file mode 100644 index 0000000..71069e9 --- /dev/null +++ b/scripts/occupationPublicBus.sqf @@ -0,0 +1,113 @@ +if (!isServer) exitWith {}; + +_logDetail = format ["[OCCUPATION:publicBus]:: Starting @ %1",time]; +[_logDetail] call SC_fnc_log; + +_position = [ 0, 50, 1, 500, 500, 200, 200, 200, true, false ] call DMS_fnc_findSafePos; + +// Get position of nearest roads +_nearRoads = _position nearRoads 2000; +_nearestRoad = _nearRoads select 0; +_nearestRoadPos = position (_nearRoads select 0); +_spawnLocation = [_nearestRoadPos select 0, _nearestRoadPos select 1, 0]; + +// Create the busDriver and ensure he doest react to gunfire or being shot at. + +_group = createGroup resistance; +_group setCombatMode "BLUE"; + +"Exile_Trader_CommunityCustoms" createUnit [_spawnLocation, _group, "busDriver = this; this disableAI 'AUTOTARGET'; this disableAI 'TARGET'; this disableAI 'SUPPRESSION'; "]; + +busDriver allowDamage false; +removeGoggles busDriver; +busDriver forceAddUniform "U_IG_Guerilla3_1"; +busDriver addVest "V_TacVest_blk_POLICE"; +busDriver addBackpack "B_FieldPack_oli"; +busDriver addHeadgear "H_Cap_blk"; +busDriver setCaptive true; + +// Spawn busDrivers Vehicle +_publicBus = createVehicle ["Exile_Car_Ikarus_Party", _spawnLocation, [], 0, "CAN_COLLIDE"]; +SC_publicBusArray = SC_publicBusArray + [_publicBus]; +_publicBus setVariable ["SC_assignedDriver", busDriver,true]; +_group addVehicle _publicBus; +clearBackpackCargoGlobal _publicBus; +clearItemCargoGlobal _publicBus; +clearMagazineCargoGlobal _publicBus; +clearWeaponCargoGlobal _publicBus; +_publicBus setVariable ["ExileIsPersistent", false]; +_publicBus setVariable["vehPos",_spawnLocation,true]; +_publicBus setFuel 1; + +diag_log format['[OCCUPATION:publicBus] Vehicle spawned @ %1',_spawnLocation]; + +_publicBus addEventHandler ["HandleDamage", { _amountOfDamage = 0; _amountOfDamage }]; + +busDriver assignasdriver _publicBus; +[busDriver] orderGetin true; + +{ + _markerName = _x; + _markerPos = getMarkerPos _markerName; + if (markerType _markerName == "ExileTraderZone") then + { + _wp = _group addWaypoint [_markerPos, 100]; + _wp setWaypointType "MOVE"; + _wp setWaypointBehaviour "CARELESS"; + _wp setWaypointspeed "LIMITED"; + }; + +} forEach allMapMarkers; + +// Add a final CYCLE +_wp = _group addWaypoint [_spawnLocation, 100]; +_wp setWaypointType "CYCLE"; +_wp setWaypointBehaviour "CARELESS"; +_wp setWaypointspeed "LIMITED"; + + +_busPos = position _publicBus; +_mk = createMarker ["busLocation",_busPos]; +"busLocation" setMarkerType "mil_warning"; +"busLocation" setMarkerText "Public Bus"; + +diag_log format['[OCCUPATION:publicBus] Running']; +busDriver = _publicBus getVariable "SC_assignedDriver"; + +// Make busDriver stop when players near him. +while {true} do +{ + + _pos = position _publicBus; + _mk setMarkerPos _pos; + _nearPlayers = (count (_pos nearEntities [['Exile_Unit_Player'],75])); + + if (_nearPlayers >= 1) then + { + uiSleep 0.5; + _publicBus setFuel 0; + busDriver action ["salute", busDriver]; + busDriver disableAI "MOVE"; + uiSleep 3; + } + else + { + _currentDriver = driver _publicBus; + if(isPlayer _currentDriver) then + { + [_currentDriver] orderGetin false; + }; + + if(isnull _currentDriver) then + { + sleep 0.1; + busDriver assignAsDriver _publicBus; + busDriver moveInDriver _publicBus; + [busDriver] orderGetin true; + }; + _publicBus setFuel 1; + uiSleep 3; + busDriver enableAI "MOVE"; + if(!Alive busDriver) exitWith {}; + }; +}; diff --git a/scripts/occupationSea.sqf b/scripts/occupationSea.sqf index 49b18e6..a79eec0 100644 --- a/scripts/occupationSea.sqf +++ b/scripts/occupationSea.sqf @@ -108,6 +108,11 @@ for "_i" from 1 to _vehiclesToSpawn do }; } forEach _vehicleRoles; + { + _unit = _x; + [_unit] joinSilent grpNull; + [_unit] joinSilent _group; + }foreach units _group; if(SC_infiSTAR_log) then { diff --git a/scripts/occupationSky.sqf b/scripts/occupationSky.sqf index 1f51e1a..b967f82 100644 --- a/scripts/occupationSky.sqf +++ b/scripts/occupationSky.sqf @@ -131,6 +131,11 @@ for "_i" from 1 to _vehiclesToSpawn do }; } forEach _vehicleRoles; + { + _unit = _x; + [_unit] joinSilent grpNull; + [_unit] joinSilent _group; + }foreach units _group; if(SC_infiSTAR_log) then { diff --git a/scripts/occupationStatic.sqf b/scripts/occupationStatic.sqf index dbbb19e..55bdbec 100644 --- a/scripts/occupationStatic.sqf +++ b/scripts/occupationStatic.sqf @@ -89,6 +89,13 @@ for [{_i = 0},{_i < (count _statics)},{_i =_i + 1}] do DMS_ai_use_launchers = false; _group = [_spawnPosition, _aiCount, _difficulty, "assault", _side] call DMS_fnc_SpawnAIGroup; + + { + _unit = _x; + [_unit] joinSilent grpNull; + [_unit] joinSilent _group; + }foreach units _group; + [ _group,_spawnPosition,_difficulty,"AWARE" ] call DMS_fnc_SetGroupBehavior; DMS_ai_use_launchers = true; @@ -124,7 +131,7 @@ for [{_i = 0},{_i < (count _statics)},{_i =_i + 1}] do } foreach _buildingPositions; _wpPosition = _highest; - //diag_log format ["Static Patrol %3 waypoint added - building: %1 position: %2",_y,_highest,_group]; + diag_log format ["Static Patrol %3 waypoint added - building: %1 position: %2",_y,_highest,_group]; _i = _buildingPositions find _wpPosition; _wp = _group addWaypoint [_wpPosition, 0] ; _wp setWaypointBehaviour "AWARE"; diff --git a/scripts/occupationVehicle.sqf b/scripts/occupationVehicle.sqf index a9a907c..da67583 100644 --- a/scripts/occupationVehicle.sqf +++ b/scripts/occupationVehicle.sqf @@ -122,6 +122,8 @@ if(_vehiclesToSpawn >= 1) then if(_vehicleRole == "Driver") then { _unit = [_group,_spawnLocation,"assault","random","bandit","Vehicle"] call DMS_fnc_SpawnAISoldier; + [_unit] joinSilent grpNull; + [_unit] joinSilent _group; _unit disableAI "TARGET"; _unit disableAI "AUTOTARGET"; _unit disableAI "AUTOCOMBAT"; @@ -135,7 +137,7 @@ if(_vehiclesToSpawn >= 1) then }; sleep 0.1; _unit assignAsDriver _vehicle; - _unit moveInDriver _vehicle; + _unit moveInDriver _vehicle; _unit setVariable ["DMS_AssignedVeh",_vehicle]; _unit setVariable ["SC_drivenVehicle", _vehicle,true]; _unit addMPEventHandler ["mpkilled", "_this call SC_fnc_driverKilled;"]; @@ -147,13 +149,17 @@ if(_vehiclesToSpawn >= 1) then if(_vehicleRole == "Turret") then { _unit = [_group,_spawnLocation,"assault","random","bandit","Vehicle"] call DMS_fnc_SpawnAISoldier; + [_unit] joinSilent grpNull; + [_unit] joinSilent _group; _unit moveInTurret [_vehicle, _vehicleSeat]; _unit setVariable ["DMS_AssignedVeh",_vehicle]; _unitPlaced = true; }; if(_vehicleRole == "CARGO") then { - _unit = [_group,_spawnLocation,"assault","random","bandit","Vehicle"] call DMS_fnc_SpawnAISoldier; + _unit = [_group,_spawnLocation,"assault","random","bandit","Vehicle"] call DMS_fnc_SpawnAISoldier; + [_unit] joinSilent grpNull; + [_unit] joinSilent _group; _unit assignAsCargo _vehicle; _unit moveInCargo _vehicle; _unit setVariable ["DMS_AssignedVeh",_vehicle]; diff --git a/scripts/startOccupation.sqf b/scripts/startOccupation.sqf index 8758133..8861aa3 100644 --- a/scripts/startOccupation.sqf +++ b/scripts/startOccupation.sqf @@ -9,10 +9,16 @@ if(SC_debug) then { SC_refreshTime = 60; }else{ SC_refreshTime = 300; }; // Add selected occupation scripts to Exile Threading System +if(SC_occupyPublicBus) then +{ + [] execVM "\x\addons\a3_exile_occupation\scripts\occupationPublicBus.sqf"; +}; + if(SC_occupyLootCrates) then { if(SC_occupyLootCratesMarkers) then { + uiSleep 15; // delay the start fnc_occupationDeleteMapMarker = compile preprocessFileLineNumbers "\x\addons\a3_exile_occupation\scripts\deleteMapMarkers.sqf"; [10, fnc_occupationDeleteMapMarker, [], true] call ExileServer_system_thread_addTask; }; @@ -67,6 +73,7 @@ if(SC_occupyMilitary) then [SC_refreshTime, fnc_occupationMilitary, [], true] call ExileServer_system_thread_addTask; }; + uiSleep 15; // delay the start fnc_occupationMonitor = compile preprocessFileLineNumbers "\x\addons\a3_exile_occupation\scripts\occupationMonitor.sqf"; [SC_refreshTime, fnc_occupationMonitor, [], true] call ExileServer_system_thread_addTask;