Update spawnCrashSite

This commit is contained in:
ebaydayz
2016-03-26 22:02:28 -04:00
parent cfff2454aa
commit 8f2ff5cb3e
8 changed files with 33 additions and 230 deletions

View File

@@ -594,7 +594,6 @@ if (isServer) then {
if(isNil "DynamicVehicleFuelLow") then {DynamicVehicleFuelLow = 0;}; if(isNil "DynamicVehicleFuelLow") then {DynamicVehicleFuelLow = 0;};
if(isNil "DynamicVehicleFuelHigh") then {DynamicVehicleFuelHigh = 100;}; if(isNil "DynamicVehicleFuelHigh") then {DynamicVehicleFuelHigh = 100;};
if(isNil "HeliCrashArea") then {HeliCrashArea = dayz_MapArea / 2;}; if(isNil "HeliCrashArea") then {HeliCrashArea = dayz_MapArea / 2;};
if(isNil "OldHeliCrash") then {OldHeliCrash = false;};
if(isNil "DZE_DiagFpsSlow") then {DZE_DiagFpsSlow = false;}; // Log server FPS + player count every 5 minutes if(isNil "DZE_DiagFpsSlow") then {DZE_DiagFpsSlow = false;}; // Log server FPS + player count every 5 minutes
if(isNil "DZE_DiagFpsFast") then {DZE_DiagFpsFast = false;}; // Log server FPS + player count every 2 minutes if(isNil "DZE_DiagFpsFast") then {DZE_DiagFpsFast = false;}; // Log server FPS + player count every 2 minutes
if(isNil "DZE_DiagVerbose") then {DZE_DiagVerbose = false;}; // Also log allMissionObjects count (very intensive) if(isNil "DZE_DiagVerbose") then {DZE_DiagVerbose = false;}; // Also log allMissionObjects count (very intensive)

View File

@@ -54,7 +54,7 @@ dz_loot_groups = [];
dz_loot_weighted = []; dz_loot_weighted = [];
dz_loot_definitions = []; dz_loot_definitions = [];
_cfgGroups = (configFile >> "CfgLoot" >> "Groups"); _cfgGroups = if (DZE_MissionLootTable) then {missionConfigFile >> "CfgLoot" >> "Groups"} else {configFile >> "CfgLoot" >> "Groups"};
for "_i" from 0 to (count _cfgGroups) - 1 do for "_i" from 0 to (count _cfgGroups) - 1 do
{ {

View File

@@ -57,7 +57,7 @@ sched_buriedZeds = {
//_a = _a + 1; //_a = _a + 1;
_b = nearestBuilding _z; _b = nearestBuilding _z;
if (!isNull _b) then { if (!isNull _b) then {
_config = configFile >> "CfgLoot" >> "Buildings" >> (typeOf _b) >> "zedPos"; _config = if (DZE_MissionLootTable) then {missionConfigFile >> "CfgLoot" >> "Buildings" >> (typeOf _b) >> "zedPos"} else {configFile >> "CfgLoot" >> "Buildings" >> (typeOf _b) >> "zedPos"};
_zedPos = [] + getArray _config; _zedPos = [] + getArray _config;
if ((count _zedPos > 0) and {([_b, _pos] call _checkInsideBuilding)}) then { if ((count _zedPos > 0) and {([_b, _pos] call _checkInsideBuilding)}) then {
_elevation = (_b modelToWorld (_zedPos select 0)) select 2; // ATL _elevation = (_b modelToWorld (_zedPos select 0)) select 2; // ATL

View File

@@ -15,32 +15,18 @@ Author:
//Number of care packages to spawn //Number of care packages to spawn
#define SPAWN_NUM 6 #define SPAWN_NUM 6
#define SEARCH_CENTER [7542,7134] #define SEARCH_CENTER dayz_centerMarker
#define SEARCH_RADIUS 6150 #define SEARCH_RADIUS HeliCrashArea
#define SEARCH_DIST_MIN 30 #define SEARCH_DIST_MIN 30
#define SEARCH_SLOPE_MAX 1000 #define SEARCH_SLOPE_MAX 1000
#define SEARCH_BLACKLIST [[[12923,3643],[14275,2601]]] #define SEARCH_BLACKLIST [[[12923,3643],[14275,2601]]]
private private ["_typeGroup","_position","_type","_class","_vehicle","_loot","_lootGroup","_lootNum","_lootPos","_lootVeh","_size"];
[
"_typeGroup",
"_position",
"_type",
"_class",
"_vehicle",
"_loot",
"_lootGroup",
"_lootNum",
"_lootPos",
"_lootVeh",
"_size"
];
_lootGroup = Loot_GetGroup("CarePackage"); _lootGroup = Loot_GetGroup("CarePackage");
_typeGroup = Loot_GetGroup("CarePackageType"); _typeGroup = Loot_GetGroup("CarePackageType");
for "_i" from 1 to (SPAWN_NUM) do for "_i" from 1 to (SPAWN_NUM) do {
{
_type = Loot_SelectSingle(_typeGroup); _type = Loot_SelectSingle(_typeGroup);
_class = _type select 1; _class = _type select 1;
_lootNum = round Math_RandomRange(_type select 2, _type select 3); _lootNum = round Math_RandomRange(_type select 2, _type select 3);
@@ -63,23 +49,17 @@ for "_i" from 1 to (SPAWN_NUM) do
_lootVeh = Loot_Spawn(_x, _lootPos); _lootVeh = Loot_Spawn(_x, _lootPos);
_lootVeh setVariable ["permaLoot", true]; _lootVeh setVariable ["permaLoot", true];
switch (dayz_spawncarepkgs_clutterCutter) do switch (dayz_spawncarepkgs_clutterCutter) do {
{ case 1: { //Lift loot up by 5cm
case 1: //Lift loot up by 5cm
{
_lootPos set [2, 0.05]; _lootPos set [2, 0.05];
_lootVeh setPosATL _lootpos; _lootVeh setPosATL _lootpos;
}; };
case 2: { //Clutter cutter
case 2: //Clutter cutter
{
createVehicle ["ClutterCutter_small_2_EP1", _lootPos, [], 0, "CAN_COLLIDE"]; createVehicle ["ClutterCutter_small_2_EP1", _lootPos, [], 0, "CAN_COLLIDE"];
}; };
case 3: { //Debug sphere
case 3: //Debug sphere
{
createVehicle ["Sign_sphere100cm_EP1", _lootPos, [], 0, "CAN_COLLIDE"]; createVehicle ["Sign_sphere100cm_EP1", _lootPos, [], 0, "CAN_COLLIDE"];
}; };
}; };
} foreach Loot_Select(_lootGroup, _lootNum); } forEach Loot_Select(_lootGroup, _lootNum);
}; };

View File

@@ -1,124 +0,0 @@
private ["_position","_num","_config","_itemType","_weights","_index","_crashModel","_lootTable","_guaranteedLoot","_randomizedLoot","_frequency","_variance","_spawnChance","_spawnMarker","_spawnRadius","_spawnFire","_crashName","_nearby","_itemTypes","_cntWeights","_fadeFire"];
//_crashModel = _this select 0;
//_lootTable = _this select 1;
_guaranteedLoot = _this select 0;
_randomizedLoot = _this select 1;
_frequency = _this select 2;
_variance = _this select 3;
_spawnChance = _this select 4;
_spawnMarker = _this select 5;
_spawnRadius = _this select 6;
_spawnFire = _this select 7;
_fadeFire = _this select 8;
diag_log("CRASHSPAWNER: Starting spawn logic for Crash Spawner");
while {1 == 1} do {
private["_timeAdjust","_timeToSpawn","_spawnRoll","_crash","_hasAdjustment","_newHeight","_adjustedPos"];
// Allows the variance to act as +/- from the spawn frequency timer
_timeAdjust = round((random(_variance * 2)) - _variance);
_timeToSpawn = time + _frequency + _timeAdjust;
//Adding some Random systems
_crashModel = ["UH60Wreck_DZ","UH1Wreck_DZ","UH60_NAVY_Wreck_DZ","UH60_ARMY_Wreck_DZ","UH60_NAVY_Wreck_burned_DZ","UH60_ARMY_Wreck_burned_DZ","Mass_grave_DZ"] call BIS_fnc_selectRandom;
if(_crashModel == "Mass_grave_DZ") then {
_lootTable = "MassGrave";
} else {
//Crash loot just uncomment the one you wish to use by default with 50cals is enabled.
//Table including 50 cals
_lootTable = ["Military","HeliCrash","MilitarySpecial"] call BIS_fnc_selectRandom;
//Table without 50 cals
//_lootTable = ["Military","HeliCrash_No50s","MilitarySpecial"] call BIS_fnc_selectRandom;
};
_crashName = getText (configFile >> "CfgVehicles" >> _crashModel >> "displayName");
diag_log(format["CRASHSPAWNER: %1%2 chance to spawn '%3' with loot table '%4' in %5 seconds", round(_spawnChance * 100), '%', _crashName, _lootTable, _timeToSpawn]);
// Apprehensive about using one giant long sleep here given server time variances over the life of the server daemon
waituntil {time > _timeToSpawn};
_spawnRoll = random 1;
// Percentage roll
if (_spawnRoll <= _spawnChance) then {
_position = [getMarkerPos _spawnMarker,0,_spawnRadius,10,0,2000,0] call BIS_fnc_findSafePos;
diag_log(format["CRASHSPAWNER: Spawning '%1' with loot table '%2' NOW! (%3) at: %4", _crashName, _lootTable, time, str(_position)]);
_crash = createVehicle [_crashModel,_position, [], 0, "CAN_COLLIDE"];
// Randomize the direction the wreck is facing
_crash setDir round(random 360);
// Using "custom" wrecks (using the destruction model of a vehicle vs. a prepared wreck model) will result
// in the model spawning halfway in the ground. To combat this, an OPTIONAL configuration can be tied to
// the CfgVehicles class you've created for the custom wreck to define how high above the ground it should
// spawn. This is optional.
_config = configFile >> "CfgVehicles" >> _crashModel >> "heightAdjustment";
_hasAdjustment = isNumber(_config);
_newHeight = 0;
if (_hasAdjustment) then {
_newHeight = getNumber(_config);
//diag_log(format["DIAG: ADJUSTMENT FOUND FOR %1, IT IS: %2", _crashName, _newHeight]);
};
// Must setPos after a setDir otherwise the wreck won't level itself with the terrain
_adjustedPos = [(_position select 0), (_position select 1), _newHeight];
//diag_log(format["DIAG: Designated Position: %1", str(_adjustedPos)]);
_crash setPos _adjustedPos;
// I don't think this is needed (you can't get "in" a crash), but it was in the original DayZ Crash logic
dayz_serverObjectMonitor set [count dayz_serverObjectMonitor,_crash];
_crash setVariable ["ObjectID","1",true];
// Disable simulation server side
_crash enableSimulation false;
_num = (round(random _randomizedLoot)) + _guaranteedLoot;
if(_crashModel == "Mass_grave_DZ") then {
_spawnFire = false;
_num = _num * 2;
};
if (_spawnFire) then {
//["PVDZ_obj_Fire",[_crash,2,time,false,_fadeFire]] call broadcastRpcCallAll;
PVDZ_obj_Fire = [_crash,2,time,false,_fadeFire];
publicVariable "PVDZ_obj_Fire";
_crash setvariable ["fadeFire",_fadeFire,true];
};
_config = configFile >> "CfgBuildingLoot" >> _lootTable;
if (DZE_MissionLootTable) then {
_config = missionConfigFile >> "CfgBuildingLoot" >> _lootTable;
};
_itemTypes = [] + getArray (_config >> "itemType");
_index = dayz_CBLBase find toLower(_lootTable);
_weights = dayz_CBLChances select _index;
_cntWeights = count _weights;
for "_x" from 1 to _num do {
//create loot
_index = floor(random _cntWeights);
_index = _weights select _index;
_itemType = _itemTypes select _index;
[_itemType select 0, _itemType select 1, _position, 5] call spawn_loot;
diag_log(format["CRASHSPAWNER: Loot spawn at '%1' with loot table '%2'", _crashName, _lootTable]);
// ReammoBox is preferred parent class here, as WeaponHolder wouldn't match MedBox0 && other such items.
_nearby = _position nearObjects ["ReammoBox", sizeOf(_crashModel)];
{
_x setVariable ["permaLoot",true];
} count _nearBy;
};
};
};

View File

@@ -21,8 +21,8 @@ Author:
#define SPAWN_CHANCE 0.75 #define SPAWN_CHANCE 0.75
//Parameters for finding a suitable position to spawn the crash site //Parameters for finding a suitable position to spawn the crash site
#define SEARCH_CENTER [7049,9241] #define SEARCH_CENTER dayz_centerMarker
#define SEARCH_RADIUS 4880 #define SEARCH_RADIUS HeliCrashArea
#define SEARCH_DIST_MIN 20 #define SEARCH_DIST_MIN 20
#define SEARCH_SLOPE_MAX 2 #define SEARCH_SLOPE_MAX 2
#define SEARCH_BLACKLIST [[[2092,14167],[10558,12505]]] #define SEARCH_BLACKLIST [[[2092,14167],[10558,12505]]]
@@ -34,31 +34,11 @@ Author:
#define LOOT_MIN 5 #define LOOT_MIN 5
#define LOOT_MAX 8 #define LOOT_MAX 8
private private ["_debugZone","_spawnCrashSite","_type","_class","_lootGroup","_position","_vehicle","_lootParams","_dir","_mag","_lootNum","_lootPos","_lootVeh","_lootpos","_time"];
[
"_debugZone",
"_spawnCrashSite",
"_type",
"_class",
"_lootGroup",
"_position",
"_vehicle",
// "_size",
// "_loot",
"_lootParams",
"_dir",
"_mag",
"_lootNum",
"_lootPos",
"_lootVeh",
"_lootpos",
"_time"
];
diag_log format ["CRASHSPAWNER: Starting crash site spawner. Frequency: %1±%2 min. Spawn chance: %3", SPAWN_FREQUENCY, SPAWN_VARIANCE, SPAWN_CHANCE]; diag_log format ["CRASHSPAWNER: Starting crash site spawner. Frequency: %1±%2 min. Spawn chance: %3", SPAWN_FREQUENCY, SPAWN_VARIANCE, SPAWN_CHANCE];
_spawnCrashSite = _spawnCrashSite = {
{
_type = Loot_SelectSingle(Loot_GetGroup("CrashSiteType")); _type = Loot_SelectSingle(Loot_GetGroup("CrashSiteType"));
_class = _type select 1; _class = _type select 1;
_lootGroup = Loot_GetGroup(_type select 2); _lootGroup = Loot_GetGroup(_type select 2);
@@ -91,49 +71,36 @@ _spawnCrashSite =
_lootVeh = Loot_Spawn(_x, _lootPos); _lootVeh = Loot_Spawn(_x, _lootPos);
_lootVeh setVariable ["permaLoot", true]; _lootVeh setVariable ["permaLoot", true];
switch (dayz_spawnCrashSite_clutterCutter) do switch (dayz_spawnCrashSite_clutterCutter) do {
{ case 1: { //Lift loot up by 5cm
case 1: //Lift loot up by 5cm
{
_lootPos set [2, 0.05]; _lootPos set [2, 0.05];
_lootVeh setPosATL _lootpos; _lootVeh setPosATL _lootpos;
}; };
case 2: { //Clutter cutter
case 2: //Clutter cutter
{
createVehicle ["ClutterCutter_small_2_EP1", _lootPos, [], 0, "CAN_COLLIDE"]; createVehicle ["ClutterCutter_small_2_EP1", _lootPos, [], 0, "CAN_COLLIDE"];
}; };
case 3: { //Debug sphere
case 3: //Debug sphere
{
createVehicle ["Sign_sphere100cm_EP1", _lootPos, [], 0, "CAN_COLLIDE"]; createVehicle ["Sign_sphere100cm_EP1", _lootPos, [], 0, "CAN_COLLIDE"];
}; };
}; };
} } forEach Loot_Select(_lootGroup, _lootNum);
foreach Loot_Select(_lootGroup, _lootNum);
}; };
//Spawn initial crash sites //Spawn initial crash sites
for "_i" from 1 to (INITIAL_NUM) do for "_i" from 1 to (INITIAL_NUM) do {
{
call _spawnCrashSite; call _spawnCrashSite;
}; };
while {true} do while {true} do {
{
//Pick a time to attempt spawning //Pick a time to attempt spawning
//currentTime + frequency + ±1 * variance //currentTime + frequency + ±1 * variance
_time = time + 60 * ((SPAWN_FREQUENCY) + ((round random 1) * 2 - 1) * random (SPAWN_VARIANCE)); _time = time + 60 * ((SPAWN_FREQUENCY) + ((round random 1) * 2 - 1) * random (SPAWN_VARIANCE));
//Wait until the previously decided time //Wait until the previously decided time
while {time < _time} do while {time < _time} do {
{ uiSleep (60 * (SPAWN_FREQUENCY) / (TIMER_RESOLUTION));
sleep (60 * (SPAWN_FREQUENCY) / (TIMER_RESOLUTION));
}; };
//try to spawn //try to spawn
if ((SPAWN_CHANCE) > random 1) then if ((SPAWN_CHANCE) > random 1) then {call _spawnCrashSite;};
{
call _spawnCrashSite;
};
}; };

View File

@@ -35,32 +35,19 @@ Author:
#define SEARCH_PRECISION 30 #define SEARCH_PRECISION 30
#define SEARCH_ATTEMPTS 10 #define SEARCH_ATTEMPTS 10
private private ["_typeGroup","_lootGroup","_objectGroup","_type","_position","_composition","_compositionObjects","_objectPos"];
[
"_typeGroup",
"_lootGroup",
"_objectGroup",
"_type",
"_position",
"_composition",
"_compositionObjects",
"_objectPos"
];
_typeGroup = Loot_GetGroup("InfectedCampType"); _typeGroup = Loot_GetGroup("InfectedCampType");
_lootGroup = Loot_GetGroup("InfectedCamp"); _lootGroup = Loot_GetGroup("InfectedCamp");
_objectGroup = Loot_GetGroup("InfectedCampObject"); _objectGroup = Loot_GetGroup("InfectedCampObject");
for "_i" from 1 to (CAMP_NUM) do for "_i" from 1 to (CAMP_NUM) do {
{
//Select type of camp //Select type of camp
_type = Loot_SelectSingle(_typeGroup); _type = Loot_SelectSingle(_typeGroup);
_composition = _type select 1; _composition = _type select 1;
//Find a position //Find a position
for "_j" from 1 to (SEARCH_ATTEMPTS) do {
for "_j" from 1 to (SEARCH_ATTEMPTS) do
{
_position = ((selectBestPlaces [SEARCH_CENTER, SEARCH_RADIUS, SEARCH_EXPRESSION, SEARCH_PRECISION, 1]) select 0) select 0; _position = ((selectBestPlaces [SEARCH_CENTER, SEARCH_RADIUS, SEARCH_EXPRESSION, SEARCH_PRECISION, 1]) select 0) select 0;
_position set [2, 0]; _position set [2, 0];
@@ -75,11 +62,10 @@ for "_i" from 1 to (CAMP_NUM) do
//Add loot to containers //Add loot to containers
{ {
if (_x isKindOf (CAMP_CONTAINER_BASE)) then if (_x isKindOf (CAMP_CONTAINER_BASE)) then {
{
Loot_InsertCargo(_x, _lootGroup, round Math_RandomRange(LOOT_MIN, LOOT_MAX)); Loot_InsertCargo(_x, _lootGroup, round Math_RandomRange(LOOT_MIN, LOOT_MAX));
}; };
} foreach _compositionObjects; } forEach _compositionObjects;
//Spawn objects around the camp //Spawn objects around the camp
{ {
@@ -87,5 +73,5 @@ for "_i" from 1 to (CAMP_NUM) do
Loot_Spawn(_x, _objectPos); Loot_Spawn(_x, _objectPos);
} foreach Loot_Select(_objectGroup, round Math_RandomRange(OBJECT_MIN, OBJECT_MAX)); } forEach Loot_Select(_objectGroup, round Math_RandomRange(OBJECT_MIN, OBJECT_MAX));
}; };

View File

@@ -361,11 +361,6 @@ for "_x" from 1 to MaxMineVeins do {[] spawn spawn_mineveins;};
// All done spawning stuff, can clear these now // All done spawning stuff, can clear these now
buildingList = []; roadList = []; buildingList = []; roadList = [];
// [_guaranteedLoot,_randomizedLoot,_frequency,_variance,_spawnChance,_spawnMarker,_spawnRadius,_spawnFire,_fadeFire]
if (OldHeliCrash) then {
_nul = [3,4,(50 * 60),(15 * 60),0.75,'center',HeliCrashArea,true,false] spawn server_spawnCrashSite;
};
[] spawn server_spawnEvents; [] spawn server_spawnEvents;
_debugMarkerPosition = getMarkerPos "respawn_west"; _debugMarkerPosition = getMarkerPos "respawn_west";
_debugMarkerPosition = [(_debugMarkerPosition select 0),(_debugMarkerPosition select 1),1]; _debugMarkerPosition = [(_debugMarkerPosition select 0),(_debugMarkerPosition select 1),1];