Organize files a bit and removed non source pbo's

This commit is contained in:
vbawol
2013-06-24 06:26:15 -05:00
parent b4cee9175b
commit 483279c126
1607 changed files with 0 additions and 0 deletions

View File

@@ -0,0 +1,29 @@
private ["_obj","_type","_config","_positions","_iPos","_nearBy","_itemType","_itemTypes","_lootChance","_weights","_cntWeights","_index"];
_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];
_config = configFile >> "CfgBuildingLoot" >> _type;
_positions = [] + getArray (_config >> "lootPos");
_itemTypes = [] + getArray (_config >> "itemType");
_lootChance = getNumber (_config >> "lootChance");
{
if ((random 1) < _lootChance) then {
_iPos = _obj modelToWorld _x;
_nearBy = nearestObjects [_iPos, ["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];
};
};
} forEach _positions;

View File

@@ -0,0 +1,65 @@
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);
if (dayz_maxCurrentZeds > dayz_maxZeds) exitwith {};
if (dayz_CurrentZombies > dayz_maxGlobalZombies) exitwith {};
if (dayz_spawnZombies > dayz_maxLocalZombies) exitwith {};
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 {
_noPlayerNear = (count ((getPosATL _obj) nearEntities ["CAManBase",30])) == 0;
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));
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;
};
};
} forEach _positions;
};
dayz_buildingMonitor set [count dayz_buildingMonitor,_obj];
};

View File

@@ -0,0 +1,57 @@
private ["_position","_target","_targetPos","_isAlive","_list","_isSomeone","_myDest","_agent"];
//Definitions
_agent = _this select 0;
//Add handlers
//_id = _agent addeventhandler ["HandleDamage",{_this call local_zombieDamage}];
//Loop behaviour
_list = (getposATL _agent) nearEntities ["Man",200];
_isSomeone = ({isPlayer _x} count _list) > 0;
_isAlive = alive _agent;
while {_isAlive and _isSomeone} do {
//NO TARGET
_agent disableAI "FSM";
_target = objNull;
_targetPos = [];
//Spawn roaming script (individual to unit)
_myDest = getPosATL _agent;
//Loop looking for targets
while {isNull _target and _isAlive and _isSomeone} do {
_isAlive = alive _agent;
_list = (getposATL _agent) nearEntities ["Man",200];
_isSomeone = ({isPlayer _x} count _list) > 0;
_target = _agent call zombie_findTargetAgent;
if (_isAlive and (_agent distance _myDest < 5)) then {
[_agent,_position] call zombie_loiter;
};
_agent forceSpeed 2;
sleep 1;
};
//CHASE TARGET
//Leader cries out
[_agent,"attack",0,false] call dayz_zombieSpeak;
//Start Movement loop
while {!isNull _target and _isAlive and _isSomeone} do {
_target = _agent call zombie_findTargetAgent;
_isAlive = alive _agent;
_targetPos = getPosATL _target;
//Move to target
_agent moveTo _targetPos;
_agent forceSpeed 8;
sleep 1;
};
//LOOP
_agent setVariable ["targets",[],true];
_isAlive = alive _agent;
sleep 1;
};
//Wait for a while then cleanup
sleep 5;
deleteVehicle _agent;

View File

@@ -0,0 +1,22 @@
private ["_dog","_target","_targets","_man","_manDis"];
_dog = _this;
_target = objNull;
_targets = [];
_man = objNull;
_manDis = 600;
_targets = _dog getVariable ["targets",[]];
diag_log "DEBUG: FIND TARGET AGENT";
if (isNil "_targets") exitWith { diag_log "DEBUG: DOG WAS NIL";};
if (count _targets > 0) then {
{
if ((_x distance _dog) < _manDis) then {
_man = _x;
_manDis = (_x distance _dog);
};
} forEach _targets;
_target = _man;
};
_target;

View File

@@ -0,0 +1,55 @@
scriptName "Functions\arrays\fn_selectRandomWeighted.sqf";
/*
File: fn_selectRandomWeighted.sqf
Author: Joris-Jan van 't Land
Description:
Function to select a random item from an array, taking into account item weights.
The weights should be Numbers between 0 and 1, with a maximum precision of hundreds.
Parameter(s):
_this select 0: source Array (Array of Any Value)
_this select 1: weights (Array of Number)
Returns:
Any Value selected item
TODO:
[*] Algorithm is inefficient?
*/
private ["_weights","_weighted"];
//_array = _this select 0;
_weights = _this select 1;
/*
//Parameter validation.
if ((typeName _array) != (typeName [])) exitWith {debugLog "Log: [selectRandomWeighted] Array (0) must be an Array!"; nil};
if ((typeName _weights) != (typeName [])) exitWith {debugLog "Log: [selectRandomWeighted] Weights (1) must be an Array!"; nil};
if ((count _array) > (count _weights)) exitWith {debugLog "Log: [selectRandomWeighted] There must be at least as many elements in Weights (1) as there are in Array (0)!"; nil};
*/
//Created weighted array of indices.
_weighted = [];
for "_i" from 0 to ((count _weights) - 1) do
{
private ["_weight"];
_weight = _weights select _i;
//Ensure the weight is a Number.
//If it's not, set weight to 0 to exclude it.
if ((typeName _weight) != (typeName 0)) then {diag_log "Log: [selectRandomWeighted] Weights should be Numbers; weight set to 0!"; _weight = 0};
//The weight should be a Number between 0 and 1.
if (_weight < 0) then {diag_log "Log: [selectRandomWeighted] Weights should be more than or equal to 0; weight set to 0!"; _weight = 0};
//if (_weight > 1) then {debugLog "Log: [selectRandomWeighted] Weights should be less than or equal to 1; weight set to 1!"; _weight = 1};
//Normalize the weight for a precision of hundreds.
_weight = round(_weight * 100);
for "_k" from 0 to (_weight - 1) do
{
_weighted = _weighted + [_i];
};
};
_weighted

View File

@@ -0,0 +1,13 @@
private ["_hrStr","_minStr","_curDate","_hr","_min"];
_curDate = date;
_hr = _curDate select 3;
_min = _curDate select 4;
_hrStr = "";
_minStr = "";
if (_hr < 10) then {_hrStr = format["0%1",_hr]} else {_hrStr = format["%1",_hr]};
if (_hr == 0) then {_hrStr = "00"};
if (_min < 10) then {_minStr = format["0%1",_min]} else {_minStr = format["%1",_min]};
if (_min == 0) then {_minStr = "00"};
_strTime = format["%1%2 hrs",_hrStr,_minStr];
_strTime;

View File

@@ -0,0 +1,261 @@
scriptName "Functions\misc\fn_damageActions.sqf";
/***********************************************************
ADD ACTIONS FOR A CASUALTY
- Function
- [] call fnc_usec_damageActions;
************************************************************/
private ["_weaponName","_action","_turret","_weapons","_assignedRole","_action1","_action2","_x","_vehicle","_unit","_vehType","_displayName","_ammoQty","_ammoSerial","_weapon","_magTypes","_type","_typeVeh","_index","_inventory","_unitTo","_isEngineer","_vehClose","_hasVehicle","_unconscious","_lowBlood","_injured","_inPain","_legsBroke","_armsBroke","_charID","_friendlies","_playerMagazines","_hasBandage","_hasEpi","_hasMorphine","_hasBlood","_hasToolbox","_hasJerry","_hasJerryE","_hasWire","_hasPainkillers","_unconscious_crew","_patients","_crew","_menClose","_hasPatient","_inVehicle","_isClose","_bag","_classbag","_isDisallowRefuel","_hasBarrel","_hasBarrelE"];
if (TradeInprogress) exitWith {}; // Do not allow if any script is running.
_menClose = cursorTarget;
_hasPatient = alive _menClose;
_vehicle = vehicle player;
_inVehicle = (_vehicle != player);
_isClose = ((player distance _menClose) < ((sizeOf typeOf _menClose) / 2));
_bag = unitBackpack player;
_classbag = typeOf _bag;
if (_inVehicle) then {
r_player_lastVehicle = _vehicle;
_assignedRole = assignedVehicleRole player;
if (str (_assignedRole) != str (r_player_lastSeat)) then {
call r_player_removeActions2;
};
if (!r_player_unconscious && !r_action2) then {
r_player_lastSeat = _assignedRole;
if (count _assignedRole > 1) then {
_turret = _assignedRole select 1;
_weapons = _vehicle weaponsTurret _turret;
{
_weaponName = getText (configFile >> "cfgWeapons" >> _x >> "displayName");
_action = _vehicle addAction [format["Add AMMO to %1",_weaponName], "\z\addons\dayz_code\actions\ammo.sqf",[_vehicle,_x,_turret], 0, false, true];
r_player_actions2 set [count r_player_actions2,_action];
r_action2 = true;
} forEach _weapons;
};
};
} else {
call r_player_removeActions2;
r_player_lastVehicle = objNull;
r_player_lastSeat = [];
};
if (_hasPatient and !r_drag_sqf and !r_action and !_inVehicle and !r_player_unconscious and _isClose) then {
_unit = cursorTarget;
_isDisallowRefuel = typeOf _unit in ["M240Nest_DZ"];
player reveal _unit;
_vehClose = (getPosATL player) nearEntities [["Car","Tank","Helicopter","Plane","StaticWeapon","Ship"],5]; //nearestObjects [player, ["Car","Tank","Helicopter","Plane","StaticWeapon","Ship"], 5];
_hasVehicle = ({alive _x} count _vehClose > 0);
_unconscious = _unit getVariable ["NORRN_unconscious", false];
_lowBlood = _unit getVariable ["USEC_lowBlood", false];
_injured = _unit getVariable ["USEC_injured", false];
_inPain = _unit getVariable ["USEC_inPain", false];
_legsBroke = _unit getVariable ["hit_legs", 0] >= 1;
_armsBroke = _unit getVariable ["hit_hands", 0] >= 1;
_charID = _unit getVariable ["characterID", 0];
_friendlies = player getVariable ["friendlies", []];
_playerMagazines = magazines player;
_hasBandage = "ItemBandage" in _playerMagazines;
_hasEpi = "ItemEpinephrine" in _playerMagazines;
_hasMorphine = "ItemMorphine" in _playerMagazines;
_hasBlood = "ItemBloodbag" in _playerMagazines;
_hasToolbox = "ItemToolbox" in items player;
_hasJerry = "ItemJerrycan" in _playerMagazines;
_hasBarrel = "ItemFuelBarrel" in _playerMagazines;
_hasJerryE = "ItemJerrycanEmpty" in _playerMagazines;
_hasBarrelE = "ItemFuelBarrelEmpty" in _playerMagazines;
//_hasEtool = "ItemEtool" in weapons player;
_hasWire = "ItemWire" in _playerMagazines;
_hasPainkillers = "ItemPainkiller" in _playerMagazines;
//Allow player to drag
if(_unconscious) then {
r_action = true;
_action1 = _unit addAction [localize "str_actions_medical_01", "\z\addons\dayz_code\medical\drag.sqf",_unit, 0, true, true];
_action2 = _unit addAction [localize "str_actions_medical_02", "\z\addons\dayz_code\medical\pulse.sqf",_unit, 0, true, true];
r_player_actions = r_player_actions + [_action1,_action2];
};
//Load Vehicle
if (_hasVehicle and _unconscious) then {
_x = 0;
r_action = true;
_unit = _unit;
_vehicle = (_vehClose select _x);
while{((!alive _vehicle) and (_x < (count _vehClose)))} do {
_x = _x + 1;
_vehicle = (_vehClose select _x);
};
_vehType = typeOf _vehicle;
_action = _unit addAction [format[localize "str_actions_medical_03",_vehType], "\z\addons\dayz_code\medical\load\load_act.sqf",[player,_vehicle,_unit], 0, true, true];
r_player_actions set [count r_player_actions,_action];
};
//Allow player to bandage
if(_injured and _hasBandage) then {
r_action = true;
//_unit setdamage 0.8;
_action = _unit addAction [localize "str_actions_medical_04", "\z\addons\dayz_code\medical\bandage.sqf",[_unit], 0, true, true, "", ""];
r_player_actions set [count r_player_actions,_action];
};
//Allow player to give Epinephrine
if(_unconscious and _hasEpi) then {
r_action = true;
_action = _unit addAction [localize "str_actions_medical_05", "\z\addons\dayz_code\medical\epinephrine.sqf",[_unit], 0, true, true];
r_player_actions set [count r_player_actions,_action];
};
//Allow player to give Morphine
if((_legsBroke or _armsBroke) and _hasMorphine) then {
r_action = true;
_action = _unit addAction [localize "str_actions_medical_06", "\z\addons\dayz_code\medical\morphine.sqf",[_unit], 0, true, true, "", ""];
r_player_actions set [count r_player_actions,_action];
};
//Allow player to give Painkillers
if(_inPain and _hasPainkillers) then {
r_action = true;
_action = _unit addAction [localize "str_actions_medical_07", "\z\addons\dayz_code\medical\painkiller.sqf",[_unit], 0, true, true, "", ""];
r_player_actions set [count r_player_actions,_action];
};
//Allow player to transfuse blood
if(_lowBlood and _hasBlood) then {
r_action = true;
_action = _unit addAction [localize "str_actions_medical_08", "\z\addons\dayz_code\medical\transfusion.sqf",[_unit], 0, true, true, "", ""];
r_player_actions set [count r_player_actions,_action];
};
//Repairs
if ((_unit isKindOf "AllVehicles") and !(_unit isKindOf "Man") and !_isDisallowRefuel) then {
_type = TypeOf(_unit);
_typeVeh = getText(configFile >> "cfgVehicles" >> _type >> "displayName");
//CAN WE REFUEL THE OBJECT?
if ((fuel _unit < 1) and (_hasJerry or _hasBarrel)) then {
r_action = true;
_action = _unit addAction [format[localize "str_actions_medical_10",_typeVeh], "\z\addons\dayz_code\actions\refuel.sqf",[], 0, true, true, "", ""];
r_player_actions set [count r_player_actions,_action];
};
//CAN WE siphon fuel from THE OBJECT?
if ((fuel _unit > 0) and (_hasJerryE or _hasBarrelE)) then {
r_action = true;
_action = _unit addAction [format["Siphon fuel from %1",_typeVeh], "\z\addons\dayz_code\actions\siphonFuel.sqf",[], 0, true, true, "", ""];
r_player_actions set [count r_player_actions,_action];
};
//CAN WE ISSUE ANOTHER KIND OF AMMUNITION?
if (count weapons _unit > 0) then {
//Get mag array
_weapon = weapons _unit select 0;
_magTypes = getArray(configFile >> "cfgWeapons" >> _weapon >> "magazines");
{
_ammoSerial = (USEC_LogisticsItems find _x);
if (_ammoSerial > -1) then {
//Have the item type
_ammoQty = ((USEC_LogisticsDetail select _ammoSerial) select 1);
if (_ammoQty > 0) then {
//Have at least one
r_action = true;
_displayName = getText(configFile >> "cfgMagazines" >> _x >> "displayName");
_action = _unit addAction [format[localize "str_actions_medical_11",_displayName], "\z\addons\dayz_code\actions\logistics_loadmag.sqf",[_unit,_x], 0, false, true];
r_player_actions set [count r_player_actions,_action];
};
};
} forEach _magTypes;
};
//CAN CARRY BACKPACK
if ((_type in USEC_PackableObjects) and (_classbag == "")) then {
r_action = true;
_action = _unit addAction [format[localize "str_actions_medical_12",_typeVeh], "\z\addons\dayz_code\actions\pack.sqf",[_unit], 0, true, true];
r_player_actions set [count r_player_actions,_action];
};
} else {
// should only fire if cursor target is man and not vehicle
if ((isPlayer _unit) and !(_charID in _friendlies)) then {
r_action = true;
_action = _unit addAction ["Tag as friendly", "\z\addons\dayz_code\actions\player_tagFriendly.sqf", [], 0, false, true, "", ""];
r_player_actions set [count r_player_actions,_action];
};
};
if ((_unit isKindOf "Building")) then {
_type = TypeOf(_unit);
_typeVeh = getText(configFile >> "cfgVehicles" >> _type >> "displayName");
_isEngineer = _hasToolbox;//(_classbag isKindOf "BAF_AssaultPack_Engineer");
//CAN DISASSEMBLE
if (_isEngineer and (_type in USEC_CanDisassemble)) then {
r_action = true;
_index = USEC_CanDisassemble find _type;
_inventory = USEC_DisassembleKits select _index;
_action = _unit addAction [format[localize "str_actions_medical_12",_typeVeh], "\z\addons\dayz_code\actions\disassemble.sqf",[_unit,_inventory], 0, true, true];
r_player_actions set [count r_player_actions,_action];
};
//Upgrade Wire
if (_isEngineer and (_type == "usec_wire_cat1") and _hasWire) then {
r_action = true;
_unitTo = "usec_wire_cat2";
_action = _unit addAction [format[localize "str_actions_medical_13",_typeVeh], "\z\addons\dayz_code\actions\engineer_upgrade.sqf",[_unit,"ItemWire",_unitTo], 0, false, true];
r_player_actions set [count r_player_actions,_action];
};
if (_isEngineer and (_type == "usec_wire_cat2") and _hasWire) then {
r_action = true;
_unitTo = "Fort_RazorWire";
_action = _unit addAction [format[localize "str_actions_medical_13",_typeVeh], "\z\addons\dayz_code\actions\engineer_upgrade.sqf",[_unit,"ItemWire",_unitTo], 0, false, true];
r_player_actions set [count r_player_actions,_action];
};
};
if (r_action) then {
r_action_targets = r_action_targets + [_unit];
};
};
/*
if ((r_player_vehicle != _vehicle) and r_action) then {
//Player is in a new vehicle
r_action = false;
call fnc_usec_medic_removeActions;
};
*/
if (_inVehicle) then {
//Check if patients
_crew = crew _vehicle;
if (count _crew > 0) then {
_unconscious_crew = [];
{
if (_x getVariable "NORRN_unconscious") then {
_unconscious_crew = _unconscious_crew + [_x]
};
} forEach _crew;
_patients = (count _unconscious_crew);
if (_patients > 0) then {
if (!r_action_unload) then {
r_action_unload = true;
_vehType = typeOf _vehicle;
_action = _vehicle addAction [format[localize "str_actions_medical_14",_vehType], "\z\addons\dayz_code\medical\load\unLoad_act.sqf",[player,_vehicle], 0, false, true];
r_player_actions set [count r_player_actions,_action];
};
} else {
if (r_action_unload) then {
call fnc_usec_medic_removeActions;
r_action_unload = false;
};
};
};
//hintSilent format["Crew: %1\nPatients: %2\nAction: %3",(count _crew),_patients,r_action_unload];
} else {
if (r_action_unload) then {
r_action_unload = false;
call fnc_usec_medic_removeActions;
};
};
//Remove Actions
if ((!_isClose or !_hasPatient) and r_action) then {
call fnc_usec_medic_removeActions;
r_action = false;
};
//Pain Effects
//if (r_player_inpain and !r_player_unconscious) then {
// playSound "breath_1";
// addCamShake [2, 1, 25];
//};

View File

@@ -0,0 +1,243 @@
private ["_unit","_humanityHit","_myKills","_hit","_damage","_isPlayer","_unconscious","_wound","_isHit","_isInjured","_type","_hitPain","_isCardiac","_isHeadHit","_isMinor","_scale","_canHitFree","_rndPain","_rndInfection","_hitInfection","_lowBlood","_isPZombie","_source","_ammo","_unitIsPlayer"];
scriptName "Functions\misc\fn_damageHandler.sqf";
/***********************************************************
PROCESS DAMAGE TO A UNIT
- Function
- [unit, selectionName, damage, source, projectile] call fnc_usec_damageHandler;
************************************************************/
private ["_unit","_humanityHit","_myKills","_hit","_damage","_isPlayer","_unconscious","_wound","_isHit","_isInjured","_type","_hitPain","_isCardiac","_isHeadHit","_isMinor","_scale","_canHitFree","_rndPain","_rndInfection","_hitInfection","_lowBlood","_isPZombie","_source","_ammo","_unitIsPlayer"];
_unit = _this select 0;
_hit = _this select 1;
_damage = _this select 2;
_unconscious = _unit getVariable ["NORRN_unconscious", false];
_source = _this select 3;
_ammo = _this select 4;
_type = [_damage,_ammo] call fnc_usec_damageType;
_isMinor = (_hit in USEC_MinorWounds);
_isHeadHit = (_hit == "head_hit");
//_evType = "";
//_recordable = false;
_isPlayer = (isPlayer _source);
_humanityHit = 0;
_myKills = 0;
_unitIsPlayer = _unit == player;
//Publish Damage
//player sidechat format["Processed damage for %1",_unit];
//USEC_SystemMessage = format["CLIENT: %1 damaged for %2 (in vehicle: %5)",_unit,_damage,_isMinor,_isHeadHit,_inVehicle];
//PublicVariable "USEC_SystemMessage";
/*
if (_isPlayer) then {
if (_damage > 0.1) then {
dayz_canDisconnect = false;
//["dayzDiscoAdd",getPlayerUID player] call callRpcProcedure;
dayzDiscoAdd = getPlayerUID player;
publicVariableServer "dayzDiscoAdd";
dayz_damageCounter = time;
//Ensure Control is visible
_display = uiNamespace getVariable 'DAYZ_GUI_display';
_control = _display displayCtrl 1204;
_control ctrlShow true;
};
};
*/
if (_unitIsPlayer) then {
if (_hit == "") then {
if ((_source != player) and _isPlayer) then {
//Enable aggressor Actions
if (_source isKindOf "CAManBase") then {
_source setVariable["startcombattimer",1];
};
_canHitFree = player getVariable ["freeTarget",false];
if (!_canHitFree) then {
_myKills = 200 - (((player getVariable ["humanKills",0]) / 30) * 100);
//Process Morality Hit
_humanityHit = -(_myKills * _damage);
//["dayzHumanity",[_source,_humanityHit,30]] call broadcastRpcCallAll;
dayzHumanity = [_source,_humanityHit,30];
publicVariable "dayzHumanity";
};
};
};
};
//PVP Damage
_scale = 200;
if (_damage > 0.4) then {
if (_ammo != "zombie") then {
_scale = _scale + 50;
};
if (_isHeadHit) then {
_scale = _scale + 500;
};
if ((isPlayer _source) and !(player == _source)) then {
_scale = _scale + 800;
if (_isHeadHit) then {
_scale = _scale + 500;
};
};
switch (_type) do {
case 1: {_scale = _scale + 200};
case 2: {_scale = _scale + 200};
};
if (_unitIsPlayer) then {
//Cause blood loss
//Log Damage
//diag_log ("DAMAGE: player hit by " + typeOf _source + " in " + _hit + " with " + _ammo + " for " + str(_damage) + " scaled " + str(_damage * _scale));
r_player_blood = r_player_blood - (_damage * _scale);
};
};
//Record Damage to Minor parts (legs, arms)
if (_hit in USEC_MinorWounds) then {
if (_ammo == "zombie") then {
if (_hit == "legs") then {
[_unit,_hit,(_damage / 6)] call object_processHit;
} else {
[_unit,_hit,(_damage / 4)] call object_processHit;
};
} else {
[_unit,_hit,(_damage / 2)] call object_processHit;
};
if (_ammo == "") then {
[_unit,_hit,_damage] call object_processHit;
};
};
if (_unitIsPlayer) then {
//incombat
_unit setVariable["startcombattimer", 1, false];
};
if (_damage > 0.1) then {
if (_unitIsPlayer) then {
//shake the cam, frighten them!
//player sidechat format["Processed bullet hit for %1 (should only be for me!)",_unit];
1 call fnc_usec_bulletHit;
};
if (local _unit) then {
_unit setVariable["medForceUpdate",true,true];
};
};
if (_damage > 0.4) then { //0.25
/*
BLEEDING
*/
_wound = _hit call fnc_usec_damageGetWound;
_isHit = _unit getVariable[_wound,false];
if (_unitIsPlayer) then {
_rndPain = (random 10);
_rndInfection = (random 500);
_hitPain = (_rndPain < _damage);
if ((_isHeadHit) or (_damage > 1.2 and _hitPain)) then {
_hitPain = true;
};
_hitInfection = (_rndInfection < 1);
//player sidechat format["HitPain: %1, HitInfection %2 (Damage: %3)",_rndPain,_rndInfection,_damage]; //r_player_infected
if (_isHit) then {
//Make hit worse
if (_unitIsPlayer) then {
r_player_blood = r_player_blood - 50;
};
};
if (_hitInfection) then {
//Set Infection if not already
if (_unitIsPlayer) then {
r_player_infected = true;
player setVariable["USEC_infected",true,true];
};
};
if (_hitPain) then {
//Set Pain if not already
if (_unitIsPlayer) then {
r_player_inpain = true;
player setVariable["USEC_inPain",true,true];
};
};
if ((_damage > 1.5) and _isHeadHit) then {
[_source,"shothead"] spawn player_death;
};
};
if(!_isHit) then {
_isPZombie = player isKindOf "PZombie_VB";
if(!_isPZombie) then {
//Create Wound
_unit setVariable[_wound,true,true];
[_unit,_wound,_hit] spawn fnc_usec_damageBleed;
usecBleed = [_unit,_wound,_hit];
publicVariable "usecBleed";
//Set Injured if not already
_isInjured = _unit getVariable["USEC_injured",false];
if (!_isInjured) then {
_unit setVariable["USEC_injured",true,true];
if ((_unitIsPlayer) and (_ammo != "zombie")) then {
dayz_sourceBleeding = _source;
};
};
//Set ability to give blood
_lowBlood = _unit getVariable["USEC_lowBlood",false];
if (!_lowBlood) then {
_unit setVariable["USEC_lowBlood",true,true];
};
if (_unitIsPlayer) then {
r_player_injured = true;
};
};
};
};
if (_type == 1) then {
/*
BALISTIC DAMAGE
*/
if ((_damage > 0.01) and (_unitIsPlayer)) then {
//affect the player
[20,45] call fnc_usec_pitchWhine; //Visual , Sound
};
if (_damage > 4) then {
//serious ballistic damage
if (_unitIsPlayer) then {
[_source,"explosion"] spawn player_death;
};
} else {
if (_damage > 2) then {
_isCardiac = _unit getVariable["USEC_isCardiac",false];
if (!_isCardiac) then {
_unit setVariable["USEC_isCardiac",true,true];
r_player_cardiac = true;
};
};
};
};
if (_type == 2) then {
/*
HIGH CALIBRE
*/
if (_damage > 4) then {
//serious ballistic damage
if (_unitIsPlayer) then {
[_source,"shotheavy"] spawn player_death;
};
} else {
if (_damage > 2) then {
_isCardiac = _unit getVariable["USEC_isCardiac",false];
if (!_isCardiac) then {
_unit setVariable["USEC_isCardiac",true,true];
r_player_cardiac = true;
};
};
};
};
if (!_unconscious and !_isMinor and ((_damage > 2) or ((_damage > 0.5) and _isHeadHit))) then {
//set unconsious
[_unit,_damage] call fnc_usec_damageUnconscious;
};

