Update server_functions

The protective box is not needed on Chernarus.

If other maps need it we are better off spawning a permanent box around
the debug area once, instead of constantly creating new boxes every time
a player logs in.
This commit is contained in:
ebaydayz
2016-03-25 21:24:43 -04:00
parent 145fbf093f
commit e435d41f6c
28 changed files with 384 additions and 1013 deletions

View File

@@ -62,7 +62,7 @@ _nbpatchs = 0;
_houseType = _x select 0;
_houseList = _x select 1;
if (count _houseList == 0) then {
_houseList = (getMarkerpos "center") nearObjects [_houseType, 20000];
_houseList = dayz_centerMarker nearObjects [_houseType, 20000];
}
else {
_tmp = [];

View File

@@ -314,7 +314,7 @@ fa_checkVehicles = {
// move object to map boundary if it's out of map
fa_staywithus = {
private["_a","_dir","_px","_py","_b","_cx","_cy","_k", "_SWcorner", "_NEcorner"];
private["_a","_dir","_px","_py","_cx","_cy","_k", "_SWcorner", "_NEcorner"];
_dir = +(_this select 0); // current position of player / vehicle
_a = +(_this select 1); // current position of player / vehicle
@@ -328,10 +328,9 @@ fa_staywithus = {
// first : put object close to the map boundary, following an axis to the center of the map.
_px = _a select 0;
_py = _a select 1;
_b = getMarkerpos "center";
_cx = (_b select 0) - _px; if (_cx == 0) then { _cx = 0.00001; };
_cy = (_b select 1) - _py; if (_cy == 0) then { _cy = 0.00001; };
_cx = (dayz_centerMarker select 0) - _px; if (_cx == 0) then { _cx = 0.00001; };
_cy = (dayz_centerMarker select 1) - _py; if (_cy == 0) then { _cy = 0.00001; };
if (_px <= (_SWcorner select 0)) then { _py = _py + (1 + (_SWcorner select 0) - _px) / _cx * _cy; _px = 1 + (_SWcorner select 0); };
if (_py <= (_SWcorner select 1)) then { _px = _px + (1 + (_SWcorner select 1) - _py) / _cy * _cx; _py = 1 + (_SWcorner select 1); };
if (_px >= (_NEcorner select 0)) then { _py = _py + ((_NEcorner select 0) - 1 - _px) / _cx * _cy; _px = (_NEcorner select 0) - 1; };

View File

@@ -0,0 +1,13 @@
private ["_vehicle","_player","_attached"];
if (DZE_HeliLift) then {
_vehicle = _this select 0;
_player = _this select 2;
_attached = _vehicle getVariable ["attached",false];
if (typeName _attached == "OBJECT") then {
_player action ["eject",_vehicle];
detach _vehicle;
_vehicle setVariable ["attached",false,true];
_attached setVariable ["hasAttached",false,true];
};
};

View File

@@ -0,0 +1,26 @@
private ["_player","_obj","_objectID","_objectUID","_statusText","_puid","_status","_clientID","_type"];
_player = _this select 0;
_obj = _this select 1;
_status = _this select 2;
_type = typeOf _obj;
if (isNull _player) then {diag_log "ERROR: server_logUnlockLockEvent called with Null player object";};
_clientID = owner _player;
_puid = [_player] call FNC_GetPlayerUID;
_statusText = if (_status) then {"LOCKED"} else {"UNLOCKED"};
if (!isNull _obj) then {
_objectID = _obj getVariable ["ObjectID","0"];
_objectUID = _obj getVariable ["ObjectUID","0"];
if (_status) then {[_obj,"gear"] call server_updateObject;};
diag_log format["%6 %5: ID:%1 UID:%2 BY %3(%4)",_objectID,_objectUID,name _player,_puid,_statusText,_type];
dze_waiting = "success";
_clientID publicVariableClient "dze_waiting";
} else {
diag_log format["ERROR: %4 BY %1(%2) IS NULL AND COULD NOT BE %3 (THIS SHOULD NOT HAPPEN)",name _player,_puid,_statusText,_type];
dze_waiting = "fail";
_clientID publicVariableClient "dze_waiting";
};

View File

@@ -25,7 +25,7 @@ _object setVariable ["ObjectUID", _uid,true];
if (DZE_GodModeBase) then {
_object addEventHandler ["HandleDamage", {false}];
}else{
_object addMPEventHandler ["MPKilled",{_this call object_handleServerKilled;}];
_object addMPEventHandler ["MPKilled",{_this call vehicle_handleServerKilled;}];
};
// Test disabling simulation server side on buildables only.
_object enableSimulation false;

View File

@@ -24,9 +24,7 @@ if(_donotusekey) then {
diag_log ("PUBLISH: Attempt " + str(_object));
_dir = _worldspace select 0;
_location = _worldspace select 1;
//Generate UID test using time
_uid = _worldspace call dayz_objectUID3;
_uid = _worldspace call dayz_objectUID2;
//Send request
_key = format["CHILD:308:%1:%2:%3:%4:%5:%6:%7:%8:%9:",dayZ_instance, _class, 0 , _characterID, _worldspace, [], [], 1,_uid];

View File

@@ -14,9 +14,7 @@ if(!_isOK || isNull _object) exitWith { diag_log ("HIVE-pv3: Vehicle does not ex
diag_log ("PUBLISH: Attempt " + str(_object));
_dir = _worldspace select 0;
_location = _worldspace select 1;
//Generate UID test using time
_uid = _worldspace call dayz_objectUID3;
_uid = _worldspace call dayz_objectUID2;
//Send request
_key = format["CHILD:308:%1:%2:%3:%4:%5:%6:%7:%8:%9:",dayZ_instance, _class, 0 , _characterID, _worldspace, [], [], 1,_uid];

View File

@@ -29,7 +29,7 @@ Author:
#define OBJECT_RADIUS_MIN 8
#define OBJECT_RADIUS_MAX 13
#define SEARCH_CENTER getMarkerPos "center"
#define SEARCH_CENTER dayz_centerMarker
#define SEARCH_RADIUS 7500
#define SEARCH_EXPRESSION "(5 * forest) + (4 * trees) + (3 * meadow) - (20 * houses) - (30 * sea)" //+ (3 * meadow) - (20 * houses) - (30 * sea)
#define SEARCH_PRECISION 30

View File

@@ -66,7 +66,7 @@ _object setVariable ["ObjectUID", _uid,true];
if (DZE_GodModeBase) then {
_object addEventHandler ["HandleDamage", {false}];
}else{
_object addMPEventHandler ["MPKilled",{_this call object_handleServerKilled;}];
_object addMPEventHandler ["MPKilled",{_this call vehicle_handleServerKilled;}];
};
// Test disabling simulation server side on buildables only.
_object enableSimulation false;

View File

@@ -25,7 +25,7 @@ if ((typeName _objectID == "SCALAR") || (typeName _objectUID == "SCALAR")) then
_objectUID = nil;
};
if (!((typeOf _object) in ["ParachuteWest","ParachuteC"]) && !locked _object) then {
if (!((typeOf _object) in DZE_safeVehicle) && !locked _object) then {
//diag_log format["Object: %1, ObjectID: %2, ObjectUID: %3",_object,_objectID,_objectUID];
if (!(_objectID in dayz_serverIDMonitor) && isNil {_objectUID}) then {
//force fail
@@ -161,7 +161,7 @@ _object_killed = {
_key call server_hiveWrite;
diag_log ("HIVE: WRITE: "+ str(_key));
if ((typeOf _object) in DayZ_removableObjects) then {[_objectID,_objectUID] call server_deleteObj;};
if (((typeOf _object) in DayZ_removableObjects) or ((typeOf _object) in DZE_isRemovable)) then {[_objectID,_objectUID] call server_deleteObj;};
};
_object_maintenance = {

View File

@@ -0,0 +1,19 @@
private ["_position","_veh","_istoomany"];
waitUntil {!isNil "BIS_fnc_selectRandom"};
_position = RoadList call BIS_fnc_selectRandom;
_position = _position modelToWorld [0,0,0];
waitUntil {!isNil "BIS_fnc_findSafePos"};
_position = [_position,5,20,5,0,2000,0] call BIS_fnc_findSafePos;
if ((count _position) == 2) then {
_istoomany = _position nearObjects ["All",5];
if ((count _istoomany) > 0) exitWith {};
_veh = createVehicle ["Supply_Crate_DZE",_position, [], 0, "CAN_COLLIDE"];
_veh enableSimulation false;
_veh setDir round(random 360);
_veh setPos _position;
_veh setVariable ["ObjectID","1",true];
};

View File

@@ -0,0 +1,18 @@
private ["_position","_veh","_istoomany","_spawnveh","_positions"];
_position = [dayz_centerMarker,0,(HeliCrashArea*0.75),10,0,2000,0] call BIS_fnc_findSafePos;
if ((count _position) == 2) then {
_positions = selectBestPlaces [_position, 500, "(1 + forest) * (1 + hills) * (1 - houses) * (1 - sea)", 10, 5];
_position = (_positions call BIS_fnc_selectRandom) select 0;
_istoomany = _position nearObjects ["All",10];
if (((count _istoomany) > 0) or (isOnRoad _position)) exitWith {};
_spawnveh = ["Iron_Vein_DZE","Iron_Vein_DZE","Iron_Vein_DZE","Iron_Vein_DZE","Iron_Vein_DZE","Silver_Vein_DZE","Silver_Vein_DZE","Silver_Vein_DZE","Gold_Vein_DZE","Gold_Vein_DZE"] call BIS_fnc_selectRandom;
//diag_log("DEBUG: Spawning a crashed " + _spawnveh + " with " + _spawnloot + " at " + str(_position));
_veh = createVehicle [_spawnveh,_position, [], 0, "CAN_COLLIDE"];
_veh enableSimulation false;
_veh setDir round(random 360);
_veh setPos _position;
_veh setVariable ["ObjectID","1",true];
};

View File

@@ -0,0 +1,22 @@
private ["_position","_veh","_istoomany","_spawnveh"];
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 {
_istoomany = _position nearObjects ["All",5];
if ((count _istoomany) > 0) exitWith {};
waitUntil {!isNil "BIS_fnc_selectRandom"};
_spawnveh = DZE_isWreck call BIS_fnc_selectRandom;
_veh = createVehicle [_spawnveh,_position, [], 0, "CAN_COLLIDE"];
_veh enableSimulation false;
_veh setDir round(random 360);
_veh setPos _position;
_veh setVariable ["ObjectID","1",true];
};

View File

@@ -0,0 +1,128 @@
private ["_random","_lastIndex","_weights","_index","_vehicle","_velimit","_qty","_isAir","_isShip","_position","_dir","_istoomany","_veh","_objPosition","_iClass","_itemTypes","_cntWeights","_itemType","_num","_allCfgLoots"];
if (isNil "spawn_vehicles_init") then {
spawn_vehicles_init = "done";
// Get all buildings and roads only once. Very taxing, but only on first startup
buildingList = [];
{
if (DZE_MissionLootTable) then {
if (isClass (missionConfigFile >> "CfgLoot" >> "Buildings" >> (typeOf _x))) then {buildingList set [count buildingList,_x];};
} else {
if (isClass (configFile >> "CfgLoot" >> "Buildings" >> (typeOf _x))) then {buildingList set [count buildingList,_x];};
};
} count (dayz_centerMarker nearObjects ["building",DynamicVehicleArea]);
roadList = dayz_centerMarker nearRoads DynamicVehicleArea;
};
while {count AllowedVehiclesList > 0} do {
// BIS_fnc_selectRandom replaced because the index may be needed to remove the element
_index = floor random count AllowedVehiclesList;
_random = AllowedVehiclesList select _index;
_vehicle = _random select 0;
_velimit = _random select 1;
_qty = {_x == _vehicle} count serverVehicleCounter;
// If under limit allow to proceed
if (_qty <= _velimit) exitWith {};
// vehicle limit reached, remove vehicle from list
// since elements cannot be removed from an array, overwrite it with the last element and cut the last element of (as long as order is not important)
_lastIndex = (count AllowedVehiclesList) - 1;
if (_lastIndex != _index) then {AllowedVehiclesList set [_index, AllowedVehiclesList select _lastIndex];};
AllowedVehiclesList resize _lastIndex;
};
if (count AllowedVehiclesList == 0) then {
diag_log "DEBUG: unable to find suitable vehicle to spawn";
} else {
// add vehicle to counter for next pass
serverVehicleCounter set [count serverVehicleCounter,_vehicle];
// Find Vehicle Type to better control spawns
_isAir = _vehicle isKindOf "Air";
_isShip = _vehicle isKindOf "Ship";
if (_isShip or _isAir) then {
if (_isShip) then {
// Spawn anywhere on coast on water
waitUntil {!isNil "BIS_fnc_findSafePos"};
_position = [dayz_centerMarker,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_findSafePos"};
_position = [dayz_centerMarker,0,DynamicVehicleArea,10,0,2000,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 {};
_veh = createVehicle [_vehicle, _position, [], 0, "CAN_COLLIDE"];
_veh setDir _dir;
_veh setPos _position;
_objPosition = getPosATL _veh;
clearWeaponCargoGlobal _veh;
clearMagazineCargoGlobal _veh;
// _veh setVehicleAmmo DZE_vehicleAmmo;
// Add 0-3 loots to vehicle using random cfgloots
_num = floor(random 4);
_allCfgLoots = ["Trash","ZombieCivilian","Consumable","Generic","MedicalLow","Military","ZombiePolice","ZombieHunter","ZombieWorker","clothes","militaryclothes","specialclothes","Trash"];
for "_x" from 1 to _num do {
_iClass = _allCfgLoots call BIS_fnc_selectRandom;
_itemTypes = [];
if (DZE_MissionLootTable) then{
{
_itemTypes set [count _itemTypes, _x select 2]
} count getArray(missionConfigFile >> "CfgLoot" >> "Groups" >> _iClass);
}
else {
{
_itemTypes set [count _itemTypes, _x select 2]
} count getArray(configFile >> "CfgLoot" >> "Groups" >> _iClass);
};
// Need to use new loot chances format
/*
_index = dayz_CLBase find _iClass;
_weights = dayz_CLChances select _index;
_cntWeights = count _weights;
_index = floor(random _cntWeights);
_index = _weights select _index;
_itemType = _itemTypes select _index;
_veh addMagazineCargoGlobal [_itemType,1];
//diag_log("DEBUG: spawed loot inside vehicle " + str(_itemType));
*/
};
[_veh,[_dir,_objPosition],_vehicle,true,"0"] call server_publishVeh;
};
};

View File

@@ -16,8 +16,7 @@ while {_counter < _amount} do {
//_radius = 0;
_method = "CAN_COLLIDE";
//_createSafePos = getMarkerPos "center";
_position = [getMarkerPos "center",1,6500,1] call fn_selectRandomLocation;
_position = [dayz_centerMarker,1,6500,1] call fn_selectRandomLocation;
//Create Zed
_agent = createAgent [_type, _position, [], 1, _method];