This commit is contained in:
Aaron Clark
2012-11-04 20:28:50 -06:00
commit 76e9a0582e
1049 changed files with 94406 additions and 0 deletions

1
dayz_server/$PBOPREFIX$ Normal file
View File

@@ -0,0 +1 @@
z\addons\dayz_server

View File

@@ -0,0 +1,23 @@
private["_qty","_item","_meat"];
_item = _this select 0;
_qty = _this select 1;
_meat = 0;
_loop = true;
if (local _item) then {
for "_x" from 1 to _qty do {
_item addMagazine "FoodSteakRaw";
};
sleep 2;
_timer = time;
while {_loop} do {
_meat = count magazines _item;
if (_meat == 0) then {_loop = false};
if ((time - _timer) > 300) then {_loop = false};
sleep 1;
};
dayzHideBody = _item;
publicVariable "dayzHideBody";
hideBody _item;
sleep 10;
deleteVehicle _item;
};

View File

@@ -0,0 +1,28 @@
/*
*/
private["_hasDel","_serial","_object","_objects","_updates","_myGroup","_nearVeh"];
_playerID = _this select 0;
_playerName = _this select 1;
_object = call compile format["player%1",_playerID];
_characterID = _object getVariable ["characterID","0"];
if (vehicle _object != _object) then {
_object action ["eject", vehicle _object];
};
diag_log format["DISCONNECT: %1 (%2) Object: %3, _characterID: %4", _playerName,_playerID,_object,_characterID];
dayz_disco = dayz_disco - [_playerID];
if (!isNull _object) then {
//Update Vehicle
{ [_x,"gear"] call server_updateObject } foreach
(nearestObjects [getPosATL _object, ["Car", "Helicopter", "Motorcycle", "Ship", "TentStorage"], 10]);
if (alive _object) then {
[_object,[],true] call server_playerSync;
_id = [_playerID,_characterID,2] spawn dayz_recordLogin;
_myGroup = group _object;
deleteVehicle _object;
deleteGroup _myGroup;
};
};

View File

@@ -0,0 +1,46 @@
private["_characterID","_minutes","_newObject","_playerID","_playerName","_playerID","_myGroup","_group"];
//[unit, weapon, muzzle, mode, ammo, magazine, projectile]
_characterID = _this select 0;
_minutes = _this select 1;
_newObject = _this select 2;
_playerID = _this select 3;
_playerName = _this select 4;
dayz_disco = dayz_disco - [_playerID];
_newObject setVariable["processedDeath",time];
/*
diag_log ("DW_DEBUG: (isnil _characterID): " + str(isnil "_characterID"));
if (isnil "_characterID") then {
diag_log ("DW_DEBUG: _newObject: " + str(_newObject));
};
*/
if !(isnil "_characterID") then {
if (_characterID != "0") then {
_key = format["CHILD:202:%1:%2:",_characterID,_minutes];
//diag_log ("HIVE: WRITE: "+ str(_key));
_key call server_hiveWrite;
} else {
deleteVehicle _newObject;
};
} else {
deleteVehicle _newObject;
};
diag_log ("PDEATH: Player Died " + _playerID);
/*
_eh = [_newObject] spawn {
_body = _this select 0;
_method = _body getVariable["deathType","unknown"];
_name = _body getVariable["bodyName","unknown"];
waitUntil{!isPlayer _body;sleep 1};
_body setVariable["deathType",_method,true];
_body setVariable["bodyName",_name,true];
diag_log ("PDEATH: Player Left Body " + _name);
};
*/
//dead_bodyCleanup set [count dead_bodyCleanup,_newObject];

View File

@@ -0,0 +1,120 @@
private["_int","_newModel","_doLoop","_wait","_hiveVer","_isHiveOk","_playerID","_playerObj","_randomSpot","_publishTo","_primary","_secondary","_key","_result","_charID","_playerObj","_playerName","_finished","_spawnPos","_spawnDir","_items","_counter","_magazines","_weapons","_group","_backpack","_worldspace","_direction","_newUnit","_score","_position","_isNew","_inventory","_backpack","_medical","_survival","_stats","_state"];
//Set Variables
diag_log ("STARTING LOGIN: " + str(_this));
_playerID = _this select 0;
_playerObj = _this select 1;
_playerName = name _playerObj;
_worldspace = [];
if (count _this > 2) then {
dayz_players = dayz_players - [_this select 2];
};
waitUntil{allowConnection};
//Variables
_inventory = [];
_backpack = [];
_items = [];
_magazines = [];
_weapons = [];
_medicalStats = [];
_survival = [0,0,0];
_tent = [];
_state = [];
_direction = 0;
_model = "";
_newUnit = objNull;
if (_playerID == "") then {
_playerID = getPlayerUID _playerObj;
};
if ((_playerID == "") or (isNil "_playerID")) exitWith {
diag_log ("LOGIN FAILED: Player [" + _playerName + "] has no login ID");
};
endLoadingScreen;
diag_log ("LOGIN ATTEMPT: " + str(_playerID) + " " + _playerName);
//Do Connection Attempt
_doLoop = 0;
while {_doLoop < 5} do {
_key = format["CHILD:101:%1:%2:%3:",_playerID,dayZ_instance,_playerName];
_primary = [_key,false,dayZ_hivePipeAuth] call server_hiveReadWrite;
if (count _primary > 0) then {
if ((_primary select 0) != "ERROR") then {
_doLoop = 9;
};
};
_doLoop = _doLoop + 1;
};
if (isNull _playerObj or !isPlayer _playerObj) exitWith {
diag_log ("LOGIN RESULT: Exiting, player object null: " + str(_playerObj));
};
//Process request
_newPlayer = _primary select 1;
_isNew = count _primary < 6; //_result select 1;
_charID = _primary select 2;
_randomSpot = false;
//diag_log ("LOGIN RESULT: " + str(_primary));
/* PROCESS */
_hiveVer = 0;
if (!_isNew) then {
//RETURNING CHARACTER
_inventory = _primary select 4;
_backpack = _primary select 5;
_survival = _primary select 6;
_model = _primary select 7;
_hiveVer = _primary select 8;
if (!(_model in ["SurvivorW2_DZ","Survivor2_DZ","Sniper1_DZ","Soldier1_DZ","Rocket_DZ","Camo1_DZ","BanditW1_DZ","Bandit1_DZ","SurvivorW2_DZ"])) then {
_model = "Survivor2_DZ";
};
} else {
_model = _primary select 3;
_hiveVer = _primary select 4;
if (isNil "_model") then {
_model = "Survivor2_DZ";
} else {
if (_model == "") then {
_model = "Survivor2_DZ";
};
};
//Record initial inventory
_config = (configFile >> "CfgSurvival" >> "Inventory" >> "Default");
_mags = getArray (_config >> "magazines");
_wpns = getArray (_config >> "weapons");
_bcpk = getText (_config >> "backpack");
_randomSpot = true;
//Wait for HIVE to be free
_key = format["CHILD:203:%1:%2:%3:",_charID,[_wpns,_mags],[_bcpk,[],[]]];
_key spawn server_hiveWrite;
};
diag_log ("LOGIN LOADED: " + str(_playerObj) + " Type: " + (typeOf _playerObj));
_isHiveOk = false; //EDITED
if (_hiveVer >= dayz_hiveVersionNo) then {
_isHiveOk = true;
};
//diag_log ("SERVER RESULT: " + str("X") + " " + str(dayz_hiveVersionNo));
//Server publishes variable to clients and WAITS
//_playerObj setVariable ["publish",[_charID,_inventory,_backpack,_survival,_isNew,dayz_versionNo,_model,_isHiveOk,_newPlayer],true];
_clientID = owner _playerObj;
dayzPlayerLogin = [_charID,_inventory,_backpack,_survival,_isNew,dayz_versionNo,_model,_isHiveOk,_newPlayer];
_clientID publicVariableClient "dayzPlayerLogin";
//_playerObj enableSimulation false;

View File

