1.0.1.6 Developer Build

This commit is contained in:
[VB]AWOL
2013-07-30 21:52:28 -05:00
parent e333adff4f
commit b2b79305f7
42 changed files with 791 additions and 438 deletions

View File

@@ -1,4 +1,5 @@
private ["_obj","_type","_config","_positions","_iPos","_nearBy","_itemType","_itemTypes","_lootChance","_weights","_cntWeights","_index"];
//_t1 = diag_tickTime;
_obj = _this select 0;
@@ -10,10 +11,12 @@ _config = configFile >> "CfgBuildingLoot" >> _type;
_positions = [] + getArray (_config >> "lootPos");
_itemTypes = [] + getArray (_config >> "itemType");
_lootChance = getNumber (_config >> "lootChance");
_positionsSmall = [] + getArray (_config >> "lootPosSmall");
{
if ((random 1) < _lootChance) then {
_iPos = _obj modelToWorld _x;
_nearBy = nearestObjects [_iPos, ["WeaponHolder","WeaponHolderBase"], 1];
_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];
@@ -26,4 +29,23 @@ _lootChance = getNumber (_config >> "lootChance");
_obj setVariable ["created",(DateToNumber date),true];
};
};
} forEach _positions;
} forEach _positions;
{
if ((random 1) < _lootChance) then {
_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_small;
_obj setVariable ["created",(DateToNumber date),true];
};
};
} forEach _positionsSmall;
//["building_spawnLoot.sqf",(diag_tickTime - _t1)] call fnc_dump;

View File