View File

@@ -0,0 +1,20 @@
scriptName "Functions\misc\fn_damageHandler.sqf";
/***********************************************************
PROCESS DAMAGE TO A UNIT
- Function
- [unit, selectionName, damage, source, projectile] call fnc_usec_damageHandler;
************************************************************/
private ["_unit","_hit","_damage","_total"];
_unit = _this select 0;
_hit = _this select 1;
_damage = _this select 2;
//_source = _this select 3;
//_ammo = _this select 4;
_total = _damage;
//diag_log ("DAMAGE VEH: " + typeof(_unit) + " / " + str(_hit) + " / " + str(_damage) + " / " + str(getDammage _unit));
if (local _unit) then {
_total = [_unit,_hit,_damage] call object_setHitServer;
};
_total

View File

@@ -0,0 +1,33 @@
//[unit, selectionName, damage, source, projectile]
//will only run when local to the created object
//record any key hits to the required selection
private["_zed","_selection","_damage","_hitter","_projectile","_headShots","_damageOrg"];
_zed = _this select 0;
_selection = _this select 1;
_damage = _this select 2;
_hitter = _this select 3;
_projectile = _this select 4;
if (local _zed) then {
if (_damage > 1 and _projectile != "") then {
//Record deliberate critical damages
switch (_selection) do {
case "head_hit": {
if (!(_zed getVariable["hitRegistered",false])) then {
_headShots = _hitter getVariable["headShots",0];
_hitter setVariable["headShots",(_headShots + 1),true];
_zed setVariable["hitRegistered",true];
};
};
};
if (_projectile isKindOf "Bolt") then {
_damageOrg = _hitter getVariable["firedDamage",0]; //_unit getVariable["firedSelection",_selection];
if (_damageOrg < _damage) then {
_hitter setVariable["firedHit",[_zed,_selection],true];
_hitter setVariable["firedDamage",_damage,true];
};
};
};
};
_damage

View File

@@ -0,0 +1,39 @@
//------------------
// Authors: Peter Morrison (snYpir) & Philipp Pilhofer (raedor)
// Purpose: Checks if a position lies within an angle sector
// Arguments: [<center position>,<center angle of sector>,<sector width>,<position>]
// Return: boolean
//
/*
Returns true if <position> lies within the sector defined by <center position>,
<center angle of sector> and <sector width>. Use this function to determine if
a position lies within a certain angle from another position (ie the <center position>).
Example:
[position player,getdir player,30,position enemy_tank] call BIS_fnc_inAngleSector
will return true if the vehicle named enemy_tank is within 30 degrees of where the player is pointing.
*/
// Revision History:
// 09/01/08 0.1 - First cut VBS2
//------------------
private["_dir1","_dir2","_dir3","_small","_large","_x","_y","_r"];
_r = false;
_small = (_this select 1) - ((_this select 2) / 2);
_large = (_this select 1) + ((_this select 2) / 2);
_x = ((_this select 3) select 0) - ((_this select 0) select 0);
_y = ((_this select 3) select 1) - ((_this select 0) select 1);
_dir1 = _x atan2 _y;
if (_dir1 < 0) then {_dir1 = _dir1 + 360};
_dir2 = _dir1 - 360;
_dir3 = _dir1 + 360;
if ((_dir1 >= _small && _dir1 <= _large) || (_dir2 >= _small && _dir2 <= _large) || (_dir3 >= _small && _dir3 <= _large)) then {_r = true};
_r

View File

@@ -0,0 +1,28 @@
//Kilzone_Kid's megafast inString function
//caseinsensitive
//params [needle,haystack]
private["_needle","_haystack","_found","_haystackArr","_haystackLen","_needleLen","_hayArr"];
scopeName "main";
_needle = _this select 0;
_haystack = _this select 1;
_haystackArr = toArray _haystack;
_haystackLen = count _haystackArr;
_needleLen = count (toArray _needle);
_found = false;
if (_needleLen <= _haystackLen) then {
_hayArr = [];
for "_i" from 0 to (_needleLen - 1) do {
_hayArr set [count _hayArr, _haystackArr select _i];
};
for "_i" from _needleLen to _haystackLen do {
if (toString _hayArr != _needle) then {
_hayArr set [_needleLen, _haystackArr select _i];
_hayArr set [0, "x"];
_hayArr = _hayArr - ["x"];
} else {
_found = true;
breakTo "main";
};
};
};
_found

View File

@@ -0,0 +1,36 @@
private ["_unit1","_building","_relPos","_boundingBox","_min","_max","_myX","_myY","_myZ","_inside"];
_unit1 = _this select 0;
//_building = _this select 1;
_building = nearestObject [player, "HouseBase"];
//_type = typeOf _building;
_relPos = _building worldToModel (getPosATL _unit1);
_boundingBox = boundingBox _building;
//diag_log ("DEBUG: Building: " + str(_building) );
//diag_log ("DEBUG: Building Type: " + str(_type) );
//diag_log ("DEBUG: BoundingBox: " + str(_boundingBox) );
_min = _boundingBox select 0;
_max = _boundingBox select 1;
//diag_log ("Min: " + str(_min) );
//diag_log ("Max: " + str(_max) );
_myX = _relPos select 0;
_myY = _relPos select 1;
_myZ = _relPos select 2;
//diag_log ("X: " + str(_myX) );
//diag_log ("Y: " + str(_myY) );
//diag_log ("Z: " + str(_myZ) );
if ((_myX > (_min select 0)) and (_myX < (_max select 0))) then {
if ((_myY > (_min select 1)) and (_myY < (_max select 1))) then {
if ((_myZ > (_min select 2)) and (_myZ < (_max select 2))) then {
_inside = true;
} else { _inside = false; };
} else { _inside = false; };
} else { _inside = false; };
//diag_log ("isinBuilding Check: " + str(_inside) );
_inside

View File

@@ -0,0 +1,35 @@
private ["_unit1","_building","_relPos","_boundingBox","_min","_max","_myX","_myY","_myZ","_inside"];
_unit1 = _this select 0;
_building = _this select 1;
//_type = typeOf _building;
_relPos = _building worldToModel (getPosATL _unit1);
_boundingBox = boundingBox _building;
//diag_log ("DEBUG: Building: " + str(_building) );
//diag_log ("DEBUG: Building Type: " + str(_type) );
//diag_log ("DEBUG: BoundingBox: " + str(_boundingBox) );
_min = _boundingBox select 0;
_max = _boundingBox select 1;
//diag_log ("Min: " + str(_min) );
//diag_log ("Max: " + str(_max) );
_myX = _relPos select 0;
_myY = _relPos select 1;
_myZ = _relPos select 2;
//diag_log ("X: " + str(_myX) );
//diag_log ("Y: " + str(_myY) );
//diag_log ("Z: " + str(_myZ) );
if ((_myX > (_min select 0)) and (_myX < (_max select 0))) then {
if ((_myY > (_min select 1)) and (_myY < (_max select 1))) then {
if ((_myZ > (_min select 2)) and (_myZ < (_max select 2))) then {
_inside = true;
} else { _inside = false; };
} else { _inside = false; };
} else { _inside = false; };
//diag_log ("isinBuilding Check: " + str(_inside) );
_inside

View File

@@ -0,0 +1,23 @@
scriptName "Functions\arrays\fn_selectRandom.sqf";
/************************************************************
Random Select
By Andrew Barron
Parameters: array
This returns a randomly selected element from the passed array.
Example: [1,2,3] call BIS_fnc_selectRandom
Returns: 1, 2, or 3
************************************************************/
private "_ret";
if(count _this > 0) then
{
_ret = (count _this) - 1; //number of elements in the array
//_ret = [0, _ret] call BIS_fnc_randomInt; //choose random index
_ret = random _ret;
_ret = _this select _ret; //get the element, return it
};
_ret

View File

@@ -0,0 +1,59 @@
scriptName "Functions\arrays\fn_selectRandomWeighted.sqf";
/*
File: fn_selectRandomWeighted.sqf
Author: Joris-Jan van 't Land
Description:
Function to select a random item from an array, taking into account item weights.
The weights should be Numbers between 0 and 1, with a maximum precision of hundreds.
Parameter(s):
_this select 0: source Array (Array of Any Value)
_this select 1: weights (Array of Number)
Returns:
Any Value selected item
TODO:
[*] Algorithm is inefficient?
*/
private ["_array","_weights","_index","_weighted"];
_array = _this select 0;
_weights = _this select 1;
//Parameter validation.
if ((typeName _array) != (typeName [])) exitWith {debugLog "Log: [selectRandomWeighted] Array (0) must be an Array!"; nil};
if ((typeName _weights) != (typeName [])) exitWith {debugLog "Log: [selectRandomWeighted] Weights (1) must be an Array!"; nil};
if ((count _array) > (count _weights)) exitWith {debugLog "Log: [selectRandomWeighted] There must be at least as many elements in Weights (1) as there are in Array (0)!"; nil};
//Created weighted array of indices.
private ["_weighted"];
_weighted = [];
for "_i" from 0 to ((count _weights) - 1) do
{
private ["_weight"];
_weight = _weights select _i;
//Ensure the weight is a Number.
//If it's not, set weight to 0 to exclude it.
if ((typeName _weight) != (typeName 0)) then {debugLog "Log: [selectRandomWeighted] Weights should be Numbers; weight set to 0!"; _weight = 0};
//The weight should be a Number between 0 and 1.
if (_weight < 0) then {debugLog "Log: [selectRandomWeighted] Weights should be more than or equal to 0; weight set to 0!"; _weight = 0};
//if (_weight > 1) then {debugLog "Log: [selectRandomWeighted] Weights should be less than or equal to 1; weight set to 1!"; _weight = 1};
//Normalize the weight for a precision of hundreds.
_weight = round(_weight * 100);
for "_k" from 0 to (_weight - 1) do
{
_weighted = _weighted + [_i];
};
};
//Randomly select an index from the weighted array and therefore an element.
private ["_index"];
_index = _weighted call BIS_fnc_selectRandom;
_array select _index

View File

@@ -0,0 +1,659 @@
scriptName "Functions\misc\fn_selfActions.sqf";
/***********************************************************
ADD ACTIONS FOR SELF
- 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"];
if (TradeInprogress) exitWith {}; // Do not allow if any script is running.
_vehicle = vehicle player;
_isPZombie = player isKindOf "PZombie_VB";
_inVehicle = (_vehicle != player);
_onLadder = (getNumber (configFile >> "CfgMovesMaleSdr" >> "States" >> (animationState player) >> "onLadder")) == 1;
_canDo = (!r_drag_sqf and !r_player_unconscious and !_onLadder);
_nearLight = nearestObject [player,"LitObject"];
_canPickLight = false;
if (!isNull _nearLight) then {
if (_nearLight distance player < 4) then {
_canPickLight = isNull (_nearLight getVariable ["owner",objNull]);
};
};
//Grab Flare
if (_canPickLight and !dayz_hasLight and !_isPZombie) then {
if (s_player_grabflare < 0) then {
_text = getText (configFile >> "CfgAmmo" >> (typeOf _nearLight) >> "displayName");
s_player_grabflare = player addAction [format[localize "str_actions_medical_15",_text], "\z\addons\dayz_code\actions\flare_pickup.sqf",_nearLight, 1, false, true, "", ""];
s_player_removeflare = player addAction [format[localize "str_actions_medical_17",_text], "\z\addons\dayz_code\actions\flare_remove.sqf",_nearLight, 1, false, true, "", ""];
};
} else {
player removeAction s_player_grabflare;
player removeAction s_player_removeflare;
s_player_grabflare = -1;
s_player_removeflare = -1;
};
if(DZEdebug) 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, "",""];
s_player_debuglootpos1 = player addAction ["Raise Z", "\z\addons\dayz_code\actions\debug\Make_lootPos.sqf", ["up"], 99, false, true, "",""];
s_player_debuglootpos2 = player addAction ["Lower Z", "\z\addons\dayz_code\actions\debug\Make_lootPos.sqf", ["down"], 99, false, true, "",""];
s_player_debuglootpos3 = player addAction ["Raise Z", "\z\addons\dayz_code\actions\debug\Make_lootPos.sqf", ["up_small"], 99, false, true, "",""];
s_player_debuglootpos4 = player addAction ["Lower Z", "\z\addons\dayz_code\actions\debug\Make_lootPos.sqf", ["down_small"], 99, false, true, "",""];
Base_Z_height = 0.5;
};
};
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, "",""];
};
if (s_player_pzombiesattack < 0) then {
s_player_pzombiesattack = player addAction ["Attack", "\z\addons\dayz_code\actions\pzombie\pz_attack.sqf",cursorTarget, 6, true, false, "",""];
};
if (s_player_pzombiesvision < 0) then {
s_player_pzombiesvision = player addAction ["Night Vision", "\z\addons\dayz_code\actions\pzombie\pz_vision.sqf", [], 4, false, true, "nightVision", "_this == _target"];
};
if (!isNull cursorTarget and (player distance cursorTarget < 3)) then { //Has some kind of target
_isAnimal = cursorTarget isKindOf "Animal";
_isZombie = cursorTarget isKindOf "zZombie_base";
_isHarvested = cursorTarget getVariable["meatHarvested",false];
_isMan = cursorTarget isKindOf "Man";
// Pzombie Gut human corpse or animal
if (!alive cursorTarget and (_isAnimal or _isMan) and !_isZombie and !_isHarvested) then {
if (s_player_pzombiesfeed < 0) then {
s_player_pzombiesfeed = player addAction ["Feed", "\z\addons\dayz_code\actions\pzombie\pz_feed.sqf",cursorTarget, 3, true, false, "",""];
};
} else {
player removeAction s_player_pzombiesfeed;
s_player_pzombiesfeed = -1;
};
} else {
player removeAction s_player_pzombiesfeed;
s_player_pzombiesfeed = -1;
};
};
// Increase distance only if AIR OR SHIP
_allowedDistance = 4;
_isAir = cursorTarget isKindOf "Air";
_isShip = cursorTarget isKindOf "Ship";
if(_isAir or _isShip) then {
_allowedDistance = 6;
};
if (!isNull cursorTarget and !_inVehicle and !_isPZombie and (player distance cursorTarget < _allowedDistance) and _canDo) then { //Has some kind of target
// set cursortarget to variable
_cursorTarget = cursorTarget;
// get typeof cursortarget once
_typeOfCursorTarget = typeOf _cursorTarget;
_isVehicle = _cursorTarget isKindOf "AllVehicles";
_isVehicletype = _typeOfCursorTarget in ["ATV_US_EP1","ATV_CZ_EP1"];
_isnewstorage = _typeOfCursorTarget in ["VaultStorage","OutHouse_DZ","Wooden_shed_DZ","WoodShack_DZ","StorageShed_DZ"];
// get items and magazines only once
_magazinesPlayer = magazines player;
//boiled Water
_hasbottleitem = "ItemWaterbottle" in _magazinesPlayer;
_hastinitem = false;
{
if (_x in _magazinesPlayer) then {
_hastinitem = true;
};
} forEach boil_tin_cans;
_hasFuelE = "ItemJerrycanEmpty" in _magazinesPlayer;
_itemsPlayer = items player;
_temp_keys = [];
// find available keys
_key_colors = ["ItemKeyYellow","ItemKeyBlue","ItemKeyRed","ItemKeyGreen","ItemKeyBlack"];
{
if (configName(inheritsFrom(configFile >> "CfgWeapons" >> _x)) in _key_colors) then {
_ownerKeyId = getNumber(configFile >> "CfgWeapons" >> _x >> "keyid");
_temp_keys set [count _temp_keys,str(_ownerKeyId)];
};
} forEach _itemsPlayer;
_hasKnife = "ItemKnife" in _itemsPlayer;
_hasToolbox = "ItemToolbox" in _itemsPlayer;
_isMan = _cursorTarget isKindOf "Man";
_traderType = _typeOfCursorTarget;
_ownerID = _cursorTarget getVariable ["characterID","0"];
_isAnimal = _cursorTarget isKindOf "Animal";
_isDog = (_cursorTarget isKindOf "DZ_Pastor" || _cursorTarget isKindOf "DZ_Fin");
_isZombie = _cursorTarget isKindOf "zZombie_base";
_isDestructable = _cursorTarget isKindOf "BuiltItems";
_isWreck = _typeOfCursorTarget in ["SKODAWreck","HMMWVWreck","UralWreck","datsun01Wreck","hiluxWreck","datsun02Wreck","UAZWreck","Land_Misc_Garb_Heap_EP1","Fort_Barricade_EP1","Rubbish2"];
_isRemovable = _typeOfCursorTarget in ["Fence_corrugated_DZ","M240Nest_DZ","ParkBench_DZ","SandNest_DZ","Plastic_Pole_EP1_DZ"];
_isDisallowRepair = _typeOfCursorTarget in ["M240Nest_DZ"];
_isTent = _cursorTarget isKindOf "TentStorage";
_isAlive = alive _cursorTarget;
_canmove = canmove _cursorTarget;
_text = getText (configFile >> "CfgVehicles" >> _typeOfCursorTarget >> "displayName");
_rawmeat = meatraw;
_hasRawMeat = false;
{
if (_x in _magazinesPlayer) then {
_hasRawMeat = true;
};
} forEach _rawmeat;
_isFuel = false;
if (_hasFuelE) then {
{
if(_cursorTarget isKindOf _x) exitWith {_isFuel = true;};
} forEach dayz_fuelsources;
};
// diag_log ("OWNERID = " + _ownerID + " CHARID = " + dayz_characterID + " " + str(_ownerID == dayz_characterID));
//Allow player to delete objects
if((_isDestructable or _isWreck or (_isRemovable and ("ItemCrowbar" in _itemsPlayer))) and _hasToolbox and _isAlive) then {
if (s_player_deleteBuild < 0) then {
s_player_deleteBuild = player addAction [format[localize "str_actions_delete",_text], "\z\addons\dayz_code\actions\remove.sqf",_cursorTarget, 1, true, true, "", ""];
};
} else {
player removeAction s_player_deleteBuild;
s_player_deleteBuild = -1;
};
// Allow Owner to lock and unlock vehicle
if(_isVehicle and _isAlive and !_isMan and _ownerID != "0") then {
if (s_player_lockUnlock_crtl < 0) then {
_hasKey = _ownerID in _temp_keys;
_oldOwner = (_ownerID == dayz_playerUID);
if(locked _cursorTarget) then {
if(_hasKey or _oldOwner) then {
_Unlock = player addAction [format["Unlock %1",_text], "\z\addons\dayz_code\actions\unlock_veh.sqf",_cursorTarget, 2, true, true, "", ""];
s_player_lockunlock set [count s_player_lockunlock,_Unlock];
s_player_lockUnlock_crtl = 1;
} else {
_Unlock = player addAction ["<t color='#ff0000'>Vehicle Locked</t>", "",_cursorTarget, 2, true, true, "", ""];
s_player_lockunlock set [count s_player_lockunlock,_Unlock];
s_player_lockUnlock_crtl = 1;
};
} else {
if(_hasKey or _oldOwner) then {
_lock = player addAction [format["Lock %1",_text], "\z\addons\dayz_code\actions\lock_veh.sqf",_cursorTarget, 1, true, true, "", ""];
s_player_lockunlock set [count s_player_lockunlock,_lock];
s_player_lockUnlock_crtl = 1;
};
};
};
} else {
{player removeAction _x} forEach s_player_lockunlock;s_player_lockunlock = [];
s_player_lockUnlock_crtl = -1;
};
/*
//Allow player to force save
if((_isVehicle or _isTent) and !_isMan) then {
if (s_player_forceSave < 0) then {
s_player_forceSave = player addAction [format[localize "str_actions_save",_text], "\z\addons\dayz_code\actions\forcesave.sqf",_cursorTarget, 1, true, true, "", ""];
};
} else {
player removeAction s_player_forceSave;
s_player_forceSave = -1;
};
if((_isVehicle or _isTent or _isnewstorage) and _isAlive and !_isMan) then {
if (s_player_checkGear < 0) then {
s_player_checkGear = player addAction ["Cargo Check", "\z\addons\dayz_code\actions\cargocheck.sqf",_cursorTarget, 1, true, true, "", ""];
};
} else {
player removeAction s_player_checkGear;
s_player_checkGear = -1;
};
*/
//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, "", ""];
};
};
} else {
player removeAction s_player_flipveh;
s_player_flipveh = -1;
};
//Allow player to fill jerrycan
if(_hasFuelE and _isFuel) then {
if (s_player_fillfuel < 0) then {
s_player_fillfuel = player addAction [localize "str_actions_self_10", "\z\addons\dayz_code\actions\jerry_fill.sqf",[], 1, false, true, "", ""];
};
} else {
player removeAction s_player_fillfuel;
s_player_fillfuel = -1;
};
// 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(_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;
};
//Fireplace Actions check
if (inflamed _cursorTarget and _hasRawMeat) 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, "", ""];
};
} else {
player removeAction s_player_cook;
s_player_cook = -1;
};
if (inflamed _cursorTarget and (_hasbottleitem and _hastinitem)) 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, "", ""];
};
} else {
player removeAction s_player_boil;
s_player_boil = -1;
};
if(_cursorTarget == dayz_hasFire) then {
if ((s_player_fireout < 0) and !(inflamed _cursorTarget) and (player distance _cursorTarget < 3)) then {
s_player_fireout = player addAction [localize "str_actions_self_06", "\z\addons\dayz_code\actions\fire_pack.sqf",_cursorTarget, 0, false, true, "",""];
};
} else {
player removeAction s_player_fireout;
s_player_fireout = -1;
};
//Packing my tent
if(_cursorTarget isKindOf "TentStorage" 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, "",""];
};
} else {
player removeAction s_player_packtent;
s_player_packtent = -1;
};
//Allow owner to unlock vault
if((_typeOfCursorTarget == "VaultStorageLocked" or _typeOfCursorTarget == "VaultStorage") and _ownerID != "0" and (player distance _cursorTarget < 3)) then {
if (s_player_unlockvault < 0) then {
if(_typeOfCursorTarget == "VaultStorageLocked") then {
if(_ownerID == dayz_combination or _ownerID == dayz_playerUID) then {
_combi = player addAction ["Open Safe", "\z\addons\dayz_code\actions\vault_unlock.sqf",_cursorTarget, 0, false, true, "",""];
} else {
_combi = player addAction ["Unlock Safe", "\z\addons\dayz_code\actions\vault_combination_1.sqf",_cursorTarget, 0, false, true, "",""];
};
s_player_combi set [count s_player_combi,_combi];
s_player_unlockvault = 1;
} else {
if(_ownerID != dayz_combination and _ownerID != dayz_playerUID) then {
_combi = player addAction ["Enter Combo", "\z\addons\dayz_code\actions\vault_combination_1.sqf",_cursorTarget, 0, false, true, "",""];
s_player_combi set [count s_player_combi,_combi];
s_player_unlockvault = 1;
};
};
};
} else {
{player removeAction _x} forEach s_player_combi;s_player_combi = [];
s_player_unlockvault = -1;
};
//Allow owner to pack vault
if(_typeOfCursorTarget == "VaultStorage" and _ownerID != "0" and (player distance _cursorTarget < 3)) then {
if (s_player_lockvault < 0) then {
if(_ownerID == dayz_combination or _ownerID == dayz_playerUID) then {
s_player_lockvault = player addAction ["Lock Safe", "\z\addons\dayz_code\actions\vault_lock.sqf",_cursorTarget, 0, false, true, "",""];
};
};
if (s_player_packvault < 0 and (_ownerID == dayz_combination or _ownerID == dayz_playerUID)) then {
s_player_packvault = player addAction ["<t color='#ff0000'>Pack Safe</t>", "\z\addons\dayz_code\actions\vault_pack.sqf",_cursorTarget, 0, false, true, "",""];
};
} else {
player removeAction s_player_packvault;
s_player_packvault = -1;
player removeAction s_player_lockvault;
s_player_lockvault = -1;
};
//Player Deaths
if(_typeOfCursorTarget == "Info_Board_EP1") then {
if ((s_player_information < 0) and (player distance _cursorTarget < 3)) then {
s_player_information = player addAction ["Recent Deaths", "\z\addons\dayz_code\actions\list_playerDeaths.sqf",[], 0, false, true, "",""];
};
} else {
player removeAction s_player_information;
s_player_information = -1;
};
//Fuel Pump
if(_typeOfCursorTarget in dayz_fuelpumparray) then {
if ((s_player_fuelauto < 0) and (player distance _cursorTarget < 3)) then {
// check if Generator_DZ is running within 30 meters
_findNearestGens = nearestObjects [player, ["Generator_DZ"], 30];
_findNearestGen = [];
{
if (alive _x and (_x getVariable ["GeneratorRunning", false])) then {
_findNearestGen set [(count _findNearestGen),_x];
};
} foreach _findNearestGens;
_IsNearRunningGen = count (_findNearestGen);
// show that pump needs power if no generator nearby.
if(_IsNearRunningGen > 0) then {
s_player_fuelauto = player addAction ["Fill Vehicle", "\z\addons\dayz_code\actions\fill_nearestVehicle.sqf",[], 0, false, true, "",""];
} else {
s_player_fuelauto = player addAction ["<t color='#ff0000'>Needs Power</t>", "",[], 0, false, true, "",""];
};
};
} else {
player removeAction s_player_fuelauto;
s_player_fuelauto = -1;
};
//Start Generator
if(_cursorTarget isKindOf "Generator_DZ") then {
if ((s_player_fillgen < 0) and (player distance _cursorTarget < 3)) then {
// check if not running
if((_cursorTarget getVariable ["GeneratorRunning", false])) then {
s_player_fillgen = player addAction ["Stop Generator", "\z\addons\dayz_code\actions\stopGenerator.sqf",_cursorTarget, 0, false, true, "",""];
} else {
// check if not filled and player has jerry.
if((_cursorTarget getVariable ["GeneratorFilled", false])) then {
s_player_fillgen = player addAction ["Start Generator", "\z\addons\dayz_code\actions\fill_startGenerator.sqf",_cursorTarget, 0, false, true, "",""];
} else {
if("ItemJerrycan" in _magazinesPlayer) then {
s_player_fillgen = player addAction ["Fill and Start Generator", "\z\addons\dayz_code\actions\fill_startGenerator.sqf",_cursorTarget, 0, false, true, "",""];
};
};
};
};
} else {
player removeAction s_player_fillgen;
s_player_fillgen = -1;
};
// not the right place for this...
// Find if fuel pump is within 5 meters.
// If so then look for a generator within 30m of pump
// and if generator is running
// Allow auto fill
//Sleep
if(_cursorTarget isKindOf "TentStorage" 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, "",""];
};
} else {
player removeAction s_player_sleep;
s_player_sleep = -1;
};
//Repairing Vehicles
if ((dayz_myCursorTarget != _cursorTarget) and _isVehicle and !_isMan and _hasToolbox and (damage _cursorTarget < 1) and !_isDisallowRepair) then {
if (s_player_repair_crtl < 0) then {
dayz_myCursorTarget = _cursorTarget;
_menu = dayz_myCursorTarget addAction ["Repair Vehicle", "\z\addons\dayz_code\actions\repair_vehicle.sqf",_cursorTarget, 0, true, false, "",""];
_menu1 = dayz_myCursorTarget addAction ["Salvage Vehicle", "\z\addons\dayz_code\actions\salvage_vehicle.sqf",_cursorTarget, 0, true, false, "",""];
s_player_repairActions set [count s_player_repairActions,_menu];
s_player_repairActions set [count s_player_repairActions,_menu1];
s_player_repair_crtl = 1;
} else {
{dayz_myCursorTarget removeAction _x} forEach s_player_repairActions;s_player_repairActions = [];
s_player_repair_crtl = -1;
};
};
// All Traders
if (_isMan and !_isPZombie and _traderType in serverTraders) then {
if (s_player_parts_crtl < 0) then {
// get humanity
_humanity = player getVariable ["humanity",0];
_traderMenu = call compile format["menu_%1;",_traderType];
// diag_log ("TRADER = " + str(_traderMenu));
_low_high = "low";
_humanity_logic = false;
if((_traderMenu select 2) == "friendly") then {
_humanity_logic = (_humanity < -2000);
};
if((_traderMenu select 2) == "hostile") then {
_low_high = "high";
_humanity_logic = (_humanity > -2000);
};
if((_traderMenu select 2) == "hero") then {
_humanity_logic = (_humanity < 5000);
};
if(_humanity_logic) then {
_cancel = player addAction [format["Your humanity is too %1 this trader refuses to talk to you.",_low_high], "\z\addons\dayz_code\actions\trade_cancel.sqf",["na"], 0, true, false, "",""];
s_player_parts set [count s_player_parts,_cancel];
} else {
// Static Menu
{
diag_log format["DEBUG TRADER: %1", _x];
_buy = player addAction [format["Trade %1 %2 for %3 %4",(_x select 3),(_x select 5),(_x select 2),(_x select 6)], "\z\addons\dayz_code\actions\trade_items_wo_db.sqf",[(_x select 0),(_x select 1),(_x select 2),(_x select 3),(_x select 4),(_x select 5),(_x select 6)], (_x select 7), true, true, "",""];
s_player_parts set [count s_player_parts,_buy];
} forEach (_traderMenu select 1);
// Database menu
{
_buy = player addAction [(_x select 0), "\z\addons\dayz_code\actions\buy_or_sell.sqf",[(_x select 1),(_x select 0)], 99, true, false, "",""];
s_player_parts set [count s_player_parts,_buy];
} forEach (_traderMenu select 0);
// Add static metals trader options under sub menu
_metals_trader = player addAction ["Trade Metals", "\z\addons\dayz_code\actions\trade_metals.sqf",["na"], 0, true, false, "",""];
s_player_parts set [count s_player_parts,_metals_trader];
};
s_player_parts_crtl = 1;
};
} else {
{player removeAction _x} forEach s_player_parts;s_player_parts = [];
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 {
//Dog
if (_isDog and _isAlive and (_hasRawMeat) and _ownerID == "0" and player getVariable ["dogID", 0] == 0) then {
if (s_player_tamedog < 0) then {
s_player_tamedog = player addAction [localize "str_actions_tamedog", "\z\addons\dayz_code\actions\tame_dog.sqf", _cursorTarget, 1, false, true, "", ""];
};
} else {
player removeAction s_player_tamedog;
s_player_tamedog = -1;
};
if (_isDog and _ownerID == dayz_characterID and _isAlive) then {
_dogHandle = player getVariable ["dogID", 0];
if (s_player_feeddog < 0 and _hasRawMeat) then {
s_player_feeddog = player addAction [localize "str_actions_feeddog","\z\addons\dayz_code\actions\dog\feed.sqf",[_dogHandle,0], 0, false, true,"",""];
};
if (s_player_waterdog < 0 and "ItemWaterbottle" in _magazinesPlayer) then {
s_player_waterdog = player addAction [localize "str_actions_waterdog","\z\addons\dayz_code\actions\dog\feed.sqf",[_dogHandle,1], 0, false, true,"",""];
};
if (s_player_staydog < 0) then {
_lieDown = _dogHandle getFSMVariable "_actionLieDown";
if (_lieDown) then { _text = "str_actions_liedog"; } else { _text = "str_actions_sitdog"; };
s_player_staydog = player addAction [localize _text,"\z\addons\dayz_code\actions\dog\stay.sqf", _dogHandle, 5, false, true,"",""];
};
if (s_player_trackdog < 0) then {
s_player_trackdog = player addAction [localize "str_actions_trackdog","\z\addons\dayz_code\actions\dog\track.sqf", _dogHandle, 4, false, true,"",""];
};
if (s_player_barkdog < 0) then {
s_player_barkdog = player addAction [localize "str_actions_barkdog","\z\addons\dayz_code\actions\dog\speak.sqf", _cursorTarget, 3, false, true,"",""];
};
if (s_player_warndog < 0) then {
_warn = _dogHandle getFSMVariable "_watchDog";
if (_warn) then { _text = "Quiet"; _warn = false; } else { _text = "Alert"; _warn = true; };
s_player_warndog = player addAction [format[localize "str_actions_warndog",_text],"\z\addons\dayz_code\actions\dog\warn.sqf",[_dogHandle, _warn], 2, false, true,"",""];
};
if (s_player_followdog < 0) then {
s_player_followdog = player addAction [localize "str_actions_followdog","\z\addons\dayz_code\actions\dog\follow.sqf",[_dogHandle,true], 6, false, true,"",""];
};
} else {
player removeAction s_player_feeddog;
s_player_feeddog = -1;
player removeAction s_player_waterdog;
s_player_waterdog = -1;
player removeAction s_player_staydog;
s_player_staydog = -1;
player removeAction s_player_trackdog;
s_player_trackdog = -1;
player removeAction s_player_barkdog;
s_player_barkdog = -1;
player removeAction s_player_warndog;
s_player_warndog = -1;
player removeAction s_player_followdog;
s_player_followdog = -1;
};
};
} else {
//Engineering
{dayz_myCursorTarget removeAction _x} forEach s_player_repairActions;s_player_repairActions = [];
s_player_repair_crtl = -1;
{player removeAction _x} forEach s_player_combi;s_player_combi = [];
dayz_myCursorTarget = objNull;
{player removeAction _x} forEach s_player_parts;s_player_parts = [];
s_player_parts_crtl = -1;
{player removeAction _x} forEach s_player_lockunlock;s_player_lockunlock = [];
s_player_lockUnlock_crtl = -1;
player removeAction s_player_checkGear;
s_player_checkGear = -1;
//Others
player removeAction s_player_forceSave;
s_player_forceSave = -1;
player removeAction s_player_flipveh;
s_player_flipveh = -1;
player removeAction s_player_sleep;
s_player_sleep = -1;
player removeAction s_player_deleteBuild;
s_player_deleteBuild = -1;
player removeAction s_player_butcher;
s_player_butcher = -1;
player removeAction s_player_cook;
s_player_cook = -1;
player removeAction s_player_boil;
s_player_boil = -1;
player removeAction s_player_fireout;
s_player_fireout = -1;
player removeAction s_player_packtent;
s_player_packtent = -1;
player removeAction s_player_fillfuel;
s_player_fillfuel = -1;
player removeAction s_player_studybody;
s_player_studybody = -1;
//Dog
player removeAction s_player_tamedog;
s_player_tamedog = -1;
player removeAction s_player_feeddog;
s_player_feeddog = -1;
player removeAction s_player_waterdog;
s_player_waterdog = -1;
player removeAction s_player_staydog;
s_player_staydog = -1;
player removeAction s_player_trackdog;
s_player_trackdog = -1;
player removeAction s_player_barkdog;
s_player_barkdog = -1;
player removeAction s_player_warndog;
s_player_warndog = -1;
player removeAction s_player_followdog;
s_player_followdog = -1;
// vault
player removeAction s_player_unlockvault;
s_player_unlockvault = -1;
player removeAction s_player_packvault;
s_player_packvault = -1;
player removeAction s_player_lockvault;
s_player_lockvault = -1;
player removeAction s_player_information;
s_player_information = -1;
player removeAction s_player_fillgen;
s_player_fillgen = -1;
player removeAction s_player_fuelauto;
s_player_fuelauto = -1;
};
//Dog actions on player self
_dogHandle = player getVariable ["dogID", 0];
if (_dogHandle > 0) then {
_dog = _dogHandle getFSMVariable "_dog";
_ownerID = "0";
if (!isNull cursorTarget) then { _ownerID = cursorTarget getVariable ["characterID","0"]; };
if (_canDo and !_inVehicle and alive _dog and _ownerID != dayz_characterID) then {
if (s_player_movedog < 0) then {
s_player_movedog = player addAction [localize "str_actions_movedog", "\z\addons\dayz_code\actions\dog\move.sqf", player getVariable ["dogID", 0], 1, false, true, "", ""];
};
if (s_player_speeddog < 0) then {
_text = "Walk";
_speed = 0;
if (_dog getVariable ["currentSpeed",1] == 0) then { _speed = 1; _text = "Run"; };
s_player_speeddog = player addAction [format[localize "str_actions_speeddog", _text], "\z\addons\dayz_code\actions\dog\speed.sqf",[player getVariable ["dogID", 0],_speed], 0, false, true, "", ""];
};
if (s_player_calldog < 0) then {
s_player_calldog = player addAction [localize "str_actions_calldog", "\z\addons\dayz_code\actions\dog\follow.sqf", [player getVariable ["dogID", 0], true], 2, false, true, "", ""];
};
};
} else {
player removeAction s_player_movedog;
s_player_movedog = -1;
player removeAction s_player_speeddog;
s_player_speeddog = -1;
player removeAction s_player_calldog;
s_player_calldog = -1;
};