@@ -0,0 +1,266 @@
private["_int","_characterID","_doLoop","_newModel","_wait","_playerID","_playerObj","_randomSpot","_publishTo","_primary","_secondary","_key","_result","_charID","_playerObj","_playerName","_finished","_spawnPos","_spawnDir","_items","_counter","_magazines","_weapons","_group","_backpack","_worldspace","_direction","_newUnit","_score","_position","_pos","_isIsland","_isNew","_inventory","_backpack","_medical","_survival","_stats","_state","_lastinstance"];
//Set Variables
//Wait for HIVE to be free
//diag_log ("SETUP: attempted with " + str(_this));
_characterID = _this select 0;
_playerObj = _this select 1;
_playerID = _this select 2;
if (isNull _playerObj) exitWith {
diag_log ("SETUP INIT FAILED: Exiting, player object null: " + str(_playerObj));
};
if (_playerID == "") then {
_playerID = getPlayerUID _playerObj;
};
if (_playerID == "") exitWith {
diag_log ("SETUP INIT FAILED: Exiting, no player ID: " + str(_playerObj));
};
//Variables
_worldspace = [];
_survival = [0,0,0];
_tent = [];
_state = [];
//Do Connection Attempt
_doLoop = 0;
while {_doLoop < 5} do {
_key = format["CHILD:102:%1:",_characterID];
_primary = [_key,false,dayZ_hivePipeAuth] call server_hiveReadWrite;
if (count _primary > 0) then {
if ((_primary select 0) != "ERROR") then {
_doLoop = 9;
};
};
_doLoop = _doLoop + 1;
};
if (isNull _playerObj or !isPlayer _playerObj) exitWith {
diag_log ("SETUP RESULT: Exiting, player object null: " + str(_playerObj));
};
//Wait for HIVE to be free
//diag_log ("SETUP: RESULT: Successful with " + str(_primary));
_medical = _primary select 1;
_stats = _primary select 2;
_state = _primary select 3;
_worldspace = _primary select 4;
_humanity = _primary select 5;
_lastinstance = _primary select 6;
//Set position
_randomSpot = false;
//diag_log ("WORLDSPACE: " + str(_worldspace));
if (count _worldspace > 0) then {
_direction = _worldspace select 0;
_position = _worldspace select 1;
if (count _position < 3) then {
//prevent debug world!
_randomSpot = true;
};
_debug = getMarkerpos "respawn_west";
_distance = _debug distance _position;
if (_distance < 2000) then {
_randomSpot = true;
};
_distance = [0,0,0] distance _position;
if (_distance < 500) then {
_randomSpot = true;
};
// Came from another server force random spawn
if (_lastinstance != dayZ_instance) then {
_randomSpot = true;
}
//_playerObj setPosATL _position;
//_playerObj setDir _direction;
} else {
_randomSpot = true;
};
//diag_log ("LOGIN: Location: " + str(_worldspace) + " doRnd?: " + str(_randomSpot));
//set medical values
if (count _medical > 0) then {
_playerObj setVariable["USEC_isDead",(_medical select 0),true];
_playerObj setVariable["NORRN_unconscious", (_medical select 1), true];
_playerObj setVariable["USEC_infected",(_medical select 2),true];
_playerObj setVariable["USEC_injured",(_medical select 3),true];
_playerObj setVariable["USEC_inPain",(_medical select 4),true];
_playerObj setVariable["USEC_isCardiac",(_medical select 5),true];
_playerObj setVariable["USEC_lowBlood",(_medical select 6),true];
_playerObj setVariable["USEC_BloodQty",(_medical select 7),true];
_playerObj setVariable["unconsciousTime",(_medical select 10),true];
// if (_playerID in dayz_disco) then {
// _playerObj setVariable["NORRN_unconscious",true, true];
// _playerObj setVariable["unconsciousTime",300,true];
// } else {
// _playerObj setVariable["unconsciousTime",(_medical select 10),true];
// };
//Add Wounds
{
_playerObj setVariable[_x,true,true];
[_playerObj,_x,_hit] spawn fnc_usec_damageBleed;
usecBleed = [_playerObj,_x,0];
publicVariable "usecBleed";
} forEach (_medical select 8);
//Add fractures
_fractures = (_medical select 9);
_playerObj setVariable ["hit_legs",(_fractures select 0),true];
_playerObj setVariable ["hit_hands",(_fractures select 1),true];
if (count _medical > 11) then {
//Additional medical stats
_playerObj setVariable ["messing",(_medical select 11),true];
};
} else {
//Reset Fractures
_playerObj setVariable ["hit_legs",0,true];
_playerObj setVariable ["hit_hands",0,true];
_playerObj setVariable ["USEC_injured",false,true];
_playerObj setVariable ["USEC_inPain",false,true];
_playerObj setVariable ["messing",[0,0],true];
};
if (count _stats > 0) then {
//register stats
_playerObj setVariable["zombieKills",(_stats select 0),true];
_playerObj setVariable["headShots",(_stats select 1),true];
_playerObj setVariable["humanKills",(_stats select 2),true];
_playerObj setVariable["banditKills",(_stats select 3),true];
_playerObj addScore (_stats select 1);
//Save Score
_score = score _playerObj;
_playerObj addScore ((_stats select 0) - _score);
//record for Server JIP checks
_playerObj setVariable["zombieKills_CHK",(_stats select 0)];
_playerObj setVariable["headShots_CHK",(_stats select 1)];
_playerObj setVariable["humanKills_CHK",(_stats select 2)];
_playerObj setVariable["banditKills_CHK",(_stats select 3)];
if (count _stats > 4) then {
if (!(_stats select 3)) then {
_playerObj setVariable["selectSex",true,true];
};
} else {
_playerObj setVariable["selectSex",true,true];
};
} else {
//Save initial loadout
//register stats
_playerObj setVariable["zombieKills",0,true];
_playerObj setVariable["humanKills",0,true];
_playerObj setVariable["banditKills",0,true];
_playerObj setVariable["headShots",0,true];
//record for Server JIP checks
_playerObj setVariable["zombieKills_CHK",0];
_playerObj setVariable["humanKills_CHK",0,true];
_playerObj setVariable["banditKills_CHK",0,true];
_playerObj setVariable["headShots_CHK",0];
};
if (_randomSpot) then {
private["_counter","_position","_isNear","_isZero","_mkr"];
if (!isDedicated) then {
endLoadingScreen;
};
//Spawn modify via mission init.sqf
if(isnil "spawnArea") then {
spawnArea = 1500;
};
if(isnil "spawnShoremode") then {
spawnShoremode = 1;
};
//spawn into random
_findSpot = true;
_mkr = "";
while {_findSpot} do {
_counter = 0;
while {_counter < 20 and _findSpot} do {
_mkr = "spawn" + str(round(random 4));
_position = ([(getMarkerPos _mkr),0,spawnArea,10,0,2000,spawnShoremode] call BIS_fnc_findSafePos);
_isNear = count (_position nearEntities ["Man",100]) == 0;
_isZero = ((_position select 0) == 0) and ((_position select 1) == 0);
//Island Check //TeeChange
_pos = _position;
_isIsland = false; //Can be set to true during the Check
for [{_w=0},{_w<=150},{_w=_w+2}] do {
_pos = [(_pos select 0),((_pos select 1) + _w),(_pos select 2)];
if(surfaceisWater _pos) exitWith {
_isIsland = true;
};
};
if ((_isNear and !_isZero) || _isIsland) then {_findSpot = false};
_counter = _counter + 1;
};
};
_isZero = ((_position select 0) == 0) and ((_position select 1) == 0);
_position = [_position select 0,_position select 1,0];
if (!_isZero) then {
//_playerObj setPosATL _position;
_worldspace = [0,_position];
};
};
//Record player for management
dayz_players set [count dayz_players,_playerObj];
//record player pos locally for server checking
_playerObj setVariable["characterID",_characterID,true];
_playerObj setVariable["humanity",_humanity,true];
_playerObj setVariable["humanity_CHK",_humanity];
//_playerObj setVariable["worldspace",_worldspace,true];
//_playerObj setVariable["state",_state,true];
_playerObj setVariable["lastPos",getPosATL _playerObj];
dayzPlayerLogin2 = [_worldspace,_state];
_clientID = owner _playerObj;
_clientID publicVariableClient "dayzPlayerLogin2";
//record time started
_playerObj setVariable ["lastTime",time];
//_playerObj setVariable ["model_CHK",typeOf _playerObj];
diag_log ("LOGIN PUBLISHING: " + str(_playerObj) + " Type: " + (typeOf _playerObj));
myObj = objNull;
call compile format["myObj = player%1",_playerID];
if (!(isNull myObj)) then {
if (alive myObj) then {
deleteVehicle myObj;
diag_log ("LOGIN DUPLICATE PLAYER: " + str(_playerObj) + " DELETED ORIGINAL");
};
};
//Record player for management
myObj = _playerObj;
call compile format["player%1 = myObj;",_playerID];
//diag_log (format["player%1 = myObj",_playerID]);
//dayz_players set [count dayz_players,_playerObj];
dayzLogin = null;
dayzLogin2 = null;
//Save Login

View File

@@ -0,0 +1,4 @@
private[];
_unit = _this select 0;
_variable = _this select 1;
_change = _this select 2;

View File

@@ -0,0 +1,207 @@
private["_characterID","_currentModelCheck","_temp","_isSync","_currentWpn","_currentMag","_magazines","_force","_qty","_qtyT","_val","_isNewPos","_isNewBackp","_humanity","_isNewGear","_doUpdate","_currentModel","_modelChk","_playerPos","_playerGear","_playerBackp","_backpack","_updates","_killsB","_killsH","_medical","_isNewMed","_character","_timeSince","_charPos","_isInVehicle","_justAte","_justDrank","_distanceFoot","_lastPos","_legs","_arms","_kills","_headShots","_killsCHK","_headShotsCHK","_timeGross","_timeLeft","_onLadder","_isTerminal"];
//[player,array]
//diag_log ("UPDATE: " + str(_this) );
//waituntil {(typeName(_this) == "ARRAY");sleep 0.01;}; //seems to cause often infinite waits (but not for first n players)
if ( typeName(_this) == "OBJECT" ) then {
_this = [_this,[],true];
//diag_log ("DW_DEBUG: #manual fix _this: " + str(_this));
};
//correct
//"UPDATE: [B 1-1-B:1 (THE BEAST) REMOTE,[],true]"
//error
//"UPDATE: B 1-1-B:1 (THE BEAST) REMOTE"
_character = _this select 0;
_magazines = _this select 1;
_force = _this select 2;
_force = true;
_doUpdate = false;
_characterID = _character getVariable ["characterID","0"];
_charPos = getPosATL _character;
_isInVehicle = vehicle _character != _character;
_timeSince = 0;
_humanity = 0;
//diag_log ("DW_DEBUG: (isnil _characterID): " + str(isnil "_characterID"));
/*
if !(isnil "_characterID") then {
diag_log ("DW_DEBUG: _characterID: " + str(_characterID));
};
*/
if (_character isKindOf "Animal") exitWith {
diag_log ("ERROR: Cannot Sync Character " + (name _character) + " is an Animal class");
};
if (isnil "_characterID") exitWith {
diag_log ("ERROR: Cannot Sync Character " + (name _character) + " has nil characterID");
};
if (_characterID == "0") exitWith {
diag_log ("ERROR: Cannot Sync Character " + (name _character) + " as no characterID");
};
//Check for server initiated updates
_isNewMed = _character getVariable["medForceUpdate",false]; //Med Update is forced when a player receives some kind of med incident
_isNewPos = _character getVariable["posForceUpdate",false]; //Med Update is forced when a player receives some kind of med incident
_isNewGear = (count _magazines) > 0;
//diag_log ("Starting Save... MED: " + str(_isNewMed) + " / POS: " + str(_isNewPos)); sleep 0.05;
//Check for player initiated updates
if (_characterID != "0") then {
_playerPos = [];
_playerGear = [];
_playerBackp = [];
_medical = [];
_distanceFoot = 0;
//diag_log ("Found Character...");
//Check if update is requested
if (_isNewPos or _force) then {
//diag_log ("position..." + str(_isNewPos) + " / " + str(_force)); sleep 0.05;
if (((_charPos select 0) == 0) and ((_charPos select 1) == 0)) then {
//Zero Position
} else {
//diag_log ("getting position..."); sleep 0.05;
_playerPos = [round(direction _character),_charPos];
_lastPos = _character getVariable["lastPos",_charPos];
if (count _lastPos > 2 and count _charPos > 2) then {
if (!_isInVehicle) then {
_distanceFoot = round(_charPos distance _lastPos);
};
_character setVariable["lastPos",_charPos];
};
if (count _charPos < 3) then {
_playerPos = [];
};
//diag_log ("position = " + str(_playerPos)); sleep 0.05;
};
_character setVariable ["posForceUpdate",false,true];
};
if (_isNewGear) then {
//diag_log ("gear..."); sleep 0.05;
_playerGear = [weapons _character,_magazines];
_backpack = unitBackpack _character;
_playerBackp = [typeOf _backpack,getWeaponCargo _backpack,getMagazineCargo _backpack];
};
if (_isNewMed or _force) then {
//diag_log ("medical..."); sleep 0.05;
_wounds = [];
if (!(_character getVariable["USEC_isDead",false])) then {
//diag_log ("medical check..."); sleep 0.05;
_medical = _character call player_sumMedical;
//diag_log ("medical result..." + str(_medical)); sleep 0.05;
};
_character setVariable ["medForceUpdate",false,true];
};
//Process update
if (_characterID != "0") then {
//Record stats while we're here
/*
Check previous stats against what client had when they logged in
this helps prevent JIP issues, where a new player wouldn't have received
the old players updates. Only valid for stats where clients could have
be recording results from their local objects (such as agent zombies)
*/
_kills = ["zombieKills",_character] call server_getDiff;
_killsB = ["banditKills",_character] call server_getDiff;
_killsH = ["humanKills",_character] call server_getDiff;
_headShots = ["headShots",_character] call server_getDiff;
_humanity = ["humanity",_character] call server_getDiff2;
//_humanity = _character getVariable ["humanity",0];
_character addScore _kills;
/*
Assess how much time has passed, for recording total time on server
*/
_lastTime = _character getVariable["lastTime",time];
_timeGross = (time - _lastTime);
_timeSince = floor(_timeGross / 60);
_timeLeft = (_timeGross - (_timeSince * 60));
/*
Get character state details
*/
_currentWpn = currentMuzzle _character;
_currentAnim = animationState _character;
_config = configFile >> "CfgMovesMaleSdr" >> "States" >> _currentAnim;
_onLadder = (getNumber (_config >> "onLadder")) == 1;
_isTerminal = (getNumber (_config >> "terminal")) == 1;
//_wpnDisabled = (getNumber (_config >> "disableWeapons")) == 1;
_currentModel = typeOf _character;
_modelChk = _character getVariable ["model_CHK",""];
if (_currentModel == _modelChk) then {
_currentModel = "";
} else {
_currentModel = str(_currentModel);
_character setVariable ["model_CHK",typeOf _character];
};
if (_onLadder or _isInVehicle or _isTerminal) then {
_currentAnim = "";
//If position to be updated, make sure it is at ground level!
if ((count _playerPos > 0) and !_isTerminal) then {
_charPos set [2,0];
_playerPos set[1,_charPos];
};
};
if (_isInVehicle) then {
_currentWpn = "";
} else {
if ( typeName(_currentWpn) == "STRING" ) then {
_muzzles = getArray(configFile >> "cfgWeapons" >> _currentWpn >> "muzzles");
if (count _muzzles > 1) then {
_currentWpn = currentMuzzle _character;
};
} else {
//diag_log ("DW_DEBUG: _currentWpn: " + str(_currentWpn));
_currentWpn = "";
};
};
_temp = round(_character getVariable ["temperature",100]);
_currentState = [_currentWpn,_currentAnim,_temp];
/*
Everything is ready, now publish to HIVE
*/
if (count _playerPos > 0) then {
_array = [];
{
if (_x > -20000 and _x < 20000) then {
_array set [count _array,_x];
};
} forEach (_playerPos select 1);
_playerPos set [1,_array];
};
if (!isNull _character) then {
if (alive _character) then {
//Wait for HIVE to be free
//Send request
_key = format["CHILD:201:%1:%2:%3:%4:%5:%6:%7:%8:%9:%10:%11:%12:%13:%14:%15:%16:",_characterID,_playerPos,_playerGear,_playerBackp,_medical,false,false,_kills,_headShots,_distanceFoot,_timeSince,_currentState,_killsH,_killsB,_currentModel,_humanity];
//diag_log ("HIVE: WRITE: "+ str(_key) + " / " + _characterID);
_key call server_hiveWrite;
};
};
// If player is in a vehicle, keep its position updated
if (vehicle _character != _character) then {
[vehicle _character, "position"] call server_updateObject;
};
// Force gear updates for nearby vehicles/tents
_pos = _this select 0;
{
[_x, "gear"] call server_updateObject;
} forEach nearestObjects [_pos, ["Car", "Helicopter", "Motorcycle", "Ship", "TentStorage"], 10];
//[_charPos] call server_updateNearbyObjects;
//Reset timer
if (_timeSince > 0) then {
_character setVariable ["lastTime",(time - _timeLeft)];
};
};
};

