add configurable % chance for survivor spawning
This commit is contained in:
second_coming 2016-04-13 13:02:59 +01:00
parent 568e4cbf0a
commit d0f81fc838
5 changed files with 86 additions and 31 deletions

View File

@ -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_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_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) // Occupation Military (roaming AI near military buildings)
SC_occupyMilitary = false; // true if you want military buildings patrolled (specify which types of building below) 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" "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_occupySky = true; // true if you want to have roaming AI helis
SC_occupySea = false; // true if you want to have roaming AI boats SC_occupySea = false; // true if you want to have roaming AI boats

View File

@ -2,7 +2,7 @@
// //
// Server Occupation script by second_coming // 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/ // http://www.exilemod.com/profile/60-second_coming/
// //

View File

@ -6,6 +6,15 @@ _logDetail = format ["[OCCUPATION:Unstick]:: Initialised at %1",time];
[_logDetail] call SC_fnc_log; [_logDetail] call SC_fnc_log;
_x setFuel 1; _x setFuel 1;
sleep 5; 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; }forEach SC_liveHelisArray;
{ {

View File

@ -130,13 +130,13 @@ _locations = (nearestLocations [_spawnCenter, ["NameVillage","NameCity", "NameCi
if(_nearEastAI == 0 AND _nearWestAI == 0) then if(_nearEastAI == 0 AND _nearWestAI == 0) then
{ {
_sideToSpawn = random 100; _sideToSpawn = random 100;
if(_sideToSpawn < 50) then if(_sideToSpawn <= SC_SurvivorsChance) then
{ {
_side = "bandit"; _side = "survivor";
} }
else else
{ {
_side = "survivor"; _side = "bandit";
}; };
}; };
if(_nearEastAI > 0 AND _nearWestAI == 0) then if(_nearEastAI > 0 AND _nearWestAI == 0) then

View File

@ -3,6 +3,19 @@ if (!isServer) exitWith {};
_logDetail = format['[OCCUPATION:Vehicle] Started']; _logDetail = format['[OCCUPATION:Vehicle] Started'];
[_logDetail] call SC_fnc_log; [_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 // more than _scaleAI players on the server and the max AI count drops per additional player
_currentPlayerCount = count playableUnits; _currentPlayerCount = count playableUnits;
@ -59,6 +72,17 @@ _maxDistance = _middle;
if(_vehiclesToSpawn >= 1) then 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; _useLaunchers = DMS_ai_use_launchers;
_locations = (nearestLocations [_spawnCenter, ["NameVillage","NameCity", "NameCityCapital"], _maxDistance]); _locations = (nearestLocations [_spawnCenter, ["NameVillage","NameCity", "NameCityCapital"], _maxDistance]);
_i = 0; _i = 0;
@ -85,14 +109,23 @@ if(_vehiclesToSpawn >= 1) then
_position = position _Location; _position = position _Location;
_pos = [_position,10,250,5,0,20,0] call BIS_fnc_findSafePos; _pos = [_position,10,250,5,0,20,0] call BIS_fnc_findSafePos;
// Get position of nearest roads // Get position of nearest roads
_nearRoads = _pos nearRoads 500; _nearRoads = _pos nearRoads 500;
_nearestRoad = _nearRoads select 0; _nearestRoad = _nearRoads select 0;
_nearestRoad = position (_nearRoads select 0); _nearestRoad = position (_nearRoads select 0);
_spawnLocation = [_nearestRoad select 0, _pos select 1, 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; _VehicleClassToUse = SC_VehicleClassToUse call BIS_fnc_selectRandom;
_vehicle = createVehicle [_VehicleClassToUse, _spawnLocation, [], 0, "NONE"]; _vehicle = createVehicle [_VehicleClassToUse, _spawnLocation, [], 0, "NONE"];
_group addVehicle _vehicle; _group addVehicle _vehicle;
@ -105,6 +138,7 @@ if(_vehiclesToSpawn >= 1) then
_vehicle setVariable ["SC_vehicleSpawnLocation", _spawnLocation,true]; _vehicle setVariable ["SC_vehicleSpawnLocation", _spawnLocation,true];
_vehicle setFuel 1; _vehicle setFuel 1;
_vehicle engineOn true; _vehicle engineOn true;
if(SC_occupyVehiclesLocked) then if(SC_occupyVehiclesLocked) then
{ {
_vehicle lock 2; _vehicle lock 2;
@ -122,7 +156,6 @@ if(_vehiclesToSpawn >= 1) then
_vehicle limitSpeed 60; _vehicle limitSpeed 60;
_vehicle action ["LightOn", _vehicle]; _vehicle action ["LightOn", _vehicle];
// Calculate the crew requried // Calculate the crew requried
_vehicleRoles = (typeOf _vehicle) call bis_fnc_vehicleRoles; _vehicleRoles = (typeOf _vehicle) call bis_fnc_vehicleRoles;
{ {
@ -131,7 +164,12 @@ if(_vehiclesToSpawn >= 1) then
_vehicleSeat = _x select 1; _vehicleSeat = _x select 1;
if(_vehicleRole == "Driver") then 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 "TARGET";
_unit disableAI "AUTOTARGET"; _unit disableAI "AUTOTARGET";
_unit disableAI "AUTOCOMBAT"; _unit disableAI "AUTOCOMBAT";
@ -156,14 +194,24 @@ if(_vehiclesToSpawn >= 1) then
}; };
if(_vehicleRole == "Turret") 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 moveInTurret [_vehicle, _vehicleSeat];
_unit setVariable ["DMS_AssignedVeh",_vehicle]; _unit setVariable ["DMS_AssignedVeh",_vehicle];
_unitPlaced = true; _unitPlaced = true;
}; };
if(_vehicleRole == "CARGO") then 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 assignAsCargo _vehicle;
_unit moveInCargo _vehicle; _unit moveInCargo _vehicle;
_unit setVariable ["DMS_AssignedVeh",_vehicle]; _unit setVariable ["DMS_AssignedVeh",_vehicle];
@ -171,23 +219,18 @@ if(_vehiclesToSpawn >= 1) then
}; };
if(SC_extendedLogging && _unitPlaced) 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; [_logDetail] call SC_fnc_log;
}; };
} forEach _vehicleRoles; } forEach _vehicleRoles;
// Get the AI to shut the fuck up :) // Get the AI to shut the fuck up :)
enableSentences false; enableSentences false;
enableRadio false; enableRadio false;
if(SC_extendedLogging) then _logDetail = format['[OCCUPATION:Vehicle] %3 vehicle %1 spawned @ %2',_VehicleClassToUse,_spawnLocation,_side];
{ [_logDetail] call SC_fnc_log;
_logDetail = format['[OCCUPATION:Vehicle] %1 spawned @ %2',_VehicleClassToUse,_spawnLocation];
[_logDetail] call SC_fnc_log;
};
[_group, _spawnLocation, 2000] call bis_fnc_taskPatrol; [_group, _spawnLocation, 2000] call bis_fnc_taskPatrol;
_group setBehaviour "SAFE"; _group setBehaviour "SAFE";
_group setCombatMode "RED"; _group setCombatMode "RED";
@ -198,10 +241,10 @@ if(_vehiclesToSpawn >= 1) then
clearItemCargoGlobal _vehicle; clearItemCargoGlobal _vehicle;
_vehicle addMagazineCargoGlobal ["HandGrenade", (random 2)]; _vehicle addMagazineCargoGlobal ["HandGrenade", (random 2)];
_vehicle addItemCargoGlobal ["ItemGPS", (random 1)]; _vehicle addItemCargoGlobal ["ItemGPS", (random 1)];
_vehicle addItemCargoGlobal ["Exile_Item_InstaDoc", (random 1)]; _vehicle addItemCargoGlobal ["Exile_Item_InstaDoc", (random 1)];
_vehicle addItemCargoGlobal ["Exile_Item_PlasticBottleFreshWater", 2 + (random 2)]; _vehicle addItemCargoGlobal ["Exile_Item_PlasticBottleFreshWater", 2 + (random 2)];
_vehicle addItemCargoGlobal ["Exile_Item_EMRE", 2 + (random 2)]; _vehicle addItemCargoGlobal ["Exile_Item_EMRE", 2 + (random 2)];
// Add weapons with ammo to the vehicle // Add weapons with ammo to the vehicle
_possibleWeapons = _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;
_logDetail = format['[OCCUPATION:Vehicle] End check %1 currently active (max %2) @ %3',SC_liveVehicles,SC_maxNumberofVehicles,time];
[_logDetail] call SC_fnc_log;
};