View File

@@ -0,0 +1,124 @@
/************************************************************
Set Pitch and Bank
By General Barron ([EMAIL=aw_barron@hotmail.com]aw_barron@hotmail.com[/EMAIL]) and vektorboson
Parameters: [object, pitch, bank]
Returns: nothing
Rotates an object, giving it the specified pitch and bank,
in degrees.
Pitch is 0 when the object is level; 90 when pointing straight
up; and -90 when pointing straight down.
Bank is 0 when level; 90 when the object is rolled to the right,
-90 when rolled to the left, and 180 when rolled upside down.
Note that the object's yaw can be set with the setdir command,
which should be issued before using this function, if required.
The pitch/bank can be leveled out (set to 0) by using the
setdir command.
************************************************************/
//extract parameters
private ["_obj","_pitch","_bank","_yaw","_vdir","_vup","_sign","_rotate"];
_obj = _this select 0;
_pitch = _this select 1;
_bank = _this select 2;
//find the yaw (direction) of the object
//map compass directions go CW, while coordinate (vector) directions go CCW, so we need to flip this
//if we don't flip this, the object will face backwards
_yaw = 360-(getdir _obj);
//----------------------------
//function to rotate a 2d vector around the origin
//----------------------------
_rotate =
{
private ["_v","_d","_x","_y"];
//extract parameters
_v = +(_this select 0); //we don't want to modify the originally passed vector
_d = _this select 1;
//extract old x/y values
_x = _v select 0;
_y = _v select 1;
//if vector is 3d, we don't want to mess up the last element
_v set [0, (cos _d)*_x - (sin _d)*_y];
_v set [1, (sin _d)*_x + (cos _d)*_y];
//return new vector
_v
};
//----------------------------
//find vector dir (pitch)
//----------------------------
//find sign of pitch
_sign = [1,-1] select (_pitch < 0);
//cut off numbers above 180
while {abs _pitch > 180} do {_pitch = _sign*((abs _pitch) - 180)};
//we can't use pitch that is exactly equal to 90, because then the engine doesn't know what 2d compass direction the object is facing
if(abs _pitch == 90) then {_pitch = _sign*(89.9)};
//we can't pitch beyond 90 degrees without changing the facing of our object
//(pitching beyond 90 degrees means that the object's eyes will point in the 2d compass direction that its back used to point)
if(abs _pitch > 90) then
{
//we are rolling upside down; flip our direction (yaw)
_obj setdir (getdir _obj)-180;
_yaw = 360-(getdir _obj);
//use bank to flip upside down
_bank = _bank + 180;
//and adjust our original pitch
_pitch = (180 - abs _pitch)*_sign;
};
//find appropriate vdir according to our pitch, as if we were facing north
_vdir = [0, cos _pitch, sin _pitch];
//then rotate X & Y around the origin according to object's yaw (direction)
_vdir = [_vdir, _yaw] call _rotate;
//----------------------------
//find vector up (bank)
//----------------------------
//find sign of bank
_sign = [1,-1] select (_bank < 0);
//cut off numbers above 360
while {abs _bank > 360} do {_bank = _sign*((abs _bank) - 360)};
//reflect numbers above 180
if(abs _bank > 180) then {_sign = -1*_sign; _bank = (360-_bank)*_sign};
//find appropriate vup according to our bank, as if we were facing north
_vup = [sin _bank, 0, cos _bank];
//rotate Y & Z elements according to pitch
_vup = [_vup select 0] + ([[_vup select 1, _vup select 2], _pitch] call _rotate);
//rotate X & Y around origin according to yaw
_vup = [_vup, _yaw] call _rotate;
//----------------------------
//apply the vectors
//----------------------------
_obj setVectorDirAndUp [_vdir, _vup];

View File

@@ -0,0 +1,22 @@
/*
Author: CarlGustaffa (modified by gammadust)
Description:
Returns the sun's rise in hours for the current day of the year on any island (whos latitude may differ).
Parameters:
None needed.
Returns:
Sun's rise in hours, in the same format as engine's [daytime] command (16.5 == 16:30)
To obtain sun's set, just subtract the result from 24.
Reference:
http://forums.bistudio.com/showthread.php?107476-How-do-I-detect-sundown-sunrise
*/
private ["_lat","_day","_hour","_daytime"];
_lat = -1 * getNumber(configFile >> "CfgWorlds" >> worldName >> "latitude");
_day = 360 * (dateToNumber date);
_hour = acos ((24 * sin(_lat) * cos(_day)) / ((12 * cos(_day) - 78) * cos(_lat)));
_daytime = _hour / 360 * 24;
_daytime

View File

@@ -0,0 +1,20 @@
//Assess Terrain
private ["_unit","_pos","_type","_typeA","_soundType","_soundVal","_array"];
_unit = _this;
_pos = getPosATL _unit;
_type = surfaceType _pos;
_typeA = toArray _type;
_typeA set [0,"DEL"];
_typeA = _typeA - ["DEL"];
_type = toString _typeA;
// _test = 0;
//diag_log ("FINDME: " + _type);
_soundType = getText (configFile >> "CfgSurfaces" >> _type >> "soundEnviron");
_soundVal = parseNumber format["%1",((getArray (configFile >> "CfgVehicles" >> "CAManBase" >> "SoundEnvironExt" >> _soundType) select 0) select 3)];
if (_soundVal == 0) then {
_soundVal = 25;
};
_array = [_soundType,_soundVal];
_array

View File

@@ -0,0 +1,166 @@
/*
Author: TeeTime
Does: Manages the body temperatur of a Player
Possible Problems:
=> Balancing
Missing:
Save Functions
Should Effects Sum Up?
Math Functions for Water
Player Update GUI Colours need to be checked
Shivering Function need improments
*/
private ["_looptime","_sun_factor","_building_factor","_vehicle_factor","_fire_factor","_water_factor","_rain_factor","_night_factor","_wind_factor","_height_mod","_difference","_isinbuilding","_isinvehicle","_raining","_sunrise","_building","_fireplaces","_daytime","_temp","_moving_factor"];
_looptime = _this;
//Factors are equal to win/loss of factor*basic value
//All Values can be seen as x of 100: 100 / x = minutes from min temperetaure to max temperature (without other effects)
_vehicle_factor = 4;
_moving_factor = 7;
_fire_factor = 15; //Should be always: _rain_factor + _night_factor + _wind_factor OR higher !
_building_factor = 7;
_sun_factor = 4; //max sunfactor linear over the day. highest value in the middle of the day
_water_factor = -8;
_rain_factor = -3;
_night_factor = -1.5;
_wind_factor = -1;
_difference = 0;
// _hasfireffect = false;
_isinbuilding = false;
_isinvehicle = false;
_raining = if(rain > 0) then {true} else {false};
_sunrise = call world_sunRise;
//POSITIV EFFECTS
//vehicle
if((vehicle player) != player) then {
_difference = _difference + _vehicle_factor;
_isinvehicle = true;
} else {
//speed factor
private["_vel","_speed"];
_vel = velocity player;
_speed = round((_vel distance [0,0,0]) * 3.5);
_difference = (_moving_factor * (_speed / 20)) min 7;
};
//fire
private ["_fireplaces"];
_fireplaces = nearestObjects [player, ["Land_Fire","Land_Campfire"], 8];
if(({inflamed _x} count _fireplaces) > 0 && !_isinvehicle ) then {
//Math: factor * 1 / (0.5*(distance max 1)^2) 0.5 = 12.5% of the factor effect in a distance o 4 meters
_difference = _difference + (_fire_factor /(0.5*((player distance (_fireplaces select 0)) max 1)^2));
//_hasfireffect = true;
};
//building
_building = nearestObject [player, "HouseBase"];
if(!isNull _building) then {
if([player,_building] call fnc_isInsideBuilding) then {
//Make sure thate Fire and Building Effect can only appear single Not used at the moment
//if(!_hasfireffect && _fire_factor > _building_factor) then {
_difference = _difference + _building_factor;
//};
_isinbuilding = true;
dayz_inside = true;
} else {
dayz_inside = false;
};
} else {
dayz_inside = false;
};
//sun
if(daytime > _sunrise && daytime < (24 - _sunrise) && !_raining && overcast <= 0.6 && !_isinbuilding) then {
/*Mathematic Basic
t = temperature effect
a = calcfactor
f = sunfactor
s = sunrise
d = daytime
I: a = f / (12 - s)<29>
II: t = -a * (d - 12)<29> + f
I + II =>
t = -(f / (12 - s)<29>) * (d - 12)<29> + f
Parabel with highest Point( greatest Effect == _sun_factor) always at 12.00
Zero Points are always at sunrise and sunset -> Only Positiv Values Possible
*/
_difference = _difference + (-((_sun_factor / (12 - _sunrise)^2)) * ((daytime - 12)^2) + _sun_factor);
};
//NEGATIVE EFFECTS
//water
if(surfaceIsWater getPosATL player || dayz_isSwimming) then {
_difference = _difference + _water_factor;
};
//rain
if(_raining && !_isinvehicle && !_isinbuilding) then {
_difference = _difference + (rain * _rain_factor);
};
//night
private ["_daytime"];
if((daytime < _sunrise || daytime > (24 - _sunrise)) && !_isinvehicle) then {
_daytime = if(daytime < 12) then {daytime + 24} else {daytime};
if(_isinbuilding) then {
_difference = _difference + ((((_night_factor * -1) / (_sunrise^2)) * ((_daytime - 24)^2) + _night_factor)) / 2;
} else {
_difference = _difference + (((_night_factor * -1) / (_sunrise^2)) * ((_daytime - 24)^2) + _night_factor);
};
};
//wind
if(((wind select 0) > 4 || (wind select 1) > 4) && !_isinvehicle && !_isinbuilding ) then {
_difference = _difference + _wind_factor;
};
//height
if (!_isinvehicle && overcast >= 0.6) then {
_height_mod = ((getPosASL player select 2) / 100) / 2;
_difference = _difference - _height_mod;
};
//Calculate Change Value Basic Factor Looptime Correction Adjust Value to current used temperatur scala
_difference = _difference * SleepTemperatur / (60 / _looptime) * ((dayz_temperaturmax - dayz_temperaturmin) / 100);
//Change Temperatur Should be moved in a own Function to allow adding of Items which increase the Temp like "hot tea"
dayz_temperatur = (((dayz_temperatur + _difference) max dayz_temperaturmin) min dayz_temperaturmax);
//Add Shivering
// Percent when the Shivering will start
if(dayz_temperatur <= (0.125 * (dayz_temperaturmax - dayz_temperaturmin) + dayz_temperaturmin)) then {
//CamShake as linear Function Maximum reached when Temp is at temp minimum. First Entry = Max Value
_temp = 0.6 * (dayz_temperaturmin / dayz_temperatur );
addCamShake [_temp,(_looptime + 1),30]; //[0.5,looptime,6] -> Maximum is 25% of the Pain Effect
} else {
addCamShake [0,0,0]; //Not needed at the Moment, but will be necesarry for possible Items
};

View File

@@ -0,0 +1,100 @@
private ["_timeout","_isOnDeck","_isInLocation","_inVehicle","_bloodLow","_isHospital","_totalTimeout","_display","_ctrl1","_ctrl1Pos"];
disableSerialization;
if ((!r_player_handler1) and (r_handlerCount == 0)) then {
//Unconscious Meter
_totalTimeout = r_player_timeout;
4 cutRsc ["playerStatusWaiting", "PLAIN",0];
_display = uiNamespace getVariable 'DAYZ_GUI_waiting';
_ctrl1 = _display displayCtrl 1400;
_ctrl1Pos = ctrlPosition _ctrl1;
_timeout = 0;
r_handlerCount = r_handlerCount + 1;
r_player_handler1 = true;
player playAction "CanNotMove";
"dynamicBlur" ppEffectEnable true;"dynamicBlur" ppEffectAdjust [2]; "dynamicBlur" ppEffectCommit 0;
"colorCorrections" ppEffectEnable true;"colorCorrections" ppEffectEnable true;"colorCorrections" ppEffectAdjust [1, 1, 0, [1, 1, 1, 0.0], [1, 1, 1, 0.1], [1, 1, 1, 0.0]];"colorCorrections" ppEffectCommit 0;
0 fadeSound 0.05;
disableUserInput true;
//waitUntil{USEC_MotherInbox == ""};
//["MED001",0,"Unconscious"] call fnc_usec_recordEventClient;
diag_log "CLIENT: Unconscious...";
while {(r_player_unconscious)} do {
_ctrl1 ctrlSetPosition [(_ctrl1Pos select 0),(_ctrl1Pos select 1),(_ctrl1Pos select 2),((0.136829 * safezoneH) * (1 -(r_player_timeout / _totalTimeout)))];
_ctrl1 ctrlCommit 1;
playSound "heartbeat_1";
sleep 1;
_isOnDeck = false; //getPos player in LHA_Deck;
_isInLocation = false; //getPos player in LHA_Location;
_inVehicle = (vehicle player != player);
_bloodLow = ((r_player_blood/r_player_bloodTotal) < 0.5);
if ((surfaceIsWater (getPosASL player)) and !_isOnDeck and !_inVehicle) then {
player setpos [(getPosASL player select 0),(getPosASL player select 1),0.3];
};
if(_timeout == 0) then {
if (!r_player_dead and !_bloodLow and r_player_injured) then {
_timeout = 10;
//_animType = (USEC_WoundAnim select (floor(random (count USEC_WoundAnim))));
//player playActionNow _anim;
};
} else {
_timeout = _timeout - 1;
};
if (r_player_timeout > 0) then {
r_player_timeout = r_player_timeout - 1;
} else {
if ((!r_player_dead) and (!r_player_cardiac)) then {
nul = [] spawn fnc_usec_recoverUncons;
};
};
//Check if near field hospital
_isHospital = false; //(count( nearestObjects [player, ["USMC_WarfareBFieldhHospital"], 8]) > 0);
if (_isHospital or _isOnDeck or _isInLocation) then {
waitUntil {!(player getVariable ["NORRN_unit_dragged", false])};
cutText[localize "str_medical_healing", "PLAIN", 2];
sleep 5;
r_player_inpain = false;
r_player_dead = false;
r_player_injured = false;
r_player_cardiac = false;
//Give Blood
r_player_blood = r_player_bloodTotal;
player setVariable["USEC_lowBlood",false,true];
usecMorphine = [player,player];
publicVariable "usecMorphine";
player setVariable ["USEC_inPain", false, true];
usecBandage = [player,player];
publicVariable "usecBandage";
player setdamage 0;
{player setVariable[_x,false,true];} forEach USEC_woundHit;
player setVariable ["USEC_injured",false,true];
sleep 1;
r_player_handler = false;
nul = [] spawn fnc_usec_recoverUncons;
};
if (!(player getVariable ["NORRN_unconscious", true])) then {
nul = [] spawn fnc_usec_recoverUncons;
};
if(animationState player == "AmovPpneMstpSnonWnonDnon_healed") then {
nul = [] spawn fnc_usec_recoverUncons;
};
};
4 cutRsc ["default", "PLAIN",1];
diag_log "CLIENT: Conscious...";
disableUserInput false;
//waitUntil{USEC_MotherInbox == ""};
//["MED001",0,"Conscious"] call fnc_usec_recordEventClient;
if (!r_player_injured and ((r_player_blood/r_player_bloodTotal) >= 0.5)) then {
10 fadeSound 1;
"dynamicBlur" ppEffectAdjust [0]; "dynamicBlur" ppEffectCommit 5;
"colorCorrections" ppEffectAdjust [1, 1, 0, [1, 1, 1, 0.0], [1, 1, 1, 1], [1, 1, 1, 1]];"colorCorrections" ppEffectCommit 5;
};
r_handlerCount = r_handlerCount - 1;
};