View File

@@ -0,0 +1,29 @@
private["_type","_location","_dir","_character","_tent","_class","_id","_uid"];
//[dayz_characterID,_tent,[_dir,_location],"TentStorage"]
_charID = _this select 0;
_object = _this select 1;
_worldspace = _this select 2;
_class = _this select 3;
_id = 0;
if (!(_object isKindOf "Building")) exitWith {
deleteVehicle _object;
};
//diag_log ("PUBLISH: Attempt " + str(_object));
_dir = _worldspace select 0;
_location = _worldspace select 1;
//get UID
_uid = _worldspace call dayz_objectUID2;
//Send request
_key = format["CHILD:308:%1:%2:%3:%4:%5:%6:%7:%8:%9:",dayZ_instance, _class, 0 , _charID, _worldspace, [], [], 0,_uid];
//diag_log ("HIVE: WRITE: "+ str(_key));
_key call server_hiveWrite;
_object setVariable ["ObjectUID", _uid,true];
dayz_serverObjectMonitor set [count dayz_serverObjectMonitor,_object];
//diag_log ("PUBLISH: Created " + (_class) + " with ID " + _uid);

View File

@@ -0,0 +1,129 @@
private["_object","_worldspace","_location","_dir","_character","_tent","_class","_id","_uid","_dam","_hitpoints","_selection","_array","_damage","_randFuel","_fuel","_key","_result","_outcome","_totaldam","_parts","_retry","_done"];
//[_veh,[_dir,_location],"V3S_Civ"]
_object = _this select 0;
_worldspace = _this select 1;
_class = _this select 2;
_uid = _this select 3;
_fuel = 0;
_damage = 0;
_array = [];
diag_log ("PUBLISH: Attempt " + str(_object));
_dir = _worldspace select 0;
_location = _worldspace select 1;
//Generate UID
_uid = _worldspace call dayz_objectUID2;
// _uid = format["%1%2",dayZ_instance,_uid];
if (getNumber(configFile >> "CfgVehicles" >> _class >> "isBicycle") != 1) then {
// Create randomly damaged parts
_totaldam = 0;
_hitpoints = _object call vehicle_getHitpoints;
{
_dam = 0;
if(["Body",_x,false] call fnc_inString) then {
_dam = call generate_new_damage;
};
if(["Engine",_x,false] call fnc_inString) then {
_dam = call generate_exp_damage;
};
if(["HRotor",_x,false] call fnc_inString) then {
_dam = call generate_new_damage;
};
if(["Fuel",_x,false] call fnc_inString) then {
_dam = call generate_exp_damage;
};
if(["Wheel",_x,false] call fnc_inString) then {
_dam = call generate_new_damage;
};
if(["Glass",_x,false] call fnc_inString) then {
_dam = call generate_new_damage;
};
_selection = getText(configFile >> "cfgVehicles" >> _class >> "HitPoints" >> _x >> "name");
if (_dam > 0) then {
_array set [count _array,[_selection,_dam]];
_totaldam = _totaldam + _dam;
};
} forEach _hitpoints;
// just set low base dmg - may change later
_damage = 0;
// 50% chance that vehicle will have a little gas
_randFuel = random(1);
if(_randFuel > 0.5) then {
_fuel = random(0.5);
};
};
//Send request
_key = format["CHILD:308:%1:%2:%3:%4:%5:%6:%7:%8:%9:",dayZ_instance, _class, _damage , 0, _worldspace, [], _array, _fuel,_uid]; // Change this to dynamic parts damage and fuel
diag_log ("HIVE: WRITE: "+ str(_key));
_key call server_hiveWrite;
// Wait just a little
sleep 0.1;
_done = false;
_retry = 0;
while{not _done} do {
// GET DB ID
_key = format["CHILD:388:%1:",_uid];
diag_log ("HIVE: WRITE: "+ str(_key));
_result = [_key] call server_hiveReadWrite;
_outcome = _result select 0;
if (_outcome == "PASS") then {
_oid = _result select 1;
_object setVariable ["ObjectID", _oid, true];
diag_log("CUSTOM: Selected " + str(_oid));
_done = true;
} else {
diag_log("CUSTOM: trying again to get id for: " + str(_uid));
_done = false;
_retry = _retry + 1;
sleep 0.1;
};
if(_retry == 5) exitWith { deleteVehicle _object; diag_log("CUSTOM: failed to get id for : " + str(_uid)); };
};
// disable marker later
//_marker = createMarker [str(_location) , _location];
//_marker setMarkerShape "ICON";
//_marker setMarkerType "DOT";
//_marker setMarkerText (typeOf _object);
//_marker setMarkerColor "ColorBlue";
// not needed yet
// _object setVariable ["ObjectUID", _uid, true];
_object setVariable ["lastUpdate",time];
_object setVariable ["CharacterID", "0", true];
_object setDamage _damage;
// Set Hits after ObjectID is set
{
_selection = _x select 0;
_dam = _x select 1;
if (_selection in dayZ_explosiveParts and _dam > 0.8) then {_dam = 0.8};
[_object,_selection,_dam] call object_setFixServer;
} forEach _array;
_object setvelocity [0,0,1];
_object setFuel _fuel;
_id = _object spawn fnc_vehicleEventHandler;
dayz_serverObjectMonitor set [count dayz_serverObjectMonitor,_object];
diag_log ("PUBLISH: Created " + (_class) + " with ID " + str(_uid));

View File

@@ -0,0 +1,14 @@
private["_unitArray","_handle"];
_unitArray = [];
if (isSinglePlayer) then {
_unitArray = [player];
} else {
_unitArray = dayz_players;
};
{
if (!isNull _x) then {
//diag_log ("SERVER: Routine Player Check: " + str(_x));
_handle = _x spawn server_updatePlayer;
waitUntil{scriptDone _handle};
};
} forEach _unitArray;

View File

@@ -0,0 +1,24 @@
private["_position","_size","_loot","_zeds","_groups","_group"];
_position = _this select 0;
_size = _this select 1;
_type = _this select 2;
_town = nearestLocation [_position, _type];
//Clean Loot
_loot = nearestObjects [_position, ["WeaponHolder"], _size];
{
deleteVehicle _x;
} forEach _loot;
//Clean Zeds
_zeds = _position nearEntities ["zZombie_Base",_size];
_groups = [];
{
if (!(isNull _group)) then {
_group = group _x;
if (!(_group in _groups)) then {_groups set [count _groups,_group];};
_x setDamage 1;
};
} forEach _zeds;
diag_log "Dezombify Town";
dayz_zombifiedTowns = dayz_zombifiedTowns - [_town];

View File

