mirror of
https://github.com/EpochModTeam/DayZ-Epoch.git
synced 2025-12-17 09:10:27 +03:00
Server Done I Think
This commit is contained in:
96
SQF/dayz_server/compile/fa_antiwallhack.sqf
Normal file
96
SQF/dayz_server/compile/fa_antiwallhack.sqf
Normal file
@@ -0,0 +1,96 @@
|
||||
/*
|
||||
Created exclusively for ArmA2:OA - DayZMod.
|
||||
Please request permission to use/alter/distribute from project leader (R4Z0R49) AND the author (facoptere@gmail.com)
|
||||
*/
|
||||
|
||||
private ["_antiwallhack","_houseType","_houseList","_tmp","_patchList","_house","_o","_nbhouses","_nbpatchs","_pos"];
|
||||
|
||||
_antiwallhack=[
|
||||
[
|
||||
"Land_A_Hospital", // building type
|
||||
[
|
||||
[6414.05,2760.21,0], [6817.3,2702.03,0], [10517.9,2287.55,0], [11956.7,9120.21,0] // optional precomputed building positions
|
||||
],
|
||||
[
|
||||
[17.6182,-1.8418,3.23178,"Land_CncBlock_D",0],[15.7192,-1.84277,3.22177,"Land_CncBlock_D",0],[-17.4,-0.38,-4.25,"Land_CncBlock_D",90],[-17.4,2.25,-4.25,"Land_CncBlock_D",90],[-17.4,4.22,-4.25,"Land_CncBlock_D",90],[-17.42,-3.55,-7.63,"Land_CncBlock_D",90],[-13.27,2.83,-4.25,"Fort_RazorWire",180],[-13.23,4.28,-4.25,"Fort_RazorWire",180],[-16.81,1.38,-4.25,"Hedgehog",85],[-16.82,-0.6,-4.25,"Hedgehog",90],[-7.45,4.26,-4.25,"Fort_RazorWire",180] // what to add on building (coordinates/type/angle)
|
||||
]
|
||||
],
|
||||
[
|
||||
"Land_HouseB_Tenement",
|
||||
[
|
||||
[6855.66,2496.78,0]
|
||||
],
|
||||
[
|
||||
[-9.66602,7.66602,18.3236,"Fort_RazorWire",0], [-1.30273,7.66602,18.3236,"Fort_RazorWire",0], [-9.66602,0.814453,18.3236,"Fort_RazorWire",0], [-1.30273,0.814453,18.3236,"Fort_RazorWire",0], [-15.0029,4.18359,18.3236,"Fort_RazorWire",90], [3.62109,3.95117,18.3236,"Fort_RazorWire",270], [-7.42,8.15,-20.57,"Fort_RazorWire",180], [-4.67,9.92,-21.55,"Fort_RazorWire",180]
|
||||
]
|
||||
],
|
||||
[
|
||||
"Land_A_Office02",
|
||||
[[6552.96,2807.47,0], [7036.05,2526.13,0], [10028.6,1832.52,0]],
|
||||
[
|
||||
[2.17627, 1.98828, 5.31387, "Land_CncBlock_D" , 0], [2.85547, 3.02246, 5.38394, "Land_CncBlock_D" , 0], [-15.7412, 3.98145, 5.38394, "Land_CncBlock_D" , 270], [-20.2915, 4.01563, 5.35391, "Land_CncBlock_D" , 90], [-20.291, 1.22559, 5.36392, "Land_CncBlock_D" , 90], [-19.0527, -0.318359, 5.38394, "Land_CncBlock_D" , 0], [-16.6426, -0.321289, 5.38394, "Land_CncBlock_D" , 0], [-15.4575, 1.01563, 5.35391, "Land_CncBlock_D" , 270], [-16.7344, 5.30762, 5.38394, "Land_CncBlock_D" , 180], [-19.0361, 5.30859, 5.38394, "Land_CncBlock_D" , 180]
|
||||
]
|
||||
],
|
||||
[
|
||||
"Land_A_Office01",
|
||||
[[3804.1,8924.83,-0.15], [10481.5,2358.45,0], [12742.4,9593.23,0]],
|
||||
[
|
||||
[0.837891, -1.13086, 5.93463, "Land_CncBlock_D", 90], [2.30957, -2.65918, 6.02472, "Land_CncBlock_D", 0], [3.68457, -1.2168, 6.06476, "Land_CncBlock_D", 270], [2.36914, -1.09863, 6.01471, "Land_CncBlock_D", 225], [2.4043, 0.155273, 6.14484, "Land_CncBlock_D", 180], [2.18359, -1.36035, 6.01471, "Land_CncBlock_D", 135]
|
||||
]
|
||||
],
|
||||
[
|
||||
"Land_A_statue01",
|
||||
[[3796.36,8838.01,0], [6531.07,2804.09,0], [6811.04,2455.16,0]],
|
||||
[
|
||||
[1.50049,2.14844,-3.6926,"Land_CncBlock_D",180], [2.86523,0.0966797,-3.69263,"Land_CncBlock_D",270], [1.38232,-2.17578,-3.69305,"Land_CncBlock_D",0]
|
||||
]
|
||||
],
|
||||
[
|
||||
"Land_Barn_Metal",
|
||||
[[2860.45,9746.05,0.682495],[4565.07,4528.81,0.199997], [6339.55,7693.31,0.0499878],[11329.8,6646.15,0.331261]],
|
||||
[
|
||||
[7.02,17.13,-5.74,"Misc_TyreHeap",36], [-5.4,7.85,-5.44,"SKODAWreck",181], [-7.5,8.87,-5.44,"SKODAWreck",181], [-0.99,-9.31,-5.44,"UralWreck",320],
|
||||
[8.33,8.43,-5.44,"datsun01Wreck",176], [4.13,10.16,-5.44,"SKODAWreck",176], [-7.21,-15.37,-5.44,"SKODAWreck",8], [3.3,15.19,-5.44,"UralWreck",210],
|
||||
[-5.76,12.87,-5.44,"SKODAWreck",150], [6.76,-6.86,-5.54,"LADAWreck",85], [-0.42,-21.9,-5.75,"Misc_TyreHeap",95]
|
||||
]
|
||||
]
|
||||
];
|
||||
|
||||
_nbhouses = 0;
|
||||
_nbpatchs = 0;
|
||||
{
|
||||
_houseType = _x select 0;
|
||||
_houseList = _x select 1;
|
||||
if (count _houseList == 0) then {
|
||||
_houseList = (getMarkerpos "center") nearObjects [_houseType, 20000];
|
||||
}
|
||||
else {
|
||||
_tmp = [];
|
||||
{
|
||||
_tmp set [count _tmp, _x nearestObject _houseType];
|
||||
} forEach _houseList;
|
||||
_houseList = _tmp;
|
||||
};
|
||||
_patchList = _x select 2;
|
||||
{
|
||||
_nbhouses = _nbhouses +1;
|
||||
_house = _x;
|
||||
{
|
||||
_pos = +(_x);
|
||||
_pos resize 3;
|
||||
_pos = _house modelToWorld _pos;
|
||||
_o = createVehicle [(_x select 3), _pos, [], 0, "CAN_COLLIDE"];
|
||||
_o setDir ((getDir _house)+(_x select 4));
|
||||
_o setPosATL _pos;
|
||||
diag_log [ typeOf _o, getPosATL _o, getDir _o, 0, nil];
|
||||
_nbpatchs = _nbpatchs +1;
|
||||
} forEach _patchList;
|
||||
//diag_log format["Found building %1 at %2", _houseType, getPosATL _house ];
|
||||
} forEach _houseList;
|
||||
} forEach _antiwallhack;
|
||||
|
||||
diag_log(format["%1: %2 buildings patched with %3 objects", __FILE__, _nbhouses, _nbpatchs]);
|
||||
|
||||
|
||||
|
||||
|
||||
18
SQF/dayz_server/compile/fa_fuelConsumption.sqf
Normal file
18
SQF/dayz_server/compile/fa_fuelConsumption.sqf
Normal file
@@ -0,0 +1,18 @@
|
||||
/*
|
||||
Not Used Test System
|
||||
*/
|
||||
|
||||
|
||||
//_vehicle = _this select 0;
|
||||
//_engineState = _this select 1;
|
||||
|
||||
_rate = getNumber (configFile >> "CfgVehicles" >> (typeOf (_this select 0)) >> "fuelconsumptionrate");
|
||||
|
||||
if (_this select 1) then {
|
||||
//[_vehicle, _rate] spawn {
|
||||
while {isEngineOn (_this select 0)} do {
|
||||
(_this select 0) setFuel ( Fuel (_this select 0) - (_this select 1));
|
||||
sleep 1;
|
||||
};
|
||||
//};
|
||||
};
|
||||
58
SQF/dayz_server/compile/fa_hiveMaintenance.hpp
Normal file
58
SQF/dayz_server/compile/fa_hiveMaintenance.hpp
Normal file
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
Created exclusively for ArmA2:OA - DayZMod.
|
||||
Please request permission to use/alter/distribute from project leader (R4Z0R49) AND the author (facoptere@gmail.com)
|
||||
*/
|
||||
|
||||
//// TENTS CHECK ////
|
||||
|
||||
// Proceed to empty tents check: extra empty tents will be ignored (tents won't be created on map)
|
||||
// comment this out if you don't want any check
|
||||
//#define EMPTY_TENTS_CHECK
|
||||
|
||||
// Max number of empty tents
|
||||
#define EMPTY_TENTS_GLOBAL_LIMIT 100
|
||||
|
||||
// Keep a least this number of empty tents per user
|
||||
#define EMPTY_TENTS_USER_LIMIT 3
|
||||
|
||||
|
||||
|
||||
//// OUT-OF-MAP CHECK ////
|
||||
|
||||
// Move out-of-map tents and other crafted/installed objects next to map boundary.
|
||||
//#define OBJECTS_FIX_OUTOFMAP
|
||||
|
||||
// Move out-of-map vehicle next to map boundary.
|
||||
//#define VEH_MAINTENANCE_FIX_OUTOFMAP
|
||||
|
||||
// Move out-of-map player next to map boundary during playerSetup
|
||||
//#define PLAYERS_FIX_OUTOFMAP
|
||||
|
||||
|
||||
|
||||
//// VEHICLE MAINTENANCE /////
|
||||
|
||||
// Ignore (don't create on map) vehicles not decribed in Cfg file, or outnumbered ones
|
||||
//#define VEH_MAINTENANCE_IGNORE_UNKNOWN
|
||||
|
||||
// Add missing vehicles, as described in Cfg file. Respawn damaged vehicles.
|
||||
//#define VEH_MAINTENANCE_ADD_MISSING
|
||||
|
||||
// Don't look for a suitable place anywhere on map if current place is not safe
|
||||
#define VEH_MAINTENANCE_DONT_BE_SMART
|
||||
|
||||
// Damage the vehicle for 1 startup over 5
|
||||
// don't define if you don't want any damage
|
||||
//#define VEH_MAINTENANCE_ROTTEN_AT_STARTUP 5
|
||||
|
||||
// How the damage is computed. Here, a 0% damaged vehicle would be respawned after 100 restarts
|
||||
#define VEH_MAINTENANCE_ROTTEN_LOGIC (_damage * 1.04 + 0.03)
|
||||
|
||||
// How initial fuel level is set when a vehicle is created/spawned
|
||||
#define VEH_MAINTENANCE_SPAWN_FUEL_LOGIC (0.1 + floor(random 3) / 10)
|
||||
|
||||
|
||||
|
||||
|
||||
// where the config is described
|
||||
#define CONFIGBASE_VEHMAINTENANCE configFile >> "CfgPatches" >> "vehMaint"
|
||||
584
SQF/dayz_server/compile/fa_hiveMaintenance.sqf
Normal file
584
SQF/dayz_server/compile/fa_hiveMaintenance.sqf
Normal file
@@ -0,0 +1,584 @@
|
||||
/*
|
||||
Created exclusively for ArmA2:OA - DayZMod.
|
||||
Please request permission to use/alter/distribute from project leader (R4Z0R49) AND the author (facoptere@gmail.com)
|
||||
*/
|
||||
|
||||
#include "fa_hiveMaintenance.hpp"
|
||||
|
||||
// coor2str: convert position to a GPS coordinates
|
||||
fa_coor2str = {
|
||||
private["_pos","_res","_nearestCity","_town"];
|
||||
|
||||
_pos = +(_this);
|
||||
if (count _pos < 1) then { _pos = [0,0]; }
|
||||
else { if (count _pos < 2) then { _pos = [_pos select 0,0]; };
|
||||
};
|
||||
_nearestCity = nearestLocations [_pos, ["NameCityCapital","NameCity","NameVillage","NameLocal"],1000];
|
||||
_town = "Wilderness";
|
||||
if (count _nearestCity > 0) then {_town = text (_nearestCity select 0)};
|
||||
_res = format["%1 [%2:%3]", _town, round((_pos select 0)/100), round((15360-(_pos select 1))/100)];
|
||||
|
||||
_res
|
||||
};
|
||||
|
||||
// print vehicle OID and name. if OID is unknown, it should be an hacked vehicle so print hacker PID.
|
||||
fa_veh2str = {
|
||||
private["_res","_oid", "_type"];
|
||||
|
||||
_res = "anything";
|
||||
if (!isNil "_this") then {
|
||||
_oid = _this getVariable ["ObjectID", nil];
|
||||
if (isNil "_oid" OR {(_oid == "")}) then {
|
||||
_oid = "Hacked vehicle owned by PID#" + str(owner _this);
|
||||
}
|
||||
else {
|
||||
_oid = "OID#" + _oid;
|
||||
};
|
||||
_type = getText(configFile >> "CfgVehicles" >> (typeOf _this) >> "displayName");
|
||||
if (_type == "") then { _type = typeOf _this; };
|
||||
_res = format["%1(%2)", _oid, _type ];
|
||||
};
|
||||
|
||||
_res
|
||||
};
|
||||
|
||||
// print player player PID and name. If name unknown then print UID.
|
||||
fa_plr2str = {
|
||||
private["_x","_res","_name"];
|
||||
_x = _this;
|
||||
_res = "nobody";
|
||||
if (!isNil "_x") then {
|
||||
_name = _x getVariable ["bodyName", nil];
|
||||
if ((isNil "_name" OR {(_name == "")}) AND ({alive _x})) then { _name = name _x; };
|
||||
if (isNil "_name" OR {(_name == "")}) then { _name = "UID#"+(getPlayerUID _x); };
|
||||
_res = format["PID#%1(%2)", owner _x, _name ];
|
||||
};
|
||||
_res
|
||||
};
|
||||
|
||||
|
||||
// isoutofmap: return true if position is out of map
|
||||
fa_isoutofmap = {
|
||||
private ["_SWcorner","_NEcorner"];
|
||||
_SWcorner = getArray(CONFIGBASE_VEHMAINTENANCE >> (worldName) >> "SWcorner");
|
||||
_NEcorner = getArray(CONFIGBASE_VEHMAINTENANCE >> (worldName) >> "NEcorner");
|
||||
(!((((_this select 0 >= _SWcorner select 0) AND {(_this select 0 <= _NEcorner select 0)})
|
||||
AND {(_this select 1 >= _SWcorner select 1)}) AND {(_this select 1 <= _NEcorner select 1)}))
|
||||
};
|
||||
|
||||
// spawninventory: draw preexisting loot in the vehicle. helicrash loot type is taken here + parts taken as arg
|
||||
fa_spawninventory = {
|
||||
private["_partType","_partChance","_lootWeight","_config","_itemType","_itemChance","_weights",
|
||||
"_index","_y","_partWeight","_spawnType","_spawnChance","_inventory","_weaponType","_weaponQty" ];
|
||||
|
||||
_partType = _this select 0;
|
||||
_partChance = _this select 1;
|
||||
_config = configFile >> "CfgLoot" >> "Buildings" >> "HeliCrash";
|
||||
// append parts to loot item
|
||||
_itemType = (getArray (_config >> "itemType"));
|
||||
{ _itemType set [count _itemType, [_x,"object"]] } forEach _partType;
|
||||
_itemChance = getArray (_config >> "itemChance");
|
||||
//diag_log (format["FACO _itemType:%1 _itemChance:%2", _itemType, _itemChance]);
|
||||
// _partWeight : sum of weights of parts list
|
||||
_partWeight = 0; { _partWeight = _partWeight + _x; } forEach _partChance;
|
||||
// _lootWeight : sum of weights of loot list
|
||||
_lootWeight = 0; { _lootWeight = _lootWeight + _x; } forEach _itemChance;
|
||||
// multiply parts weight so that parts have same chance to be chosen as regular loot
|
||||
// and append parts chance to loot item weight array
|
||||
{ _itemChance set [count _itemChance, _x * _lootWeight / _partWeight]; } forEach _partChance;
|
||||
// _partWeight : now, number of item to be chosen
|
||||
_partWeight = ceil(random(_partWeight));
|
||||
// lets choose the inventory
|
||||
_spawnType = [];
|
||||
_spawnQty = [];
|
||||
_weaponType = [];
|
||||
_weaponQty = [];
|
||||
_weights = [_itemType,_itemChance] call fnc_buildWeightedArray;
|
||||
for "_x" from 0 to _partWeight do {
|
||||
_index = _weights call BIS_fnc_selectRandom;
|
||||
if (_index < count _itemType) then {
|
||||
_y=(_itemType select _index) select 0;
|
||||
if (_y != "") then {
|
||||
if (_y isKindOf "Pistol" OR _y isKindOf "RifleCore" OR _y isKindOf "Binocular") then {
|
||||
_weaponType set [count _weaponType, _y ];
|
||||
_weaponType set [count _weaponType, 1];
|
||||
}
|
||||
else {
|
||||
_spawnType set [count _spawnType, _y ];
|
||||
_spawnQty set [count _spawnQty, 1];
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
_inventory = [[_weaponType,_weaponQty],[_spawnType,_spawnQty],[[],[]]];
|
||||
_inventory
|
||||
};
|
||||
|
||||
// populateCargo: add item and quantity to the 3 cargos (magazines,weapons,backpack) of an unit
|
||||
fa_populateCargo = {
|
||||
private["_entity","_config","_magItemTypes","_magItemQtys","_i","_inventory"];
|
||||
_entity = _this select 0;
|
||||
_inventory = _this select 1;
|
||||
|
||||
clearWeaponCargoGlobal _entity;
|
||||
clearMagazineCargoGlobal _entity;
|
||||
clearBackpackCargoGlobal _entity;
|
||||
_config = ["CfgWeapons", "CfgMagazines", "CfgVehicles" ];
|
||||
{
|
||||
_magItemTypes = _x select 0;
|
||||
_magItemQtys = _x select 1;
|
||||
_i = _forEachIndex;
|
||||
{
|
||||
if (_x == "Crossbow") then { _x = "Crossbow_DZ" }; // Convert Crossbow to Crossbow_DZ
|
||||
if (_x == "BoltSteel") then { _x = "WoodenArrow" }; // Convert BoltSteel to WoodenArrow
|
||||
if (_x == "ItemBloodbag") then { _x = "bloodBagONEG" }; // Convert ItemBloodbag into universal blood type/rh bag
|
||||
// Convert to DayZ Weapons
|
||||
if (_x == "DMR") then { _x = "DMR_DZ" };
|
||||
//if (_x == "M14_EP1") then { _x = "M14_DZ" };
|
||||
if (_x == "SVD") then { _x = "SVD_DZ" };
|
||||
if (_x == "SVD_CAMO") then { _x = "SVD_CAMO_DZ" };
|
||||
if (isClass(configFile >> (_config select _i) >> _x) &&
|
||||
getNumber(configFile >> (_config select _i) >> _x >> "stopThis") != 1) then {
|
||||
if (_forEachIndex < count _magItemQtys) then {
|
||||
switch (_i) do {
|
||||
case 0: { _entity addWeaponCargoGlobal [_x,(_magItemQtys select _forEachIndex)]; };
|
||||
case 1: { _entity addMagazineCargoGlobal [_x,(_magItemQtys select _forEachIndex)]; };
|
||||
case 2: { _entity addBackpackCargoGlobal [_x,(_magItemQtys select _forEachIndex)]; };
|
||||
};
|
||||
};
|
||||
};
|
||||
} forEach _magItemTypes;
|
||||
} forEach _inventory;
|
||||
};
|
||||
|
||||
|
||||
// all damageable parts names defined in Legacy/dayz_vehicles/config.cpp, some of them commented.
|
||||
// other damageables parts, defined in other CfgVehicles, are ignored.
|
||||
dayZ_damageableParts = [ "motor", "sklo predni P", "sklo predni L", "karoserie", "palivo", "wheel_1_1_steering", "wheel_2_1_steering", "wheel_1_2_steering", "wheel_2_2_steering", "glass1", "glass2", "glass3", "glass4"
|
||||
//, "glass5", "glass6", "door_fl", "door_rl", "door_fr", "door_rr"
|
||||
];
|
||||
|
||||
// setDamagedParts: declare some damageable parts of a vehicle. Randomly set damage to 80% (very damaged) to some parts
|
||||
// compute global damage of the vehicle
|
||||
// return: global damage, "_this" is modified and should be _hitpoints array from server_monitor
|
||||
fa_setDamagedParts = {
|
||||
private ["_part_damage", "_part_name", "_damage", "_hitpoints"];
|
||||
_damage = 0;
|
||||
_hitpoints = _this;
|
||||
{
|
||||
_part_damage = 0.05; // don't put 0, otherwise server_updateObject will think it's repaired
|
||||
if (random(3)<1) then { _part_damage = 0.80; };
|
||||
_part_name = getText (configFile >> "CfgVehicles" >> (typeOf _entity) >> "HitPoints" >> _x >> "name");
|
||||
if (_part_name IN dayZ_damageableParts) then {
|
||||
_damage = _damage + _part_damage;
|
||||
_hitpoints set [count _hitpoints, [ _part_name, _part_damage ]];
|
||||
};
|
||||
} forEach (_entity call vehicle_getHitpoints);
|
||||
_damage = _damage / (1 + (count _hitpoints)); // avoid DIV0
|
||||
|
||||
_damage
|
||||
};
|
||||
|
||||
fa_tentEmpty = {
|
||||
( (count _this == 0) || {
|
||||
(count ((_this select 0) select 0) == 0) &&
|
||||
(count ((_this select 1) select 0) == 0) &&
|
||||
(count ((_this select 2) select 0) == 0)
|
||||
})
|
||||
};
|
||||
|
||||
// ignore empty tents from array of objects fetched from hive
|
||||
fa_removeExtraTents = {
|
||||
private ["_emptytenttotal", "_idx", "_intentory", "_k", "_maxEmptyTents", "_allowedEmptyTents", "_ownerID", "_stall", "_tentcur", "_tentidx", "_tentowner", "_y", "_z", "_myArray"];
|
||||
|
||||
_myArray = _this select 0;
|
||||
_maxEmptyTents = _this select 1;
|
||||
_allowedEmptyTents = _this select 2;
|
||||
|
||||
_tentowner=[];
|
||||
_tentidx=[];
|
||||
_tentcur=[];
|
||||
_emptytenttotal=0;
|
||||
|
||||
{
|
||||
if ((_x select 2) == "TentStorage") then {
|
||||
_idx=_forEachIndex;
|
||||
_ownerID = _x select 3;
|
||||
if (!(_ownerID IN _tentowner)) then {
|
||||
_tentidx set [count _tentidx, []];
|
||||
_tentcur set [count _tentcur, 0];
|
||||
_tentowner set [count _tentowner, _ownerID];
|
||||
};
|
||||
_intentory = (_x select 5);
|
||||
if (_intentory call fa_tentEmpty) then {
|
||||
{
|
||||
if (_x == _ownerID) then {
|
||||
(_tentidx select _forEachIndex) set [count (_tentidx select _forEachIndex), _idx];
|
||||
_emptytenttotal = _emptytenttotal + 1;
|
||||
};
|
||||
} forEach _tentowner;
|
||||
};
|
||||
};
|
||||
} forEach _myArray;
|
||||
diag_log (format [ "fa_removeExtraTents: Empty tents: %1, would like less than %2.",
|
||||
_emptytenttotal,
|
||||
_maxEmptyTents
|
||||
]);
|
||||
if (_emptytenttotal > _maxEmptyTents) then {
|
||||
for [{_k = _emptytenttotal / 2}, {_k >= 2}, {_k = _k / 2}] do {
|
||||
_stall = 0;
|
||||
while {_emptytenttotal > _maxEmptyTents && _stall == 0} do {
|
||||
_stall = 1;
|
||||
for [{_x = (count _tentidx) - 1}, {_x >= 0 && _emptytenttotal >= _maxEmptyTents}, {_x = _x - 1}] do {
|
||||
_y = _tentidx select _x;
|
||||
_z = _tentcur select _x;
|
||||
if (_z < (count _y) -_allowedEmptyTents + 2 - _k) then {
|
||||
_idx = _myArray select (_y select _z);
|
||||
/*diag_log (format ["fa_removeExtraTents: will remove Tent ID=%1, owner=%2",
|
||||
_idx select 1,
|
||||
_idx select 3
|
||||
]);*/
|
||||
_idx set [ 8, 1 ]; // Set damage to 100%
|
||||
_emptytenttotal = _emptytenttotal - 1;
|
||||
_tentcur set [_x, _z + 1];
|
||||
_stall=0;
|
||||
};
|
||||
};
|
||||
_z =_z + 1;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
// check that vehicles list from the Hive has the right count of each vehicle
|
||||
// if some vehicles are missing, add them to the array
|
||||
// if a vehicle is illegal or outnumbered, delete it
|
||||
fa_checkVehicles = {
|
||||
private ["_vehcat", "_myArray", "_y", "_j","_type", "_count", "_idKey" ];
|
||||
_myArray = _this select 0;
|
||||
|
||||
// populate catalogue by browsing configFile
|
||||
_vehcat = [];
|
||||
_list = configFile >> "CfgPatches" >> "vehMaint";
|
||||
for "_x" from 0 to (count _list - 1) do {
|
||||
_class = configname (_list select _x);
|
||||
_qty = getNumber(CONFIGBASE_VEHMAINTENANCE >> _class >> "quantity");
|
||||
if (_qty > 0) then {
|
||||
_vehcat set [count _vehcat, [_class, _qty]];
|
||||
// diag_log(format["class:%1 val:%2", _class, _qty]);
|
||||
};
|
||||
};
|
||||
|
||||
// check the amount of vehicles of each kind
|
||||
{
|
||||
_type = _x select 2;
|
||||
for "_j" from 0 to (count _vehcat-1) do {
|
||||
if (_type == ((_vehcat select _j) select 0)) then {
|
||||
_count = ((_vehcat select _j) select 1);
|
||||
if (_count > 0) then {
|
||||
(_vehcat select _j) set [1, (_count-1)];
|
||||
if ((_x select 8) >= 1) then {
|
||||
#ifdef VEH_MAINTENANCE_ADD_MISSING
|
||||
(_myArray select _forEachIndex) set [8, 0.9] ; // damage = 0.9 so this veh will me respawned
|
||||
diag_log (format["fa_checkVehicles: recycling vehicle class=%1, oid=%2", _x select 2, _x select 1]);
|
||||
#endif
|
||||
};
|
||||
}
|
||||
#ifdef VEH_MAINTENANCE_IGNORE_UNKNOWN
|
||||
else {
|
||||
(_myArray select _forEachIndex) set [8,2]; // damage=2, so this veh will be deleted
|
||||
diag_log (format["fa_checkVehicles: skipping vehicle class=%1, oid=%2",
|
||||
_x select 2, _x select 1]);
|
||||
}
|
||||
#endif
|
||||
;_j = 999999; // break;
|
||||
};
|
||||
};
|
||||
} foreach _myArray;
|
||||
|
||||
#ifdef VEH_MAINTENANCE_ADD_MISSING
|
||||
// create missing vehicles of each kind.
|
||||
{
|
||||
for "_y" from 1 to (_x select 1) do {
|
||||
// create a new one at the end of _myArray list
|
||||
_type = (_x select 0);
|
||||
_idKey = format["%1%2",48,60000+floor(random 10000)];
|
||||
// "1" as Character ID since if I put "0" the vehicle is not stored in hive (since january 2013)
|
||||
_myArray set [count _myArray, ["CREATED",_idKey,_type,"1",[0,[0,0,0]],[[[],[]],[[],[]],[[],[]]],[],0,0.9]];
|
||||
diag_log (format["fa_checkVehicles: inserting in HIVE: vehicle class=%1, chosen oid=%2", _type, _idKey]);
|
||||
};
|
||||
} foreach _vehcat;
|
||||
#endif
|
||||
};
|
||||
|
||||
// move object to map boundary if it's out of map
|
||||
fa_staywithus = {
|
||||
|
||||
private["_a","_dir","_px","_py","_b","_cx","_cy","_k", "_SWcorner", "_NEcorner"];
|
||||
|
||||
_dir = +(_this select 0); // current position of player / vehicle
|
||||
_a = +(_this select 1); // current position of player / vehicle
|
||||
|
||||
_SWcorner = getArray(CONFIGBASE_VEHMAINTENANCE >> (worldName) >> "SWcorner");
|
||||
_NEcorner = getArray(CONFIGBASE_VEHMAINTENANCE >> (worldName) >> "NEcorner");
|
||||
|
||||
_a = ASLtoATL [_a select 0, _a select 1, 0];
|
||||
if ((((_a select 2) > 9) AND {(surfaceisWater _a)}) // entity in water and sea depth above 9 meters?
|
||||
OR {(_a call fa_isoutofmap)}) then { // or entity is out of map?
|
||||
// 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; };
|
||||
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; };
|
||||
if (_py >= (_NEcorner select 1)) then { _px = _px + ((_NEcorner select 1) - 1 - _py) / _cy * _cx; _py = (_NEcorner select 1) - 1; };
|
||||
// 2nd: compute the object direction, so that it heads toward the center of the map.
|
||||
_dir = atan(_cx / _cy);
|
||||
if (_cy < 0) then { _dir = _dir + 180; };
|
||||
|
||||
// 3rd: if the object is on shalow sea, make it virtually swim so that sea depth is below 9 meters.
|
||||
_a = [_px,_py,0];
|
||||
for "_k" from 0 to 1 step 0.005 do {
|
||||
_a = [_px + _cx * _k, _py + _cy * _k, 0];
|
||||
// if ((_k*200) mod 5 == 4) then { diag_log (format["fa_staywithus: a:%1 water:%2 zx:%3", _a, surfaceisWater _a, (getPosATL _o) select 2]); };
|
||||
if (surfaceisWater _a) then {
|
||||
_a = ASLtoATL [_a select 0, _a select 1, 0];
|
||||
if (((_a select 2) < 9) AND{(!(_a call fa_isoutofmap))}) then { _k = 2; }
|
||||
else { if ((_a select 2) < 30) then { _k = _k - 0.0045; };}; // slow down on the axis
|
||||
}
|
||||
else {
|
||||
if (!(_a call fa_isoutofmap)) then { _k = 2; };
|
||||
};
|
||||
};
|
||||
/*diag_log (format["FACO out-of-map new pos:%1 direction:%2 in water:%3 out-of-map:%4 ",
|
||||
(getPosATL _o) call fa_coor2str,
|
||||
round(_dir),
|
||||
surfaceisWater _a,
|
||||
(if ([_a] call fa_isoutofmap == 1) then { true } else { false })
|
||||
]);*/
|
||||
};
|
||||
|
||||
// cancel the change if it is too near original pos
|
||||
if (([(_this select 1),_a] call BIS_fnc_distance2Dsqr) <= 30) then {
|
||||
[_this select 0, +(_this select 1)]
|
||||
}
|
||||
else {
|
||||
[ _dir, [_a select 0, _a select 1, 0]]
|
||||
}
|
||||
};
|
||||
|
||||
// used only by fa_server_locationCheck
|
||||
stream_locationFill = compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\stream_locationFill.sqf";
|
||||
dayz_locationsActive = [];
|
||||
// used only by fa_smartlocation. Same as stream_locationCheck, but without any deletion.
|
||||
fa_server_locationCheck = {
|
||||
private ["_point","_rad","_config","_i","_location","_distCfg","_distAct"];
|
||||
|
||||
_point = _this select 0;
|
||||
_rad = _this select 1;
|
||||
_config = configFile >> "CfgTownGeneratorChernarus";
|
||||
|
||||
if (count _point >= 2) then {
|
||||
for "_i" from (count _config -1) to 0 step -1 do {
|
||||
_x = _config select _i;
|
||||
_location = getArray (_x >> "position");
|
||||
_distCfg = getNumber (_x >> "size");
|
||||
_distAct = [_point select 0, _point select 1, 0] distance [_location select 0, _location select 1, 0];
|
||||
|
||||
if (!(_i in dayz_locationsActive)) then {
|
||||
if (_distAct < _distCfg + _rad) then {
|
||||
dayz_locationsActive set [count dayz_locationsActive,_i];
|
||||
diag_log format ["%1::fa_server_locationCheck : creating %2 objects at '%3'", __FILE__, count _x, _location];
|
||||
[_x, false] call stream_locationFill; // create wrecks & rubbish as local objects
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
// used only by fa_smartlocation
|
||||
fa_smartlocation_commonTests = { // [_type, _pos, _minAltitude, _maxAltitude, _found]
|
||||
private ["_found", "_point", "_worldspace"];
|
||||
|
||||
_found = false;
|
||||
_point = _this select 1;
|
||||
|
||||
//diag_log(format["fa_smartlocation %1 %2", __LINE__, _this]);
|
||||
|
||||
_point set [2, 0];
|
||||
_point = ATLtoASL _point;
|
||||
if (((_point select 2) < _this select 3) AND {((_point select 2) > _this select 2)}) then {
|
||||
if (count (_point nearEntities [["Air", "LandVehicle", "Ship"], _this select 4]) <= 0) then {
|
||||
if (_this select 3 < 0) then { // boats
|
||||
_found = surfaceisWater _point;
|
||||
}
|
||||
else { // not boats
|
||||
_point set [2, 0];
|
||||
_worldspace = [_this select 0, _point] call fn_niceSpot;
|
||||
if (count _worldspace == 2) then {
|
||||
_point = _worldspace select 1;
|
||||
(_this select 1) set [0, _point select 0];
|
||||
(_this select 1) set [1, _point select 1];
|
||||
(_this select 1) set [2, 0];
|
||||
_found = true;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
// diag_log(format["fa_smartlocation %1 %2", __LINE__, _this]);
|
||||
|
||||
_found
|
||||
};
|
||||
|
||||
// move vehicle to a safe position, respawn vehicle.
|
||||
fa_smartlocation = {
|
||||
private ["_type","_class","_dir","_oldpos","_action","_distance","_minAltitude","_maxAltitude","_tmpobject","_width","_found","_wp","_worldCenter","_worldRadius","_locations","_radius","_nearObjectTypes","_types","_pickedLocation","_o","_objects","_counter","_locpos","_loc","_y","_r","_deg","_veh","_size","_old", "_point"];
|
||||
|
||||
_type = _this select 0; // vehicle "typeOf"
|
||||
_class = _type;
|
||||
if (_type isKindOf "Air") then { _class = "Land_Ind_TankBig"; }; // for helis we take a big circular tank as a footprint
|
||||
_dir = _this select 1;
|
||||
_oldpos = +(_this select 2); // current vehicle position (from hive)
|
||||
_action = _this select 3; // "OBJ"=> read from hive, keep position the best we can. Otherwise: choose a random position.
|
||||
_distance = 500; // distance from other vehicles. decrease as soon as we can't find a spot
|
||||
|
||||
_minAltitude = getNumber(CONFIGBASE_VEHMAINTENANCE >> _type >> "minAltitude");
|
||||
_maxAltitude = getNumber(CONFIGBASE_VEHMAINTENANCE >> _type >> "maxAltitude");
|
||||
|
||||
// workaround for sizeof bug -- do not remove
|
||||
_tmpobject = _class createVehicleLocal (getMarkerPos "respawn_west");
|
||||
sleep 0.01; // wait object loading
|
||||
_width = (((boundingBox _tmpobject) select 1) select 0);
|
||||
//diag_log(format["fa_smartlocation _this:%1 %2", _this, (sizeOf _class)]);
|
||||
|
||||
_point = [];
|
||||
_found = false;
|
||||
// try to place the object in a safe position near current position
|
||||
if ((!(_action IN [ "CREATED", "SPAWNED"])) and {(count _oldpos>=2)}) then {
|
||||
#ifdef VEH_MAINTENANCE_FIX_OUTOFMAP
|
||||
// move object back on the map
|
||||
_wp = [0, _oldpos] call fa_staywithus; // use ATL format
|
||||
_point = +(_wp select 1);
|
||||
if (count _point < 2) then { _point = _oldpos; };
|
||||
#else
|
||||
_point = +(_oldpos);
|
||||
#endif
|
||||
// find a safe position around current position for air vehicles
|
||||
if (_type isKindOf "Air") then {
|
||||
[_point, 20] call fa_server_locationCheck; // towngenerator around spawn point, to limit collisions
|
||||
deleteVehicle _tmpobject;
|
||||
_tmpobject = _class createVehicleLocal _point;
|
||||
_point = getPosATL _tmpobject;
|
||||
};
|
||||
// check altitude
|
||||
#ifdef VEH_MAINTENANCE_FIX_OUTOFMAP
|
||||
if (count _point >= 2) then {
|
||||
_point set [2, 0];
|
||||
_point = ATLtoASL _point;
|
||||
_found = (((_point select 2) < _maxAltitude) AND {((_point select 2) > _minAltitude)});
|
||||
};
|
||||
#else
|
||||
_found = true;
|
||||
#endif
|
||||
/*diag_log(format["fa_smartlocation: Looking for a safe place near original position... _action:%1 _type:%2 suitable:%3 distance:%4",
|
||||
_action,
|
||||
_type,
|
||||
_found,
|
||||
if (_found) then { [_oldpos, _point] call BIS_fnc_distance2D } else { "" }
|
||||
]);*/
|
||||
}
|
||||
else {
|
||||
[_point, 20] call fa_server_locationCheck; // towngenerator around spawn point, to limit collisions
|
||||
};
|
||||
deleteVehicle _tmpobject;
|
||||
sleep 0.01; // wait object destroy. nearEntities may return false info if not done.
|
||||
#ifndef VEH_MAINTENANCE_DONT_BE_SMART
|
||||
if (!_found) then { // we failed to find a suitable position around current one, so respawn vehicle
|
||||
_worldCenter = getArray(CONFIGBASE_VEHMAINTENANCE >> (worldName) >> "center");
|
||||
_worldRadius = getNumber(CONFIGBASE_VEHMAINTENANCE >> (worldName) >> "spawnRadius");
|
||||
|
||||
// if vehicle is not described in configFile, then locations is empty.
|
||||
_locations = nearestLocations [
|
||||
_worldCenter,
|
||||
getArray(CONFIGBASE_VEHMAINTENANCE >> _type >> "localityTypes"),
|
||||
_worldRadius
|
||||
];
|
||||
_radius = getNumber(CONFIGBASE_VEHMAINTENANCE >> _type >> "localityRadius");
|
||||
_nearObjectTypes = getArray(CONFIGBASE_VEHMAINTENANCE >> _type >> "nearObjects");
|
||||
// diag_log(format["fa_smartlocation: Getting choice logic: Altitude min:%1 max:%2 _radius:%3 _types=%4 countlocations:%5", _minAltitude, _maxAltitude, _radius, _nearObjectTypes, (count _locations) ]);
|
||||
_pickedLocation = nil;
|
||||
_o = nil;
|
||||
_objects = nil;
|
||||
_counter = 0;
|
||||
_point = [];
|
||||
while ({count _locations > 0 AND !_found}) do {
|
||||
_pickedLocation = _locations call BIS_fnc_selectRandom;
|
||||
_locpos = position _pickedLocation;
|
||||
_locpos set [2,0];
|
||||
_locpos = ATLtoASL _locpos;
|
||||
// if location is in the sea, or on the ground and at the right altitude
|
||||
if ((_maxAltitude<0) OR {(((_locpos select 2) < _maxAltitude+0.05*_radius) AND {((_locpos select 2) > _minAltitude-0.05*_radius)})}) then {
|
||||
[_locpos, _radius] call fa_server_locationCheck;
|
||||
if (count _nearObjectTypes > 0 ) then { // spawn close to an object
|
||||
_objects = nearestObjects [_locpos, _nearObjectTypes, _radius];
|
||||
//diag_log(format["fa_smartlocation: In locality loop _loc:%1 near objects count:%2 ", _pickedLocation, count _objects ]);
|
||||
while ({count _objects > 0 AND !_found}) do {
|
||||
_counter=_counter+0.0001;
|
||||
_o = _objects call BIS_fnc_selectRandom;
|
||||
// move spot in front of object, according to object length (its Y axis) and vehicle width (its X axis)
|
||||
// vehicle should be located slightly in front object, twisted by a 90* angle
|
||||
_point = _o modelToWorld [0,-(_width+(((boundingBox _o) select 1) select 1))/2,0];
|
||||
_point set [2, 0];
|
||||
_dir = (getDir _o)+90;
|
||||
_found = [_class, _point, _minAltitude, _maxAltitude, _distance] call fa_smartlocation_commonTests;
|
||||
//if (_found) then { diag_log(format["fa_smartlocation %1 %3 +--> %2", __LINE__, _point, _oldpos]); };
|
||||
_objects = _objects - [_o];
|
||||
_distance = _distance * 0.995;
|
||||
};
|
||||
}
|
||||
else { // spawn anywhere on the location
|
||||
for [{_y = _radius * _radius / 20000}, {(_y > 0 ) AND !_found}, {_y = _y - 1}] do {
|
||||
_counter=_counter+0.0001;
|
||||
_r = random(_radius*_radius)^0.5;
|
||||
_deg = random 360;
|
||||
_point = [(_locpos select 0) + sin(_deg) * _r, (_locpos select 1) + cos(_deg) * _r, 0];
|
||||
_dir = _deg;
|
||||
_found = [_class, _point, _minAltitude, _maxAltitude,_distance] call fa_smartlocation_commonTests;
|
||||
//if (_found) then { diag_log(format["fa_smartlocation %1 %3 +--> %2", __LINE__, _point, _oldpos]); };
|
||||
_distance = _distance * 0.995;
|
||||
};
|
||||
};
|
||||
}; // was suitable altitude
|
||||
_counter = _counter + 1;
|
||||
_locations = _locations - [_pickedLocation];
|
||||
}; // while suitable location
|
||||
diag_log(format["fa_smartlocation: %2 _veh:%1 _size:%6 _old:%8 |--> _point:%3 _pickedLocation:%4 _counter=%5 badly near:%7",
|
||||
_type,
|
||||
if (_found) then {"ok"} else {"** FAILED **"},
|
||||
_point,
|
||||
if (!isNil "_pickedLocation") then {text(_pickedLocation)} else {""},
|
||||
_counter, (sizeOf _class),
|
||||
if (count _point >0) then { (_point nearEntities [["Air", "LandVehicle", "Ship"],_distance])-[_tmpobject] } else { "" },
|
||||
_oldpos
|
||||
]);
|
||||
};
|
||||
#endif
|
||||
|
||||
if (_found) then { [_dir, [_point select 0, _point select 1, 0]] } else { [] }
|
||||
};
|
||||
|
||||
|
||||
FNC_kindOf = {
|
||||
_inherit = inheritsFrom _this;
|
||||
_list = [configName _this];
|
||||
while { (configName _inherit) != "" } do {
|
||||
_list set[count _list,configName _inherit];
|
||||
_inherit = inheritsFrom( _inherit );
|
||||
};
|
||||
_list
|
||||
};
|
||||
|
||||
@@ -3,10 +3,11 @@ _playerUID = _this select 0;
|
||||
_playerName = _this select 1;
|
||||
_playerObj = nil;
|
||||
_playerPos = [];
|
||||
|
||||
{
|
||||
_PUID = [_x] call FNC_GetPlayerUID;
|
||||
if (_PUID == _playerUID) exitWith {_playerObj = _x;};
|
||||
} count playableUnits;
|
||||
if (_PUID == _playerUID) exitWith { _playerObj = _x; _playerPos = getPosATL _playerObj;};
|
||||
} count playableUnits;
|
||||
|
||||
if (isNil "_playerObj") then {
|
||||
diag_log format["nil player object attempting PV, :%1", _this];
|
||||
@@ -21,12 +22,23 @@ if (isNil "_playerObj") exitWith {
|
||||
_PUID = [_playerObj] call FNC_GetPlayerUID;
|
||||
diag_log format["get: %1 (%2), sent: %3 (%4)",typeName _PUID, _PUID, typeName _playerUID, _playerUID];
|
||||
|
||||
if (!isNull _playerObj) then {
|
||||
_characterID = _playerObj getVariable["characterID", "?"];
|
||||
_lastDamage = _playerObj getVariable["noatlf4",0];
|
||||
_Sepsis = _playerObj getVariable["USEC_Sepsis",false];
|
||||
|
||||
if (_characterID != "?") exitwith {
|
||||
_playerPos = getPosATL _playerObj;
|
||||
_characterID = _playerObj getVariable ["CharacterID","0"];
|
||||
//_characterID = _playerObj getVariable ["CharacterID","0"];
|
||||
_timeout = _playerObj getVariable["combattimeout",0];
|
||||
|
||||
//If the player has sepsis before logging off lets give them infected status.
|
||||
if (_Sepsis) then {
|
||||
_playerObj setVariable["USEC_infected",true,true];
|
||||
};
|
||||
|
||||
//Record Player Login/LogOut
|
||||
[_playerUID,_characterID,2] call dayz_recordLogin;
|
||||
|
||||
_invehicle = false;
|
||||
|
||||
if (vehicle _playerObj != _playerObj) then {
|
||||
@@ -53,20 +65,42 @@ if (!isNull _playerObj) then {
|
||||
_id = [_playerUID,_characterID,2] spawn dayz_recordLogin;
|
||||
|
||||
if (alive _playerObj) then {
|
||||
|
||||
|
||||
//[_playerObj,nil,true] call server_playerSync;
|
||||
|
||||
_isplayernearby = (DZE_BackpackGuard && !_invehicle && ({(isPlayer _x) && (alive _x)} count (_playerPos nearEntities ["AllVehicles", 5]) > 1));
|
||||
|
||||
// prevent saving more than 20 magazine items
|
||||
_magazines = [(magazines _playerObj),20] call array_reduceSize;
|
||||
|
||||
[_playerObj,_magazines,true,true,_isplayernearby] call server_playerSync;
|
||||
|
||||
|
||||
if (dayz_enableGhosting) then {
|
||||
//diag_log format["GhostPlayers: %1, ActivePlayers: %2",dayz_ghostPlayers,dayz_activePlayers];
|
||||
if (!(_playerUID in dayz_ghostPlayers)) then {
|
||||
dayz_ghostPlayers set [count dayz_ghostPlayers, _playerUID];
|
||||
dayz_activePlayers set [count dayz_activePlayers, [_playerUID,diag_ticktime]];
|
||||
|
||||
//diag_log format["playerID %1 added to ghost list",_playerUID];
|
||||
};
|
||||
};
|
||||
|
||||
// remove player
|
||||
_playerObj call dayz_removePlayerOnDisconnect;
|
||||
} else {
|
||||
//Update Vehicle
|
||||
{
|
||||
[_x,"gear"] call server_updateObject;
|
||||
} count (nearestObjects [_playerPos, dayz_updateObjects, 10]);
|
||||
};
|
||||
//Update Vehicle
|
||||
{
|
||||
[_x,"gear"] call server_updateObject;
|
||||
} count (nearestObjects [_playerPos, DayZ_GearedObjects, 10]);
|
||||
};
|
||||
|
||||
if (isNull _playerObj) then { diag_log("Player Object does not esist"); };
|
||||
|
||||
|
||||
//Lets remove the object.
|
||||
if (!isNull _playerObj) then {
|
||||
_myGroup = group _playerObj;
|
||||
deleteVehicle _playerObj;
|
||||
deleteGroup _myGroup;
|
||||
};
|
||||
|
||||
|
||||
23
SQF/dayz_server/compile/server_plantSpawner.sqf
Normal file
23
SQF/dayz_server/compile/server_plantSpawner.sqf
Normal file
@@ -0,0 +1,23 @@
|
||||
private ["_SWcorner","_NEcorner","_amount","_a","_b","_c"];
|
||||
|
||||
#define CONFIGBASE_VEHMAINTENANCE configFile >> "CfgPatches" >> "vehMaint"
|
||||
|
||||
_SWcorner = getArray(CONFIGBASE_VEHMAINTENANCE >> (worldName) >> "SWcorner");
|
||||
_NEcorner = getArray(CONFIGBASE_VEHMAINTENANCE >> (worldName) >> "NEcorner");
|
||||
|
||||
_a = [(_SWcorner select 0), (_SWcorner select 1), (_NEcorner select 0) - (_SWcorner select 0), (_NEcorner select 1) - (_SWcorner select 1) ] call psrnd_init;
|
||||
_b = [ -15, -15, 30, 30 ] call psrnd_init;
|
||||
_c = [ 0, 0, 3, 360 ] call psrnd_init;
|
||||
|
||||
PVCDZ_plr_plantSpawner = [ _a, _b, _c, [] ];
|
||||
//diag_log [ __FILE__, _a, _b, _c ];
|
||||
|
||||
"PVDZ_objgather_Delete" addPublicVariableEventHandler {
|
||||
private [ "_pos", "_blacklist"];
|
||||
_pos = (_this select 1);
|
||||
|
||||
_blacklist = PVCDZ_plr_plantSpawner select 3;
|
||||
_blacklist set [ count _blacklist, _pos ];
|
||||
//diag_log [ __FILE__, _this, _blacklist ];
|
||||
};
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#include "\z\addons\dayz_server\compile\server_toggle_debug.hpp"
|
||||
private ["_characterID","_minutes","_newObject","_playerID","_infected","_victim","_victimName","_killer","_killerName","_weapon","_distance","_message","_loc_message","_key","_death_record"];
|
||||
//[unit, weapon, muzzle, mode, ammo, magazine, projectile]
|
||||
_characterID = _this select 0;
|
||||
@@ -75,9 +76,14 @@ if (isnil "dayz_disco") then {
|
||||
dayz_disco = [];
|
||||
};
|
||||
*/
|
||||
dayz_died set [count dayz_died, _playerID];
|
||||
|
||||
// dayz_disco = dayz_disco - [_playerID];
|
||||
_newObject setVariable["processedDeath",diag_tickTime];
|
||||
_newObject setVariable ["bodyName", _victimName, true];
|
||||
_pos = getPosATL _newObject;
|
||||
if (_pos select 2 < 0.1) then { _pos set [2,0]; };
|
||||
_newObject setVariable [ "deathPos", _pos];
|
||||
|
||||
if (typeName _minutes == "STRING") then
|
||||
{
|
||||
@@ -97,4 +103,14 @@ if (_characterID != "0") then
|
||||
else
|
||||
{
|
||||
deleteVehicle _newObject;
|
||||
};
|
||||
};
|
||||
#ifdef PLAYER_DEBUG
|
||||
diag_log format ["Player UID#%3 CID#%4 %1 as %5 died at %2",
|
||||
_newObject call fa_plr2str, (getPosATL _newObject) call fa_coor2str,
|
||||
getPlayerUID _newObject,_characterID,
|
||||
typeOf _newObject
|
||||
];
|
||||
#endif
|
||||
_newObject setDamage 1;
|
||||
_newObject setOwner 0;
|
||||
//dead_bodyCleanup set [count dead_bodyCleanup,_newObject];
|
||||
@@ -1,5 +1,5 @@
|
||||
private ["_isInfected","_doLoop","_hiveVer","_isHiveOk","_playerID","_playerObj","_primary","_key","_charID","_playerName","_backpack","_isNew","_inventory","_survival","_model","_mags","_wpns","_bcpk","_config","_newPlayer"];
|
||||
|
||||
#include "\z\addons\dayz_server\compile\server_toggle_debug.hpp"
|
||||
#ifdef DZE_SERVER_DEBUG
|
||||
diag_log ("STARTING LOGIN: " + str(_this));
|
||||
#endif
|
||||
@@ -7,7 +7,7 @@ diag_log ("STARTING LOGIN: " + str(_this));
|
||||
_playerID = _this select 0;
|
||||
_playerObj = _this select 1;
|
||||
_playerName = name _playerObj;
|
||||
|
||||
_worldspace = [];
|
||||
if (_playerName == '__SERVER__' || _playerID == '' || local player) exitWith {};
|
||||
|
||||
if (isNil "sm_done") exitWith {
|
||||
@@ -15,6 +15,10 @@ if (isNil "sm_done") exitWith {
|
||||
diag_log ("Login cancelled, server is not ready. " + str(_playerObj));
|
||||
#endif
|
||||
};
|
||||
// Cancel any login until server_monitor terminates.
|
||||
// This is mandatory since all vehicles must be spawned before the first players spawn on the map.
|
||||
// Otherwise, all vehicle event handlers won't be created on players' client side.
|
||||
if (isNil "sm_done") exitWith { diag_log ("Login cancelled, server is not ready. " + str(_playerObj)); };
|
||||
|
||||
if (count _this > 2) then {
|
||||
dayz_players = dayz_players - [_this select 2];
|
||||
@@ -23,10 +27,17 @@ if (count _this > 2) then {
|
||||
//Variables
|
||||
_inventory = [];
|
||||
_backpack = [];
|
||||
_items = [];
|
||||
_magazines = [];
|
||||
_weapons = [];
|
||||
_medicalStats = [];
|
||||
_survival = [0,0,0];
|
||||
_isInfected = 0;
|
||||
_tent = [];
|
||||
_state = [];
|
||||
_direction = 0;
|
||||
_model = "";
|
||||
|
||||
_newUnit = objNull;
|
||||
if (_playerID == "") then {
|
||||
_playerID = [_playerObj] call FNC_GetPlayerUID;
|
||||
};
|
||||
@@ -41,6 +52,35 @@ if ((_playerID == "") || (isNil "_playerID")) exitWith {
|
||||
diag_log ("LOGIN ATTEMPT: " + str(_playerID) + " " + _playerName);
|
||||
#endif
|
||||
|
||||
_endMission = false;
|
||||
_timeleft = 0;
|
||||
{
|
||||
//if ((_playerID select _i) in activePlayers) exitWith { diag_log ("Login cancelled, player has logged out within the past 2 mins. " + str(_playerObj)); };
|
||||
_0 = _x select 0;
|
||||
_1 = _x select 1;
|
||||
_timeleft = diag_ticktime - _1;
|
||||
|
||||
if (_playerID == _0) then {
|
||||
//If players last logoff is about the ghost timer remove player from ghost que.
|
||||
if ((_timeleft > dayz_ghostTimer) or (_timeleft < 0)) then {
|
||||
dayz_ghostPlayers = dayz_ghostPlayers - [_0];
|
||||
dayz_activePlayers set[_forEachIndex, _0];
|
||||
dayz_activePlayers = dayz_activePlayers - [_0];
|
||||
} else {
|
||||
//if player is in died allow them passage.
|
||||
if (_playerID in dayz_died) then {
|
||||
dayz_died = dayz_died - [_playerID];
|
||||
dayz_ghostPlayers = dayz_ghostPlayers - [_0];
|
||||
dayz_activePlayers set[_forEachIndex, _0];
|
||||
dayz_activePlayers = dayz_activePlayers - [_0];
|
||||
} else {
|
||||
// Logoff time is not beyond ghost time and player didn't die
|
||||
_endMission = true;
|
||||
};
|
||||
};
|
||||
};
|
||||
}forEach dayz_activePlayers;
|
||||
|
||||
//Do Connection Attempt
|
||||
_doLoop = 0;
|
||||
while {_doLoop < 5} do {
|
||||
@@ -70,7 +110,7 @@ if ((_primary select 0) == "ERROR") exitWith {
|
||||
_newPlayer = _primary select 1;
|
||||
_isNew = count _primary < 7; //_result select 1;
|
||||
_charID = _primary select 2;
|
||||
|
||||
_randomSpot = false;
|
||||
#ifdef DZE_SERVER_DEBUG
|
||||
diag_log ("LOGIN RESULT: " + str(_primary));
|
||||
#endif
|
||||
@@ -114,7 +154,7 @@ if (!_isNew) then {
|
||||
_mags = getArray (_config >> "magazines");
|
||||
_wpns = getArray (_config >> "weapons");
|
||||
_bcpk = getText (_config >> "backpack");
|
||||
|
||||
_randomSpot = true;
|
||||
if(!isNil "DefaultMagazines") then {
|
||||
_mags = DefaultMagazines;
|
||||
};
|
||||
@@ -146,5 +186,23 @@ if (worldName == "chernarus") then {
|
||||
([4654,9595,0] nearestObject 145260) setDamage 1;
|
||||
};
|
||||
|
||||
dayzPlayerLogin = [_charID,_inventory,_backpack,_survival,_isNew,dayz_versionNo,_model,_isHiveOk,_newPlayer,_isInfected];
|
||||
(owner _playerObj) publicVariableClient "dayzPlayerLogin";
|
||||
//dayzPlayerLogin = [_charID,_inventory,_backpack,_survival,_isNew,dayz_versionNo,_model,_isHiveOk,_newPlayer,_isInfected];
|
||||
PVCDZ_plr_Login = [_charID,_inventory,_backpack,_survival,_isNew,dayz_versionNo,_model,_isHiveOk,_newPlayer,_isInfected];
|
||||
#ifdef DZE_SERVER_DEBUG
|
||||
diag_log format["%1, %2, %3, %4, %5, %6, %7, %8, %9, %10",_charID,_inventory,_backpack,_survival,_isNew,dayz_versionNo,_model,_isHiveOk,_newPlayer,_isInfected];
|
||||
#endif
|
||||
|
||||
(owner _playerObj) publicVariableClient "PVCDZ_plr_Login";
|
||||
|
||||
//Make player wait till ghost timer is up.
|
||||
if (_endMission) exitwith {
|
||||
_remaining = dayz_ghostTimer - _timeleft;
|
||||
diag_log format["LOGIN CANCELLED: player: %1 is in ghost mode. Time remianing: %2 before login!!",_playerObj,_remaining];
|
||||
PVCDZ_plr_Ghost = [_remaining];
|
||||
(owner _playerObj) publicVariableClient "PVCDZ_plr_Ghost";
|
||||
};
|
||||
|
||||
[_playerID,_charID,1] call dayz_recordLogin;
|
||||
|
||||
PVCDZ_plr_PlayerAccepted = [_playerName,diag_ticktime];
|
||||
(owner _playerObj) publicVariableClient "PVCDZ_plr_PlayerAccepted";
|
||||
@@ -4,15 +4,17 @@ private ["_characterID","_playerObj","_playerID","_dummy","_worldspace","_state"
|
||||
|
||||
_characterID = _this select 0;
|
||||
_playerObj = _this select 1;
|
||||
_spawnSelection = _this select 3;
|
||||
_playerID = [_playerObj] call FNC_GetPlayerUID;
|
||||
|
||||
#include "\z\addons\dayz_server\compile\server_toggle_debug.hpp"
|
||||
if (isNull _playerObj) exitWith {
|
||||
diag_log ("SETUP INIT FAILED: Exiting, player object null: " + str(_playerObj));
|
||||
};
|
||||
|
||||
//Add MPHit event handler
|
||||
// diag_log("Adding MPHit EH for " + str(_playerObj));
|
||||
_playerObj addMPEventHandler ["MPHit", {_this spawn fnc_plyrHit;}];
|
||||
//_playerObj addMPEventHandler ["MPHit", {_this spawn fnc_plyrHit;}];
|
||||
|
||||
if (_playerID == "") then {
|
||||
_playerID = [_playerObj] call FNC_GetPlayerUID;
|
||||
@@ -57,13 +59,34 @@ if (isNull _playerObj || !isPlayer _playerObj) exitWith {
|
||||
_medical = _primary select 1;
|
||||
_stats = _primary select 2;
|
||||
_state = _primary select 3;
|
||||
_statearray = if (count _primary >= 4) then { _primary select 3 } else {[""]};
|
||||
_worldspace = _primary select 4;
|
||||
_humanity = _primary select 5;
|
||||
_lastinstance = _primary select 6;
|
||||
|
||||
if (count _statearray == 0) then { _statearray = [""]; };
|
||||
//diag_log ("StateNew: "+str(_statearray));
|
||||
|
||||
if (typeName ((_statearray) select 0) == "STRING") then {
|
||||
_statearray = [_statearray,[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]];
|
||||
};
|
||||
|
||||
_state = ((_statearray) select 0);
|
||||
//diag_log ("State: "+str(_state));
|
||||
_Achievements = ((_statearray) select 1);
|
||||
|
||||
if (count _Achievements == 0) then {
|
||||
_Achievements = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];
|
||||
};
|
||||
//diag_log ("Achievements: "+str(_Achievements));
|
||||
|
||||
_worldspace = _primary select 4;
|
||||
_humanity = _primary select 5;
|
||||
|
||||
//Set position
|
||||
_randomSpot = false;
|
||||
|
||||
//diag_log ("WORLDSPACE: " + str(_worldspace));
|
||||
if (count _worldspace > 0) then {
|
||||
|
||||
_position = _worldspace select 1;
|
||||
@@ -81,11 +104,6 @@ if (count _worldspace > 0) then {
|
||||
if (_distance < 500) then {
|
||||
_randomSpot = true;
|
||||
};
|
||||
|
||||
// Came from another server force random spawn
|
||||
if (_lastinstance != dayZ_instance) then {
|
||||
_randomSpot = true;
|
||||
};
|
||||
|
||||
//_playerObj setPosATL _position;
|
||||
} else {
|
||||
@@ -108,10 +126,10 @@ if (count _medical > 0) then {
|
||||
|
||||
//Add Wounds
|
||||
{
|
||||
_playerObj setVariable[_x,true,true];
|
||||
_playerObj setVariable["hit_"+_x,true, true];
|
||||
//["usecBleed",[_playerObj,_x,_hit]] call broadcastRpcCallAll;
|
||||
usecBleed = [_playerObj,_x,_hit];
|
||||
publicVariable "usecBleed";
|
||||
//usecBleed = [_playerObj,_x,_hit];
|
||||
//publicVariable "usecBleed";
|
||||
} count (_medical select 8);
|
||||
|
||||
//Add fractures
|
||||
@@ -119,21 +137,34 @@ if (count _medical > 0) then {
|
||||
_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];
|
||||
_playerObj setVariable["messing",if (count _medical >= 14) then {(_medical select 13)} else {[0,0,0]},true];
|
||||
|
||||
_playerObj setVariable["blood_testdone",if (count _medical >= 15) then {(_medical select 14)} else {false},true];
|
||||
if (count _medical >= 12) then {
|
||||
_playerObj setVariable["blood_type",(_medical select 11),true];
|
||||
_playerObj setVariable["rh_factor",(_medical select 12),true];
|
||||
diag_log [ "Character data: blood_type,rh_factor,testdone=",
|
||||
_playerObj getVariable ["blood_type", "?"],_playerObj getVariable ["rh_factor", "?"], _playerObj getVariable["blood_testdone", false]
|
||||
];
|
||||
} else {
|
||||
_playerObj call player_bloodCalc;
|
||||
diag_log [ "Character upgrade to 1.8.3: blood_type,rh_factor=",_playerObj getVariable ["blood_type", "?"],_playerObj getVariable ["rh_factor", "?"]];
|
||||
};
|
||||
|
||||
} else {
|
||||
//Reset bleeding wounds
|
||||
call fnc_usec_resetWoundPoints;
|
||||
//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];
|
||||
_playerObj call player_bloodCalc; // will set blood_type and rh_factor according to real population statitics
|
||||
diag_log [ "New character setup: blood_type,rh_factor=",_playerObj getVariable ["blood_type", "?"],_playerObj getVariable ["rh_factor", "?"]];
|
||||
_playerObj setVariable ["messing",[0,0,0],true];
|
||||
_playerObj setVariable ["blood_testdone",false,true];
|
||||
};
|
||||
|
||||
if (count _stats > 0) then {
|
||||
if (count _stats > 0) then {
|
||||
//register stats
|
||||
_playerObj setVariable["zombieKills",(_stats select 0),true];
|
||||
_playerObj setVariable["headShots",(_stats select 1),true];
|
||||
@@ -188,38 +219,46 @@ if (_randomSpot) then {
|
||||
|
||||
//
|
||||
_spawnMC = actualSpawnMarkerCount;
|
||||
|
||||
if (worldName in ["dzhg", "panthera2", "Sara", "Utes", "Dingor", "namalsk", "isladuala", "Tavi", "dayznogova","tasmania2010"]) then { _IslandMap = true; } else { _IslandMap = false; };
|
||||
|
||||
//spawn into random
|
||||
_findSpot = true;
|
||||
_mkr = "";
|
||||
while {_findSpot} do {
|
||||
_counter = 0;
|
||||
while {_counter < 20 && _findSpot} do {
|
||||
// switched to floor
|
||||
_mkr = "spawn" + str(floor(random _spawnMC));
|
||||
_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) && ((_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 && !_isZero) || _isIsland) then {_findSpot = false};
|
||||
_counter = _counter + 1;
|
||||
_mkr = [];
|
||||
_position = [0,0,0];
|
||||
for [{_j=0},{_j<=100 AND _findSpot},{_j=_j+1}] do {
|
||||
if (_spawnSelection == 9) then {
|
||||
// random spawn location selected, lets get the marker and spawn in somewhere
|
||||
if (dayz_spawnselection == 1) then { _mkr = getMarkerPos ("spawn" + str(floor(random 6))); } else { _mkr = getMarkerPos ("spawn" + str(floor(random 5))); };
|
||||
} else {
|
||||
// spawn is not random, lets spawn in our location that was selected
|
||||
_mkr = getMarkerPos ("spawn" + str(_spawnSelection));
|
||||
};
|
||||
_position = ([_mkr,0,spawnArea,10,0,2,spawnShoremode] call BIS_fnc_findSafePos);
|
||||
if ((count _position >= 2) // !bad returned position
|
||||
AND {(_position distance _mkr < 1400)}) then { // !ouside the disk
|
||||
_position set [2, 0];
|
||||
if (((ATLtoASL _position) select 2 > 2.5) //! player's feet too wet
|
||||
AND {({alive _x} count (_position nearEntities ["Man",150]) == 0)}) then { // !too close from other players/zombies
|
||||
_pos = +(_position);
|
||||
_isIsland = false; //Can be set to true during the Check
|
||||
// we check over a 809-meter cross line, with an effective interlaced step of 5 meters
|
||||
for [{_w = 0}, {_w != 809}, {_w = ((_w + 17) % 811)}] do {
|
||||
//if (_w < 17) then { diag_log format[ "%1 loop starts with _w=%2", __FILE__, _w]; };
|
||||
_pos = [((_pos select 0) - _w),((_pos select 1) + _w),(_pos select 2)];
|
||||
if((surfaceisWater _pos) and (!_IslandMap)) exitWith {
|
||||
_isIsland = true;
|
||||
};
|
||||
};
|
||||
if (!_isIsland) then {_findSpot = false};
|
||||
};
|
||||
};
|
||||
//diag_log format["%1: pos:%2 _findSpot:%3", __FILE__, _position, _findSpot];
|
||||
};
|
||||
_isZero = ((_position select 0) == 0) && ((_position select 1) == 0);
|
||||
_position = [_position select 0,_position select 1,0];
|
||||
if (!_isZero) then {
|
||||
//_playerObj setPosATL _position;
|
||||
_worldspace = [0,_position];
|
||||
if ((_findSpot) and (!_IslandMap)) exitWith {
|
||||
diag_log format["%1: Error, failed to find a suitable spawn spot for player. area:%2",__FILE__, _mkr];
|
||||
};
|
||||
_worldspace = [0,_position];
|
||||
};
|
||||
|
||||
//Record player for management
|
||||
@@ -233,23 +272,22 @@ _playerObj setVariable["humanity_CHK",_humanity];
|
||||
//_playerObj setVariable["state",_state,true];
|
||||
_playerObj setVariable["lastPos",getPosATL _playerObj];
|
||||
|
||||
dayzPlayerLogin2 = [_worldspace,_state];
|
||||
|
||||
// PVDZE_obj_Debris = DZE_LocalRoadBlocks;
|
||||
_clientID = owner _playerObj;
|
||||
if (!isNull _playerObj) then {
|
||||
_clientID publicVariableClient "dayzPlayerLogin2";
|
||||
|
||||
if (isNil "PVDZE_plr_SetDate") then {
|
||||
call server_timeSync;
|
||||
};
|
||||
_clientID publicVariableClient "PVDZE_plr_SetDate";
|
||||
if (!isNil "faco_hook_playerSetup") then {
|
||||
[_worldspace,_state,_playerObj, _characterID] call faco_hook_playerSetup;
|
||||
_playerObj call faco_sendSecret;
|
||||
};
|
||||
|
||||
|
||||
PVCDZ_plr_Login2 = [_worldspace,_state,_Achievements];
|
||||
_clientID = owner _playerObj;
|
||||
|
||||
_clientID publicVariableClient "PVCDZ_plr_Login2";
|
||||
_clientID publicVariableClient "PVCDZ_plr_plantSpawner";
|
||||
//record time started
|
||||
_playerObj setVariable ["lastTime",time];
|
||||
//_playerObj setVariable ["model_CHK",typeOf _playerObj];
|
||||
|
||||
//diag_log ("LOGIN PUBLISHING: " + str(_playerObj) + " Type: " + (typeOf _playerObj));
|
||||
|
||||
PVDZE_plr_Login = nil;
|
||||
PVDZE_plr_Login2 = nil;
|
||||
PVDZ_plr_Login1 = null;
|
||||
PVDZ_plr_Login2 = null;
|
||||
@@ -1,7 +1,10 @@
|
||||
private ["_empty","_name","_playerwasNearby","_character","_magazines","_force","_characterID","_charPos","_isInVehicle","_timeSince","_humanity","_debug","_distance","_isNewMed","_isNewPos","_isNewGear","_playerPos","_playerGear","_playerBackp","_medical","_distanceFoot","_lastPos","_backpack","_kills","_killsB","_killsH","_headShots","_lastTime","_timeGross","_timeLeft","_currentWpn","_currentAnim","_config","_onLadder","_isTerminal","_currentModel","_modelChk","_muzzles","_temp","_currentState","_array","_key","_pos","_forceGear","_friendlies"];
|
||||
|
||||
|
||||
_character = _this select 0;
|
||||
_magazines = _this select 1;
|
||||
_Achievements = _character getVariable "Achievements";
|
||||
|
||||
|
||||
//_force = _this select 2;
|
||||
_forceGear = _this select 3;
|
||||
@@ -36,17 +39,33 @@ if (_characterID == "0") exitWith {
|
||||
diag_log ("ERROR: Cannot Sync Character " + (_name) + " as no characterID");
|
||||
};
|
||||
|
||||
if (isNil {_Achievements}) exitWith {
|
||||
diag_log ("ERROR: Cannot Sync Achievements " + (name _character) + " has no default Achievements");
|
||||
_Achievements = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];
|
||||
};
|
||||
|
||||
/*
|
||||
private["_debug","_distance"];
|
||||
_debug = getMarkerpos "respawn_west";
|
||||
_distance = _debug distance _charPos;
|
||||
if (_distance < 2000) exitWith {
|
||||
diag_log format["ERROR: server_playerSync: Cannot Sync Player %1 [%2]. Position in debug! %3",_name,_characterID,_charPos];
|
||||
};
|
||||
}; */
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//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;
|
||||
_isNewGear = if (!isNil "_magazines") then { true } else { false };
|
||||
|
||||
//Check for player initiated updates
|
||||
if (_characterID != "0") then {
|
||||
@@ -80,7 +99,10 @@ if (_characterID != "0") then {
|
||||
};
|
||||
_character setVariable ["posForceUpdate",false,true];
|
||||
};
|
||||
|
||||
if (_isNewGear || _forceGear) then {
|
||||
|
||||
|
||||
//diag_log ("gear..."); uiSleep 0.05;
|
||||
_playerGear = [weapons _character,_magazines];
|
||||
//diag_log ("playerGear: " +str(_playerGear));
|
||||
@@ -92,6 +114,7 @@ if (_characterID != "0") then {
|
||||
_playerBackp = [typeOf _backpack,getWeaponCargo _backpack,getMagazineCargo _backpack];
|
||||
};
|
||||
};
|
||||
|
||||
if (_isNewMed || _force) then {
|
||||
//diag_log ("medical..."); uiSleep 0.05;
|
||||
if (!(_character getVariable["USEC_isDead",false])) then {
|
||||
@@ -121,8 +144,8 @@ if (_characterID != "0") then {
|
||||
/*
|
||||
Assess how much time has passed, for recording total time on server
|
||||
*/
|
||||
_lastTime = _character getVariable["lastTime",time];
|
||||
_timeGross = (time - _lastTime);
|
||||
_lastTime = _character getVariable["lastTime",diag_ticktime];
|
||||
_timeGross = (diag_ticktime - _lastTime);
|
||||
_timeSince = floor(_timeGross / 60);
|
||||
_timeLeft = (_timeGross - (_timeSince * 60));
|
||||
/*
|
||||
@@ -139,7 +162,7 @@ if (_characterID != "0") then {
|
||||
if (_currentModel == _modelChk) then {
|
||||
_currentModel = "";
|
||||
} else {
|
||||
_currentModel = _currentModel;
|
||||
_currentModel = str(_currentModel);
|
||||
_character setVariable ["model_CHK",typeOf _character];
|
||||
};
|
||||
|
||||
@@ -165,7 +188,9 @@ if (_characterID != "0") then {
|
||||
};
|
||||
};
|
||||
_temp = round(_character getVariable ["temperature",100]);
|
||||
_currentState = [_currentWpn,_currentAnim,_temp];
|
||||
|
||||
_currentState = [[_currentWpn,_currentAnim,_temp],_Achievements];
|
||||
|
||||
if(DZE_FriendlySaving) then {
|
||||
// save only last/most recent 5 entrys as we only have 200 chars in db field && weapon + animation names are sometimes really long 60-70 chars.
|
||||
_friendlies = [(_character getVariable ["friendlies",[]]),5] call array_reduceSizeReverse;
|
||||
@@ -183,16 +208,21 @@ if (_characterID != "0") then {
|
||||
} count (_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;
|
||||
@@ -203,14 +233,15 @@ if (_characterID != "0") then {
|
||||
};
|
||||
|
||||
// Force gear updates for nearby vehicles/tents
|
||||
|
||||
{
|
||||
[_x, "gear"] call server_updateObject;
|
||||
} count (nearestObjects [_charPos, dayz_updateObjects, 10]);
|
||||
} count (nearestObjects [_charPos, DayZ_GearedObjects, 10]);
|
||||
//[_charPos] call server_updateNearbyObjects;
|
||||
|
||||
//Reset timer
|
||||
if (_timeSince > 0) then {
|
||||
_character setVariable ["lastTime",(time - _timeLeft)];
|
||||
_character setVariable ["lastTime",(diag_ticktime - _timeLeft)];
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
@@ -1,101 +0,0 @@
|
||||
private ["_unit","_variable","_arraytosend","_owner","_vehicle","_qty"];
|
||||
//Inbound [_unit,"PVCDZ_hlt_Transfuse",[_unit,player,1000]]
|
||||
_unit = _this select 0;
|
||||
|
||||
if(isNull _unit) exitWith {diag_log format ["ERROR: sendToClient is Null: %1", _unit]};
|
||||
|
||||
_variable = _this select 1;
|
||||
_arraytosend = _this select 2;
|
||||
_owner = owner _unit;
|
||||
|
||||
//diag_log format ["%1, %2, %3, %4", _unit, _variable, _arraytosend, _owner];
|
||||
|
||||
//execution
|
||||
switch (_variable) do {
|
||||
case "VehHandleDam": {
|
||||
_vehicle = _arraytosend select 0;
|
||||
if (local _vehicle) then {
|
||||
_arraytosend call fnc_veh_handleDam;
|
||||
} else {
|
||||
PVCDZE_vehSH = _arraytosend;
|
||||
_owner publicVariableClient "PVCDZE_vehSH";
|
||||
};
|
||||
};
|
||||
|
||||
case "SFuel": {
|
||||
_vehicle = _arraytosend select 0;
|
||||
_qty = _arraytosend select 1;
|
||||
if (local _vehicle) then {
|
||||
_vehicle setFuel _qty;
|
||||
} else {
|
||||
PVDZE_veh_SFuel = _arraytosend;
|
||||
_owner publicVariableClient "PVDZE_veh_SFuel";
|
||||
};
|
||||
};
|
||||
|
||||
case "HideBody": {
|
||||
PVDZE_plr_HideBody = _arraytosend select 0;
|
||||
_owner publicVariableClient "PVDZE_plr_HideBody";
|
||||
};
|
||||
|
||||
case "Humanity": {
|
||||
PVDZE_plr_HumanityChange = _arraytosend;
|
||||
_owner publicVariableClient "PVDZE_plr_HumanityChange";
|
||||
};
|
||||
|
||||
case "PZ_BreakLegs": {
|
||||
usecBreakLegs = _arraytosend;
|
||||
_owner publicVariableClient "usecBreakLegs";
|
||||
};
|
||||
|
||||
case "Bleed": {
|
||||
usecBleed = _arraytosend;
|
||||
_owner publicVariableClient "usecBleed";
|
||||
};
|
||||
|
||||
case "HideObj": {
|
||||
PVDZE_obj_Hide = _arraytosend select 0;
|
||||
_owner publicVariableClient "PVDZE_obj_Hide";
|
||||
};
|
||||
|
||||
case "RoadFlare": {
|
||||
PVDZE_obj_RoadFlare = _arraytosend;
|
||||
_owner publicVariableClient "PVDZE_obj_RoadFlare";
|
||||
};
|
||||
|
||||
case "Transfuse": {
|
||||
usecTransfuse = _arraytosend;
|
||||
_owner publicVariableClient "usecTransfuse";
|
||||
_unit setVariable["medForceUpdate",true];
|
||||
};
|
||||
|
||||
case "Painkiller": {
|
||||
usecPainK = _arraytosend;
|
||||
_owner publicVariableClient "usecPainK";
|
||||
_unit setVariable["medForceUpdate",true];
|
||||
};
|
||||
|
||||
case "Morphine": {
|
||||
usecMorphine = _arraytosend;
|
||||
_owner publicVariableClient "usecMorphine";
|
||||
_unit setVariable ["hit_legs",0,false];
|
||||
_unit setVariable ["hit_hands",0,false];
|
||||
_unit setVariable["medForceUpdate",true];
|
||||
};
|
||||
|
||||
case "Epinephrine": {
|
||||
usecEpi = _arraytosend;
|
||||
_owner publicVariableClient "usecEpi";
|
||||
_unit setVariable["medForceUpdate",true];
|
||||
};
|
||||
|
||||
case "Bandage": {
|
||||
usecBandage = _arraytosend;
|
||||
_owner publicVariableClient "usecBandage";
|
||||
_unit setVariable["medForceUpdate",true];
|
||||
};
|
||||
case "tagFriendly": {
|
||||
PVDZE_plr_FriendRQ = _arraytosend;
|
||||
_owner publicVariableClient "PVDZE_plr_FriendRQ";
|
||||
};
|
||||
};
|
||||
85
SQF/dayz_server/compile/server_spawnCarePackages.sqf
Normal file
85
SQF/dayz_server/compile/server_spawnCarePackages.sqf
Normal file
@@ -0,0 +1,85 @@
|
||||
/*
|
||||
Spawns care packages.
|
||||
|
||||
Single parameter:
|
||||
integer Number of care packages to spawn.
|
||||
|
||||
Author:
|
||||
Foxy
|
||||
*/
|
||||
|
||||
#include "\z\addons\dayz_code\util\Math.hpp"
|
||||
#include "\z\addons\dayz_code\util\Vector.hpp"
|
||||
#include "\z\addons\dayz_code\loot\Loot.hpp"
|
||||
|
||||
//Number of care packages to spawn
|
||||
#define SPAWN_NUM 6
|
||||
|
||||
#define SEARCH_CENTER [7542,7134]
|
||||
#define SEARCH_RADIUS 6150
|
||||
#define SEARCH_DIST_MIN 30
|
||||
#define SEARCH_SLOPE_MAX 1000
|
||||
#define SEARCH_BLACKLIST [[[12923,3643],[14275,2601]]]
|
||||
|
||||
private
|
||||
[
|
||||
"_typeGroup",
|
||||
"_position",
|
||||
"_type",
|
||||
"_class",
|
||||
"_vehicle",
|
||||
"_loot",
|
||||
"_lootGroup",
|
||||
"_lootNum",
|
||||
"_lootPos",
|
||||
"_lootVeh",
|
||||
"_size"
|
||||
];
|
||||
|
||||
_lootGroup = Loot_GetGroup("CarePackage");
|
||||
_typeGroup = Loot_GetGroup("CarePackageType");
|
||||
|
||||
for "_i" from 1 to (SPAWN_NUM) do
|
||||
{
|
||||
_type = Loot_SelectSingle(_typeGroup);
|
||||
_class = _type select 1;
|
||||
_lootNum = round Math_RandomRange(_type select 2, _type select 3);
|
||||
_position = [SEARCH_CENTER, 0, SEARCH_RADIUS, SEARCH_DIST_MIN, 0, SEARCH_SLOPE_MAX, 0, SEARCH_BLACKLIST] call BIS_fnc_findSafePos;
|
||||
_position set [2, 0];
|
||||
|
||||
diag_log format ["DEBUG: Spawning a care package (%1) at %2 with %3 items.", _class, _position, _lootNum];
|
||||
|
||||
_vehicle = createVehicle [_class, _position, [], 0, "CAN_COLLIDE"];
|
||||
dayz_serverObjectMonitor set [count dayz_serverObjectMonitor, _vehicle];
|
||||
_vehicle setVariable ["ObjectID", 1, true];
|
||||
|
||||
_size = sizeOf _class;
|
||||
|
||||
{
|
||||
//Calculate random loot position
|
||||
_lootPos = Vector_Add(_position, Vector_Multiply(Vector_FromDir(random 360), _size * 0.6 + random _size));
|
||||
_lootPos set [2, 0];
|
||||
|
||||
_lootVeh = Loot_Spawn(_x, _lootPos);
|
||||
_lootVeh setVariable ["permaLoot", true];
|
||||
|
||||
switch (dayz_spawncarepkgs_clutterCutter) do
|
||||
{
|
||||
case 1: //Lift loot up by 5cm
|
||||
{
|
||||
_lootPos set [2, 0.05];
|
||||
_lootVeh setPosATL _lootpos;
|
||||
};
|
||||
|
||||
case 2: //Clutter cutter
|
||||
{
|
||||
createVehicle ["ClutterCutter_small_2_EP1", _lootPos, [], 0, "CAN_COLLIDE"];
|
||||
};
|
||||
|
||||
case 3: //Debug sphere
|
||||
{
|
||||
createVehicle ["Sign_sphere100cm_EP1", _lootPos, [], 0, "CAN_COLLIDE"];
|
||||
};
|
||||
};
|
||||
} foreach Loot_Select(_lootGroup, _lootNum);
|
||||
};
|
||||
139
SQF/dayz_server/compile/server_spawnCrashSites.sqf
Normal file
139
SQF/dayz_server/compile/server_spawnCrashSites.sqf
Normal file
@@ -0,0 +1,139 @@
|
||||
/*
|
||||
Spawns crash sites at the beginning of mission and periodically during it.
|
||||
|
||||
Author:
|
||||
Foxy
|
||||
*/
|
||||
|
||||
#include "\z\addons\dayz_code\util\Math.hpp"
|
||||
#include "\z\addons\dayz_code\util\Vector.hpp"
|
||||
#include "\z\addons\dayz_code\loot\Loot.hpp"
|
||||
|
||||
//Spawn frequency ± variance in minutes
|
||||
#define SPAWN_FREQUENCY 40
|
||||
#define SPAWN_VARIANCE 15
|
||||
|
||||
//The higher the number, the more accurate the timer is.
|
||||
//Must be positive and non-zero.
|
||||
#define TIMER_RESOLUTION 10
|
||||
|
||||
//Chance to spawn a crash site
|
||||
#define SPAWN_CHANCE 0.75
|
||||
|
||||
//Parameters for finding a suitable position to spawn the crash site
|
||||
#define SEARCH_CENTER [7049,9241]
|
||||
#define SEARCH_RADIUS 4880
|
||||
#define SEARCH_DIST_MIN 20
|
||||
#define SEARCH_SLOPE_MAX 2
|
||||
#define SEARCH_BLACKLIST [[[2092,14167],[10558,12505]]]
|
||||
|
||||
//Number of crash sites to spawn at the beginning of the mission
|
||||
#define INITIAL_NUM 3
|
||||
|
||||
//Number of loot items to spawn per site
|
||||
#define LOOT_MIN 5
|
||||
#define LOOT_MAX 8
|
||||
|
||||
private
|
||||
[
|
||||
"_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];
|
||||
|
||||
_spawnCrashSite =
|
||||
{
|
||||
_type = Loot_SelectSingle(Loot_GetGroup("CrashSiteType"));
|
||||
_class = _type select 1;
|
||||
_lootGroup = Loot_GetGroup(_type select 2);
|
||||
|
||||
_position = [SEARCH_CENTER, 0, SEARCH_RADIUS, SEARCH_DIST_MIN, 0, SEARCH_SLOPE_MAX, 0, SEARCH_BLACKLIST] call BIS_fnc_findSafePos;
|
||||
_position set [2, 0];
|
||||
|
||||
_lootNum = round Math_RandomRange(LOOT_MIN, LOOT_MAX);
|
||||
|
||||
diag_log format ["CRASHSPAWNER: Spawning crash site (%1) at %2 with %3 items.", _class, _position, _lootNum];
|
||||
|
||||
_vehicle = createVehicle ["ClutterCutter_small_2_EP1", _position, [], 0, "CAN_COLLIDE"];
|
||||
_vehicle = createVehicle [_class, _position, [], 0, "CAN_COLLIDE"];
|
||||
dayz_serverObjectMonitor set [count dayz_serverObjectMonitor, _vehicle];
|
||||
_vehicle setVariable ["ObjectID", 1, true];
|
||||
_vehicle setDir random 360;
|
||||
_vehicle setPos _position;
|
||||
|
||||
_lootParams = getArray (configFile >> "CfgVehicles" >> _class >> "lootParams");
|
||||
|
||||
{
|
||||
_dir = random 360;
|
||||
_mag = random (_lootParams select 4);
|
||||
_lootPos = [((_lootParams select 2) + _mag) * sin _dir, ((_lootParams select 3) + _mag) * cos _dir, 0];
|
||||
_lootPos = Vector_Add(_lootPos, _lootParams select 0);
|
||||
_lootPos = Vector_Rotate2D(_lootPos, _lootParams select 1);
|
||||
_lootPos = _vehicle modelToWorld _lootPos;
|
||||
_lootPos set [2, 0];
|
||||
|
||||
_lootVeh = Loot_Spawn(_x, _lootPos);
|
||||
_lootVeh setVariable ["permaLoot", true];
|
||||
|
||||
switch (dayz_spawnCrashSite_clutterCutter) do
|
||||
{
|
||||
case 1: //Lift loot up by 5cm
|
||||
{
|
||||
_lootPos set [2, 0.05];
|
||||
_lootVeh setPosATL _lootpos;
|
||||
};
|
||||
|
||||
case 2: //Clutter cutter
|
||||
{
|
||||
createVehicle ["ClutterCutter_small_2_EP1", _lootPos, [], 0, "CAN_COLLIDE"];
|
||||
};
|
||||
|
||||
case 3: //Debug sphere
|
||||
{
|
||||
createVehicle ["Sign_sphere100cm_EP1", _lootPos, [], 0, "CAN_COLLIDE"];
|
||||
};
|
||||
};
|
||||
}
|
||||
foreach Loot_Select(_lootGroup, _lootNum);
|
||||
};
|
||||
|
||||
//Spawn initial crash sites
|
||||
for "_i" from 1 to (INITIAL_NUM) do
|
||||
{
|
||||
call _spawnCrashSite;
|
||||
};
|
||||
|
||||
while {true} do
|
||||
{
|
||||
//Pick a time to attempt spawning
|
||||
//currentTime + frequency + ±1 * variance
|
||||
_time = time + 60 * ((SPAWN_FREQUENCY) + ((round random 1) * 2 - 1) * random (SPAWN_VARIANCE));
|
||||
|
||||
//Wait until the previously decided time
|
||||
while {time < _time} do
|
||||
{
|
||||
sleep (60 * (SPAWN_FREQUENCY) / (TIMER_RESOLUTION));
|
||||
};
|
||||
|
||||
//try to spawn
|
||||
if ((SPAWN_CHANCE) > random 1) then
|
||||
{
|
||||
call _spawnCrashSite;
|
||||
};
|
||||
};
|
||||
91
SQF/dayz_server/compile/server_spawnInfectedCamps.sqf
Normal file
91
SQF/dayz_server/compile/server_spawnInfectedCamps.sqf
Normal file
@@ -0,0 +1,91 @@
|
||||
/*
|
||||
Spawns infected camps
|
||||
|
||||
Author:
|
||||
Foxy
|
||||
*/
|
||||
|
||||
#include "\z\addons\dayz_code\util\Math.hpp"
|
||||
#include "\z\addons\dayz_code\loot\Loot.hpp"
|
||||
|
||||
//Number of infected camps to spawn
|
||||
#define CAMP_NUM 3
|
||||
|
||||
//Minimum distance between camps
|
||||
#define CAMP_MIN_DIST 300
|
||||
|
||||
//Base class of objects to add loot to
|
||||
#define CAMP_CONTAINER_BASE "IC_Tent"
|
||||
|
||||
//Loot per tent
|
||||
#define LOOT_MIN 10
|
||||
#define LOOT_MAX 20
|
||||
|
||||
//Random objects per camp
|
||||
#define OBJECT_MIN 4
|
||||
#define OBJECT_MAX 12
|
||||
|
||||
//Radius around the camp in which random objects are spawned
|
||||
#define OBJECT_RADIUS_MIN 8
|
||||
#define OBJECT_RADIUS_MAX 13
|
||||
|
||||
#define SEARCH_CENTER getMarkerPos "center"
|
||||
#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
|
||||
#define SEARCH_ATTEMPTS 10
|
||||
|
||||
private
|
||||
[
|
||||
"_typeGroup",
|
||||
"_lootGroup",
|
||||
"_objectGroup",
|
||||
"_type",
|
||||
"_position",
|
||||
"_composition",
|
||||
"_compositionObjects",
|
||||
"_objectPos"
|
||||
];
|
||||
|
||||
_typeGroup = Loot_GetGroup("InfectedCampType");
|
||||
_lootGroup = Loot_GetGroup("InfectedCamp");
|
||||
_objectGroup = Loot_GetGroup("InfectedCampObject");
|
||||
|
||||
for "_i" from 1 to (CAMP_NUM) do
|
||||
{
|
||||
//Select type of camp
|
||||
_type = Loot_SelectSingle(_typeGroup);
|
||||
_composition = _type select 1;
|
||||
|
||||
//Find a position
|
||||
|
||||
for "_j" from 1 to (SEARCH_ATTEMPTS) do
|
||||
{
|
||||
_position = ((selectBestPlaces [SEARCH_CENTER, SEARCH_RADIUS, SEARCH_EXPRESSION, SEARCH_PRECISION, 1]) select 0) select 0;
|
||||
_position set [2, 0];
|
||||
|
||||
//Check if a camp already exists within the minimum distance
|
||||
if (count (nearestObjects [_position, [CAMP_CONTAINER_BASE], CAMP_MIN_DIST]) < 1) exitWith {};
|
||||
};
|
||||
|
||||
diag_log format ["Spawning an infected camp (%1) at %2", _composition, _position];
|
||||
|
||||
//Spawn composition
|
||||
_compositionObjects = [_position, random 360,_composition] call spawnComposition;
|
||||
|
||||
//Add loot to containers
|
||||
{
|
||||
if (_x isKindOf (CAMP_CONTAINER_BASE)) then
|
||||
{
|
||||
Loot_InsertCargo(_x, _lootGroup, round Math_RandomRange(LOOT_MIN, LOOT_MAX));
|
||||
};
|
||||
} foreach _compositionObjects;
|
||||
|
||||
//Spawn objects around the camp
|
||||
{
|
||||
_objectPos = [_position, OBJECT_RADIUS_MIN, OBJECT_RADIUS_MAX, 5] call fn_selectRandomLocation;
|
||||
|
||||
Loot_Spawn(_x, _objectPos);
|
||||
|
||||
} foreach Loot_Select(_objectGroup, round Math_RandomRange(OBJECT_MIN, OBJECT_MAX));
|
||||
};
|
||||
19
SQF/dayz_server/compile/server_toggle_debug.hpp
Normal file
19
SQF/dayz_server/compile/server_toggle_debug.hpp
Normal file
@@ -0,0 +1,19 @@
|
||||
/*
|
||||
Created exclusively for ArmA2:OA - DayZMod.
|
||||
Please request permission to use/alter/distribute from project leader (R4Z0R49)
|
||||
*/
|
||||
|
||||
//// TOGGLE DEBUGS ////
|
||||
|
||||
// comment this out if you don't want any LOGIN related debug
|
||||
#define LOGIN_DEBUG
|
||||
|
||||
// comment this out if you don't want any VEHICLE/TENT/OBJECT related debug
|
||||
#define OBJECT_DEBUG
|
||||
|
||||
// comment this out if you don't want any PLAYER (WORLDSPACE/INVENTORY/ETC) related debug
|
||||
#define PLAYER_DEBUG
|
||||
|
||||
// comment this out if you don't want any misc SERVER (ZOMBIE, LOOT, CLEANUP) related debug
|
||||
#define SERVER_DEBUG
|
||||
|
||||
9
SQF/dayz_server/compile/server_updateNearbyObjects.sqf
Normal file
9
SQF/dayz_server/compile/server_updateNearbyObjects.sqf
Normal file
@@ -0,0 +1,9 @@
|
||||
private["_pos"];
|
||||
_pos = _this select 0;
|
||||
#include "\z\addons\dayz_server\compile\server_toggle_debug.hpp"
|
||||
|
||||
|
||||
{
|
||||
[_x, "gear"] call server_updateObject;
|
||||
} forEach nearestObjects [_pos, DayZ_GearedObjects, 10];
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
USAGE:
|
||||
[_object, _type] spawn server_updateObject;
|
||||
*/
|
||||
#include "\z\addons\dayz_server\compile\server_toggle_debug.hpp"
|
||||
if (isNil "sm_done") exitwith {};
|
||||
|
||||
private ["_object","_type","_objectID","_uid","_lastUpdate","_needUpdate","_object_position","_object_inventory","_object_damage","_isNotOk","_parachuteWest","_firstTime","_object_killed","_object_repair","_isbuildable"];
|
||||
|
||||
@@ -11,25 +13,51 @@ if (isNull _object) exitWith {
|
||||
diag_log format ["Skipping Null Object: %1", _object];
|
||||
};
|
||||
|
||||
_type = _this select 1;
|
||||
_type = _this select 1;
|
||||
_forced = false;
|
||||
_recorddmg = false;
|
||||
_parachuteWest = (typeOf _object) in ["ParachuteWest","ParachuteC"];
|
||||
_isbuildable = (typeOf _object) in dayz_allowedObjects;
|
||||
_isNotOk = false;
|
||||
_firstTime = false;
|
||||
|
||||
_objectID = _object getVariable ["ObjectID","0"];
|
||||
_uid = _object getVariable ["ObjectUID","0"];
|
||||
_objectID = "0";
|
||||
_objectUID = "0";
|
||||
|
||||
if (typeName _objectID != "STRING" || typeName _uid != "STRING") then {
|
||||
diag_log format ["Non-string Object: ID %1 UID %2", _objectID, _uid];
|
||||
_objectID = "0";
|
||||
_uid = "0";
|
||||
if (!((isNil "_object") OR {(isNull _object)})) then {
|
||||
_objectID = _object getVariable ["ObjectID","0"];
|
||||
_objectUID = _object getVariable ["ObjectUID","0"];
|
||||
};
|
||||
|
||||
if ((typeName _objectID == "SCALAR") || (typeName _objectUID == "SCALAR")) then {
|
||||
|
||||
#ifdef OBJECT_DEBUG
|
||||
diag_log(format["Non-string Object: ID %1 UID %2", _objectID, _objectUID]);
|
||||
#endif
|
||||
|
||||
//force fail
|
||||
_objectID = nil;
|
||||
_objectUID = nil;
|
||||
};
|
||||
|
||||
if (!_parachuteWest && !locked _object) then {
|
||||
if (_objectID == "0" && _uid == "0") then {
|
||||
if (!(_objectID in dayz_serverIDMonitor) AND isNil {_objectUID}) then {
|
||||
//force fail
|
||||
_objectID = nil;
|
||||
_objectUID = nil;
|
||||
};
|
||||
|
||||
if ((isNil {_objectID}) AND (isNil {_objectUID})) then
|
||||
{
|
||||
_object_position = getPosATL _object;
|
||||
_isNotOk = true;
|
||||
#ifdef OBJECT_DEBUG
|
||||
diag_log(format["Object %1 with invalid ID at pos [%2,%3,%4]",
|
||||
typeOf _object,
|
||||
_object_position select 0,
|
||||
_object_position select 1,
|
||||
_object_position select 2]);
|
||||
#endif
|
||||
_isNotOk = true;
|
||||
};
|
||||
};
|
||||
|
||||
@@ -39,75 +67,143 @@ if (_isNotOk) exitWith {
|
||||
diag_log format ["Deleting object %1 with invalid ID at pos [%2,%3,%4]", typeOf _object, _object_position select 0, _object_position select 1, _object_position select 2];
|
||||
};
|
||||
|
||||
_lastUpdate = _object getVariable ["lastUpdate", time];
|
||||
_lastUpdate = _object getVariable ["lastUpdate",diag_tickTime];
|
||||
_needUpdate = _object in needUpdate_objects;
|
||||
|
||||
_object_position = {
|
||||
private ["_position","_worldspace","_fuel","_key"];
|
||||
private["_position","_worldspace","_fuel","_key"];
|
||||
_position = getPosATL _object;
|
||||
_worldspace = [
|
||||
round (getDir _object),
|
||||
round(direction _object),
|
||||
_position
|
||||
];
|
||||
_fuel = if (_object isKindOf "AllVehicles") then { fuel _object } else { 0 };
|
||||
_key = format ["CHILD:305:%1:%2:%3:", _objectID, _worldspace, _fuel];
|
||||
_key call server_hiveWrite;
|
||||
_fuel = 0;
|
||||
if (_object isKindOf "AllVehicles") then {
|
||||
_fuel = fuel _object;
|
||||
};
|
||||
|
||||
_key = format["CHILD:305:%1:%2:%3:",_objectID,_worldspace,_fuel];
|
||||
_key call server_hiveWrite;
|
||||
|
||||
#ifdef OBJECT_DEBUG
|
||||
diag_log ("HIVE: WRITE: "+ str(_key));
|
||||
#endif
|
||||
};
|
||||
|
||||
_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];
|
||||
_key = if (_objectID == "0") then { format ["CHILD:309:%1:", _uid] + str _inventory + ":" } else { format ["CHILD:303:%1:", _objectID] + str _inventory + ":" };
|
||||
if (_object isKindOf "TrapItems") then {
|
||||
_inventory = [["armed",_object getVariable ["armed", false]]];
|
||||
} else {
|
||||
_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:",_objectUID,_inventory];
|
||||
} else {
|
||||
_key = format["CHILD:303:%1:%2:",_objectID,_inventory];
|
||||
};
|
||||
|
||||
#ifdef OBJECT_DEBUG
|
||||
diag_log ("HIVE: WRITE: "+ str(_key));
|
||||
#endif
|
||||
|
||||
_key call server_hiveWrite;
|
||||
};
|
||||
};
|
||||
|
||||
_object_damage = {
|
||||
private ["_hitpoints","_array","_hit","_selection","_key","_damage"];
|
||||
//Allow dmg process
|
||||
private["_hitpoints","_array","_hit","_selection","_key","_damage", "_allFixed"];
|
||||
_hitpoints = _object call vehicle_getHitpoints;
|
||||
_damage = damage _object;
|
||||
|
||||
_array = [];
|
||||
_allFixed = true;
|
||||
{
|
||||
_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]];
|
||||
};
|
||||
_object setHit [_selection, _hit];
|
||||
} count _hitpoints;
|
||||
_hit = [_object,_x] call object_getHit;
|
||||
_selection = getText (configFile >> "CfgVehicles" >> (typeOf _object) >> "HitPoints" >> _x >> "name");
|
||||
if (_hit > 0) then {
|
||||
_allFixed = false;
|
||||
_array set [count _array,[_selection,_hit]];
|
||||
//diag_log format ["Section Part: %1, Dmg: %2",_selection,_hit];
|
||||
} else {
|
||||
_array set [count _array,[_selection,0]];
|
||||
};
|
||||
|
||||
} forEach _hitpoints;
|
||||
|
||||
if (_allFixed) then {
|
||||
_object setDamage 0;
|
||||
};
|
||||
|
||||
_key = "CHILD:306:" + _objectID + ":" + str _array + ":" + str _damage + ":";
|
||||
_key call server_hiveWrite;
|
||||
_object setVariable ["needUpdate", false, true];
|
||||
if (_forced) then {
|
||||
if (_object in needUpdate_objects) then {
|
||||
needUpdate_objects = needUpdate_objects - [_object];
|
||||
};
|
||||
_recorddmg = true;
|
||||
} else {
|
||||
//Prevent damage events for the first 10 seconds of the servers live.
|
||||
if (diag_ticktime - _lastUpdate > 10) then {
|
||||
if (!(_object in needUpdate_objects)) then {
|
||||
//diag_log format["DEBUG: Monitoring: %1",_object];
|
||||
needUpdate_objects set [count needUpdate_objects, _object];
|
||||
_recorddmg = true;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
if (_recorddmg) then {
|
||||
if (_objectID == "0") then {
|
||||
_key = format["CHILD:306:%1:%2:%3:",_objectUID,_array,_damage];
|
||||
} else {
|
||||
_key = format["CHILD:306:%1:%2:%3:",_objectID,_array,_damage];
|
||||
};
|
||||
diag_log ("HIVE: WRITE: "+ str(_key));
|
||||
_key call server_hiveWrite;
|
||||
};
|
||||
};
|
||||
|
||||
//Walls
|
||||
_objWallDamage = {
|
||||
private["_key"];
|
||||
_damage = _this select 2;
|
||||
|
||||
_object setDamage _damage;
|
||||
|
||||
if (_objectID == "0") then {
|
||||
_key = format["CHILD:306:%1:%2:%3:",_objectUID,[],_damage];
|
||||
} else {
|
||||
_key = format["CHILD:306:%1:%2:%3:",_objectID,[],_damage];
|
||||
};
|
||||
|
||||
_key call server_hiveWrite;
|
||||
};
|
||||
|
||||
_object_killed = {
|
||||
private ["_hitpoints","_array","_hit","_PUID","_selection","_key","_damage"];
|
||||
_hitpoints = _object call vehicle_getHitpoints;
|
||||
_damage = 1;
|
||||
|
||||
_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]];
|
||||
};
|
||||
_object setHit [_selection, 1];
|
||||
} count _hitpoints;
|
||||
|
||||
_key = "CHILD:306:" + _objectID + ":" + str _array + ":" + str _damage + ":";
|
||||
_key call server_hiveWrite;
|
||||
|
||||
_object setVariable ["needUpdate", false, true];
|
||||
private["_key"];
|
||||
_object setDamage 1;
|
||||
|
||||
if (_objectID == "0") then {
|
||||
//Need to update hive to make a new call too allow UID to be updated for a killed event
|
||||
//_key = format["CHILD:306:%1:%2:%3:",_objectUID,[],1];
|
||||
_key = format["CHILD:310:%1:",_objectUID];
|
||||
} else {
|
||||
_key = format["CHILD:306:%1:%2:%3:",_objectID,[],1];
|
||||
};
|
||||
|
||||
diag_log ("HIVE: WRITE: "+ str(_key));
|
||||
_key call server_hiveWrite;
|
||||
|
||||
if ((typeOf _object) in DayZ_removableObjects) then {
|
||||
[_objectID,_objectUID] call server_deleteObj;
|
||||
};
|
||||
|
||||
if (count _this > 2) then {
|
||||
_killer = _this select 2;
|
||||
@@ -145,38 +241,80 @@ _object_repair = {
|
||||
_object setVariable ["needUpdate", false, true];
|
||||
};
|
||||
|
||||
_object setVariable ["lastUpdate", time, true];
|
||||
_object_maintenance = {
|
||||
private["_ownerArray","_key"];
|
||||
|
||||
if (_type == "all") exitWith {
|
||||
call _object_position;
|
||||
call _object_inventory;
|
||||
call _object_damage;
|
||||
};
|
||||
_ownerArray = _object getVariable ["ownerArray",[]];
|
||||
_accessArray = _object getVariable ["dayz_padlockCombination",[]];
|
||||
|
||||
_variables set [ count _variables, ["ownerArray", _ownerArray]];
|
||||
_variables set [ count _variables, ["padlockCombination", _accessArray]];
|
||||
|
||||
if (_type == "position") exitWith {
|
||||
if !(_object in needUpdate_objects) then {
|
||||
needUpdate_objects set [count needUpdate_objects, _object];
|
||||
};
|
||||
};
|
||||
|
||||
if (_type == "gear") exitWith {
|
||||
call _object_inventory;
|
||||
};
|
||||
|
||||
if (_type == "damage") exitWith {
|
||||
if (time - _lastUpdate > 5) then {
|
||||
call _object_damage;
|
||||
if (_objectID == "0") then {
|
||||
_key = format["CHILD:309:%1:%2:",_objectUID,_ownerArray];
|
||||
//Wont work just now.
|
||||
_key = format["CHILD:306:%1:%2:%3:",_objectUID,[],0];
|
||||
} else {
|
||||
if !(_object in needUpdate_objects) then {
|
||||
needUpdate_objects set [count needUpdate_objects, _object];
|
||||
};
|
||||
_key = format["CHILD:303:%1:%2:",_objectID,_ownerArray];
|
||||
_key = format["CHILD:306:%1:%2:%3:",_objectID,[],0];
|
||||
};
|
||||
|
||||
// #ifdef OBJECT_DEBUG
|
||||
diag_log ("HIVE: WRITE: Maintenance, "+ str(_key));
|
||||
// #endif
|
||||
|
||||
_key call server_hiveWrite;
|
||||
};
|
||||
|
||||
_object_variables = {
|
||||
private["_ownerArray","_key","_accessArray","_variables"];
|
||||
|
||||
_ownerArray = _object getVariable ["ownerArray",[]];
|
||||
_accessArray = _object getVariable ["dayz_padlockCombination",[]];
|
||||
_lockedArray = _object getVariable ["BuildLock",false];
|
||||
|
||||
//diag_log format ["[%1,%2]",_ownerArray,_accessArray];
|
||||
_variables = [];
|
||||
|
||||
_variables set [ count _variables, ["ownerArray", _ownerArray]];
|
||||
_variables set [ count _variables, ["padlockCombination", _accessArray]];
|
||||
_variables set [ count _variables, ["BuildLock", _lockedArray]];
|
||||
|
||||
if (_objectID == "0") then {
|
||||
_key = format["CHILD:309:%1:%2:",_objectUID,_variables];
|
||||
} else {
|
||||
_key = format["CHILD:303:%1:%2:",_objectID,_variables];
|
||||
};
|
||||
|
||||
_key call server_hiveWrite;
|
||||
};
|
||||
|
||||
_object setVariable ["lastUpdate",diag_ticktime,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 "maintenance": {
|
||||
call _object_maintenance;
|
||||
};
|
||||
case "damage"; case "repair" : {
|
||||
call _object_damage;
|
||||
};
|
||||
case "killed": {
|
||||
call _object_killed;
|
||||
};
|
||||
case "accessCode"; case "buildLock" : {
|
||||
call _object_variables;
|
||||
};
|
||||
case "objWallDamage": {
|
||||
call _objWallDamage;
|
||||
};
|
||||
};
|
||||
|
||||
if (_type == "killed") exitWith {
|
||||
call _object_killed;
|
||||
};
|
||||
|
||||
if (_type == "repair") exitWith {
|
||||
call _object_damage;
|
||||
};
|
||||
|
||||
51
SQF/dayz_server/compile/zombie_Wildgenerate.sqf
Normal file
51
SQF/dayz_server/compile/zombie_Wildgenerate.sqf
Normal file
@@ -0,0 +1,51 @@
|
||||
private ["_position","_doLoiter","_unitTypes","_array","_agent","_type","_radius","_method","_rndx","_rndy","_counter","_amount","_wildsdone"];
|
||||
_unitTypes = _this select 0;
|
||||
_amount = _this select 1;
|
||||
//_doLoiter = true;
|
||||
_wildsdone = true;
|
||||
_counter = 0;
|
||||
|
||||
while {_counter < _amount} do {
|
||||
//_loot = "";
|
||||
//_array = [];
|
||||
_agent = objNull;
|
||||
_type = _unitTypes call BIS_fnc_selectRandom;
|
||||
|
||||
//Create the Group and populate it
|
||||
//diag_log ("Spawned: " + _type);
|
||||
//_radius = 0;
|
||||
_method = "CAN_COLLIDE";
|
||||
|
||||
//_createSafePos = getMarkerPos "center";
|
||||
_position = [getMarkerPos "center",1,6500,1] call fn_selectRandomLocation;
|
||||
|
||||
//Create Zed
|
||||
_agent = createAgent [_type, _position, [], 1, _method];
|
||||
//Set Random Direction
|
||||
_agent setDir floor(random 360);
|
||||
//Loiter State
|
||||
_agent setVariable ["doLoiter",true]; //Might not be used.
|
||||
//Zed stance
|
||||
if (random 1 > 0.7) then {
|
||||
_agent setUnitPos "Middle";
|
||||
};
|
||||
//Set home location to loiter around
|
||||
_position = getPosATL _agent;
|
||||
_agent setVariable ["homePos",_position,true];
|
||||
//Store _agentobject
|
||||
_agent setVariable["agentObject",_agent,true];
|
||||
|
||||
//add to counter
|
||||
_counter = _counter + 1;
|
||||
|
||||
//Start behavior
|
||||
//_id = [_position,_agent] execFSM "\z\AddOns\dayz_code\system\zombie_wildagent.fsm";
|
||||
//_agent setVariable [ "fsmid", _id ];
|
||||
|
||||
//Disable all zed systems
|
||||
_agent enableSimulation false;
|
||||
|
||||
//diag_log format ["CREATE WILD: Active: %1, Waiting: %2",_counter,(_amount - _counter)]
|
||||
};
|
||||
|
||||
_wildsdone
|
||||
8
SQF/dayz_server/compile/zombie_findOwner.sqf
Normal file
8
SQF/dayz_server/compile/zombie_findOwner.sqf
Normal file
@@ -0,0 +1,8 @@
|
||||
private["_unit"];
|
||||
_unit = _this select 0;
|
||||
#include "\z\addons\dayz_server\compile\server_toggle_debug.hpp"
|
||||
|
||||
#ifdef SERVER_DEBUG
|
||||
diag_log ("CLEANUP: DELETE UNCONTROLLED ZOMBIE: " + (typeOf _unit) + " OF: " + str(_unit) );
|
||||
#endif
|
||||
deleteVehicle _unit;
|
||||
Reference in New Issue
Block a user