mirror of
https://github.com/EpochModTeam/DayZ-Epoch.git
synced 2026-02-09 09:42:52 +03:00
0.1
This commit is contained in:
49
dayz_code/compile/building_spawnLoot.sqf
Normal file
49
dayz_code/compile/building_spawnLoot.sqf
Normal file
@@ -0,0 +1,49 @@
|
||||
private["_serial","_positions","_lootGroup","_iArray","_iItem","_iClass","_iPos","_item","_mags","_qty","_max","_tQty","_canType","_obj","_type","_nearBy","_allItems","_items","_itemType","_itemChance","_lootChance","_weights","_index"];
|
||||
_obj = _this select 0;
|
||||
_fastRun = _this select 1;
|
||||
|
||||
_type = typeOf _obj;
|
||||
_config = configFile >> "CfgBuildingLoot" >> _type;
|
||||
|
||||
_positions = [] + getArray (_config >> "lootPos");
|
||||
//diag_log ("LOOTSPAWN: READ:" + str(_type));
|
||||
_lootChance = getNumber (_config >> "lootChance");
|
||||
_itemType = [] + getArray (_config >> "itemType");
|
||||
//diag_log ("LOOTSPAWN: READ:" + str(_itemType));
|
||||
_itemChance = [] + getArray (_config >> "itemChance");
|
||||
|
||||
//diag_log ("LOOTSPAWN: Type " + str(count _itemType) + " / Chance " + str(count _itemChance));
|
||||
|
||||
//diag_log ("I want to spawn loot...");
|
||||
|
||||
{
|
||||
private["_iPos2"];
|
||||
_iPos2 = _obj modelToWorld _x;
|
||||
_rnd = random 1;
|
||||
//Place something at each position
|
||||
if (player distance _iPos2 > 5) then {
|
||||
if (_rnd < _lootChance) then {
|
||||
//if (true) then {
|
||||
_nearBy = nearestObjects [_iPos2, ["WeaponHolder","WeaponHolderBase"],1];
|
||||
if (count _nearBy == 0) then {
|
||||
private["_index","_iArray"];
|
||||
_weights = [_itemType,_itemChance] call fnc_buildWeightedArray;
|
||||
_index = _weights call BIS_fnc_selectRandom;
|
||||
//diag_log ("LOOTSPAWN: _itemType:" + str(_itemType));
|
||||
//diag_log ("LOOTSPAWN: _index:" + str(_index));
|
||||
if (_index >= 0) then {
|
||||
_iArray = +(_itemType select _index);
|
||||
// diag_log ("LOOTSPAWN: _iArray" + str(_iArray));
|
||||
_iArray set [2,_iPos2];
|
||||
_iArray set [3,0];
|
||||
_iArray call spawn_loot;
|
||||
_iArray = [];
|
||||
};
|
||||
_item setVariable ["created",(DateToNumber date),true];
|
||||
};
|
||||
if (!_fastRun) then {
|
||||
sleep 0.1;
|
||||
};
|
||||
};
|
||||
};
|
||||
} forEach _positions;
|
||||
48
dayz_code/compile/building_spawnZombies.sqf
Normal file
48
dayz_code/compile/building_spawnZombies.sqf
Normal file
@@ -0,0 +1,48 @@
|
||||
private["_serial","_positions","_min","_lootGroup","_iArray","_iItem","_iClass","_iPos","_item","_mags","_qty","_max","_tQty","_canType","_obj","_type","_nearBy","_clean","_unitTypes","_max","_isNoone","_config","_num","_originalPos","_zombieChance","_rnd","_fastRun"];
|
||||
_obj = _this select 0;
|
||||
_type = typeOf _obj;
|
||||
_config = configFile >> "CfgBuildingLoot" >> _type;
|
||||
_canLoot = isClass (_config);
|
||||
_fastRun = _this select 1;
|
||||
_originalPos = getPosATL _obj;
|
||||
if (_canLoot) then {
|
||||
//Get zombie class
|
||||
_unitTypes = getArray (_config >> "zombieClass");
|
||||
_min = getNumber (_config >> "maxRoaming");
|
||||
_max = getNumber (_config >> "minRoaming");
|
||||
|
||||
//Walking Zombies
|
||||
_num = round(random _max) max _min; // + round(_max / 3);
|
||||
//diag_log ("Class: " + _type + " / Zombies: " + str(_unitTypes) + " / Walking: " + str(_num));
|
||||
for "_i" from 1 to _num do
|
||||
{
|
||||
[_originalPos,true,_unitTypes] call zombie_generate;
|
||||
if (!_fastRun) then {
|
||||
sleep 0.1;
|
||||
};
|
||||
};
|
||||
|
||||
//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,false,_unitTypes] call zombie_generate;
|
||||
};
|
||||
};
|
||||
if (!_fastRun) then {
|
||||
sleep 0.1;
|
||||
};
|
||||
} forEach _positions;
|
||||
};
|
||||
dayz_buildingMonitor set [count dayz_buildingMonitor,_obj];
|
||||
};
|
||||
56
dayz_code/compile/control_zombieAgent.sqf
Normal file
56
dayz_code/compile/control_zombieAgent.sqf
Normal file
@@ -0,0 +1,56 @@
|
||||
private["_position","_unitTypes","_group","_unit","_target","_bodies","_targetPos","_codeSpawns","_unitSpawn","_lead","_isAlive","_units"];
|
||||
//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;
|
||||
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 6;
|
||||
sleep 1;
|
||||
};
|
||||
//LOOP
|
||||
_agent setVariable ["targets",[],true];
|
||||
_isAlive = alive _agent;
|
||||
sleep 1;
|
||||
};
|
||||
|
||||
//Wait for a while then cleanup
|
||||
sleep 5;
|
||||
deleteVehicle _agent;
|
||||
55
dayz_code/compile/fn_buildWeightedArray.sqf
Normal file
55
dayz_code/compile/fn_buildWeightedArray.sqf
Normal 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 ["_array", "_weights"];
|
||||
_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
|
||||
12
dayz_code/compile/fn_curTimeStr.sqf
Normal file
12
dayz_code/compile/fn_curTimeStr.sqf
Normal file
@@ -0,0 +1,12 @@
|
||||
_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;
|
||||
211
dayz_code/compile/fn_damageActions.sqf
Normal file
211
dayz_code/compile/fn_damageActions.sqf
Normal file
@@ -0,0 +1,211 @@
|
||||
scriptName "Functions\misc\fn_damageActions.sqf";
|
||||
/***********************************************************
|
||||
ADD ACTIONS FOR A CASUALTY
|
||||
- Function
|
||||
- [] call fnc_usec_damageActions;
|
||||
************************************************************/
|
||||
private["_menClose","_unit","_unconscious","_lowBlood","_injured","_inPain","_hasBandage","_hasEpi","_hasMorphine","_hasBlood","_action1","_action2","_action","_vehClose","_hasVehicle","_vehicle","_inVehicle","_crew","_unconscious_crew","_patients"];
|
||||
|
||||
_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 (_hasPatient and !r_drag_sqf and !r_action and !_inVehicle and !r_player_unconscious and _isClose) then {
|
||||
_unit = cursorTarget;
|
||||
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;
|
||||
_hasBandage = "ItemBandage" in magazines player;
|
||||
_hasEpi = "ItemEpinephrine" in magazines player;
|
||||
_hasMorphine = "ItemMorphine" in magazines player;
|
||||
_hasBlood = "ItemBloodbag" in magazines player;
|
||||
_hasToolbox = "ItemToolbox" in items player;
|
||||
_hasJerry = "ItemJerrycan" in magazines player;
|
||||
_hasEtool = "ItemEtool" in weapons player;
|
||||
_hasWire = "ItemWire" in magazines player;
|
||||
_hasPainkillers = "ItemPainkiller" in magazines player;
|
||||
|
||||
//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, "", "'ItemBandage' in magazines player"];
|
||||
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, "", "'ItemMorphine' in magazines player"];
|
||||
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, "", "'ItemPainkiller' in magazines player"];
|
||||
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, "", "'ItemBloodbag' in magazines player"];
|
||||
r_player_actions set [count r_player_actions,_action];
|
||||
};
|
||||
|
||||
//Repairs
|
||||
if ((_unit isKindOf "AllVehicles") and !(_unit isKindOf "Man")) then {
|
||||
_type = TypeOf(_unit);
|
||||
_typeVeh = getText(configFile >> "cfgVehicles" >> _type >> "displayName");
|
||||
|
||||
//CAN WE REFUEL THE OBJECT?
|
||||
if ((fuel _unit < 1) and _hasJerry) then {
|
||||
r_action = true;
|
||||
_action = _unit addAction [format[localize "str_actions_medical_10",_typeVeh], "\z\addons\dayz_code\actions\refuel.sqf",[_unit], 0, true, true, "", "'ItemJerrycan' in magazines player"];
|
||||
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];
|
||||
};
|
||||
};
|
||||
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];
|
||||
};
|
||||
233
dayz_code/compile/fn_damageHandler.sqf
Normal file
233
dayz_code/compile/fn_damageHandler.sqf
Normal file
@@ -0,0 +1,233 @@
|
||||
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","_isBandit","_hit","_damage","_isPlayer","_unconscious","_wound","_isHit","_isInjured","_type","_hitPain","_inPain","_isDead","_isCardiac","_killerID","_evType","_recordable","_inVehicle","_isHeadHit","_isMinor","_scale","_canHitFree"];
|
||||
_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");
|
||||
_inVehicle = (vehicle _unit != _unit);
|
||||
_evType = "";
|
||||
_recordable = false;
|
||||
_isPlayer = (isPlayer _source);
|
||||
_humanityHit = 0;
|
||||
_myKills = 0;
|
||||
_sourceZombie = _source isKindOf "zZombie_base";
|
||||
|
||||
//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;
|
||||
publicVariable "dayzDiscoAdd";
|
||||
dayz_damageCounter = time;
|
||||
|
||||
//Ensure Control is visible
|
||||
_display = uiNamespace getVariable 'DAYZ_GUI_display';
|
||||
_control = _display displayCtrl 1204;
|
||||
_control ctrlShow true;
|
||||
};
|
||||
};
|
||||
*/
|
||||
|
||||
if (_unit == player) then {
|
||||
if (_hit == "") then {
|
||||
if ((_source != player) and _isPlayer) then {
|
||||
_canHitFree = player getVariable ["freeTarget",false];
|
||||
_isBandit = (typeOf player) == "Bandit1_DZ";
|
||||
if (!_canHitFree and !_isBandit) then {
|
||||
_myKills = 200 - (((player getVariable ["humanKills",0]) / 30) * 100);
|
||||
//Process Morality Hit
|
||||
_humanityHit = -(_myKills * _damage);
|
||||
_id = [_source,_humanityHit] spawn {
|
||||
dayzHumanity = [_this select 0,_this select 1,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 (_unit == player) 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 (_unit == player) then {
|
||||
player sideChat str(_damage);
|
||||
};
|
||||
*/
|
||||
if (_damage > 0.1) then {
|
||||
if (_unit == player) 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 (_unit == player) then {
|
||||
_rndPain = (random 10);
|
||||
_rndInfection = (random 1000);
|
||||
_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 (_unit == player) then {
|
||||
r_player_blood = r_player_blood - 50;
|
||||
};
|
||||
};
|
||||
if (_hitInfection) then {
|
||||
//Set Infection if not already
|
||||
if (_unit == player) then {
|
||||
r_player_infected = true;
|
||||
player setVariable["USEC_infected",true,true];
|
||||
};
|
||||
|
||||
};
|
||||
if (_hitPain) then {
|
||||
//Set Pain if not already
|
||||
if (_unit == player) then {
|
||||
r_player_inpain = true;
|
||||
player setVariable["USEC_inPain",true,true];
|
||||
};
|
||||
};
|
||||
if ((_damage > 1.5) and _isHeadHit) then {
|
||||
_id = [_source,"shothead"] spawn player_death;
|
||||
};
|
||||
};
|
||||
if(!_isHit) 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 ((_unit == player) 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 (_unit == player) then {
|
||||
r_player_injured = true;
|
||||
};
|
||||
};
|
||||
};
|
||||
if (_type == 1) then {
|
||||
/*
|
||||
BALISTIC DAMAGE
|
||||
*/
|
||||
if ((_damage > 0.01) and (_unit == player)) then {
|
||||
//affect the player
|
||||
[20,45] call fnc_usec_pitchWhine; //Visual , Sound
|
||||
};
|
||||
if (_damage > 4) then {
|
||||
//serious ballistic damage
|
||||
if (_unit == player) then {
|
||||
_id = [_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 (_unit == player) then {
|
||||
_id = [_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;
|
||||
};
|
||||
25
dayz_code/compile/fn_damageHandlerVehicle.sqf
Normal file
25
dayz_code/compile/fn_damageHandlerVehicle.sqf
Normal file
@@ -0,0 +1,25 @@
|
||||
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","_unconscious","_wound","_isHit","_isInjured","_type","_hitPain","_inPain","_isDead","_isCardiac","_killerID","_evType","_recordable","_inVehicle","_isHeadHit","_isMinor","_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 {
|
||||
if (_ammo == "zombie") then {
|
||||
//_unit setDamage (_damage / 2);
|
||||
_total = [_unit,_hit,_damage] call object_setFixServer;
|
||||
} else {
|
||||
_total = [_unit,_hit,_damage] call object_setHitServer;
|
||||
};
|
||||
};
|
||||
_total
|
||||
33
dayz_code/compile/fn_damageHandlerZ.sqf
Normal file
33
dayz_code/compile/fn_damageHandlerZ.sqf
Normal 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
|
||||
39
dayz_code/compile/fn_inAngleSector.sqf
Normal file
39
dayz_code/compile/fn_inAngleSector.sqf
Normal 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
|
||||
59
dayz_code/compile/fn_inString.sqf
Normal file
59
dayz_code/compile/fn_inString.sqf
Normal file
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
File: inString.sqf
|
||||
Author: Mika Hannola
|
||||
|
||||
Description:
|
||||
Find a string within a string.
|
||||
|
||||
Parameter(s):
|
||||
_this select 0: BOOL - when true, displays all units, otherwise just player positions
|
||||
_this select 0: <string> string to be found
|
||||
_this select 1: <string> string to search from
|
||||
_this select 2 (Optional): search is case sensitive (default: false)
|
||||
|
||||
Returns:
|
||||
Boolean (true when string is found).
|
||||
|
||||
How to use:
|
||||
BIS_fnc_inString = compile preprocessFile "inString.sqf"; //Compile the function
|
||||
_found = ["string","String",true] call BIS_fnc_inString; //Find a string within a string
|
||||
*/
|
||||
|
||||
private ["_casesensitive","_find","_string","_findarray","_stringarray","_findcount","_stringcount","_found","_match","_y","_i","_x"];
|
||||
|
||||
_find = _this select 0;
|
||||
_string = _this select 1;
|
||||
|
||||
//modification : default _casesensitive is false
|
||||
_casesensitive = false;
|
||||
if(count(_this) > 2) then {_casesensitive = _this select 2;};
|
||||
|
||||
_findarray = toArray _find;
|
||||
_stringarray = toArray _string;
|
||||
_findcount = count _findarray;
|
||||
_stringcount = count _stringarray;
|
||||
_found = false;
|
||||
|
||||
scopeName "main";
|
||||
if (_findcount <= _stringcount and !_found) then
|
||||
{
|
||||
for "_y" from 0 to (_stringcount - _findcount) do
|
||||
{
|
||||
_match = [];
|
||||
for "_i" from 0 to (_findcount - 1) do
|
||||
{
|
||||
_match set [count _match,_stringarray select (_y + _i)];
|
||||
};
|
||||
_found = true;
|
||||
_i = 0;
|
||||
{
|
||||
if (_x != _match select _i) then
|
||||
{
|
||||
_found = false;
|
||||
};
|
||||
_i = _i + 1;
|
||||
} forEach _findarray;
|
||||
if (_found) then {breakTo "main";};
|
||||
};
|
||||
};
|
||||
_found;
|
||||
36
dayz_code/compile/fn_isInsideBuilding.sqf
Normal file
36
dayz_code/compile/fn_isInsideBuilding.sqf
Normal file
@@ -0,0 +1,36 @@
|
||||
private["_unit1","_building","_type","_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
|
||||
51
dayz_code/compile/fn_motherrequest.sqf
Normal file
51
dayz_code/compile/fn_motherrequest.sqf
Normal file
@@ -0,0 +1,51 @@
|
||||
/***********************************************************
|
||||
REQUEST FROM hive
|
||||
- Function
|
||||
- result = [_key] call fnc_usec_hive_request;
|
||||
************************************************************/
|
||||
private["_key","_pipe","_result","_resultArray","_buildings","_stream","_data","_attempt"];
|
||||
_key = _this select 0;
|
||||
_confirm = _this select 1;
|
||||
_resultArray = [];
|
||||
hiveContact = true;
|
||||
_attempt = 0;
|
||||
|
||||
//startLoadingScreen ["Accessing hive"];
|
||||
//diag_log format ["hive: Request: %1", _key];
|
||||
while {true} do {
|
||||
//Wait until not in use
|
||||
scopeName "usePipe";
|
||||
while {true} do {
|
||||
scopeName "pipeWaiting5";
|
||||
_pipe = [dayZ_hivePipe1] call jayarma2lib_fnc_openpipe;
|
||||
if ((_pipe != "_JERR_PIPE_INVALID")) then {breakOut "pipeWaiting5";};
|
||||
};
|
||||
//Send Key
|
||||
_ret = [_pipe, _key] call jayarma2lib_fnc_writepipe;
|
||||
//Wait until hive replies
|
||||
while {true} do {
|
||||
scopeName "pipeWaiting6";
|
||||
_data = [_pipe] call jayarma2lib_fnc_readpipe;
|
||||
if (!(isNil "_data") and (_data != "_JERR_NULL")) then {breakOut "pipeWaiting6";};
|
||||
};
|
||||
//Release hive
|
||||
[_pipe] call jayarma2lib_fnc_closepipe;
|
||||
//Do we have an answer?
|
||||
if(_data == "_JERR_FALSE" and _confirm) then {
|
||||
if (_attempt > 10) then {
|
||||
breakOut "usePipe";
|
||||
} else {
|
||||
//Retry the read
|
||||
diag_log format ["hive: Failed with: %1, Retrying", _data];
|
||||
};
|
||||
} else {
|
||||
breakOut "usePipe";
|
||||
};
|
||||
_attempt = _attempt + 1;
|
||||
};
|
||||
//diag_log format ["hive: Received: %1", _data];
|
||||
//endLoadingScreen;
|
||||
|
||||
//Return information
|
||||
_resultArray = call compile format ["%1",_data];
|
||||
_resultArray;
|
||||
70
dayz_code/compile/fn_motherrequest_dual.sqf
Normal file
70
dayz_code/compile/fn_motherrequest_dual.sqf
Normal file
@@ -0,0 +1,70 @@
|
||||
/***********************************************************
|
||||
REQUEST FROM hive
|
||||
- Function
|
||||
- result = [_key] call fnc_usec_hive_request;
|
||||
************************************************************/
|
||||
private["_key","_pipe","_result","_resultArray","_buildings","_stream","_data","_attempt","_result1","_result2"];
|
||||
_key = _this select 0;
|
||||
_confirm = _this select 1;
|
||||
_resultArray = [];
|
||||
hiveContact = true;
|
||||
_attempt = 0;
|
||||
_result1 = "";
|
||||
_result2 = "";
|
||||
|
||||
//startLoadingScreen ["Accessing hive"];
|
||||
//diag_log format ["hive: Request: %1", _key];
|
||||
while {true} do {
|
||||
//Wait until not in use
|
||||
scopeName "usePipe";
|
||||
while {true} do {
|
||||
scopeName "pipeWaiting5";
|
||||
_pipe = [dayZ_hivePipe1] call jayarma2lib_fnc_openpipe;
|
||||
if ((_pipe != "_JERR_PIPE_INVALID")) then {breakOut "pipeWaiting5";};
|
||||
};
|
||||
//Send Key
|
||||
_ret = [_pipe, _key] call jayarma2lib_fnc_writepipe;
|
||||
//Wait until hive replies
|
||||
while {true} do {
|
||||
scopeName "pipeWaiting6";
|
||||
_data = [_pipe] call jayarma2lib_fnc_readpipe;
|
||||
if (!(isNil "_data") and (_data != "_JERR_NULL")) then {breakOut "pipeWaiting6";};
|
||||
};
|
||||
|
||||
_result1 = call compile format ["%1",_data];
|
||||
|
||||
_ret = [_pipe, "['OK']"] call jayarma2lib_fnc_writepipe;
|
||||
_data = "";
|
||||
|
||||
//Send Key
|
||||
_ret = [_pipe, _key] call jayarma2lib_fnc_writepipe;
|
||||
//Wait until hive replies
|
||||
while {true} do {
|
||||
scopeName "pipeWaiting6";
|
||||
_data = [_pipe] call jayarma2lib_fnc_readpipe;
|
||||
if (!(isNil "_data") and (_data != "_JERR_NULL")) then {breakOut "pipeWaiting6";};
|
||||
};
|
||||
|
||||
_result2 = call compile format ["%1",_data];
|
||||
|
||||
//Release hive
|
||||
[_pipe] call jayarma2lib_fnc_closepipe;
|
||||
//Do we have an answer?
|
||||
if(_data == "_JERR_FALSE" and _confirm) then {
|
||||
if (_attempt > 10) then {
|
||||
breakOut "usePipe";
|
||||
} else {
|
||||
//Retry the read
|
||||
diag_log format ["hive: Failed with: %1, Retrying", _data];
|
||||
};
|
||||
} else {
|
||||
breakOut "usePipe";
|
||||
};
|
||||
_attempt = _attempt + 1;
|
||||
};
|
||||
//diag_log format ["hive: Received: %1", _data];
|
||||
//endLoadingScreen;
|
||||
|
||||
//Return information
|
||||
_resultArray = _result1;
|
||||
_resultArray;
|
||||
53
dayz_code/compile/fn_motherrequest_spawn.sqf
Normal file
53
dayz_code/compile/fn_motherrequest_spawn.sqf
Normal file
@@ -0,0 +1,53 @@
|
||||
/***********************************************************
|
||||
REQUEST FROM hive
|
||||
- Function
|
||||
- result = [_key] call fnc_usec_hive_request;
|
||||
************************************************************/
|
||||
private["_key","_pipe","_result","_resultArray","_buildings","_stream","_data","_attempt"];
|
||||
_key = _this select 0;
|
||||
_confirm = _this select 1;
|
||||
dayz_resultArray = [];
|
||||
hiveContact = true;
|
||||
_attempt = 0;
|
||||
|
||||
//startLoadingScreen ["Accessing hive"];
|
||||
//diag_log format ["hive: Request: %1", _key];
|
||||
while {true} do {
|
||||
//Wait until not in use
|
||||
scopeName "usePipe";
|
||||
while {true} do {
|
||||
scopeName "pipeWaiting5";
|
||||
_pipe = [dayZ_hivePipe1] call jayarma2lib_fnc_openpipe;
|
||||
if ((_pipe != "_JERR_PIPE_INVALID")) then {breakOut "pipeWaiting5";};
|
||||
};
|
||||
sleep 0.1;
|
||||
//Send Key
|
||||
_ret = [_pipe, _key] call jayarma2lib_fnc_writepipe;
|
||||
//Wait until hive replies
|
||||
while {true} do {
|
||||
scopeName "pipeWaiting6";
|
||||
_data = [_pipe] call jayarma2lib_fnc_readpipe;
|
||||
if (!(isNil "_data") and (_data != "_JERR_NULL")) then {breakOut "pipeWaiting6";};
|
||||
sleep 0.01;
|
||||
};
|
||||
sleep 0.1;
|
||||
//Release hive
|
||||
[_pipe] call jayarma2lib_fnc_closepipe;
|
||||
//Do we have an answer?
|
||||
if(_data == "_JERR_FALSE" and _confirm) then {
|
||||
if (_attempt > 10) then {
|
||||
breakOut "usePipe";
|
||||
} else {
|
||||
//Retry the read
|
||||
diag_log format ["hive: Failed with: %1, Retrying", _data];
|
||||
};
|
||||
} else {
|
||||
breakOut "usePipe";
|
||||
};
|
||||
_attempt = _attempt + 1;
|
||||
};
|
||||
//diag_log format ["hive: Received: %1", _data];
|
||||
//endLoadingScreen;
|
||||
|
||||
//Return information
|
||||
dayz_resultArray = call compile format ["%1",_data];
|
||||
23
dayz_code/compile/fn_selectRandom.sqf
Normal file
23
dayz_code/compile/fn_selectRandom.sqf
Normal 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
|
||||
59
dayz_code/compile/fn_selectRandomWeighted.sqf
Normal file
59
dayz_code/compile/fn_selectRandomWeighted.sqf
Normal 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","_i"];
|
||||
_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
|
||||
227
dayz_code/compile/fn_selfActions.sqf
Normal file
227
dayz_code/compile/fn_selfActions.sqf
Normal file
@@ -0,0 +1,227 @@
|
||||
scriptName "Functions\misc\fn_selfActions.sqf";
|
||||
/***********************************************************
|
||||
ADD ACTIONS FOR SELF
|
||||
- Function
|
||||
- [] call fnc_usec_selfActions;
|
||||
************************************************************/
|
||||
private["_menClose","_hasBandage","_hasEpi","_hasMorphine","_hasBlood","_vehicle","_inVehicle","_color","_part"];
|
||||
|
||||
_vehicle = vehicle player;
|
||||
_inVehicle = (_vehicle != player);
|
||||
_bag = unitBackpack player;
|
||||
_classbag = typeOf _bag;
|
||||
_isWater = (surfaceIsWater (position player)) or dayz_isSwimming;
|
||||
_hasAntiB = "ItemAntibiotic" in magazines player;
|
||||
_hasFuelE = "ItemJerrycanEmpty" in magazines player;
|
||||
_hasRawMeat = "FoodSteakRaw" in magazines player;
|
||||
_hasKnife = "ItemKnife" in items player;
|
||||
_hasToolbox = "ItemToolbox" in items player;
|
||||
//_hasTent = "ItemTent" in items player;
|
||||
_onLadder = (getNumber (configFile >> "CfgMovesMaleSdr" >> "States" >> (animationState player) >> "onLadder")) == 1;
|
||||
_nearLight = nearestObject [player,"LitObject"];
|
||||
_canPickLight = false;
|
||||
|
||||
if (!isNull _nearLight) then {
|
||||
if (_nearLight distance player < 4) then {
|
||||
_canPickLight = isNull (_nearLight getVariable ["owner",objNull]);
|
||||
};
|
||||
};
|
||||
_canDo = (!r_drag_sqf and !r_player_unconscious and !_onLadder);
|
||||
|
||||
//Grab Flare
|
||||
if (_canPickLight and !dayz_hasLight) 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 (!isNull cursorTarget and !_inVehicle and (player distance cursorTarget < 4)) then { //Has some kind of target
|
||||
_isHarvested = cursorTarget getVariable["meatHarvested",false];
|
||||
_isVehicle = cursorTarget isKindOf "AllVehicles";
|
||||
_isMan = cursorTarget isKindOf "Man";
|
||||
_ownerID = cursorTarget getVariable ["characterID","0"];
|
||||
_isAnimal = cursorTarget isKindOf "Animal";
|
||||
_isZombie = cursorTarget isKindOf "zZombie_base";
|
||||
_isDestructable = cursorTarget isKindOf "BuiltItems";
|
||||
_isTent = cursorTarget isKindOf "TentStorage";
|
||||
_isFuel = false;
|
||||
_isAlive = alive cursorTarget;
|
||||
_text = getText (configFile >> "CfgVehicles" >> typeOf cursorTarget >> "displayName");
|
||||
if (_hasFuelE) then {
|
||||
_isFuel = (cursorTarget isKindOf "Land_Ind_TankSmall") or (cursorTarget isKindOf "Land_fuel_tank_big") or (cursorTarget isKindOf "Land_fuel_tank_stairs") or (cursorTarget isKindOf "Land_fuel_tank_stairs_ep1") or (cursorTarget isKindOf "Land_wagon_tanker") or (cursorTarget isKindOf "Land_fuelstation") or (cursorTarget isKindOf "Land_fuelstation_army");
|
||||
};
|
||||
//diag_log ("OWNERID = " + _ownerID + " CHARID = " + dayz_characterID + " " + str(_ownerID == dayz_characterID));
|
||||
|
||||
//Allow player to delete objects
|
||||
if(_isDestructable and _hasToolbox and _canDo) 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 player to force save
|
||||
if((_isVehicle or _isTent) and _canDo 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;
|
||||
};
|
||||
*/
|
||||
|
||||
//Allow player to fill jerrycan
|
||||
if(_hasFuelE and _isFuel and _canDo) 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;
|
||||
};
|
||||
|
||||
if (!alive cursorTarget and _isAnimal and _hasKnife and !_isHarvested and _canDo) then {
|
||||
if (s_player_butcher < 0) then {
|
||||
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 and _canDo) 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(cursorTarget == dayz_hasFire and _canDo) 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;
|
||||
};
|
||||
|
||||
//place tent
|
||||
//if(_hasTent and _canDo) then {
|
||||
// s_player_placetent = player addAction [localize "Place Tent", "\z\addons\dayz_code\actions\tent_pitch.sqf",cursorTarget, 0, false, true, "", ""];
|
||||
//} else {
|
||||
// player removeAction s_player_placetent;
|
||||
// s_player_placetent = -1;
|
||||
//};
|
||||
|
||||
//Packing my tent
|
||||
if(cursorTarget isKindOf "TentStorage" and _canDo 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;
|
||||
};
|
||||
|
||||
//Repairing Vehicles
|
||||
if ((dayz_myCursorTarget != cursorTarget) and !_isMan and _hasToolbox and (damage cursorTarget < 1)) then {
|
||||
_vehicle = cursorTarget;
|
||||
{dayz_myCursorTarget removeAction _x} forEach s_player_repairActions;s_player_repairActions = [];
|
||||
dayz_myCursorTarget = _vehicle;
|
||||
|
||||
_allFixed = true;
|
||||
_hitpoints = _vehicle call vehicle_getHitpoints;
|
||||
|
||||
{
|
||||
_damage = [_vehicle,_x] call object_getHit;
|
||||
_part = "PartGeneric";
|
||||
|
||||
//change "HitPart" to " - Part" rather than complicated string replace
|
||||
_cmpt = toArray (_x);
|
||||
_cmpt set [0,20];
|
||||
_cmpt set [1,toArray ("-") select 0];
|
||||
_cmpt set [2,20];
|
||||
_cmpt = toString _cmpt;
|
||||
|
||||
if(["Engine",_x,false] call fnc_inString) then {
|
||||
_part = "PartEngine";
|
||||
};
|
||||
|
||||
if(["HRotor",_x,false] call fnc_inString) then {
|
||||
_part = "PartVRotor"; //yes you need PartVRotor to fix HRotor LOL
|
||||
};
|
||||
|
||||
if(["Fuel",_x,false] call fnc_inString) then {
|
||||
_part = "PartFueltank";
|
||||
};
|
||||
|
||||
if(["Wheel",_x,false] call fnc_inString) then {
|
||||
_part = "PartWheel";
|
||||
};
|
||||
|
||||
if(["Glass",_x,false] call fnc_inString) then {
|
||||
_part = "PartGlass";
|
||||
};
|
||||
|
||||
// get every damaged part no matter how tiny damage is!
|
||||
if (_damage > 0) then {
|
||||
|
||||
_allFixed = false;
|
||||
_color = "color='#ffff00'"; //yellow
|
||||
if (_damage >= 0.5) then {_color = "color='#ff8800'";}; //orange
|
||||
if (_damage >= 0.9) then {_color = "color='#ff0000'";}; //red
|
||||
|
||||
_string = format["<t %2>Repair%1</t>",_cmpt,_color]; //Repair - Part
|
||||
_handle = dayz_myCursorTarget addAction [_string, "\z\addons\dayz_code\actions\repair.sqf",[_vehicle,_part,_x], 0, false, true, "",""];
|
||||
s_player_repairActions set [count s_player_repairActions,_handle];
|
||||
};
|
||||
|
||||
} forEach _hitpoints;
|
||||
if (_allFixed) then {
|
||||
_vehicle setDamage 0;
|
||||
};
|
||||
};
|
||||
|
||||
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;
|
||||
};
|
||||
} else {
|
||||
//Engineering
|
||||
{dayz_myCursorTarget removeAction _x} forEach s_player_repairActions;s_player_repairActions = [];
|
||||
dayz_myCursorTarget = objNull;
|
||||
//Others
|
||||
player removeAction s_player_forceSave;
|
||||
s_player_forceSave = -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_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;
|
||||
};
|
||||
124
dayz_code/compile/fn_setpitchbank.sqf
Normal file
124
dayz_code/compile/fn_setpitchbank.sqf
Normal 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];
|
||||
22
dayz_code/compile/fn_sunRise.sqf
Normal file
22
dayz_code/compile/fn_sunRise.sqf
Normal 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"];
|
||||
_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
|
||||
20
dayz_code/compile/fn_surfaceNoise.sqf
Normal file
20
dayz_code/compile/fn_surfaceNoise.sqf
Normal file
@@ -0,0 +1,20 @@
|
||||
//Assess Terrain
|
||||
private["_unit","_pos","_type","_typeA","_soundType","_soundVal","_array","_test"];
|
||||
_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
|
||||
156
dayz_code/compile/fn_temperatur.sqf
Normal file
156
dayz_code/compile/fn_temperatur.sqf
Normal file
@@ -0,0 +1,156 @@
|
||||
/*
|
||||
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","_difference","_hasfireffect","_isinbuilding","_isinvehicle","_raining","_sunrise","_building"];
|
||||
|
||||
_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 1;
|
||||
};
|
||||
|
||||
//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)²
|
||||
II: t = -a * (d - 12)² + f
|
||||
|
||||
I + II =>
|
||||
|
||||
t = -(f / (12 - s)²) * (d - 12)² + 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_factor;
|
||||
};
|
||||
|
||||
//night
|
||||
private ["_daytime"];
|
||||
if((daytime < _sunrise || daytime < (24 - _sunrise)) && !_isinvehicle && !_isinbuilding) then {
|
||||
_daytime = if(daytime < 12) then {daytime + 24} else {daytime};
|
||||
_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;
|
||||
};
|
||||
|
||||
//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
|
||||
};
|
||||
99
dayz_code/compile/fn_unconscious.sqf
Normal file
99
dayz_code/compile/fn_unconscious.sqf
Normal file
@@ -0,0 +1,99 @@
|
||||
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;
|
||||
localize "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 _unit != _unit);
|
||||
_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];
|
||||
localize "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;
|
||||
};
|
||||
66
dayz_code/compile/local_createObj.sqf
Normal file
66
dayz_code/compile/local_createObj.sqf
Normal file
@@ -0,0 +1,66 @@
|
||||
private["_type","_location","_dir","_character","_tent","_class","_id"];
|
||||
//[dayz_characterID,_tent,[_dir,_location],"TentStorage"]
|
||||
_class = _this select 3;
|
||||
_location = getPosATL player;
|
||||
_dir = getDir player;
|
||||
player allowdamage false;
|
||||
diag_log ("PUBLISH: Attempt " + _class);
|
||||
_worldspace = [_dir,_location];
|
||||
|
||||
_object = createVehicle [_class, _location, [], 0, "CAN_COLLIDE"];
|
||||
_object setdir _dir;
|
||||
_object setpos _location;
|
||||
_object setVariable ["CharacterID", "0", true];
|
||||
sleep 1;
|
||||
_dam = 1;
|
||||
_hitpoints = _object call vehicle_getHitpoints;
|
||||
_object setFuel 0;
|
||||
{
|
||||
_selection = getText(configFile >> "cfgVehicles" >> _class >> "HitPoints" >> _x >> "name");
|
||||
if (_x != "HitEngine" and _x != "HitFuel") then {
|
||||
_dam = 1;
|
||||
} else {
|
||||
_dam = 0.85;
|
||||
};
|
||||
[_object,_selection,_dam] call object_setFixServer;
|
||||
//_object setHit[_selection,1];
|
||||
} forEach _hitpoints;
|
||||
_object setvelocity [1,0,0];
|
||||
player reveal _object;
|
||||
|
||||
//Send request
|
||||
|
||||
_array = [];
|
||||
_dam = 1;
|
||||
{
|
||||
_hit = [_object,_x] call object_getHit;
|
||||
_selection = getText (configFile >> "CfgVehicles" >> _class >> "HitPoints" >> _x >> "name");
|
||||
if (_hit > 0) then {_array set [count _array,[_selection,_hit]]};
|
||||
} forEach _hitpoints;
|
||||
|
||||
//add to database
|
||||
dayz_serverObjectMonitor set [count dayz_serverObjectMonitor,_object];
|
||||
|
||||
//Send request
|
||||
//61 to 120
|
||||
//207 to 208
|
||||
for "_x" from 61 to 120 do {
|
||||
_key = format["CHILD:301:%1:%2:%3:%4:%5:%6:%7:%8:",_x, _class, 0 , 0, _worldspace, [], _array, 0];
|
||||
diag_log ("HIVE: WRITE: "+ str(_key));
|
||||
_key call server_hiveWrite;
|
||||
//sleep 0.5;
|
||||
/*
|
||||
waitUntil{!hiveInUse};
|
||||
hiveInUse = true;
|
||||
//Send request
|
||||
_primary = [_key,false,dayZ_hivePipeAuth] call server_hiveReadWrite;
|
||||
hiveInUse = false;
|
||||
*/
|
||||
};
|
||||
|
||||
diag_log ("PUBLISH: Result " + str(_result));
|
||||
if (count _result > 1) then {
|
||||
_id = _result select 1;
|
||||
_object setVariable ["ObjectID", _id, true];
|
||||
diag_log ("PUBLISH: Created " + (_class) + " with ID " + str(_id));
|
||||
};
|
||||
22
dayz_code/compile/local_deleteObj.sqf
Normal file
22
dayz_code/compile/local_deleteObj.sqf
Normal file
@@ -0,0 +1,22 @@
|
||||
/*
|
||||
[_objectID,_objectUID] call local_deleteObj;
|
||||
*/
|
||||
private["_id","_uid","_key"];
|
||||
_id = _this select 0;
|
||||
_uid = _this select 1;
|
||||
|
||||
if (isServer) then {
|
||||
//remove from database
|
||||
if (parseNumber _id > 0) then {
|
||||
//Send request
|
||||
_key = format["CHILD:304:%1:",_id];
|
||||
_key call server_hiveWrite;
|
||||
diag_log format["DELETE: Deleted by ID: %1",_id];
|
||||
};
|
||||
if (parseNumber _uid > 0) then {
|
||||
//Send request
|
||||
_key = format["CHILD:310:%1:",_uid];
|
||||
_key call server_hiveWrite;
|
||||
diag_log format["DELETE: Deleted by UID: %1",_uid];
|
||||
};
|
||||
};
|
||||
14
dayz_code/compile/local_eventKill.sqf
Normal file
14
dayz_code/compile/local_eventKill.sqf
Normal 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];
|
||||
};
|
||||
23
dayz_code/compile/local_gutObject.sqf
Normal file
23
dayz_code/compile/local_gutObject.sqf
Normal file
@@ -0,0 +1,23 @@
|
||||
private["_qty","_item","_meat"];
|
||||
_item = _this select 0;
|
||||
_qty = _this select 1;
|
||||
_meat = 0;
|
||||
_loop = true;
|
||||
if (local _item) then {
|
||||
for "_x" from 1 to _qty do {
|
||||
_item addMagazine "FoodSteakRaw";
|
||||
};
|
||||
sleep 2;
|
||||
_timer = time;
|
||||
while {_loop} do {
|
||||
_meat = count magazines _item;
|
||||
if (_meat == 0) then {_loop = false};
|
||||
if ((time - _timer) > 300) then {_loop = false};
|
||||
sleep 1;
|
||||
};
|
||||
dayzHideBody = _item;
|
||||
publicVariable "dayzHideBody";
|
||||
hideBody _item;
|
||||
sleep 10;
|
||||
deleteVehicle _item;
|
||||
};
|
||||
31
dayz_code/compile/local_publishObj.sqf
Normal file
31
dayz_code/compile/local_publishObj.sqf
Normal file
@@ -0,0 +1,31 @@
|
||||
private["_type","_location","_dir","_character","_tent","_class","_id"];
|
||||
//[dayz_characterID,_tent,[_dir,_location],"TentStorage"]
|
||||
_charID = _this select 0;
|
||||
_object = _this select 1;
|
||||
_worldspace = _this select 2;
|
||||
_class = _this select 3;
|
||||
_id = 0;
|
||||
|
||||
diag_log ("PUBLISH: Attempt " + str(_object));
|
||||
_dir = _worldspace select 0;
|
||||
_location = _worldspace select 1;
|
||||
|
||||
_object = createVehicle [_class, _location, [], 0, "CAN_COLLIDE"];
|
||||
_object setdir _dir;
|
||||
_object setpos _location;
|
||||
_object setVariable ["OwnerID", _charID, true];
|
||||
|
||||
//add to database
|
||||
dayz_serverObjectMonitor set [count dayz_serverObjectMonitor,_object];
|
||||
|
||||
//get UID
|
||||
_uid = _object call dayz_objectUID;
|
||||
|
||||
//Send request
|
||||
_key = format["CHILD:308:%1:%2:%3:%4:%5:%6:%7:%8:%9:",dayZ_instance, _class, 0 , _charID, _worldspace, [], [], 0,_uid];
|
||||
diag_log ("HIVE: WRITE: "+ str(_key));
|
||||
_key call server_hiveWrite;
|
||||
|
||||
_object setVariable ["ObjectUID", _uid, true];
|
||||
|
||||
diag_log ("PUBLISH: Created " + (_class) + " with ID " + _uid);
|
||||
5
dayz_code/compile/local_setFuel.sqf
Normal file
5
dayz_code/compile/local_setFuel.sqf
Normal file
@@ -0,0 +1,5 @@
|
||||
private["_qty","_vehicle"];
|
||||
_vehicle = _this select 0;
|
||||
_qty = _this select 1;
|
||||
|
||||
_vehicle setFuel _qty;
|
||||
57
dayz_code/compile/object_cargoCheck.sqf
Normal file
57
dayz_code/compile/object_cargoCheck.sqf
Normal file
@@ -0,0 +1,57 @@
|
||||
private["_currentObjects","_currentTypes","_currentQty","_previousTypes","_previousQty","_serial","_itemVal","_itemQty","_oldSerial","_oldQty"];
|
||||
//_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
|
||||
9
dayz_code/compile/object_delLocal.sqf
Normal file
9
dayz_code/compile/object_delLocal.sqf
Normal 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};
|
||||
};
|
||||
7
dayz_code/compile/object_getHit.sqf
Normal file
7
dayz_code/compile/object_getHit.sqf
Normal 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
|
||||
38
dayz_code/compile/object_processHit.sqf
Normal file
38
dayz_code/compile/object_processHit.sqf
Normal file
@@ -0,0 +1,38 @@
|
||||
private["_unit","_hp","_selection","_strH","_dam","_display"];
|
||||
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;
|
||||
};
|
||||
};
|
||||
43
dayz_code/compile/object_roadFlare.sqf
Normal file
43
dayz_code/compile/object_roadFlare.sqf
Normal file
@@ -0,0 +1,43 @@
|
||||
private["_flare","_sfx","_isLocal","_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;
|
||||
};
|
||||
};
|
||||
};
|
||||
23
dayz_code/compile/object_setFixServer.sqf
Normal file
23
dayz_code/compile/object_setFixServer.sqf
Normal file
@@ -0,0 +1,23 @@
|
||||
private["_unit","_selection","_strH","_dam","_total"];
|
||||
_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 {
|
||||
dayzUpdateVehicle = [_unit,"repair"];
|
||||
} else {
|
||||
dayzUpdateVehicle = [_unit,"damage"];
|
||||
};
|
||||
if (isServer) then {
|
||||
if (allowConnection) then {
|
||||
dayzUpdateVehicle call server_updateObject;
|
||||
};
|
||||
} else {
|
||||
publicVariable "dayzUpdateVehicle";
|
||||
};
|
||||
};
|
||||
13
dayz_code/compile/object_setHit.sqf
Normal file
13
dayz_code/compile/object_setHit.sqf
Normal 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
|
||||
16
dayz_code/compile/object_setHitLocal.sqf
Normal file
16
dayz_code/compile/object_setHitLocal.sqf
Normal 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
|
||||
28
dayz_code/compile/object_setHitServer.sqf
Normal file
28
dayz_code/compile/object_setHitServer.sqf
Normal file
@@ -0,0 +1,28 @@
|
||||
private["_unit","_selection","_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"];
|
||||
if (isServer) then {
|
||||
if (allowConnection) then {
|
||||
dayzUpdateVehicle call server_updateObject;
|
||||
};
|
||||
} else {
|
||||
publicVariable "dayzUpdateVehicle";
|
||||
};
|
||||
};
|
||||
|
||||
} else {
|
||||
_damage = 0;
|
||||
};
|
||||
_damage
|
||||
45
dayz_code/compile/object_spawnDamVehicle.sqf
Normal file
45
dayz_code/compile/object_spawnDamVehicle.sqf
Normal file
@@ -0,0 +1,45 @@
|
||||
private["_car","_hitpoints","_dam","_selection","_type","_pos","_dir"];
|
||||
_type = _this select 0;
|
||||
_pos = _this select 1;
|
||||
_dir = _this select 2;
|
||||
_car = _type createVehicle _pos;
|
||||
_car setpos _pos;
|
||||
_car setdir _dir;
|
||||
_hitpoints = _car call vehicle_getHitpoints;
|
||||
_dam = 1;
|
||||
_car setFuel 0;
|
||||
{
|
||||
_selection = getText(configFile >> "cfgVehicles" >> typeOf _car >> "HitPoints" >> _x >> "name");
|
||||
if (_x != "HitEngine" and _x != "HitFuel") then {
|
||||
_dam = 1;
|
||||
} else {
|
||||
_dam = 0.85;
|
||||
};
|
||||
[_car,_selection,_dam] call object_setFixServer;
|
||||
} forEach _hitpoints;
|
||||
_car setvelocity [1,0,0];
|
||||
player reveal _car;
|
||||
dayzVehicleInit = _car;
|
||||
publicVariable "dayzVehicleInit";
|
||||
if (isServer) then {
|
||||
_car call fnc_vehicleEventHandler;
|
||||
[0,_car,[_dir,_pos],_type] call local_publishObj;
|
||||
};
|
||||
|
||||
//Wait for HIVE to be free
|
||||
waitUntil{!hiveInUse};
|
||||
hiveInUse = true;
|
||||
|
||||
//Send request
|
||||
_hitpoints = _car call vehicle_getHitpoints;
|
||||
_array = [];
|
||||
_dam = 1;
|
||||
{
|
||||
_hit = [_car,_x] call object_getHit;
|
||||
_selection = getText (configFile >> "CfgVehicles" >> (typeOf _car) >> "HitPoints" >> _x >> "name");
|
||||
if (_hit > 0) then {_array set [count _array,[_selection,_hit]]};
|
||||
} forEach _hitpoints;
|
||||
|
||||
copyToClipboard str(_array);
|
||||
|
||||
_car
|
||||
44
dayz_code/compile/object_speak.sqf
Normal file
44
dayz_code/compile/object_speak.sqf
Normal file
@@ -0,0 +1,44 @@
|
||||
private["_unit","_type","_chance","_rnd","_sound","_local","_dis"];
|
||||
_unit = _this select 0;
|
||||
_type = _this select 1;
|
||||
_chance = _this select 2;
|
||||
_local = _this select 3;
|
||||
_dis = 40;
|
||||
|
||||
_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 (_type in ["shout","hit","attack","scream","breath"]) then {
|
||||
_dis = 100;
|
||||
};
|
||||
|
||||
_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;
|
||||
};
|
||||
};
|
||||
10
dayz_code/compile/object_updatePosition.sqf
Normal file
10
dayz_code/compile/object_updatePosition.sqf
Normal 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];
|
||||
};
|
||||
10
dayz_code/compile/object_vehicleKilled.sqf
Normal file
10
dayz_code/compile/object_vehicleKilled.sqf
Normal file
@@ -0,0 +1,10 @@
|
||||
private["_unit","_selection","_strH","_dam","_total"];
|
||||
_unit = _this select 0;
|
||||
_killer = _this select 1;
|
||||
_type = typeOf _unit;
|
||||
_pos = getposATL _unit;
|
||||
_dir = direction _unit;
|
||||
if (local _unit) then {
|
||||
deleteVehicle _unit;
|
||||
// [_type,_pos,_dir] spawn object_spawnDamVehicle;
|
||||
};
|
||||
22
dayz_code/compile/player_alertZombies.sqf
Normal file
22
dayz_code/compile/player_alertZombies.sqf
Normal file
@@ -0,0 +1,22 @@
|
||||
private["_unit","_distance","_i","_listTalk","_zombie","_targets","_pos"];
|
||||
//Alert Zed's to noise of shot
|
||||
_pos = _this select 0;
|
||||
_distance = _this select 1;
|
||||
_doRun = _this select 2;
|
||||
_pos = _this select 3;
|
||||
_listTalk = _pos nearEntities ["zZombie_Base",_distance];
|
||||
|
||||
//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;
|
||||
37
dayz_code/compile/player_animalCheck.sqf
Normal file
37
dayz_code/compile/player_animalCheck.sqf
Normal file
@@ -0,0 +1,37 @@
|
||||
private["_list","_Pos","_randrefpoint","_PosList","_PosSelect","_Pos","_list","_animalssupported","_type","_root","_favouritezones"];
|
||||
_list = getposATL player nearEntities [["CAAnimalBase"],dayz_animalDistance];
|
||||
|
||||
if (count _list < dayz_maxAnimals) then {
|
||||
//Find where animal likes
|
||||
_animalssupported = ["hen","Cow","Sheep","WildBoar","WildBoar","WildBoar","Goat","Rabbit","Rabbit"];
|
||||
_type = (_animalssupported select floor(random(count _animalssupported)));
|
||||
if (_type == "Cow") then {
|
||||
_animalssupported = ["Cow01","Cow02","Cow03","Cow04"];
|
||||
_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 == 0)) then {
|
||||
//Create Marker
|
||||
/*
|
||||
DAYZ_agentnumber = DAYZ_agentnumber + 1;
|
||||
_GroupMarker = "animal_" + (str DAYZ_agentnumber) + "_" + str(dayz_characterID);
|
||||
createMarker [_GroupMarker, _Pos ];
|
||||
_GroupMarker setMarkerType "Dot";
|
||||
_GroupMarker setMarkerColor "ColorRed";
|
||||
_GroupMarker setMarkerText _type;
|
||||
*/
|
||||
_agent = createAgent [_type, _Pos, [], 0, "FORM"];
|
||||
_agent setpos _Pos;
|
||||
_id = [_pos,_agent] execFSM "\z\addons\dayz_code\system\animal_agent.fsm";
|
||||
};
|
||||
sleep 1;
|
||||
};z
|
||||
120
dayz_code/compile/player_checkStealth.sqf
Normal file
120
dayz_code/compile/player_checkStealth.sqf
Normal file
@@ -0,0 +1,120 @@
|
||||
private["_vel","_speed","_scalePose","_scaleMvmt","_scaleLight","_scaleAlert","_anim","_anim4","_initial","_isDay","_nearFlare","_scaler","_pos"];
|
||||
_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;
|
||||
|
||||
//Assess Players Position
|
||||
_anim = animationState player;
|
||||
_anim4 = toArray _anim;
|
||||
_anim4 resize 4;
|
||||
_anim4 = toString _anim4;
|
||||
|
||||
if (["pknl",_anim] call fnc_inString) then {
|
||||
_scaleMvmt = 0.2; //0.1;
|
||||
_scalePose = 0.6; //0.4
|
||||
} else {;
|
||||
if (["ppne",_anim] call fnc_inString) then {
|
||||
_scaleMvmt = 0.3;
|
||||
_scalePose = 0.14;
|
||||
};
|
||||
};
|
||||
|
||||
if (_anim4 == "aswm") then {
|
||||
_scaleMvmt = 0.3;
|
||||
dayz_isSwimming = true;
|
||||
} 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;
|
||||
};
|
||||
};
|
||||
_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;
|
||||
10
dayz_code/compile/player_combatLogged.sqf
Normal file
10
dayz_code/compile/player_combatLogged.sqf
Normal file
@@ -0,0 +1,10 @@
|
||||
private["_playerName","_center","_group"];
|
||||
_playerName = _this;
|
||||
|
||||
cutText [format["%1 has combat logged!",_playerName], "PLAIN DOWN"];
|
||||
|
||||
_center = createCenter sideLogic;
|
||||
_group = createGroup _center;
|
||||
cl_gamelogic = _group createUnit ["LOGIC", [0, 0, 0], [], 0, "NONE"];
|
||||
cl_gamelogic sideChat format["(COMBAT LOG) %1",_playerName];
|
||||
deleteVehicle cl_gamelogic;
|
||||
53
dayz_code/compile/player_crossbowBolt.sqf
Normal file
53
dayz_code/compile/player_crossbowBolt.sqf
Normal file
@@ -0,0 +1,53 @@
|
||||
private["_unit","_ammo","_audible","_distance","_listTalk","_weapon","_projectile","_vUp","_endPos","_dir","_height","_bolt","_hitArray","_hitObject","_hitSelection","_config","_hitMemoryPt","_variation","_val","_doLoop","_countr"];
|
||||
_unit = _this select 0;
|
||||
_weapon = _this select 1;
|
||||
_ammo = _this select 4;
|
||||
_projectile = _this select 6;
|
||||
|
||||
_projectile = nearestObject [_unit, _ammo];
|
||||
_vUp = vectorUp _projectile;
|
||||
_endPos = getPosATL _projectile;
|
||||
_dir = 0;
|
||||
|
||||
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 ["BoltSteelF", _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];
|
||||
};
|
||||
};
|
||||
127
dayz_code/compile/player_death.sqf
Normal file
127
dayz_code/compile/player_death.sqf
Normal file
@@ -0,0 +1,127 @@
|
||||
private["_array","_source","_kills","_killsV","_humanity","_wait","_myKills"];
|
||||
if (deathHandled) exitWith {};
|
||||
deathHandled = true;
|
||||
//Death
|
||||
|
||||
_body = player;
|
||||
_playerID = getPlayerUID player;
|
||||
|
||||
//Send Death Notice
|
||||
dayzDeath = [dayz_characterID,0,_body,_playerID,dayz_playerName];
|
||||
publicVariableServer "dayzDeath";
|
||||
if (isServer) then {
|
||||
_id = dayzDeath spawn server_playerDied;
|
||||
};
|
||||
|
||||
_id = [player,50,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];
|
||||
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];
|
||||
_isBandit = (["Bandit",typeOf player,false] call fnc_inString);
|
||||
_myKills = ((player getVariable ["humanKills",0]) / 30) * 1000;
|
||||
if (!_canHitFree and !_isBandit) 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 and !_isBandit) then {
|
||||
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;
|
||||
|
||||
//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;
|
||||
publicVariable "dayzFlies";
|
||||
*/
|
||||
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;
|
||||
70
dayz_code/compile/player_fired.sqf
Normal file
70
dayz_code/compile/player_fired.sqf
Normal file
@@ -0,0 +1,70 @@
|
||||
private["_unit","_ammo","_audible","_distance","_listTalk","_weapon"];
|
||||
//[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;
|
||||
// Put everyone in range of the bullet into combat
|
||||
//_id = _this spawn player_projectileNear;
|
||||
// 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 {
|
||||
_id = [_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;
|
||||
};
|
||||
};
|
||||
};
|
||||
39
dayz_code/compile/player_gearSet.sqf
Normal file
39
dayz_code/compile/player_gearSet.sqf
Normal file
@@ -0,0 +1,39 @@
|
||||
private["_inventory","_wpns","_mags","_idc","_isOK","_val","_item","_x"];
|
||||
_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;
|
||||
};
|
||||
//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
|
||||
{
|
||||
//Is item legal?
|
||||
_isOK = isClass(configFile >> "CfgWeapons" >> _x);
|
||||
if (_isOK) then {
|
||||
player addWeapon _x;
|
||||
};
|
||||
} forEach _wpns;
|
||||
};
|
||||
83
dayz_code/compile/player_gearSync.sqf
Normal file
83
dayz_code/compile/player_gearSync.sqf
Normal file
@@ -0,0 +1,83 @@
|
||||
private ["_objects"];
|
||||
_objects = nearestObjects [getPosATL player, ["Car", "Helicopter", "Motorcycle", "Ship", "TentStorage"], 10];
|
||||
{
|
||||
dayzUpdateVehicle = [_x,"all"];
|
||||
publicVariable "dayzUpdateVehicle";
|
||||
} foreach _objects;
|
||||
|
||||
private ["_backpackWpnQtys","_backpackWpnTypes","_backpackWpn","_backpackMag","_countr"];
|
||||
dayz_myBackpack = unitBackpack player;
|
||||
_backpackWpn = getWeaponCargo unitBackpack player;
|
||||
_backpackMag = getMagazineCargo unitBackpack player;
|
||||
|
||||
clearWeaponCargoGlobal unitBackpack player;
|
||||
clearMagazineCargoGlobal unitBackpack player;
|
||||
|
||||
//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;
|
||||
|
||||
private["_dialog","_magazineArray","_control","_item","_val","_max"];
|
||||
diag_log ("REQUESTING GEAR SYNC");
|
||||
disableSerialization;
|
||||
//if (!dayzGearSave) exitWith {};
|
||||
|
||||
diag_log ("CONDUCTING GEAR SYNC");
|
||||
_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 (_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;
|
||||
25
dayz_code/compile/player_humanityChange.sqf
Normal file
25
dayz_code/compile/player_humanityChange.sqf
Normal file
@@ -0,0 +1,25 @@
|
||||
private["_object","_change","_humanity","_timeStart"];
|
||||
//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 ((typeOf player != "Bandit1_DZ") && (typeOf player != "BanditW1_DZ")) then {
|
||||
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];
|
||||
};
|
||||
};
|
||||
96
dayz_code/compile/player_humanityMorph.sqf
Normal file
96
dayz_code/compile/player_humanityMorph.sqf
Normal file
@@ -0,0 +1,96 @@
|
||||
private["_updates","_playerUID","_charID","_humanity","_worldspace","_model"];
|
||||
_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];
|
||||
|
||||
//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];
|
||||
[player,_x,_hit] spawn fnc_usec_damageBleed;
|
||||
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 0)] 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];
|
||||
|
||||
dayzPlayerMorph = [_charID,player,_playerUID,[_zombieKills,_headShots,_humanKills,_banditKills],_humanity];
|
||||
publicVariable "dayzPlayerMorph";
|
||||
if (isServer) then {
|
||||
dayzPlayerMorph call server_playerMorph;
|
||||
};
|
||||
|
||||
call dayz_resetSelfActions;
|
||||
|
||||
eh_player_killed = player addeventhandler ["FiredNear",{_this call player_weaponFiredNear;} ];
|
||||
|
||||
//Combat logging
|
||||
_eh_combat_projectilenear = player addEventHandler ["IncomingFire",{_this call player_projectileNear;} ];
|
||||
//
|
||||
[player] call fnc_usec_damageHandle;
|
||||
player allowDamage true;
|
||||
|
||||
player addWeapon "Loot";
|
||||
player addWeapon "Flare";
|
||||
|
||||
sleep 0.1;
|
||||
deleteVehicle _old;
|
||||
6
dayz_code/compile/player_login.sqf
Normal file
6
dayz_code/compile/player_login.sqf
Normal file
@@ -0,0 +1,6 @@
|
||||
private["_unit","_move","_damage","_wound","_sound","_local","_dir","_hpList","_hp","_strH","_dam","_total","_result","_vehicle"];
|
||||
_unit = _this select 0;
|
||||
_detail = _this select 1;
|
||||
if(_unit == getPlayerUID player) then {
|
||||
player setVariable["publish",_detail];
|
||||
};
|
||||
11
dayz_code/compile/player_music.sqf
Normal file
11
dayz_code/compile/player_music.sqf
Normal file
@@ -0,0 +1,11 @@
|
||||
private["_zombie","_type","_chance","_rnd","_sound"];
|
||||
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;
|
||||
};
|
||||
75
dayz_code/compile/player_packTent.sqf
Normal file
75
dayz_code/compile/player_packTent.sqf
Normal file
@@ -0,0 +1,75 @@
|
||||
/*
|
||||
[_obj] spawn player_packTent;
|
||||
*/
|
||||
private["_objectID","_objectUID","_obj","_ownerID","_dir","_pos","_bag","_holder","_weapons","_magazines","_backpacks","_objWpnTypes","_objWpnQty","_countr"];
|
||||
_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) then {
|
||||
_alreadyPacking = _obj getVariable["packing",0];
|
||||
|
||||
if (_alreadyPacking == 1) exitWith {cutText [format[(localize "str_player_beingpacked")] , "PLAIN DOWN"]};
|
||||
|
||||
_obj setVariable["packing",1];
|
||||
|
||||
_dir = direction _obj;
|
||||
_pos = getposATL _obj;
|
||||
[player,"tentpack",0,false] call dayz_zombieSpeak;
|
||||
sleep 3;
|
||||
|
||||
//place tent (local)
|
||||
_bag = createVehicle ["WeaponHolder_ItemTent",_pos,[], 0, "CAN_COLLIDE"];
|
||||
_bag setdir _dir;
|
||||
player reveal _bag;
|
||||
|
||||
_holder = "WeaponHolder" createVehicle _pos;
|
||||
|
||||
_weapons = getWeaponCargo _obj;
|
||||
_magazines = getMagazineCargo _obj;
|
||||
_backpacks = getBackpackCargo _obj;
|
||||
|
||||
dayzDeleteObj = [_objectID,_objectUID];
|
||||
publicVariable "dayzDeleteObj";
|
||||
if (isServer) then {
|
||||
dayzDeleteObj call local_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"];
|
||||
} else {
|
||||
cutText [localize "str_fail_tent_pack", "PLAIN DOWN"];
|
||||
};
|
||||
30
dayz_code/compile/player_projectileNear.sqf
Normal file
30
dayz_code/compile/player_projectileNear.sqf
Normal file
@@ -0,0 +1,30 @@
|
||||
private["_unit","_shooter","_distance","_ammo","_position","_isInCombat"];
|
||||
_unit = _this select 0;
|
||||
_shooter = _this select 1;
|
||||
_ammo = _this select 2;
|
||||
_distance = _this select 3;
|
||||
_position = _this select 4;
|
||||
_projectile = _this select 6;
|
||||
|
||||
_isInComat = _unit getVariable["startcombattimer",0];
|
||||
_endPos = getPosATL _projectile;
|
||||
|
||||
_listNear = _unit nearEntities [["CAManBase","AllVehicles"],25];
|
||||
{
|
||||
_nearVehicle = _x;
|
||||
_isInCombat = _nearVehicle getVariable["startcombattimer",0];
|
||||
|
||||
if ((alive _unit) and (isPlayer _unit) and _isInCombat == 0) then {
|
||||
_unit 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) then {
|
||||
_x setVariable["startcombattimer", 1, true];
|
||||
diag_log("Now in Combat (Crew): " + name _x);
|
||||
};
|
||||
} forEach (crew _nearVehicle);
|
||||
};
|
||||
} forEach _listNear;
|
||||
75
dayz_code/compile/player_serverModelChange.sqf
Normal file
75
dayz_code/compile/player_serverModelChange.sqf
Normal file
@@ -0,0 +1,75 @@
|
||||
private["_int","_newModel","_wait","_playerID","_playerObj","_randomSpot","_publishTo","_primary","_secondary","_key","_result","_charID","_playerObj","_playerName","_finished","_spawnPos","_spawnDir","_items","_counter","_magazines","_weapons","_group","_backpack","_worldspace","_direction","_newUnit","_score","_position","_isNew","_inventory","_backpack","_medical","_survival","_stats","_state"];
|
||||
//Set Variables
|
||||
_playerID = _this select 0;
|
||||
_playerObj = _this select 1;
|
||||
_playerName = name _playerObj;
|
||||
_worldspace = [];
|
||||
|
||||
waitUntil{allowConnection};
|
||||
|
||||
//Variables
|
||||
_inventory = [];
|
||||
_backpack = [];
|
||||
_items = [];
|
||||
_magazines = [];
|
||||
_weapons = [];
|
||||
_medicalStats = [];
|
||||
_survival = [0,0,0];
|
||||
_tent = [];
|
||||
_state = [];
|
||||
_direction = 0;
|
||||
_newUnit = objNull;
|
||||
|
||||
if (_playerID == "") then {
|
||||
_playerID = getPlayerUID _playerObj;
|
||||
};
|
||||
|
||||
endLoadingScreen;
|
||||
diag_log ("LOGIN ATTEMPT: " + str(_playerID) + " " + _playerName);
|
||||
|
||||
//Wait for HIVE to be free
|
||||
waitUntil{!hiveInUse};
|
||||
hiveInUse = true;
|
||||
//Send request
|
||||
_key = format["CHILD:101:%1:%2:%3:",_playerID,dayZ_instance,_playerName];
|
||||
_primary = [_key,true] call fnc_motherrequest;
|
||||
//Release HIVE
|
||||
hiveInUse = false;
|
||||
|
||||
//Process request
|
||||
_isNew = count _primary < 4; //_result select 1;
|
||||
_charID = _primary select 2;
|
||||
_randomSpot = false;
|
||||
|
||||
diag_log ("LOGIN OBJ: " + str(_playerObj) + " Type: " + (typeOf _playerObj) + " ID: " + str(_charID));
|
||||
|
||||
/* PROCESS */
|
||||
|
||||
if (!_isNew) then {
|
||||
//RETURNING CHARACTER
|
||||
_inventory = _primary select 4;
|
||||
_backpack = _primary select 5;
|
||||
_survival = _primary select 6;
|
||||
_model = _primary select 7;
|
||||
} else {
|
||||
_model = _primary select 3;
|
||||
//Record initial inventory
|
||||
_config = (configFile >> "CfgSurvival" >> "Inventory" >> "Default");
|
||||
_mags = getArray (_config >> "magazines");
|
||||
_wpns = getArray (_config >> "weapons");
|
||||
_bcpk = getText (_config >> "backpack");
|
||||
_randomSpot = true;
|
||||
|
||||
//Wait for HIVE to be free
|
||||
waitUntil{!hiveInUse};
|
||||
hiveInUse = true;
|
||||
//Send request
|
||||
_key = format["CHILD:203:%1:%2:%3:",_charID,[_wpns,_mags],[_bcpk,[],[]]];
|
||||
_result = [_key,false] call fnc_motherrequest;
|
||||
//Release HIVE
|
||||
hiveInUse = false;
|
||||
};
|
||||
diag_log ("LOGIN LOADED: " + str(_playerObj) + " Type: " + (typeOf _playerObj));
|
||||
|
||||
//Server publishes variable to clients and WAITS
|
||||
_playerObj setVariable ["publish",[_charID,_inventory,_backpack,_survival,_isNew,dayz_versionNo,_model],true];
|
||||
76
dayz_code/compile/player_spawnCheck.sqf
Normal file
76
dayz_code/compile/player_spawnCheck.sqf
Normal file
@@ -0,0 +1,76 @@
|
||||
_isAir = vehicle player iskindof "Air";
|
||||
_inVehicle = (vehicle player != player);
|
||||
_fastRun = _this select 0;
|
||||
_dateNow = (DateToNumber date);
|
||||
_age = -1;
|
||||
if (!_inVehicle) then {
|
||||
_position = getPosATL player;
|
||||
//waitUntil{_position nearObjectsReady 200};
|
||||
_nearby = _position nearObjects ["building",200]; //nearestObjects [player, ["building"], 200];
|
||||
_tooManyZs = {alive _x} count (_position nearEntities ["zZombie_Base",400]) > dayz_maxLocalZombies;
|
||||
{
|
||||
_type = typeOf _x;
|
||||
_config = configFile >> "CfgBuildingLoot" >> _type;
|
||||
_canLoot = isClass (_config);
|
||||
if (_canLoot) then {
|
||||
_dis = _x distance player;
|
||||
if ((_dis < 120) and (_dis > 30)) then {
|
||||
_looted = (_x getVariable ["looted",-0.1]);
|
||||
_cleared = (_x getVariable ["cleared",true]);
|
||||
/*
|
||||
if(isServer) then {
|
||||
_dateNow = (DateToNumber date);
|
||||
_age = (_dateNow - _looted) * 525948;
|
||||
} else {
|
||||
_dateNow = serverTime;
|
||||
_age = (_dateNow * 60) - _looted;
|
||||
};
|
||||
*/
|
||||
_dateNow = (DateToNumber date);
|
||||
_age = (_dateNow - _looted) * 525948;
|
||||
//diag_log ("SPAWN LOOT: " + _type + " Building is " + str(_age) + " old" );
|
||||
if ((_age > 10) and (!_cleared) and !_inVehicle) 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) and !_inVehicle) then {
|
||||
//Register
|
||||
_x setVariable ["looted",_dateNow,true];
|
||||
//cleanup
|
||||
_handle = [_x,_fastRun] spawn building_spawnLoot;
|
||||
waitUntil{scriptDone _handle};
|
||||
};
|
||||
};
|
||||
if ((time - dayz_spawnWait) > dayz_spawnDelay) then {
|
||||
if (dayz_spawnZombies < dayz_maxLocalZombies) then {
|
||||
if (!_tooManyZs) then {
|
||||
private["_zombied"];
|
||||
_zombied = (_x getVariable ["zombieSpawn",-0.1]);
|
||||
_dateNow = (DateToNumber date);
|
||||
_age = (_dateNow - _zombied) * 525948;
|
||||
if (_age > 5) then {
|
||||
_bPos = getPosATL _x;
|
||||
_zombiesNum = {alive _x} count (_bPos nearEntities ["zZombie_Base",(((sizeOf _type) * 2) + 10)]);
|
||||
if (_zombiesNum == 0) then {
|
||||
//Randomize Zombies
|
||||
_x setVariable ["zombieSpawn",_dateNow,true];
|
||||
_handle = [_x,_fastRun] spawn building_spawnZombies;
|
||||
waitUntil{scriptDone _handle};
|
||||
//} else {
|
||||
//_x setVariable ["zombieSpawn",_dateNow,true];
|
||||
};
|
||||
};
|
||||
};
|
||||
} else {
|
||||
dayz_spawnWait = time;
|
||||
dayz_spawnZombies = 0;
|
||||
};
|
||||
};
|
||||
};
|
||||
if (!_fastRun) then {
|
||||
sleep 0.1;
|
||||
};
|
||||
} forEach _nearby;
|
||||
};
|
||||
200
dayz_code/compile/player_switchModel.sqf
Normal file
200
dayz_code/compile/player_switchModel.sqf
Normal file
@@ -0,0 +1,200 @@
|
||||
private["_class","_position","_dir","_group","_oldUnit","_newUnit","_currentWpn","_muzzles","_currentAnim","_currentCamera"];
|
||||
_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(_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;
|
||||
|
||||
if (!isNull dayz_originalPlayer) then {
|
||||
dayz_originalPlayer = _oldUnit;
|
||||
_oldUnit addEventHandler ["HandleDamage",{false}];
|
||||
_oldUnit disableAI "ANIM";
|
||||
_oldUnit disableAI "MOVE";
|
||||
} else {
|
||||
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["player%1 = player;",_playerUID];
|
||||
publicVariable _playerObjName;
|
||||
42
dayz_code/compile/player_taskHint.sqf
Normal file
42
dayz_code/compile/player_taskHint.sqf
Normal 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;
|
||||
33
dayz_code/compile/player_throwObject.sqf
Normal file
33
dayz_code/compile/player_throwObject.sqf
Normal file
@@ -0,0 +1,33 @@
|
||||
private["_unit","_ammo","_audible","_distance","_listTalk","_weapon","_projectile","_vUp","_endPos","_dir","_height","_bolt","_hitArray","_hitObject","_hitSelection","_config","_hitMemoryPt","_variation","_val","_doLoop","_countr"];
|
||||
_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;
|
||||
};
|
||||
};
|
||||
|
||||
_id = [_unit,_distance,false,_endPos] spawn player_alertZombies;
|
||||
96
dayz_code/compile/player_updateGui.sqf
Normal file
96
dayz_code/compile/player_updateGui.sqf
Normal file
@@ -0,0 +1,96 @@
|
||||
private["_display","_ctrlBlood","_bloodVal","_ctrlFood","_ctrlThirst","_foodVal","_ctrlTemp","_tempVal","_array"];
|
||||
disableSerialization;
|
||||
|
||||
_foodVal = 1 - (dayz_hunger / SleepFood);
|
||||
_thirstVal = 1 - (dayz_thirst / SleepWater);
|
||||
_tempVal = (dayz_temperatur / dayz_temperaturnormal); //TeeChange
|
||||
_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 * _tempVal)),(Dayz_GUI_G * _tempVal),(Dayz_GUI_B + (0.25 * (1/_tempVal))), 0.5]; //TeeChange Coulor should change into red if value is higher as normale temp and into blue if coulor is lower as normal temp
|
||||
_ctrlCombat ctrlSetTextColor [(Dayz_GUI_R + (0.3 * (1-_combatVal))),(Dayz_GUI_G * _combatVal),(Dayz_GUI_B * _combatVal), 0.5];
|
||||
|
||||
/*
|
||||
_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;
|
||||
};
|
||||
*/
|
||||
|
||||
_visualtext = "";
|
||||
_visual = round((dayz_disVisual / 100) * 4) min 5;
|
||||
if (_visual > 0) then {_visualtext = "\z\addons\dayz_code\gui\val_" + str(_visual) + "_ca.paa"};
|
||||
|
||||
_audibletext = "";
|
||||
_audible = round((dayz_disAudial / 50) * 4) min 5;
|
||||
if (_audible > 0) then {_audibletext = "\z\addons\dayz_code\gui\val_" + str(_audible) + "_ca.paa"};
|
||||
|
||||
_ctrlEye ctrlSetText _visualtext;
|
||||
_ctrlEar ctrlSetText _audibletext;
|
||||
|
||||
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.833) then { //TeeChange
|
||||
_ctrlTemp call player_guiControlFlash;
|
||||
};
|
||||
|
||||
if (r_player_injured) then {
|
||||
_ctrlBleed call player_guiControlFlash;
|
||||
};
|
||||
|
||||
if (!canStand player) then {
|
||||
if (!(ctrlShown _ctrlFracture)) then {
|
||||
r_fracture_legs = true;
|
||||
_ctrlFracture ctrlShow true;
|
||||
};
|
||||
};
|
||||
|
||||
_array = [_foodVal,_thirstVal];
|
||||
_array
|
||||
36
dayz_code/compile/player_weaponCheck.sqf
Normal file
36
dayz_code/compile/player_weaponCheck.sqf
Normal file
@@ -0,0 +1,36 @@
|
||||
private["_currentObjects","_newObjects","_checkObjects"];
|
||||
//_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
|
||||
94
dayz_code/compile/player_weaponFiredNear.sqf
Normal file
94
dayz_code/compile/player_weaponFiredNear.sqf
Normal file
@@ -0,0 +1,94 @@
|
||||
//[unit, weapon, muzzle, mode, ammo, magazine, projectile]
|
||||
private["_unit","_magazine","_used","_quantity","_magsNet","_magsWhole","_key","_result","_evType","_recordable","_inVehicle","_isPlayer","_isRocket","_dmgDistance","_isBallistic","_handled"];
|
||||
//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 (<=15m) go into "combat" to prevent ALT-F4
|
||||
_firer setVariable["startcombattimer", 1, true];
|
||||
_listNear = _firer nearEntities [["CAManBase","AllVehicles"],15];
|
||||
{
|
||||
if (_isPlayer) then {
|
||||
_unit setVariable["startcombattimer", 1, true];
|
||||
};
|
||||
} forEach _listNear;
|
||||
|
||||
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
|
||||
108
dayz_code/compile/player_zombieAttack.sqf
Normal file
108
dayz_code/compile/player_zombieAttack.sqf
Normal file
@@ -0,0 +1,108 @@
|
||||
private["_unit","_targets","_move","_damage","_wound","_sound","_local","_dir","_hpList","_hp","_strH","_dam","_total","_result","_vehicle","_tPos","_zPos","_cantSee","_inAngle"];
|
||||
_unit = _this;
|
||||
_vehicle = (vehicle player);
|
||||
|
||||
_targets = _unit getVariable ["targets",[]];
|
||||
if (!(_vehicle in _targets)) exitWith {};
|
||||
|
||||
//Do the attack
|
||||
_move = "ZombieStandingAttack1";
|
||||
_rnd = 0;
|
||||
_wound = "";
|
||||
if (r_player_unconscious) then {
|
||||
_rnd = round(random 4) + 1;
|
||||
_move = "ZombieFeed" + str(_rnd);
|
||||
} else {
|
||||
_rnd = round(random 9) + 1;
|
||||
_move = "ZombieStandingAttack" + str(_rnd);
|
||||
};
|
||||
_dir = [_unit,player] call BIS_Fnc_dirTo;
|
||||
_unit setDir _dir;
|
||||
[objNull, _unit, rPlayMove,_move] call RE;
|
||||
|
||||
//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");
|
||||
_total = 0;
|
||||
|
||||
if(["Glass",_hp,false] call fnc_inString) then {
|
||||
_damage = 0.5;
|
||||
_strH = "hit_" + (_wound);
|
||||
_dam = _vehicle getVariable [_strH,0];
|
||||
_total = (_dam + _damage);
|
||||
};
|
||||
if(["Wheel",_hp,false] call fnc_inString) then {
|
||||
_damage = 0.1;
|
||||
_strH = "hit_" + (_wound);
|
||||
_dam = _vehicle getVariable [_strH,0];
|
||||
_total = (_dam + _damage);
|
||||
};
|
||||
if(["Body",_hp,false] call fnc_inString) then {
|
||||
_damage = 0.05;
|
||||
_strH = "hit_" + (_wound);
|
||||
_dam = _vehicle getVariable [_strH,0];
|
||||
_total = (_dam + _damage);
|
||||
};
|
||||
if(["Engine",_hp,false] call fnc_inString) then {
|
||||
_damage = 0.03;
|
||||
_strH = "hit_" + (_wound);
|
||||
_dam = _vehicle getVariable [_strH,0];
|
||||
_total = (_dam + _damage);
|
||||
};
|
||||
if(["Fuel",_hp,false] call fnc_inString) then {
|
||||
[_unit,"hit",0,false] call dayz_zombieSpeak;
|
||||
_damage = 0.03;
|
||||
_strH = "hit_" + (_wound);
|
||||
_dam = _vehicle getVariable [_strH,0];
|
||||
_total = (_dam + _damage);
|
||||
};
|
||||
if(_total > 0) then {
|
||||
[_unit,"hit",0,false] call dayz_zombieSpeak;
|
||||
_result = [_vehicle, _wound,_total, _unit,"zombie"] call fnc_usec_damageVehicle;
|
||||
dayzHitV = [_vehicle,_wound,_total, _unit,"zombie"];
|
||||
publicVariable "dayzHitV";
|
||||
};
|
||||
|
||||
} else {
|
||||
//Did he hit?
|
||||
if ((_unit distance player) <= 3) 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 {
|
||||
_wound = DAYZ_woundHit call BIS_fnc_selectRandomWeighted;
|
||||
} else {
|
||||
_wound = DAYZ_woundHit_ok call BIS_fnc_selectRandomWeighted;
|
||||
};
|
||||
_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",0,false] call dayz_zombieSpeak;
|
||||
} else {
|
||||
/*
|
||||
_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",0,false] call dayz_zombieSpeak;
|
||||
};
|
||||
*/
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
109
dayz_code/compile/player_zombieCheck.sqf
Normal file
109
dayz_code/compile/player_zombieCheck.sqf
Normal file
@@ -0,0 +1,109 @@
|
||||
private["_listTalk","_isZombie","_group","_eyeDir","_attacked","_chance","_last","_audial","_distance","_refObj","_list","_scaleMvmt","_scalePose","_scaleLight","_anim","_activators","_nearFire","_nearFlare","_scaleAlert","_inAngle","_scaler","_initial","_tPos","_zPos","_cantSee"];
|
||||
_refObj = vehicle player;
|
||||
_listTalk = (position _refObj) nearEntities ["zZombie_Base",200];
|
||||
_pHeight = (getPosATL _refObj) select 2;
|
||||
_attacked = false;
|
||||
|
||||
//_list = list dayz_playerTrigger;
|
||||
{
|
||||
if (alive _x) then {
|
||||
private["_dist"];
|
||||
_dist = (_x distance _refObj);
|
||||
_group = _x;
|
||||
/*
|
||||
_group = group _x;
|
||||
_chance = (count units _group);
|
||||
if (isNull group _x) then {
|
||||
_group = _x;
|
||||
_chance = 1;
|
||||
};
|
||||
*/
|
||||
_chance = 1;
|
||||
//if ((_x in _list) and !(animationState _x == "ZombieFeed")) then {
|
||||
if ((_x distance player < dayz_areaAffect) and !(animationState _x == "ZombieFeed")) 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 {
|
||||
//_isZInside = [_x,_building] call fnc_isInsideBuilding;
|
||||
//if ((_isPlayerInside and _isZInside) or (!_isPlayerInside and !_isZInside)) then {
|
||||
_x spawn player_zombieAttack;
|
||||
_x setVariable["lastAttack",time];
|
||||
//};
|
||||
};
|
||||
_attacked = true;
|
||||
} else {
|
||||
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 = _group getVariable ["targets",[]];
|
||||
if (!(_refObj in _targets)) then {
|
||||
if (_dist < DAYZ_disAudial) then {
|
||||
if (DAYZ_disAudial > 80) then {
|
||||
_targets set [count _targets, driver _refObj];
|
||||
_group 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];
|
||||
_group setVariable ["targets",_targets,true];
|
||||
} else {
|
||||
if (_dist < (DAYZ_disAudial / 2)) then {
|
||||
_targets set [count _targets, driver _refObj];
|
||||
_group setVariable ["targets",_targets,true];
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
//Sight Activation
|
||||
_targets = _group 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];
|
||||
_group 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;
|
||||
};
|
||||
};
|
||||
};
|
||||
182
dayz_code/compile/server_updatePlayer.sqf
Normal file
182
dayz_code/compile/server_updatePlayer.sqf
Normal file
@@ -0,0 +1,182 @@
|
||||
private["_characterID","_currentModelCheck","_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","_legs","_arms","_kills","_headShots","_killsCHK","_headShotsCHK","_timeGross","_timeLeft","_onLadder","_isTerminal"];
|
||||
_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 > -20000 and _x < 20000) 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)];
|
||||
};
|
||||
};
|
||||
};
|
||||
6
dayz_code/compile/spawn_flies.sqf
Normal file
6
dayz_code/compile/spawn_flies.sqf
Normal 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];
|
||||
54
dayz_code/compile/spawn_loot.sqf
Normal file
54
dayz_code/compile/spawn_loot.sqf
Normal file
@@ -0,0 +1,54 @@
|
||||
private["_itemType","_iPos","_indexLootSpawn","_iArray","_iItem","_iClass","_item","_qty","_max","_tQty","_arrayLootSpawn","_canType"];
|
||||
// [_itemType,_weights]
|
||||
_iItem = _this select 0;
|
||||
_iClass = _this select 1;
|
||||
_iPos = _this select 2;
|
||||
_radius = _this select 3;
|
||||
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"];
|
||||
_arrayLootSpawn = [] + getArray (configFile >> "cfgLoot" >> _iClass);
|
||||
_itemType = _arrayLootSpawn select 0;
|
||||
_weights = _arrayLootSpawn call fnc_buildWeightedArray;
|
||||
_qty = 0;
|
||||
_max = ceil(random 4) + 1;
|
||||
//diag_log ("LOOTSPAWN: QTY: " + str(_max) + " ARRAY: " + str(_arrayLootSpawn));
|
||||
while {_qty < _max} do {
|
||||
private["_tQty","_indexLootSpawn","_canType"];
|
||||
_tQty = floor(random 1) + 1;
|
||||
//diag_log ("LOOTSPAWN: ITEM QTY: " + str(_tQty));
|
||||
|
||||
_indexLootSpawn = _weights call BIS_fnc_selectRandom;
|
||||
_canType = _itemType select _indexLootSpawn;
|
||||
|
||||
//diag_log ("LOOTSPAWN: ITEM: " + str(_canType));
|
||||
_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 {
|
||||
_item addMagazineCargoGlobal [(_mags select 0),(round(random 3))];
|
||||
};
|
||||
};
|
||||
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"];
|
||||
};
|
||||
};
|
||||
if (count _iPos > 2) then {
|
||||
_item setPosATL _ipos;
|
||||
};
|
||||
29
dayz_code/compile/stream_locationCheck.sqf
Normal file
29
dayz_code/compile/stream_locationCheck.sqf
Normal file
@@ -0,0 +1,29 @@
|
||||
//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;
|
||||
12
dayz_code/compile/stream_locationDel.sqf
Normal file
12
dayz_code/compile/stream_locationDel.sqf
Normal 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));
|
||||
24
dayz_code/compile/stream_locationFill.sqf
Normal file
24
dayz_code/compile/stream_locationFill.sqf
Normal 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));
|
||||
45
dayz_code/compile/ui_changeDisplay.sqf
Normal file
45
dayz_code/compile/ui_changeDisplay.sqf
Normal 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;
|
||||
*/
|
||||
64
dayz_code/compile/ui_selectSlot.sqf
Normal file
64
dayz_code/compile/ui_selectSlot.sqf
Normal file
@@ -0,0 +1,64 @@
|
||||
private ["_control","_button","_parent","_group","_pos","_item","_conf","_name","_cfgActions","_numActions","_height","_menu","_config","_type","_script","_outputOriented","_compile","_uiControl"];
|
||||
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;
|
||||
};
|
||||
26
dayz_code/compile/vehicle_getHitpoints.sqf
Normal file
26
dayz_code/compile/vehicle_getHitpoints.sqf
Normal 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
|
||||
37
dayz_code/compile/vehicle_handleDamage.sqf
Normal file
37
dayz_code/compile/vehicle_handleDamage.sqf
Normal file
@@ -0,0 +1,37 @@
|
||||
/***********************************************************
|
||||
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"];
|
||||
if (isServer) then {
|
||||
if (allowConnection) then {
|
||||
dayzUpdateVehicle call server_updateObject;
|
||||
};
|
||||
} else {
|
||||
publicVariable "dayzUpdateVehicle";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
_total
|
||||
31
dayz_code/compile/vehicle_handleKilled.sqf
Normal file
31
dayz_code/compile/vehicle_handleKilled.sqf
Normal file
@@ -0,0 +1,31 @@
|
||||
private["_unit","_selection","_killer"];
|
||||
|
||||
_unit = _this select 0;
|
||||
_killer = _this select 1;
|
||||
|
||||
// Prevent spazzing out vehicles from spamming server/MySQL
|
||||
_waskilled = _unit getVariable ['waskilled', 0];
|
||||
if (_waskilled) exitWith{};
|
||||
|
||||
_unit setVariable ['waskilled', 1, true];
|
||||
|
||||
_hitPoints = _unit call vehicle_getHitpoints;
|
||||
{
|
||||
_selection = getText (configFile >> "CfgVehicles" >> (typeof _unit) >> "HitPoints" >> _x >> "name");
|
||||
_unit setVariable [_selection, 1, true];
|
||||
} forEach _hitPoints;
|
||||
|
||||
dayzUpdateVehicle = [_unit, "damage", true];
|
||||
|
||||
if (isServer) then {
|
||||
if (allowConnection) then {
|
||||
dayzUpdateVehicle call server_updateObject;
|
||||
};
|
||||
} else {
|
||||
publicVariable "dayzUpdateVehicle";
|
||||
};
|
||||
|
||||
_unit removeAllEventHandlers "HandleDamage";
|
||||
_unit removeAllEventHandlers "Killed";
|
||||
_unit removeAllEventHandlers "GetIn";
|
||||
_unit removeAllEventHandlers "GetOut";
|
||||
78
dayz_code/compile/zombie_findTarget.sqf
Normal file
78
dayz_code/compile/zombie_findTarget.sqf
Normal 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 "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;
|
||||
63
dayz_code/compile/zombie_findTargetAgent.sqf
Normal file
63
dayz_code/compile/zombie_findTargetAgent.sqf
Normal file
@@ -0,0 +1,63 @@
|
||||
private["_agent","_target","_targets","_targetDis","_c","_man","_manDis","_targets","_agent","_agentheight","_nearEnts","_rnd","_assigned","_range","_objects"];
|
||||
_agent = _this;
|
||||
_target = objNull;
|
||||
_targets = [];
|
||||
_targetDis = [];
|
||||
_range = 300;
|
||||
_manDis = 0;
|
||||
|
||||
_targets = _agent getVariable ["targets",[]];
|
||||
/*
|
||||
//Search for fires
|
||||
if (count _targets == 0) then {
|
||||
_fires = nearestObjects [_agent,["Land_Fire"],_range];
|
||||
{
|
||||
private["_dis"];
|
||||
_dis = _x distance _agent;
|
||||
_rnd = random 1;
|
||||
if ((_dis < _range) and (inflamed _x) and !(_x in _targets) and (_rnd < 0.5)) then {
|
||||
_targets set [count _targets,_x];
|
||||
_targetDis set [count _targetDis,_dis];
|
||||
};
|
||||
} forEach _fires;
|
||||
};
|
||||
*/
|
||||
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;
|
||||
//diag_log (str(_man) + str(_manDis));
|
||||
{
|
||||
private["_dis"];
|
||||
_dis = _x distance _agent;
|
||||
if (_dis < _manDis) then {
|
||||
_man = _x;
|
||||
_manDis = _dis;
|
||||
};
|
||||
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;
|
||||
97
dayz_code/compile/zombie_generate.sqf
Normal file
97
dayz_code/compile/zombie_generate.sqf
Normal file
@@ -0,0 +1,97 @@
|
||||
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;
|
||||
|
||||
_isNoone = {isPlayer _x} count (_position nearEntities ["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];
|
||||
|
||||
if (_doLoiter) then {
|
||||
_agent setPosATL _position;
|
||||
//_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 ["CAManBase",30])) > 0;
|
||||
|
||||
if (random 1 > 0.7) then {
|
||||
_agent setUnitPos "Middle";
|
||||
};
|
||||
|
||||
//diag_log ("CREATED: " + str(_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";
|
||||
8
dayz_code/compile/zombie_initialize.sqf
Normal file
8
dayz_code/compile/zombie_initialize.sqf
Normal 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}];
|
||||
};
|
||||
20
dayz_code/compile/zombie_loiter.sqf
Normal file
20
dayz_code/compile/zombie_loiter.sqf
Normal file
@@ -0,0 +1,20 @@
|
||||
private["_unit","_originalPos","_pos"];
|
||||
_unit = _this select 0;
|
||||
_originalPos = _this select 1;
|
||||
_pos = getPosATL _unit;
|
||||
|
||||
if (count _this > 2) then {
|
||||
_pos = _this select 2;
|
||||
} else {
|
||||
//_unit enableAI "MOVE";
|
||||
//_unit enableAI "ANIM";
|
||||
_pos = [_originalPos,10,90,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];
|
||||
Reference in New Issue
Block a user