From d0f81fc8385867fc9ba8e993750ea13bcd17b434 Mon Sep 17 00:00:00 2001 From: second_coming Date: Wed, 13 Apr 2016 13:02:59 +0100 Subject: [PATCH] edits add configurable % chance for survivor spawning --- config.sqf | 12 +++-- initServer.sqf | 2 +- scripts/occupationMonitor.sqf | 9 ++++ scripts/occupationPlaces.sqf | 6 +-- scripts/occupationVehicle.sqf | 88 +++++++++++++++++++++++++---------- 5 files changed, 86 insertions(+), 31 deletions(-) diff --git a/config.sqf b/config.sqf index 17aab91..97ad377 100644 --- a/config.sqf +++ b/config.sqf @@ -29,6 +29,13 @@ SC_useWaypoints = true; // When spawning AI create waypoints to make t SC_occupyPlaces = true; // true if you want villages,towns,cities patrolled by bandits SC_occupyPlacesSurvivors = true; // true if you want a chance to spawn survivor AI as well as bandits (SC_occupyPlaces must be true to use this option) +SC_occupyVehicle = true; // true if you want to have roaming AI vehicles +SC_occupyVehiclesLocked = true; // true if AI vehicles to stay locked until all the linked AI are dead +SC_occupyVehicleSurvivors = true; // true if you want a chance to spawn survivor AI as well as bandits (SC_occupyVehicle must be true to use this option) + +SC_SurvivorsChance = 33; // chance in % to spawn survivors instead of bandits (for places and land vehicles) + + // Occupation Military (roaming AI near military buildings) SC_occupyMilitary = false; // true if you want military buildings patrolled (specify which types of building below) @@ -41,10 +48,9 @@ SC_buildings = [ "Land_Cargo_Patrol_V1_F","Land_i_Barracks_V1_F", "Land_Army_hut_int","Land_Army_hut2_int" ]; -SC_occupyStatic = false; // true if you want to garrison AI in specific locations (not working yet) +SC_occupyStatic = false; // true if you want to garrison AI in specific locations + -SC_occupyVehicle = true; // true if you want to have roaming AI vehicles -SC_occupyVehiclesLocked = true; // true if AI vehicles to stay locked until all the linked AI are dead SC_occupySky = true; // true if you want to have roaming AI helis SC_occupySea = false; // true if you want to have roaming AI boats diff --git a/initServer.sqf b/initServer.sqf index 27cdf9e..9088098 100644 --- a/initServer.sqf +++ b/initServer.sqf @@ -2,7 +2,7 @@ // // Server Occupation script by second_coming // -SC_occupationVersion = "v11 (12-04-2016)"; +SC_occupationVersion = "v12 (13-04-2016)"; // // http://www.exilemod.com/profile/60-second_coming/ // diff --git a/scripts/occupationMonitor.sqf b/scripts/occupationMonitor.sqf index 189d532..6032662 100644 --- a/scripts/occupationMonitor.sqf +++ b/scripts/occupationMonitor.sqf @@ -6,6 +6,15 @@ _logDetail = format ["[OCCUPATION:Unstick]:: Initialised at %1",time]; [_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 + { + _GroupLeader = leader (group _x); + _GroupLeader doMove _originalSpawnLocation; + }; }forEach SC_liveHelisArray; { diff --git a/scripts/occupationPlaces.sqf b/scripts/occupationPlaces.sqf index ef7c024..399a546 100644 --- a/scripts/occupationPlaces.sqf +++ b/scripts/occupationPlaces.sqf @@ -130,13 +130,13 @@ _locations = (nearestLocations [_spawnCenter, ["NameVillage","NameCity", "NameCi if(_nearEastAI == 0 AND _nearWestAI == 0) then { _sideToSpawn = random 100; - if(_sideToSpawn < 50) then + if(_sideToSpawn <= SC_SurvivorsChance) then { - _side = "bandit"; + _side = "survivor"; } else { - _side = "survivor"; + _side = "bandit"; }; }; if(_nearEastAI > 0 AND _nearWestAI == 0) then diff --git a/scripts/occupationVehicle.sqf b/scripts/occupationVehicle.sqf index 49014bf..3272d03 100644 --- a/scripts/occupationVehicle.sqf +++ b/scripts/occupationVehicle.sqf @@ -3,6 +3,19 @@ if (!isServer) exitWith {}; _logDetail = format['[OCCUPATION:Vehicle] Started']; [_logDetail] call SC_fnc_log; +// set the default side to "bandit" +_side = "bandit"; + +if(SC_occupyVehicleSurvivors) then +{ + // Make survivors friendly to players and enemies to bandit AI + RESISTANCE setFriend[WEST,1]; + WEST setFriend[RESISTANCE,1]; + WEST setFriend[EAST,0]; + EAST setFriend[WEST,0]; + + if(!isNil "DMS_Enable_RankChange") then { DMS_Enable_RankChange = true; }; +}; // more than _scaleAI players on the server and the max AI count drops per additional player _currentPlayerCount = count playableUnits; @@ -59,6 +72,17 @@ _maxDistance = _middle; if(_vehiclesToSpawn >= 1) then { + // decide which side to spawn + _sideToSpawn = random 100; + if(_sideToSpawn <= SC_SurvivorsChance) then + { + _side = "survivor"; + } + else + { + _side = "bandit"; + }; + _useLaunchers = DMS_ai_use_launchers; _locations = (nearestLocations [_spawnCenter, ["NameVillage","NameCity", "NameCityCapital"], _maxDistance]); _i = 0; @@ -85,14 +109,23 @@ if(_vehiclesToSpawn >= 1) then _position = position _Location; _pos = [_position,10,250,5,0,20,0] call BIS_fnc_findSafePos; - // Get position of nearest roads _nearRoads = _pos nearRoads 500; _nearestRoad = _nearRoads select 0; _nearestRoad = position (_nearRoads select 0); _spawnLocation = [_nearestRoad select 0, _pos select 1, 0]; - _group = createGroup east; + _group = createGroup EAST; + if(_side == "survivor") then + { + deleteGroup _group; + _group = createGroup WEST; + }; + + _group setVariable ["DMS_LockLocality",nil]; + _group setVariable ["DMS_SpawnedGroup",true]; + _group setVariable ["DMS_Group_Side", _side]; + _VehicleClassToUse = SC_VehicleClassToUse call BIS_fnc_selectRandom; _vehicle = createVehicle [_VehicleClassToUse, _spawnLocation, [], 0, "NONE"]; _group addVehicle _vehicle; @@ -105,6 +138,7 @@ if(_vehiclesToSpawn >= 1) then _vehicle setVariable ["SC_vehicleSpawnLocation", _spawnLocation,true]; _vehicle setFuel 1; _vehicle engineOn true; + if(SC_occupyVehiclesLocked) then { _vehicle lock 2; @@ -122,7 +156,6 @@ if(_vehiclesToSpawn >= 1) then _vehicle limitSpeed 60; _vehicle action ["LightOn", _vehicle]; - // Calculate the crew requried _vehicleRoles = (typeOf _vehicle) call bis_fnc_vehicleRoles; { @@ -131,7 +164,12 @@ if(_vehiclesToSpawn >= 1) then _vehicleSeat = _x select 1; if(_vehicleRole == "Driver") then { - _unit = [_group,_spawnLocation,"assault","random","bandit","Vehicle"] call DMS_fnc_SpawnAISoldier; + _unit = [_group,_spawnLocation,"assault","random",_side,"Vehicle"] call DMS_fnc_SpawnAISoldier; + if(_side == "survivor") then + { + removeUniform _unit; + _unit forceAddUniform "Exile_Uniform_BambiOverall"; + }; _unit disableAI "TARGET"; _unit disableAI "AUTOTARGET"; _unit disableAI "AUTOCOMBAT"; @@ -156,14 +194,24 @@ if(_vehiclesToSpawn >= 1) then }; if(_vehicleRole == "Turret") then { - _unit = [_group,_spawnLocation,"assault","random","bandit","Vehicle"] call DMS_fnc_SpawnAISoldier; + _unit = [_group,_spawnLocation,"assault","random",_side,"Vehicle"] call DMS_fnc_SpawnAISoldier; + if(_side == "survivor") then + { + removeUniform _unit; + _unit forceAddUniform "Exile_Uniform_BambiOverall"; + }; _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",_side,"Vehicle"] call DMS_fnc_SpawnAISoldier; + if(_side == "survivor") then + { + removeUniform _unit; + _unit forceAddUniform "Exile_Uniform_BambiOverall"; + }; _unit assignAsCargo _vehicle; _unit moveInCargo _vehicle; _unit setVariable ["DMS_AssignedVeh",_vehicle]; @@ -171,23 +219,18 @@ if(_vehiclesToSpawn >= 1) then }; if(SC_extendedLogging && _unitPlaced) then { - _logDetail = format['[OCCUPATION:Vehicle] %1 added to vehicle %2',_vehicleRole,_vehicle]; + _logDetail = format['[OCCUPATION:Vehicle] %1 %2 added to vehicle %3',_side,_vehicleRole,_vehicle]; [_logDetail] call SC_fnc_log; }; - } forEach _vehicleRoles; - + } forEach _vehicleRoles; // Get the AI to shut the fuck up :) enableSentences false; enableRadio false; - if(SC_extendedLogging) then - { - _logDetail = format['[OCCUPATION:Vehicle] %1 spawned @ %2',_VehicleClassToUse,_spawnLocation]; - [_logDetail] call SC_fnc_log; - }; + _logDetail = format['[OCCUPATION:Vehicle] %3 vehicle %1 spawned @ %2',_VehicleClassToUse,_spawnLocation,_side]; + [_logDetail] call SC_fnc_log; - [_group, _spawnLocation, 2000] call bis_fnc_taskPatrol; _group setBehaviour "SAFE"; _group setCombatMode "RED"; @@ -198,10 +241,10 @@ if(_vehiclesToSpawn >= 1) then clearItemCargoGlobal _vehicle; _vehicle addMagazineCargoGlobal ["HandGrenade", (random 2)]; - _vehicle addItemCargoGlobal ["ItemGPS", (random 1)]; - _vehicle addItemCargoGlobal ["Exile_Item_InstaDoc", (random 1)]; - _vehicle addItemCargoGlobal ["Exile_Item_PlasticBottleFreshWater", 2 + (random 2)]; - _vehicle addItemCargoGlobal ["Exile_Item_EMRE", 2 + (random 2)]; + _vehicle addItemCargoGlobal ["ItemGPS", (random 1)]; + _vehicle addItemCargoGlobal ["Exile_Item_InstaDoc", (random 1)]; + _vehicle addItemCargoGlobal ["Exile_Item_PlasticBottleFreshWater", 2 + (random 2)]; + _vehicle addItemCargoGlobal ["Exile_Item_EMRE", 2 + (random 2)]; // Add weapons with ammo to the vehicle _possibleWeapons = @@ -226,8 +269,5 @@ if(_vehiclesToSpawn >= 1) then }; }; -if(SC_extendedLogging) then -{ - _logDetail = format['[OCCUPATION:Vehicle] End check %1 currently active (max %2) @ %3',SC_liveVehicles,SC_maxNumberofVehicles,time]; - [_logDetail] call SC_fnc_log; -}; \ No newline at end of file +_logDetail = format['[OCCUPATION:Vehicle] End check %1 currently active (max %2) @ %3',SC_liveVehicles,SC_maxNumberofVehicles,time]; +[_logDetail] call SC_fnc_log; \ No newline at end of file