@@ -0,0 +1,68 @@
private["_town","_spot","_buildings","_list","_size","_numZeds","_impt","_position","_buildings","_totalBuildings","_numGroups","_building","_type"];
//has town
_town = _this;
_type = type _town;
_spot = objNull;
_buildings = [];
_list = [];
_numZeds = 2;
_impt = (importance _town);
_size = 50;
switch (_type) do {
default {
_numZeds = 3;
_size = 40 * _impt;
};
case "NameCity": {
_numZeds = 6;
_size = 80 * _impt;
};
case "NameCityCapital": {
_numZeds = 10;
_size = 120 * _impt;
};
};
_position = position _town;
_buildings = nearestObjects [_position, ["Building"], _size];
_totalBuildings = count _buildings;
_numGroups = 0;
_i = 0;
/*
_markerstr = createMarker["markername_" + (text _town),_position];
_markerstr setMarkerShape "ELLIPSE";
_markerstr setMarkerSize [_size, _size];
*/
_trigger = createTrigger["EmptyDetector",_position];
_trigger setTriggerArea[dayz_zSpawnDistance,dayz_zSpawnDistance,0,false];
_trigger setTriggerActivation["WEST","NOT PRESENT",false];
_code = format["_id = [%1,%2,'%3'] spawn server_townDeZombify;",_position,_size,_type];
_trigger setTriggerStatements["this", _code, ""];
_val = 60 * 10;
_trigger setTriggerTimeout [_val, _val, _val, true];
while {_numGroups < _numZeds and _i < _totalBuildings} do {
_building = _buildings call BIS_fnc_selectRandom;
if (!isNull _building) then {
_list = _building nearRoads 20;
if (count _list > 0) then {
_spot = _list call BIS_fnc_selectRandom;
_nearMen = (position _spot) nearEntities [["Man"],50];
if (!isNull _spot and (count _nearMen == 0)) then {
/*
_marker = createMarker [(text _town) + "Marker2" + str(_i), position _spot];
_marker setMarkerShape "ICON";
_marker setMarkerType "DOT";
_marker setMarkerColor "ColorBlue";
_marker setMarkerText str(_i);
*/
_numGroups = _numGroups + 1;
(position _spot) spawn dayz_spawnZombies;
};
};
};
_i = _i + 1;
sleep 0.1;
};

View File

@@ -0,0 +1,6 @@
private["_pos","_objects"];
_pos = _this select 0;
{
[_x, "gear"] call server_updateObject;
} forEach nearestObjects [_pos, ["Car", "Helicopter", "Motorcycle", "Ship", "TentStorage"], 10];

View File

@@ -0,0 +1,95 @@
/*
[_object,_type] spawn server_updateObject;
*/
private["_object","_type","_objectID","_uid","_lastUpdate","_needUpdate"];
_object = _this select 0;
_type = _this select 1;
_objectID = _object getVariable ["ObjectID","0"];
_uid = _object getVariable ["ObjectUID","0"];
if (_objectID == "0" && _uid == "0") then { _uid = _object call dayz_objectUID; }; //seems never been call
_lastUpdate = _object getVariable ["lastUpdate",time];
_needUpdate = _object in needUpdate_objects;
// TODO ----------------------
_object_position = {
private["_position","_worldspace","_fuel","_key"];
_position = getPosATL _object;
_worldspace = [
round(direction _object),
_position
];
_fuel = 0;
if (_object isKindOf "AllVehicles") then {
_fuel = fuel _object;
};
_key = format["CHILD:305:%1:%2:%3:",_objectID,_worldspace,_fuel];
diag_log ("HIVE: WRITE: "+ str(_key));
_key call server_hiveWrite;
};
_object_inventory = {
private["_inventory","_previous","_key"];
_inventory = [
getWeaponCargo _object,
getMagazineCargo _object,
getBackpackCargo _object
];
_previous = str(_object getVariable["lastInventory",[]]);
if (str(_inventory) != _previous) then {
_object setVariable["lastInventory",_inventory];
if (_objectID == "0") then {
_key = format["CHILD:309:%1:%2:",_uid,_inventory];
} else {
_key = format["CHILD:303:%1:%2:",_objectID,_inventory];
};
diag_log ("HIVE: WRITE: "+ str(_key));
_key call server_hiveWrite;
};
};
_object_damage = {
private["_hitpoints","_array","_hit","_selection","_key","_damage"];
_hitpoints = _object call vehicle_getHitpoints;
_damage = damage _object;
_array = [];
{
_hit = [_object,_x] call object_getHit;
_selection = getText (configFile >> "CfgVehicles" >> (typeOf _object) >> "HitPoints" >> _x >> "name");
if (_hit > 0) then {_array set [count _array,[_selection,_hit]]};
} forEach _hitpoints;
_key = format["CHILD:306:%1:%2:%3:",_objectID,_array,_damage];
diag_log ("HIVE: WRITE: "+ str(_key));
_key call server_hiveWrite;
_object setVariable ["needUpdate",false,true];
};
// TODO ----------------------
_object setVariable ["lastUpdate",time,true];
switch (_type) do {
case "all": {
call _object_position;
call _object_inventory;
call _object_damage;
};
case "position": {
call _object_position;
};
case "gear": {
call _object_inventory;
};
case "damage": {
if ( (time - _lastUpdate) > 5 && !_needUpdate ) then {
call _object_damage;
} else {
if ( !_needUpdate ) then {
needUpdate_objects set [count needUpdate_objects, _object];
};
};
};
case "repair": {
call _object_damage;
};
};

View File

@@ -0,0 +1,46 @@
private["_unit","_potential","_newOwner","_client"];
_unit = _this select 0;
diag_log ("CLEANUP: DELETE UNCONTROLLED ZOMBIE: " + (typeOf _unit) + " OF: " + str(_unit) );
deleteVehicle _unit;
/*
//Not server then exit
if(!isServer) exitWith {
diag_log ("DW_DEBUG: #findOwner exits as not server: " + str(isServer));
};
//Not local then exit
if(!local _unit) exitWith {
diag_log ("DW_DEBUG: #findOwner exits _unit not local: " + str(local _unit));
};
//Find a new owner
_potential = (getposATL _unit) nearEntities [["CAManBase"],300];
_newOwner = objNull;
{
if (isPlayer _x) then {
_newOwner = _x;
};
if (!isNull _newOwner) exitWith {
//diag_log ("DW_DEBUG: #findOwner potencial _newOwner: " + str(_newOwner));
};
} forEach _potential;
//If no nearby player, delete the agent
//diag_log ("DW_DEBUG: #findOwner isNull _newOwner: " + str(isNull _newOwner));
if(isNull _newOwner) exitWith {
diag_log ("CLEANUP: NOTHING TO TRANSFER OWNERSHIP OF TYPE: " + (typeOf _unit) + " OF: " + str(_unit) );
deleteVehicle _unit;
};
//set client as controller
_client = owner _newOwner;
_unit setOwner _client;
diag_log ("CLEANUP: TRANSFERRED OWNERSHIP OF TYPE: " + (typeOf _unit) + " OF _unit: " + str(_unit) + " TO _client: " + str(_client) );
*/

View File