View File

@@ -0,0 +1,31 @@
private ["_markerstr","_class","_name","_type","_position","_radiusA","_radiusB","_maptype","_config"];
if ("ItemMap_Debug" in items player) then {
// _world = toUpper(worldName);
_maptype = ["NameCityCapital","NameCity","NameVillage","NameLocal"];
_config = configFile >> "CfgWorlds" >> worldName >> "Names";
for "_i" from 0 to (count _config -1) do {
_class = _config select _i; //Returns a conif
_name = getText (_class >> "name");
_type = getText (_class >> "type");
_position = getArray (_class >> "position");
_radiusA = getNumber (_class >> "radiusA");
_radiusB = getNumber (_class >> "radiusB");
if (_type in _maptype) then {

View File

@@ -0,0 +1,14 @@
//[unit, selectionName, damage, source, projectile]
//will only run when local to the created object
//record any key hits to the required selection
private["_zed","_killer","_kills","_array","_type"];
_array = _this select 0;
_zed = _array select 0;
_killer = _array select 1;
_type = _this select 1;
if (local _zed) then {
_kills = _killer getVariable[_type,0];
_killer setVariable[_type,(_kills + 1),true];
};

View File

@@ -0,0 +1,31 @@
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 {
for "_x" from 1 to _qty do {
_animalbody addMagazine _rawfoodtype;
};
[time, _animalbody] spawn {
private ["_timer", "_body"];
_timer = _this select 0;
_body = _this select 1;
while {(count magazines _body >0) and (time - _timer < 300) } do {
sleep 5;
};
//["dayzHideBody",_body] call broadcastRpcCallAll;
dayzHideBody = _body;
hideBody _body; // local player
publicVariable "dayzHideBody"; // remote player
sleep 5;
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

@@ -0,0 +1,30 @@
private ["_zombiebody","_ehLoc"];
_zombiebody = _this select 0;
// _qty = _this select 1;
if (local _zombiebody) then {
_zombiebody addMagazine "ItemZombieParts";
[time, _zombiebody] spawn {
private ["_timer", "_body"];
_timer = _this select 0;
_body = _this select 1;
while {(count magazines _body >0) and (time - _timer < 300) } do {
sleep 5;
};
//["dayzHideBody",_body] call broadcastRpcCallAll;
dayzHideBody = _body;
hideBody _body; // local player
publicVariable "dayzHideBody"; // remote player
sleep 5;
deleteVehicle _body;
// Give small humanity increase after body is removed
[player,1] call player_humanityChange;
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

@@ -0,0 +1,11 @@
private ["_vehicle","_status"];
_vehicle = _this select 0;
_status = _this select 1;
if (local _vehicle) then {
if(_status) then {
_vehicle setVehicleLock "LOCKED";
} else {
_vehicle setVehicleLock "UNLOCKED";
};
};

View File

@@ -0,0 +1,5 @@
private["_qty","_vehicle"];
_vehicle = _this select 0;
_qty = _this select 1;
_vehicle setFuel _qty;

View File

@@ -0,0 +1,57 @@
private ["_currentObjects","_currentTypes","_currentQty","_previousTypes","_previousQty","_serial","_itemVal","_itemQty","_oldSerial","_oldQty","_change","_checkObjects"];
//_newObjects = [_previous,weapons player] call player_weaponCheck;
_currentObjects = _this select 0;
_checkObjects = _this select 1;
_change = false;
if (count _currentObjects > 1) then {
_currentTypes = _currentObjects select 0;
_currentQty = _currentObjects select 1;
} else {
_currentTypes = [];
_currentQty = [];
};
if (count _checkObjects > 1) then {
_previousTypes = _checkObjects select 0;
_previousQty = _checkObjects select 1;
} else {
_previousTypes = [];
_previousQty = [];
};
//Check if some of old loadout not there
//Review current loadout
_serial = 0;
{
_itemVal = _x;
_itemQty = _currentQty select _serial;
_oldSerial = _previousTypes find _itemVal;
_oldQty = 0;
if (_oldSerial >= 0) then {
_oldQty = _previousQty select _oldSerial;
};
if (_itemQty != _oldQty) then {_change = true};
_serial = _serial + 1;
} forEach _currentTypes;
//Review old loadout
_serial = 0;
{
_itemVal = _x;
_itemQty = _previousQty select _serial;
_oldSerial = _currentTypes find _itemVal;
_oldQty = 0;
if (_oldSerial >= 0) then {
_oldQty = _currentQty select _oldSerial;
};
if (_itemQty != _oldQty) then {_change = true};
_serial = _serial + 1;
} forEach _previousTypes;
_change

View File

@@ -0,0 +1,9 @@
private["_type","_tent","_pos"];
_type = _this select 0;
_pos = _this select 1;
_tent = nearestObject [_type,_pos];
if (!isNull _tent) then {
if (local _tent) then {deleteVehicle _tent};
};

View File

@@ -0,0 +1,7 @@
private["_unit","_hp","_selection","_strH","_dam"];
_unit = _this select 0;
_hp = _this select 1;
_selection = getText (configFile >> "CfgVehicles" >> (typeOf _unit) >> "HitPoints" >> _hp >> "name");
_strH = "hit_" + (_selection);
_dam = _unit getVariable [_strH,0];
_dam

View File

@@ -0,0 +1,88 @@
private["_countMagazines","_countWeapons","_countBackpacks","_countFreeSlots","_getControlText","_setControlText","_object","_objectName","_controlText","_magazinesMax","_weaponsMax","_backpacksMax","_distance","_isVehicle","_isMan","_isStorage","_isOK","_magazines","_weapons","_backpacks","_freeSlots","_timeout"];
_countWeapons = {
private["_weapons","_return"];
_weapons = [];
_return = 0;
_weapons = (getWeaponCargo _object) select 1;
{ _return = _return + _x } foreach _weapons;
_return;
};
_countMagazines = {
private["_magazines","_return"];
_magazines = [];
_return = 0;
_magazines = (getMagazineCargo _object) select 1;
{ _return = _return + _x } foreach _magazines;
_return;
};
_countBackpacks = {
private["_backpacks","_return"];
_backpacks = [];
_return = 0;
_backpacks = (getBackpackCargo _object) select 1;
{ _return = _return + _x } foreach _backpacks;
_return;
};
_countFreeSlots = {
private["_return"];
_return = [(_weaponsMax - _weapons), (_magazinesMax - _magazines), (_backpacksMax - _backpacks)];
_return;
};
_getControlText = {
private["_control","_return"];
disableSerialization;
_control = (findDisplay 106) displayCtrl 156;
_return = ctrlText _control;
_return;
};
_setControlText = {
private["_control"];
disableSerialization;
_control = (findDisplay 106) displayCtrl 156;
_control ctrlSetText format["%1 (%2/%3/%4)", _objectName, _freeSlots select 0, _freeSlots select 1, _freeSlots select 2];
};
if (vehicle player != player) then {
_object = vehicle player;
} else {
_object = cursorTarget;
};
_isVehicle = _object isKindOf "AllVehicles";
_isMan = _object isKindOf "Man";
_isStorage = _object isKindOf "Land_A_tent";
_timeout = time + 2;
waitUntil { !(isNull (findDisplay 106)) or (_timeout < time) };
//diag_log format["object_monitorGear.sqf: _object: %1 _isStorage: %4 _isVehicle: %2 _isMan: %3 _display: %5", _object, _isVehicle, _isMan, _isStorage, findDisplay 106];
if ((_isVehicle or _isStorage) and (!_isMan) and (!(isNull (findDisplay 106)))) then {
_objectName = getText (configFile >> "CfgVehicles" >> (typeof _object) >> "displayName");
_controlText = [] call _getControlText;
if (_objectName == _controlText) then {
_weaponsMax = getNumber (configFile >> "CfgVehicles" >> (typeof _object) >> "transportMaxWeapons");
_magazinesMax = getNumber (configFile >> "CfgVehicles" >> (typeof _object) >> "transportMaxMagazines");
_backpacksMax = getNumber (configFile >> "CfgVehicles" >> (typeof _object) >> "transportMaxBackpacks");
while {!(isNull (findDisplay 106))} do {
_weapons = [] call _countWeapons;
_magazines = [] call _countMagazines;
_backpacks = [] call _countBackpacks;
_freeSlots = [] call _countFreeSlots;
[] call _setControlText;
sleep 0.01;
};
};
};

View File

@@ -0,0 +1,38 @@
private ["_unit","_selection","_strH","_dam","_display","_id","_break","_ctrlFracture","_total","_damage"];
disableSerialization;
_unit = _this select 0;
_selection = _this select 1;
_damage = _this select 2;
_strH = "hit_" + (_selection);
if (local _unit) then {
_dam = _unit getVariable [_strH,0];
_total = (_dam + _damage);
_unit setVariable [_strH,_total,true];
_break = false;
if (_selection in USEC_MinorWounds and _total >= 1 and _unit == player) then {
_display = uiNamespace getVariable 'DAYZ_GUI_display';
_ctrlFracture = _display displayCtrl 1203;
if ((_selection == "legs") and !r_fracture_legs) then {
r_fracture_legs = true;
_ctrlFracture ctrlShow true;
_id = [] spawn {
player setHit["legs",1];
};
_break = true;
};
if ((_selection == "arms") and !r_fracture_arms) then {
r_fracture_arms = true;
_ctrlFracture ctrlShow true;
_id = [] spawn {
player setHit["hands",1];
};
_break = true;
};
};
if (_break) then {
[player,"fracture",0,false] call dayz_zombieSpeak;
};
};

View File

@@ -0,0 +1,43 @@
private ["_flare","_lightArea","_lightSpark","_type","_color"];
_flare = _this select 0;
_type = _this select 1;
//_sfx = objNull;
if (!isNull _flare) then {
switch (_type) do {
case 0: {
//_isLocal = local _flare;
//Area Light
_lightArea = "#lightpoint" createVehicleLocal (getPosATL _flare);
_lightArea setLightColor [0.5,0,0]; //[0.1,0.005,0.005];
_lightArea setLightAmbient [0.2,0.01,0.01];
_lightArea setLightBrightness 0.2;
_lightArea lightAttachObject [_flare, [0,0,0]];
//Spark Light
_lightSpark = "#lightpoint" createVehicleLocal (getPosATL _flare);
_lightSpark setLightColor [0.1,0.1,0.1];
_lightSpark setLightAmbient [0.05,0.05,0.05];
_lightSpark setLightBrightness 0.05;
_lightSpark lightAttachObject [_flare, [0,0,0]];
while {alive _flare} do {
_lightArea setLightAmbient [((random 0.2) + 0.2),0.01,0.01];
//_lightArea setLightColor [((random 0.1) + 0.1),0.005,0.005];
sleep (random 0.1);
};
deleteVehicle _lightArea;
deleteVehicle _lightSpark;
};
case 1: {
//Spark Light
_color = getArray(configFile >> "cfgAmmo" >> (typeOf _flare) >> "lightColor");
_lightSpark = "#lightpoint" createVehicleLocal (getPosATL _flare);
_lightSpark setLightColor _color;
_lightSpark setLightAmbient _color;
_lightSpark setLightBrightness 0.01;
_lightSpark lightAttachObject [_flare, [0,0,0]];
waitUntil{!(alive _flare)};
deleteVehicle _lightSpark;
};
};
};

View File

@@ -0,0 +1,26 @@
private ["_unit","_selection","_strH","_damage"];
_unit = _this select 0;
_selection = _this select 1;
_damage = _this select 2;
if (_selection != "" and local _unit) then {
_strH = "hit_" + (_selection);
_unit setHit[_selection,_damage];
//player sidechat str _damage;
_unit setVariable [_strH,_damage,true];
if (_damage == 0) then {
if (isServer) then {
[_unit,"repair"] call server_updateObject
} else {
dayzUpdateVehicle = [_unit,"repair"];
publicVariableServer "dayzUpdateVehicle";
};
} else {
if (isServer) then {
[_unit,"damage"] call server_updateObject
} else {
dayzUpdateVehicle = [_unit,"damage"];
publicVariableServer "dayzUpdateVehicle";
};
};
};

View File

@@ -0,0 +1,13 @@
private ["_unit","_selection","_strH","_dam"];
_unit = _this select 0;
_selection = _this select 1;
_damage = _this select 2;
if (_selection != "") then {
_strH = "hit_" + (_selection);
_dam = _unit getVariable [_strH,0];
_unit setVariable [_strH,(_dam + _damage)];
if (_selection in USEC_MinorWounds) then {
_unit setHit[_selection,(_dam + _damage)];
};
};
_damage;

View File

@@ -0,0 +1,16 @@
private ["_unit","_selection","_strH","_dam","_total"];
_unit = _this select 0;
_selection = _this select 1;
_damage = _this select 2;
if ((_selection != "")) then {
_strH = "hit_" + (_selection);
_dam = _unit getVariable [_strH,0];
_total = (_dam + _damage);
if (_total > 1) then {
_total = 1;
};
_unit setVariable [_strH,_total];
} else {
_damage = 0;
};
_damage;

View File

@@ -0,0 +1,23 @@
private["_unit","_selection","_damage","_strH","_dam","_total"];
_unit = _this select 0;
_selection = _this select 1;
_damage = _this select 2;
if ((_selection != "") and local _unit) then {
_strH = "hit_" + (_selection);
_dam = _unit getVariable [_strH,0];
_total = (_dam + _damage);
if (_total > 1) then {
_total = 1;
};
_unit setVariable [_strH,_total,true];
if (_damage >= 1) then {
//["dayzUpdateVehicle",[_unit,"damage"]] call callRpcProcedure;
dayzUpdateVehicle = [_unit,"damage"];
publicVariableServer "dayzUpdateVehicle";
};
} else {
_damage = 0;
};
_damage

View File

@@ -0,0 +1,51 @@
private ["_unit","_type","_chance","_rnd","_sound","_local","_dis","_num","_isWoman"];
_unit = _this select 0;
_type = _this select 1;
_chance = _this select 2;
_num = switch (_type) do {
default {0};
case "cough": {2};
case "chase": {14};
case "spotted": {13};
case "hit": {6};
case "attack": {13};
case "idle": {35};
case "scream": {4};
case "fracture": {1};
case "eat": {3};
case "cook": {2};
case "panic": {1};
case "dog_bark": {4};
case "dog_growl": {3};
case "dog_qq": {2};
};
if (count _this > 4) then {
_dis = _this select 4;
_local = ({isPlayer _x} count (_unit nearEntities ["AllVehicles",_dis]) < 2);
} else {
_local = _this select 3;
if (_type in ["shout","hit","attack","scream","breath","spotted"]) then {
_dis = 100;
} else {
_dis = 40;
};
};
_isWoman = getText(configFile >> "cfgVehicles" >> (typeOf _unit) >> "TextPlural") == "Women";
if (_isWoman and (_type in ["scream","panic"])) then {
_type = _type + "_w";
};
if ((round(random _chance) == _chance) or (_chance == 0)) then {
_rnd =(round(random _num));
_sound = "z_" + _type + "_" + str(_rnd);
if (_local) then {
_unit say [_sound, _dis];
} else {
[nil,_unit,rSAY,[_sound, _dis]] call RE;
};
};

View File

@@ -0,0 +1,10 @@
private["_object","_updateObj"];
//check if can pitch here
_object = _this;
if (_object getVariable ["ObjectID",0] > 0) then {
_updateObj = _object getVariable["update",[false,false,false]];
_updateObj set [1,true];
_object setVariable ["update",_updateObj,true];
_object setVariable ["position",(getPosATL _object),true];
};

View File

@@ -0,0 +1,9 @@
private ["_unit"];
_unit = _this select 0;
//_killer = _this select 1;
//_type = typeOf _unit;
//_pos = getposATL _unit;
//_dir = direction _unit;
if (local _unit) then {
deleteVehicle _unit;
};

View File

@@ -0,0 +1,30 @@
private ["_unit","_distance","_listTalk","_zombie","_targets","_pos","_doRun"];
//Alert Zed's to noise of shot
_unit = _this select 0;
_distance = _this select 1;
_doRun = _this select 2;
_pos = _this select 3;
_listTalk = _pos nearEntities ["zZombie_Base",_distance/2];
if ("ItemMap_Debug" in items player) then {
diag_log ("alertzeds Unit: " +str(_unit));
diag_log ("alertzeds Distance: " +str(_distance/2));
diag_log ("alertzeds DoRun: " +str(_doRun));
diag_log ("alertzeds Pos: " +str(_pos));
diag_log ("alertzeds ListTalk: " +str(_listTalk));
};
//hint str(_listTalk);
{
_zombie = _x;
if (_doRun) then {
_targets = _zombie getVariable ["targets",[]];
if (!(_unit in _targets)) then {
_targets set [count _targets,_unit];
_zombie setVariable ["targets",_targets,true];
};
} else {
_zombie setVariable ["myDest",_pos,true];
};
} forEach _listTalk;

View File

@@ -0,0 +1,47 @@
private ["_list","_animalssupported","_type","_root","_favouritezones","_randrefpoint","_PosList","_PosSelect","_Pos","_agent","_id"];
_list = getposATL player nearEntities [["CAAnimalBase"],dayz_animalDistance];
if (count _list < dayz_maxAnimals) then {
//Find where animal likes
_animalssupported = ["Chicken","Cow","Sheep","WildBoar","WildBoar","WildBoar","Goat","Rabbit","Rabbit","Dog"];
_type = (_animalssupported select floor(random(count _animalssupported)));
if (_type == "Cow") then {
_animalssupported = ["Cow01","Cow02","Cow03","Cow04","Cow01_EP1"];
_type = (_animalssupported select floor(random(count _animalssupported)));
};
if (_type == "Goat") then {
_animalssupported = ["Goat01_EP1","Goat02_EP1","Goat"];
_type = (_animalssupported select floor(random(count _animalssupported)));
};
if (_type == "Sheep") then {
_animalssupported = ["Sheep","Sheep02_EP1","Sheep01_EP1"];
_type = (_animalssupported select floor(random(count _animalssupported)));
};
if (_type == "Chicken") then {
_animalssupported = ["Hen","Cock"];
_type = (_animalssupported select floor(random(count _animalssupported)));
};
if (_type == "Dog") then {
_animalssupported = ["DZ_Fin","DZ_Pastor"];
_type = (_animalssupported select floor(random(count _animalssupported)));
};
_root = configFile >> "CfgVehicles" >> _type;
_favouritezones = getText ( _root >> "favouritezones");
//_randrefpoint = [position player, 10, dayz_animalDistance, 1, 0, 50, 0] call BIS_fnc_findSafePos;
_randrefpoint = getposATL player;
_PosList = selectbestplaces [_randrefpoint,dayz_animalDistance,_favouritezones,10,5];
_PosSelect = _PosList select (floor random (count _PosList));
_Pos = _PosSelect select 0;
_list = _Pos nearEntities [["CAAnimalBase","Man"],50];
if (player distance _Pos < dayz_animalDistance and NOT surfaceIsWater _Pos and (count _list <= 1)) then {
if (_type == "DZ_Pastor") then { _agent = createAgent [_type, _Pos, [], 0, "NONE"]; } else { _agent = createAgent [_type, _Pos, [], 0, "FORM"]; };
_agent setpos _Pos;
_id = [_pos,_agent] execFSM "\z\addons\dayz_code\system\animal_agent.fsm";
};
sleep 1;
};

View File

@@ -0,0 +1,153 @@
private ["_vel","_speed","_pos","_scalePose","_scaleMvmt","_scaleLight","_anim","_anim4","_initial","_scaleSound","_nearFlare","_scaler","_nearLight","_nearFire","_building","_isPlayerInside","_audial","_isWater","_isPZombie"];
_vel = velocity (vehicle player);
_speed = (_vel distance [0,0,0]);
_pos = getPosATL player;
_scalePose = 0.9;
_scaleMvmt = 0.2; //0.4;
_scaleLight = 0.5;
// _scaleAlert = 1;
_isPZombie = player isKindOf "PZombie_VB";
if(_isPZombie) exitWith { DAYZ_disAudial = 0; DAYZ_disVisual = 0; };
//Assess Players Position
_anim = animationState player;
_anim4 = toArray _anim;
_anim4 resize 4;
_anim4 = toString _anim4;
dayz_isKneeling = false;
dayz_isCrawling = false;
if (["pknl",_anim] call fnc_inString) then {
_scaleMvmt = 0.2; //0.1;
_scalePose = 0.6; //0.4
dayz_isKneeling = true;
} else {
if (["ppne",_anim] call fnc_inString) then {
_scaleMvmt = 0.3;
_scalePose = 0.14;
dayz_isCrawling = true;
};
};
if (_anim4 == "aswm") then {
_scaleMvmt = 0.3;
dayz_isSwimming = true;
// if surface is not water abort
_isWater = surfaceIsWater _pos;
if(!_isWater) then {
// Stops swimming in ground
if (vehicle player == player) then {
[objNull, player, rSwitchMove,""] call RE;
player playActionNow "stop";
};
// This sleep was much needed
sleep 5;
dayz_isSwimming = false;
};
} else {
dayz_isSwimming = false;
};
_initial = 20 + (sunOrMoon * 20);
_scaleLight = (
(sunOrMoon * 2) //add sunlight
+ moonIntensity //add moonlight
- (overcast * 0.2) //remove for cloud state
- (rain * 0.2) //remove for rain state
- (fog * 0.5)); //remove for fog state
dayz_scaleLight = _scaleLight;
_scaleSound = (1
- (rain * 0.3) //remove for rain state
//+ (fog * 0.3) //add for fog state
)
max 0;
if (_scaleLight < 0.9) then {
//Assess if near lightsource
_nearFlare = nearestObject [(vehicle player),"RoadFlare"];
if (!isNull _nearFlare) then {
_scaler = (_nearFlare distance (vehicle player));
if (_scaler <= 30) then {
_scaler = 30 - _scaler;
_scaleLight = ((_scaler / 30) * 2) + _scaleLight;
};
};
_nearLight = nearestObject [(vehicle player),"StreetLamp"];
//if (!isNull _nearLight && (lightIsOn _nearLight == "ON")) then {
if (!isNull _nearLight) then {
_scaler = 50 - (_nearLight distance (vehicle player));
_scaleLight = ((_scaler / 50) * 2) + _scaleLight;
};
_nearFire = nearestObject [(vehicle player),"Land_Fire"];
if (!isNull _nearFire) then {
_scaler = 50 - (_nearFire distance (vehicle player));
_scaleLight = ((_scaler / 50) * 2) + _scaleLight;
};
};
//Ensure zero or above
_scaleLight = _scaleLight max 0;
//Terrain Visibility
if (["grass",dayz_surfaceType] call fnc_inString) then {
_initial = _initial * 0.75;
_scaleMvmt = _scaleMvmt - 0.05;
} else {
if (["forest",dayz_surfaceType] call fnc_inString) then {
_initial = _initial * 0.5;
_scaleMvmt = _scaleMvmt - 0.1;
} else {
if (["concrete",dayz_surfaceType] call fnc_inString) then {
_initial = _initial * 1.2;
_scaleMvmt = _scaleMvmt + 0.1;
} else {
if (["rock",dayz_surfaceType] call fnc_inString) then {
_initial = _initial * 1.1;
_scaleMvmt = _scaleMvmt + 0.05;
};
};
};
};
if (isOnRoad _pos) then {
_initial = _initial * 1.3;
_scaleMvmt = _scaleMvmt + 0.2;
//dayz_surfaceNoise = dayz_surfaceNoise + 10;
};
/*
if (_speed > 5) then {
_speed = _speed * 1;
} else {
if (_speed > 3) then {
_speed = _speed * 0.7;
} else {
_speed = _speed * 0.3;
};
};
*/
//Are they inside a building
_building = nearestObject [(vehicle player), "Building"];
_isPlayerInside = [(vehicle player),_building] call fnc_isInsideBuilding;
if (_isPlayerInside) then {
_initial = 5;
};
//Work out result
_audial = round(_speed * dayz_surfaceNoise * _scaleMvmt * _scaleSound);
if ((_audial > DAYZ_disAudial) or ((time - dayz_firedCooldown) > 0.3)) then {
DAYZ_disAudial = _audial;
};
DAYZ_disVisual = (round((_initial + (_speed * 3)) * _scalePose * _scaleLight)) * 1.5;

View File

@@ -0,0 +1,61 @@
private ["_unit","_ammo","_distance","_weapon","_projectile","_vUp","_endPos","_dir","_height","_bolt","_hitArray","_hitObject","_hitSelection","_config","_hitMemoryPt","_variation","_val","_doLoop","_countr","_magazine"];
_unit = _this select 0;
_weapon = _this select 1;
_ammo = _this select 4;
_magazine = _this select 5;
_projectile = _this select 6;
_projectile = nearestObject [_unit, _ammo];
_vUp = vectorUp _projectile;
_endPos = getPosATL _projectile;
_dir = 0;
if (_magazine == "Quiver") then {
_ammo = player ammo "Crossbow_DZ";
if (_ammo > 0) then {
player removeMagazines "Quiver";
player addMagazine ["Quiver", _ammo];
};
};
while {alive _projectile} do {
_endPos = getPosATL _projectile;
_vUp = vectorUp _projectile;
sleep 0.01;
};
_distance = _unit distance _endPos;
_height = _endPos select 2;
_doLoop = true;
_countr = 0;
if (_height < 100) then {
_bolt = createVehicle ["WoodenArrowF", _endPos, [], 0, "CAN_COLLIDE"];
_bolt setPosATL _endPos;
_bolt setDir (getDir _unit);
_bolt setVectorUp _vUp;
_hitArray = _unit getVariable["firedHit",[]];
while {_doLoop} do {
_hitArray = _unit getVariable["firedHit",[]];
if (count _hitArray > 0) then {_doLoop = false};
if (_countr > 50) then {_doLoop = false};
_countr = _countr + 1;
sleep 0.1;
};
if (count _hitArray > 0) then {
_hitObject = _hitArray select 0;
_hitSelection = _hitArray select 1;
_config = configFile >> "cfgBody" >> _hitSelection;
_hitMemoryPt = getText(_config >> "memoryPoint");
_variation = getNumber(_config >> "variation");
_val = [((random (_variation * 2)) - _variation),((random (_variation * 2)) - _variation),((random (_variation * 2)) - _variation)];
_bolt attachTo [_hitObject,_val,_hitMemoryPt];
_dir = ([_hitObject,_unit] call BIS_fnc_relativeDirTo) + 180;
_bolt setDir (_dir);
_bolt setPos (getPos _bolt);
_unit setVariable["firedHit",[]];
_unit setVariable["firedDamage",0,true];
};
};

View File

@@ -0,0 +1,136 @@
private ["_array","_source","_kills","_killsV","_humanity","_wait","_myKills","_infected","_canHitFree","_myHumanity","_method","_body","_playerID","_id","_myGroup"];
if (deathHandled) exitWith {};
deathHandled = true;
//Death
_body = player;
_playerID = getPlayerUID player;
_infected = 0;
if (r_player_infected) then {
_infected = 1;
};
//Send Death Notice
//["dayzDeath",[dayz_characterID,0,_body,_playerID,dayz_playerName,_infected]] call callRpcProcedure;
dayzDeath = [dayz_characterID,0,_body,_playerID,dayz_playerName,_infected];
publicVariableServer "dayzDeath";
_id = [player,20,true,getPosATL player] spawn player_alertZombies;
sleep 0.5;
player setDamage 1;
0.1 fadeSound 0;
player setVariable ["NORRN_unconscious", false, true];
player setVariable ["unconsciousTime", 0, true];
player setVariable ["USEC_isCardiac",false,true];
player setVariable ["medForceUpdate",true,true];
//remove combat timer on death
player setVariable ["startcombattimer", 0, true];
r_player_unconscious = false;
r_player_cardiac = false;
_id = player spawn spawn_flies;
_humanity = 0;
_wait = 0;
_array = _this;
if (count _array > 0) then {
_source = _array select 0;
_method = _array select 1;
if (!isNull _source) then {
if (_source != player) then {
_canHitFree = player getVariable ["freeTarget",false];
_myHumanity = ((player getVariable ["humanity",0]) / 10);
_myKills = ((player getVariable ["humanKills",0]) / 5) * (1000 - _myHumanity);
if (!_canHitFree) then {
//Process Morality Hit
_humanity = -(2000 - _myKills);
_kills = _source getVariable ["humanKills",0];
_source setVariable ["humanKills",(_kills + 1),true];
_wait = 300;
} else {
//Process Morality Hit
//_humanity = _myKills * 100;
_killsV = _source getVariable ["banditKills",0];
_source setVariable ["banditKills",(_killsV + 1),true];
_wait = 0;
};
if (_humanity < 0) then {
_wait = 0;
};
if (!_canHitFree) then {
//["dayzHumanity",[_source,_humanity,_wait]] call broadcastRpcCallAll;
dayzHumanity = [_source,_humanity,_wait];
publicVariable "dayzHumanity";
};
};
};
_body setVariable ["deathType",_method,true];
};
terminate dayz_musicH;
terminate dayz_lootCheck;
terminate dayz_slowCheck;
terminate dayz_animalCheck;
terminate dayz_monitor1;
terminate dayz_medicalH;
terminate dayz_gui;
terminate dayz_zedCheck;
terminate dayz_locationCheck;
terminate dayz_combatCheck;
terminate dayz_friendliesCheck;
//Reset (just in case)
//deleteVehicle dayz_playerTrigger;
disableUserInput false;
r_player_dead = true;
"dynamicBlur" ppEffectEnable true;"dynamicBlur" ppEffectAdjust [4]; "dynamicBlur" ppEffectCommit 0.2;
"colorCorrections" ppEffectEnable true;
"colorCorrections" ppEffectAdjust [1, 1, 0, [1, 1, 1, 0.0], [1, 1, 1, 0.01], [1, 1, 1, 0.0]];
"colorCorrections" ppEffectCommit 1;
//Player is Dead!
3 fadeSound 0;
0 cutText ["", "BLACK",10];
dayz_DeathActioned = true;
sleep 1;
TitleText[localize "str_player_12","PLAIN DOWN",5];
dayz_originalPlayer enableSimulation true;
addSwitchableUnit dayz_originalPlayer;
setPlayable dayz_originalPlayer;
selectPlayer dayz_originalPlayer;
_myGroup = group _body;
[_body] joinSilent dayz_firstGroup;
deleteGroup _myGroup;
3 cutRsc ["default", "PLAIN",3];
4 cutRsc ["default", "PLAIN",3];
if (count _array > 0) then {
_body setVariable ["deathType",_method,true];
};
_body setVariable["combattimeout", 0, true];
//["dayzFlies",player] call broadcastRpcCallAll;
sleep 2;
1 cutRsc ["DeathScreen","BLACK OUT",3];
playMusic "dayz_track_death_1";
"dynamicBlur" ppEffectAdjust [0]; "dynamicBlur" ppEffectCommit 5;
"colorCorrections" ppEffectAdjust [1, 1, 0, [1, 1, 1, 0.0], [1, 1, 1, 1], [1, 1, 1, 1]];"colorCorrections" ppEffectCommit 5;

View File

@@ -0,0 +1,13 @@
private ["_weapons","_magazines","_weaponscnt","_magazinescnt","_backpack"];
_backpack = nearestObject [player, "Bag_Base_EP1"];
if (!(isNull _backpack) and local _backpack) then {
_weapons = getWeaponCargo _backpack;
_magazines = getMagazineCargo _backpack;
_weaponscnt = count (_weapons select 0);
_magazinescnt = count (_magazines select 0);
if((_magazinescnt > 0) or (_weaponscnt > 0)) then {
// hide backpack from everyone else
dayzHideObject = _backpack;
publicVariable "dayzHideObject";
};
};

View File

@@ -0,0 +1,68 @@
private ["_unit","_ammo","_audible","_distance","_listTalk","_weapon","_group","_targets","_i","_projectile","_id","_caliber"];
//[unit, weapon, muzzle, mode, ammo, magazine, projectile]
_unit = _this select 0;
_weapon = _this select 1;
_ammo = _this select 4;
_projectile = _this select 6;
//Alert Nearby
_audible = getNumber (configFile >> "CfgAmmo" >> _ammo >> "audibleFire");
_caliber = getNumber (configFile >> "CfgAmmo" >> _ammo >> "caliber");
_distance = round(_audible * 10 * _caliber);
dayz_disAudial = _distance;
dayz_firedCooldown = time;
// Color in the combat icon
dayz_combat = 1;
if (_ammo isKindOf "Melee") exitWith {
_unit playActionNow "GestureSwing";
};
//Smoke Grenade
if (_ammo isKindOf "SmokeShell") then {
//Alert Zed's to smoke
_i = 0;
_projectile = nearestObject [_unit, _ammo];
_listTalk = (getPosATL _projectile) nearEntities ["zZombie_Base",50];
{
_group = group _x;
if (isNull group _x) then {
_group = _x;
};
_x reveal [_projectile,4];
_targets = _group getVariable ["targets",[]];
if (!(_projectile in _targets)) then {
_targets set [count _targets,_projectile];
_group setVariable ["targets",_targets,true];
};
_i = _i + 1;
} forEach _listTalk;
} else {
[_unit,_distance,true,(getPosATL player)] spawn player_alertZombies;
//Check if need to place arrow
if (_ammo isKindOf "Bolt") then {
_id = _this spawn player_crossbowBolt;
};
if (_ammo isKindOf "GrenadeHand") then {
if (_ammo isKindOf "ThrownObjects") then {
_id = _this spawn player_throwObject;
};
if (_ammo isKindOf "RoadFlare") then {
//hint str(_ammo);
_projectile = nearestObject [_unit, "RoadFlare"];
_id = [_projectile,0] spawn object_roadFlare;
dayzRoadFlare = [_projectile,0];
publicVariable "dayzRoadFlare";
_id = _this spawn player_throwObject;
};
if (_ammo isKindOf "ChemLight") then {
_projectile = nearestObject [_unit, "ChemLight"];
_id = [_projectile,1] spawn object_roadFlare;
dayzRoadFlare = [_projectile,1];
publicVariable "dayzRoadFlare";
_id = _this spawn player_throwObject;
};
};
};

View File

@@ -0,0 +1,104 @@
private ["_charID","_friendlies","_rcharID","_rfriendlyTo","_tag","_player","_newTagList","_position","_rfriendlies","_tagList","_statusNew","_tagColor","_humanity","_status","_everyone"];
_charID = player getVariable ["characterID", "0"];
_friendlies = player getVariable ["friendlies", []];
_everyone = player getVariable ["everyone", []];
_tagList = player getVariable ["tagList", []];
// create tags
{
if (isPlayer _x and player != _x) then {
_rcharID = _x getVariable ["characterID", "0"];
if(!(_rcharID in _everyone)) then {
// Track who has tags
_everyone set [count _everyone, _rcharID];
player setVariable ["everyone", _everyone];
// Add sphere to everyone
_position = [0,0,0];
_tag = "Sign_sphere10cm_EP1" createVehicleLocal _position;
_tag attachTo [_x,[0,0,0],"lwrist"];
_tag setVariable ["belongsTo", _rcharID];
// Force white
// _tag setobjecttexture [0,"#(argb,8,8,3)color(1,1,1,0.5,ca)"];
diag_log format["SETUP ORB FOR: %1", _x];
// Maintenance array
_tagList set [count _tagList, [_x, _tag,"init"]];
player setVariable ["tagList", _tagList];
};
};
} forEach playableUnits;
// keep track of tags created
_newTagList = [];
{
_player = _x select 0;
_tag = _x select 1;
_status = _x select 2;
_statusNew = "white";
_tagColor = "";
// _tagColor = "#(argb,8,8,3)color(1,1,1,0.5,ca)";
// friendly player disconnected
if (!(isPlayer _player)) then {
deleteVehicle _tag;
} else {
if (_status != "green") then {
//diag_log format["CHECK IF FRIENDLY: %1", _player];
_rcharID = _player getVariable ["characterID", "0"];
_rfriendlies = _player getVariable ["friendlies", []];
_rfriendlyTo = _player getVariable ["friendlyTo", []];
if ((_rcharID in _friendlies) and (_charID in _rfriendlies)) then {
if (!(_charID in _rfriendlyTo)) then {
// diag_log format["IS FRIENDLY: %1", _player];
_rfriendlyTo set [count _rfriendlyTo, _charID];
_player setVariable ["friendlyTo", _rfriendlyTo, true];
titleText [format["You and %1 are now tagged as friendlies.", (name _player)], "PLAIN DOWN"];
_statusNew = "green";
_tagColor = "#(argb,8,8,3)color(0,1,0,0.5,ca)";
// light green #(argb,8,8,3)color(0.04,0.86,0.1,0.5,ca)
};
} else {
// Get humanity
_humanity = _player getVariable ["humanity",0];
if(_humanity < -2000) then {
_statusNew = "red";
_tagColor = "#(argb,8,8,3)color(1,0,0,0.5,ca)";
} else {
if(_humanity > 5000) then {
_statusNew = "blue";
_tagColor = "#(argb,8,8,3)color(0,0,1,0.5,ca)";
};
};
// diag_log format["CHECK HUMANITY: %1 %2", _player, _humanity];
};
if(_statusNew != _status) then {
diag_log format["STATUS CHANGED: %1 != %2", _statusNew, _status];
// Set texture based on humanity or friendship status
_tag setobjecttexture [0,_tagColor];
_status = _statusNew;
};
};
// diag_log format["CHECK STATUS: %1 != %2", _statusNew, _status];
_newTagList set [count _newTagList, [_player, _tag, _status]];
};
} forEach _tagList;
player setVariable ["tagList", _newTagList];

View File

@@ -0,0 +1,44 @@
private ["_inventory","_wpns","_mags","_idc","_isOK"];
_inventory = _this;
if (count _inventory > 0) then {
_wpns = _inventory select 0;
_mags = _inventory select 1;
//Add inventory
{
private["_item","_val"];
//is it an array?
_idc = 109;
if (typeName _x == "ARRAY") then {
_item = _x select 0;
_val = _x select 1;
} else {
_item = _x;
_val = -1;
};
if (_item == "BoltSteel") then { _item = "WoodenArrow" }; // Convert BoltSteel to WoodenArrow
//Is item legal?
_isOK = isClass(configFile >> "CfgMagazines" >> _item);
if (_isOK) then {
if (_val != -1) then {
player addMagazine [_item,_val];
} else {
player addMagazine _item;
};
};
_idc = _idc + 1;
} forEach _mags;
//Add weapons
{
if (_x == "Crossbow") then { _x = "Crossbow_DZ" }; // Convert Crossbow to Crossbow_DZ
//Is item legal?
_isOK = isClass(configFile >> "CfgWeapons" >> _x);
if (_isOK) then {
player addWeapon _x;
};
} forEach _wpns;
};

View File

@@ -0,0 +1,49 @@
private ["_objects"];
_objects = nearestObjects [getPosATL player, dayz_updateObjects, 10];
{
//["dayzUpdateVehicle",[_x,"gear"]] call callRpcProcedure;
dayzUpdateVehicle = [_x,"gear"];
publicVariableServer "dayzUpdateVehicle";
} foreach _objects;
private["_dialog","_magazineArray","_control","_item","_val","_max"];
disableSerialization;
_dialog = _this select 0;
_magazineArray = [];
//Primary Mags
for "_i" from 109 to 120 do
{
_control = _dialog displayCtrl _i;
_item = gearSlotData _control;
_val = gearSlotAmmoCount _control;
_max = getNumber (configFile >> "CfgMagazines" >> _item >> "count");
if (_item != "") then {
if (_item == "BoltSteel") then { _item = "WoodenArrow" };
if (_val != _max) then {
_magazineArray set [count _magazineArray,[_item,_val]];
} else {
_magazineArray set [count _magazineArray,_item];
};
};
};
//Secondary Mags
for "_i" from 122 to 129 do
{
_control = _dialog displayCtrl _i;
_item = gearSlotData _control;
_val = gearSlotAmmoCount _control;
_max = getNumber (configFile >> "CfgMagazines" >> _item >> "count");
if (_item != "") then {
if (_val != _max) then {
_magazineArray set [count _magazineArray,[_item,_val]];
} else {
_magazineArray set [count _magazineArray,_item];
};
};
};
dayz_unsaved = true;
dayz_Magazines = _magazineArray;

View File

@@ -0,0 +1,24 @@
private ["_object","_change","_humanity","_wait"];
//Set Variables
_object = _this select 0;
_change = _this select 1;
_humanity = 0;
if (_object == player) then {
_humanity = player getVariable["humanity",0];
_humanity = _humanity + _change;
if (_change < 0) then {
_wait = _this select 2;
player setVariable["humanity",_humanity,true];
if (player getVariable ["freeTarget",false]) then {
waitUntil{!(player getVariable ["freeTarget",false])};
};
player setVariable ["freeTarget",true,true];
//_timeStart = time;
sleep _wait;
player setVariable ["freeTarget",false,true];
} else {
player setVariable["humanity",_humanity,true];
};
};

View File

@@ -0,0 +1,94 @@
private ["_updates","_playerUID","_charID","_humanity","_worldspace","_model","_friendlies","_fractures","_old","_medical","_zombieKills","_headShots","_humanKills","_banditKills","_tagList"];
_playerUID = _this select 0;
_charID = _this select 1;
_model = _this select 2;
_old = player;
player allowDamage false;
player removeEventHandler ["FiredNear",eh_player_killed];
player removeEventHandler ["HandleDamage",mydamage_eh1];
player removeEventHandler ["Killed",mydamage_eh3];
player removeEventHandler ["Fired",mydamage_eh2];
_updates = player getVariable["updatePlayer",[false,false,false,false,false]];
_updates set [0,true];
player setVariable["updatePlayer",_updates,true];
dayz_unsaved = true;
//Logout
_humanity = player getVariable["humanity",0];
_medical = player call player_sumMedical;
_worldspace = [round(direction player),getPosATL player];
_zombieKills = player getVariable ["zombieKills",0];
_headShots = player getVariable ["headShots",0];
_humanKills = player getVariable ["humanKills",0];
_banditKills = player getVariable ["banditKills",0];
_friendlies = player getVariable ["friendlies",[]];
_tagList = player getVariable ["tagList",[]];
//Switch
_model call player_switchModel;
//Login
//set medical values
if (count _medical > 0) then {
player setVariable["USEC_isDead",(_medical select 0),true];
player setVariable["NORRN_unconscious", (_medical select 1), true];
player setVariable["USEC_infected",(_medical select 2),true];
player setVariable["USEC_injured",(_medical select 3),true];
player setVariable["USEC_inPain",(_medical select 4),true];
player setVariable["USEC_isCardiac",(_medical select 5),true];
player setVariable["USEC_lowBlood",(_medical select 6),true];
player setVariable["USEC_BloodQty",(_medical select 7),true];
player setVariable["unconsciousTime",(_medical select 10),true];
//Add Wounds
{
player setVariable[_x,true,true];
//["usecBleed",[player,_x,_hit]] call broadcastRpcCallAll;
usecBleed = [player,_x,0];
publicVariable "usecBleed";
} forEach (_medical select 8);
//Add fractures
_fractures = (_medical select 9);
// player setVariable ["hit_legs",(_fractures select 0),true];
// player setVariable ["hit_hands",(_fractures select 1),true];
[player,"legs", (_fractures select 0)] call object_setHit;
[player,"hands", (_fractures select 1)] call object_setHit;
} else {
//Reset Fractures
player setVariable ["hit_legs",0,true];
player setVariable ["hit_hands",0,true];
player setVariable ["USEC_injured",false,true];
player setVariable ["USEC_inPain",false,true];
};
//General Stats
player setVariable["humanity",_humanity,true];
player setVariable["zombieKills",_zombieKills,true];
player setVariable["headShots",_headShots,true];
player setVariable["humanKills",_humanKills,true];
player setVariable["banditKills",_banditKills,true];
player setVariable["characterID",_charID,true];
player setVariable["worldspace",_worldspace,true];
player setVariable["friendlies",_friendlies,true];
player setVariable["tagList",_tagList,true];
//code for this on the server is missing
//["dayzPlayerMorph",[_charID,player,_playerUID,[_zombieKills,_headShots,_humanKills,_banditKills],_humanity]] call callRpcProcedure;
call dayz_resetSelfActions;
eh_player_killed = player addeventhandler ["FiredNear",{_this call player_weaponFiredNear;} ];
[player] call fnc_usec_damageHandle;
player allowDamage true;
player addWeapon "Loot";
player addWeapon "Flare";
sleep 0.1;
deleteVehicle _old;

View File

@@ -0,0 +1,81 @@
/*
DayZ Lock Safe
Usage: [_obj] spawn player_unlockVault;
Made for DayZ Epoch please ask permission to use/edit/distrubute email vbawol@veteranbastards.com.
*/
private ["_objectID","_objectUID","_obj","_ownerID","_dir","_pos","_holder","_weapons","_magazines","_backpacks","_alreadyPacking"];
if(TradeInprogress) exitWith { cutText ["Lock already in progress." , "PLAIN DOWN"]; };
TradeInprogress = true;
_obj = _this;
// Silently exit if object no longer exists
if(isNull _obj) exitWith { TradeInprogress = false; };
// Test cannot lock while another player is nearby
_playerNear = {isPlayer _x} count (player nearEntities ["CAManBase", 12]) > 1;
if(_playerNear) exitWith { TradeInprogress = false; cutText ["Cannot lock vault while another player is nearby." , "PLAIN DOWN"]; };
_ownerID = _obj getVariable["CharacterID","0"];
_objectID = _obj getVariable["ObjectID","0"];
_objectUID = _obj getVariable["ObjectUID","0"];
player playActionNow "Medic";
player removeAction s_player_lockvault;
s_player_lockvault = 1;
if((_ownerID != dayz_combination) and (_ownerID != dayz_playerUID)) exitWith {TradeInprogress = false; s_player_lockvault = -1; cutText ["You cannot lock this Safe, you do not know the combination", "PLAIN DOWN"]; };
_alreadyPacking = _obj getVariable["packing",0];
if (_alreadyPacking == 1) exitWith {TradeInprogress = false; s_player_lockvault = -1; cutText ["That Safe is already being locked." , "PLAIN DOWN"]};
_obj setVariable["packing",1];
_dir = direction _obj;
// _pos = getposATL _obj;
_pos = _obj getVariable["OEMPos",(getposATL _obj)];
[player,"tentpack",0,false] call dayz_zombieSpeak;
sleep 3;
if(!isNull _obj) then {
// force vault save just before locking
dayzUpdateVehicle = [_obj,"gear"];
publicVariableServer "dayzUpdateVehicle";
//place tent (local)
_holder = createVehicle ["VaultStorageLocked",_pos,[], 0, "CAN_COLLIDE"];
_holder setdir _dir;
_holder setpos _pos;
player reveal _holder;
_holder setVariable["CharacterID",_ownerID,true];
_holder setVariable["ObjectID",_objectID,true];
_holder setVariable["ObjectUID",_objectUID,true];
_holder setVariable ["OEMPos", _pos, true];
_weapons = getWeaponCargo _obj;
_magazines = getMagazineCargo _obj;
_backpacks = getBackpackCargo _obj;
// remove vault
deleteVehicle _obj;
// Fill variables with loot
if (count _weapons > 0) then {
_holder setVariable ["WeaponCargo", _weapons, true];
};
if (count _magazines > 0) then {
_holder setVariable ["MagazineCargo", _magazines, true];
};
if (count _backpacks > 0) then {
_holder setVariable ["BackpackCargo", _backpacks, true];
};
cutText ["Your Safe has been locked", "PLAIN DOWN"];
s_player_lockvault = -1;
};
TradeInprogress = false;

View File

@@ -0,0 +1,6 @@
private ["_unit","_detail"];
_unit = _this select 0;
_detail = _this select 1;
if(_unit == getPlayerUID player) then {
player setVariable["publish",_detail];
};

View File

@@ -0,0 +1,11 @@
private ["_sound","_num","_length","_pause"];
while {!r_player_dead} do {
_num = round(random 35);
_sound = "z_suspense_" + str(_num);
_length = getNumber(configFile >> "cfgMusic" >> _sound >> "Duration");
_pause = ((random 5) + 2) + _length;
if (!r_player_unconscious and !r_pitchWhine) then {
playMusic _sound;
};
sleep _pause;
};

View File

@@ -0,0 +1,51 @@
private ["_display","_btnRespawn","_btnAbort","_timeOut","_timeMax"];
disableSerialization;
waitUntil {
_display = findDisplay 49;
!isNull _display;
};
_btnRespawn = _display displayCtrl 1010;
_btnAbort = _display displayCtrl 104;
_btnRespawn ctrlEnable false;
_btnAbort ctrlEnable false;
_timeOut = 0;
_timeMax = 30;
dayz_lastCheckBit = time;
if(r_player_dead) exitWith {_btnAbort ctrlEnable true;};
if(r_fracture_legs) exitWith {_btnRespawn ctrlEnable true; _btnAbort ctrlEnable true;};
//force gear save
if (time - dayz_lastCheckBit > 10) then {
call dayz_forceSave;
};
while {!isNull _display} do {
switch true do {
case ({isPlayer _x} count (player nearEntities ["AllVehicles", 6]) > 1) : {
_btnAbort ctrlEnable false;
cutText [localize "str_abort_playerclose", "PLAIN DOWN"];
};
case (_timeOut < _timeMax && count (player nearEntities ["zZombie_Base", 35]) > 0) : {
_btnAbort ctrlEnable false;
cutText [format ["Can Abort in %1", (_timeMax - _timeOut)], "PLAIN DOWN"];
//cutText [format[localize "str_abort_zedsclose",_text, "PLAIN DOWN"];
};
case (!canbuild) : {
_btnAbort ctrlEnable false;
cutText ["Cannot Abort while in a trader city!", "PLAIN DOWN"];
};
case (player getVariable["combattimeout", 0] >= time) : {
_btnAbort ctrlEnable false;
//cutText ["Cannot Abort while in combat!", "PLAIN DOWN"];
cutText [localize "str_abort_playerincombat", "PLAIN DOWN"];
};
default {
_btnAbort ctrlEnable true;
cutText ["", "PLAIN DOWN"];
};
};
sleep 1;
_timeOut = _timeOut + 1;
};
cutText ["", "PLAIN DOWN"];

View File

@@ -0,0 +1,90 @@
/*
[_obj] spawn player_packTent;
*/
private ["_objectID","_objectUID","_obj","_ownerID","_dir","_pos","_object","_holder","_weapons","_magazines","_backpacks","_objWpnTypes","_objWpnQty","_countr","_alreadyPacking","_dis","_sfx","_classname","_location"];
if(TradeInprogress) exitWith { cutText ["Pack tent already in progress." , "PLAIN DOWN"]; };
TradeInprogress = true;
_obj = _this;
_ownerID = _obj getVariable["CharacterID","0"];
_objectID = _obj getVariable["ObjectID","0"];
_objectUID = _obj getVariable["ObjectUID","0"];
player playActionNow "Medic";
player removeAction s_player_packtent;
s_player_packtent = 1;
if(_ownerID != dayz_characterID) exitWith {TradeInprogress = false; s_player_packtent = -1; cutText [localize "str_fail_tent_pack", "PLAIN DOWN"];};
_alreadyPacking = _obj getVariable["packing",0];
if (_alreadyPacking == 1) exitWith {TradeInprogress = false; s_player_packtent = -1; cutText [format[(localize "str_player_beingpacked")] , "PLAIN DOWN"]};
_obj setVariable["packing",1];
_dir = direction _obj;
_pos = getposATL _obj;
_dis=20;
_sfx = "tentpack";
[player,_sfx,0,false,_dis] call dayz_zombieSpeak;
[player,_dis,true,(getPosATL player)] spawn player_alertZombies;
sleep 3;
_classname = getText (configFile >> "CfgVehicles" >> (typeOf _obj) >> "create");
_location = _pos;
//place tent (local)
//_bag = createVehicle ["WeaponHolder_ItemTent",_pos,[], 0, "CAN_COLLIDE"];
_object = createVehicle [_classname, _location, [], 0, "CAN_COLLIDE"];
_object setdir _dir;
player reveal _object;
_holder = "WeaponHolder" createVehicle _pos;
_weapons = getWeaponCargo _obj;
_magazines = getMagazineCargo _obj;
_backpacks = getBackpackCargo _obj;
//["dayzDeleteObj",[_objectID,_objectUID]] call callRpcProcedure;
dayzDeleteObj = [_objectID,_objectUID];
publicVariableServer "dayzDeleteObj";
if (isServer) then {
dayzDeleteObj call server_deleteObj;
};
deleteVehicle _obj;
//Add weapons
_objWpnTypes = _weapons select 0;
_objWpnQty = _weapons select 1;
_countr = 0;
{
_holder addweaponcargoGlobal [_x,(_objWpnQty select _countr)];
_countr = _countr + 1;
} forEach _objWpnTypes;
//Add Magazines
_objWpnTypes = _magazines select 0;
_objWpnQty = _magazines select 1;
_countr = 0;
{
_holder addmagazinecargoGlobal [_x,(_objWpnQty select _countr)];
_countr = _countr + 1;
} forEach _objWpnTypes;
//Add Backpacks
_objWpnTypes = _backpacks select 0;
_objWpnQty = _backpacks select 1;
_countr = 0;
{
_holder addbackpackcargoGlobal [_x,(_objWpnQty select _countr)];
_countr = _countr + 1;
} forEach _objWpnTypes;
cutText [localize "str_success_tent_pack", "PLAIN DOWN"];
s_player_packtent = -1;
TradeInprogress = false;

View File

@@ -0,0 +1,105 @@
/*
[_obj] spawn player_packVault;
*/
private["_obj","_ownerID","_objectID","_objectUID","_alreadyPacking","_location1","_location2","_dir","_pos","_bag","_holder","_weapons","_magazines","_backpacks","_objWpnTypes","_objWpnQty","_countr"];
if(TradeInprogress) exitWith { cutText ["That Safe is already being packed." , "PLAIN DOWN"]; };
TradeInprogress = true;
_obj = _this;
// Silently exit if object no longer exists
if(isNull _obj or !(alive _obj)) exitWith { TradeInprogress = false; };
// Test cannot lock while another player is nearby
_playerNear = {isPlayer _x} count (player nearEntities ["CAManBase", 12]) > 1;
if(_playerNear) exitWith { TradeInprogress = false; cutText ["Cannot pack vault while another player is nearby." , "PLAIN DOWN"]; };
_ownerID = _obj getVariable["CharacterID","0"];
_objectID = _obj getVariable["ObjectID","0"];
_objectUID = _obj getVariable["ObjectUID","0"];
player removeAction s_player_packvault;
s_player_packvault = 1;
if((_ownerID != dayz_combination) and (_ownerID != dayz_playerUID)) exitWith { TradeInprogress = false; s_player_packvault = -1; cutText ["You cannot pack this Safe, you do not know the combination.", "PLAIN DOWN"];};
_alreadyPacking = _obj getVariable["packing",0];
if (_alreadyPacking == 1) exitWith {TradeInprogress = false; s_player_packvault = -1; cutText ["That Safe is already being packed." , "PLAIN DOWN"]};
_obj setVariable["packing",1];
cutText ["Packing Safe move from this position to cancel within 5 seconds.", "PLAIN DOWN"];
sleep 1;
_location1 = getPosATL player;
sleep 5;
_location2 = getPosATL player;
if(_location1 distance _location2 > 0.1) exitWith {
cutText ["Packing Safe canceled." , "PLAIN DOWN"];
_obj setVariable["packing",0];
};
_dir = direction _obj;
_pos = _obj getVariable["OEMPos",(getposATL _obj)];
if(!isNull _obj and alive _obj) then {
player playActionNow "Medic";
[player,"tentpack",0,false] call dayz_zombieSpeak;
sleep 3;
_weapons = getWeaponCargo _obj;
_magazines = getMagazineCargo _obj;
_backpacks = getBackpackCargo _obj;
// Remove from database
dayzDeleteObj = [_objectID,_objectUID];
publicVariableServer "dayzDeleteObj";
// Set down vault "take" item
_bag = createVehicle ["WeaponHolder_ItemVault",_pos,[], 0, "CAN_COLLIDE"];
// Delete original
deleteVehicle _obj;
_bag setdir _dir;
_bag setpos _pos;
player reveal _bag;
// Empty weapon holder
_holder = "WeaponHolder" createVehicle _pos;
//Add weapons
_objWpnTypes = _weapons select 0;
_objWpnQty = _weapons select 1;
_countr = 0;
{
_holder addweaponcargoGlobal [_x,(_objWpnQty select _countr)];
_countr = _countr + 1;
} forEach _objWpnTypes;
//Add Magazines
_objWpnTypes = _magazines select 0;
_objWpnQty = _magazines select 1;
_countr = 0;
{
_holder addmagazinecargoGlobal [_x,(_objWpnQty select _countr)];
_countr = _countr + 1;
} forEach _objWpnTypes;
//Add Backpacks
_objWpnTypes = _backpacks select 0;
_objWpnQty = _backpacks select 1;
_countr = 0;
{
_holder addbackpackcargoGlobal [_x,(_objWpnQty select _countr)];
_countr = _countr + 1;
} forEach _objWpnTypes;
cutText ["Your Safe has been packed", "PLAIN DOWN"];
s_player_packvault = -1;
};
TradeInprogress = false;

View File

@@ -0,0 +1,51 @@
private ["_unit","_projectile","_isInCombat","_currentNear","_projectilespeed","_projectflight","_listNear","_callCount","_nearVehicle"];
_unit = _this select 0;
_projectile = _this select 6;
diag_log ("0");
//_isInComat = _unit getVariable["startcombattimer",0];
diag_log ("Bullit Speed: " +str(Speed _projectile));
diag_log ("Bullit Velocity: " +str(velocity _projectile));
_listNear = [];
_callCount = 0;
//approx 1020 meters
while {(alive _projectile) && !(isNull _projectile) && _callCount < 85;} do {
_projectilespeed = Speed _projectile;
_projectflight = (((_projectilespeed / 60) * 1000));
if (_projectflight > 0) then {
sleep (12 / (_projectflight));
};
if (alive _projectile && !(isNull _projectile)) then {_currentNear = (Position _projectile) nearEntities [["CAManBase","AllVehicles"],15];};
_listNear = _listNear + _currentNear;
_callCount = _callCount + 1;
};
diag_log ("2");
{
_nearVehicle = _x;
_listNear = _listNear - [_x];
diag_log ("3");
if (isPlayer _nearVehicle) then {
_isInCombat = _nearVehicle getVariable["startcombattimer",0];
if ((alive _nearVehicle) and _isInCombat == 0) then {
_nearVehicle setVariable["startcombattimer", 1, true];
diag_log("Now in Combat (Player): " + name _unit);
};
};
if (_nearVehicle isKindOf "AllVehicles") then {
{
_isInCombat = _x getVariable["startcombattimer",0];
if (isPlayer _x and _isInCombat == 0 and alive _x) then {
_x setVariable["startcombattimer", 1, true];
diag_log("Now in Combat (Crew): " + name _x);
};
} forEach (crew _nearVehicle);
};
} forEach _listNear;

View File

@@ -0,0 +1,167 @@
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"];
_type = _this select 0;
//_Keepspawning = _this select 1;
_isAir = vehicle player iskindof "Air";
_inVehicle = (vehicle player != player);
_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;
};
};
*/
_players = _position nearEntities ["CAManBase",_radius+200];
dayz_maxGlobalZombies = dayz_maxGlobalZombiesInit;
{
if(isPlayer _x) then {
dayz_maxGlobalZombies = dayz_maxGlobalZombies + dayz_maxGlobalZombiesIncrease;
};
} 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";
deleteMarkerLocal "Loot30";
deleteMarkerLocal "Loot120";
deleteMarkerLocal "Agro80";
_markerstr = createMarkerLocal ["MaxZeds", _position];
_markerstr setMarkerColorLocal "ColorYellow";
_markerstr setMarkerShapeLocal "ELLIPSE";
_markerstr setMarkerBrushLocal "Border";
_markerstr setMarkerSizeLocal [_radius, _radius];
_markerstr1 = createMarkerLocal ["Counter", _position];
_markerstr1 setMarkerColorLocal "ColorRed";
_markerstr1 setMarkerShapeLocal "ELLIPSE";
_markerstr1 setMarkerBrushLocal "Border";
_markerstr1 setMarkerSizeLocal [_radius+100, _radius+100];
_markerstr2 = createMarkerLocal ["Agro80", _position];
_markerstr2 setMarkerColorLocal "ColorRed";
_markerstr2 setMarkerShapeLocal "ELLIPSE";
_markerstr2 setMarkerBrushLocal "Border";
_markerstr2 setMarkerSizeLocal [80, 80];
_markerstr2 = createMarkerLocal ["Loot30", _position];
_markerstr2 setMarkerColorLocal "ColorRed";
_markerstr2 setMarkerShapeLocal "ELLIPSE";
_markerstr2 setMarkerBrushLocal "Border";
_markerstr2 setMarkerSizeLocal [30, 30];
_markerstr3 = createMarkerLocal ["Loot120", _position];
_markerstr3 setMarkerColorLocal "ColorBlue";
_markerstr3 setMarkerShapeLocal "ELLIPSE";
_markerstr3 setMarkerBrushLocal "Border";
_markerstr3 setMarkerSizeLocal [120, 120];
diag_log ("SpawnWait: " +str(time - dayz_spawnWait));
diag_log ("LocalZombies: " +str(dayz_spawnZombies) + "/" +str(dayz_maxLocalZombies));
diag_log ("GlobalZombies: " +str(dayz_CurrentZombies) + "/" +str(dayz_maxGlobalZombies));
diag_log ("dayz_maxCurrentZeds: " +str(dayz_maxCurrentZeds) + "/" +str(dayz_maxZeds));
};
_nearby = _position nearObjects ["building",_radius];
_nearbyCount = count _nearby;
if (_nearbyCount < 1) exitwith
{
if ((dayz_spawnZombies < _maxWildZombies) and !_inVehicle) then {
[_position] call wild_spawnZombies;
};
};
{
_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 ((_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;
};
} else {
dayz_spawnWait = time;
};
};
};
};
} forEach _nearby;

View File

@@ -0,0 +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};
};

