diff --git a/SQF/dayz_code/Configs/CfgLoot/CfgBuildingLoot.hpp b/SQF/dayz_code/Configs/CfgLoot/CfgBuildingLoot.hpp index 3c09f3051..fb3ec77ac 100644 --- a/SQF/dayz_code/Configs/CfgLoot/CfgBuildingLoot.hpp +++ b/SQF/dayz_code/Configs/CfgLoot/CfgBuildingLoot.hpp @@ -72,7 +72,6 @@ class CfgBuildingLoot { ,{"ItemWatch","generic",0.04} ,{"ItemCompass","generic",0.03} ,{"ItemMap","weapon",0.02} - ,{"pistols","cfglootweapon",0.1} ,{"ItemFlashlight","generic",0.01} ,{"ItemKnife","generic",0.04} ,{"ItemMatchbox_DZE","generic",0.01} @@ -86,7 +85,6 @@ class CfgBuildingLoot { ,{"clothes","single",0.01} ,{"specialclothes","single",0.01} ,{"WeaponHolder_MeleeCrowbar","object",0.03} - ,{"shotgunsingleshot","cfglootweapon",0.06} }; }; class Office: Default { @@ -102,12 +100,10 @@ class CfgBuildingLoot { ,{"ItemWatch","generic",0.04} ,{"ItemCompass","generic",0.03} ,{"ItemMap","weapon",0.02} - ,{"pistols","cfglootweapon",0.11} ,{"ItemFlashlight","generic",0.01} ,{"ItemKnife","generic",0.04} ,{"ItemMatchbox_DZE","generic",0.01} ,{"","generic",0.31} - ,{"shotgunsingleshot","cfglootweapon",0.05} ,{"backpacks","backpack",0.04} ,{"tents","single",0.01} ,{"","military",0.02} @@ -186,7 +182,6 @@ class CfgBuildingLoot { lootType[] = { {"ItemJerrycan","magazine",0.05} ,{"","generic",0.3} - ,{"farmweapons","cfglootweapon",0.18} ,{"","trash",0.26} ,{"PartPlankPack","magazine",0.06} ,{"WeaponHolder_ItemHatchet_DZE","object",0.05} @@ -210,12 +205,10 @@ class CfgBuildingLoot { ,{"ItemWatch","generic",0.07} ,{"ItemCompass","generic",0.02} ,{"ItemMap","weapon",0.04} - ,{"pistols","cfglootweapon",0.04} ,{"ItemFlashlight","generic",0.01} ,{"ItemKnife","generic",0.02} ,{"ItemMatchbox_DZE","generic",0.04} ,{"","generic",0.04} - ,{"shotgunsingleshot","cfglootweapon",0.04} ,{"backpacks","backpack",0.07} ,{"tents","single",0.01} ,{"","food",0.3} @@ -232,11 +225,7 @@ class CfgBuildingLoot { lootChance = 0.5; lootPos[] = {}; lootType[] = { - {"assaultrifles","cfglootweapon",0.1} - ,{"submachinegun","cfglootweapon",0.04} - ,{"sniperrifles","cfglootweapon",0.07} - ,{"machineguns","cfglootweapon",0.06} - ,{"","military",0.3} + {"","military",0.3} ,{"","medical",0.18} ,{"MAAWS","weapon",0.02} ,{"MedBox0","object",0.05} @@ -254,11 +243,7 @@ class CfgBuildingLoot { lootChance = 0.5; lootPos[] = {}; lootType[] = { - {"assaultrifles","cfglootweapon",0.09} - ,{"submachinegun","cfglootweapon",0.03} - ,{"sniperrifles","cfglootweapon",0.05} - ,{"machineguns","cfglootweapon",0.05} - ,{"","military",0.35} + {"","military",0.35} ,{"","medical",0.18} ,{"MAAWS","weapon",0.02} ,{"MedBox0","object",0.05} @@ -289,12 +274,7 @@ class CfgBuildingLoot { lootChance = 0.4; lootPos[] = {}; lootType[] = { - {"pistols","cfglootweapon",0.04} - ,{"assaultrifles","cfglootweapon",0.13} - ,{"sniperrifles","cfglootweapon",0.04} - ,{"shotgunsingleshot","cfglootweapon",0.06} - ,{"submachinegun","cfglootweapon",0.07} - ,{"Binocular","weapon",0.03} + {"Binocular","weapon",0.03} ,{"ItemFlashlightRed","military",0.04} ,{"ItemKnife","military",0.01} ,{"ItemGPS","weapon",0.01} @@ -305,7 +285,6 @@ class CfgBuildingLoot { ,{"","military",0.3} ,{"ItemEtool","weapon",0.02} ,{"ItemSandbag","magazine",0.02} - ,{"machineguns","cfglootweapon",0.03} }; }; class MilitaryIndustrial: Default { @@ -315,13 +294,8 @@ class CfgBuildingLoot { lootChance = 0.4; lootPos[] = {}; lootType[] = { - {"pistols","cfglootweapon",0.02} - ,{"assaultrifles","cfglootweapon",0.05} - ,{"PartGeneric","magazine",0.03} - ,{"sniperrifles","cfglootweapon",0.01} - ,{"shotgunsingleshot","cfglootweapon",0.05} + {"PartGeneric","magazine",0.03} ,{"ItemGenerator","magazine",0.01} - ,{"submachinegun","cfglootweapon",0.05} ,{"PartWheel","magazine",0.02} ,{"Binocular","weapon",0.01} ,{"ItemFlashlightRed","military",0.03} @@ -336,7 +310,6 @@ class CfgBuildingLoot { ,{"ItemSandbag","magazine",0.02} ,{"ItemFuelBarrelEmpty","magazine",0.03} ,{"ItemFuelPump","magazine",0.01} - ,{"machineguns","cfglootweapon",0.01} }; }; class IndustrialMilitary: Default { @@ -346,13 +319,8 @@ class CfgBuildingLoot { lootChance = 0.5; lootPos[] = {}; lootType[] = { - {"pistols","cfglootweapon",0.02} - ,{"assaultrifles","cfglootweapon",0.05} - ,{"PartGeneric","magazine",0.03} - ,{"sniperrifles","cfglootweapon",0.01} - ,{"shotgunsingleshot","cfglootweapon",0.05} + {"PartGeneric","magazine",0.03} ,{"ItemGenerator","magazine",0.01} - ,{"submachinegun","cfglootweapon",0.05} ,{"PartWheel","magazine",0.02} ,{"Binocular","weapon",0.01} ,{"ItemFlashlightRed","military",0.03} @@ -370,7 +338,6 @@ class CfgBuildingLoot { ,{"ItemSandbag","magazine",0.02} ,{"ItemFuelBarrelEmpty","magazine",0.03} ,{"ItemFuelPump","magazine",0.01} - ,{"machineguns","cfglootweapon",0.01} }; }; class MilitarySpecial: Default { @@ -381,13 +348,7 @@ class CfgBuildingLoot { lootChance = 0.4; lootPos[] = {}; lootType[] = { - {"assaultrifles","cfglootweapon",0.1} - ,{"machineguns","cfglootweapon",0.04} - ,{"pistols","cfglootweapon",0.08} - ,{"sniperrifles","cfglootweapon",0.03} - ,{"militaryshotguns","cfglootweapon",0.05} - ,{"submachinegun","cfglootweapon",0.06} - ,{"AmmoBoxSmall_556","object",0.01} + {"AmmoBoxSmall_556","object",0.01} ,{"AmmoBoxSmall_762","object",0.02} ,{"Binocular","weapon",0.01} ,{"ItemFlashlightRed","military",0.02} @@ -417,7 +378,6 @@ class CfgBuildingLoot { ,{"ItemFlashlight","generic",0.01} ,{"ItemKnife","generic",0.01} ,{"ItemMatchbox_DZE","generic",0.03} - ,{"farmweapons","cfglootweapon",0.03} ,{"","military",0.38} ,{"WeaponHolder_ItemMachete","object",0.02} ,{"","hunter",0.5} diff --git a/SQF/dayz_code/compile/building_spawnLoot.sqf b/SQF/dayz_code/compile/building_spawnLoot.sqf index 011dc348a..e33571eb6 100644 --- a/SQF/dayz_code/compile/building_spawnLoot.sqf +++ b/SQF/dayz_code/compile/building_spawnLoot.sqf @@ -1,58 +1,75 @@ -private ["_obj","_type","_config","_positions","_iPos","_nearBy","_itemType","_itemTypes","_lootChance","_weights","_cntWeights","_index","_itemTypesSmall","_positionsSmall"]; -//_t1 = diag_tickTime; - -_obj = _this select 0; - -// lower case to prevent issues with differing case for buildings from map to map. -_type = toLower(typeOf _obj); - -//diag_log format["Spawning loot for: %1", _type]; +/* + Created exclusively for ArmA2:OA - DayZMod. + Please request permission to use/alter/distribute from project leader (R4Z0R49) +*/ +//private ["_lootChance","_index","_weights","_cntWeights","_itemType","_qty","_rnd","_iPos","_obj","_type","_config","_pos","_itemTypes","_positions","_bias"]; +private ["_lootChance"]; +_obj = _this; +_type = typeOf _obj; +_config = configFile >> "CfgBuildingLoot" >> _type; +_pos = [] + getArray (_config >> "lootPos"); +_itemTypes = [] + getArray (_config >> "lootType"); +_lootChance = getNumber (_config >> "lootChance"); +//_countPositions = count _pos; +_qty = 0; // effective quantity of spawned weaponholder +_lootSpawnBias = 67; //67 between 50 and 100. The lower it is, the lower chance some of the lootpiles will spawn -_config = configFile >> "CfgBuildingLoot" >> _type; -if (DZE_MissionLootTable) then { - _config = missionConfigFile >> "CfgBuildingLoot" >> _type; +// shuffles an array +// parameters: array +// example: _myrandomarray = _myNormalArray call _ShuffleArray; +ShuffleArray = { + private ["_ar","_rand_array","_rand"]; + _ar = _this; + _rand_array = []; + while {count _ar > 0} do { + _rand = (count _ar); + _rand = floor (random _rand); + _rand_array set [count _rand_array, _ar select _rand]; + _ar set [_rand, "randarray_del"]; + _ar = _ar - ["randarray_del"]; + }; + _rand_array; }; +_positions = _pos call ShuffleArray; -_positions = [] + getArray (_config >> "lootPos"); -_itemTypes = [] + getArray (_config >> "itemType"); -_lootChance = getNumber (_config >> "lootChance"); + +// bias for this building. The lower it is, the lower chance some of the lootpiles will spawn +_bias = 50 max _lootSpawnBias; +_bias = 100 min _bias; +_bias = (_bias + random(100 - _bias)) / 100; +//diag_log(format["BIAS:%1 LOOTCHANCE:%2", _bias, _lootChance]); { - if ((random 1) < _lootChance) then { + if (count _x == 3) then { + _rnd = (random 1) / _bias; _iPos = _obj modelToWorld _x; - _nearBy = nearestObjects [_iPos, ["ReammoBox","WeaponHolder","WeaponHolderBase"], 1]; - if (count _nearBy == 0) then { - _index = dayz_CBLBase find _type; - //diag_log format["Found %2 at index: %1", _index,_type]; - _weights = dayz_CBLChances select _index; - _cntWeights = count _weights; - _index = floor(random _cntWeights); - _index = _weights select _index; - _itemType = _itemTypes select _index; - [_itemType select 0, _itemType select 1 , _iPos, 0.0] call spawn_loot; - //_obj setVariable ["created",(DateToNumber date),true]; + _nearBy = nearestObjects [_iPos, ["ReammoBox"], 2]; + + if (count _nearBy > 0) then { + _lootChance = _lootChance + 0.05; }; + + if (dayz_currentWeaponHolders < dayz_maxMaxWeaponHolders) then { + if (_rnd <= _lootChance) then { + if (count _nearBy == 0) then { + _index = dayz_CBLBase find _type; + _weights = dayz_CBLChances select _index; + _cntWeights = count _weights; + _index = floor(random _cntWeights); + _index = _weights select _index; + _itemType = _itemTypes select _index; + [_itemType select 0, _itemType select 1 , _iPos, 0.0] call spawn_loot; + // diag_log (format["SpawnLoot: Pos: %1, LootType: %2/%3,",_iPos,_itemType select 0,_itemType select 1]); + dayz_currentWeaponHolders = dayz_currentWeaponHolders +1; + //loclout system + _islocal = _obj getVariable ["", false]; // object created locally via TownGenerator. See stream_locationFill.sqf + _obj setVariable ["looted",diag_tickTime + dayz_tickTimeOffset,!_islocal]; + }; + }; + }; + //sleep 0.002; }; } forEach _positions; -_itemTypesSmall = [] + getArray (_config >> "itemTypeSmall"); -_positionsSmall = [] + getArray (_config >> "lootPosSmall"); -{ - if ((random 1) < _lootChance) then { - _iPos = _obj modelToWorld _x; - _nearBy = nearestObjects [_iPos, ["ReammoBox","WeaponHolder","WeaponHolderBase"], 1]; - if (count _nearBy == 0) then { - _index = dayzE_CBLSBase find _type; - //diag_log format["Found %2 at index: %1", _index,_type]; - _weights = dayzE_CBLSChances select _index; - _cntWeights = count _weights; - _index = floor(random _cntWeights); - _index = _weights select _index; - _itemType = _itemTypesSmall select _index; - [_itemType select 0, _itemType select 1 , _iPos, 0.0] call spawn_loot_small; - //_obj setVariable ["created",(DateToNumber date),true]; - }; - }; -} forEach _positionsSmall; -//["building_spawnLoot.sqf",(diag_tickTime - _t1)] call fnc_dump; +//dayz_currentWeaponHolders; diff --git a/SQF/dayz_code/compile/player_spawnCheck.sqf b/SQF/dayz_code/compile/player_spawnCheck.sqf index 46c1f6050..02144ffb6 100644 --- a/SQF/dayz_code/compile/player_spawnCheck.sqf +++ b/SQF/dayz_code/compile/player_spawnCheck.sqf @@ -7,7 +7,7 @@ _onTheMove = (speed (vehicle player) > 10); _dateNow = (DateToNumber date); _maxWildZombies = 3; _age = -1; -_radius = 200; +_radius = 200; _position = getPosATL player; dayz_spawnZombies = 0; @@ -46,7 +46,7 @@ if ("ItemMap_Debug" in items player) then { deleteMarkerLocal "Loot30"; deleteMarkerLocal "Loot120"; deleteMarkerLocal "Agro80"; - + _markerstr = createMarkerLocal ["MaxZeds", _position]; _markerstr setMarkerColorLocal "ColorYellow"; _markerstr setMarkerShapeLocal "ELLIPSE"; @@ -58,7 +58,7 @@ if ("ItemMap_Debug" in items player) then { _markerstr1 setMarkerShapeLocal "ELLIPSE"; _markerstr1 setMarkerBrushLocal "Border"; _markerstr1 setMarkerSizeLocal [_radius+100, _radius+100]; - + _markerstr2 = createMarkerLocal ["Agro80", _position]; _markerstr2 setMarkerColorLocal "ColorRed"; _markerstr2 setMarkerShapeLocal "ELLIPSE"; @@ -83,11 +83,11 @@ diag_log ("GlobalZombies: " +str(dayz_CurrentZombies) + "/" +str(dayz_maxGlobalZ diag_log ("dayz_maxCurrentZeds: " +str(dayz_maxCurrentZeds) + "/" +str(dayz_maxZeds)); }; - + _nearby = _position nearObjects ["building",_radius]; _nearbyCount = count _nearby; -if (_nearbyCount < 1) exitwith +if (_nearbyCount < 1) exitwith { if ((dayz_spawnZombies < _maxWildZombies) and !_inVehicle) then { [_position] call wild_spawnZombies; @@ -102,7 +102,7 @@ if (_nearbyCount < 1) exitwith _config = missionConfigFile >> "CfgBuildingLoot" >> _type; }; _canLoot = isClass (_config); - + if(_canLoot) then { _dis = _x distance player; @@ -124,8 +124,7 @@ if (_nearbyCount < 1) exitwith //Register _x setVariable ["looted",_dateNow,true]; //cleanup - _handle = [_x] spawn building_spawnLoot; - waitUntil{scriptDone _handle}; + _x call building_spawnLoot; }; }; diff --git a/SQF/dayz_code/compile/player_spawnlootCheck.sqf b/SQF/dayz_code/compile/player_spawnlootCheck.sqf index 6f3b2c89c..3c98ddb10 100644 --- a/SQF/dayz_code/compile/player_spawnlootCheck.sqf +++ b/SQF/dayz_code/compile/player_spawnlootCheck.sqf @@ -1,28 +1,28 @@ -private ["_radius","_position","_inVehicle","_dateNow","_age","_locationstypes","_nearestCity","_type","_looted","_cleared","_nearByObj","_handle","_x"];//_radius, _position, _inVehicle, _dateNow, _age, _locationstypes, _nearestCity, _nearbyBuildings - -_radius = _this select 0; -_position = _this select 1; -_inVehicle = _this select 2; -_dateNow = _this select 3; -_age = _this select 4; -_locationstypes = _this select 5; -_nearestCity = _this select 6; - -_looted = (_x getVariable ["looted",-0.1]); -_cleared = (_x getVariable ["cleared",true]); -_dateNow = (DateToNumber date); -_age = (_dateNow - _looted) * 525948; -//diag_log ("SPAWN LOOT: " + _type + " Building is " + str(_age) + " old" ); -if ((_age > 10) and (!_cleared)) then { - _nearByObj = nearestObjects [(getPosATL _x), ["WeaponHolder","WeaponHolderBase"],((sizeOf _type)+5)]; - {deleteVehicle _x} forEach _nearByObj; - _x setVariable ["cleared",true,true]; - _x setVariable ["looted",_dateNow,true]; -}; -if ((_age > 10) and (_cleared)) then { - //Register - _x setVariable ["looted",_dateNow,true]; - //cleanup - _handle = [_x] spawn building_spawnLoot; - waitUntil{scriptDone _handle}; -}; \ No newline at end of file +// private["_radius","_position","_inVehicle","_dateNow","_age","_locationstypes","_nearestCity","_nearbyBuildings","_nearby","_type","_config","_canZombie","_canLoot","_dis","_keepAwayDist","_isNoone","_looted","_cleared"];//_radius, _position, _inVehicle, _dateNow, _age, _locationstypes, _nearestCity, _nearbyBuildings +// +// _radius = _this select 0; +// _position = _this select 1; +// _inVehicle = _this select 2; +// _dateNow = _this select 3; +// _age = _this select 4; +// _locationstypes = _this select 5; +// _nearestCity = _this select 6; +// +// _looted = (_x getVariable ["looted",-0.1]); +// _cleared = (_x getVariable ["cleared",true]); +// _dateNow = (DateToNumber date); +// _age = (_dateNow - _looted) * 525948; +// //diag_log ("SPAWN LOOT: " + _type + " Building is " + str(_age) + " old" ); +// if ((_age > 10) and (!_cleared)) then { +// _nearByObj = nearestObjects [(getPosATL _x), ["WeaponHolder","WeaponHolderBase"],((sizeOf _type)+5)]; +// {deleteVehicle _x} forEach _nearByObj; +// _x setVariable ["cleared",true]; +// _x setVariable ["looted",_dateNow,true]; +// }; +// if ((_age > 10) and (_cleared)) then { +// //Register +// _x setVariable ["looted",_dateNow,true]; +// //cleanup +// _handle = [_x] spawn building_spawnLoot; +// waitUntil{scriptDone _handle}; +// }; \ No newline at end of file diff --git a/SQF/dayz_code/compile/spawn_loot.sqf b/SQF/dayz_code/compile/spawn_loot.sqf index 361c2f4d2..32c35c523 100644 --- a/SQF/dayz_code/compile/spawn_loot.sqf +++ b/SQF/dayz_code/compile/spawn_loot.sqf @@ -1,150 +1,102 @@ -private ["_iItem","_iClass","_iPos","_radius","_item","_itemTypes","_index","_weights","_cntWeights","_qty","_max","_tQty","_canType","_mags","_dateNow"]; +private ["_item","_itemTypes","_qty","_tQty","_uniq"]; -_iItem = _this select 0; -_iClass = _this select 1; -//diag_log format["DEBUG spawn loot class: %1", _iClass]; -_iPos = _this select 2; -_radius = _this select 3; +_iItem = _this select 0; +_iClass = _this select 1; +_iPos = _this select 2; +_radius = _this select 3; -switch (_iClass) do -{ - default - { +//_uniq = ["ItemWaterbottle", "ItemWaterbottleUnfilled"]; +_uniq = []; +//_permaLoot = false; + +_iPosZ = _iPos select 2; +if((isNil "_iPosZ") OR {( _iPosZ < 0)}) then { _iPos = [_iPos select 0,_iPos select 1,0]; }; + +//if(_iClass == "Unknown") exitwith {}; + +switch (_iClass) do { + default { //Item is food, add random quantity of cans along with an item (if exists) _item = createVehicle ["WeaponHolder", _iPos, [], _radius, "CAN_COLLIDE"]; + _itemTypes = []; - if (DZE_MissionLootTable) then { - _itemTypes = ((getArray (missionConfigFile >> "cfgLoot" >> _iClass)) select 0); - } else { - _itemTypes = ((getArray (configFile >> "cfgLoot" >> _iClass)) select 0); - }; - _index = dayz_CLBase find _iClass; - _weights = dayz_CLChances select _index; - _cntWeights = count _weights; + { + _itemTypes set [count _itemTypes, _x select 0] + } foreach getArray (configFile >> "cfgLoot" >> _iClass); + _qty = 0; - _max = 1 + round(random 2); - while {_qty < _max} do - { - _tQty = 1 + round(random 1); - _index = floor(random _cntWeights); - _index = _weights select _index; - _canType = _itemTypes select _index; - _item addMagazineCargoGlobal [_canType,_tQty]; - _qty = _qty + _tQty; + _max = ceil(random 2) + 1; + while {_qty < _max} do { + _index = dayz_CLBase find _iClass; + _weights = dayz_CLChances select _index; + _cntWeights = count _weights; + _index = floor(random _cntWeights); + _index = _weights select _index; + _canType = _itemTypes select _index; + + //_itemarray = dayz_CLItemNames select _index; + //_canType = _itemarray call BIS_fnc_selectRandom; + + //diag_log ("CanType: "+str(_canType)); + _tQty = round(random 1) + 1; + if (_canType in _uniq) then { + if (({_x in _uniq} count magazines _item) == 0) then { _tQty = 1; } else { _tQty = 0;}; + if (_tQty == 0) then {diag_log(format["%1 Prevent any duplicate member %2 from family %3",__FILE__, _canType, _uniq]);}; + //diag_log(format["%1 %2 DUP? type:%3 mag:%4 _this:%5",__FILE__, __LINE__, _canType, magazines _item, _this]); + }; + if (_tQty > 0) then { + if (!(_canType in _uniq)) then { + _item addMagazineCargoGlobal [_canType,1]; + _uniq set [count _uniq, _canType]; + //diag_log ("uniq: "+str(_uniq)); + _qty = _qty + 1; + }; + }; }; - if (_iItem != "") then - { + if (_iItem != "") then { _item addWeaponCargoGlobal [_iItem,1]; + //diag_log ("Unknown"); }; }; - case "single": - { - //Item is sigle, add 1 item from cfgloot - _item = createVehicle ["WeaponHolder", _iPos, [], _radius, "CAN_COLLIDE"]; - _itemTypes = []; - if (DZE_MissionLootTable) then { - _itemTypes = ((getArray (missionConfigFile >> "cfgLoot" >> _iItem)) select 0); - } else { - _itemTypes = ((getArray (configFile >> "cfgLoot" >> _iItem)) select 0); - }; - _index = dayz_CLBase find _iItem; - _weights = dayz_CLChances select _index; - _cntWeights = count _weights; - - _index = floor(random _cntWeights); - _index = _weights select _index; - _canType = _itemTypes select _index; - _item addMagazineCargoGlobal [_canType,1]; - }; - case "backpack": - { - //Item is single backpack - if (DZE_MissionLootTable) then { - _itemTypes = ((getArray (missionConfigFile >> "cfgLoot" >> _iItem)) select 0); - } else { - _itemTypes = ((getArray (configFile >> "cfgLoot" >> _iItem)) select 0); - }; - _index = dayz_CLBase find _iItem; - _weights = dayz_CLChances select _index; - _cntWeights = count _weights; - _index = floor(random _cntWeights); - _index = _weights select _index; - _iItem = _itemTypes select _index; - - _item = createVehicle [_iItem, _iPos, [], _radius, "CAN_COLLIDE"]; - }; - case "cfglootweapon": - { - if (DZE_MissionLootTable) then { - _itemTypes = ((getArray (missionConfigFile >> "cfgLoot" >> _iItem)) select 0); - } else { - _itemTypes = ((getArray (configFile >> "cfgLoot" >> _iItem)) select 0); - }; - _index = dayz_CLBase find _iItem; - _weights = dayz_CLChances select _index; - _cntWeights = count _weights; - - _index = floor(random _cntWeights); - _index = _weights select _index; - _iItem = _itemTypes select _index; - - if (_iItem == "Chainsaw") then { - _iItem = ["ChainSaw","ChainSawB","ChainSawG","ChainSawP","ChainSawR"] call BIS_fnc_selectRandom; - }; - + case "weapon": { //Item is a weapon, add it and a random quantity of magazines _item = createVehicle ["WeaponHolder", _iPos, [], _radius, "CAN_COLLIDE"]; _item addWeaponCargoGlobal [_iItem,1]; _mags = [] + getArray (configFile >> "cfgWeapons" >> _iItem >> "magazines"); - if ((count _mags) > 0) then - { - if (_mags select 0 == "Quiver") then { _mags set [0, "WoodenArrow"] }; // Prevent spawning a Quiver + if ((count _mags) > 0) then { + // if (_mags select 0 == "Quiver") then { _mags set [0, "WoodenArrow"] }; // Prevent spawning a Quiver if (_mags select 0 == "20Rnd_556x45_Stanag") then { _mags set [0, "30Rnd_556x45_Stanag"] }; if (_mags select 0 == "30Rnd_556x45_G36") then { _mags set [0, "30Rnd_556x45_Stanag"] }; if (_mags select 0 == "30Rnd_556x45_G36SD") then { _mags set [0, "30Rnd_556x45_StanagSD"] }; - _item addMagazineCargoGlobal [(_mags select 0), (round(random 2))]; - }; - - }; - case "weapon": - { - //Item is a weapon, add it and a random quantity of magazines - _item = createVehicle ["WeaponHolder", _iPos, [], _radius, "CAN_COLLIDE"]; - _item addWeaponCargoGlobal [_iItem,1]; - _mags = [] + getArray (configFile >> "cfgWeapons" >> _iItem >> "magazines"); - if ((count _mags) > 0) then - { - if (_mags select 0 == "Quiver") then { _mags set [0, "WoodenArrow"] }; // Prevent spawning a Quiver - if (_mags select 0 == "20Rnd_556x45_Stanag") then { _mags set [0, "30Rnd_556x45_Stanag"] }; - if (_mags select 0 == "30Rnd_556x45_G36") then { _mags set [0, "30Rnd_556x45_Stanag"] }; - if (_mags select 0 == "30Rnd_556x45_G36SD") then { _mags set [0, "30Rnd_556x45_StanagSD"] }; - _item addMagazineCargoGlobal [(_mags select 0), (round(random 2))]; + if (!(_iItem in MeleeWeapons)) then { + _magQty = round(random 10); + if (_magQty > 3) then { + _item addMagazineCargoGlobal [(_mags select 0), (round(random 1) + 1)]; + }; + }; }; }; - case "weaponnomags": - { - //Item is a weapon, and spawns no mags + /* + case "tools": { + //Item is one tool _item = createVehicle ["WeaponHolder", _iPos, [], _radius, "CAN_COLLIDE"]; - _item addWeaponCargoGlobal [_iItem,1]; + _item addMagazineCargoGlobal [_iItem,1]; }; - case "magazine": - { + */ + case "magazine": { //Item is one magazine _item = createVehicle ["WeaponHolder", _iPos, [], _radius, "CAN_COLLIDE"]; _item addMagazineCargoGlobal [_iItem,1]; }; - case "object": - { + case "object": { //Item is one magazine _item = createVehicle [_iItem, _iPos, [], _radius, "CAN_COLLIDE"]; }; }; - -// timestamp for later clearing -_dateNow = (DateToNumber date); -_item setVariable ["looted",_dateNow,true]; - -if ((count _iPos) > 2) then -{ +if ((count _iPos) > 2) then { _item setPosATL _iPos; }; + +//if (_permaLoot == true) then { _item setVariable ["permaLoot",true]; }; + +_item // used in server_spawnCrashSite diff --git a/SQF/dayz_code/compile/spawn_loot_small.sqf b/SQF/dayz_code/compile/spawn_loot_small.sqf deleted file mode 100644 index 46c7d5c55..000000000 --- a/SQF/dayz_code/compile/spawn_loot_small.sqf +++ /dev/null @@ -1,108 +0,0 @@ - -private ["_iItem","_iClass","_iPos","_radius","_item","_itemTypes","_index","_weights","_cntWeights","_canType","_dateNow"]; - -_iItem = _this select 0; -_iClass = _this select 1; -//diag_log format["DEBUG spawn loot class: %1", _iClass]; -_iPos = _this select 2; -_radius = _this select 3; - -switch (_iClass) do -{ - default - { - //Item is sigle, add 1 item from CfgLootSmall - _item = createVehicle ["WeaponHolder", _iPos, [], _radius, "CAN_COLLIDE"]; - _itemTypes = []; - if (DZE_MissionLootTable) then { - _itemTypes = ((getArray (missionConfigFile >> "CfgLootSmall" >> _iClass)) select 0); - } else { - _itemTypes = ((getArray (configFile >> "CfgLootSmall" >> _iClass)) select 0); - }; - _index = dayzE_CLSBase find _iClass; - - _weights = dayzE_CLSChances select _index; - _cntWeights = count _weights; - - _index = floor(random _cntWeights); - _index = _weights select _index; - _canType = _itemTypes select _index; - _item addMagazineCargoGlobal [_canType,1]; - }; - case "single": - { - //Item is sigle, add 1 item from CfgLootSmall - _item = createVehicle ["WeaponHolder", _iPos, [], _radius, "CAN_COLLIDE"]; - - _itemTypes = []; - if (DZE_MissionLootTable) then { - _itemTypes = ((getArray (missionConfigFile >> "CfgLootSmall" >> _iItem)) select 0); - } else { - _itemTypes = ((getArray (configFile >> "CfgLootSmall" >> _iItem)) select 0); - }; - _index = dayzE_CLSBase find _iItem; - _weights = dayzE_CLSChances select _index; - _cntWeights = count _weights; - - _index = floor(random _cntWeights); - _index = _weights select _index; - _canType = _itemTypes select _index; - _item addMagazineCargoGlobal [_canType,1]; - }; - case "cfglootweapon": - { - //Item is sigle, add 1 item from cfgloot - _item = createVehicle ["WeaponHolder", _iPos, [], _radius, "CAN_COLLIDE"]; - - _itemTypes = []; - if (DZE_MissionLootTable) then { - _itemTypes = ((getArray (missionConfigFile >> "CfgLootSmall" >> _iItem)) select 0); - } else { - _itemTypes = ((getArray (configFile >> "CfgLootSmall" >> _iItem)) select 0); - }; - _index = dayz_CLBase find _iItem; - _weights = dayz_CLChances select _index; - _cntWeights = count _weights; - - _index = floor(random _cntWeights); - _index = _weights select _index; - _iItem = _itemTypes select _index; - - _item = createVehicle ["WeaponHolder", _iPos, [], _radius, "CAN_COLLIDE"]; - _item addWeaponCargoGlobal [_iItem,1]; - - }; - case "weapon": - { - _item = createVehicle ["WeaponHolder", _iPos, [], _radius, "CAN_COLLIDE"]; - _item addWeaponCargoGlobal [_iItem,1]; - }; - case "magazine": - { - //Item is one magazine - _item = createVehicle ["WeaponHolder", _iPos, [], _radius, "CAN_COLLIDE"]; - _item addMagazineCargoGlobal [_iItem,1]; - }; - - case "weaponnomags": - { - //do nothing for now - }; - case "backpack": - { - //do nothing for now - }; - case "object": - { - //do nothing for now - }; -}; - -// timestamp for later clearing -_dateNow = (DateToNumber date); -_item setVariable ["looted",_dateNow,true]; - -if ((count _iPos) > 2) then -{ - _item setPosATL _iPos; -}; \ No newline at end of file diff --git a/SQF/dayz_code/compile/zombie_generate.sqf b/SQF/dayz_code/compile/zombie_generate.sqf index 8f42725ad..3342bd52d 100644 --- a/SQF/dayz_code/compile/zombie_generate.sqf +++ b/SQF/dayz_code/compile/zombie_generate.sqf @@ -1,120 +1,157 @@ -private ["_position","_doLoiter","_unitTypes","_isNoone","_loot","_array","_agent","_type","_radius","_method","_nearByPlayer","_myDest","_newDest","_lootType","_isAlive","_rnd","_id"]; -_position = _this select 0; -_doLoiter = _this select 1; -_unitTypes = _this select 2; +private ["_position","_unitTypes","_radius","_method","_agent"]; -if (dayz_maxCurrentZeds > dayz_maxZeds) exitwith {}; -if (dayz_CurrentZombies > dayz_maxGlobalZombies) exitwith {}; -if (dayz_spawnZombies > dayz_maxLocalZombies) exitwith {}; +_position = _this select 0; +_doLoiter = _this select 1; // wander around +_unitTypes = _this select 2; // class of wanted models +_maxControlledZombies = round(dayz_maxLocalZombies); -_isNoone = {isPlayer _x} count (_position nearEntities [["AllVehicles","CAManBase"],30]) == 0; -_loot = ""; -_array = []; -_agent = objNull; +_cantSee = { + private ["_isok"]; -//Exit if a player is nearby -if (!_isNoone) exitWith {}; - -if (count _unitTypes == 0) then { - - if (DZE_MissionLootTable) then { - _unitTypes = []+ getArray (missionConfigFile >> "CfgBuildingLoot" >> "Default" >> "zombieClass"); - } else { - _unitTypes = []+ getArray (configFile >> "CfgBuildingLoot" >> "Default" >> "zombieClass"); + _isok = true; + _zPos = +(_this select 0); + if (count _zPos < 3) exitWith { + diag_log format["%1::_cantSee illegal pos %2", __FILE__, _zPos]; + false }; -}; - -_type = _unitTypes call BIS_fnc_selectRandom; - -//Create the Group and populate it -//diag_log ("Spawned: " + _type); -_radius = 0; -_method = "CAN_COLLIDE"; -if (_doLoiter) then { - _radius = 40; - _method = "NONE"; -}; -//diag_log ("Spawned: " + str([_type, _position, [], _radius, _method])); -_agent = createAgent [_type, _position, [], _radius, _method]; -PVDZE_zed_Spawn = [_agent]; -publicVariableServer "PVDZE_zed_Spawn"; - -if (_doLoiter) then { - _agent setDir round(random 180); - _agent setPosATL _position; - _agent setvelocity [0, 0, 1]; - //_agent setVariable ["doLoiter",true,true]; -} else { - _agent setVariable ["doLoiter",false,true]; -}; -dayz_spawnZombies = dayz_spawnZombies + 1; - -//diag_log ("CREATE INFECTED: " + str(_this)); - -_position = getPosATL _agent; -_nearByPlayer = ({isPlayer _x} count (_position nearEntities [["AllVehicles","CAManBase"],30]) > 0); - -if (random 1 > 0.7) then { - _agent setUnitPos "Middle"; -}; - -//diag_log ("CREATED: " + str(_agent)); -if (_nearByPlayer) then { - deleteVehicle _agent; -}; -/* -//_agent setVariable["host",player,true]; -if (!_doLoiter) then { - _agent setPosATL _position; - _agent setDir round(random 180); - if (_nearByPlayer) then { - deleteVehicle _agent; - }; -} else { - if (_nearByPlayer) then { - _attempt = 0; - while {_nearByPlayer} do { - _position = [_position,0,20,10,0,20,0] call BIS_fnc_findSafePos; - _agent setPos _position; - _nearByPlayer = ({isPlayer _x} count (_position nearEntities ["CAManBase",30]) > 0); - _attempt = _attempt + 1; - if (_attempt > 10) exitWith {}; - }; - _agent setPos _position; - }; -}; -*/ -if (isNull _agent) exitWith { - dayz_spawnZombies = dayz_spawnZombies - 1; -}; - -_isAlive = alive _agent; - -_myDest = getPosATL _agent; -_newDest = getPosATL _agent; -_agent setVariable ["myDest",_myDest]; -_agent setVariable ["newDest",_newDest]; - -//Add some loot -_rnd = random 1; -if (_rnd > 0.3) then { - _lootType = configFile >> "CfgVehicles" >> _type >> "zombieLoot"; - if (isText _lootType) then { - - _array = []; - if (DZE_MissionLootTable) then { - _array = getArray (missionConfigFile >> "cfgLoot" >> getText(_lootType)); - } else { - _array = getArray (configFile >> "cfgLoot" >> getText(_lootType)); - }; - if (count _array > 0) then { - _loot = _array call BIS_fnc_selectRandomWeighted; - if(!isNil "_array") then { - _agent addMagazine _loot; + _zPos = ATLtoASL _zPos; + _fov = _this select 1; // players half field of view + _safeDistance = _this select 2; // minimum distance. closer is wrong + _farDistance = _this select 3; // distance further we won't check + _zPos set [2, (_zPos select 2) + 1.7]; + { + _xasl = getPosASL _x; + if (_xasl distance _zPos < _farDistance) then { + if (_xasl distance _zPos < _safeDistance) then { + _isok = false; + } + else { + _eye = eyePos _x; // ASL + _ed = eyeDirection _x; + _ed = (_ed select 0) atan2 (_ed select 1); + _deg = [_xasl, _zPos] call BIS_fnc_dirTo; + _deg = (_deg - _ed + 720) % 360; + if (_deg > 180) then { _deg = _deg - 360; }; + if ((abs(_deg) < _fov) AND {( // in right angle sector? + (!(terrainIntersectASL [_zPos, _eye]) // no terrain between? + AND {(!(lineIntersects [_zPos, _eye]))}) // and no object between? + )}) then { + _isok = false; + }; }; }; - }; + if (!_isok) exitWith {false}; + } forEach playableUnits; + + _isok }; -//Start behavior -_id = [_position,_agent] execFSM "\z\AddOns\dayz_code\system\zombie_agent.fsm"; \ No newline at end of file +if ((dayz_spawnZombies < _maxControlledZombies) and (dayz_CurrentNearByZombies < dayz_maxNearByZombies) and (dayz_currentGlobalZombies < dayz_maxGlobalZeds)) then { + if ([_position, dayz_cantseefov, 10, dayz_cantseeDist] call _cantSee) then { + //Check if anyone close + _tooClose = {isPlayer _x} count (_position nearEntities ["CAManBase",30]) > 0; + if (_tooClose) exitwith { + diag_log ("Zombie_Generate: was too close to player."); + }; + + //Add zeds if unitTypes equals 0 + if (count _unitTypes == 0) then { + if (DZE_MissionLootTable) then { + _unitTypes = []+ getArray (missionConfigFile >> "CfgBuildingLoot" >> "Default" >> "zombieClass"); + } else { + _unitTypes = []+ getArray (configFile >> "CfgBuildingLoot" >> "Default" >> "zombieClass"); + }; + }; + + // lets create an agent + _type = _unitTypes call BIS_fnc_selectRandom; + _radius = 5; + _method = "NONE"; + if (_doLoiter) then { + _radius = 40; + _method = "CAN_COLLIDE"; + }; + + //Check if point is in water + if (surfaceIsWater _position) exitwith { Diag_log ("Location is in Water Abort"); }; + + _agent = createAgent [_type, _position, [], _radius, _method]; + sleep 0.001; + + //add to global counter + dayz_spawnZombies = dayz_spawnZombies + 1; + + //Add some loot + _loot = ""; + _array = []; + _rnd = random 1; + if (_rnd < 0.2) then { + _lootType = configFile >> "CfgVehicles" >> _type >> "zombieLoot"; + if (isText _lootType) then { + _array = []; + { + _array set [count _array, _x select 0] + } foreach getArray (configFile >> "cfgLoot" >> getText(_lootType)); + if (count _array > 0) then { + _index = dayz_CLBase find getText(_lootType); + _weights = dayz_CLChances select _index; + _loot = _array select (_weights select (floor(random (count _weights)))); + if(!isNil "_array") then { + _loot_count = getNumber(configFile >> "CfgMagazines" >> _loot >> "count"); + if(_loot_count>1) then { + _agent addMagazine [_loot, ceil(random _loot_count)]; + } else { + _agent addMagazine _loot; + }; + }; + }; + }; + }; + + _agent setVariable["agentObject",_agent]; + + if (!isNull _agent) then { + // sometime Z can be seen flying in very high speed while tp. Its altitude is set underground to hide that. + /* + _agtPos = getPosASL _agent; + _agtPos set [2, -3]; + _agent setPosASL _agtPos; + sleep 0.001; + _agtPos = +(_position); + _agtPos set [2, -3]; + _agent setPosASL _agtPos; + sleep 0.001; + */ + _agent setDir random 360; + //_agent setPosATL _position; + sleep 0.001; + + _position = getPosATL _agent; + + _favStance = ( + switch ceil(random(3^0.5)^2) do { + //case 3: {"DOWN"}; // prone + case 2: {"Middle"}; // Kneel + default {"UP"} // stand-up + } + ); + _agent setUnitPos _favStance; + + _agent setVariable ["stance", _favStance]; + _agent setVariable ["BaseLocation", _position]; + _agent setVariable ["doLoiter", true]; // true: Z will be wandering, false: stay still + _agent setVariable ["myDest", _position]; + _agent setVariable ["newDest", _position]; + [_agent, _position] call zombie_loiter; + }; + //add to monitor + //dayz_zedMonitor set [count dayz_zedMonitor, _agent]; + + //Disable simulation + PVDZ_Server_Simulation = [_agent, false]; + publicVariableServer "PVDZ_Server_Simulation"; + + //Start behavior + _id = [_position,_agent] execFSM "\z\AddOns\dayz_code\system\zombie_agent.fsm"; + }; +}; \ No newline at end of file diff --git a/SQF/dayz_code/init/compiles.sqf b/SQF/dayz_code/init/compiles.sqf index 94c88d771..28b26326f 100644 --- a/SQF/dayz_code/init/compiles.sqf +++ b/SQF/dayz_code/init/compiles.sqf @@ -1,4 +1,4 @@ -/* +/* FUNCTION COMPILES */ //Player only @@ -6,7 +6,7 @@ if (!isDedicated) then { "filmic" setToneMappingParams [0.07, 0.31, 0.23, 0.37, 0.011, 3.750, 6, 4]; setToneMapping "Filmic"; - BIS_Effects_Burn = compile preprocessFile "\ca\Data\ParticleEffects\SCRIPTS\destruction\burn.sqf"; + BIS_Effects_Burn = compile preprocessFile "\ca\Data\ParticleEffects\SCRIPTS\destruction\burn.sqf"; player_zombieCheck = compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\player_zombieCheck.sqf"; //Run on a players computer, checks if the player is near a zombie player_zombieAttack = compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\player_zombieAttack.sqf"; //Run on a players computer, causes a nearby zombie to attack them fnc_usec_damageActions = compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\fn_damageActions.sqf"; //Checks which actions for nearby casualty @@ -31,14 +31,14 @@ if (!isDedicated) then { player_packTent = compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\player_packTent.sqf"; player_packVault = compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\player_packVault.sqf"; player_unlockVault = compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\player_unlockVault.sqf"; - + player_removeObject = compile preprocessFileLineNumbers "\z\addons\dayz_code\actions\remove.sqf"; player_removeNet = compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\object_removeNet.sqf"; player_removeTankTrap = compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\object_removeTankTrap.sqf"; player_unlockDoor = compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\player_unlockDoor.sqf"; player_changeCombo = compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\player_changeCombo.sqf"; - + player_lockVault = compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\player_lockVault.sqf"; // control_zombieAgent = compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\control_zombieAgent.sqf"; player_updateGui = compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\player_updateGui.sqf"; @@ -59,22 +59,22 @@ if (!isDedicated) then { player_alertZombies = compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\player_alertZombies.sqf"; player_fireMonitor = compile preprocessFileLineNumbers "\z\addons\dayz_code\system\fire_monitor.sqf"; fn_gearMenuChecks = compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\fn_gearMenuChecks.sqf"; - + //Objects object_roadFlare = compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\object_roadFlare.sqf"; object_setpitchbank = compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\fn_setpitchbank.sqf"; object_monitorGear = compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\object_monitorGear.sqf"; local_roadDebris = compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\local_roadDebris.sqf"; - + //Zombies zombie_findTargetAgent = compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\zombie_findTargetAgent.sqf"; zombie_loiter = compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\zombie_loiter.sqf"; //Server compile, used for loiter behaviour zombie_generate = compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\zombie_generate.sqf"; //Server compile, used for loiter behaviour wild_spawnZombies = compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\wild_spawnZombies.sqf"; //Server compile, used for loiter behaviour - + pz_attack = compile preprocessFileLineNumbers "\z\addons\dayz_code\actions\pzombie\pz_attack.sqf"; - + // dog_findTargetAgent = compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\dog_findTargetAgent.sqf"; @@ -105,24 +105,24 @@ if (!isDedicated) then { //player_mineOre = compile preprocessFileLineNumbers "\z\addons\dayz_code\actions\player_mineOre.sqf"; player_antiWall = compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\player_antiWall.sqf"; player_deathBoard = compile preprocessFileLineNumbers "\z\addons\dayz_code\actions\list_playerDeathsAlt.sqf"; - + player_plotPreview = compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\object_showPlotRadius.sqf"; player_upgradeVehicle = compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\player_upgradeVehicle.sqf"; - + //ui player_selectSlot = compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\ui_selectSlot.sqf"; player_gearSync = compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\player_gearSync.sqf"; player_gearSet = compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\player_gearSet.sqf"; ui_changeDisplay = compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\ui_changeDisplay.sqf"; ui_gear_sound = compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\ui_gear_sound.sqf"; - + //System player_monitor = compile preprocessFileLineNumbers "\z\addons\dayz_code\system\player_monitor.sqf"; player_spawn_1 = compile preprocessFileLineNumbers "\z\addons\dayz_code\system\player_spawn_1.sqf"; player_spawn_2 = compile preprocessFileLineNumbers "\z\addons\dayz_code\system\player_spawn_2.sqf"; onPreloadStarted "dayz_preloadFinished = false;"; onPreloadFinished "dayz_preloadFinished = true;"; - + // helper functions player_hasTools = compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\fn_hasTools.sqf"; player_checkItems = compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\fn_checkItems.sqf"; @@ -137,7 +137,7 @@ if (!isDedicated) then { }; _b }; - + epoch_totalCurrency = { // total currency @@ -154,7 +154,7 @@ if (!isDedicated) then { epoch_itemCost = { _trade_total = 0; - { + { _part_in_configClass = configFile >> "CfgMagazines" >> (_x select 0); if (isClass (_part_in_configClass)) then { _part_inWorth = (_part_in_configClass >> "worth"); @@ -163,26 +163,26 @@ if (!isDedicated) then { }; }; } forEach _this; - + diag_log format["DEBUG TRADER ITEMCOST: %1", _this]; _trade_total }; epoch_returnChange = compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\epoch_returnChange.sqf"; // usage [["partinclassname",4]] call epoch_returnChange; - + // RunTime = 0; TotalRuns = 0; - + fnc_dump = { private["_code","_benchmark","_averageRunTime"]; _code = _this select 0; _benchmark = _this select 1; - + RunTime = RunTime + _benchmark; TotalRuns = TotalRuns + 1; _averageRunTime = RunTime/TotalRuns; @@ -201,7 +201,7 @@ if (!isDedicated) then { _myExp = _myExp * 0.7; _myExp }; - + ui_initDisplay = { private["_control","_ctrlBleed","_display","_ctrlFracture","_ctrlDogFood","_ctrlDogWater","_ctrlDogWaterBorder", "_ctrlDogFoodBorder"]; disableSerialization; @@ -220,23 +220,23 @@ if (!isDedicated) then { _ctrlDogFoodBorder ctrlShow false; _ctrlDogFood = _display displayCtrl 1701; _ctrlDogFood ctrlShow false; - + _ctrlDogWaterBorder = _display displayCtrl 1502; _ctrlDogWaterBorder ctrlShow false; _ctrlDogWater = _display displayCtrl 1702; _ctrlDogWater ctrlShow false }; - + dayz_losCheck = { private["_target","_agent","_cantSee"]; _target = _this select 0; // PUT THE PLAYER IN FIRST ARGUMENT!!!! _agent = _this select 1; _cantSee = true; if (!isNull _target) then { - + _tPos = visiblePositionASL _target; _zPos = visiblePositionASL _agent; - + _tPos set [2,(_tPos select 2)+1]; _zPos set [2,(_zPos select 2)+1]; @@ -249,21 +249,21 @@ if (!isDedicated) then { }; _cantSee }; - + eh_zombieInit = { private["_unit","_pos"]; //_unit = _this select 0; //_pos = getPosATL _unit; //_id = [_pos,_unit] execFSM "\z\AddOns\dayz_code\system\zombie_agent.fsm"; }; - + dayz_equipCheck = { private ["_empty", "_needed","_diff","_success"]; _config = _this; _empty = [player] call BIS_fnc_invSlotsEmpty; _needed = [_config] call BIS_fnc_invSlotType; _diff = [_empty,_needed] call BIS_fnc_vectorDiff; - + _success = true; { if (_x > 0) then {_success = false}; @@ -282,9 +282,9 @@ if (!isDedicated) then { }; player_tagFriendlyMsg = { - if(player == (_this select 0)) then { + if(player == (_this select 0)) then { cutText[(localize "str_epoch_player_2"),"PLAIN DOWN"]; - }; + }; }; player_serverModelChange = { @@ -295,7 +295,7 @@ if (!isDedicated) then { _model call player_switchModel; }; }; - + player_guiControlFlash = { private["_control"]; _control = _this; @@ -305,7 +305,7 @@ if (!isDedicated) then { _control ctrlShow true; }; }; - + gear_ui_offMenu = { private["_control","_parent","_menu"]; disableSerialization; @@ -323,10 +323,10 @@ if (!isDedicated) then { _control ctrlCommit 0; }; }; - + dze_surrender_off = { player setVariable ["DZE_Surrendered", false, true]; - DZE_Surrender = false; + DZE_Surrender = false; }; gear_ui_init = { @@ -344,7 +344,7 @@ if (!isDedicated) then { _control ctrlShow false; _control ctrlCommit 0; }; - + dayz_eyeDir = { private["_vval","_vdir"]; _vval = (eyeDirection _this); @@ -389,7 +389,7 @@ if (!isDedicated) then { }; _notClosest }; - + // trader menu code if (DZE_ConfigTrader) then { call compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\player_traderMenuConfig.sqf"; @@ -419,8 +419,8 @@ if (!isDedicated) then { while { _timeOut < 12000 } do { if (dayz_clientPreload && dayz_authed) exitWith { diag_log "PLOGIN: Login loop completed!"; }; if (!isNil "_display") then { - if ( isNull _display ) then { - waitUntil { !dialog; }; + if ( isNull _display ) then { + waitUntil { !dialog; }; startLoadingScreen ["","RscDisplayLoadCustom"]; _display = uiNameSpace getVariable "BIS_loadingScreen"; _control1 = _display displayctrl 8400; @@ -458,13 +458,13 @@ if (!isDedicated) then { }; dayz_originalPlayer = player; - + progressLoadingScreen 0.8; }; //Both BIS_fnc_selectRandom = compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\BIS_fnc\fn_selectRandom.sqf"; - BIS_fnc_vectorAdd = compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\BIS_fnc\fn_vectorAdd.sqf"; + BIS_fnc_vectorAdd = compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\BIS_fnc\fn_vectorAdd.sqf"; BIS_fnc_halo = compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\BIS_fnc\fn_halo.sqf"; BIS_fnc_findNestedElement = compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\BIS_fnc\fn_findNestedElement.sqf"; BIS_fnc_param = compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\BIS_fnc\fn_param.sqf"; @@ -486,7 +486,7 @@ if (!isDedicated) then { vehicle_handleDamage = compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\vehicle_handleDamage.sqf"; vehicle_handleKilled = compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\vehicle_handleKilled.sqf"; //fnc_vehicleEventHandler = compile preprocessFileLineNumbers "\z\addons\dayz_code\init\vehicle_init.sqf"; //Initialize vehicle - fnc_inString = compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\fn_inString.sqf"; + fnc_inString = compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\fn_inString.sqf"; fnc_isInsideBuilding = compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\fn_isInsideBuilding.sqf"; //_isInside = [_unit,_building] call fnc_isInsideBuilding; fnc_isInsideBuilding2 = compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\fn_isInsideBuilding2.sqf"; //_isInside = [_unit,_building] call fnc_isInsideBuilding; fnc_isInsideBuilding3 = compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\fn_isInsideBuilding3.sqf"; //_isInside = [_unit,_building] call fnc_isInsideBuilding; @@ -510,14 +510,13 @@ if (!isDedicated) then { world_isDay = {if ((daytime < (24 - dayz_sunRise)) and (daytime > dayz_sunRise)) then {true} else {false}}; player_humanityChange = compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\player_humanityChange.sqf"; spawn_loot = compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\spawn_loot.sqf"; - spawn_loot_small = compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\spawn_loot_small.sqf"; // player_projectileNear = compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\player_projectileNear.sqf"; - + dayz_HungerThirst = { dayz_hunger = dayz_hunger + (_this select 0); dayz_thirst = dayz_thirst + (_this select 1); }; - + // better item counting by maca134 - https://github.com/vbawol/DayZ-Epoch/issues/916 MC_item_spaces = { private ["_unit", "_item", "_slotsEmpty", "_slotsItem", "_slotsAfterAdd", "_c", "_space"]; @@ -582,7 +581,7 @@ if (!isDedicated) then { ]; _medical }; - + //Server Only if (isServer) then { call compile preprocessFileLineNumbers "\z\addons\dayz_server\init\server_functions.sqf"; diff --git a/SQF/dayz_code/init/publicEH.sqf b/SQF/dayz_code/init/publicEH.sqf index b9f59192c..5fb41c342 100644 --- a/SQF/dayz_code/init/publicEH.sqf +++ b/SQF/dayz_code/init/publicEH.sqf @@ -28,6 +28,13 @@ /* PVS/PVC - Skaronator */ "PVCDZE_vehSH" addPublicVariableEventHandler {(_this select 1) call vehicle_handleDamage}; // set damage to vehicle part + "PVDZ_Server_Simulation" addPublicVariableEventHandler { + _agent = ((_this select 1) select 0); + _control = ((_this select 1) select 1); + + _agent enableSimulation _control; + }; + //Server only if (isServer) then { /* PVS/PVC - Skaronator */ @@ -54,8 +61,8 @@ if (isServer) then { "PVDZE_obj_Swap" addPublicVariableEventHandler {(_this select 1) spawn server_swapObject}; // disable zombies server side "PVDZE_zed_Spawn" addPublicVariableEventHandler {(_this select 1) spawn server_handleZedSpawn}; - - // Dayz epoch custom + + // Dayz epoch custom "PVDZE_veh_Publish" addPublicVariableEventHandler {(_this select 1) spawn server_publishVeh}; "PVDZE_veh_Publish2" addPublicVariableEventHandler {(_this select 1) spawn server_publishVeh2}; "PVDZE_veh_Upgrade" addPublicVariableEventHandler {(_this select 1) spawn server_publishVeh3}; @@ -76,9 +83,9 @@ if (!isDedicated) then { "PVDZE_plr_Morph" addPublicVariableEventHandler {(_this select 1) call server_switchPlayer}; "PVDZE_obj_Fire" addPublicVariableEventHandler {nulexp=(_this select 1) spawn BIS_Effects_Burn}; "PVDZE_plr_FriendRQ" addPublicVariableEventHandler {(_this select 1) call player_tagFriendlyMsg}; - + // "PVDZE_obj_Debris" addPublicVariableEventHandler {(_this select 1) call local_roadDebris}; - + "norrnRaDrag" addPublicVariableEventHandler {(_this select 1) execVM "\z\addons\dayz_code\medical\publicEH\animDrag.sqf"}; "norrnRnoAnim" addPublicVariableEventHandler {(_this select 1) execVM "\z\addons\dayz_code\medical\publicEH\noAnim.sqf"}; }; diff --git a/SQF/dayz_code/init/variables.sqf b/SQF/dayz_code/init/variables.sqf index 41f11e96f..1a688bd2d 100644 --- a/SQF/dayz_code/init/variables.sqf +++ b/SQF/dayz_code/init/variables.sqf @@ -429,6 +429,12 @@ DAYZ_agentnumber = 0; dayz_animalDistance = 800; dayz_zSpawnDistance = 1000; +dayz_maxMaxModels = 80; // max quantity of Man models (player or Z, dead or alive) around players. Below this limit we can spawn Z // max quantity of loot piles around players. Below this limit we can spawn some loot +dayz_spawnArea = 200; // radius around player where we can spawn loot & Z +dayz_cantseeDist = 150; // distance from which we can spawn a Z in front of any player without ray-tracing and angle checks +dayz_cantseefov = 70; // half player field-of-view. Visible Z won't be spawned in front of any near players +dayz_canDelete = 300; // Z, further than this distance from its "owner", will be deleted + if(isNil "dayz_maxAnimals") then { dayz_maxAnimals = 5; }; @@ -656,20 +662,34 @@ if(!isDedicated) then { dayz_areaAffect = 2.5; dayz_heartBeat = false; dayzClickTime = 0; +//Current local + dayz_spawnZombies = 0; + dayz_swarmSpawnZombies = 0; +//Max local + dayz_maxLocalZombies = 30; // max quantity of Z controlled by local gameclient, used by player_spawnCheck. Below this limit we can spawn Z +//Current NearBy + dayz_CurrentNearByZombies = 0; +//Max NearBy + dayz_maxNearByZombies = 60; // max quantity of Z controlled by local gameclient, used by player_spawnCheck. Below this limit we can spawn Z +//Current total + dayz_currentGlobalZombies = 0; +//Max global zeds. + dayz_maxGlobalZeds = 3000; dayz_spawnDelay = 120; dayz_spawnWait = -120; dayz_lootDelay = 3; dayz_lootWait = -300; - dayz_spawnZombies = 0; //used to count global zeds around players dayz_CurrentZombies = 0; //Used to limit overall zed counts + dayz_tickTimeOffset = 0; + dayz_currentWeaponHolders = 0; + dayz_maxMaxWeaponHolders = 80; dayz_maxCurrentZeds = 0; dayz_inVehicle = false; dayz_Magazines = []; dayzGearSave = false; dayz_unsaved = false; - DZE_ActionInProgress = false; dayz_scaleLight = 0; dayzDebug = false; dayzState = -1; @@ -678,6 +698,8 @@ if(!isDedicated) then { // dayzDebug = true; //}; + DZE_ActionInProgress = false; + // DayZ Epoch Client only variables if(isNil "DZE_AllowForceSave") then { DZE_AllowForceSave = false; diff --git a/SQF/dayz_code/system/player_monitor.fsm b/SQF/dayz_code/system/player_monitor.fsm index 0b3388f1f..d98c7269f 100644 --- a/SQF/dayz_code/system/player_monitor.fsm +++ b/SQF/dayz_code/system/player_monitor.fsm @@ -1,7 +1,7 @@ -/*%FSM*/ +/*%FSM*/ /*%FSM*/ /* -item0[] = {"init",0,250,-75.000000,-350.000000,25.000000,-300.000000,0.000000,"init"}; +item0[] = {"init",0,4346,-75.000000,-350.000000,25.000000,-300.000000,0.000000,"init"}; item1[] = {"isServer",4,218,50.000000,-350.000000,150.000000,-300.000000,0.000000,"isServer"}; item2[] = {"wait",2,250,50.000000,-275.000000,150.000000,-225.000000,0.000000,"wait"}; item3[] = {"Allow_Conn",4,218,50.000000,-200.000000,150.000000,-150.000000,0.000000,"Allow" \n "Conn"}; @@ -47,7 +47,7 @@ item42[] = {"New_Character",4,218,-325.000000,400.000000,-225.000000,450.000000, item43[] = {"Gender_Selection",2,250,-575.000000,400.000000,-475.000000,450.000000,0.000000,"Gender Selection" \n "Dialog"}; item44[] = {"Selected",4,218,-575.000000,475.000000,-475.000000,525.000000,0.000000,"Selected"}; item45[] = {"Process",2,250,-575.000000,550.000000,-475.000000,600.000000,0.000000,"Process"}; -item46[] = {"no_PlayerID",4,4314,50.000000,-100.000000,150.000000,-50.000000,2.000000,"no PlayerID"}; +item46[] = {"no_PlayerID",4,218,50.000000,-100.000000,150.000000,-50.000000,2.000000,"no PlayerID"}; item47[] = {"ERROR__No_Player_1",2,250,175.000000,-100.000000,275.000000,-50.000000,0.000000,"ERROR:" \n "No PlayerID"}; item48[] = {"Too_Long",4,218,300.000000,-100.000000,400.000000,-50.000000,0.000000,"Too" \n "Long"}; item49[] = {"Stream",2,250,-75.000000,900.000000,25.000000,950.000000,0.000000,"Stream"}; @@ -169,8 +169,8 @@ link85[] = {75,57}; link86[] = {76,78}; link87[] = {77,76}; link88[] = {78,57}; -globals[] = {25.000000,1,0,0,0,640,480,1,143,6316128,1,-400.773193,754.994873,294.455383,-631.582458,1137,911,1}; -window[] = {2,-1,-1,-1,-1,958,200,1478,200,3,1155}; +globals[] = {25.000000,1,0,0,0,640,480,1,143,6316128,1,-578.392273,577.375793,454.378448,-471.659088,1137,911,1}; +window[] = {2,0,0,-1,-1,817,340,1618,59,3,1155}; *//*%FSM*/ class FSM { @@ -182,12 +182,11 @@ class FSM { name = "init"; init = /*%FSM*/"dayz_versionNo = getText(configFile >> ""CfgMods"" >> ""DayZ"" >> ""version"");" \n - "diag_log (""DAYZ: CLIENT IS RUNNING DAYZ_CODE "" + str(dayz_versionNo));" \n - "" \n "_AuthAttempt = 0;" \n "" \n "0 fadeSound 0;" \n "//player setPosATL [-2148,6655,0];" \n + "//DayZ Mod 1.8.1;" \n "" \n "progressLoadingScreen 0.1;" \n "0 cutText ["""",""BLACK""];" \n @@ -195,10 +194,13 @@ class FSM "_timeStart = diag_tickTime;" \n "_readytoAuth = false;" \n "_startCheck = 0;" \n - "//player enableSimulation false;" \n - "if(isNil ""DZEdebug"") then { DZEdebug = false; };" \n + "if(isNil ""DZEdebug"") then { DZEdebug = 1; };" \n "_debug = DZEdebug;" \n "" \n + "if (_debug == 1) then {" \n + "diag_log (""DAYZ: CLIENT IS RUNNING DAYZ_CODE "" + str(dayz_versionNo));" \n + "};" \n + "" \n ""/*%FSM*/; precondition = /*%FSM*/""/*%FSM*/; class Links