@@ -0,0 +1,461 @@
waituntil {!isnil "bis_fnc_init"};
BIS_Effects_Burn = {};
object_spawnDamVehicle = compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\object_spawnDamVehicle.sqf";
server_playerLogin = compile preprocessFileLineNumbers "\z\addons\dayz_server\compile\server_playerLogin.sqf";
server_playerSetup = compile preprocessFileLineNumbers "\z\addons\dayz_server\compile\server_playerSetup.sqf";
server_onPlayerDisconnect = compile preprocessFileLineNumbers "\z\addons\dayz_server\compile\server_onPlayerDisconnect.sqf";
server_routinePlayerCheck = compile preprocessFileLineNumbers "\z\addons\dayz_server\compile\server_routinePlayerCheck.sqf";
server_updateObject = compile preprocessFileLineNumbers "\z\addons\dayz_server\compile\server_updateObject.sqf";
server_playerDied = compile preprocessFileLineNumbers "\z\addons\dayz_server\compile\server_playerDied.sqf";
server_updatePlayer = compile preprocessFileLineNumbers "\z\addons\dayz_server\compile\server_updatePlayer.sqf";
server_playerStat = compile preprocessFileLineNumbers "\z\addons\dayz_server\compile\server_playerStat.sqf";
server_publishObj = compile preprocessFileLineNumbers "\z\addons\dayz_server\compile\server_publishObject.sqf";
server_publishVeh = compile preprocessFileLineNumbers "\z\addons\dayz_server\compile\server_publishVehicle.sqf"; // Custom to add vehicles
local_publishObj = compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\local_publishObj.sqf"; //Creates the object in DB
local_deleteObj = compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\local_deleteObj.sqf"; //Creates the object in DB
local_createObj = compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\local_createObj.sqf"; //Creates the object in DB
server_playerSync = compile preprocessFileLineNumbers "\z\addons\dayz_server\compile\server_playerSync.sqf";
//zombie_initialize = compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\zombie_initialize.sqf";
zombie_findOwner = compile preprocessFileLineNumbers "\z\addons\dayz_server\compile\zombie_findOwner.sqf";
server_updateNearbyObjects = compile preprocessFileLineNumbers "\z\addons\dayz_server\compile\server_updateNearbyObjects.sqf";
vehicle_handleInteract = {
private["_object"];
_object = _this select 0;
[_object, "all"] call server_updateObject;
};
//event Handlers
eh_localCleanup = {
_object = _this select 0;
_object addEventHandler ["local", {
if(_this select 1) then {
private["_type","_unit"];
_unit = _this select 0;
_type = typeOf _unit;
deleteVehicle _unit;
diag_log ("CLEANUP: DELETED A " + str(_type) );
};
}];
};
server_characterSync = {
//dayzCharDisco = [_characterID,_playerPos,[_weapons,_magazines],[typeOf _backpack,getWeaponCargo _backpack,getMagazineCargo _backpack],_medical,_currentState,_currentModel];
_characterID = _this select 0;
_playerPos = _this select 1;
_playerGear = _this select 2;
_playerBackp = _this select 3;
_medical = _this select 4;
_currentState = _this select 5;
_currentModel = _this select 6;
_key = format["CHILD:201:%1:%2:%3:%4:%5:%6:%7:%8:%9:%10:%11:%12:%13:%14:%15:%16:",_characterID,_playerPos,_playerGear,_playerBackp,_medical,false,false,0,0,0,0,_currentState,0,0,_currentModel,0];
//diag_log ("HIVE: WRITE: "+ str(_key) + " / " + _characterID);
_key call server_hiveWrite;
};
//was missing for server
fnc_buildWeightedArray = compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\fn_buildWeightedArray.sqf"; //Checks which actions for nearby casualty
//onPlayerConnected "[_uid,_name] spawn server_onPlayerConnect;";
onPlayerDisconnected "[_uid,_name] call server_onPlayerDisconnect;";
server_hiveWrite = {
private["_resultArray","_data"];
//diag_log ("ATTEMPT WRITE: " + _this);
_data = "HiveEXT" callExtension _this;
diag_log ("WRITE: " + _data);
};
server_hiveReadWrite = {
private["_key","_resultArray","_data"];
_key = _this select 0;
//diag_log ("ATTEMPT READ/WRITE: " + _key);
_data = "HiveEXT" callExtension _key;
diag_log ("READ/WRITE: " + _data);
_resultArray = call compile format ["%1;",_data];
_resultArray;
};
// Setup globals allow overwrite from init.sqf
if(isnil "dayz_MapArea") then {
dayz_MapArea = 10000;
};
if(isnil "DynamicVehicleArea") then {
DynamicVehicleArea = dayz_MapArea / 2;
};
if(isnil "HeliCrashArea") then {
HeliCrashArea = dayz_MapArea / 2;
};
spawn_heliCrash = {
private["_position","_veh","_num","_config","_itemType","_itemChance","_weights","_index","_iArray"];
waitUntil{!isNil "BIS_fnc_selectRandom"};
if (isDedicated) then {
_position = [getMarkerPos "center",0,HeliCrashArea,10,0,2000,0] call BIS_fnc_findSafePos;
_veh = createVehicle ["UH1Wreck_DZ",_position, [], 0, "CAN_COLLIDE"];
dayz_serverObjectMonitor set [count dayz_serverObjectMonitor,_veh];
_veh setVariable ["ObjectID",1,true];
dayzFire = [_veh,2,time,false,false];
publicVariable "dayzFire";
if (isServer) then {
nul=dayzFire spawn BIS_Effects_Burn;
};
_num = round(random 4) + 3;
_config = configFile >> "CfgBuildingLoot" >> "HeliCrash";
_itemType = [] + getArray (_config >> "itemType");
//diag_log ("DW_DEBUG: _itemType: " + str(_itemType));
_itemChance = [] + getArray (_config >> "itemChance");
//diag_log ("DW_DEBUG: _itemChance: " + str(_itemChance));
//diag_log ("DW_DEBUG: (isnil fnc_buildWeightedArray): " + str(isnil "fnc_buildWeightedArray"));
waituntil {!isnil "fnc_buildWeightedArray"};
_weights = [];
_weights = [_itemType,_itemChance] call fnc_buildWeightedArray;
//diag_log ("DW_DEBUG: _weights: " + str(_weights));
for "_x" from 1 to _num do {
//create loot
_index = _weights call BIS_fnc_selectRandom;
sleep 1;
if (count _itemType > _index) then {
//diag_log ("DW_DEBUG: " + str(count (_itemType)) + " select " + str(_index));
_iArray = _itemType select _index;
_iArray set [2,_position];
_iArray set [3,5];
_iArray call spawn_loot;
_nearby = _position nearObjects ["WeaponHolder",20];
{
_x setVariable ["permaLoot",true];
} forEach _nearBy;
};
};
};
};
// Get all buildings and roads only once
MarkerPosition = getMarkerPos "center";
RoadList = MarkerPosition nearRoads DynamicVehicleArea;
BuildingList = MarkerPosition nearObjects ["House",DynamicVehicleArea];
spawn_vehicles = {
private["_vehicle","_isAir","_isShip","_position","_roadlist","_buildinglist","_istoomany","_marker","_veh","_objPosition","_weights","_index","_uid"];
// TODO: change this part either to DB or mission config.
// 1 : Motocycles
// 2 : Bicycles, ATV's
// 3 : Trucks Unarmed
// 4 : Trucks
// 5 : Cars
// 6 : Jeeps
// 7 : Bus, Tractor, SUV, Vans
// 8 : Helicopters
// 9 : Helicopters Unarmed
// 10: Military Unarmed
// 11: Military
// 12: Boat Unarmed
// 13: Boat
// 14: Heavy Armor Unarmed
// 15: Fuel Trucks
_AllowedVehiclesList = ["M1030_US_DES_EP1","TT650_TK_CIV_EP1","Old_moto_TK_Civ_EP1","TT650_Civ","TT650_Ins",
"MMT_Civ","Old_bike_TK_INS_EP1","ATV_US_EP1","BAF_ATV_D","ATV_CZ_EP1",
"hilux1_civil_3_open_EP1","hilux1_civil_2_covered","hilux1_civil_1_open","datsun1_civil_3_open","datsun1_civil_2_covered","datsun1_civil_1_open",
"Pickup_PK_TK_GUE_EP1","Offroad_DSHKM_TK_GUE_EP1","Offroad_SPG9_TK_GUE_EP1","Pickup_PK_GUE","Pickup_PK_INS",
"policecar","Octavia_ACR","Lada1","Lada2","LadaLM","Skoda","SkodaBlue","SkodaGreen","SkodaRed","VWGolf","car_hatchback","car_sedan","Lada1_TK_CIV_EP1","Lada2_TK_CIV_EP1","VolhaLimo_TK_CIV_EP1","Volha_1_TK_CIV_EP1","Volha_2_TK_CIV_EP1",
"UAZ_CDF","UAZ_INS","UAZ_RU","UAZ_Unarmed_TK_CIV_EP1","UAZ_Unarmed_TK_EP1","UAZ_Unarmed_UN_EP1",
"Ikarus","Ikarus_TK_CIV_EP1","tractor","TowingTractor","SUV_TK_CIV_EP1","S1203_TK_CIV_EP1","S1203_ambulance_EP1",
"UH1H_DZ","UH1H_TK_EP1","CH_47F_EP1","Mi17_TK_EP1","Mi17_UN_CDF_EP1","Mi171Sh_CZ_EP1","UH60M_EP1","Mi17_CDF","MH60S","UH1Y",
"Mi17_Civilian","MH6J_EP1","UH60M_MEV_EP1","MV22",
"LandRover_ACR","LandRover_CZ_EP1","LandRover_TK_CIV_EP1","HMMWV","HMMWV_DES_EP1","HMMWV_M1035_DES_EP1","HMMWV_Ambulance","HMMWV_Ambulance_CZ_DES_EP1","GAZ_Vodnik_MedEvac","Ural_TK_CIV_EP1","Ural_UN_EP1","V3S_Open_TK_CIV_EP1","V3S_Open_TK_EP1","MTVR_DES_EP1","Kamaz",
"HMMWV_M998A2_SOV_DES_EP1","HMMWV_M1151_M2_CZ_DES_EP1","LandRover_Special_CZ_EP1","LandRover_MG_TK_EP1","ArmoredSUV_PMC",
"Fishing_Boat","PBX","PBX_ACR","Smallboat_1","Smallboat_2","Zodiac",
"RHIB","RHIB2Turret",
"M113Ambul_UN_EP1","M113Ambul_TK_EP1","BMP2_Ambul_CDF","BMP2_Ambul_INS",
"KamazRefuel","MtvrRefuel_DES_EP1","UralRefuel_TK_EP1","V3S_Refuel_TK_GUE_EP1","T810Refuel_Des_ACR","T810Refuel_ACR"];
_AllowedVehiclesChance = [0.55,0.65,0.25,0.35,0.45,
0.25,0.75,0.45,0.45,0.45,
0.40,0.35,0.35,0.25,0.20,0.25,
0.25,0.75,0.45,0.45,0.45,
0.2,0.25,0.45,0.45,0.45,0.45,0.45,0.45,0.45,0.35,0.40,0.40,0.40,0.25,0.45,0.45,0.45,
0.30,0.30,0.30,0.30,0.30,0.30,
0.15,0.15,0.15,0.05,0.05,0.30,0.15,
0.05,0.05,0.01,0.025,0.025,0.025,0.025,0.02,0.02,0.02,
0.09,0.08,0.07,0.01,
0.11,0.11,0.11,0.10,0.10,0.10,0.05,0.05,0.05,0.05,0.10,0.10,0.10,0.10,0.10,
0.05,0.05,0.01,0.05,0.01,
0.15,0.15,0.15,0.15,0.15,0.15,
0.01,0.01,
0.001,0.001,0.001,0.001,
0.001,0.001,0.001,0.001,0.001,0.001];
if (isDedicated) then {
waituntil {!isnil "fnc_buildWeightedArray"};
_weights = [];
_weights = [_AllowedVehiclesList,_AllowedVehiclesChance] call fnc_buildWeightedArray;
waitUntil{!isNil "BIS_fnc_selectRandom"};
// get index from fnc_buildWeightedArray
_index = _weights call BIS_fnc_selectRandom;
// select vehicle
_vehicle = _AllowedVehiclesList select _index;
// Find Vehicle Type to better control spawns
_isAir = _vehicle isKindOf "Air";
_isShip = _vehicle isKindOf "Ship";
if(_isShip || _isAir) then {
if(_isShip) then {
// Spawn anywhere on coast on water
waitUntil{!isNil "BIS_fnc_selectRandom"};
_position = [MarkerPosition,0,DynamicVehicleArea,10,1,2000,1] call BIS_fnc_findSafePos;
//diag_log("DEBUG: spawning boat near coast " + str(_position));
} else {
// Spawn air anywhere that is flat
waitUntil{!isNil "BIS_fnc_selectRandom"};
_position = [MarkerPosition,0,DynamicVehicleArea,25,0,1,0] call BIS_fnc_findSafePos;
//diag_log("DEBUG: spawning air anywhere flat " + str(_position));
};
} else {
// Spawn around buildings and 50% near roads
if((random 1) > 0.5) then {
waitUntil{!isNil "BIS_fnc_selectRandom"};
_position = RoadList call BIS_fnc_selectRandom;
_position = _position modelToWorld [0,0,0];
waitUntil{!isNil "BIS_fnc_findSafePos"};
_position = [_position,0,10,10,0,2000,0] call BIS_fnc_findSafePos;
//diag_log("DEBUG: spawning near road " + str(_position));
} else {
waitUntil{!isNil "BIS_fnc_selectRandom"};
_position = BuildingList call BIS_fnc_selectRandom;
_position = _position modelToWorld [0,0,0];
waitUntil{!isNil "BIS_fnc_findSafePos"};
_position = [_position,0,40,5,0,2000,0] call BIS_fnc_findSafePos;
//diag_log("DEBUG: spawning around buildings " + str(_position));
};
};
// only proceed if two params otherwise BIS_fnc_findSafePos failed and may spawn in air
if ((count _position) == 2) then {
_dir = round(random 180);
_istoomany = _position nearObjects ["AllVehicles",50];
if((count _istoomany) > 0) exitWith { diag_log("DEBUG: Too many vehicles at " + str(_position)); };
//place vehicle
_veh = createVehicle [_vehicle, _position, [], 0, "CAN_COLLIDE"];
_veh setdir _dir;
_veh setpos _position;
// Get position with ground
_objPosition = getPosATL _veh;
clearWeaponCargoGlobal _veh;
clearMagazineCargoGlobal _veh;
[_veh,[_dir,_objPosition],_vehicle,_uid] call server_publishVeh;
};
};
};
spawn_roadblocks = {
private["_position","_veh","_num","_config","_itemType","_itemChance","_weights","_index","_iArray","_isRoad","_roadlist","_istoomany"];
_WreckList = ["SKODAWreck","HMMWVWreck","UralWreck","datsun01Wreck","hiluxWreck","datsun02Wreck","UAZWreck","Land_Misc_Garb_Heap_EP1","Fort_Barricade_EP1"];
_WreckLoot = ["DynamicDebris"];
waitUntil{!isNil "BIS_fnc_selectRandom"};
if (isDedicated) then {
waitUntil{!isNil "BIS_fnc_selectRandom"};
_position = RoadList call BIS_fnc_selectRandom;
_position = _position modelToWorld [0,0,0];
waitUntil{!isNil "BIS_fnc_findSafePos"};
_position = [_position,0,10,5,0,2000,0] call BIS_fnc_findSafePos;
if ((count _position) == 2) then {
// Get position with ground
_istoomany = _position nearObjects ["All",5];
if((count _istoomany) > 0) exitWith { diag_log("DEBUG: Too many at " + str(_position)); };
//_isRoad = isOnRoad _position;
//_marker = createMarker [str(_position) , _position];
//_marker setMarkerShape "ICON";
//_marker setMarkerType "DOT";
//_marker setMarkerText "ON";
waitUntil{!isNil "BIS_fnc_selectRandom"};
_spawnveh = _WreckList call BIS_fnc_selectRandom;
waitUntil{!isNil "BIS_fnc_selectRandom"};
_spawnloot = _WreckLoot call BIS_fnc_selectRandom;
diag_log("DEBUG: Spawning a crashed " + _spawnveh + " with " + _spawnloot + " at " + str(_position));
_veh = createVehicle [_spawnveh,_position, [], 0, "CAN_COLLIDE"];
// Randomize placement a bit
_veh setDir round(random 360);
_veh setpos _position;
dayz_serverObjectMonitor set [count dayz_serverObjectMonitor,_veh];
_veh setVariable ["ObjectID",1,true];
_num = round(random 4) + 3;
_config = configFile >> "CfgBuildingLoot" >> _spawnloot;
_itemType = [] + getArray (_config >> "itemType");
_itemChance = [] + getArray (_config >> "itemChance");
waituntil {!isnil "fnc_buildWeightedArray"};
_weights = [];
_weights = [_itemType,_itemChance] call fnc_buildWeightedArray;
for "_x" from 1 to _num do {
//create loot
_index = _weights call BIS_fnc_selectRandom;
sleep 1;
if (count _itemType > _index) then {
_iArray = _itemType select _index;
_iArray set [2,_position];
_iArray set [3,5];
_iArray call spawn_loot;
_nearby = _position nearObjects ["WeaponHolder",20];
{
_x setVariable ["permaLoot",true];
} forEach _nearBy;
};
};
};
};
};
// Damage generator fuction
generate_new_damage = {
private ["_damage","_rnd"];
_rnd = random 1;
if(_rnd > 0.5) then {
_damage = 0;
} else {
_rnd = random 1;
if(_rnd > 0.5) then {
_damage = 0.50;
} else {
_damage = 1;
};
};
_damage;
};
// Damage generator fuction
generate_exp_damage = {
private ["_damage","_rnd"];
_rnd = random 1;
if(_rnd > 0.5) then {
_damage = 0;
} else {
_rnd = random 1;
if(_rnd > 0.5) then {
_damage = 0.50;
} else {
_damage = 0.85;
};
};
_damage;
};
server_getDiff = {
private["_variable","_object","_vNew","_vOld","_result"];
_variable = _this select 0;
_object = _this select 1;
_vNew = _object getVariable[_variable,0];
_vOld = _object getVariable[(_variable + "_CHK"),_vNew];
_result = 0;
if (_vNew < _vOld) then {
//JIP issues
_vNew = _vNew + _vOld;
_object getVariable[(_variable + "_CHK"),_vNew];
} else {
_result = _vNew - _vOld;
_object setVariable[(_variable + "_CHK"),_vNew];
};
_result
};
server_getDiff2 = {
private["_variable","_object","_vNew","_vOld","_result"];
_variable = _this select 0;
_object = _this select 1;
_vNew = _object getVariable[_variable,0];
_vOld = _object getVariable[(_variable + "_CHK"),_vNew];
_result = _vNew - _vOld;
_object setVariable[(_variable + "_CHK"),_vNew];
_result
};
dayz_objectUID = {
private["_position","_dir","_key","_object"];
_object = _this;
_position = getPosATL _object;
_dir = direction _object;
_key = [_dir,_position] call dayz_objectUID2;
_key
};
dayz_objectUID2 = {
private["_position","_dir","_key"];
_dir = _this select 0;
_key = "";
_position = _this select 1;
{
_x = _x * 10;
if ( _x < 0 ) then { _x = _x * -10 };
_key = _key + str(round(_x));
} forEach _position;
_key = _key + str(round(_dir));
_key
};
dayz_recordLogin = {
private["_key"];
_key = format["CHILD:103:%1:%2:%3:",_this select 0,_this select 1,_this select 2];
diag_log ("HIVE: WRITE: "+ str(_key));
_key call server_hiveWrite;
};