View File

@@ -0,0 +1,19 @@
private ["_dateNow","_age","_zombied","_x"];
//_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;
//_maxZombies = _this select 7;
_zombied = (_x getVariable ["zombieSpawn",-0.1]);
_dateNow = (DateToNumber date);
_age = (_dateNow - _zombied) * 525948;
if (_age > 1) then {
_x setVariable ["zombieSpawn",_dateNow,true];
[_x] call building_spawnZombies;
};

View File

@@ -0,0 +1,206 @@
private ["_class","_position","_dir","_group","_oldUnit","_newUnit","_currentWpn","_muzzles","_currentAnim","_playerUID","_weapons","_magazines","_primweapon","_secweapon","_newBackpackType","_backpackWpn","_backpackMag","_backpackWpnTypes","_backpackWpnQtys","_countr","_backpackmagTypes","_backpackmagQtys","_playerObjName"];
_class = _this;
_position = getPosATL player;
_dir = getDir player;
_currentAnim = animationState player;
//_currentCamera = cameraView;
//Get PlayerID
private ["_playerUID"];
_playerUID = "";
if (count playableUnits == 0 and isServer) then {
//In Single Player
isSinglePlayer = true;
player sidechat "Single player Mode detected!";
//_id = [42,"SinglePlayer"] spawn server_onPlayerConnect;
_playerUID = "42";
} else {
_playerUID = getPlayerUID player;
};
//BackUp Weapons and Mags
private ["_weapons","_magazines","_primweapon","_secweapon"];
_weapons = weapons player;
_magazines = call player_countmagazines; //magazines player;
if ( (_playerUID == dayz_playerUID) && (count _magazines == 0) && (count (magazines player) > 0 )) exitWith {cutText ["can't count magazines!", "PLAIN DOWN"]};
// if ( count _magazines == 0 ) exitWith {cutText ["can't count magazines!", "PLAIN DOWN"]};
_primweapon = primaryWeapon player;
_secweapon = secondaryWeapon player;
//Checks
if(!(_primweapon in _weapons) && _primweapon != "") then {
_weapons = _weapons + [_primweapon];
};
if(!(_secweapon in _weapons) && _secweapon != "") then {
_weapons = _weapons + [_secweapon];
};
// if(count _magazines == 0) then {
// _magazines = magazines player;
// };
//BackUp Backpack
private ["_newBackpackType","_backpackWpn","_backpackMag"];
dayz_myBackpack = unitBackpack player;
_newBackpackType = (typeOf dayz_myBackpack);
if(_newBackpackType != "") then {
_backpackWpn = getWeaponCargo unitBackpack player;
_backpackMag = getMagazineCargo unitBackpack player;
};
//Get Muzzle
_currentWpn = currentWeapon player;
_muzzles = getArray(configFile >> "cfgWeapons" >> _currentWpn >> "muzzles");
if (count _muzzles > 1) then {
_currentWpn = currentMuzzle player;
};
//Debug Message
diag_log "Attempting to switch model";
diag_log str(_weapons);
diag_log str(_magazines);
diag_log (str(_backpackWpn));
diag_log (str(_backpackMag));
//Secure Player for Transformation
player setPosATL dayz_spawnPos;
//BackUp Player Object
_oldUnit = player;
/***********************************/
//DONT USE player AFTER THIS POINT
/***********************************/
//Create New Character
//[player] joinSilent grpNull;
_group = createGroup west;
_newUnit = _group createUnit [_class,dayz_spawnPos,[],0,"NONE"];
_newUnit setPosATL _position;
_newUnit setDir _dir;
//Clear New Character
{_newUnit removeMagazine _x;} forEach magazines _newUnit;
removeAllWeapons _newUnit;
//Equip New Charactar
{
if (typeName _x == "ARRAY") then {_newUnit addMagazine [_x select 0,_x select 1] } else { _newUnit addMagazine _x };
//sleep 0.05;
} forEach _magazines;
{
_newUnit addWeapon _x;
//sleep 0.05;
} forEach _weapons;
//Check and Compare it
if(str(_weapons) != str(weapons _newUnit)) then {
//Get Differecnce
{
_weapons = _weapons - [_x];
} forEach (weapons _newUnit);
//Add the Missing
{
_newUnit addWeapon _x;
//sleep 0.2;
} forEach _weapons;
};
if(_primweapon != (primaryWeapon _newUnit)) then {
_newUnit addWeapon _primweapon;
};
if (_primweapon == "MeleeCrowbar") then {
_newUnit addMagazine 'crowbar_swing';
};
if (_primweapon == "MeleeHatchet") then {
_newUnit addMagazine 'hatchet_swing';
};
if (_primweapon == "MeleeMachete") then {
_newUnit addMagazine 'Machete_swing';
};
if (_primweapon == "MeleeFishingPole") then {
_newUnit addMagazine 'Fishing_Swing';
};
if(_secweapon != (secondaryWeapon _newUnit) && _secweapon != "") then {
_newUnit addWeapon _secweapon;
};
//Add and Fill BackPack
if (!isNil "_newBackpackType") then {
if (_newBackpackType != "") then {
_newUnit addBackpack _newBackpackType;
//_oldBackpack = dayz_myBackpack;
dayz_myBackpack = unitBackpack _newUnit;
//Fill backpack contents
//Weapons
_backpackWpnTypes = [];
_backpackWpnQtys = [];
if (count _backpackWpn > 0) then {
_backpackWpnTypes = _backpackWpn select 0;
_backpackWpnQtys = _backpackWpn select 1;
};
_countr = 0;
{
dayz_myBackpack addWeaponCargoGlobal [_x,(_backpackWpnQtys select _countr)];
_countr = _countr + 1;
} forEach _backpackWpnTypes;
//magazines
_backpackmagTypes = [];
_backpackmagQtys = [];
if (count _backpackmag > 0) then {
_backpackmagTypes = _backpackMag select 0;
_backpackmagQtys = _backpackMag select 1;
};
_countr = 0;
{
dayz_myBackpack addmagazineCargoGlobal [_x,(_backpackmagQtys select _countr)];
_countr = _countr + 1;
} forEach _backpackmagTypes;
};
};
//Debug Message
diag_log "Swichtable Unit Created. Equipment:";
diag_log str(weapons _newUnit);
diag_log str(magazines _newUnit);
diag_log str(getWeaponCargo unitBackpack _newUnit);
diag_log str(getMagazineCargo unitBackpack _newUnit);
//Make New Unit Playable
addSwitchableUnit _newUnit;
setPlayable _newUnit;
selectPlayer _newUnit;
//Clear and delete old Unit
removeAllWeapons _oldUnit;
{_oldUnit removeMagazine _x;} forEach magazines _oldUnit;
deleteVehicle _oldUnit;
//Move player inside
// player switchCamera = _currentCamera;
if(_currentWpn != "") then {_newUnit selectWeapon _currentWpn;};
[objNull, player, rSwitchMove,_currentAnim] call RE;
//dayz_originalPlayer attachTo [_newUnit];
player disableConversation true;
player setVariable ["bodyName",dayz_playerName,true];
_playerUID=getPlayerUID player;
_playerObjName = format["player%1",_playerUID];
call compile format["%1 = player;",_playerObjName];
publicVariable _playerObjName;