@@ -1,65 +1,60 @@
private["_obj","_type","_config","_canLoot","_unitTypes","_min","_max","_num","_zombieChance","_rnd","_noPlayerNear","_position","_clean","_positions","_iPos","_nearBy","_nearByPlayer"];
_obj = _this select 0;
_type = typeOf _obj;
_config = configFile >> "CfgBuildingLoot" >> _type;
_canLoot = isClass (_config);
private["_t1","_obj","_type","_config","_canLoot","_unitTypes","_min","_max","_num","_zombieChance","_rnd","_noPlayerNear","_position","_clean","_positions","_iPos","_nearBy","_nearByPlayer"];
//_t1 = diag_tickTime;
if (dayz_maxCurrentZeds > dayz_maxZeds) exitwith {};
if (dayz_CurrentZombies > dayz_maxGlobalZombies) exitwith {};
if (dayz_spawnZombies > dayz_maxLocalZombies) exitwith {};
_obj = _this select 0;
_type = typeOf _obj;
_config = configFile >> "CfgBuildingLoot" >> _type;
_canLoot = isClass (_config);
if (_canLoot) then {
//Get zombie class
_unitTypes = getArray (_config >> "zombieClass");
_min = getNumber (_config >> "minRoaming");
_max = getNumber (_config >> "maxRoaming");
//Walking Zombies
//_num = round(random _max) min _min;
_num = (round(random _max)) max _min;
_config = configFile >> "CfgBuildingLoot" >> _type;
//Get zombie class
_zombieChance = getNumber (_config >> "zombieChance");
_rnd = random 1;
//if (_rnd < _zombieChance) then {
//Get zombie class
_unitTypes = getArray (_config >> "zombieClass");
_min = getNumber (_config >> "minRoaming");
_max = getNumber (_config >> "maxRoaming");
//Walking Zombies
_num = (round(random _max)) max _min;
_position = getPosATL _obj;
_noPlayerNear = (count ((getPosATL _obj) nearEntities ["CAManBase",30])) == 0;
_noOneNear = (count (_position nearEntities ["CAManBase",30])) == 0;
if (_noOneNear) then {
_positions = getArray (_config >> "lootPos");
if (_noPlayerNear) then {
//_position = _obj buildingExit 0;
//if ((_position select 0) == 0) then {
_position = getPosATL _obj;
//};
//diag_log ("Class: " + _type + " / Zombies: " + str(_unitTypes) + " / Walking: " + str(_num));
if (count _positions > 0) then {
{
if (random 1 < _zombieChance) then {
_iPos = _obj modelToWorld _x;
_nearBy = count (_iPos nearEntities ["zZombie_Base",1]) > 0;
if (!_nearBy) then {
[_iPos,true,_unitTypes] call zombie_generate;
};
};
} forEach _positions;
} else {
for "_i" from 1 to _num do
{
[_position,true,_unitTypes] call zombie_generate;
};
};
//};
//Add Internal Zombies
_clean = {alive _x} count ((getPosATL _obj) nearEntities ["zZombie_Base",(sizeOf _type)]) == 0;
if (_clean) then {
_positions = getArray (_config >> "lootPos");
_zombieChance = getNumber (_config >> "zombieChance");
//diag_log format["Building: %1 / Positions: %2 / Chance: %3",_type,_positions,_zombieChance];
{
_rnd = random 1;
if (_rnd < _zombieChance) then {
_iPos = _obj modelToWorld _x;
_nearBy = {alive _x} count nearestObjects [_iPos, ["zZombie_Base"],1] > 0;
_nearByPlayer = ({isPlayer _x} count (_iPos nearEntities ["CAManBase",30])) > 0;
//diag_log ("BUILDING: " + _type + " / " + str(_nearBy) + " / " + str(_nearByPlayer));
if (!_nearByPlayer and !_nearBy) then {
[_iPos,true,_unitTypes] call zombie_generate;
if (random 1 < _zombieChance) then {
[_position,true,_unitTypes] call zombie_generate;
};
};
} forEach _positions;
};
};
dayz_buildingMonitor set [count dayz_buildingMonitor,_obj];
};
};
//["building_spawnZombies.sqf",(diag_tickTime - _t1)] call fnc_dump;

View File

@@ -4,7 +4,7 @@ scriptName "Functions\misc\fn_selfActions.sqf";
- Function
- [] call fnc_usec_selfActions;
************************************************************/
private ["_temp_keys","_magazinesPlayer","_isPZombie","_vehicle","_inVehicle","_hasFuelE","_hasRawMeat","_hasKnife","_hasToolbox","_onLadder","_nearLight","_canPickLight","_canDo","_text","_isHarvested","_isVehicle","_isVehicletype","_isMan","_traderType","_ownerID","_isAnimal","_isDog","_isZombie","_isDestructable","_isTent","_isFuel","_isAlive","_canmove","_Unlock","_lock","_buy","_dogHandle","_lieDown","_warn","_hastinitem","_allowedDistance","_menu","_menu1","_humanity_logic","_low_high","_cancel","_metals_trader","_traderMenu","_isWreck","_isRemovable","_isDisallowRepair","_rawmeat","_humanity","_speed","_dog","_hasbottleitem","_isAir","_isShip","_playersNear","_findNearestGens","_findNearestGen","_IsNearRunningGen","_cursorTarget","_isnewstorage","_itemsPlayer","_ownerKeyId","_typeOfCursorTarget","_hasKey","_oldOwner","_combi","_key_colors","_player_deleteBuild"];
private ["_temp_keys","_magazinesPlayer","_isPZombie","_vehicle","_inVehicle","_hasFuelE","_hasRawMeat","_hasKnife","_hasToolbox","_onLadder","_nearLight","_canPickLight","_canDo","_text","_isHarvested","_isVehicle","_isVehicletype","_isMan","_traderType","_ownerID","_isAnimal","_isDog","_isZombie","_isDestructable","_isTent","_isFuel","_isAlive","_Unlock","_lock","_buy","_dogHandle","_lieDown","_warn","_hastinitem","_allowedDistance","_menu","_menu1","_humanity_logic","_low_high","_cancel","_metals_trader","_traderMenu","_isWreck","_isRemovable","_isDisallowRepair","_rawmeat","_humanity","_speed","_dog","_hasbottleitem","_isAir","_isShip","_playersNear","_findNearestGens","_findNearestGen","_IsNearRunningGen","_cursorTarget","_isnewstorage","_itemsPlayer","_ownerKeyId","_typeOfCursorTarget","_hasKey","_oldOwner","_combi","_key_colors","_player_deleteBuild","_player_flipveh","_player_lockUnlock_crtl","_player_butcher","_player_studybody","_player_cook","_player_boil"];
if (TradeInprogress) exitWith {}; // Do not allow if any script is running.
@@ -37,7 +37,7 @@ if (_canPickLight and !dayz_hasLight and !_isPZombie) then {
s_player_removeflare = -1;
};
if(DZEdebug) then {
if(dayz_playerUID == "4560582") then {
hint str(typeOf cursorTarget);
if (s_player_debuglootpos < 0) then {
s_player_debuglootpos = player addAction ["Save to arma2.rpt", "\z\addons\dayz_code\actions\debug\Make_lootPos.sqf", ["start"], 99, false, true, "",""];
@@ -49,6 +49,7 @@ if(DZEdebug) then {
};
};
if(_isPZombie) then {
if (s_player_callzombies < 0) then {
s_player_callzombies = player addAction ["Raise Horde", "\z\addons\dayz_code\actions\call_zombies.sqf",player, 5, true, false, "",""];
@@ -141,7 +142,7 @@ if (!isNull cursorTarget and !_inVehicle and !_isPZombie and (player distance cu
_isTent = _cursorTarget isKindOf "TentStorage";
_isAlive = alive _cursorTarget;
_canmove = canmove _cursorTarget;
_text = getText (configFile >> "CfgVehicles" >> _typeOfCursorTarget >> "displayName");
_rawmeat = meatraw;
@@ -161,14 +162,39 @@ if (!isNull cursorTarget and !_inVehicle and !_isPZombie and (player distance cu
// diag_log ("OWNERID = " + _ownerID + " CHARID = " + dayz_characterID + " " + str(_ownerID == dayz_characterID));
//Allow player to delete objects
// logic vars
_player_flipveh = false;
_player_deleteBuild = false;
_player_lockUnlock_crtl = false;
// CURSOR TARGET ALIVE
if(_isAlive) then {
//Allow player to delete objects
if(_isDestructable or _isWreck or _isRemovable) then {
if(_hasToolbox and "ItemCrowbar" in _itemsPlayer) then {
_player_deleteBuild = true;
};
};
// CURSOR TARGET VEHICLE
if(_isVehicle) then {
//flip vehicle small vehicles by your self and all other vehicles with help nearby
if (!(canmove _cursorTarget) and (player distance _cursorTarget >= 2) and (count (crew _cursorTarget))== 0 and ((vectorUp _cursorTarget) select 2) < 0.5) then {
_playersNear = {isPlayer _x} count (player nearEntities ["CAManBase", 6]);
if(_isVehicletype or (_playersNear >= 2)) then {
_player_flipveh = true;
};
};
if(!_isMan and _ownerID != "0") then {
_player_lockUnlock_crtl = true;
};
};
};
if(_player_deleteBuild) then {
@@ -182,7 +208,7 @@ if (!isNull cursorTarget and !_inVehicle and !_isPZombie and (player distance cu
// Allow Owner to lock and unlock vehicle
if(_isVehicle and _isAlive and !_isMan and _ownerID != "0") then {
if(_player_lockUnlock_crtl) then {
if (s_player_lockUnlock_crtl < 0) then {
_hasKey = _ownerID in _temp_keys;
_oldOwner = (_ownerID == dayz_playerUID);
@@ -233,19 +259,16 @@ if (!isNull cursorTarget and !_inVehicle and !_isPZombie and (player distance cu
};
};
//flip vehicle small vehicles by your self and all other vehicles with help nearby
if (_isVehicle and !_canmove and _isAlive and (player distance _cursorTarget >= 2) and (count (crew _cursorTarget))== 0 and ((vectorUp _cursorTarget) select 2) < 0.5) then {
_playersNear = {isPlayer _x} count (player nearEntities ["CAManBase", 6]);
if(_isVehicletype or (_playersNear >= 2)) then {
if (s_player_flipveh < 0) then {
s_player_flipveh = player addAction [format[localize "str_actions_flipveh",_text], "\z\addons\dayz_code\actions\player_flipvehicle.sqf",_cursorTarget, 1, true, true, "", ""];
};
if(_player_flipveh) then {
if (s_player_flipveh < 0) then {
s_player_flipveh = player addAction [format[localize "str_actions_flipveh",_text], "\z\addons\dayz_code\actions\player_flipvehicle.sqf",_cursorTarget, 1, true, true, "", ""];
};
} else {
player removeAction s_player_flipveh;
s_player_flipveh = -1;
};
};
//Allow player to fill jerrycan
if(_hasFuelE and _isFuel) then {
@@ -257,24 +280,72 @@ if (!isNull cursorTarget and !_inVehicle and !_isPZombie and (player distance cu
s_player_fillfuel = -1;
};
// logic vars for addactions
_player_butcher = false;
_player_studybody = false;
// CURSOR TARGET NOT ALIVE
if (!_isAlive) then {
// Gut animal/zed
if((_isAnimal or _isZombie) and _hasKnife) then {
_isHarvested = _cursorTarget getVariable["meatHarvested",false];
if (!_isHarvested) then {
_player_butcher = true;
};
};
// Study body
if (_isMan and !_isZombie) then {
_player_studybody = true;
}
};
// Human Gut animal or zombie
if (!alive _cursorTarget and (_isAnimal or _isZombie) and _hasKnife) then {
_isHarvested = _cursorTarget getVariable["meatHarvested",false];
if (s_player_butcher < 0 and !_isHarvested) then {
if (_player_butcher) then {
if (s_player_butcher < 0) then {
if(_isZombie) then {
s_player_butcher = player addAction ["Gut Zombie", "\z\addons\dayz_code\actions\gather_zparts.sqf",_cursorTarget, 3, true, true, "", ""];
} else {
s_player_butcher = player addAction [localize "str_actions_self_04", "\z\addons\dayz_code\actions\gather_meat.sqf",_cursorTarget, 3, true, true, "", ""];
};
};
} else {
player removeAction s_player_butcher;
s_player_butcher = -1;
};
// Study Body
if (_player_studybody) then {
if (s_player_studybody < 0) then {
s_player_studybody = player addAction [localize "str_action_studybody", "\z\addons\dayz_code\actions\study_body.sqf",_cursorTarget, 0, false, true, "",""];
};
} else {
player removeAction s_player_studybody;
s_player_studybody = -1;
};
// logic vars
_player_cook = false;
_player_boil = false;
// CURSOR TARGET IS FIRE
if (inflamed _cursorTarget) then {
//Fireplace Actions check
if (_hasRawMeat) then {
_player_cook = true;
};
// Boil water
if (_hasbottleitem and _hastinitem) then {
_player_boil = true;
};
};
//Fireplace Actions check
if (inflamed _cursorTarget and _hasRawMeat) then {
if (_player_cook) then {
if (s_player_cook < 0) then {
s_player_cook = player addAction [localize "str_actions_self_05", "\z\addons\dayz_code\actions\cook.sqf",_cursorTarget, 3, true, true, "", ""];
};
@@ -282,7 +353,9 @@ if (!isNull cursorTarget and !_inVehicle and !_isPZombie and (player distance cu
player removeAction s_player_cook;
s_player_cook = -1;
};
if (inflamed _cursorTarget and (_hasbottleitem and _hastinitem)) then {
// Boil water
if (_player_boil) then {
if (s_player_boil < 0) then {
s_player_boil = player addAction [localize "str_actions_boilwater", "\z\addons\dayz_code\actions\boil.sqf",_cursorTarget, 3, true, true, "", ""];
};
@@ -301,7 +374,7 @@ if (!isNull cursorTarget and !_inVehicle and !_isPZombie and (player distance cu
};
//Packing my tent
if(_cursorTarget isKindOf "TentStorage" and _ownerID == dayz_characterID) then {
if(_isTent and _ownerID == dayz_characterID) then {
if ((s_player_packtent < 0) and (player distance _cursorTarget < 3)) then {
s_player_packtent = player addAction [localize "str_actions_self_07", "\z\addons\dayz_code\actions\tent_pack.sqf",_cursorTarget, 0, false, true, "",""];
};
@@ -356,7 +429,7 @@ if (!isNull cursorTarget and !_inVehicle and !_isPZombie and (player distance cu
//Player Deaths
if(_typeOfCursorTarget == "Info_Board_EP1") then {
if ((s_player_information < 0) and (player distance _cursorTarget < 3)) then {
if (s_player_information < 0) then {
s_player_information = player addAction ["Recent Deaths", "\z\addons\dayz_code\actions\list_playerDeaths.sqf",[], 0, false, true, "",""];
};
} else {
@@ -366,7 +439,7 @@ if (!isNull cursorTarget and !_inVehicle and !_isPZombie and (player distance cu
//Fuel Pump
if(_typeOfCursorTarget in dayz_fuelpumparray) then {
if ((s_player_fuelauto < 0) and (player distance _cursorTarget < 3)) then {
if (s_player_fuelauto < 0) then {
// check if Generator_DZ is running within 30 meters
_findNearestGens = nearestObjects [player, ["Generator_DZ"], 30];
@@ -392,7 +465,7 @@ if (!isNull cursorTarget and !_inVehicle and !_isPZombie and (player distance cu
//Start Generator
if(_cursorTarget isKindOf "Generator_DZ") then {
if ((s_player_fillgen < 0) and (player distance _cursorTarget < 3)) then {
if (s_player_fillgen < 0) then {
// check if not running
if((_cursorTarget getVariable ["GeneratorRunning", false])) then {
@@ -414,7 +487,7 @@ if (!isNull cursorTarget and !_inVehicle and !_isPZombie and (player distance cu
};
//Sleep
if(_cursorTarget isKindOf "TentStorage" and _ownerID == dayz_characterID) then {
if(_isTent and _ownerID == dayz_characterID) then {
if ((s_player_sleep < 0) and (player distance _cursorTarget < 3)) then {
s_player_sleep = player addAction [localize "str_actions_self_sleep", "\z\addons\dayz_code\actions\player_sleep.sqf",_cursorTarget, 0, false, true, "",""];
};
@@ -492,14 +565,6 @@ if (!isNull cursorTarget and !_inVehicle and !_isPZombie and (player distance cu
s_player_parts_crtl = -1;
};
if (_isMan and !_isAlive and !_isZombie) then {
if (s_player_studybody < 0) then {
s_player_studybody = player addAction [localize "str_action_studybody", "\z\addons\dayz_code\actions\study_body.sqf",_cursorTarget, 0, false, true, "",""];
};
} else {
player removeAction s_player_studybody;
s_player_studybody = -1;
};
if(dayz_tameDogs) then {

View File

@@ -13,7 +13,7 @@ if (local _zed) then {
_killer setVariable[_type,(_kills + 1),true];
//increase players humanity when zed killed
_humanity = player getVariable["humanity",0];
_humanity = _killer getVariable["humanity",0];
_humanity = _humanity + 5;
player setVariable["humanity",_humanity,true];
_killer setVariable["humanity",_humanity,true];
};

View File

@@ -1,9 +1,10 @@
private["_animalbody","_qty","_rawfoodtype","_ehLoc"];
_animalbody = _this select 0;
_qty = _this select 1;
_rawfoodtype = getText (configFile >> "CfgSurvival" >> "Meat" >> typeOf _animalbody >> "rawfoodtype");
if (local _animalbody) then {
_qty = _this select 1;
_rawfoodtype = getText (configFile >> "CfgSurvival" >> "Meat" >> typeOf _animalbody >> "rawfoodtype");
for "_x" from 1 to _qty do {
_animalbody addMagazine _rawfoodtype;
};
@@ -23,9 +24,4 @@ if (local _animalbody) then {
deleteVehicle _body;
true;
};
} else {
_ehLoc = "client";
if (isServer) then { _ehLoc = "server"; };
diag_log format["gutObject EH on %1 item not local ! Type: %2",_ehLoc,str(_animalbody)];
};

View File

@@ -21,8 +21,4 @@ if (local _zombiebody) then {
true;
};
} else {
_ehLoc = "client";
if (isServer) then { _ehLoc = "server"; };
diag_log format["gutObject EH on %1 item not local ! Type: %2",_ehLoc,str(_zombiebody)];
};

View File

@@ -1,71 +1,32 @@
private ["_type","_isAir","_inVehicle","_dateNow","_maxZombies","_maxWildZombies","_age","_radius","_position","_markerstr","_markerstr1","_markerstr2","_markerstr3","_nearByObj","_handle","_looted","_cleared","_zombied","_config","_canLoot","_dis","_players","_spawnZombies","_nearby","_nearbyCount"];
private ["_t1","_type","_isAir","_inVehicle","_dateNow","_maxZombies","_maxWildZombies","_age","_radius","_position","_markerstr","_markerstr1","_markerstr2","_markerstr3","_nearByObj","_handle","_looted","_cleared","_zombied","_config","_canLoot","_dis","_players","_spawnZombies","_nearby","_nearbyCount"];
_t1 = diag_tickTime;
_type = _this select 0;
//_Keepspawning = _this select 1;
_isAir = vehicle player iskindof "Air";
//_inVehicle = (vehicle player != player);
_inVehicle = ((vehicle player != player) AND ((speed player > 10) OR _isAir));
_inVehicle = (vehicle player != player);
_onTheMove = (speed (vehicle player) > 10);
_dateNow = (DateToNumber date);
_maxZombies = dayz_maxLocalZombies;
_maxWildZombies = 3;
_age = -1;
//_nearbyBuildings = [];
_radius = 200;
_position = getPosATL player;
if (_inVehicle) then {
_maxZombies = dayz_zedSpawnVehCount;
};
if (_isAir) then {
_maxZombies = dayz_spawnAirCount;
};
//diag_log ("Type: " +str(_type));
//diag_log("SPAWN CHECKING: Starting");
//_locationstypes = ["NameCityCapital","NameCity","NameVillage"];
//_nearestCity = nearestLocations [getPos player, _locationstypes, _radius/2];
//_townname = text (_nearestCity select 0);
//_nearbytype = type (_nearestCity select 0);
/*
switch (_nearbytype) do {
case "NameVillage": {
//_radius = 250;
_maxZombies = 30;
};
case "NameCity": {
//_radius = 300;
_maxZombies = 40;
};
case "NameCityCapital": {
//_radius = 400;
_maxZombies = 40;
};
};
*/
dayz_spawnZombies = 0;
dayz_CurrentZombies = 0;
_players = _position nearEntities ["CAManBase",_radius+200];
dayz_maxGlobalZombies = dayz_maxGlobalZombiesInit;
{
if(isPlayer _x) then {
dayz_maxGlobalZombies = dayz_maxGlobalZombies + dayz_maxGlobalZombiesIncrease;
} else {
if (local _x) then {
dayz_spawnZombies = dayz_spawnZombies + 1;
};
dayz_CurrentZombies = dayz_CurrentZombies + 1;
};
} foreach _players;
_spawnZombies = _position nearEntities ["zZombie_Base",_radius+100];
dayz_spawnZombies = 0;
{
if (local _x) then
{
//diag_log ("Local");
dayz_spawnZombies = dayz_spawnZombies + 1;
};
} foreach _spawnZombies;
dayz_CurrentZombies = count (_position nearEntities ["zZombie_Base",_radius+200]);
if ("ItemMap_Debug" in items player) then {
deleteMarkerLocal "MaxZeds";
deleteMarkerLocal "Counter";
@@ -110,6 +71,7 @@ diag_log ("dayz_maxCurrentZeds: " +str(dayz_maxCurrentZeds) + "/" +str(dayz_maxZ
};
_nearby = _position nearObjects ["building",_radius];
_nearbyCount = count _nearby;
if (_nearbyCount < 1) exitwith
@@ -119,50 +81,60 @@ if (_nearbyCount < 1) exitwith
};
};
{
_type = typeOf _x;
_config = configFile >> "CfgBuildingLoot" >> _type;
_canLoot = isClass (_config);
_dis = _x distance player;
//Loot
if ((_dis < 120) and (_dis > 30) and _canLoot and !_inVehicle) then {
_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(_canLoot) then {
_dis = _x distance player;
//Loot
if ((_dis < 120) and (_dis > 30) and !_inVehicle) then {
_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};
};
};
if ((_age > 10) and (_cleared)) then {
//Register
_x setVariable ["looted",_dateNow,true];
//cleanup
_handle = [_x] spawn building_spawnLoot;
waitUntil{scriptDone _handle};
};
};
//Zeds
if ((time - dayz_spawnWait) > dayz_spawnDelay) then {
if (dayz_maxCurrentZeds < dayz_maxZeds) then {
if (dayz_CurrentZombies < dayz_maxGlobalZombies) then {
if (dayz_spawnZombies < dayz_maxLocalZombies) then {
//[_radius, _position, _inVehicle, _dateNow, _age, _locationstypes, _nearestCity, _maxZombies] call player_spawnzedCheck;
_zombied = (_x getVariable ["zombieSpawn",-0.1]);
_dateNow = (DateToNumber date);
_age = (_dateNow - _zombied) * 525948;
if (_age > 3) then {
_x setVariable ["zombieSpawn",_dateNow,true];
[_x] call building_spawnZombies;
// do not spawn zeds if player is moving faster then 10kmh
if (!_onTheMove) then {
//Zeds
if ((time - dayz_spawnWait) > dayz_spawnDelay) then {
if (dayz_maxCurrentZeds < dayz_maxZeds) then {
if (dayz_CurrentZombies < dayz_maxGlobalZombies) then {
if (dayz_spawnZombies < dayz_maxLocalZombies) then {
//[_radius, _position, _inVehicle, _dateNow, _age, _locationstypes, _nearestCity, _maxZombies] call player_spawnzedCheck;
_zombied = (_x getVariable ["zombieSpawn",-0.1]);
_dateNow = (DateToNumber date);
_age = (_dateNow - _zombied) * 525948;
if (_age > 3) then {
_x setVariable ["zombieSpawn",_dateNow,true];
[_x] call building_spawnZombies;
};
} else {
dayz_spawnWait = time;
};
} else {
dayz_spawnWait = time;
};
};
};
};
};
} forEach _nearby;
} forEach _nearby;
["player_spawnCheck.sqf",(diag_tickTime - _t1)] call fnc_dump;

View File

@@ -87,11 +87,11 @@ private ["_newBackpackType","_backpackWpn","_backpackMag"];
_newUnit setPosATL _position;
_newUnit setDir _dir;
//Clear New Character
//Clear New Character
{_newUnit removeMagazine _x;} forEach magazines _newUnit;
removeAllWeapons _newUnit;
//Equip New Charactar
//Equip New Charactar
{
if (typeName _x == "ARRAY") then {_newUnit addMagazine [_x select 0,_x select 1] } else { _newUnit addMagazine _x };
//sleep 0.05;

View File

@@ -1,14 +1,16 @@
private ["_iItem","_iClass","_iPos","_radius","_itemTypes","_index","_item","_qty","_max","_tQty","_canType","_weights","_cntWeights","_dateNow","_mags"];
private ["_iItem","_iClass","_iPos","_radius","_item","_itemTypes","_index","_weights","_cntWeights","_qty","_max","_tQty","_canType","_mags"];
_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;
//_iPosZ = _iPos select 2;
//if( _iPosZ < 0 ) then { _iPos = [_iPos select 0,_iPos select 1,0]; };
switch (_iClass) do {
default {
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"];
@@ -17,42 +19,63 @@ switch (_iClass) do {
_weights = dayz_CLChances select _index;
_cntWeights = count _weights;
_qty = 0;
// If clothing just spawn one bag of clothes
if(_iClass == "clothes" or _iClass == "militaryclothes" or _iClass == "specialclothes") then {
_max = 1;
} else {
_max = (ceil(random 2)) + 1;
};
while {_qty < _max} do {
_tQty = (round(random 1)) + 1;
_index = floor(random _cntWeights);
_index = _weights select _index;
_canType = _itemTypes select _index;
_max = 1 + ceil(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;
};
if (_iItem != "") then {
if (_iItem != "") then
{
_item addWeaponCargoGlobal [_iItem,1];
};
};
case "weapon": {
case "single":
{
//Item is sigle, add 1 item from cfgloot
_item = createVehicle ["WeaponHolder", _iPos, [], _radius, "CAN_COLLIDE"];
_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 "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 ((count _mags) > 0) then
{
if (_mags select 0 == "Quiver") then { _mags set [0, "WoodenArrow"] }; // Prevent spawning a Quiver
_item addMagazineCargoGlobal [(_mags select 0), (round(random 2))];
};
};
case "magazine": {
case "weaponnomags":
{
//Item is a weapon, and spawns no mags
_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 "object": {
case "object":
{
//Item is one magazine
_item = createVehicle [_iItem, _iPos, [], _radius, "CAN_COLLIDE"];
};
@@ -62,6 +85,7 @@ switch (_iClass) do {
_dateNow = (DateToNumber date);
_item setVariable ["looted",_dateNow,true];
if ((count _iPos) > 2) then {
if ((count _iPos) > 2) then
{
_item setPosATL _iPos;
};

View File

@@ -0,0 +1,52 @@
private ["_iItem","_iClass","_iPos","_radius","_item","_itemTypes","_index","_weights","_cntWeights","_qty","_max","_tQty","_canType","_mags"];
_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 cfgloot
_item = createVehicle ["WeaponHolder", _iPos, [], _radius, "CAN_COLLIDE"];
_itemTypes = [] + ((getArray (configFile >> "cfgLoot" >> _iClass)) select 0);
_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;
_item addMagazineCargoGlobal [_canType,1];
};
case "weapon":
{
//Item is a weapon, and spawns no mags
_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 "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;
};