View File

@@ -0,0 +1,10 @@
while {isServer} do {
while {isServer} do {
while {isServer} do {
diag_log ("DEBUG FPS : " + str(diag_fps) );
sleep 181;
};
sleep 181;
};
sleep 181;
};

View File

@@ -0,0 +1,443 @@
/*%FSM<COMPILE "scriptedFSM.cfg, DayZ Server Cleanup">*/
/*%FSM<HEAD>*/
/*
item0[] = {"init",0,250,-75.000000,-400.000000,25.000000,-350.000000,0.000000,"init"};
item1[] = {"true",8,218,-75.000000,-175.000000,25.000000,-125.000000,0.000000,"true"};
item2[] = {"waiting",2,250,-75.000000,-100.000000,25.000000,-50.000000,0.000000,"waiting"};
item3[] = {"too_many_dead",4,218,-150.000000,-25.000000,-50.000000,25.000000,2.000000,"too many" \n "dead"};
item4[] = {"cleanup_dead",2,250,-150.000000,50.000000,-50.000000,100.000000,0.000000,"cleanup" \n "dead"};
item5[] = {"too_many_objects",4,218,-25.000000,-25.000000,75.000000,25.000000,0.000000,"too many" \n "objects"};
item6[] = {"cleanup_objects",2,250,-25.000000,50.000000,75.000000,100.000000,0.000000,"cleanup" \n "objects"};
item7[] = {"time_sync",4,218,-275.000000,-25.000000,-175.000000,25.000000,1.000000,"time" \n "sync"};
item8[] = {"sync_the_time",2,250,-275.000000,50.000000,-175.000000,100.000000,0.000000,"sync" \n "the time"};
item9[] = {"true",8,218,-75.000000,125.000000,25.000000,175.000000,0.000000,"true"};
item10[] = {"general_cleanup",2,250,-75.000000,200.000000,25.000000,250.000000,0.000000,"general" \n "cleanup"};
item11[] = {"",7,210,-304.000000,220.999985,-296.000000,229.000015,0.000000,""};
item12[] = {"",7,210,-304.000000,-154.000000,-296.000000,-146.000000,0.000000,""};
item13[] = {"",7,210,221.000000,-79.000000,229.000000,-71.000000,0.000000,""};
item14[] = {"",7,210,221.000000,146.000000,229.000000,154.000000,0.000000,""};
item15[] = {"initialized",4,218,-75.000000,-325.000000,25.000000,-275.000000,0.000000,"initialized"};
item16[] = {"prepare",2,250,-75.000000,-250.000000,25.000000,-200.000000,0.000000,"prepare"};
item17[] = {"update_objects",2,4346,100.000000,50.000000,200.000000,100.000000,0.000000,"update objects"};
item18[] = {"need_update",4,218,100.000000,-25.000000,200.000000,25.000000,1.000000,"need update"};
item19[] = {"",7,210,221.000000,-79.000000,229.000000,-71.000000,0.000000,""};
link0[] = {0,15};
link1[] = {1,2};
link2[] = {2,3};
link3[] = {2,5};
link4[] = {2,7};
link5[] = {2,13};
link6[] = {2,18};
link7[] = {3,4};
link8[] = {4,9};
link9[] = {5,6};
link10[] = {6,9};
link11[] = {7,8};
link12[] = {8,9};
link13[] = {9,10};
link14[] = {10,11};
link15[] = {11,12};
link16[] = {12,1};
link17[] = {13,14};
link18[] = {13,19};
link19[] = {14,9};
link20[] = {15,16};
link21[] = {16,1};
link22[] = {17,9};
link23[] = {18,17};
globals[] = {25.000000,1,0,0,0,640,480,1,24,6316128,1,-396.580658,354.272186,463.204498,-386.553192,911,1031,1};
window[] = {2,-1,-1,-1,-1,1020,322,1651,78,3,929};
*//*%FSM</HEAD>*/
class FSM
{
fsmName = "DayZ Server Cleanup";
class States
{
/*%FSM<STATE "init">*/
class init
{
name = "init";
init = /*%FSM<STATEINIT""">*/""/*%FSM</STATEINIT""">*/;
precondition = /*%FSM<STATEPRECONDITION""">*/""/*%FSM</STATEPRECONDITION""">*/;
class Links
{
/*%FSM<LINK "initialized">*/
class initialized
{
priority = 0.000000;
to="prepare";
precondition = /*%FSM<CONDPRECONDITION""">*/""/*%FSM</CONDPRECONDITION""">*/;
condition=/*%FSM<CONDITION""">*/"!isnil ""bis_fnc_init"""/*%FSM</CONDITION""">*/;
action=/*%FSM<ACTION""">*/""/*%FSM</ACTION""">*/;
};
/*%FSM</LINK>*/
};
};
/*%FSM</STATE>*/
/*%FSM<STATE "waiting">*/
class waiting
{
name = "waiting";
init = /*%FSM<STATEINIT""">*/"//diag_log ""CLEANUP: Waiting for next task"";" \n
"_numDead = {local _x} count allDead;" \n
""/*%FSM</STATEINIT""">*/;
precondition = /*%FSM<STATEPRECONDITION""">*/""/*%FSM</STATEPRECONDITION""">*/;
class Links
{
/*%FSM<LINK "too_many_dead">*/
class too_many_dead
{
priority = 2.000000;
to="cleanup_dead";
precondition = /*%FSM<CONDPRECONDITION""">*/""/*%FSM</CONDPRECONDITION""">*/;
condition=/*%FSM<CONDITION""">*/"(_numDead > 300)"/*%FSM</CONDITION""">*/;
action=/*%FSM<ACTION""">*/""/*%FSM</ACTION""">*/;
};
/*%FSM</LINK>*/
/*%FSM<LINK "time_sync">*/
class time_sync
{
priority = 1.000000;
to="sync_the_time";
precondition = /*%FSM<CONDPRECONDITION""">*/""/*%FSM</CONDPRECONDITION""">*/;
condition=/*%FSM<CONDITION""">*/"((time - _lastUpdate) > 300)"/*%FSM</CONDITION""">*/;
action=/*%FSM<ACTION""">*/"_lastUpdate = time;"/*%FSM</ACTION""">*/;
};
/*%FSM</LINK>*/
/*%FSM<LINK "need_update">*/
class need_update
{
priority = 1.000000;
to="update_objects";
precondition = /*%FSM<CONDPRECONDITION""">*/""/*%FSM</CONDPRECONDITION""">*/;
condition=/*%FSM<CONDITION""">*/"( (count needUpdate_objects) > 0 && (time-_lastNeedUpdate>10) )"/*%FSM</CONDITION""">*/;
action=/*%FSM<ACTION""">*/"_lastNeedUpdate = time;"/*%FSM</ACTION""">*/;
};
/*%FSM</LINK>*/
/*%FSM<LINK "true">*/
class true
{
priority = 0.000000;
to="general_cleanup";
precondition = /*%FSM<CONDPRECONDITION""">*/""/*%FSM</CONDPRECONDITION""">*/;
condition=/*%FSM<CONDITION""">*/"true"/*%FSM</CONDITION""">*/;
action=/*%FSM<ACTION""">*/""/*%FSM</ACTION""">*/;
};
/*%FSM</LINK>*/
/*%FSM<LINK "too_many_objects">*/
class too_many_objects
{
priority = 0.000000;
to="cleanup_objects";
precondition = /*%FSM<CONDPRECONDITION""">*/""/*%FSM</CONDPRECONDITION""">*/;
condition=/*%FSM<CONDITION""">*/"((time - _timeNem) > 60)"/*%FSM</CONDITION""">*/;
action=/*%FSM<ACTION""">*/"_timeNem = time;"/*%FSM</ACTION""">*/;
};
/*%FSM</LINK>*/
};
};
/*%FSM</STATE>*/
/*%FSM<STATE "cleanup_dead">*/
class cleanup_dead
{
name = "cleanup_dead";
init = /*%FSM<STATEINIT""">*/"diag_log (""CLEANUP: TOO MANY DEAD BODIES"");" \n
"" \n
"diag_log (""CLEANUP: PERFORMING BODY CLEANUP ON "" + str(_numDead) + "" BODIES"");" \n
"" \n
"_delQtyZ = 0;" \n
"_numZombie = {_x isKindOf ""zZombie_Base""} count allDead;" \n
"{" \n
" if (local _x) then {" \n
" if (_x isKindOf ""zZombie_Base"") then {" \n
" deleteVehicle _x;" \n
" _delQtyZ = _delQtyZ + 1;" \n
" } else {" \n
" _exists = _x in _deadBodies;" \n
" if(!_exists) then {" \n
" _deadBodies set [count _deadBodies,_x];" \n
" };" \n
" };" \n
" };" \n
"} forEach allDead;" \n
"" \n
"//Cleanup players" \n
"_body = objNull;" \n
"_delQtyP = 0;" \n
"_delDo = _numDead - _numZombie;" \n
"_delDo = ((_delDo min (count _deadBodies)) -1);" \n
"if (_delDo<1) then {_delDo=1};" \n
"for ""_i"" from 0 to _delDo do {" \n
" _body = _deadBodies select _i;" \n
" if(!isNil ""_body"") then {" \n
" _pos = getPosATL _body;" \n
" _sfx = nearestObject [_pos,""Sound_Flies""];" \n
" if (!(isNull _sfx)) then {" \n
" deleteVehicle _sfx;" \n
" };" \n
" deleteVehicle _body;" \n
" _delQtyP = _delQtyP + 1;" \n
" };" \n
" _deadBodies set [_i,""DEL""];" \n
"" \n
"//Let's move this into the body removal sequence so uncontrolled flies are removed only if corpses are cleaned" \n
"//Check Flies" \n
"_isOK=-1;" \n
"_dwUSOFC=0;" \n
"{" \n
" //_isOk = {!alive _x} count (nearestObjects [_x, [""CAManBase""], 2]);" \n
" _isOk = {!alive _x} count (_x nearEntities [[""CAManBase""], 2]);" \n
" if (_isOk>-1) then {" \n
" diag_log (""DW_DEBUG _isOK: "" + str(_isOK) );" \n
" };" \n
" if ((_isOk>-1) AND (isOK<1)) then {" \n
" //diag_log (""CLEANUP: DELETING A SOUND OF FLIES"");" \n
"_dwUSOFC=_dwUSOFC+1;" \n
" deleteVehicle _x;" \n
" diag_log (""CLEANUP: DELETED AN UNCONTROLLED SOUND OF FLIES:"" + str(_dwUSOFC) );" \n
" };" \n
"} forEach allMissionObjects ""Sound_Flies"";" \n
"" \n
"" \n
"//Let's move this into the body removal sequence so uncontrolled fireplaces are removed only if corpses are cleaned" \n
"//clean fireplaces" \n
"_dwUFPC=0;" \n
"{" \n
" if (local _x) then {" \n
" //diag_log (""CLEANUP: DELETING A UNCONTROLLED FIREPLACE"");" \n
" deleteVehicle _x;" \n
"_dwUFPC=_dwUFPC+1;" \n
" diag_log (""CLEANUP: DELETED AN UNCONTROLLED FIREPLACE:"" + str(_dwUFPC) );" \n
" };" \n
"} forEach allMissionObjects ""Land_Fire_DZ"";" \n
"" \n
"};" \n
"_deadBodies = _deadBodies - [""DEL""];" \n
"" \n
"diag_log (""CLEANUP: DELETED "" + str(_delQtyP) + "" PLAYER BODIES AND "" + str(_delQtyZ) + "" BODIES"");" \n
""/*%FSM</STATEINIT""">*/;
precondition = /*%FSM<STATEPRECONDITION""">*/""/*%FSM</STATEPRECONDITION""">*/;
class Links
{
/*%FSM<LINK "true">*/
class true
{
priority = 0.000000;
to="general_cleanup";
precondition = /*%FSM<CONDPRECONDITION""">*/""/*%FSM</CONDPRECONDITION""">*/;
condition=/*%FSM<CONDITION""">*/"true"/*%FSM</CONDITION""">*/;
action=/*%FSM<ACTION""">*/""/*%FSM</ACTION""">*/;
};
/*%FSM</LINK>*/
};
};
/*%FSM</STATE>*/
/*%FSM<STATE "cleanup_objects">*/
class cleanup_objects
{
name = "cleanup_objects";
init = /*%FSM<STATEINIT""">*/"_missionObjs = allMissionObjects ""WeaponHolder"";" \n
"_qty = count _missionObjs;" \n
"" \n
"//diag_log (""CLEANUP: PERFORMING ITEM CLEANUP: TOTAL "" + str(_qty) + "" LOOT BAGS"");" \n
"_delQty = 0;" \n
"{" \n
" if (local _x) then {" \n
" _keep = _x getVariable [""permaLoot"",false];" \n
" _nearby = {isPlayer _x} count (_x nearEntities [[""CAManBase""], 100]);" \n
" if ( (!_keep) && (_nearby==0) ) then {" \n
" deleteVehicle _x;" \n
" _delQty = _delQty + 1;" \n
" };" \n
" };" \n
"} forEach _missionObjs;" \n
"if (_delQty > 0) then {" \n
" diag_log (""CLEANUP: DELETED "" + str(_delQty) + "" LOOT BAGS"");" \n
"};" \n
""/*%FSM</STATEINIT""">*/;
precondition = /*%FSM<STATEPRECONDITION""">*/""/*%FSM</STATEPRECONDITION""">*/;
class Links
{
/*%FSM<LINK "true">*/
class true
{
priority = 0.000000;
to="general_cleanup";
precondition = /*%FSM<CONDPRECONDITION""">*/""/*%FSM</CONDPRECONDITION""">*/;
condition=/*%FSM<CONDITION""">*/"true"/*%FSM</CONDITION""">*/;
action=/*%FSM<ACTION""">*/""/*%FSM</ACTION""">*/;
};
/*%FSM</LINK>*/
};
};
/*%FSM</STATE>*/
/*%FSM<STATE "sync_the_time">*/
class sync_the_time
{
name = "sync_the_time";
init = /*%FSM<STATEINIT""">*/"//Send request" \n
"_key = ""CHILD:307:"";" \n
"_result = [_key] call server_hiveReadWrite;" \n
"_outcome = _result select 0;" \n
"if(_outcome == ""PASS"") then {" \n
" _date = _result select 1; " \n
" _dateNum = dateToNumber(_date); " \n
" _diff = ( _dateNum - dateToNumber (date) )*365*24*60;" \n
" if ( abs(_diff)>5 ) then {" \n
" setDate _date;" \n
" dayzSetDate = _date;" \n
" publicVariable ""dayzSetDate"";" \n
" diag_log (""TIME SYNC: Local Time set to "" + str(_date));" \n
"};" \n
"};" \n
""/*%FSM</STATEINIT""">*/;
precondition = /*%FSM<STATEPRECONDITION""">*/""/*%FSM</STATEPRECONDITION""">*/;
class Links
{
/*%FSM<LINK "true">*/
class true
{
priority = 0.000000;
to="general_cleanup";
precondition = /*%FSM<CONDPRECONDITION""">*/""/*%FSM</CONDPRECONDITION""">*/;
condition=/*%FSM<CONDITION""">*/"true"/*%FSM</CONDITION""">*/;
action=/*%FSM<ACTION""">*/""/*%FSM</ACTION""">*/;
};
/*%FSM</LINK>*/
};
};
/*%FSM</STATE>*/
/*%FSM<STATE "general_cleanup">*/
class general_cleanup
{
name = "general_cleanup";
init = /*%FSM<STATEINIT""">*/"//Clean groups" \n
"{" \n
" //diag_log (""CLEANUP: CHECKING GROUP WITH "" + str(count units _x) + "" UNITS"");" \n
" if (count units _x==0) then {" \n
" deleteGroup _x;" \n
" //diag_log (""CLEANUP: DELETING A GROUP"");" \n
" };" \n
"} forEach allGroups;" \n
"" \n
"/*" \n
"//Check for Ammobox" \n
" {" \n
" if(!(_x isKindOf ""WeaponHolder"")) then {" \n
" diag_log (""CLEANUP: DELETING AN AMMOBOX "" + (typeOf _x));" \n
" deleteVehicle _x;" \n
" };" \n
" } forEach allMissionObjects ""ReammoBox"";" \n
"*/" \n
"" \n
"//Check for hackers" \n
" {" \n
" if(vehicle _x != _x && !(vehicle _x in _safety) && (typeOf vehicle _x) != ""ParachuteWest"") then {" \n
" diag_log (""CLEANUP: KILLING A HACKER "" + (name _x) + "" "" + str(_x) + "" IN "" + (typeOf vehicle _x));" \n
" (vehicle _x) setDamage 1;" \n
" _x setDamage 1;" \n
" };" \n
" } forEach allUnits;" \n
"" \n
"/*" \n
"//Let's move this into the body removal sequence so uncontrolled flies are removed only if corpses are cleaned" \n
"//Check Flies" \n
"_isOK=-1;" \n
"_dwUSOFC=0;" \n
"{" \n
" //_isOk = {!alive _x} count (nearestObjects [_x, [""CAManBase""], 2]);" \n
" _isOk = {!alive _x} count (_x nearEntities [[""CAManBase""], 2]);" \n
" if (_isOk>-1) then {" \n
" diag_log (""DW_DEBUG _isOK: "" + str(_isOK) );" \n
" };" \n
" if ((_isOk>-1) AND (isOK<1)) then {" \n
" //diag_log (""CLEANUP: DELETING A SOUND OF FLIES"");" \n
"_dwUSOFC=_dwUSOFC+1;" \n
" deleteVehicle _x;" \n
" diag_log (""CLEANUP: DELETED AN UNCONTROLLED SOUND OF FLIES:"" + str(_dwUSOFC) );" \n
" };" \n
"} forEach allMissionObjects ""Sound_Flies"";" \n
"*/" \n
"" \n
"dayz_serverObjectMonitor = _safety;"/*%FSM</STATEINIT""">*/;
precondition = /*%FSM<STATEPRECONDITION""">*/""/*%FSM</STATEPRECONDITION""">*/;
class Links
{
/*%FSM<LINK "true">*/
class true
{
priority = 0.000000;
to="waiting";
precondition = /*%FSM<CONDPRECONDITION""">*/""/*%FSM</CONDPRECONDITION""">*/;
condition=/*%FSM<CONDITION""">*/"true"/*%FSM</CONDITION""">*/;
action=/*%FSM<ACTION""">*/""/*%FSM</ACTION""">*/;
};
/*%FSM</LINK>*/
};
};
/*%FSM</STATE>*/
/*%FSM<STATE "prepare">*/
class prepare
{
name = "prepare";
init = /*%FSM<STATEINIT""">*/"diag_log (""CLEANUP: INITIALIZING CLEANUP SCRIPT"");" \n
"" \n
"_safety = dayz_serverObjectMonitor;" \n
"" \n
"_lastUpdate = time;" \n
"_timeNem = time;" \n
"_deadBodies = [];" \n
"_lastNeedUpdate = time;" \n
"_maxBodies = 15;" \n
""/*%FSM</STATEINIT""">*/;
precondition = /*%FSM<STATEPRECONDITION""">*/""/*%FSM</STATEPRECONDITION""">*/;
class Links
{
/*%FSM<LINK "true">*/
class true
{
priority = 0.000000;
to="waiting";
precondition = /*%FSM<CONDPRECONDITION""">*/""/*%FSM</CONDPRECONDITION""">*/;
condition=/*%FSM<CONDITION""">*/"true"/*%FSM</CONDITION""">*/;
action=/*%FSM<ACTION""">*/""/*%FSM</ACTION""">*/;
};
/*%FSM</LINK>*/
};
};
/*%FSM</STATE>*/
/*%FSM<STATE "update_objects">*/
class update_objects
{
name = "update_objects";
init = /*%FSM<STATEINIT""">*/"diag_log format[""DEBUG: needUpdate_objects=%1"",needUpdate_objects];" \n
"{" \n
"// _x setVariable [""needUpdate"",false,true];" \n
" needUpdate_objects = needUpdate_objects - [_x];" \n
" [_x,""all""] spawn server_updateObject;" \n
"" \n
"} forEach needUpdate_objects;" \n
""/*%FSM</STATEINIT""">*/;
precondition = /*%FSM<STATEPRECONDITION""">*/""/*%FSM</STATEPRECONDITION""">*/;
class Links
{
/*%FSM<LINK "true">*/
class true
{
priority = 0.000000;
to="general_cleanup";
precondition = /*%FSM<CONDPRECONDITION""">*/""/*%FSM</CONDPRECONDITION""">*/;
condition=/*%FSM<CONDITION""">*/"true"/*%FSM</CONDITION""">*/;
action=/*%FSM<ACTION""">*/""/*%FSM</ACTION""">*/;
};
/*%FSM</LINK>*/
};
};
/*%FSM</STATE>*/
};
initState="init";
finalStates[] =
{
};
};
/*%FSM</COMPILE>*/