View File

@@ -0,0 +1,24 @@
private ["_target","_id","_pos","_dog","_fsmid","_hasRawMeat","_hasdog"];
_target = _this select 0;
//_caller = _this select 1;
_id = _this select 2;
//_params = _this select 3;
_pos = position _target;
_hasRawMeat = "FoodSteakRaw" in magazines player;
_hasdog = player getVariable ["dogid", "false"];
if ((_hasRawMeat) && (_hasdog == "false")) then {
player removeMagazine "FoodSteakRaw";
deleteVehicle (_this select 0);
_dog = (group player) createUnit [typeOf _target, _pos, [], 0, "FORM"];
_dog disableAI "FSM";
_fsmid = [_dog, typeOf _target] execFSM "\z\addons\dayz_code\system\dog_agent.fsm";
_fsmid setFSMVariable ["_handle", _fsmid];
_target removeAction _id;
player setvariable ["dogid", _fsmid];
} else {
cutText ["You must have RawMeat", "PLAIN DOWN"];
};
//handle publicVariables here later.

View File

@@ -0,0 +1,42 @@
#define WHITE [1,1,1,1]
#define GREY [0.75,0.75,0.75,1]
#define GREEN [0.6,0.8,0.4,1]
#define RED [1,0.1,0,1]
private["_task", "_taskDescription", "_taskStatus", "_taskParams"];
_task = _this select 0;
_taskDescription = (taskDescription _task) select 1;
_taskStatus = toUpper(taskState _task);
_taskParams = switch (_taskStatus) do
{
case "CREATED":
{
[format["NEW TASK ASSIGNED: \n%1", _taskDescription], WHITE, "taskNew"]
};
case "ASSIGNED":
{
[format["ASSIGNED TASK: \n%1", _taskDescription], WHITE, "taskCurrent"]
};
case "SUCCEEDED":
{
[format["TASK ACCOMPLISHED: \n%1", _taskDescription], GREEN, "taskDone"]
};
case "FAILED":
{
[format["TASK FAILED: \n%1", _taskDescription], RED, "taskFAILED"]
};
case "CANCELED":
{
[format["TASK CANCELED: \n%1", _taskDescription], GREY, "taskDone"]
};
};
taskHint _taskParams;

View File

@@ -0,0 +1,33 @@
private ["_unit","_ammo","_distance","_weapon","_projectile","_endPos","_dir","_doWait","_vel"];
_unit = _this select 0;
_weapon = _this select 1;
_ammo = _this select 4;
_projectile = _this select 6;
_projectile = nearestObject [_unit, _ammo];
_endPos = getPosATL _projectile;
_dir = 0;
_doWait = true;
while {_doWait} do {
_vel = (velocity _projectile) distance [0,0,0];
if (!(alive _projectile)) then {_doWait = false};
if (_vel < 0.1) then {_doWait = false};
_endPos = getPosATL _projectile;
sleep 0.01;
};
_distance = parseNumber format["%1",(getArray (configFile >> "CfgAmmo" >> _ammo >> "soundHit") select 3)];
if (_ammo isKindOf "ChemLight") then {
_distance = 10;
};
if (_ammo isKindOf "RoadFlare") then {
if (call world_isDay) then {
_distance = 30;
} else {
_distance = 60;
};
};
[_unit,_distance,false,_endPos] spawn player_alertZombies;

View File

@@ -0,0 +1,126 @@
/*
DayZ Lock Safe
Usage: [_obj] spawn player_unlockVault;
Made for DayZ Epoch please ask permission to use/edit/distrubute email vbawol@veteranbastards.com.
*/
private ["_objectID","_objectUID","_obj","_ownerID","_dir","_pos","_holder","_weapons","_magazines","_backpacks","_objWpnTypes","_objWpnQty","_countr","_alreadyPacking"];
if(TradeInprogress) exitWith { cutText ["Unlock already in progress." , "PLAIN DOWN"]; };
TradeInprogress = true;
// Test cannot lock while another player is nearby
_playerNear = {isPlayer _x} count (player nearEntities ["CAManBase", 6]) > 1;
if(_playerNear) exitWith { TradeInprogress = false; cutText ["Cannot unlock vault while another player is nearby." , "PLAIN DOWN"]; };
_obj = _this;
_alreadyPacking = _obj getVariable["packing",0];
_claimedBy = _obj getVariable["claimed","0"];
{player removeAction _x} forEach s_player_combi;s_player_combi = [];
s_player_unlockvault = 1;
// Silently exit if object no longer exists or alive
if(isNull _obj or !(alive _obj)) exitWith { TradeInprogress = false; };
_ownerID = _obj getVariable["CharacterID","0"];
if (_alreadyPacking == 1) exitWith {TradeInprogress = false; cutText ["That Safe is already being unlocked." , "PLAIN DOWN"]};
// Promt user for password if _ownerID != dayz_playerUID
if ((_ownerID == dayz_combination) or (_ownerID == dayz_playerUID)) then {
// Check if any players are nearby if not allow player to claim item.
_playerNear = {isPlayer _x} count (player nearEntities ["CAManBase", 6]) > 1;
_playerID = getPlayerUID player;
// Only allow if not already claimed.
if (_claimedBy == "0" or !_playerNear) then {
// Since item was not claimed proceed with claiming it.
_obj setVariable["claimed",_playerID,true];
};
_dir = direction _obj;
_pos = _obj getVariable["OEMPos",(getposATL _obj)];
_objectID = _obj getVariable["ObjectID","0"];
_objectUID = _obj getVariable["ObjectUID","0"];
_claimedBy = _obj getVariable["claimed","0"];
if (_claimedBy == _playerID) then {
if(!isNull _obj and alive _obj) then {
_obj setVariable["packing",1];
_weapons = _obj getVariable["WeaponCargo",[]];
_magazines = _obj getVariable["MagazineCargo",[]];
_backpacks = _obj getVariable["BackpackCargo",[]];
player playActionNow "Medic";
sleep 1;
[player,"tentpack",0,false] call dayz_zombieSpeak;
sleep 5;
//place tent (local)
_holder = createVehicle ["VaultStorage",_pos,[], 0, "CAN_COLLIDE"];
// Remove locked vault
deleteVehicle _obj;
_holder setdir _dir;
_holder setpos _pos;
player reveal _holder;
_holder setVariable["CharacterID",_ownerID,true];
_holder setVariable["ObjectID",_objectID,true];
_holder setVariable["ObjectUID",_objectUID,true];
_holder setVariable ["OEMPos", _pos, true];
if (count _weapons > 0) then {
//Add weapons
_objWpnTypes = _weapons select 0;
_objWpnQty = _weapons select 1;
_countr = 0;
{
_holder addweaponcargoGlobal [_x,(_objWpnQty select _countr)];
_countr = _countr + 1;
} forEach _objWpnTypes;
};
if (count _magazines > 0) then {
//Add Magazines
_objWpnTypes = _magazines select 0;
_objWpnQty = _magazines select 1;
_countr = 0;
{
_holder addmagazinecargoGlobal [_x,(_objWpnQty select _countr)];
_countr = _countr + 1;
} forEach _objWpnTypes;
};
if (count _backpacks > 0) then {
//Add Backpacks
_objWpnTypes = _backpacks select 0;
_objWpnQty = _backpacks select 1;
_countr = 0;
{
_holder addbackpackcargoGlobal [_x,(_objWpnQty select _countr)];
_countr = _countr + 1;
} forEach _objWpnTypes;
};
cutText ["Safe has been unlocked.", "PLAIN DOWN"];
};
} else {
TradeInprogress = false;
cutText [format[(localize "str_player_beinglooted"),"Safe"] , "PLAIN DOWN"];
};
} else {
player playActionNow "Medic";
sleep 1;
[player,"repair",0,false] call dayz_zombieSpeak;
null = [player,25,true,(getPosATL player)] spawn player_alertZombies;
sleep 5;
cutText ["Combination incorrect, Safe is still locked.", "PLAIN DOWN"];
};
s_player_unlockvault = -1;
TradeInprogress = false;

View File