View File

@@ -0,0 +1,213 @@
[]execVM "\z\addons\dayz_server\system\s_fps.sqf"; //server monitor FPS (writes each ~181s diag_fps+181s diag_fpsmin*)
dayz_versionNo = getText(configFile >> "CfgMods" >> "DayZ" >> "version");
dayz_hiveVersionNo = getNumber(configFile >> "CfgMods" >> "DayZ" >> "hiveVersion");
if ((count playableUnits == 0) and !isDedicated) then {
isSinglePlayer = true;
};
waitUntil{initialized};
diag_log "HIVE: Starting";
//Stream in objects
/* STREAM OBJECTS */
//Send the key
_key = format["CHILD:302:%1:",dayZ_instance];
_data = "HiveEXT" callExtension _key;
diag_log "HIVE: Request sent";
//Process result
_result = call compile format ["%1",_data];
_status = _result select 0;
_myArray = [];
if (_status == "ObjectStreamStart") then {
_val = _result select 1;
//Stream Objects
diag_log ("HIVE: Commence Object Streaming...");
for "_i" from 1 to _val do {
_data = "HiveEXT" callExtension _key;
_result = call compile format ["%1",_data];
_status = _result select 0;
_myArray set [count _myArray,_result];
//diag_log ("HIVE: Loop ");
};
//diag_log ("HIVE: Streamed " + str(_val) + " objects");
};
_countr = 0;
_totalvehicles = 0;
{
//Parse Array
_countr = _countr + 1;
_idKey = _x select 1;
_type = _x select 2;
_ownerID = _x select 3;
_dir = (_x select 4) select 0;
_pos = (_x select 4) select 1;
_intentory= _x select 5;
_hitPoints= _x select 6;
_fuel = _x select 7;
_damage = _x select 8;
if (_damage < 1) then {
diag_log ("OBJ: " + str(_idKey) + _type);
//Create it
_object = createVehicle [_type, _pos, [], 0, "CAN_COLLIDE"];
_object setVariable ["lastUpdate",time];
_object setVariable ["ObjectID", _idKey, true];
_object setVariable ["CharacterID", _ownerID, true];
clearWeaponCargoGlobal _object;
clearMagazineCargoGlobal _object;
if (_object isKindOf "TentStorage") then {
_pos set [2,0];
_object setpos _pos;
};
_object setdir _dir;
_object setDamage _damage;
if (count _intentory > 0) then {
//Add weapons
_objWpnTypes = (_intentory select 0) select 0;
_objWpnQty = (_intentory select 0) select 1;
_countr = 0;
{
_isOK = isClass(configFile >> "CfgWeapons" >> _x);
if (_isOK) then {
_block = getNumber(configFile >> "CfgWeapons" >> _x >> "stopThis") == 1;
if (!_block) then {
_object addWeaponCargoGlobal [_x,(_objWpnQty select _countr)];
};
};
_countr = _countr + 1;
} forEach _objWpnTypes;
//Add Magazines
_objWpnTypes = (_intentory select 1) select 0;
_objWpnQty = (_intentory select 1) select 1;
_countr = 0;
{
_isOK = isClass(configFile >> "CfgMagazines" >> _x);
if (_isOK) then {
_block = getNumber(configFile >> "CfgMagazines" >> _x >> "stopThis") == 1;
if (!_block) then {
_object addMagazineCargoGlobal [_x,(_objWpnQty select _countr)];
};
};
_countr = _countr + 1;
} forEach _objWpnTypes;
//Add Backpacks
_objWpnTypes = (_intentory select 2) select 0;
_objWpnQty = (_intentory select 2) select 1;
_countr = 0;
{
_isOK = isClass(configFile >> "CfgVehicles" >> _x);
if (_isOK) then {
_block = getNumber(configFile >> "CfgVehicles" >> _x >> "stopThis") == 1;
if (!_block) then {
_object addBackpackCargoGlobal [_x,(_objWpnQty select _countr)];
};
};
_countr = _countr + 1;
} forEach _objWpnTypes;
};
if (_object isKindOf "AllVehicles") then {
{
_selection = _x select 0;
_dam = _x select 1;
if (_selection in dayZ_explosiveParts and _dam > 0.8) then {_dam = 0.8};
[_object,_selection,_dam] call object_setFixServer;
} forEach _hitpoints;
_object setvelocity [0,0,1];
_object setFuel _fuel;
if (getDammage _object == 1) then {
_position = ([(getPosATL _object),0,100,10,0,500,0] call BIS_fnc_findSafePos);
_object setPosATL _position;
};
_id = _object spawn fnc_vehicleEventHandler;
_totalvehicles = _totalvehicles + 1;
};
//Monitor the object
//_object enableSimulation false;
dayz_serverObjectMonitor set [count dayz_serverObjectMonitor,_object];
};
} forEach _myArray;
// # END OF STREAMING #
//Set the Time
//Send request
_key = "CHILD:307:";
_result = [_key] call server_hiveReadWrite;
_outcome = _result select 0;
if(_outcome == "PASS") then {
_date = _result select 1;
if(isDedicated) then {
setDate _date;
dayzSetDate = _date;
publicVariable "dayzSetDate";
};
diag_log ("HIVE: Local Time set to " + str(_date));
};
createCenter civilian;
if (isDedicated) then {
endLoadingScreen;
};
hiveInUse = false;
if (isDedicated) then {
_id = [] execFSM "\z\addons\dayz_server\system\server_cleanup.fsm";
};
// Custom Configs
if(isnil "MaxVehicleLimit") then {
MaxVehicleLimit = 50;
};
if(isnil "MaxHeliCrashes") then {
MaxHeliCrashes = 5;
};
if(isnil "MaxDynamicDebris") then {
MaxDynamicDebris = 100;
};
// Custon Configs End
// spawn_vehicles
_vehLimit = MaxVehicleLimit - _totalvehicles;
diag_log ("HIVE: Spawning # of Vehicles: " + str(_vehLimit));
if(_vehLimit > 0) then {
for "_x" from 1 to _vehLimit do {
_id = [] spawn spawn_vehicles; // Needs setup
waitUntil{scriptDone _id};
};
};
// spawn_roadblocks
for "_x" from 1 to MaxDynamicDebris do {
_id = [] spawn spawn_roadblocks;
//waitUntil{scriptDone _id};
};
//Spawn crashed helos
for "_x" from 1 to MaxHeliCrashes do {
_id = [] spawn spawn_heliCrash;
//waitUntil{scriptDone _id};
};
// Allow connection after road debris spawns
allowConnection = true;