@@ -0,0 +1,158 @@
private ["_display","_ctrlBlood","_ctrlBleed","_bloodVal","_ctrlFood","_ctrlThirst","_thirstVal","_foodVal","_ctrlTemp","_tempVal","_combatVal","_array","_ctrlEar","_ctrlEye","_ctrlCombat","_ctrlFracture","_visualText","_visual","_audibleText","_audible","_blood","_thirstLvl","_foodLvl","_tempImg","_thirst","_food","_temp","_bloodLvl","_tempLvl"];
disableSerialization;
_foodVal = 1 - (dayz_hunger / SleepFood);
_thirstVal = 1 - (dayz_thirst / SleepWater);
_tempVal = 1 - ((dayz_temperatur - dayz_temperaturmin)/(dayz_temperaturmax - dayz_temperaturmin)); // Normalise to [0,1]
_combatVal = 1 - dayz_combat; // May change later to be a range of red/green to loosely indicate 'time left in combat'
if (uiNamespace getVariable ['DZ_displayUI', 0] == 1) exitWith {
_array = [_foodVal,_thirstVal];
_array
};
_display = uiNamespace getVariable 'DAYZ_GUI_display';
_ctrlBlood = _display displayCtrl 1300;
_ctrlBleed = _display displayCtrl 1303;
_bloodVal = r_player_blood / r_player_bloodTotal;
_ctrlFood = _display displayCtrl 1301;
_ctrlThirst = _display displayCtrl 1302;
_ctrlTemp = _display displayCtrl 1306; //TeeChange
_ctrlEar = _display displayCtrl 1304;
_ctrlEye = _display displayCtrl 1305;
//_ctrlHumanity = _display displayCtrl 1207;
_ctrlCombat = _display displayCtrl 1307;
_ctrlFracture = _display displayCtrl 1203;
//Food/Water/Blood
_ctrlBlood ctrlSetTextColor [(Dayz_GUI_R + (0.3 * (1-_bloodVal))),(Dayz_GUI_G * _bloodVal),(Dayz_GUI_B * _bloodVal), 0.5];
_ctrlFood ctrlSetTextColor [(Dayz_GUI_R + (0.3 * (1-_foodVal))),(Dayz_GUI_G * _foodVal),(Dayz_GUI_B * _foodVal), 0.5];
_ctrlThirst ctrlSetTextColor [(Dayz_GUI_R + (0.3 * (1-_thirstVal))),(Dayz_GUI_G * _thirstVal),(Dayz_GUI_B * _thirstVal), 0.5];
_ctrlTemp ctrlSetTextColor [(Dayz_GUI_R + (0.3 * (1-_tempVal))), (Dayz_GUI_G * _tempVal), _tempVal, 0.5]; // Color ranges from iceblue (cold) to red (hot)
_ctrlCombat ctrlSetTextColor [(Dayz_GUI_R + (0.3 * (1-_combatVal))),(Dayz_GUI_G * _combatVal),(Dayz_GUI_B * _combatVal), 0.5];
/*
Blood: round((r_player_blood / 2) / 1000) = _bloodLvl (6 = full, 1 = empty)
Thirst: round(_thirstVal / 0.25) = _thirstLvl (4 = full, 0 = empty)
Hunger: round(_foodVal / 0.25) = _foodLvl (4 = full, 0 = empty)
Temp: round(dayz_temperatur) = tempLvl (>= 36 = full <= 28 = empty)
*/
_blood = "";
_thirst = "";
_food = "";
_temp = "";
_tempImg = 0;
_bloodLvl = round((r_player_blood / 2) / 1000);
_thirstLvl = round(_thirstVal / 0.25);
_foodLvl = round(_foodVal / 0.25);
_tempLvl = round(dayz_temperatur);
/*
diag_log format["DEBUG: bloodlvl: %1 r_player_blood: %2 bloodval: %3",_bloodLvl, r_player_blood, _bloodVal];
diag_log format["DEBUG: thirstlvl: %1 dayz_thirst: %2 thirstval: %3",_thirstLvl, dayz_thirst, _thirstVal];
diag_log format["DEBUG: foodlvl: %1 dayz_hunger: %2 foodval: %3",_foodLvl, dayz_hunger, _foodVal];
diag_log format["DEBUG: templvl: %1 dayz_temperatur: %2 tempval: %3",_tempLvl, dayz_temperatur, _tempVal];
*/
if (_bloodLvl <= 0) then {
_blood = "\z\addons\dayz_code\gui\status_blood_inside_1_ca.paa";
} else {
_blood = "\z\addons\dayz_code\gui\status_blood_inside_" + str(_bloodLvl) + "_ca.paa";
};
if (_thirstLvl < 0) then { _thirstLvl = 0 };
_thirst = "\z\addons\dayz_code\gui\status_thirst_inside_" + str(_thirstLvl) + "_ca.paa";
if (_foodLvl < 0) then { _foodLvl = 0 };
_food = "\z\addons\dayz_code\gui\status_food_inside_" + str(_foodLvl) + "_ca.paa";
if ( _tempLvl >= 36 ) then { _tempImg = 4 };
if ( _tempLvl > 33 and _tempLvl < 36 ) then { _tempImg = 3 };
if ( _tempLvl >= 30 and _tempLvl <= 33 ) then { _tempImg = 2 };
if ( _tempLvl > 28 and _tempLvl < 30 ) then { _tempImg = 1 };
if ( _tempLvl <= 28 ) then { _tempImg = 0 };
_temp = "\z\addons\dayz_code\gui\status_temp_" + str(_tempImg) + "_ca.paa";
_ctrlBlood ctrlSetText _blood;
_ctrlThirst ctrlSetText _thirst;
_ctrlFood ctrlSetText _food;
_ctrlTemp ctrlSetText _temp;
/*
Visual:
*/
_visualtext = "";
_visual = (round((dayz_disVisual / 100) * 4)) min 5;
if (_visual > 0) then {_visualtext = "\z\addons\dayz_code\gui\val_" + str(_visual) + "_ca.paa"};
_ctrlEye ctrlSetText _visualtext;
/*
Audible:
*/
_audibletext = "";
_audible = (round((dayz_disAudial / 50) * 4)) min 5;
if (_audible > 0) then {_audibletext = "\z\addons\dayz_code\gui\val_" + str(_audible) + "_ca.paa"};
_ctrlEar ctrlSetText _audibletext;
/*
Fracture:
*/
if (!canStand player) then {
if (!(ctrlShown _ctrlFracture)) then {
r_fracture_legs = true;
_ctrlFracture ctrlShow true;
};
};
/*
Flashing:
*/
if (_combatVal == 0) then {
_ctrlCombat call player_guiControlFlash;
};
if (_bloodVal < 0.2) then {
_ctrlBlood call player_guiControlFlash;
};
if (_thirstVal < 0.2) then {
_ctrlThirst call player_guiControlFlash;
};
if (_foodVal < 0.2) then {
_ctrlFood call player_guiControlFlash;
};
if (_tempVal > 0.8) then { //TeeChange
_ctrlTemp call player_guiControlFlash;
} else {
_ctrlTemp ctrlShow true;
};
if (r_player_injured) then {
_ctrlBleed call player_guiControlFlash;
};
/*
_humanity = player getVariable["humanity",0];
_guiHumanity = 0;
if(_humanity != dayz_lastHumanity) then {
if (_humanity > 0) then {
_humanity = _humanity min 5000;
_guiHumanity = (round((_humanity / 5000) * 5) + 5);
} else {
_humanity = _humanity max -20000;
_guiHumanity = 5 - (round(-(_humanity / 20000) * 4));
};
dayz_lastHumanity = _humanity;
dayz_guiHumanity = _guiHumanity;
_humanityText = "\z\addons\dayz_code\gui\humanity_" + str(_guiHumanity) + "_ca.paa";
_ctrlHumanity ctrlSetText _humanityText;
};
*/
_array = [_foodVal,_thirstVal];
_array

View File

@@ -0,0 +1,36 @@
private ["_currentObjects","_newObjects","_checkObjects","_type","_qtyNow","_qtyBefore"];
//_newObjects = [_previous,weapons player] call player_weaponCheck;
_currentObjects = _this select 0;
_checkObjects = _this select 1;
_change = false;
//Check if some of old loadout not there
_newObjects = [];
{
if (!(_x in _newObjects)) then {
_type = _x;
_qtyNow = {_x == _type} count _checkObjects;
_qtyBefore = {_x == _type} count _currentObjects;
if (_qtyNow != _qtyBefore) then {
_change = true;
};
_newObjects set [count _newObjects,_type];
};
} forEach _currentObjects;
//Compare current loadout with old loadout
_newObjects = [];
{
if (!(_x in _newObjects)) then {
_type = _x;
_qtyNow = {_x == _type} count _checkObjects;
_qtyBefore = {_x == _type} count _currentObjects;
if (_qtyNow != _qtyBefore) then {
_change = true;
};
_newObjects set [count _newObjects,_type];
};
} forEach _checkObjects;
_change;

View File

@@ -0,0 +1,93 @@
//[unit, weapon, muzzle, mode, ammo, magazine, projectile]
private ["_unit","_evType","_recordable","_inVehicle","_isPlayer","_isRocket","_dmgDistance","_isBallistic","_handled","_id","_firer","_distance","_weapon","_ammo","_killerID","_arc","_turretDir","_weaponDir","_pos1","_pos2","_facing","_firingArc","_isInFront","_isInRear"];
//Init
//[unit, firer, distance, weapon, muzzle, mode, ammo]
_unit = _this select 0;
_firer = _this select 1;
_distance = _this select 2;
_weapon = _this select 3;
_ammo = _this select 6;
_killerID = _firer getVariable["MemberID",0];
_handled = false;
_arc = 60;
_isBallistic = (getNumber (configfile >> "CfgAmmo" >> _ammo >> "whistleOnFire") > 0);
_dmgDistance = getNumber (configfile >> "CfgAmmo" >> _ammo >> "whistleDist");
_isRocket = ((_ammo isKindOf "RocketBase") and (_firer isKindOf "Man"));
_isPlayer = (_unit == player);
_inVehicle = (vehicle _unit != _unit);
_evType = "";
_recordable = false;
// Both the firer and those nearby (<=8m) go into "combat" to prevent ALT-F4
//diag_log ("DEBUG: AMMO TYPE: " +str(_ammo));
_firer setVariable["startcombattimer", 1, false];
if (_distance <= 8) then {
_unit setVariable["startcombattimer", 1, false];
};
if (_inVehicle) exitWith{};
if (_firer == player) exitWith{};
//Is in danger angle?
_turretDir = _firer weaponDirection _weapon;
_weaponDir = ((_turretDir select 0) atan2 (_turretDir select 1));
_pos1 = getposATL _unit;
_pos2 = getposATL _firer;
_facing = ((_pos1 Select 0) - (_pos2 Select 0)) ATan2 ((_pos1 Select 1) - (_pos2 Select 1));
_firingArc = (_weaponDir - _facing);
_firingArc = (-_firingArc) max (_firingArc);
//In front?
_isInFront = (_firingArc < _arc);
_isInRear = (_firingArc > (180 - _arc));
//Ballistic Handler
if ((_isBallistic and _isInFront) and (_distance < (_dmgDistance * 2))) then {
if (_distance < _dmgDistance) then {
//Will Cause Damage
1 call fnc_usec_bulletHit;
[20,45] call fnc_usec_pitchWhine; //Visual , Sound
if (_distance < ((_dmgDistance / 2) + 1)) then {
//serious ballistic damage
if (_isPlayer) then {
_id = [] spawn player_death;
};
[_unit,4] call fnc_usec_damageUnconscious;
} else {;
//Just Knocked out
[_unit,0.5] call fnc_usec_damageUnconscious;
};
} else {
//Hit warn zone
if (_unit == player) then {
[10,20] call fnc_usec_pitchWhine; //Visual , Sound
addCamShake [15, 0.8, 25];
};
};
} else {
if (_isRocket and (_isInFront or _isInRear)) then {
if ((_distance < 5) and !_handled) then {
1 call fnc_usec_bulletHit;
[20,45] call fnc_usec_pitchWhine; //Visual , Sound
// Dead
if (_isPlayer) then {
_id = [] spawn player_death;
};
[_unit,2] call fnc_usec_damageUnconscious;
};
if ((_distance < 10) and !_handled) then {
[10,20] call fnc_usec_pitchWhine; //Visual , Sound
// Unconscious
[_unit,0.2] call fnc_usec_damageUnconscious;
};
if ((_distance < 20) and !_handled and _isPlayer) then {
// Warn
[10,20] call fnc_usec_pitchWhine; //Visual , Sound
addCamShake [15, 0.8, 25];
};
};
};
//Launcher Handler

View File

@@ -0,0 +1,149 @@
private ["_unit","_targets","_move","_damage","_wound","_index","_cnt","_dir","_hpList","_hp","_strH","_dam","_total","_vehicle","_tPos","_zPos","_cantSee","_inAngle","_rnd","_openVehicles","_chance","_attackanimations","_type"];
_unit = _this select 0;
_type = _this select 1;
_vehicle = (vehicle player);
_targets = _unit getVariable ["targets",[]];
// if (!dayz_zedsAttackVehicles and !(_vehicle in _targets)) exitWith {};
//Do the attack
if (r_player_unconscious && _vehicle == player && _type == "zombie") then {
_rnd = (round(random 4)) + 1;
_move = "ZombieFeed" + str(_rnd);
} else {
if (_type == "zombie") then {
_rnd = (round(random 9)) + 1;
_move = "ZombieStandingAttack" + str(_rnd);
} else {
_move = "Dog_Attack";
};
};
_dir = [_unit,player] call BIS_Fnc_dirTo;
_unit setDir _dir;
_unit playMove _move;
//Wait
sleep 0.3;
if (_vehicle != player) then {
_hpList = _vehicle call vehicle_getHitpoints;
_hp = _hpList call BIS_fnc_selectRandom;
_wound = getText(configFile >> "cfgVehicles" >> (typeOf _vehicle) >> "HitPoints" >> _hp >> "name");
_damage = random 0.08;
_chance = round(random 12);
if ((_chance % 4) == 0) then {
_openVehicles = ["ATV_Base_EP1", "Motorcycle", "Bicycle"];
{
if (_vehicle isKindOf _x) exitWith {
player action ["eject", _vehicle];
};
} forEach _openVehicles;
};
diag_log ("Hitpoints " +str(_wound) + "hit points " + str(_hpList));
if (_wound in DZE_vehicleZwounds) then {
_strH = "hit_" + (_wound);
_dam = _vehicle getVariable [_strH,0];
_total = (_dam + _damage);
if(_total < 1) then {
[_unit,"hit",4,false] call dayz_zombieSpeak;
};
diag_log ("Hitpoints " +str(_wound) +str(_total));
//["dayzHitV",[_vehicle, _wound,_total, _unit,"zombie"]] call broadcastRpcCallAll;
if (_total >= 1) then {
if (r_player_blood < (r_player_bloodTotal * 0.8)) then {
_cnt = count (DAYZ_woundHit select 1);
_index = floor (random _cnt);
_index = (DAYZ_woundHit select 1) select _index;
_wound = (DAYZ_woundHit select 0) select _index;
} else {
_cnt = count (DAYZ_woundHit_ok select 1);
_index = floor (random _cnt);
_index = (DAYZ_woundHit_ok select 1) select _index;
_wound = (DAYZ_woundHit_ok select 0) select _index;
};
_damage = 0.1 + random (1.2);
diag_log ("START DAM: Player Hit on " + _wound + " for " + str(_damage));
[player, _wound, _damage, _unit,"zombie"] call fnc_usec_damageHandler;
//dayzHit = [player,_wound, _damage, _unit,"zombie"];
//publicVariable "dayzHit";
[_unit,"hit",2,false] call dayz_zombieSpeak;
} else {
//["dayzHitV",[_vehicle, _wound, _total, _unit,"zombie"]] call broadcastRpcCallAll;
dayzSetFix = [_vehicle,_strH,_total];
if (local _vehicle) then {
dayzSetFix call object_setFixServer;
} else {
publicVariable "dayzSetFix";
};
};
};
} else {
//Did he hit?
//_currentAnim = animationState _unit;
//diag_log ("Animation state: " +(_currentAnim));
//"amovpercmstpsnonwnondnon",
_attackanimations = ["zombiestandingattack1","zombiestandingattack2","zombiestandingattack3","zombiestandingattack4","zombiestandingattack5","zombiestandingattack6","zombiestandingattack7","zombiestandingattack8","zombiestandingattack9","zombiestandingattack10","zombiefeed1","zombiefeed2","zombiefeed3","zombiefeed4","zombiefeed5"];
if (((_unit distance player) <= dayz_areaAffect) and ((animationState _unit) in _attackanimations)) then {
//check LOS
private[];
_tPos = (getPosASL _vehicle);
_zPos = (getPosASL _unit);
_inAngle = [_zPos,(getdir _unit),50,_tPos] call fnc_inAngleSector;
if (_inAngle) then {
//LOS check
_cantSee = [_unit,_vehicle] call dayz_losCheck;
if (!_cantSee) then {
if (r_player_blood < (r_player_bloodTotal * 0.8)) then {
_cnt = count (DAYZ_woundHit select 1);
_index = floor (random _cnt);
_index = (DAYZ_woundHit select 1) select _index;
_wound = (DAYZ_woundHit select 0) select _index;
} else {
_cnt = count (DAYZ_woundHit_ok select 1);
_index = floor (random _cnt);
_index = (DAYZ_woundHit_ok select 1) select _index;
_wound = (DAYZ_woundHit_ok select 0) select _index;
};
_damage = 0.1 + random (1.2);
diag_log ("START DAM: Player Hit on " + _wound + " for " + str(_damage));
[player, _wound, _damage, _unit,"zombie"] call fnc_usec_damageHandler;
//dayzHit = [player,_wound, _damage, _unit,"zombie"];
//publicVariable "dayzHit";
[_unit,"hit",2,false] call dayz_zombieSpeak;
} else {
diag_log ("NO LOS: Player Hit on " + str(_unit) + " for " + str(_vehicle));
/*
_isZombieInside = [_unit,_building] call fnc_isInsideBuilding;
if (_isPlayerInside) then {
_damage = 0.1 + random (1.2);
diag_log ("START DAM: Player Hit on " + _wound + " for " + str(_damage));
[player, _wound, _damage, _unit,"zombie"] call fnc_usec_damageHandler;
//dayzHit = [player,_wound, _damage, _unit,"zombie"];
//publicVariable "dayzHit";
[_unit,"hit",2,false] call dayz_zombieSpeak;
};
*/
};
} else {
diag_log ("out of angle : tpos " + str(_tPos) + " zpos " + str(_zPos) + " dir" + str(getdir _unit));
};
} else {
if(!((_unit distance player) <= dayz_areaAffect)) then {
_tPos = (getPosASL _vehicle);
_zPos = (getPosASL _unit);
diag_log ("to far to hit player : tpos " + str(_tPos) + " zpos " + str(_zPos));
};
};
};

View File

@@ -0,0 +1,315 @@
private ["_listTalk","_group","_eyeDir","_attacked","_continue","_type","_chance","_last","_refObj","_inAngle","_tPos","_zPos","_cantSee","_entHeight","_delta","_targets","_lowBlood","_pHeight"];
_refObj = vehicle player;
_listTalk = (getPos _refObj) nearEntities ["zZombie_Base",80];
_pHeight = (getPosATL _refObj) select 2;
_attacked = false;
//_multiplier = 1;
//Old System
{
_continue = true;
_type = "zombie";
if (alive _x && _continue) then {
private["_dist"];
_dist = (_x distance _refObj);
_group = _x;
_targets = _group getVariable ["targets",[]];
_chance = 1;
if ((_x distance player < dayz_areaAffect) and !(animationState _x == "ZombieFeed")) then {
if (_type == "zombie") then { [_x,"attack",(_chance),true] call dayz_zombieSpeak; };
//perform an attack
_last = _x getVariable["lastAttack",0];
_entHeight = (getPosATL _x) select 2;
_delta = _pHeight - _entHeight;
if ( ((time - _last) > 1) and ((_delta < 1.5) and (_delta > -1.5)) ) then {
zedattack = [_x, _type] spawn player_zombieAttack;
_x setVariable["lastAttack",time];
};
_attacked = true;
} else {
if (_type == "zombie") then {
if (speed _x < 4) then {
[_x,"idle",(_chance + 4),true] call dayz_zombieSpeak;
} else {
[_x,"chase",(_chance + 3),true] call dayz_zombieSpeak;
};
};
};
//Noise Activation
if (!(_refObj in _targets)) then {
if (_dist < DAYZ_disAudial) then {
if (DAYZ_disAudial > 80) then {
if (!(_refObj in _targets)) then {
_targets set [count _targets, driver _refObj];
_group setVariable ["targets",_targets,true];
};
} else {
if (_dist < (DAYZ_disAudial / 2)) then {
if (!(_refObj in _targets)) then {
_targets set [count _targets, driver _refObj];
_group setVariable ["targets",_targets,true];
};
};
};
};
};
//Sight Activation
if (!(_refObj in _targets)) then {
if (_dist < DAYZ_disVisual) then {
//_chance = [_x,_dist,DAYZ_disVisual] call dayz_losChance;
//diag_log ("Visual Detection: m" + str([_x,_dist]) + " " + str(_chance));
//if ((random 1) < _chance) then {
//diag_log ("Chance Detection");
_tPos = (getPosASL _refObj);
_zPos = (getPosASL _x);
//_eyeDir = _x call dayz_eyeDir;
_eyeDir = direction _x;
_inAngle = [_zPos,_eyeDir,30,_tPos] call fnc_inAngleSector;
if (_inAngle) then {
//LOS check
_cantSee = [_x,_refObj] call dayz_losCheck;
//diag_log ("LOS Check: " + str(_cantSee));
if (!_cantSee) then {
//diag_log ("Within LOS! Target");
if (!(_refObj in _targets)) then {
_targets set [count _targets, driver _refObj];
_group setVariable ["targets",_targets,true];
};
};
};
//};
};
};
};
//diag_log ("Targets Array: " +str(_targets));
} forEach _listTalk;
// New Systems
/*
{
_continue = true;
_type = "zombie";
_targets = _group getVariable ["targets",[]];
if (alive _x and _continue) then
{
if (local _x) then
{
private["_dist"];
_dist = (_x distance _refObj);
_chance = 1;
if ((_dist < dayz_areaAffect) and !(animationState _x == "ZombieFeed")) then
{
if (_type == "zombie") then { [_x,"attack",(_chance),true] call dayz_zombieSpeak; };
//perform an attack
_last = _x getVariable["lastAttack",0];
_entHeight = (getPosATL _x) select 2;
_delta = _pHeight - _entHeight;
if ( ((time - _last) > 1) and ((_delta < 1.5) and (_delta > -1.5)) ) then
{
[_x, _type] spawn player_zombieAttack;
_x setVariable["lastAttack",time];
};
_attacked = true;
}
else
{
if (_type == "zombie") then
{
if (speed _x < 4) then
{
[_x,"idle",(_chance + 4),true] call dayz_zombieSpeak;
}
else
{
[_x,"chase",(_chance + 3),true] call dayz_zombieSpeak;
};
};
};
//Noise Activation
_target = _x getVariable ["target",[]];
if (!(_refObj in _target)) then
{
if (_dist < DAYZ_disAudial) then
{
if (DAYZ_disAudial > 80) then
{
_target set [count _target,(driver _refObj)];
_x setVariable ["target",_target];
}
else
{
// _chance = [_x,_dist,DAYZ_disAudial] call dayz_losChance;
//diag_log ("Visual Detection: " + str([_x,_dist]) + " " + str(_chance));
// if ((random 1) < _chance) then {
_cantSee = [_x,_refObj] call dayz_losCheck;
if (!_cantSee) then
{
_target set [count _target,(driver _refObj)];
_x setVariable ["target",_target];
}
else
{
if (_dist < (DAYZ_disAudial / 2)) then
{
_target set [count _target,(driver _refObj)];
_x setVariable ["target",_target];
};
};
//};
};
};
};
//Sight Activation
_target = _x getVariable ["target",[]];
if (!(_refObj in _target)) then
{
if (_dist < DAYZ_disVisual) then
{
_chance = [_x,_dist,DAYZ_disVisual] call dayz_losChance;
//diag_log ("Visual Detection: " + str([_x,_dist]) + " " + str(_chance));
//if ((random 1) < _chance) then {
//diag_log ("Chance Detection");
_tPos = (getPosASL _refObj);
_zPos = (getPosASL _x);
//_eyeDir = _x call dayz_eyeDir;
_eyeDir = direction _x;
_inAngle = [_zPos,_eyeDir,30,_tPos] call fnc_inAngleSector;
if (_inAngle) then
{
//diag_log ("In Angle");
//LOS check
_cantSee = [_x,_refObj] call dayz_losCheck;
//diag_log ("LOS Check: " + str(_cantSee));
if (!_cantSee) then
{
_target set [count _target,(driver _refObj)];
_x setVariable ["target",_target];
};
};
//};
};
};
}
else
{
private["_dist"];
_dist = (_x distance _refObj);
_chance = 1;
if ((_x distance player < dayz_areaAffect) and !(animationState _x == "ZombieFeed")) then
{
if (_type == "zombie") then { [_x,"attack",(_chance),true] call dayz_zombieSpeak; };
//perform an attack
_last = _x getVariable["lastAttack",0];
_entHeight = (getPosATL _x) select 2;
_delta = _pHeight - _entHeight;
if ( ((time - _last) > 1) and ((_delta < 1.5) and (_delta > -1.5)) ) then
{
[_x, _type] spawn player_zombieAttack;
_x setVariable["lastAttack",time];
};
_attacked = true;
}
else
{
if (_type == "zombie") then
{
if (speed _x < 4) then
{
[_x,"idle",(_chance + 4),true] call dayz_zombieSpeak;
}
else
{
[_x,"chase",(_chance + 3),true] call dayz_zombieSpeak;
};
};
};
//Noise Activation
_targets = _x getVariable ["targets",[]];
if (!(_refObj in _targets)) then
{
if (_dist < DAYZ_disAudial) then
{
if (DAYZ_disAudial > 80) then
{
_targets set [count _targets,(driver _refObj)];
_x setVariable ["targets",_targets,true];
}
else
{
//_chance = [_x,_dist,DAYZ_disAudial] call dayz_losChance;
//diag_log ("Visual Detection: " + str([_x,_dist]) + " " + str(_chance));
//if ((random 1) < _chance) then {
_cantSee = [_x,_refObj] call dayz_losCheck;
if (!_cantSee) then
{
_targets set [count _targets,(driver _refObj)];
_x setVariable ["targets",_targets,true];
}
else
{
if (_dist < (DAYZ_disAudial / 2)) then
{
_targets set [count _targets,(driver _refObj)];
_x setVariable ["targets",_targets,true];
};
};
//};
};
};
};
//Sight Activation
_targets = _x getVariable ["targets",[]];
if (!(_refObj in _targets)) then
{
if (_dist < DAYZ_disVisual) then
{
//_chance = [_x,_dist,DAYZ_disVisual] call dayz_losChance;
//diag_log ("Visual Detection: " + str([_x,_dist]) + " " + str(_chance));
//if ((random 1) < _chance) then {
//diag_log ("Chance Detection");
_tPos = (getPosASL _refObj);
_zPos = (getPosASL _x);
//_eyeDir = _x call dayz_eyeDir;
_eyeDir = direction _x;
_inAngle = [_zPos,_eyeDir,30,_tPos] call fnc_inAngleSector;
if (_inAngle) then
{
//diag_log ("In Angle");
//LOS check
_cantSee = [_x,_refObj] call dayz_losCheck;
//diag_log ("LOS Check: " + str(_cantSee));
if (!_cantSee) then
{
//diag_log ("Within LOS! Target");
_targets set [count _targets,(driver _refObj)];
_x setVariable ["targets",_targets,true];
};
};
//};
};
};
};
};
} forEach _listTalk;
*/
if (_attacked) then {
if (r_player_unconscious) then {
[_refObj,"scream",3,false] call dayz_zombieSpeak;
} else {
_lowBlood = (r_player_blood / r_player_bloodTotal) < 0.5;
if (_lowBlood) then {
dayz_panicCooldown = time;
[_refObj,"panic",3,false] call dayz_zombieSpeak;
};
};
};

View File

@@ -0,0 +1,182 @@
private ["_characterID","_temp","_isSync","_currentWpn","_currentMag","_magazines","_qty","_qtyT","_val","_isNewPos","_isNewBackp","_humanity","_isNewGear","_doUpdate","_currentModel","_modelChk","_playerPos","_playerGear","_playerBackp","_backpack","_updates","_killsB","_killsH","_medical","_isNewMed","_character","_timeSince","_charPos","_isInVehicle","_justAte","_justDrank","_distanceFoot","_lastPos","_kills","_headShots","_timeGross","_timeLeft","_onLadder","_isTerminal","_vehicle","_wounds","_currentAnim","_muzzles","_array","_key","_lastTime","_config","_currentState"];
_character = _this;
_doUpdate = false;
_characterID = _character getVariable ["characterID","0"];
_updates = _character getVariable ["updatePlayer",[false,false,false,false,false]];
_charPos = getPosATL _character;
_isInVehicle = vehicle _character != _character;
_timeSince = 0;
_humanity = 0;
if (_characterID == "0") exitWith {
diag_log ("ERROR: Cannot Sync Character " + (name _character) + " as no characterID");
};
//CheckVehicle
_character allowDamage true;
if (_isInVehicle) then {
_vehicle = (vehicle _character);
_isSync = _vehicle getVariable ["ObjectID",0] > 0;
if (!_isSync) then {
_vehicle allowDamage true;
_vehicle setDamage 1;
_character setVelocity [0,0,100];
};
};
//Check for server initiated updates
_isNewMed = _character getVariable["medForceUpdate",false]; //Med Update is forced when a player receives some kind of med incident
//Check for player initiated updates
if ((count _updates > 0 or _isNewMed) and _characterID != "0") then {
_isNewPos = _updates select 0;
_isNewGear = _updates select 1;
_isNewBackp = _updates select 2;
_justAte = _updates select 3;
_justDrank = _updates select 4;
_playerPos = [];
_playerGear = [];
_playerBackp = [];
_medical = [];
_distanceFoot = 0;
//Check if update is requested
if (_isNewPos) then {
if (((_charPos select 0) == 0) and ((_charPos select 1) == 0)) then {
//Zero Position
} else {
_playerPos = [round(direction _character),_charPos];
_lastPos = _character getVariable["lastPos",_charPos];
if (count _lastPos > 2 and count _charPos > 2) then {
if (!_isInVehicle) then {
_distanceFoot = round(_charPos distance _lastPos);
if (_distanceFoot > 500) then {
_distanceFoot = 0;
} else {
_doUpdate = true;
};
};
_character setVariable["lastPos",_charPos];
};
};
};
if (_isNewGear) then {
//player sideChat format["SERVER: %1 update backpack",_characterID];
_currentWpn = currentMuzzle _character;
_currentMag = currentMagazine _character;
_magazines = magazines _character;
_qty = _character ammo _currentWpn;
_qtyT = getNumber(configFile >> "cfgMagazines" >> _currentMag >> "count");
if (_qty < (_qtyT * 0.5)) then {
_val = _magazines find _currentMag;
_magazines set [_val,"DEL"];
_magazines = _magazines - ["DEL"];
};
_playerGear = [weapons _character,_magazines];
_doUpdate = true;
};
if (_isNewBackp) then {
//player sideChat format["SERVER: %1 update inventory",_characterID];
_backpack = unitBackpack _character;
_playerBackp = [typeOf _backpack,getWeaponCargo _backpack,getMagazineCargo _backpack];
_doUpdate = true;
};
if (_isNewMed) then {
//player sideChat format["SERVER: %1 update medical",_characterID];
_wounds = [];
if (!(_character getVariable["USEC_isDead",false])) then {
_medical = _character call player_sumMedical;
_doUpdate = true;
};
};
//Process update
if (_doUpdate and _characterID != "0") then {
//Record stats while we're here
/*
Check previous stats against what client had when they logged in
this helps prevent JIP issues, where a new player wouldn't have received
the old players updates. Only valid for stats where clients could have
be recording results from their local objects (such as agent zombies)
*/
_kills = ["zombieKills",_character] call server_getDiff;
_killsB = ["banditKills",_character] call server_getDiff;
_killsH = ["humanKills",_character] call server_getDiff;
_headShots = ["headShots",_character] call server_getDiff;
_humanity = ["humanity",_character] call server_getDiff2;
//_humanity = _character getVariable ["humanity",0];
_character addScore _kills;
/*
Assess how much time has passed, for recording total time on server
*/
_lastTime = _character getVariable["lastTime",time];
_timeGross = (time - _lastTime);
_timeSince = floor(_timeGross / 60);
_timeLeft = (_timeGross - (_timeSince * 60));
/*
Get character state details
*/
_currentWpn = currentMuzzle _character;
_currentAnim = animationState _character;
_config = configFile >> "CfgMovesMaleSdr" >> "States" >> _currentAnim;
_onLadder = (getNumber (_config >> "onLadder")) == 1;
_isTerminal = (getNumber (_config >> "terminal")) == 1;
//_wpnDisabled = (getNumber (_config >> "disableWeapons")) == 1;
_currentModel = typeOf _character;
_modelChk = _character getVariable ["model_CHK",""];
if (_currentModel == _modelChk) then {
_currentModel = "";
} else {
_currentModel = str(_currentModel);
_character setVariable ["model_CHK",typeOf _character];
};
if (_onLadder or _isInVehicle or _isTerminal) then {
_currentAnim = "";
//If position to be updated, make sure it is at ground level!
if ((count _playerPos > 0) and !_isTerminal) then {
_charPos set [2,0];
_playerPos set[1,_charPos];
};
};
if (_isInVehicle) then {
_currentWpn = "";
} else {
_muzzles = getArray(configFile >> "cfgWeapons" >> _currentWpn >> "muzzles");
if (count _muzzles > 1) then {
_currentWpn = currentMuzzle _character;
};
};
_temp = round(_character getVariable ["temperature",100]);
_currentState = [_currentWpn,_currentAnim,_temp];
/*
Everything is ready, now publish to HIVE
*/
if (count _playerPos > 0) then {
_array = [];
{
if (_x > dayz_minpos and _x < dayz_maxpos) then {
_array set [count _array,_x];
};
} forEach (_playerPos select 1);
_playerPos set [1,_array];
};
if (!isNull _character) then {
if (alive _character) then {
//Wait for HIVE to be free
//Send request
_key = format["CHILD:201:%1:%2:%3:%4:%5:%6:%7:%8:%9:%10:%11:%12:%13:%14:%15:%16:",_characterID,_playerPos,_playerGear,_playerBackp,_medical,_justAte,_justDrank,_kills,_headShots,_distanceFoot,_timeSince,_currentState,_killsH,_killsB,_currentModel,_humanity];
diag_log ("HIVE: WRITE: "+ str(_key) + " / " + _characterID);
_key spawn server_hiveWrite;
_character setVariable ["updatePlayer",[false,false,false,false,false],true];
_character setVariable ["medForceUpdate",false];
};
};
//Reset timer
if (_timeSince > 0) then {
_character setVariable ["lastTime",(time - _timeLeft)];
};
};
};

View File

@@ -0,0 +1,6 @@
private["_body","_id","_position"];
_body = _this;
_position = getPosATL _body;
_id = [_position,0.1,1.5] call bis_fnc_flies;
//_id setVariable ["body",_body];
//dayz_flyMonitor set[count dayz_flyMonitor, _id];

View File

@@ -0,0 +1,67 @@
private ["_iItem","_iClass","_iPos","_radius","_itemTypes","_index","_item","_qty","_max","_tQty","_canType","_weights","_cntWeights","_dateNow","_mags"];
_iItem = _this select 0;
_iClass = _this select 1;
_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 {
//Item is food, add random quantity of cans along with an item (if exists)
_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;
_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;
_item addMagazineCargoGlobal [_canType,_tQty];
_qty = _qty + _tQty;
};
if (_iItem != "") then {
_item addWeaponCargoGlobal [_iItem,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 (_mags select 0 == "Quiver") then { _mags set [0, "WoodenArrow"] }; // Prevent spawning a Quiver
_item addMagazineCargoGlobal [(_mags select 0), (round(random 2))];
};
};
case "magazine": {
//Item is one magazine
_item = createVehicle ["WeaponHolder", _iPos, [], _radius, "CAN_COLLIDE"];
_item addMagazineCargoGlobal [_iItem,1];
};
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 {
_item setPosATL _iPos;
};

View File

@@ -0,0 +1,28 @@
//diag_log "running location check...";
{private ["_location","_distCfg","_configClass","_distAct","_config","_position"];
_location = _x select 0;
_distCfg = (_x select 2) + 200;
_configClass = _x select 1;
_distAct = player distance position _location;
if ((_distAct < _distCfg) and !(_location in dayz_locationsActive)) then {
//Record Active Location
//diag_log "Load!";
dayz_locationsActive set [count dayz_locationsActive,_location];
//Get Town Details
_config = configFile >> "CfgTownGenerator" >> _configClass;
_locHdr = configName _config;
_position = []+ getArray (_config >> "position");
_config call stream_locationFill;
//player sidechat (_locHdr + " " + str(count _config));
} else {
if ((_distAct > _distCfg) and (_location in dayz_locationsActive)) then {
//Delete Town Objects
_config = configFile >> "CfgTownGenerator" >> _configClass;
_config call stream_locationDel;
dayz_locationsActive = dayz_locationsActive - [_location];
};
};
} forEach dayz_Locations;

View File

@@ -0,0 +1,12 @@
for "_i" from 0 to ((count _this) - 1) do
{
private ["_config","_type","_position","_dir","_onFire","_object"];
_config = (_this select _i);
if (isClass(_config)) then {
_type = getText (_config >> "ctype");
_position = getArray (_config >> "position");
_object = nearestObject [_position,_type];
deleteVehicle _object;
};
};
//diag_log ("CLEAR: " + str(_this));

View File

@@ -0,0 +1,24 @@
for "_i" from 0 to ((count _this) - 1) do
{
private ["_config","_type","_position","_dir","_onFire","_object"];
_config = (_this select _i);
if (isClass(_config)) then {
_type = getText (_config >> "type");
_position = [] + getArray (_config >> "position");
_dir = getNumber (_config >> "direction");
_onFire = getNumber (_config >> "onFire");
_object = _type createVehicleLocal _position;
_object setPos _position;
_object setDir _dir;
_object allowDamage false;
//diag_log format["CreateObj: %1 / %2",_type,_position];
/*
if (_onFire > 0) then {
nul=[_object,_onFire,time,false,false] spawn BIS_Effects_Burn;
};
*/
};
};
//diag_log ("FILL: " + str(_this));

View File

@@ -0,0 +1,36 @@
/*
File: tame_dog.sqf
Author: Kane "Alby" Stone
Description:
Allows a player to tame/domesticate a dog.
Script is applied to object via addAction.
Variables:
_target = Object that action is attached too.
_caller = Object that activates the action.
_id = ID of the action handler.
_dog = Intended target of the script.
*/
private ["_target","_caller","_id","_dog","_fsmid","_animalID"];
_target = _this select 0;
_caller = _this select 1;
_id = _this select 2;
_dog = _this select 3;
player removeMagazine "FoodSteakRaw";
_animalID = _dog getVariable "fsm_handle";
_animalID setFSMVariable ["_isTamed", true];
sleep 1;
diag_log format["DEBUG: %1, id: %2 [%3]",_dog,_animalID,completedFSM _animalID];
if (!moveToCompleted _dog) then {
_dog moveTo (position _dog);
};
_dog disableAI "FSM";
(group _dog) setBehaviour "AWARE";
_fsmid = [_dog, typeOf _dog] execFSM "\z\addons\dayz_code\system\dog_agent.fsm";
_fsmid setFSMVariable ["_handle", _fsmid];
player setVariable ["dogID", _fsmid];
_dog setVariable ["fsm_handle", _fsmid];
_dog setVariable ["characterID", dayz_characterID, true];

View File

@@ -0,0 +1,45 @@
private["_state"];
disableSerialization;
_state = uiNamespace getVariable ['DZ_displayUI', 0];
// Hard code the GUI on and the Debug Monitor off
if (dayzState != 0) then {
3 cutRsc ["playerStatusGUI", "PLAIN",0];
//Update GUI
call player_updateGui;
call ui_initDisplay;
hintSilent "";
};
dayzDebug = false;
/*
switch (_state) do {
case 0: {
if (dayzState != 0) then {
3 cutRsc ["playerStatusGUI", "PLAIN",0];
//Update GUI
call player_updateGui;
call ui_initDisplay;
hintSilent "";
};
dayzDebug = false;
};
case 1: {
if (dayzState != 1) then {
3 cutRsc ["playerStatusGUI", "PLAIN",0];
//Update GUI
call player_updateGui;
call ui_initDisplay;
};
dayzDebug = true;
};
case 2: {
if (dayzState != 2) then {
3 cutRsc ["default", "PLAIN",0];
hintSilent "";
};
dayzDebug = false;
};
};
dayzState = _state;
*/

View File

@@ -0,0 +1,64 @@
private ["_control","_button","_parent","_group","_pos","_item","_conf","_name","_cfgActions","_numActions","_height","_menu","_config","_type","_script","_outputOriented","_compile","_array","_outputClass","_outputType"];
disableSerialization;
_control = _this select 0;
_button = _this select 1;
_parent = findDisplay 106;
//if ((time - dayzClickTime) < 1) exitWith {};
if (_button == 1) then {
//dayzClickTime = time;
_group = _parent displayCtrl 6902;
_pos = ctrlPosition _group;
_pos set [0,((_this select 2) + 0.48)];
_pos set [1,((_this select 3) + 0.07)];
_item = gearSlotData _control;
_conf = configFile >> "cfgMagazines" >> _item;
if (!isClass _conf) then {
_conf = configFile >> "cfgWeapons" >> _item;
};
_name = getText(_conf >> "displayName");
_cfgActions = _conf >> "ItemActions";
_numActions = (count _cfgActions);
_height = 0;
//Populate Menu
for "_i" from 0 to (_numActions - 1) do
{
_menu = _parent displayCtrl (1600 + _i);
_menu ctrlShow true;
_config = (_cfgActions select _i);
_type = getText (_config >> "text");
_script = getText (_config >> "script");
_outputOriented = getNumber (_config >> "outputOriented") == 1;
_height = _height + (0.025 * safezoneH);
_compile = format["_id = '%2' %1;",_script,_item];
uiNamespace setVariable ['uiControl', _control];
if (_outputOriented) then {
/*
This flag means that the action is output oriented
the output class will then be transferred to the script
and the type used for the name
*/
_array = getArray (_config >> "output");
_outputClass = _array select 0;
_outputType = _array select 1;
_name = getText (configFile >> _outputType >> _outputClass >> "displayName");
_compile = format["_id = ['%2',%3] %1;",_script,_item,_array];
};
_menu ctrlSetText format[_type,_name];
_menu ctrlSetEventHandler ["ButtonClick",_compile];
};
_pos set [3,_height];
//hint format["Obj: %1 \nHeight: %2\nPos: %3",_item,_height,_grpPos];
_group ctrlShow true;
ctrlSetFocus _group;
_group ctrlSetPosition _pos;
_group ctrlCommit 0;
};

View File

@@ -0,0 +1,26 @@
private ["_cfgHitPoints", "_hps", "_funcGetHitPoints"];
_cfgHitPoints = configFile >> "CfgVehicles" >> (typeOf _this) >> "HitPoints";
_hps = [];
_funcGetHitPoints =
{
for "_i" from 0 to ((count _this) - 1) do
{
private ["_hp"];
_hp = configName (_this select _i);
if (!(_hp in _hps)) then
{
_hps set [count _hps, _hp];
};
};
};
//Explore inheritance structure fully
while {(configName _cfgHitPoints) != ""} do
{
_cfgHitPoints call _funcGetHitPoints;
_cfgHitPoints = inheritsFrom _cfgHitPoints;
};
_hps

View File

@@ -0,0 +1,36 @@
/***********************************************************
ASSIGN DAMAGE TO A UNIT
- Function Vehicle_HandleDamage
- [unit, selectionName, damage, source, projectile] call Vehicle_HandleDamage;
************************************************************/
private["_unit","_selection","_strH","_dam","_total","_damage","_needUpdate"];
_unit = _this select 0;
_selection = _this select 1;
_total = _this select 2;
_dam = _unit getVariable["totalDmg",0];
_needUpdate = _unit getVariable["needUpdate",false];
if (_dam < 1 ) then {
if ( (_selection != "") ) then {
_strH = "hit_" + (_selection);
} else {
_strH = "totalDmg";
};
if (_total > 0.98) then {
_total = 1;
};
if ( _total>0 ) then {
_unit setVariable [_strH,_total,true];
if ( !_needUpdate ) then {
_unit setVariable ["needUpdate",true,true];
//["dayzUpdateVehicle",[_unit,"damage"]] call callRpcProcedure;
if (isServer) then {
[_unit, "damage"] call server_updateObject;
} else {
dayzUpdateVehicle = [_unit,"damage"];
publicVariableServer "dayzUpdateVehicle";
};
};
};
};
_total

View File

@@ -0,0 +1,23 @@
private["_unit","_hitPoints","_selection","_killer"];
_unit = _this select 0;
_killer = _this select 1;
_hitPoints = _unit call vehicle_getHitpoints;
{
_selection = getText (configFile >> "CfgVehicles" >> (typeof _unit) >> "HitPoints" >> _x >> "name");
_unit setVariable [_selection, 1, true];
} forEach _hitPoints;
//["dayzUpdateVehicle",[_unit, "damage"]] call callRpcProcedure;
if (isServer) then {
[_unit, "killed"] call server_updateObject;
} else {
dayzUpdateVehicle = [_unit, "killed"];
publicVariableServer "dayzUpdateVehicle";
};
_unit removeAllEventHandlers "HandleDamage";
_unit removeAllEventHandlers "Killed";
_unit removeAllEventHandlers "GetIn";
_unit removeAllEventHandlers "GetOut";

View File

@@ -0,0 +1,61 @@
private["_position","_doLoiter","_unitTypes","_isNoone","_loot","_array","_agent","_type","_radius","_method","_nearByPlayer","_attempt","_myDest","_newDest","_lootType"];
_player = _this select 0;
_unitTypes = []+ getArray (configFile >> "CfgBuildingLoot" >> "Default" >> "zombieClass");
_doLoiter = true;
_loot = "";
_array = [];
_agent = objNull;
_type = _unitTypes call BIS_fnc_selectRandom;
//Create the Group and populate it
//diag_log ("Spawned: " + _type);
_radius = 40;
_method = "NONE";
_position = [_player,120,200,10,0,0,0] call BIS_fnc_findSafePos;
_agent = createAgent [_type, _position, [], _radius, _method];
if (_doLoiter) then {
//_agent setPosATL _position;
//_agent setVariable ["doLoiter",true,true];
_agent setDir round(random 180);
};
dayz_spawnZombies = dayz_spawnZombies + 1;
if (random 1 > 0.7) then {
_agent setUnitPos "Middle";
};
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 = []+ getArray (configFile >> "cfgLoot" >> getText(_lootType));
if (count _array > 0) then {
_loot = _array call BIS_fnc_selectRandomWeighted;
if(!isNil "_array") then {
_agent addMagazine _loot;
};
};
};
};
//Start behavior
_id = [_position,_agent] execFSM "\z\AddOns\dayz_code\system\zombie_agent.fsm";

View File

@@ -0,0 +1,78 @@
private["_group","_target","_targetMen","_targetDis","_c","_man","_manDis","_targets","_lead","_leadheight","_nearEnts","_rnd","_assigned"];
_group = _this;
_target = objNull;
_lead = leader _group;
_targetMen = [];
_targetDis = [];
_range = 500;
_assigned = _group getVariable ["targets",[]];
{
_group reveal [_x,4];
} forEach _assigned;
//Find targets
_targets = _lead nearTargets _range;
{
private["_obj","_dis"];
_obj = _x select 4;
_dis = _obj distance _lead;
// if (_obj isKindOf "Man") then {
if (((_obj isKindOf "Man") or (_obj isKindOf "AllVehicles")) and !(_obj isKindOf "zZombie_Base") and !(_obj in _targetMen)) then {
//process man targets
_targetMen set [count _targetMen,_obj];
_targetDis set [count _targetDis,_dis];
};
// } else {
// if ((_obj isKindOf "AllVehicles") and (count crew _obj > 0) and !(_obj in _targetMen)) then {
// //process vehicle targets
// _targetMen set [count _targetMen,_obj];
// _targetDis set [count _targetDis,_dis];
// };
// };
} forEach _targets;
//Search for fires
if (count _targetMen == 0) then {
_fires = nearestObjects [_lead,["Land_Fire","SmokeShell"],_range];
{
private["_dis"];
_dis = _x distance _lead;
if ((_dis < _range) and !(_x in _targetMen)) then {
_rnd = random 1;
if (_rnd < 0.5) then {
if ((inflamed _x) or (_x isKindOf "SmokeShell")) then {
_targetMen set [count _targetMen,_x];
_targetDis set [count _targetDis,_dis];
};
};
};
} forEach _fires;
};
//Find best target
if (count _targetMen > 0) then {
_man = _targetMen select 0;
_manDis = _targetDis select 0;
_c = 0;
{
private["_dis"];
_dis = _targetDis select _c;
if (_dis < _manDis) then {
_man = _x;
_manDis = _dis;
};
if (_x isKindOf "SmokeShell") then {
_man = _x;
_manDis = _dis;
};
_c = _c + 1;
} forEach _targetMen;
_target = _man;
};
//Check if too far
if (_manDis > _range) then {
_target = objNull;
};
_target;

View File

@@ -0,0 +1,83 @@
private["_agent","_target","_targets","_targetDis","_c","_man","_manDis","_targets","_agent","_agentheight","_nearEnts","_rnd","_assigned","_range","_objects"];
_agent = _this;
_target = objNull;
/*
_local = [];
_remote = [];
*/
_targets = [];
_targetDis = [];
_range = 120;
_manDis = 0;
_refobj = vehicle player;
/*
_local = _agent getVariable ["target",[]];
//diag_log ("Local is: " + str(_local));
_remote = _agent getVariable ["targets",[]];
//diag_log ("Remote is: " + str(_remote));
if (count _remote == 0) then
{
_targets = _local;
//diag_log ("Targets is: " + str(_targets));
}
else
{
_targets = _local + _remote;
//diag_log ("Local + Remote targets is: " + str(_targets));
};
*/
_targets = _agent getVariable ["targets",[]];
if (isNil "_targets") exitWith {};
//Search for objects
if (count _targets == 0) then
{
_objects = nearestObjects [_agent,["ThrownObjects","GrenadeHandTimedWest","SmokeShell"],50];
{
private["_dis"];
if (!(_x in _targets)) then
{
_targets set [count _targets,_x];
_targetDis set [count _targetDis,_dis];
};
} forEach _objects;
};
//Find best target
if (count _targets > 0) then
{
_man = _targets select 0;
_manDis = _man distance _agent;
{
private["_dis"];
_dis = _x distance _agent;
if (_dis < _manDis) then
{
_man = _x;
_manDis = _dis;
};
if (_dis > _range) then
{
_targets = _targets - [_x];
};
if (_x isKindOf "SmokeShell") then
{
_man = _x;
_manDis = _dis;
};
} forEach _targets;
_target = _man;
};
//Check if too far
if (_manDis > _range) then
{
_targets = _targets - [_target];
_target = objNull;
};
_target

View File

@@ -0,0 +1,108 @@
private["_position","_doLoiter","_unitTypes","_isNoone","_loot","_array","_agent","_type","_radius","_method","_nearByPlayer","_attempt","_myDest","_newDest","_lootType"];
_position = _this select 0;
_doLoiter = _this select 1;
_unitTypes = _this select 2;
if (dayz_maxCurrentZeds > dayz_maxZeds) exitwith {};
if (dayz_CurrentZombies > dayz_maxGlobalZombies) exitwith {};
if (dayz_spawnZombies > dayz_maxLocalZombies) exitwith {};
_isNoone = {isPlayer _x} count (_position nearEntities [["AllVehicles","CAManBase"],30]) == 0;
_loot = "";
_array = [];
_agent = objNull;
//Exit if a player is nearby
if (!_isNoone) exitWith {};
if (count _unitTypes == 0) then {
_unitTypes = []+ getArray (configFile >> "CfgBuildingLoot" >> "Default" >> "zombieClass");
};
_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];
dayzSpawnZed = [_agent];
publicVariableServer "dayzSpawnZed";
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 = []+ getArray (configFile >> "cfgLoot" >> getText(_lootType));
if (count _array > 0) then {
_loot = _array call BIS_fnc_selectRandomWeighted;
if(!isNil "_array") then {
_agent addMagazine _loot;
};
};
};
};
//Start behavior
_id = [_position,_agent] execFSM "\z\AddOns\dayz_code\system\zombie_agent.fsm";

View File

@@ -0,0 +1,8 @@
private["_unit"];
_unit = _this select 0;
if (isServer) then {
_unit addEventHandler ["local", {_this call zombie_findOwner}];
} else {
_position = getPosATL _unit;
_unit addEventHandler ["local", {_this call eh_zombieInit}];
};

View File

@@ -0,0 +1,33 @@
private["_unit","_originalPos","_pos"];
_unit = _this select 0;
_originalPos = _this select 1;
_pos = getPosATL _unit;
_playerpos = getPos player;
if (count _this > 2) then {
_pos = _this select 2;
} else {
//_unit enableAI "MOVE";
//_unit enableAI "ANIM";
_chance = round(random 12);
if ((_chance % 4) == 0) then {
//_Offset = [0,0,0];
//_playerworldPos = _playerpos modelToWorld _Offset;
_pos = [_playerpos,30,120,4,0,5,0] call BIS_fnc_findSafePos;
} else {
_pos = [_originalPos,10,90,4,0,5,0] call BIS_fnc_findSafePos;
};
if (_unit distance player > 250) then {
_pos = [_playerpos,120,200,4,0,5,0] call BIS_fnc_findSafePos;
};
};
if(isNull group _unit) then {
_unit moveTo _pos;
} else {
_unit domove _pos;
};
_unit forceSpeed 2;
_unit setVariable ["myDest",_pos];