diff --git a/SQF/dayz_code/NOTE.txt b/SQF/dayz_code/NOTE.txt index dede8dc39..b10d1810d 100644 --- a/SQF/dayz_code/NOTE.txt +++ b/SQF/dayz_code/NOTE.txt @@ -1,3 +1,5 @@ +DZE_BloodBags NEEDED ARRAY OF ALL BLOOD BAGS + replace all of 8Rnd_12Gauge_Buck 8Rnd_12Gauge_Slug @@ -19,6 +21,9 @@ CHANGED WEAPON CLASSES Create switchable blood system with variable. Convert (if old system) to ItemBloodbag DZE_UseBloodTypes +fn_selfActions.sqf +player_updateGui.sqf + bloodBagANEG bloodBagAPOS bloodBagBNEG bloodBagBPOS bloodBagONEG bloodBagOPOS wholeBloodBagANEG wholeBloodBagAPOS wholeBloodBagBNEG wholeBloodBagBPOS wholeBloodBagONEG wholeBloodBagOPOS @@ -69,4 +74,12 @@ PVDZ_plr_Login1 BECOMES PVDZE_plr_Login PVDZ_obj_Destroy BECOMES PVDZE_obj_Delete //WHO RENAMED THESE VARIABLES IN DAYZ VANILLA, THE COMPILE IT CALLS IS STILL NAMED server_deleteObj WHY CHANGE IT TO DESTROY!!!!??? dayzSetDate BECOMES PVDZE_plr_SetDate -PVDZ_serverStoreVar BECOMES PVDZE_serverStoreVar \ No newline at end of file +PVDZ_serverStoreVar BECOMES PVDZE_serverStoreVar + +player getVariable ["OpenTarget",false]; CHANGE TO +player getVariable ["freeTarget",false]; + + +////////SERVER STUFF/////// +REMOVE PVDZE_SEND PROJECTILE FOR FLARE AND CHEMLIGHT 0 1 +PVDZE_send = [_x,"RoadFlare",[_projectile,1]]; \ No newline at end of file diff --git a/SQF/dayz_code/compile/client_plantSpawner.sqf b/SQF/dayz_code/compile/client_plantSpawner.sqf new file mode 100644 index 000000000..9669d34f8 --- /dev/null +++ b/SQF/dayz_code/compile/client_plantSpawner.sqf @@ -0,0 +1,112 @@ +private ["_a","_b","_c","_plantcount","_roads","_road","_offset","_type","_angle","_i","_index", "_pos", "_forbid ", "_insideloop", "_ix", "_iy", "_rnd", "_maxperspot" ]; + + +//diag_log [ diag_tickTime, __FILE__, "Waiting dependency..." ]; + +waitUntil { !isNil "PVCDZ_plr_plantSpawner" }; +waitUntil { !isNil "sched_tg_grid" }; +// avoid called twice (don't know why...) +waitUntil { isNil "dayz_plantSpawner_done" }; +dayz_plantSpawner_done = 1; + +_a = PVCDZ_plr_plantSpawner select 0; // random generator for road segment to pick on map +_b = PVCDZ_plr_plantSpawner select 1; // random generator for plant position around the road segment +_c = PVCDZ_plr_plantSpawner select 2; // random generator for plant type 0..2 and plant orientation 0..360 +_blacklist = PVCDZ_plr_plantSpawner select 3; +_plantcount = 0; +_maxperspot = ceil (dayz_maxGlobalPlants / 2048 * 5); +[] spawn { sleep 90; dayz_plantSpawner_done = 2; }; // force dayz_plantSpawner_done to unlock player on login page +//diag_log [ diag_tickTime, __FILE__, "Starting plantmax/a/b/c/blacklist/_maxperspot: ", dayz_maxGlobalPlants, _a, _b, _c, _blacklist , _maxperspot]; + +_insideloop = { + _rnd = _this select 2; // a random number from _a PSRND + _this set [2,0]; +// diag_log _this; + _roads = _this nearRoads 100; + for "_j" from _maxperspot min (count _roads) to 1 step -1 do { + private [ "_cell", "_plantpos"]; + _offset = _b call psrnd; + _type = _c call psrnd; // WARNING: call all these psrnd ouside any "if" statement. pseudo random must be exhausted the same way on all clients. + _angle = _type select 1; + _type = _type select 0; + _rnd = _rnd + (_offset select 2); // add to another random number from _b PSRND + _road = _roads select (_rnd mod (count _roads)); // take a random segment if several ones are available + _this = getPosATL _road; + _plantpos = [ (_this select 0) + (_offset select 0), (_this select 1) + (_offset select 1), 0 ]; + if ((!(isOnRoad _plantpos) + and {!(surfaceIsWater _plantpos)}) + and {( ((surfaceType _plantpos) in ["#CRGrass1","#CRGrass2","CRGrassW1"]) + and {(0 == count (nearestObjects [_plantpos, [], 3]))} )} ) then { + _forbid = (1==0); + { + if ((_x distance _plantpos) < 3 ) exitWith { _forbid = (1==1); }; + } forEach _blacklist; + // insert in NEW TOWN GENERATOR grid + _ix = floor(((_plantpos select 0) - sched_tg_minX) / sched_tg_cellX); + _ix = 0 max (63 min _ix); + _iy = floor(((_plantpos select 1) - sched_tg_minY) / sched_tg_cellY); + _iy = 0 max (63 min _iy); + _index = _ix + _iy * 64; + _cell = sched_tg_grid select _index; + if (isNil "_cell") then { _cell = []; sched_tg_grid set [ _index, _cell]; }; + if (!_forbid) then { // don't spawn the plant because it has been gathered by another player + _cell set [ count _cell, [ objNull, Dayz_plants select _type, _plantpos, _angle ] ]; //_plantpos set [2, 0.5]; + //diag_log [ diag_tickTime, __FILE__, "new plant at", _plantpos]; + }; + _cell set [ count _cell, [ objNull, "ClutterCutter_small_2_EP1", +(_plantpos), _angle ] ];//"Sign_sphere100cm_EP1" + _plantcount = _plantcount + 1; + }; + _roads = _roads - [_road]; + if (_plantcount >= dayz_maxGlobalPlants) exitWith {}; + }; +}; + +for "_i" from 1 to 2048 do { + _pos = _a call psrnd; + _pos call _insideloop; + if (_plantcount >= dayz_maxGlobalPlants) exitWith {}; +}; +//diag_log [ diag_tickTime, __FILE__,"done! number/wanted", _plantcount, dayz_maxGlobalPlants ]; + +"PVDZ_objgather_Delete" addPublicVariableEventHandler { + private ["_plantpos","_ix","_iy","_index","_cell","_nearest","_distance","_d","_entry", "_x"]; + + _plantpos = (_this select 1); + diag_log [ diag_tickTime, __FILE__, _this, _plantpos]; + _ix = floor(((_plantpos select 0) - sched_tg_minX) / sched_tg_cellX); + _ix = 0 max (63 min _ix); + _iy = floor(((_plantpos select 1) - sched_tg_minY) / sched_tg_cellY); + _iy = 0 max (63 min _iy); + _index = _ix + _iy * 64; + _cell = sched_tg_grid select _index; + if (!isNil "_cell") then { + _nearest = -1; + _distance = sched_tg_cellX; + { + if ((_x select 1) in Dayz_plants) then { + _d = _plantpos distance (_x select 2); + if (_d < _distance) then { + _distance = _d; + _nearest = _forEachIndex; + }; + }; + } forEach _cell; + diag_log [ "found... cellindex/objectindex/distance/this", _index, _nearest, _d, _this ]; + if (_distance < 1) then { + _entry = _cell select _nearest; + if (!isNull (_entry select 0)) then { + deleteVehicle (_entry select 0); + diag_log "plant object deleted"; + _entry set [0, objNull]; + }; + _entry set [1, ""]; // object won't spawn anymore + diag_log "plant wont spawn anymore"; + }; + } + else { + diag_log [ "no plant found", _this]; + }; +}; + +dayz_plantSpawner_done = 2; + diff --git a/SQF/dayz_code/compile/fn_Padlock.sqf b/SQF/dayz_code/compile/fn_Padlock.sqf new file mode 100644 index 000000000..991cc39d6 --- /dev/null +++ b/SQF/dayz_code/compile/fn_Padlock.sqf @@ -0,0 +1,120 @@ +/* +File: fn_Padlock.sqf +Author: Deadactionman +Artwork: Dead Meat +Date: 25/01/15 (uk) +Description: + DayZ Padlock Functions +*/ + +padlockIDD = 76761; + +padlockColourDay = [0.85,0.85,0.85,1]; +padlockColourNight = [0.18,0.18,0.18,1]; + +padlock_open = { + disableSerialization; + _sunrise = call world_sunRise; + _colour = padlockColourDay; + if(daytime > _sunrise && daytime < (24 - _sunrise)) then { + _colour = padlockColourDay; + } else + { + _colour = padlockColourNight; + }; + + _path = "z\addons\dayz_code\gui\padlock\"; + _target = _this select 0; // TARGET LOCKABLE OBJECT + _newCode = _this select 1; // TRUE/FALSE SETTING A NEW CODE? + _digitArray = []; + _codeHistory = count(_target getVariable["dayz_padlockHistory",[]]) == 4; + + if (!_newCode && _codeHistory) then {_digitArray = _target getVariable["dayz_padlockHistory",[]];}; + if (count _digitArray != 4) then { + // NO OBJECT CODE SO GENERATE A RANDOM ONE + _digitArray = [0,0,0,0]; + { + _digitArray set[_forEachIndex,floor(random 10)]; + } forEach _digitArray; + }; + createDialog "DAYZ_PADLOCK"; + waitUntil{!isNull (findDisplay padlockIDD)}; + + ctrlEnable [1200,true]; + //ctrlSetText [1200, format["z\addons\dayz_code\gui\padlock\padlock_512X512.paa"]]; + _control = ((findDisplay padlockIDD) displayCtrl 1200); + _control ctrlSetTextColor _colour; + + uiNamespace setVariable ["dayz_padlockColour", _colour]; + uiNamespace setVariable ["dayz_padlockCode", _digitArray]; + uiNamespace setVariable ["dayz_padlockNewCode",_newCode]; + uiNamespace setVariable ["dayz_padlockTarget",_target]; + + _null = [_digitArray] spawn padlock_digitSet; +}; + +padlock_click = { + _digitArray = uiNamespace getVariable ["dayz_padlockCode", [0,0,0,0]]; + _buttonID = _this; + _newDigit = 0; + _inc = 0; + _id = 0; + switch (_buttonID) do { + case "1L": {_inc = 1;_id = 0;}; + case "1R": {_inc = -1;_id = 0;}; + case "2L": {_inc = 1;_id = 1;}; + case "2R": {_inc = -1;_id = 1;}; + case "3L": {_inc = 1;_id = 2;}; + case "3R": {_inc = -1;_id = 2;}; + case "4L": {_inc = 1;_id = 3;}; + case "4R": {_inc = -1;_id = 3;}; + }; + _newDigit = (_digitArray select _id) + _inc; + + if (_newDigit < 0) then { + _newDigit = 9; + }; + if (_newDigit > 9) then { + _newDigit = 0; + }; + + _digitArray set[_id,_newDigit]; + uiNamespace setVariable ["dayz_padlockCode", _digitArray]; + _null = [_digitArray] spawn padlock_digitSet; +}; + +padlock_digitSet = { + disableSerialization; + _digitArray = _this select 0; + _colour = uiNamespace getVariable ["dayz_padlockColour", padlockColourDay]; + { + ctrlEnable [_x,true]; + ctrlSetText [_x, format["z\addons\dayz_code\gui\padlock\%1.paa", (_digitArray select _forEachIndex)]]; + _control = ((findDisplay padlockIDD) displayCtrl _x); + _control ctrlSetTextColor _colour; + } forEach [1201,1202,1203,1204]; + uiNamespace setVariable ["dayz_padlockCode", _digitArray]; +}; + +padlock_hasp = { + _digitArray = uiNamespace getVariable ["dayz_padlockCode", [0,0,0,0]]; + _newCode = uiNamespace getVariable ["dayz_padlockNewCode",false]; + _target = uiNamespace getVariable ["dayz_padlockTarget",player]; + + if (_newCode) then { + //[_unitSending,_object,_code] + PVDZ_Server_processSetAccessCode = [player,_target,_digitArray]; + publicVariableServer "PVDZ_Server_processSetAccessCode"; + } + else + { + //[_unitSending,_object,_code] + PVDZ_Server_processCode = [player,_target,_digitArray]; + publicVariableServer "PVDZ_Server_processCode"; + }; + closeDialog(0); + +}; + + + diff --git a/SQF/dayz_code/compile/fn_damageHandler.sqf b/SQF/dayz_code/compile/fn_damageHandler.sqf index ab33babe6..71063c332 100644 --- a/SQF/dayz_code/compile/fn_damageHandler.sqf +++ b/SQF/dayz_code/compile/fn_damageHandler.sqf @@ -1,244 +1,407 @@ - scriptName "Functions\misc\fn_damageHandler.sqf"; /*********************************************************** - PROCESS DAMAGE TO A UNIT - - Function - - [unit, selectionName, damage, source, projectile] call fnc_usec_damageHandler; + + Modifyed by Alby + + PROCESS DAMAGE TO A UNIT + - Function + - [unit, selectionName, damage, source, projectile] call fnc_usec_damageHandler; ************************************************************/ -private ["_unit","_humanityHit","_myKills","_hit","_damage","_isPlayer","_unconscious","_wound","_isHit","_isInjured","_type","_hitPain","_isCardiac","_isHeadHit","_isMinor","_scale","_canHitFree","_rndPain","_rndInfection","_hitInfection","_lowBlood","_isPZombie","_source","_ammo","_unitIsPlayer","_isBandit"]; +private ["_unit","_hit","_damage","_unconscious","_source","_ammo","_Viralzed","_isMinor","_isHeadHit","_isPlayer","_isBandit","_punishment","_humanityHit","_myKills","_wpst","_sourceDist","_sourceWeap","_scale","_type","_nrj","_rndPain","_hitPain","_wound","_isHit","_isbleeding","_rndBleed","_hitBleed","_isInjured","_lowBlood","_rndInfection","_hitInfection","_isCardiac","_chance","_breakaleg","_model"]; _unit = _this select 0; _hit = _this select 1; _damage = _this select 2; _unconscious = _unit getVariable ["NORRN_unconscious", false]; -_isPZombie = player isKindOf "PZombie_VB"; _source = _this select 3; +_isPZombie = player isKindOf "PZombie_VB"; _ammo = _this select 4; -_type = [_damage,_ammo] call fnc_usec_damageType; - +_model = typeOf player; +_Viralzed = typeOf _source in DayZ_ViralZeds; _isMinor = (_hit in USEC_MinorWounds); _isHeadHit = (_hit == "head_hit"); -//_evType = ""; -//_recordable = false; _isPlayer = (isPlayer _source); -_humanityHit = 0; -_myKills = 0; -_unitIsPlayer = _unit == player; -if (_unitIsPlayer) then { - if (_hit == "") then { - if ((_source != player) && _isPlayer) then { - //Enable aggressor Actions - if (_source isKindOf "CAManBase") then { - _source setVariable["startcombattimer",1]; - }; - _canHitFree = player getVariable ["freeTarget",false]; +// anti-hack for local explosions (HelicopterExploSmall, HelicopterExploBig, SmallSecondary...) spawned by hackers +//diag_log [ diag_ticktime, __FILE__, _this]; +_breakaleg = (((_hit == "legs") AND {(_source==_unit)}) AND {((_ammo=="") AND {(Dayz_freefall select 1 > 3)})}) /*AND {(abs(time - (Dayz_freefall select 0))<1)}*/; +if ( (!_breakaleg) AND {(((isNull _source) OR {(_unit == _source)}) AND {((_ammo == "") OR {({damage _x > 0.9} count((getposATL vehicle _unit) nearEntities [["Air", "LandVehicle", "Ship"],15]) == 0) AND (count nearestObjects [getPosATL vehicle _unit, ["TrapItems"], 30] == 0)})})}) exitWith {0}; + +if (_unit == player) then +{ + if (_hit == "") then + { + if ((_source != player) and _isPlayer) then + { _isBandit = (player getVariable["humanity",0]) <= -5000; _isPZombie = player isKindOf "PZombie_VB"; + //_isBandit = (_model in ["Bandit1_DZ","BanditW1_DZ"]); + + //if player is not free to shoot at inform server that _source shot at player + if (!_isBandit && !(player getVariable ["OpenTarget",false])) then + { + PVDZ_send = [_source,"OpenTarget",[]]; + publicVariableServer "PVDZ_send"; + }; - if (!_canHitFree && !_isBandit && !_isPZombie) then { + // Due to server errors or desync killing someone in a bandit skin with >-2000 humanity CAN occur. + // Attacker should not be punished for killing a Bandit skin under any circumstances. + // To prevent this we check for Bandit Skin. + + // - Accidental Murder - \\ When wearing the garb of a non-civilian you are taking your life in your own hands + // Attackers humanity should not be punished for killing a survivor who has shrouded his identity in military garb. + + _punishment = _isBandit || {player getVariable ["OpenTarget",false]} && {!_isPZombie}; + _humanityHit = 0; + + if (!_punishment) then { + //_myKills = 200 - (((player getVariable ["humanKills",0]) / 3) * 150); + // how many non bandit players have I (the shot/damaged player) killed? + // punish my killer 200 for shooting a surivor + // but subtract 50 for each survivor I've murdered + //_humanityHit = -(_myKills * _damage); + //if (_humanityHit < -2000) then { + // _humanityHit = -2000; + //}; + // In the case of outrageous damage (crashes, explosions, desync repeated headshots); cap the limit on humanity lost. //Process Morality Hit _myKills = 0 max (1 - (player getVariable ["humanKills",0]) / 5); _humanityHit = -100 * _myKills * _damage; - /* PVS/PVC - Skaronator */ - if (_humanityHit != 0) then { - [_source,_humanityHit] spawn { - private ["_source","_humanityHit"]; - _source = _this select 0; - _humanityHit = _this select 1; - PVDZE_send = [_source,"Humanity",[_source,_humanityHit,30]]; - publicVariableServer "PVDZE_send"; - }; + [_source,_humanityHit] spawn { + private ["_source","_humanityHit"]; + _source = _this select 0; + _humanityHit = _this select 1; + PVDZ_send = [_source,"Humanity",[_source,_humanityHit,30]]; + publicVariableServer "PVDZ_send"; + }; + }; + }; + }; + + if ((vehicle player == player) and (!_unconscious)) then { + if (_ammo == "tranquiliser_bolt") then { + [_unit] spawn { + private ["_unit"]; + _unit = _this select 0; + cutText [localize "str_player_tranquilized", "PLAIN DOWN"]; + //systemChat format ["YOU HAVE BEEN TRANQUILISED"]; + //sleep 2; + // 0 fadeSound 0.05; + //sleep 5; + [_unit,0.01] call fnc_usec_damageUnconscious; + _unit setVariable ["NORRN_unconscious", true, true]; + r_player_timeout = round(random 60); + r_player_unconscious = true; + player setVariable["medForceUpdate",true,true]; + player setVariable ["unconsciousTime", r_player_timeout, true]; + }; + }; + + if (_damage > 0.4) then { + //Melee knockout system + if ((_isHeadHit) and (_ammo in ["Sledge_Swing_Ammo","Crowbar_Swing_Ammo","Bat_Swing_Ammo"])) then { + [_unit] spawn { + _unit = _this select 0; + cutText ["you have been knocked out", "PLAIN DOWN"]; + [_unit,0.01] call fnc_usec_damageUnconscious; + _unit setVariable ["NORRN_unconscious", true, true]; + r_player_timeout = 20 + round(random 60); + r_player_unconscious = true; + player setVariable["medForceUpdate",true,true]; + player setVariable ["unconsciousTime", r_player_timeout, true]; }; }; }; }; + + + //Log to server :-( OverProcessing really not needed. + if (((!(isNil {_source})) AND {(!(isNull _source))}) AND {((_source isKindOf "CAManBase") AND {(!local _source )})}) then { + if (diag_ticktime-(_source getVariable ["lastloghit",0])>2) then { + private ["_sourceWeap"]; + _source setVariable ["lastloghit",diag_ticktime]; + _wpst = weaponState _source; + + _sourceDist = round(_unit distance _source); + _sourceWeap = switch (true) do { + case ((vehicle _source) != _source) : { format ["in %1",getText(configFile >> "CfgVehicles" >> (typeOf (vehicle _source)) >> "displayName")] }; + case (_ammo == "zombie") : { _ammo }; + case (_wpst select 0 == "Throw") : { format ["with %1 thrown", _wpst select 3] }; + case (["Horn", currentWeapon _source] call fnc_inString) : {"with suspicious vehicle "+str((getposATL _source) nearEntities [["Air", "LandVehicle", "Ship"],5])}; + case (["Melee", _wpst select 0] call fnc_inString) : { format ["with %2%1",_wpst select 0, if (_sourceDist>6) then {"suspicious weapon "} else {""}] }; + case ((_wpst select 0 == "") AND {(_wpst select 4 == 0)}) : { format ["with %1/%2 suspicious", primaryWeapon _source, _ammo] }; + case (_wpst select 0 != "") : { format ["with %1/%2 ", _wpst select 0, _ammo, _wpst select 4] }; + default { "with suspicious weapon" }; + }; + if (_ammo != "zombie") then { // don't log any zombie wounds, even from remote zombies + PVDZ_sec_atp = [_unit, _source, _sourceWeap, _sourceDist]; + publicVariableServer "PVDZ_sec_atp"; + }; + }; + }; }; -//PVP Damage +//Pure blood damage _scale = 200; -if (_damage > 0.4) then { - if (_ammo != "zombie") then { - _scale = _scale + 50; - }; - if (_isHeadHit) then { - _scale = _scale + 500; - }; - if ((isPlayer _source) && !(player == _source)) then { - _scale = _scale + 800; - if (_isHeadHit) then { - _scale = _scale + 500; - }; - }; - switch (_type) do { - case 1: {_scale = _scale + 200}; - case 2: {_scale = _scale + 200}; - }; - if (_unitIsPlayer) then { - //Cause blood loss - //Log Damage - /* - if (DZE_Debug_Damage) then { - 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); - }; +_type = 0; +if ((_ammo isKindof "Grenade") or (_ammo isKindof "ShellBase") or (_ammo isKindof "TimeBombCore") or (_ammo isKindof "BombCore") or (_ammo isKindof "MissileCore") or (_ammo isKindof "RocketCore") or (_ammo isKindof "FuelExplosion") or (_ammo isKindof "GrenadeBase")) then { + _type = 1; }; +if ((_ammo isKindof "B_127x107_Ball") or (_ammo isKindof "B_127x99_Ball")) then { + _type = 2; +}; + +if (_damage > 0.4) then { + if (_ammo != "zombie") then { + _scale = _scale + 50; //250 + }; + //Start body part scale + if (_ammo == "zombie") then { + //_scale = _scale * 3; //600 = Normal, 900 = Viral + _scale = getNumber (configFile >> "CfgVehicles" >> (typeOf _source) >> "damageScale"); + if (dayz_DamageMultiplier > 1) then { + _scale = _scale * dayz_DamageMultiplier; + }; + //diag_log format["%1, DamageScale: %2",__FILE__,_scaleNew]; + }; + + if (_isHeadHit) then { + _scale = _scale * 2; //700 = Normal, 900 = Viral, 500 = wild + }; + + //End body part scale + 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 { + //diag_log ("DAMAGE: player hit by " + (typeOf _source) + " in " + _hit + " with " + _ammo + " for " + str(_damage) + " scaled " + str(_damage * _scale) + " Conscious " + str (!_unconscious)); + //diag_log format["DAMAGE: player hit by %1 in %2 with %3 for %4 scaled to %5, Conscious %6",(typeOf _source),_hit,if (_ammo == "") then { "" } else { _ammo },(str(_damage)),(str(_damage * _scale)),(str (!_unconscious))]; + 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 { + private ["_type"]; + if (_ammo == "zombie") then { + if (_hit == "legs") then { + [_unit,_hit,(_damage / 6)] call object_processHit; + } else { + [_unit,_hit,(_damage / 4)] call object_processHit; + }; + } else { + if (_breakaleg) then { + _nrj = ((Dayz_freefall select 1)*20) / 100; + _gravity = 9.81 min (2*(Dayz_freefall select 1)/((0.00001 + (Dayz_freefall select 2))^2)); + _nrj2 = _gravity * (Dayz_freefall select 1); + //diag_log [ "handler freefall", _nrj, _nrj2, Dayz_freefall]; + if (random(_nrj2 / (5 * 9.81)) > 0.5) then { // freefall from 5m => 1/2 chance to get hit legs registered + diag_log[__FILE__, "Legs damage registered from freefall, damage:",_damage,"gravity:", _gravity, + "height:", (Dayz_freefall select 1), "blood loss", (_nrj2 * 25) ]; + [_unit,_hit,_damage] call object_processHit; + } else { + [_unit,"arms",(_damage / 6)] call object_processHit; // prevent broken legs due to arma bugs + }; + if (_nrj2 > 30) then { + (3 min (_nrj2/100)) call fnc_usec_bulletHit; // red flash + r_player_blood = 0 max (r_player_blood - (_nrj2 * 25)); + }; + } else { + [_unit,_hit,(_damage / 2)] call object_processHit; + }; [_unit,_hit,(_damage / 2)] call object_processHit; }; - if (_ammo == "") then { - [_unit,_hit,_damage] call object_processHit; - }; }; - -if (_unitIsPlayer) then { -//incombat - _unit setVariable["startcombattimer", 1]; +if (_unit == player) then { +//Set player in combat + _unit setVariable["startcombattimer", 1]; }; +//Shake the cam, frighten them! if (_damage > 0.1) then { - if (_unitIsPlayer) then { - //shake the cam, frighten them! - //player sidechat format["Processed bullet hit for %1 (should only be for me!)",_unit]; - 1 call fnc_usec_bulletHit; - }; - if (local _unit) then { - _unit setVariable["medForceUpdate",true,true]; - }; + if (_unit == player) then { + //player sidechat format["Processed bullet hit for %1 (should only be for me!)",_unit]; + 1 call fnc_usec_bulletHit; + }; + if (local _unit) then { + _unit setVariable["medForceUpdate",true,true]; + }; }; -if (_damage > 0.4) then { //0.25 - /* - BLEEDING - */ - _wound = _hit call fnc_usec_damageGetWound; - _isHit = _unit getVariable[_wound,false]; - if (_unitIsPlayer) then { - _rndPain = (random 10); - _rndInfection = (random 500); - _hitPain = (_rndPain < _damage); - if ((_isHeadHit) || (_damage > 1.2 && _hitPain)) then { - _hitPain = true; - }; - _hitInfection = (_rndInfection < 1); - //player sidechat format["HitPain: %1, HitInfection %2 (Damage: %3)",_rndPain,_rndInfection,_damage]; //r_player_infected - if (_isHit) then { - //Make hit worse - if (_unitIsPlayer) then { - r_player_blood = r_player_blood - 50; - }; - }; - if (_hitInfection) then { - //Set Infection if not already - if (_unitIsPlayer && !_isPZombie) then { - r_player_infected = true; - player setVariable["USEC_infected",true,true]; - }; - }; - if (_hitPain) then { - //Set Pain if not already - if (_unitIsPlayer) then { - r_player_inpain = true; - player setVariable["USEC_inPain",true,true]; - }; - }; - if ((_damage > 1.5) && _isHeadHit) then { - [_source,"shothead"] spawn player_death; - }; - }; - if(!_isHit) then { +if (_damage > 0.4) then { + //Pain and Infection + if (_unit == player) then { + _rndPain = floor(random 10); + _hitPain = (_rndPain < _damage); + + if ((_isHeadHit) or (_damage > 1.2 and _hitPain)) then { + _hitPain = true; + }; + + if (_hitPain) 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(!_isPZombie) then { - //Create Wound - _unit setVariable[_wound,true,true]; + //Create wound and cause bleed + _wound = _hit call fnc_usec_damageGetWound; + _isHit = _unit getVariable["hit_"+_wound,false]; + + _isbleeding = false; + _isScratched = false; + switch true do { + default { + _rndBleed = floor(random 100); + _rndBleedChance = getNumber (configFile >> "CfgVehicles" >> (typeOf _source) >> "BleedChance"); + _hitBleed = (_rndBleed < _rndBleedChance); - [_unit,_wound,_hit] spawn fnc_usec_damageBleed; - /* PVS/PVC - Skaronator */ - _pos = getPosATL _unit; - _inRange = _pos nearEntities ["CAManBase",1000]; - { - // only send to other players - if(isPlayer _x && _x != player) then { - PVDZE_send = [_x,"Bleed",[_unit,_wound,_hit]]; - publicVariableServer "PVDZE_send"; - }; - } count _inRange; + if (_hitBleed) then { + _isbleeding = true; + }; + }; + }; - //Set Injured if not already - _isInjured = _unit getVariable["USEC_injured",false]; - if (!_isInjured) then { - _unit setVariable["USEC_injured",true,true]; - if ((_unitIsPlayer) && (_ammo != "zombie")) then { - dayz_sourceBleeding = _source; - }; - }; - //Set ability to give blood - _lowBlood = _unit getVariable["USEC_lowBlood",false]; - if (!_lowBlood) then { - _unit setVariable["USEC_lowBlood",true,true]; - }; - if (_unitIsPlayer) then { - r_player_injured = true; - }; - }; - }; + if (_ammo == "zombie") then { + + if(!_isHit and _isbleeding && !_isPZombie) then { + //Create Wound + _unit setVariable["hit_"+_wound,true,true]; + + PVDZ_hlt_Bleed = [_unit,_wound,_damage]; + publicVariable "PVDZ_hlt_Bleed"; // draw blood stream on character, on all gameclients + + [_unit,_wound,_hit] spawn fnc_usec_damageBleed; // draw blood stream on character, locally + + //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; + }; + + //HitInfection from zombies + if ((!r_player_infected) and !(r_player_Sepsis select 0)) then { + if (_ammo == "zombie") then { + _rndSepsis = floor(random 100); + _sepsisChance = getNumber (configFile >> "CfgVehicles" >> (typeOf _source) >> "sepsisChance"); + //_hitInfection = (_rndInfection < _infectionChance); + + if (_rndSepsis < _sepsisChance) then { + r_player_Sepsis = [true, diag_tickTime]; + player setVariable["USEC_Sepsis",true,true]; + }; + }; + }; + }; + } else { + if(!_isHit && !_isPZombie) then { + //Create Wound + _unit setVariable["hit_"+_wound,true,true]; + PVDZ_hlt_Bleed = [_unit,_wound,_damage]; + publicVariable "PVDZ_hlt_Bleed"; // draw blood stream on character, on all gameclients + [_unit,_wound,_hit] spawn fnc_usec_damageBleed; // draw blood stream on character, locally + //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) && (_unitIsPlayer)) then { - //affect the player - [20,45] call fnc_usec_pitchWhine; //Visual , Sound - }; - if (_damage > 4) then { - //serious ballistic damage - if (_unitIsPlayer) then { - [_source,"explosion"] spawn player_death; - }; - } else { - if (_damage > 2) then { - _isCardiac = _unit getVariable["USEC_isCardiac",false]; - if (!_isCardiac) then { - _unit setVariable["USEC_isCardiac",true,true]; - r_player_cardiac = true; - }; - }; - }; + /* + 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 (_unitIsPlayer) then { - [_source,"shotheavy"] spawn player_death; - }; - } else { - if (_damage > 2) then { - _isCardiac = _unit getVariable["USEC_isCardiac",false]; - if (!_isCardiac) then { - _unit setVariable["USEC_isCardiac",true,true]; - r_player_cardiac = true; - }; - }; - }; + /* + 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 && !_isMinor && ((_damage > 2) || ((_damage > 0.5) && _isHeadHit))) then { - //set unconsious - [_unit,_damage] call fnc_usec_damageUnconscious; -}; \ No newline at end of file +if (_ammo == "zombie") then { + if (!_unconscious and !_isMinor and _isHeadHit) then { + _chance = random 1; + if ((_damage > 0.8) and (_chance < 0.5)) then { + [_unit,_damage] call fnc_usec_damageUnconscious; + }; + }; +} else { + if (!_unconscious and !_isMinor and ((_damage > 2) or ((_damage > 0.5) and _isHeadHit))) then { + //set unconsious + [_unit,_damage] call fnc_usec_damageUnconscious; + }; +}; + +// all "HandleDamage event" functions should return the effective damage that the engine will record +0 + diff --git a/SQF/dayz_code/compile/fn_damageHandlerZ.sqf b/SQF/dayz_code/compile/fn_damageHandlerZ.sqf index 6d983c12b..a9cce613a 100644 --- a/SQF/dayz_code/compile/fn_damageHandlerZ.sqf +++ b/SQF/dayz_code/compile/fn_damageHandlerZ.sqf @@ -1,17 +1,22 @@ //[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"]; +private ["_damage","_headShots"]; -_zed = _this select 0; -_selection = _this select 1; -_damage = _this select 2; -_hitter = _this select 3; -_projectile = _this select 4; +_zed = _this select 0; +_selection = _this select 1; +_damage = _this select 2; +_hitter = _this select 3; +_projectile = _this select 4; + +_meleeAmmo = ["Hatchet_Swing_Ammo","Sledge_Swing_Ammo","Machete_Swing_Ammo","Crowbar_Swing_Ammo","Bat_Swing_Ammo","BatBarbed_Swing_Ammo","Fishing_Swing_Ammo","BatNailed_Swing_Ammo"]; + +if (_projectile in _meleeAmmo) then { + _damage = _damage * 10; +}; if (local _zed) then { - - if (_damage > 1 && _projectile != "") then { + if (_damage > 1 and _projectile != "") then { //Record deliberate critical damages switch (_selection) do { case "head_hit": { @@ -22,6 +27,9 @@ if (local _zed) then { }; }; }; + + //diag_log format["0: %1, 1: %2, 2: %3, 3: %4, 4: %5",_zed,_selection,_damage,_hitter,_projectile]; + if (_projectile isKindOf "Bolt") then { _damageOrg = _hitter getVariable["firedDamage",0]; //_unit getVariable["firedSelection",_selection]; if (_damageOrg < _damage) then { @@ -31,4 +39,6 @@ if (local _zed) then { }; }; }; + +// all "HandleDamage event" functions should return the effective damage that the engine will record _damage \ No newline at end of file diff --git a/SQF/dayz_code/compile/fn_dropItem.sqf b/SQF/dayz_code/compile/fn_dropItem.sqf new file mode 100644 index 000000000..cdc4084d7 --- /dev/null +++ b/SQF/dayz_code/compile/fn_dropItem.sqf @@ -0,0 +1,30 @@ +private ["_item","_pos","_nearByPile","_holder"]; + +//Radius to search for holder +#define PILE_SEARCH_RADIUS 2 +//Location to offset the holder +#define PILE_PLAYER_OFFSET [0,0,0] + +_item = _this; +_holder = objNull; + +//Lets get the location of the player in the world +_pos = player modeltoWorld PILE_PLAYER_OFFSET; + +//Check if a holder is close by the player. +_nearByPile= nearestObjects [_pos, ["WeaponHolder","WeaponHolderBase"],PILE_SEARCH_RADIUS]; + +if (count _nearByPile == 0) then { + _holder = createVehicle ["WeaponHolder", _pos, [], 0, "CAN_COLLIDE"]; +} else { + _holder = _nearByPile select 0; +}; + +//Add the item to the newly created holder or to the new holder. +_holder addMagazineCargoGlobal [_item,1]; + +//Make sure the holder spawns behind the physical location of the player +_holder setPosATL (player modeltoWorld PILE_PLAYER_OFFSET); + +//Revel the item +player reveal _holder; \ No newline at end of file diff --git a/SQF/dayz_code/compile/fn_inString.sqf b/SQF/dayz_code/compile/fn_inString.sqf index 12203f544..7870beea8 100644 --- a/SQF/dayz_code/compile/fn_inString.sqf +++ b/SQF/dayz_code/compile/fn_inString.sqf @@ -1,31 +1,29 @@ -/* -Author: Killzone_Kid - -Description: -Find a string within a string (case insensitive) - -Parameter(s): -_this select 0: string to be found -_this select 1: string to search in - -Returns: -Boolean (true when string is found) - -How to use: -_found = ["needle", "Needle in Haystack"] call KK_fnc_inString; -*/ +//Kilzone_Kid's megafast inString function +//caseinsensitive +//params [needle,haystack]; +private ["_found","_hayArr"]; -private ["_needle","_haystack","_needleLen","_hay","_found"]; -_needle = [_this, 0, "", [""]] call BIS_fnc_param; -_haystack = toArray ([_this, 1, "", [""]] call BIS_fnc_param); -_needleLen = count toArray _needle; -_hay = +_haystack; -_hay resize _needleLen; +scopeName "main"; +_needle = _this select 0; +_haystack = _this select 1; +_haystackArr = toArray _haystack; +_haystackLen = count _haystackArr; +_needleLen = count (toArray _needle); _found = false; -for "_i" from _needleLen to count _haystack do { - if (toString _hay == _needle) exitWith {_found = true}; - _hay set [_needleLen, _haystack select _i]; - _hay set [0, "x"]; - _hay = _hay - ["x"] +if (_needleLen <= _haystackLen) then { + _hayArr = []; + for "_i" from 0 to (_needleLen - 1) do { + _hayArr set [count _hayArr, _haystackArr select _i]; + }; + for "_i" from _needleLen to _haystackLen do { + if (toString _hayArr != _needle) then { + _hayArr set [_needleLen, _haystackArr select _i]; + _hayArr set [0, "x"]; + _hayArr = _hayArr - ["x"]; + } else { + _found = true; + breakTo "main"; + }; + }; }; -_found \ No newline at end of file +_found diff --git a/SQF/dayz_code/compile/fn_isInsideBuilding.sqf b/SQF/dayz_code/compile/fn_isInsideBuilding.sqf index 4f2bfa92d..169c8fdb3 100644 --- a/SQF/dayz_code/compile/fn_isInsideBuilding.sqf +++ b/SQF/dayz_code/compile/fn_isInsideBuilding.sqf @@ -1,36 +1,79 @@ -private ["_unit1","_building","_relPos","_boundingBox","_min","_max","_myX","_myY","_myZ","_inside"]; -_unit1 = _this select 0; -//_building = _this select 1; -_building = nearestObject [player, "HouseBase"]; - -//_type = typeOf _building; -_relPos = _building worldToModel (getPosATL _unit1); -_boundingBox = boundingBox _building; -//diag_log ("DEBUG: Building: " + str(_building) ); -//diag_log ("DEBUG: Building Type: " + str(_type) ); -//diag_log ("DEBUG: BoundingBox: " + str(_boundingBox) ); +/* + Created exclusively for ArmA2:OA - DayZMod. + Please request permission to use/alter/distribute from project leader (R4Z0R49) AND the author (facoptere@gmail.com) +*/ -_min = _boundingBox select 0; -_max = _boundingBox select 1; +// check if arg#0 is inside or on the roof of a building +// second argument is optional: +// - arg#1 is an object: check whether arg#0 is inside (bounding box of) arg#1 +// - missing arg#1: check whether arg#0 is inside (bounding box of) the nearest enterable building +// - arg#1 is a boolean: check also whether arg#0 is inside (bounding box of) some non-enterable buildings around. Can be used to check if a player or an installed item is on a building roof. +// - arg#0 is posATL, arg#1 should be a building -//diag_log ("Min: " + str(_min) ); -//diag_log ("Max: " + str(_max) ); - -_myX = _relPos select 0; -_myY = _relPos select 1; -_myZ = _relPos select 2; +private ["_unit","_inside","_building","_size"]; -//diag_log ("X: " + str(_myX) ); -//diag_log ("Y: " + str(_myY) ); -//diag_log ("Z: " + str(_myZ) ); +_check = { + private ["_inside"]; -if ((_myX > (_min select 0)) && (_myX < (_max select 0))) then { - if ((_myY > (_min select 1)) && (_myY < (_max select 1))) then { - if ((_myZ > (_min select 2)) && (_myZ < (_max select 2))) then { - _inside = true; - } else { _inside = false; }; - } else { _inside = false; }; -} else { _inside = false; }; + _building = _this select 0; + _point = _this select 1; + _inside = false; + _offset = 1; // shrink building boundingbox by this length. + + _relPos = _building worldToModel _point; + _boundingBox = boundingBox _building; + + _min = _boundingBox select 0; + _max = _boundingBox select 1; + _myX = _relPos select 0; + _myY = _relPos select 1; + _myZ = _relPos select 2; + + if ((_myX > (_min select 0)+_offset) and {(_myX < (_max select 0)-_offset)}) then { + if ((_myY > (_min select 1)+_offset) and {(_myY < (_max select 1)-_offset)}) then { + if ((_myZ > (_min select 2)) and {(_myZ < (_max select 2))}) then { + _inside = true; + }; + }; + }; + //diag_log(format["fnc_isInsideBuilding: building:%1 typeOf:%2 bbox:%3 relpos:%4 result:%5", _building, typeOf(_building), _boundingBox, _relPos, _inside ]); + + _inside +}; + +_size = 0; +_unit = _this select 0; +if (typeName _unit == "OBJECT") then { + _size = sizeOf typeOf _unit; + _unit = getPosATL _unit; +}; + +_inside = false; + +if (count _this > 1 AND {(typeName (_this select 1) == "OBJECT")}) then { + // optional argument #1 can be the building used for the check + _building = _this select 1; + _inside = [_building, _unit] call _check; +} +else { + // else perform check with nearest enterable building (contains a path LOD) + if (typeName _unit == "OBJECT") then { + _building = nearestBuilding _unit; + _inside = [_building,getPosATL _unit] call _check; + }; + if ((!_inside) AND {(count _this > 1)}) then { // if optional argument is a boolean + { + _building = _x; + _type = typeOf _x; + if ((((!(_type IN DayZ_SafeObjects)) // not installable objects + AND {(!(_type isKindOf "ReammoBox"))}) // not lootpiles (weaponholders and ammoboxes) + AND {((_size + (sizeOf _type)) > _unit distance _x)}) // objects might colliding + AND {([_x, _unit] call _check)}) exitWith { // perform the check. exitWith works only in non-nested "if" + _inside = true; + }; + } forEach(nearestObjects [_unit, ["Building"], 50]); + }; +}; +//diag_log ("fnc_isInsideBuilding Check: " + str(_inside)+ " last building:"+str(_building)); -//diag_log ("isinBuilding Check: " + str(_inside) ); _inside \ No newline at end of file diff --git a/SQF/dayz_code/compile/fn_niceSpot.sqf b/SQF/dayz_code/compile/fn_niceSpot.sqf new file mode 100644 index 000000000..b8a887db6 --- /dev/null +++ b/SQF/dayz_code/compile/fn_niceSpot.sqf @@ -0,0 +1,214 @@ +/* + Created exclusively for ArmA2:OA - DayZMod. + Please request permission to use/alter/distribute from project leader (R4Z0R49) AND the author (facoptere@gmail.com) +*/ + +// Check/find a spot before pitching "Land_Fire_DZ", "TentStorage", "Wire_cat1", "Sandbag1_DZ" or "Hedgehog_DZ" +// _this 0: object class +// _this 1: object (player) or array (ATL format) +// _this 2: optional, empty array that will be filled by computed boolean: _testonLadder, _testSea, _testPond, _testBuilding, _testSlope, _testDistance +// return a worldspace consisting of array [ direction, ATL position ] or empty array if no position is found +// if 2nd argument is a player, the position returned is just in front of the player, direction is so that the object is "looking to" the player + +private ["_booleans","_class","_isPlayer","_size","_testPond","_testBuilding","_testonLadder","_testSlope","_testSea","_testDistance","_noCollision","_dir","_obj","_objectsPond","_ok","_maxdistance","_x","_new","_pos"]; + +_class = _this select 0; +_pos = _this select 1; + +_realSize = { + [[0,0], (boundingBox _this) select 1] call BIS_fnc_distance2D +}; + +// check that tent position is outside the pool footprint. +// we can't check altitude since pool has no height +_checkPerimeter = { + private ["_inside","_relPos","_point","_boundingBox","_min","_max","_myX","_myY","_building"]; + + _building = _this select 0; + _point = _this select 1; + _inside = false; + + _relPos = _building worldToModel _point; + _boundingBox = boundingBox _building; + //diag_log format ["%1 %2", _relPos, _boundingBox]; + _min = _boundingBox select 0; + _max = _boundingBox select 1; + _myX = _relPos select 0; + _myY = _relPos select 1; + + if ((_myX > (_min select 0)) and {(_myX < (_max select 0))}) then { + if ((_myY > (_min select 1)) and {(_myY < (_max select 1))}) then { + _inside = true; + }; + }; + + _inside +}; + +// check if _pos a player object or some ATL coordinates array +_isPlayer = (typeName _pos != "ARRAY"); + +_testBuilding = true; +_testDistance = _isPlayer; +_maxdistance = 5; +_testonLadder = _isPlayer; +_testPond = false; +_testSea = false; +_testSlope = false; +_noCollision = false; +switch _class do { + case "TentStorage" : { // tent pitching must follow all restrictions + _testPond = true; + _testSea = true; + }; + case "DomeTentStorage" : { // tent pitching must follow all restrictions + _testPond = true; + _testSea = true; + }; + case "StashSmall" : { + _testPond = true; + _testSea = true; + }; + case "StashMedium" : { + _testPond = true; + _testSea = true; + }; + case "Land_Fire_DZ" : { // no fire in the water :) + _testPond = true; + _testSea = true; + }; + case "CamoNet_DZ" : { // no fire in the water :) + _testPond = true; + _testSea = true; + _testSlope = false; + _noCollision = false; + _testBuilding = false; + }; + case "Wire_cat1" : {}; + case "Sandbag1_DZ" : {}; + case "Hedgehog_DZ" : {}; + default { // = vehicles (used for hive maintenance on startup) + _testBuilding = false; + _testSlope = false; + _noCollision = false; + }; +}; + +//diag_log(format["niceSpot: will test: pond:%1 building:%2 slope:%3 sea:%4 distance:%5 collide:%6", _testPond, _testBuilding, _testSlope, _testSea, _testDistance, _noCollision]); + +_dir = if (_isPlayer) then {getDir(_pos)} else {0}; +_obj = _class createVehicleLocal (getMarkerpos "respawn_west"); +sleep 0.01; +_size = _obj call _realSize; +if (_isPlayer) then { _size = _size + (_pos call _realSize); }; + +// compute initial position. If _pos is the player, then the object will be in front of him/her +_new = nil; +_new = if (_isPlayer) then { _pos modeltoworld [0,_size/2,0] } else { _pos }; +_new set [2, 0]; + +// place a temporary object (not colliding or can colliding) +if (_noCollision) then { + deleteVehicle _obj; + sleep 0.01; + _obj = _class createVehicleLocal _new; + // get non colliding position + _new = getPosATL _obj; + // get relative angle of object position according to player PoV + if (_isPlayer) then { + _x = _pos worldToModel _new; + _dir = _dir + (if ((_x select 1)==0) then { 0 } else { (_x select 0) atan2 (_x select 1) }); + }; +} else { + _obj setDir _dir; + _obj setPosATL(_new); +}; + +if (_testBuilding) then { // let's proceed to the "something or its operator in a building" test + _testBuilding = (([_obj, true] call fnc_isInsideBuilding) // obj in/close to a building (enterable or not) + // or _pos is a player who is in a *enterable* building + OR {(_isPLayer AND {([_pos, false] call fnc_isInsideBuilding)})}); +}; + +deleteVehicle _obj; +sleep 0.01; + +if (_testPond) then { // let's proceed to the "object in the pond" test (not dirty) + _testPond = false; + _objectsPond = nearestObjects [_new, [], 100]; + { + if (((typeOf(_x) == "") // unnamed class? + AND {((((_x worldToModel _new) select 2) < 0)) // below water level? + AND {([_x, _new] call _checkPerimeter)}}) // inside pond square footprint? + AND {(["pond", str(_x), false] call fnc_inString)} // and is actually a pond? + ) exitWith { + _testPond = true; + }; + } forEach _objectsPond; +}; + +if (_testSlope) then { // "flat spot" test + _testSlope = false; + _x = _new isflatempty [ + 0, // don't check collisions + 0, // don't look around + (0.1*_size), // slope gradient + _size, // object size + 1, // do not check in the sea + false, // don't check far from shore + if (_isPlayer) then {_pos} else {objNull} // not used -- seems buggy. + ]; + if (count _x < 2) then { // safepos found (gradient ok AND not in sea water) + _testSlope = true; + }; +}; + +if (_testSea) then { // "not in the sea, not on the beach" test + _testSea = false; + _x = _new isflatempty [ + 0, // don't check collisions + 0, // don't look around + 999, // do not check slope gradient + _size, // object size + 0, // check not in the sea + false, // don't check far from shore + if (_isPlayer) then {_pos} else {objNull} // not used -- seems buggy. + ]; + if (count _x < 2) then { // safepos found (gradient ok AND not in sea water) + _testSea = true; + } + else { + _x set [2,0]; + _x = ATLtoASL _x; + if (_x select 2 < 3) then { // in the wave foam + _testSea = true; + }; + }; +}; + +if (_testDistance) then { // check effective distance from the player + _testDistance = ((_pos distance _new) > _maxdistance); +}; + +if (_testonLadder) then { // forbid item install process if player is on a ladder (or in a vehicle) + _testonLadder = ( + ((getNumber (configFile >> "CfgMovesMaleSdr" >> "States" >> (animationState _pos) >> "onLadder")) == 1) + OR {((isPlayer _pos) AND {((vehicle _pos) != _pos)})} + ); +}; + +//diag_log(format["niceSpot: result pond:%1 building:%2 slope:%3 sea:%4 distance:%5 collide:%6", _testPond, _testBuilding, _testSlope, _testSea, _testDistance, _noCollision]); + +_ok = !_testPond AND !_testBuilding AND !_testSlope AND !_testSea AND !_testDistance AND !_testonLadder; +if (count _this > 2) then { + _booleans = _this select 2; + _booleans set [0, _testonLadder]; + _booleans set [1, _testSea]; + _booleans set [2, _testPond]; + _booleans set [3, _testBuilding]; + _booleans set [4, _testSlope]; + _booleans set [5, _testDistance]; + //diag_log(format["niceSpot: booleans: %1", _booleans]); +}; + +if (_ok) then { [round(_dir), _new] } else { [] } diff --git a/SQF/dayz_code/compile/fn_selectRandom.sqf b/SQF/dayz_code/compile/fn_selectRandom.sqf new file mode 100644 index 000000000..f3e744c1a --- /dev/null +++ b/SQF/dayz_code/compile/fn_selectRandom.sqf @@ -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"]; + +_ret = nil; +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 diff --git a/SQF/dayz_code/compile/fn_selectRandomChance.sqf b/SQF/dayz_code/compile/fn_selectRandomChance.sqf new file mode 100644 index 000000000..d68748d72 --- /dev/null +++ b/SQF/dayz_code/compile/fn_selectRandomChance.sqf @@ -0,0 +1,15 @@ +/************************************************************ +Chance calc by deadactionman updated by R4Z0R49 + +Parameters: chance (0.00-1.00) +Returns: true/false + +E.G. +_return = [0.5] call fn_chance; // will return TRUE 50% of the time +_return = [0.25] call fn_chance; // will return TRUE 25% of the time +*************************************************************/ +private ["_result"]; + +if ((_this select 0) > (random 1)) then {_result = true;} else {_result = false;}; + +_result diff --git a/SQF/dayz_code/compile/fn_selectRandomLocation.sqf b/SQF/dayz_code/compile/fn_selectRandomLocation.sqf new file mode 100644 index 000000000..f44976a8d --- /dev/null +++ b/SQF/dayz_code/compile/fn_selectRandomLocation.sqf @@ -0,0 +1,38 @@ +private["_location","_minDistance","_maxDistance","_minobjectDistance","_X","_Y","_index"]; + +_position = _this select 0; +_minDistance = _this select 1; +_maxDistance = _this select 2; +_minobjectDistance = _this select 3; + +_X = _position select 0; +_Y = _position select 1; + +//_location = [_position, _minDistance, _maxDistance, 5, 0, 2000, 0] call BIS_fnc_findSafePos; +_index = 0; +while {_index < 50} do { + private["_PosX","_PosY","_isFlat"]; + _PosX = _X + (_maxDistance - (random (_maxDistance * 2))); + _PosY = _Y + (_maxDistance - (random (_maxDistance * 2))); + _location = [_PosX, _PosY, 0]; + + _isFlat = _location isflatempty [ + _minobjectDistance, //--- Minimal distance from another object + 0, //--- If 0, just check position. If >0, select new one + 0.7, //--- Max gradient + 5, //--- Gradient area + 0, //--- 0 for restricted water, 2 for required water, + false, //--- True if some water can be in 25m radius + objNull //--- Ignored object + ]; + + //if (!surfaceIsWater _location) then { _index = 50; }; + if (count _isFlat > 1) then { _index = 50; }; + + _index = _index + 1; +}; + +//_location = [_location select 0,_location select 1,0]; +//diag_log(str(_position)); +//diag_log(str(_location)); +_location \ No newline at end of file diff --git a/SQF/dayz_code/compile/fn_selectRandomWeighted.sqf b/SQF/dayz_code/compile/fn_selectRandomWeighted.sqf index e345d726e..ceb1ca0a5 100644 --- a/SQF/dayz_code/compile/fn_selectRandomWeighted.sqf +++ b/SQF/dayz_code/compile/fn_selectRandomWeighted.sqf @@ -5,15 +5,15 @@ scriptName "Functions\arrays\fn_selectRandomWeighted.sqf"; Description: Function to select a random item from an array, taking into account item weights. - The weights should be Numbers between 0 && 1, with a maximum precision of hundreds. - + 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? */ @@ -28,9 +28,8 @@ if ((typeName _weights) != (typeName [])) exitWith {debugLog "Log: [selectRandom 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 +for "_i" from 0 to ((count _weights) - 1) do { private ["_weight"]; _weight = _weights select _i; @@ -38,22 +37,21 @@ for "_i" from 0 to ((count _weights) - 1) do //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 && 1. - if (_weight < 0) then {debugLog "Log: [selectRandomWeighted] Weights should be more than || equal to 0; weight set to 0!"; _weight = 0}; - //if (_weight > 1) then {debugLog "Log: [selectRandomWeighted] Weights should be less than || equal to 1; weight set to 1!"; _weight = 1}; - + + //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 + + for "_k" from 0 to (_weight - 1) do { - _weighted = _weighted + [_i]; + _weighted set [(count _weighted), _i]; }; }; -//Randomly select an index from the weighted array && therefore an element. -private ["_index"]; +//Randomly select an index from the weighted array and therefore an element. _index = _weighted call BIS_fnc_selectRandom; _array select _index \ No newline at end of file diff --git a/SQF/dayz_code/compile/fn_setpitchbank.sqf b/SQF/dayz_code/compile/fn_setpitchbank.sqf index e4d61f028..18a4e1bf2 100644 --- a/SQF/dayz_code/compile/fn_setpitchbank.sqf +++ b/SQF/dayz_code/compile/fn_setpitchbank.sqf @@ -1,18 +1,18 @@ /************************************************************ -Set Pitch && Bank -By General Barron ([EMAIL=aw_barron@hotmail.com]aw_barron@hotmail.com[/EMAIL]) && vektorboson +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 && bank, +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; && -90 when pointing straight down. +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, && 180 when rolled upside down. +-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. @@ -20,9 +20,7 @@ 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"]; +private["_obj","_pitch","_bank","_yaw","_sign","_vdir","_vup"]; _obj = _this select 0; _pitch = _this select 1; @@ -38,24 +36,23 @@ _yaw = 360-(getdir _obj); //function to rotate a 2d vector around the origin //---------------------------- -_rotate = -{ -private ["_v","_d","_x","_y"]; +_rotate = { + private ["_vec","_dir","_xpos","_ypos"]; -//extract parameters -_v = +(_this select 0); //we don't want to modify the originally passed vector -_d = _this select 1; + //extract parameters + _vec = +(_this select 0); //we don't want to modify the originally passed vector + _dir = _this select 1; -//extract old x/y values -_x = _v select 0; -_y = _v select 1; + //extract old x/y values + _xpos = _vec select 0; + _ypos = _vec 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]; + //if vector is 3d, we don't want to mess up the last element + _vec set [0, (cos _dir)*_xpos - (sin _dir)*_ypos]; + _vec set [1, (sin _dir)*_xpos + (cos _dir)*_ypos]; -//return new vector -_v + //return new vector + _vec }; @@ -67,7 +64,7 @@ _v _sign = [1,-1] select (_pitch < 0); //cut off numbers above 180 -while {abs _pitch > 180} do {_pitch = _sign*((abs _pitch) - 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)}; @@ -83,7 +80,7 @@ _yaw = 360-(getdir _obj); //use bank to flip upside down _bank = _bank + 180; -//&& adjust our original pitch +//and adjust our original pitch _pitch = (180 - abs _pitch)*_sign; }; @@ -102,19 +99,19 @@ _vdir = [_vdir, _yaw] call _rotate; _sign = [1,-1] select (_bank < 0); //cut off numbers above 360 -while {abs _bank > 360} do {_bank = _sign*((abs _bank) - 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]; +_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; +_vup = [_vup, _yaw] call _rotate; //---------------------------- diff --git a/SQF/dayz_code/compile/fn_surfaceNoise.sqf b/SQF/dayz_code/compile/fn_surfaceNoise.sqf index e9c49b1c5..b3abab126 100644 --- a/SQF/dayz_code/compile/fn_surfaceNoise.sqf +++ b/SQF/dayz_code/compile/fn_surfaceNoise.sqf @@ -1,20 +1,30 @@ -//Assess Terrain -private ["_unit","_pos","_type","_typeA","_soundType","_soundVal","_array"]; -_unit = _this; -_pos = getPosATL _unit; -_type = surfaceType _pos; -_typeA = toArray _type; -_typeA set [0,"DEL"]; -_typeA = _typeA - ["DEL"]; -_type = toString _typeA; -// _test = 0; +private ["_type","_typeA","_test","_soundType","_soundVal","_soundval"]; -//diag_log ("FINDME: " + _type); +_type = surfaceType getPosATL _this; +_typeA = toArray _type; +_typeA set [0,"DEL"]; +_typeA = _typeA - ["DEL"]; +_type = toString _typeA; +//_test = 0; -_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; +_soundType = getText (configFile >> "CfgSurfaces" >> _type >> "soundEnviron"); +_soundVal = getArray (configFile >> "CfgVehicles" >> "CAManBase" >> "SoundEnvironExt" >> _soundType); +if ((isNil "_soundval") or {(count _soundval == 0)}) then { + _soundval = 25; +} +else { + _soundVal = _soundVal select 0; + if ((isNil "_soundval") or {(count _soundval <= 3)}) then { + _soundval = 25; + } + else { + _soundVal = parseNumber format["%1",_soundVal select 3]; + if (_soundVal == 0) then { + _soundVal = 25; + }; + }; }; -_array = [_soundType,_soundVal]; -_array \ No newline at end of file + +//diag_log format["Type: %1, SoundType: %2, SoundVal: %3",_type,_soundType,_soundVal]; + +[_soundType,_soundVal] \ No newline at end of file diff --git a/SQF/dayz_code/compile/fn_temperatur.sqf b/SQF/dayz_code/compile/fn_temperatur.sqf index 5f19d1461..5547d32c3 100644 --- a/SQF/dayz_code/compile/fn_temperatur.sqf +++ b/SQF/dayz_code/compile/fn_temperatur.sqf @@ -6,162 +6,173 @@ Does: Manages the body temperatur of a Player Possible Problems: => Balancing -Missing: +Missing: Save Functions - + Should Effects Sum Up? - + Math Functions for Water - + Player Update GUI Colours need to be checked - + Shivering Function need improments */ +private ["_difference","_isinvehicle","_isinbuilding","_daytime","_height_mod","_temp","_looptime","_vehicle_factor","_moving_factor","_fire_factor","_building_factor","_sun_factor","_water_factor","_rain_factor","_night_factor","_wind_factor","_raining","_sunrise","_fireplaces","_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) - private ["_looptime","_sun_factor","_building_factor","_vehicle_factor","_fire_factor","_water_factor","_rain_factor","_night_factor","_wind_factor","_height_mod","_difference","_isinbuilding","_isinvehicle","_raining","_sunrise","_building","_fireplaces","_daytime","_temp","_moving_factor"]; - - _looptime = _this; - - //Factors are equal to win/loss of factor*basic value - //All Values can be seen as x of 100: 100 / x = minutes from min temperetaure to max temperature (without other effects) +//Positive effects _vehicle_factor = 4; + _fire_factor = 15; _moving_factor = 7; - _fire_factor = 15; //Should be always: _rain_factor + _night_factor + _wind_factor || higher ! _building_factor = 7; - _sun_factor = 4; //max sunfactor linear over the day. highest value in the middle of the day + _sun_factor = 4; + +//Negative effects + _water_factor = 8; + _stand_factor = 2; + _rain_factor = 0.5; + _night_factor = 1.5; + _wind_factor = 2; +_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.6); + _difference = (_moving_factor * (_speed / 20)) min 7; +}; + //diag_log format["Moving - %1",_difference]; + +//fire +private ["_fireplaces"]; +_pPos = [player] call FNC_GetPos; +_fireplaces = nearestObjects [_pPos, ["flamable_DZ","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; - _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; + //diag_log format["fire - %1",_difference]; +}; + +//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 { - //speed factor - private["_vel","_speed"]; - _vel = velocity player; - _speed = round((_vel distance [0,0,0]) * 3.5); - _difference = (_moving_factor * (_speed / 20)) min 7; + 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); - //fire - private ["_fireplaces"]; - _pPos = [player] call FNC_GetPos; - _fireplaces = nearestObjects [_pPos, ["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; - }; + //diag_log format["sun - %1",_difference]; +}; + +//NEGATIVE EFFECTS + +//water +if((surfaceIsWater getPosATL player || dayz_isSwimming) && !_isinvehicle) then { + _difference = _difference - _water_factor; - //building - _building = nearestObject [player, "HouseBase"]; - if(!isNull _building) then { - if([player,_building] call fnc_isInsideBuilding) then { - //Make sure thate Fire && 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; - }; + //diag_log format["water - %1",_difference]; +}; + +//rain +if(_raining && !_isinvehicle && !_isinbuilding) then { + _difference = _difference - (rain * _rain_factor); + + //diag_log format["night - %1",_difference]; +}; + +//night +if((daytime < _sunrise || daytime > (24 - _sunrise)) && !_isinvehicle) then { + _daytime = if(daytime < 12) then {daytime + 24} else {daytime}; + if(_isinbuilding) then { + _difference = _difference - ((((_night_factor * -1) / (_sunrise^2)) * ((_daytime - 24)^2) + _night_factor)) / 2; } else { - dayz_inside = false; + _difference = _difference - (((_night_factor * -1) / (_sunrise^2)) * ((_daytime - 24)^2) + _night_factor); }; + //diag_log format["night - %1",_difference]; +}; + +//wind +if(((wind select 0) > 4 || (wind select 1) > 4) && !_isinvehicle && !_isinbuilding ) then { + _difference = _difference - _wind_factor; - //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 && sunset -> Only Positiv Values Possible - */ - - _difference = _difference + (-((_sun_factor / (12 - _sunrise)^2)) * ((daytime - 12)^2) + _sun_factor); - }; + //diag_log format["Wind - %1",_difference]; +}; + +//height +if (!_isinvehicle && overcast >= 0.6) then { + _height_mod = ((getPosASL player select 2) / 100) / 2; + _difference = _difference - _height_mod; + //diag_log format["height - %1",_difference]; +}; + +//Standing cooldown. +if ((speed player == 0) && !_isinvehicle && !_isinvehicle && !_isinbuilding) then { + _difference = _difference - _stand_factor; + + //diag_log format["Standing - %1",_difference]; +}; +//Calculate Change Value Basic Factor Looptime Correction Adjust Value to current used temperatur scala +_difference = _difference * SleepTemperatur / (60 / _looptime) * ((dayz_temperaturmax - dayz_temperaturmin) / 100); - //NEGATIVE EFFECTS - - //water - if(surfaceIsWater getPosATL player || dayz_isSwimming) then { - _difference = _difference + _water_factor; - }; - - //rain - if(_raining && !_isinvehicle && !_isinbuilding) then { - _difference = _difference + (rain * _rain_factor); - }; - - //night - private ["_daytime"]; - if((daytime < _sunrise || daytime > (24 - _sunrise)) && !_isinvehicle) then { - _daytime = if(daytime < 12) then {daytime + 24} else {daytime}; - if(_isinbuilding) then { - _difference = _difference + ((((_night_factor * -1) / (_sunrise^2)) * ((_daytime - 24)^2) + _night_factor)) / 2; - } else { - _difference = _difference + (((_night_factor * -1) / (_sunrise^2)) * ((_daytime - 24)^2) + _night_factor); - }; - }; - - //wind - if(((wind select 0) > 4 || (wind select 1) > 4) && !_isinvehicle && !_isinbuilding ) then { - _difference = _difference + _wind_factor; - }; - - //height - if (!_isinvehicle && overcast >= 0.6) then { - _height_mod = ((getPosASL player select 2) / 100) / 2; - _difference = _difference - _height_mod; - }; - - //Calculate Change Value Basic Factor Looptime Correction Adjust Value to current used temperatur scala - _difference = _difference * SleepTemperatur / (60 / _looptime) * ((dayz_temperaturmax - dayz_temperaturmin) / 100); - - //Change Temperatur Should be moved in a own Function to allow adding of Items which increase the Temp like "hot tea" - dayz_temperatur = (((dayz_temperatur + _difference) max dayz_temperaturmin) min dayz_temperaturmax); - - //Add Shivering - // Percent when the Shivering will start - if(dayz_temperatur <= (0.125 * (dayz_temperaturmax - dayz_temperaturmin) + dayz_temperaturmin)) then { - //CamShake as linear Function Maximum reached when Temp is at temp minimum. First Entry = Max Value - _temp = 0.6 * (dayz_temperaturmin / dayz_temperatur ); - addCamShake [_temp,(_looptime + 1),30]; //[0.5,looptime,6] -> Maximum is 25% of the Pain Effect - } else { - addCamShake [0,0,0]; //Not needed at the Moment, but will be necesarry for possible Items - }; +if (dayz_temperature_override) then { _difference = 0; if (dayz_temperatur < 37) then { dayz_temperatur = 37; } }; + +//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); + + +//diag_log format["%1 - %2",dayz_temperatur,_difference]; \ No newline at end of file diff --git a/SQF/dayz_code/compile/fn_unconscious.sqf b/SQF/dayz_code/compile/fn_unconscious.sqf index 2eae7725b..5dcc872d7 100644 --- a/SQF/dayz_code/compile/fn_unconscious.sqf +++ b/SQF/dayz_code/compile/fn_unconscious.sqf @@ -1,61 +1,124 @@ -private ["_totalTimeout","_timeout","_bloodLow","_display","_ctrl1","_ctrl1Pos","_disableHdlr"]; -disableSerialization; -if ((!r_player_handler1) && (r_handlerCount == 0)) then { - if (r_player_cardiac) then {r_player_timeout = r_player_timeout max 300;}; - _totalTimeout = r_player_timeout; - if (_totalTimeout == 0) then { _totalTimeout = 1; }; - 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; - if (vehicle player == player) then { - player playAction "CanNotMove"; +// (c) facoptere@gmail.com, licensed to DayZMod for the community + +private ["_count","_anim","_weapon","_sprint","_stance","_transmove","_start","_timeout","_short","_sandLevel","_veh","_disableHdlr", "_speed"]; + +if (r_player_unconsciousInProgress) exitWith {}; +r_player_unconsciousInProgress = true; + +/* + _anim = toArray animationState player; + _weapon = if (count _anim <= 17) then { 0 } else { + switch (_anim select 17) do { + case 114 : { 2 }; // rifle + case 112 : { 1 }; // pistol + default { 0 }; // bare hands / flare + } }; - "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; - _disableHdlr = [] spawn { uiSleep 2; disableUserInput true; r_player_unconsciousInputDisabled = true; }; - 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"; - uiSleep 1; - _bloodLow = ((r_player_blood/r_player_bloodTotal) < 0.5); - - if(_timeout == 0) then { - if (!r_player_dead && !_bloodLow && r_player_injured) then { - _timeout = 10; - }; + _sprint = if (count _anim <= 10) then { false } else { _anim select 10 in [112, 118] }; + _stance = if (count _anim <= 5) then { 2 } else { + switch (_anim select 5) do { + case 107 : { 1 }; // kneel + case 112 : { 0 }; // prone + default { 2 }; // erected + } + }; + + _transmove = (switch true do { + case (player != vehicle player) : {""}; + case (_stance == 1) : { [ // kneeled + "amovpknlmstpsnonwnondnon_amovppnemstpsnonwnondnon", // kneeled stopped bare hands + "amovpknlmstpsraswpstdnon_amovppnemstpsraswpstdnon", // kneeled stopped pistol + "amovpknlmstpsraswrfldnon_amovppnemstpsraswrfldnon" // kneeled stopped rifle + ] select _weapon }; + case (_sprint) : { [ // erected and sprinting + "amovpercmsprsnonwnondf_amovppnemstpsnonwnondnon", // erected sprinting with bare hands + "amovpercmsprslowwpstdf_amovppnemstpsraswpstdnon", // erected sprinting pistol + "amovpercmsprslowwrfldf_amovppnemstpsraswrfldnon" // erected sprinting with rifle + ] select _weapon }; + case (_stance == 2) : {([ // erected and not sprinting + "amovpercmstpsnonwnondnon_amovppnemstpsnonwnondnon", // erected stoped/walking with bare hands + "amovpercmstpsraswpstdnon_amovppnemstpsraswpstdnon", // erected stoped/walking with pistol + "amovpercmstpsraswrfldnon_amovppnemstpsraswrfldnon" // erected stoped/walking with rifle + ] select _weapon)}; + default {""}; // already prone, or swimming, or onladder + }); + + //diag_log [ __FILE__, diag_tickTime, "current player move:",toString _anim, "collapse move:",_transmove, "duration:",r_player_timeout ]; + if (_transmove != "") then { player playmove _transmove; }; +*/ + +_start = diag_tickTime; +_timeout = abs r_player_timeout; +_short = _timeout < 4; +if (!_short) then { + 4 cutRsc ["playerStatusWaiting", "PLAIN",1]; + playSound "heartbeat_1"; +}; + +_count = 0; +// can be set to false by medEPI.sqf, during the 'while' loop +r_player_unconscious = true; +player setVariable ["NORRN_unconscious", r_player_unconscious, true]; +_sandLevel = ctrlPosition ((uiNamespace getVariable 'DAYZ_GUI_waiting') displayCtrl 1400); +//diag_log [(diag_tickTime - _start) < _timeout , !r_player_unconscious , alive player ]; + +// delay so that the character does not stop before falling: +_disableHdlr = [] spawn { sleep 2; disableUserInput true; r_player_unconsciousInputDisabled = 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; + +while { (diag_tickTime - _start) < _timeout and r_player_unconscious and alive player } do { + player setVariable ["unconsciousTime", _timeout - diag_tickTime + _start, (_count % 10) == 0]; + player setVariable["medForceUpdate",true, (_count % 300) == 0]; + if (!_short) then { + _sandLevel set [ 3, 0.136829 * safezoneH * (diag_tickTime - _start) / _timeout ]; + ((uiNamespace getVariable 'DAYZ_GUI_waiting') displayCtrl 1400) ctrlSetPosition _sandLevel; + ((uiNamespace getVariable 'DAYZ_GUI_waiting') displayCtrl 1400) ctrlCommit 0.05; + }; + + _veh = vehicle player; + if ((player != _veh) and {(_veh iskindOf "LandVehicle")}) then { + _speed = [0,0,0] distance velocity _veh; + if (_speed > 10) then { + _veh engineOn false; } else { - _timeout = _timeout - 1; - }; - - if (r_player_timeout > 0) then { - r_player_timeout = r_player_timeout - 1; - } else { - if (!r_player_dead) then { - _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]; - terminate _disableHdlr; - waituntil {scriptDone _disableHdlr}; - disableUserInput false; r_player_unconsciousInputDisabled = false; - if (!r_player_injured && ((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; -}; \ No newline at end of file + player action ["eject", _veh]; + player leaveVehicle _veh; + [] spawn { sleep 0.1; player switchmove "amovppnemstpsnonwnondnon"; }; // instant prone + }; + }; + + if (player == _veh) then { player setVelocity [0,0,0]; }; + sleep 0.1; + _count = _count + 1; + +}; + +if (!_short) then{ + 4 cutRsc ["default", "PLAIN",0]; +}; + +r_player_unconscious = false; +player setVariable ["NORRN_unconscious", r_player_unconscious, true]; +r_player_timeout = 0; +player setVariable ["unconsciousTime", r_player_timeout, true]; +r_player_cardiac = false; +player setVariable ["USEC_isCardiac",r_player_cardiac, true]; +player setVariable["medForceUpdate",true, true]; + +r_player_unconsciousInProgress = false; +terminate _disableHdlr; +waituntil {scriptDone _disableHdlr}; +disableUserInput false; +r_player_unconsciousInputDisabled = false; +4 cutRsc ["default", "PLAIN",1]; +player switchMove "AmovPpneMstpSnonWnonDnon_healed"; + +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; + +//diag_log [ __FILE__, diag_tickTime, "done" ]; \ No newline at end of file diff --git a/SQF/dayz_code/compile/fn_updateCraftUI.sqf b/SQF/dayz_code/compile/fn_updateCraftUI.sqf new file mode 100644 index 000000000..b4882b557 --- /dev/null +++ b/SQF/dayz_code/compile/fn_updateCraftUI.sqf @@ -0,0 +1,365 @@ +/* + Created by ziellos2k exclusively for DayZMod. + Please request permission to use/alter from ziellos2k. + + Edited by Alby with permission from ziellos2k. +*/ +disableSerialization; + +_getItemName = { + private ["_return","_classname"]; + _classname = _this select 0; + _return = _classname; + + if (isClass (configFile >> "CfgWeapons" >> _classname)) then { + if (isText (configFile >> "CfgWeapons" >> _classname >> "displayName")) then { + _return = getText (configFile >> "CfgWeapons" >> _classname >> "displayName"); + }; + }; + + if (isClass (configFile >> "CfgMagazines" >> _classname)) then { + if (isText (configFile >> "CfgMagazines" >> _classname >> "displayName")) then { + _return = getText (configFile >> "CfgMagazines" >> _classname >> "displayName"); + }; + }; + + _return; +}; + +_getItemPicture = { + private ["_return","_classname"]; + _classname = _this select 0; + _return = _classname; + + if (isClass (configFile >> "CfgWeapons" >> _classname)) then { + _return = getText (configFile >> "CfgWeapons" >> _classname >> "picture"); + }; + + if (isClass (configFile >> "CfgMagazines" >> _classname)) then { + _return = getText (configFile >> "CfgMagazines" >> _classname >> "picture"); + }; + + _return; +}; + +_inArray = { + private ["_return","_array","_search"]; + _array = _this select 0; + _search = _this select 1; + + _return = -1; + + for "_i" from 0 to (count _array) - 1 do { + if ((_array select _i) select 0 == _search) then { + _return = _i; + }; + }; + + _return; +}; + +_getGear = { + private ["_return","_index"]; + _return = []; + _weapons = []; + _magazines = []; + _nearByPile = nearestObjects [getPosATL player, ["SmallCraftTable_dz"], 3]; + if (count _nearByPile > 0) then { + _weaps = getWeaponCargo (_nearByPile select 0); + _mags = getMagazineCargo (_nearByPile select 0); + + //diag_log format ["%1, %2", _weaps, _mags]; + + //Add weapons + _objWpnTypes = _weaps select 0; + _objWpnQty = _weaps select 1; + + for "_i" from 0 to (count _objWpnTypes - 1) do { + _obj = _objWpnTypes select _i; + _index = [_return, _obj] call _inArray; + + if (_index != -1) then { + _return set [_index, [_obj, ((_return select _index) select 1) + (_objWpnQty select _i), 0]]; + } else { + _return set [count _return, [_obj, _objWpnQty select _i, 0]]; + }; + }; + + //Add Magazines + _objMagTypes = _mags select 0; + _objMagQty = _mags select 1; + + for "_i" from 0 to (count _objMagTypes - 1) do { + _obj = _objMagTypes select _i; + _index = [_return, _obj] call _inArray; + + if (_index != -1) then { + _return set [_index, [_obj, ((_return select _index) select 1) + (_objMagQty select _i), 0]]; + } else { + _return set [count _return, [_obj, _objMagQty select _i, 0]]; + }; + }; + + } else { + _weapons = weapons player; + _magazines = magazines player; + + { + _return set [count _return, [_x, 1, 0]]; + } forEach (_weapons); + + { + _index = [_return, _x] call _inArray; + + if (_index != -1) then { + _return set [_index, [_x, ((_return select _index) select 1) + 1, 0]]; + } else { + _return set [count _return, [_x, 1, 0]]; + }; + } forEach (_magazines); + }; + + _return; +}; + +_init = { + _itemArray = [] call _getGear; + uiNamespace setVariable ["DAYZ_CraftingDialog_Items", _itemArray]; +}; + +_cleanup = { + if (dialog) then { closeDialog 0 }; + uiNamespace setVariable ["DAYZ_CraftingDialog", nil]; + uiNamespace setVariable ["DAYZ_CraftingDialog_Items", nil]; +}; + +_addItem = { + private ["_selected","_classname","_index","_item","_classname","_gearcount","_tablecount"]; + _selected = lbCurSel _list; + _classname = _list lnbData [_selected, 2]; + + _index = [_itemArray, _classname] call _inArray; + _item = _itemArray select _index; + _classname = _item select 0; + _gearcount = _item select 1; + _tablecount = _item select 2; + + if (_gearcount > 0) then { + _gearcount = _gearcount - 1; + _tablecount = _tablecount + 1; + }; + + _itemArray set [_index, [_classname, _gearcount, _tablecount]]; +}; + +_removeItem = { + private ["_selected","_classname","_index","_item","_classname","_gearcount","_tablecount"]; + _selected = lbCurSel _list; + _classname = _list lnbData [_selected, 2]; + + _index = [_itemArray, _classname] call _inArray; + _item = _itemArray select _index; + _classname = _item select 0; + _gearcount = _item select 1; + _tablecount = _item select 2; + + if (_tablecount > 0) then { + _gearcount = _gearcount + 1; + _tablecount = _tablecount - 1; + }; + + _itemArray set [_index, [_classname, _gearcount, _tablecount]]; +}; + +_update = { + private ["_control","_pictureIndex","_item","_classname","_gearcount","_tablecount","_itemName","_itemPicture","_index"]; + lbClear _list; + + // clear crafting table boxes + for "_i" from 0 to 50 do { + _control = _display displayCtrl (200 + _i); + _control ctrlSetText ""; + }; + + _pictureIndex = 1; + + for "_i" from 0 to (count _itemArray) - 1 do { + _item = _itemArray select _i; + _classname = _item select 0; + _gearcount = _item select 1; + _tablecount = _item select 2; + + _itemName = [_classname] call _getItemName; + _itemPicture = [_classname] call _getItemPicture; + + _index = _list lnbAddRow [str _gearcount, "", _itemName, str _tablecount]; + _list lnbSetData [[_index, 2], _classname]; + _list lnbSetPicture [[_index, 1], _itemPicture]; + + for "_j" from 0 to _tablecount - 1 do { + _control = _display displayCtrl (200 + _pictureIndex); + _control ctrlSetText _itemPicture; + _pictureIndex = _pictureIndex + 1; + }; + }; +}; + +_craftItem = { + private ["_classList","_countList","_item","_classname","_tablecount","_arrayToSend"]; + _classList = []; + _countList = []; + + for "_i" from 0 to (count _itemArray) - 1 do { + _item = _itemArray select _i; + _classname = _item select 0; + _tablecount = _item select 2; + + if (_tablecount > 0) then { + _classList set [count _classList, _classname]; + _countList set [count _countList, _tablecount]; + }; + }; + + if (count _classList > 0) then { + _arrayToSend = [_classList,_countList]; + [_arrayToSend] call player_checkRecipe; + + }; +}; + +_construction = { + private ["_classList","_countList","_item","_classname","_tablecount","_arrayToSend"]; + _classList = []; + _countList = []; + + for "_i" from 0 to (count _itemArray) - 1 do { + _item = _itemArray select _i; + _classname = _item select 0; + _tablecount = _item select 2; + + if (_tablecount > 0) then { + _classList set [count _classList, _classname]; + _countList set [count _countList, _tablecount]; + }; + }; + + if (count _classList > 0) then { + _arrayToSend = [_classList,_countList]; + [_arrayToSend] call player_checkConstructionRecipe; + + }; +}; + +_getRecipes = { + private["_config","_control","_controlPos","_msg","_lines"]; + _config = configFile >> "CfgCrafting"; + _control = _display displayCtrl 430; + _controlPos = ctrlPosition _control; + _msg = ""; + _lines = 0; + + for "_i" from 0 to ((count _config) - 1) do { + _entry = _config select _i; + _input = getArray (_entry >> "input"); + _itemMsg = ""; + + if (count _input > 0) then { + _isRecipe = true; + + { + _item = _x select 0; + _amount = _x select 2; + + if (typeName _item == "ARRAY") then { + _amount = _item select 2; + _item = _item select 0; + }; + + _itemMsg = _itemMsg + format ["%1 %2
", _amount, [_item] call _getItemName]; + _lines = _lines + 1; + } forEach _input; + + _msg = _msg + format ["%1
%2
", getText (_entry >> "displayName"), _itemMsg]; + _lines = _lines + 2.25; + }; + }; + + _control ctrlSetPosition [_controlPos select 0, _controlPos select 1, _controlPos select 2, 0.03921 * _lines]; // text size * numoflines + _control ctrlSetStructuredText parseText _msg; + _control ctrlCommit 0; +}; + +_getconstructionRecipes = { + private["_config","_control","_controlPos","_msg","_lines"]; + _config = configFile >> "CfgConstruction"; + _control = _display displayCtrl 430; + _controlPos = ctrlPosition _control; + _msg = ""; + _lines = 0; + + for "_i" from 0 to ((count _config) - 1) do { + _entry = _config select _i; + _input = getArray (_entry >> "input"); + _itemMsg = ""; + + if (count _input > 0) then { + _isRecipe = true; + + { + _item = _x select 0; + _amount = _x select 2; + + if (typeName _item == "ARRAY") then { + _amount = _item select 2; + _item = _item select 0; + }; + + _itemMsg = _itemMsg + format ["%1 %2
", _amount, [_item] call _getItemName]; + _lines = _lines + 1; + } forEach _input; + + _msg = _msg + format ["%1
%2
", getText (_entry >> "displayName"), _itemMsg]; + _lines = _lines + 2.25; + }; + }; + + _control ctrlSetPosition [_controlPos select 0, _controlPos select 1, _controlPos select 2, 0.03921 * _lines]; // text size * numoflines + _control ctrlSetStructuredText parseText _msg; + _control ctrlCommit 0; +}; + +_display = uiNamespace getVariable ["DAYZ_CraftingDialog", nil]; +_itemArray = uiNamespace getVariable ["DAYZ_CraftingDialog_Items", []]; +_list = _display displayCtrl 432; + +_event = _this select 0; + +switch (_event) do { + case "initcrafting": { + [] call _init; + [] call _update; + [] call _getRecipes; + }; + case "initconstruction": { + [] call _init; + [] call _update; + [] call _getconstructionRecipes; + }; + case "add": { + [] call _addItem; + [] call _update; + }; + case "remove": { + [] call _removeItem; + [] call _update; + }; + case "craft": { + [] call _craftItem; + }; + case "close": { + [] call _cleanup; + }; + case "construction": { + [] call _construction; + }; +}; diff --git a/SQF/dayz_code/compile/fn_upgradeActions.sqf b/SQF/dayz_code/compile/fn_upgradeActions.sqf new file mode 100644 index 000000000..4106e8c90 --- /dev/null +++ b/SQF/dayz_code/compile/fn_upgradeActions.sqf @@ -0,0 +1,84 @@ +private ["_vehicle","_inVehicle","_cursorTarget","_onLadder","_canDo","_ownerArray","_text","_ownerBuildLock"]; + +scriptName "Functions\misc\fn_upgradeActions.sqf"; + +_vehicle = vehicle player; +_inVehicle = (_vehicle != player); +_cursorTarget = cursorTarget; + +if ((isNil "_cursorTarget") or {(isNull _cursorTarget)}) then { + _cursorTarget = nearestObjects [ player modelToWorld [0,1.5,0] , ["DZ_buildables","BuiltItems"], 1.5]; + _cursorTarget = if (count _cursorTarget == 0) then { objNull } else { _cursorTarget select 0 }; +}; + +_onLadder = (getNumber (configFile >> "CfgMovesMaleSdr" >> "States" >> (animationState player) >> "onLadder")) == 1; +_canDo = (!r_drag_sqf and !r_player_unconscious and !_onLadder); +r_action_build = false; + +dayz_resetUpgradeActions = { + player removeAction s_player_building; + s_player_building = -1; + player removeAction s_player_maintenance; + s_player_maintenance = -1; + player removeAction s_player_disassembly; + s_player_disassembly = -1; +}; + +if ((player getVariable["alreadyBuilding",0]) == 1) exitWith { call dayz_resetUpgradeActions; }; + +_maintenanceMode = _cursorTarget getVariable["Maintenance",false]; + +if (!isNull _cursorTarget and !_inVehicle and (player distance _cursorTarget < 4) and _canDo) then { + _ownerArray = _cursorTarget getVariable ["ownerArray",[]]; + _ownerBuildLock = _cursorTarget getVariable ["BuildLock",false]; +// diag_log [ diag_tickTime, __FILE__, "_ownerArray", _ownerArray, "PlayerUID", getPlayerUID player]; + //building System + _text = getText (configFile >> "CfgVehicles" >> typeOf _cursorTarget >> "displayName"); + + if ((_cursorTarget iskindof "DZ_buildables") and isText(configFile >> "CfgVehicles" >> (typeOf _cursorTarget) >> "Upgrade" >> "create") and !_ownerBuildLock) then { + if (s_player_building < 0) then { + if (isText (configFile >> "CfgVehicles" >> (typeof _cursorTarget) >> "Upgrade" >> "create")) then { + s_player_building = player addAction [format[localize "str_upgrade",_text], "\z\addons\dayz_code\actions\object_upgradebuilding.sqf",_cursorTarget, 0, false, true, "",""]; + }; + }; + } else { + player removeAction s_player_building; + s_player_building = -1; + }; + + if (_maintenanceMode and (_cursorTarget iskindof "DZ_buildables") and isClass(configFile >> "CfgVehicles" >> (typeof _cursorTarget) >> "Maintenance")) then { + if (s_player_maintenance < 0) then { + s_player_maintenance = player addAction [format[localize "str_maintenance",_text], "\z\addons\dayz_code\actions\object_maintenance.sqf",_cursorTarget, 0, false, true, "", ""]; + }; + } else { + player removeAction s_player_maintenance; + s_player_maintenance = -1; + }; + + + if ((((getPlayerUID player) in _ownerArray) or (count _ownerArray == 0) or ((typeof _cursorTarget) in ["WoodenFence_1_foundation","WoodenGate_foundation"])) and !_ownerBuildLock) then { + if (s_player_disassembly < 0) then { + if (isClass (configFile >> "CfgVehicles" >> (typeof _cursorTarget) >> "Disassembly")) then { + s_player_disassembly = player addAction [format[localize "str_disassembly",_text], "\z\addons\dayz_code\actions\object_disassembly.sqf",_cursorTarget, 0, false, true, "", "'ItemToolbox' in items player"]; + }; + }; + } else { + player removeAction s_player_disassembly; + s_player_disassembly = -1; + }; +} else { + call dayz_resetUpgradeActions; +}; + + +/* +dayz_resetUpgradeActions = { + s_player_disassembly = -1; + s_player_building = -1; + s_player_maintenance = -1; +}; +*/ + +//Monitor +player setVariable ["upgradeActions", diag_ticktime, false]; + diff --git a/SQF/dayz_code/compile/keyboard.sqf b/SQF/dayz_code/compile/keyboard.sqf index 79697d1a7..a72d4d40a 100644 --- a/SQF/dayz_code/compile/keyboard.sqf +++ b/SQF/dayz_code/compile/keyboard.sqf @@ -9,6 +9,18 @@ _altState = _this select 4; _handled = false; if (isNil "keyboard_keys") then { + _deadcheck = { // ESCAPE +// call player_forceSave; +// _idd = uiNamespace getVariable "RscDisplayMPInterrupt"; +// if (isNil '_idd') then { +// createDialog 'RscDisplayMPInterrupt'; +// } +// else { +// closeDialog 0; +// }; + //keyboard_keys = nil;*/ + _handled = false; + }; _cancelBuild = { DZE_cancelBuilding = true; call dayz_EjectPlayer; @@ -33,15 +45,15 @@ if (isNil "keyboard_keys") then { if (_ctrlState && !_altState) then {DZE_Z_ctrl = true;}; }; _rifle = { - ["rifle"] spawn player_switchWeapon; + 2 call dz_fn_switchWeapon; _handled = true; }; _pistol = { - ["pistol"] spawn player_switchWeapon; + 3 call dz_fn_switchWeapon; _handled = true; }; _melee = { - ["melee"] spawn player_switchWeapon; + 4 call dz_fn_switchWeapon; _handled = true; }; _throwable = { // select next non empty throwable weapon @@ -155,9 +167,9 @@ if (isNil "keyboard_keys") then { }; }; _drop = { - force_dropBody = true; //Prevent exploit of drag body _doors = nearestObjects [player, DZE_DoorsLocked, 3]; //Prevent exploit of glitching through doors if (count _doors > 0) then {_handled = true;}; + force_dropBody = true; }; _interrupt = { r_interrupt = true; @@ -171,12 +183,10 @@ if (isNil "keyboard_keys") then { }; }; _journal = { - /* if (!dayz_isSwimming and !dialog) then { [player,4,true,(getPosATL player)] call player_alertZombies; createDialog "horde_journal_front_cover"; }; - */ _handled = true; }; @@ -236,7 +246,6 @@ if (isNil "keyboard_keys") then { _handled = true; // used by keyboard.sqf r_interrupt = true; }; - if (player isKindOf "PZombie_VB") then { _handled = true; DZE_PZATTACK = true; @@ -283,6 +292,7 @@ if (isNil "keyboard_keys") then { [actionKeys "User17", {DZE_4 = true;}] call _addArray; [actionKeys "User18", {DZE_6 = true;}] call _addArray; [actionKeys "User19", {DZE_5 = true;}] call _addArray; + //[[DIK_ESCAPE], _deadcheck] call _addArray; [[DIK_1], _rifle] call _addArray; [[DIK_2], _pistol] call _addArray; [[DIK_3], _melee] call _addArray; @@ -312,10 +322,16 @@ if (isNil "keyboard_keys") then { // [[DIK_NUMPAD7], _rotate_left] call _addArray; // [[DIK_NUMPAD9], _rotate_right] call _addArray; [actionKeys "ForceCommandingMode", {DZE_5 = true;_handled = true;}] call _addArray; - [[ DIK_F9,DIK_F10,DIK_F11,DIK_F12, + [[ DIK_F9, DIK_F10, DIK_F11, DIK_F8,DIK_F7,DIK_F6,DIK_F5,DIK_F4, DIK_F3,DIK_F2,DIK_F1,DIK_0,DIK_9, DIK_8,DIK_7,DIK_6,DIK_5,DIK_4], _block] call _addArray; + if (serverCommandAvailable "#kick") then { + [[DIK_F12], gcam_onoff] call _addArray; // GCAM: F12 to start (for admins only) + } + else { + [[DIK_F12], _block] call _addArray; + }; (findDisplay 46) displayRemoveAllEventHandlers "KeyUp"; (findDisplay 46) displayRemoveAllEventHandlers "KeyDown"; @@ -329,4 +345,8 @@ if (!isNil "_code") then { call _code; }; +if (serverCommandAvailable "#kick") then { + GCam_KD = _this; // GCAM: GCam_KD is the current pressed key +}; + _handled \ No newline at end of file diff --git a/SQF/dayz_code/compile/local_gutObject.sqf b/SQF/dayz_code/compile/local_gutObject.sqf index 375e32102..ca4f6fdd5 100644 --- a/SQF/dayz_code/compile/local_gutObject.sqf +++ b/SQF/dayz_code/compile/local_gutObject.sqf @@ -9,6 +9,12 @@ if (local _animalbody) then { _animalbody addMagazine _rawfoodtype; }; + if (typeOf _animalbody == "Hen") then { + _amount = (floor (random 4)) + 2; + for "_x" from 1 to _amount do { + _animalbody addMagazine "equip_feathers"; + }; + }; [time, _animalbody] spawn { private ["_timer", "_body"]; _timer = _this select 0; diff --git a/SQF/dayz_code/compile/local_setFuel.sqf b/SQF/dayz_code/compile/local_setFuel.sqf new file mode 100644 index 000000000..04e1873dc --- /dev/null +++ b/SQF/dayz_code/compile/local_setFuel.sqf @@ -0,0 +1,3 @@ +_vehicle = _this select 0; +_qty = _this select 1; +_vehicle setFuel _qty; \ No newline at end of file diff --git a/SQF/dayz_code/compile/obj_handleDam.sqf b/SQF/dayz_code/compile/obj_handleDam.sqf new file mode 100644 index 000000000..504436acc --- /dev/null +++ b/SQF/dayz_code/compile/obj_handleDam.sqf @@ -0,0 +1,28 @@ +/*********************************************************** +ASSIGN DAMAGE TO A UNIT. +Called by "HandleDamage" vehicle Event Handler + +- Function fnc_obj_handleDam +- [unit, damage] call fnc_obj_handleDam; +- return : updated damage +************************************************************/ +private["_obj","_total","_currentDamage"]; + +_obj = _this select 0; +_damage = _this select 2; +_total = (damage _obj); + +if (_damage > 0) then { + _total = (damage _obj) + _damage; + + if (!isServer) then { + PVDZ_obj_Save = [_obj,"objWallDamage",_total]; + publicVariableServer "PVDZ_obj_Save"; + } else { + [_obj,"objWallDamage",_total] call server_updateObject; + }; +}; + + +// all "HandleDamage event" functions should return the effective damage that the engine will record for that part +_total diff --git a/SQF/dayz_code/compile/object_infectedcamps.sqf b/SQF/dayz_code/compile/object_infectedcamps.sqf new file mode 100644 index 000000000..15b90c4ea --- /dev/null +++ b/SQF/dayz_code/compile/object_infectedcamps.sqf @@ -0,0 +1,43 @@ +/* + Created exclusively for ArmA2:OA - DayZMod. + Please request permission to use/alter from R4Z0R49. +*/ + +//"Infected Camps: [[[7020.76,4072.34,0],40],[[10066.8,12114.3,0],20],[[10033.4,12525,0],20],[[9125.71,7742.72,0],40],[[6057.93,2655.66,0],40]]" +//Server_InfectedCamps, [[[_basePos],_amount,_radius]] + +//diag_log(str(__FILE__)); + +private ["_markerstr","_counter","_camp","_campName","_campPos","_campAmount","_campRadius","_trigger","_trgcode","_array"]; +_array = _this; +_counter = 0; + +{ + _counter = _counter + 1; + _camp = _x; + _campName = format["BaseCamp_%1",_counter]; +//diag_log ("Camp: " +str(_x)); + _campPos = _camp select 0; +//diag_log ("CampPos: " +str(_campPos)); + _campAmount = _camp select 1; +//diag_log ("CampAmont: " +str(_campAmount)); + _campRadius = _camp select 2; +//diag_log ("CampRadius: " +str(_campRadius)); +/* + _trigger = createTrigger["EmptyDetector",_campPos]; + _trigger setTriggerArea[_campRadius,_campRadius+100,false]; + _trigger setTriggerActivation["ANY","PRESENT",false]; + _trgcode = format["[%1,%2] call camp_spawnZombies;",_campPos,_campAmount]; + _trigger setTriggerStatements["player in thislist", _trgcode, ""]; + //_trigger setTriggerTimeout [0, 5, 3, false]; +*/ + + if ("ItemMap_Debug" in items player) then { + _markerstr = createMarker [_campName,_campPos]; + _markerstr setMarkerColor "ColorRed"; + _markerstr setMarkerShape "ELLIPSE"; + _markerstr setMarkerBrush "Border"; + _markerstr setMarkerSizeLocal [_campRadius, _campRadius]; + }; + +} foreach _array; \ No newline at end of file diff --git a/SQF/dayz_code/compile/object_monitorGear.sqf b/SQF/dayz_code/compile/object_monitorGear.sqf index fc1e235f9..08e4c265d 100644 --- a/SQF/dayz_code/compile/object_monitorGear.sqf +++ b/SQF/dayz_code/compile/object_monitorGear.sqf @@ -1,4 +1,5 @@ private["_countMagazines","_countWeapons","_countBackpacks","_countFreeSlots","_getControlText","_setControlText","_object","_objectName","_controlText","_magazinesMax","_weaponsMax","_backpacksMax","_distance","_isVehicle","_isMan","_isStorage","_isOK","_magazines","_weapons","_backpacks","_freeSlots","_timeout"]; +disableSerialization; _countWeapons = { private["_weapons","_return"]; @@ -38,7 +39,6 @@ _countFreeSlots = { _getControlText = { private["_control","_return"]; - disableSerialization; _control = (findDisplay 106) displayCtrl 156; _return = ctrlText _control; _return; @@ -46,11 +46,18 @@ _getControlText = { _setControlText = { private["_control"]; - disableSerialization; + /*for [{_i = 0}, {_i < (count _valueIDCs)}, {_i = _i + 1}] do { + _control = _display displayCtrl (_valueIDCs select _i); + _control ctrlSetText format ["%1", (_freeSlots select _i)]; + }; */ _control = (findDisplay 106) displayCtrl 156; _control ctrlSetText format["%1 (%2/%3/%4)", _objectName, _freeSlots select 0, _freeSlots select 1, _freeSlots select 2]; }; +_titleIDC = 1001; +_imageIDCs = [9001,9003,9005]; +_valueIDCs = [9002,9004,9006]; + if (vehicle player != player) then { _object = vehicle player; } else { @@ -67,23 +74,43 @@ waitUntil { !(isNull (findDisplay 106)) || (_timeout < time) }; //diag_log format["object_monitorGear.sqf: _object: %1 _isStorage: %4 _isVehicle: %2 _isMan: %3 _display: %5", _object, _isVehicle, _isMan, _isStorage, findDisplay 106]; -if ((_isVehicle || _isStorage || _isnewstorage) && (!_isMan) && (!(isNull (findDisplay 106)))) then { - _objectName = getText (configFile >> "CfgVehicles" >> (typeof _object) >> "displayName"); - _controlText = [] call _getControlText; - - if (_objectName == _controlText) then { - _weaponsMax = getNumber (configFile >> "CfgVehicles" >> (typeof _object) >> "transportMaxWeapons"); - _magazinesMax = getNumber (configFile >> "CfgVehicles" >> (typeof _object) >> "transportMaxMagazines"); - _backpacksMax = getNumber (configFile >> "CfgVehicles" >> (typeof _object) >> "transportMaxBackpacks"); - - while {!(isNull (findDisplay 106))} do { - _weapons = [] call _countWeapons; - _magazines = [] call _countMagazines; - _backpacks = [] call _countBackpacks; - _freeSlots = [] call _countFreeSlots; +if (!(isNull (findDisplay 106))) then { + _display = findDisplay 106; - [] call _setControlText; - uiSleep 0.01; + if ((_isVehicle or _isStorage || _isnewstorage) and (!_isMan)) then { + _objectName = getText (configFile >> "CfgVehicles" >> (typeof _object) >> "displayName"); + _controlText = [] call _getControlText; + + + if (_objectName == _controlText) then { + _weaponsMax = getNumber (configFile >> "CfgVehicles" >> (typeof _object) >> "transportMaxWeapons"); + _magazinesMax = getNumber (configFile >> "CfgVehicles" >> (typeof _object) >> "transportMaxMagazines"); + _backpacksMax = getNumber (configFile >> "CfgVehicles" >> (typeof _object) >> "transportMaxBackpacks"); + + + while {!(isNull (findDisplay 106))} do { + _weapons = [] call _countWeapons; + _magazines = [] call _countMagazines; + _backpacks = [] call _countBackpacks; + _freeSlots = [] call _countFreeSlots; + + [] call _setControlText; + uiSleep 0.01; + }; + } else { + (_display displayCtrl _titleIDC) ctrlShow false; + + for [{_i = 0}, {_i < (count _valueIDCs)}, {_i = _i + 1}] do { + (_display displayCtrl (_imageIDCs select _i)) ctrlShow false; + (_display displayCtrl (_valueIDCs select _i)) ctrlShow false; + }; + }; + } else { + (_display displayCtrl _titleIDC) ctrlShow false; + + for [{_i = 0}, {_i < (count _valueIDCs)}, {_i = _i + 1}] do { + (_display displayCtrl (_imageIDCs select _i)) ctrlShow false; + (_display displayCtrl (_valueIDCs select _i)) ctrlShow false; }; }; }; diff --git a/SQF/dayz_code/compile/object_processHit.sqf b/SQF/dayz_code/compile/object_processHit.sqf index 2971ae8f3..f3e4f2e2f 100644 --- a/SQF/dayz_code/compile/object_processHit.sqf +++ b/SQF/dayz_code/compile/object_processHit.sqf @@ -1,9 +1,9 @@ -private ["_unit","_selection","_strH","_dam","_display","_id","_break","_ctrlFracture","_total","_damage"]; -disableSerialization; -_unit = _this select 0; -_selection = _this select 1; -_damage = _this select 2; -_strH = "hit_" + (_selection); +private["_break","_ctrlFracture"]; +_unit = _this select 0; +_selection = _this select 1; +_damage = _this select 2; + +_strH = "hit_" + _selection; if (local _unit) then { _dam = _unit getVariable [_strH,0]; @@ -11,28 +11,28 @@ if (local _unit) then { _unit setVariable [_strH,_total,true]; _break = false; - if (_selection in USEC_MinorWounds && _total >= 1 && _unit == player) then { + if (_selection in USEC_MinorWounds and _total >= 1 and _unit == player) then { + disableSerialization; _display = uiNamespace getVariable 'DAYZ_GUI_display'; - _ctrlFracture = _display displayCtrl 1203; - - if ((_selection == "legs") && !r_fracture_legs) then { - r_fracture_legs = true; - _ctrlFracture ctrlShow true; - _id = [] spawn { + _ctrlFracture = _display displayCtrl 1203; + + if ((_selection == "legs") and !r_fracture_legs) then { + _id = [] spawn { //do not touch this spawn! player setHit["legs",1]; }; + r_fracture_legs = true; _break = true; }; - if ((_selection == "arms") && !r_fracture_arms) then { - r_fracture_arms = true; - _ctrlFracture ctrlShow true; - _id = [] spawn { - player setHit["hands",1]; + if ((_selection == "arms") and !r_fracture_arms) then { + _id = [] spawn { // do not touch this spawn! + player setHit["hands",1]; }; + r_fracture_arms = true; _break = true; }; }; if (_break) then { [player,"fracture",0,false] call dayz_zombieSpeak; + _ctrlFracture ctrlShow true; }; }; \ No newline at end of file diff --git a/SQF/dayz_code/compile/object_speak.sqf b/SQF/dayz_code/compile/object_speak.sqf index 916dad31a..e4aadce07 100644 --- a/SQF/dayz_code/compile/object_speak.sqf +++ b/SQF/dayz_code/compile/object_speak.sqf @@ -3,6 +3,18 @@ _unit = _this select 0; _type = _this select 1; _chance = _this select 2; +_dis = switch true do { + case (count _this > 4): {_this select 4}; + case (_type in ["shout","hit","attack","scream","breath"]): {100}; + default {40}; +}; + +_local = false; +if (count _this > 3) then { _local = _this select 3; }; +if (!_local) then { + // we override _local according to number of players inside _dis radius + _local = { _unit distance _x < _dis; } count playableUnits <= 1; +}; _num = switch (_type) do { default {0}; case "cough": {2}; @@ -39,7 +51,7 @@ if (count _this > 4) then { }; _isWoman = getText(configFile >> "cfgVehicles" >> (typeOf _unit) >> "TextPlural") == "Women"; -if (_isWoman && (_type in ["scream","panic","cough"])) then { +if (_isWoman and (_type in ["scream","panic"])) then { _type = _type + "_w"; }; diff --git a/SQF/dayz_code/compile/player_Bubble.sqf b/SQF/dayz_code/compile/player_Bubble.sqf new file mode 100644 index 000000000..983c81abb --- /dev/null +++ b/SQF/dayz_code/compile/player_Bubble.sqf @@ -0,0 +1,77 @@ +//diag_log ("Bubble Start"); + +//Create bubble around the default view distance. +//_position = getPosATL player; + +/* +//All zeds fall under "Zed_Base", 1600 is default viewdistance +_zedsMonitored = (getPosATL player) nearEntities ["Zed_Base",1600]; + +{ + if (!(_x in dayz_zedMonitor)) then { + //add active zed to var + dayz_zedMonitor set [count dayz_zedMonitor, _x]; + }; +} foreach _zedsMonitored; + + +diag_log format["Agent's in Bubble: %1",(count dayz_zedMonitor)]; +//Enable check for all active zeds +{ + //Swap zed back to server + isAlive = alive _x; + if (isAlive) then { + _isWild = _x isKindOf "WildZombie_Base"; + if (_isWild) then { + _isLocal = local _x; + if (_isLocal) then { + if ((player distance _x) > 200) then { + //_agent = _x getVariable ["agentObject", _x]; + //_position = _x getVariable ["homePos",(getPosATL _x)]; + _Owner = _x getVariable ["Owner",1]; //default 1 is server + PVDZ_Server_changeOwner = [_x, _Owner]; + publicVariableServer "PVDZ_Server_changeOwner"; + }; + } else { + if ((player distance _x) <= 200) then { + //["Target","Owner","Agent"] + //Swap ownership to player + if (!_isLocal) then { + PVDZ_Server_changeOwner = [_x, player]; + publicVariableServer "PVDZ_Server_changeOwner"; + + waitUntil { local _x }; + _agent = _x getVariable ["agentObject", _x]; + _position = _x getVariable ["homePos",(getPosATL _x)]; + [_position,_agent] execFSM "\z\addons\dayz_code\system\zombie_wildagent.fsm"; + }; + }; + }; + }; + + //is zed aboue default view distance + if ((player distance _x) <= 1600) then { + //Animate zeds + _x enableSimulation true; + PVDZ_Server_Simulation = [_x, true]; + publicVariableServer "PVDZ_Server_Simulation"; + } else { + //Remove zed from monitor + if (_x in dayz_zedMonitor) then { + dayz_zedMonitor = dayz_zedMonitor - [_x]; + }; + //Disable simulation + _x enableSimulation false; + PVDZ_Server_Simulation = [_x, false]; + publicVariableServer "PVDZ_Server_Simulation"; + }; + } else { + dayz_zedMonitor = dayz_zedMonitor - [_x]; + }; +} foreach dayz_zedMonitor; +*/ + +//BuildingMonitor +// moved to dayz_code/system/scheduler/sched_buildingBubble.sqf + +//diag_log ("Bubble END"); diff --git a/SQF/dayz_code/compile/player_alertZombies.sqf b/SQF/dayz_code/compile/player_alertZombies.sqf index 67d68786a..f3a215514 100644 --- a/SQF/dayz_code/compile/player_alertZombies.sqf +++ b/SQF/dayz_code/compile/player_alertZombies.sqf @@ -1,30 +1,98 @@ -private ["_unit","_distance","_listTalk","_zombie","_targets","_pos","_doRun"]; -//Alert Zed's to noise of shot +private ["_unit","_distance","_doRun","_pos","_listTalk","_zombie"]; + _unit = _this select 0; _distance = _this select 1; _doRun = _this select 2; _pos = _this select 3; -_listTalk = _pos nearEntities ["zZombie_Base",_distance/2]; -if ("ItemMap_Debug" in items player) then { - diag_log ("alertzeds Unit: " +str(_unit)); - diag_log ("alertzeds Distance: " +str(_distance/2)); - diag_log ("alertzeds DoRun: " +str(_doRun)); - diag_log ("alertzeds Pos: " +str(_pos)); - diag_log ("alertzeds ListTalk: " +str(_listTalk)); -}; - -//hint str(_listTalk); +_listTalk = _pos nearEntities ["zZombie_Base",_distance]; +_inVehicle = (vehicle _unit != _unit); +_isAir = vehicle player iskindof "Air"; +_isLand = vehicle player iskindof "Land"; +_isSea = vehicle player iskindof "Sea"; +_speed = speed (vehicle _unit); { +private["_localtargets","_remotetargets","_targets","_dis"]; + + _distance = _distance max floor(_distance*.9); + + _dis = _x distance _unit; + _zombie = _x; + + switch (true) do { + case (_dis < 51): { + if (_doRun) then { + _localtargets = _x getVariable ["localtargets",[]]; + _remotetargets = _x getVariable ["remotetargets",[]]; + _targets = _localtargets + _remotetargets; + if (!(_unit in _targets)) then { + switch (local _x) do { + case false: { + _remotetargets set [count _remotetargets,_unit]; + _x setVariable ["remotetargets",_remotetargets,true]; + }; + case true: { + _localtargets set [count _localtargets,_unit]; + _x setVariable ["localtargets",_localtargets,false]; + }; + }; + }; + } else { + _zombie setVariable ["myDest",_pos,true]; + }; + }; + case ((_dis > 50) and (_dis <= 71)): { + _50 = round(random 100); + if (_50 < 50) then { + if (_doRun) then { + _localtargets = _x getVariable ["localtargets",[]]; + _remotetargets = _x getVariable ["remotetargets",[]]; + _targets = _localtargets + _remotetargets; + if (!(_unit in _targets)) then { + switch (local _x) do { + case false: { + _remotetargets set [count _remotetargets,_unit]; + _x setVariable ["remotetargets",_remotetargets,true]; + }; + case true: { + _localtargets set [count _localtargets,_unit]; + _x setVariable ["localtargets",_localtargets,false]; + }; + }; + }; + } else { + _zombie setVariable ["myDest",_pos,true]; + }; + } else { + _zombie setVariable ["myDest",_pos,true]; + }; + }; + case (_dis > 70): { + _zombie setVariable ["myDest",_pos,true]; + }; + }; + +/* _zombie = _x; if (_doRun) then { - _targets = _zombie getVariable ["targets",[]]; + _localtargets = _x getVariable ["localtargets",[]]; + _remotetargets = _x getVariable ["remotetargets",[]]; + _targets = _localtargets + _remotetargets; if (!(_unit in _targets)) then { - _targets set [count _targets,_unit]; - _zombie setVariable ["targets",_targets,true]; + switch (local _x) do { + case false: { + _remotetargets set [count _remotetargets,_unit]; + _x setVariable ["remotetargets",_remotetargets,true]; + }; + case true: { + _localtargets set [count _localtargets,_unit]; + _x setVariable ["localtargets",_localtargets,false]; + }; + }; }; } else { _zombie setVariable ["myDest",_pos,true]; }; -} count _listTalk; \ No newline at end of file +*/ +} forEach _listTalk; \ No newline at end of file diff --git a/SQF/dayz_code/compile/player_attackfsmdelay.sqf b/SQF/dayz_code/compile/player_attackfsmdelay.sqf new file mode 100644 index 000000000..9112a43fb --- /dev/null +++ b/SQF/dayz_code/compile/player_attackfsmdelay.sqf @@ -0,0 +1,11 @@ +/* + Created exclusively for ArmA2:OA - DayZMod. + Please request permission to use/alter/distribute from project leader (R4Z0R49) AND the author (facoptere@gmail.com) +*/ +private []; +//_start = diag_tickTime; + +_unit = _this select 0; +_type = _this select 1; + +[_unit, _type] call player_zombieAttack; \ No newline at end of file diff --git a/SQF/dayz_code/compile/player_checkStealth.sqf b/SQF/dayz_code/compile/player_checkStealth.sqf index 37491ebfd..304057fea 100644 --- a/SQF/dayz_code/compile/player_checkStealth.sqf +++ b/SQF/dayz_code/compile/player_checkStealth.sqf @@ -1,12 +1,12 @@ -private ["_vel","_speed","_pos","_scalePose","_scaleMvmt","_scaleLight","_anim","_anim4","_initial","_scaleSound","_nearFlare","_scaler","_nearLight","_nearFire","_building","_isPlayerInside","_audial","_isWater","_isPZombie"]; + +private ["_scalePose","_scaleMvmt","_scaleLight","_initial"]; _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; - +//_scaleAlert = 1; _isPZombie = player isKindOf "PZombie_VB"; if(_isPZombie) exitWith { DAYZ_disAudial = 0; DAYZ_disVisual = 0; }; @@ -18,7 +18,6 @@ _anim4 = toString _anim4; dayz_isKneeling = false; dayz_isCrawling = false; - if (["pknl",_anim] call fnc_inString) then { _scaleMvmt = 0.2; //0.1; _scalePose = 0.6; //0.4 @@ -58,23 +57,24 @@ if (_anim4 == "aswm") then { _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 + (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 + - (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"]; + _nearFlare = nearestObject [getPosATL (vehicle player),"RoadFlare"]; if (!isNull _nearFlare) then { _scaler = (_nearFlare distance (vehicle player)); if (_scaler <= 30) then { @@ -88,19 +88,19 @@ if (_scaleLight < 0.9) then { _scaler = 50 - (_nearLight distance (vehicle player)); _scaleLight = ((_scaler / 50) * 2) + _scaleLight; }; - _nearFire = nearestObject [(vehicle player),"Land_Fire"]; + _nearFire = nearestObject [getPosATL (vehicle player),"Land_Fire"]; if (!isNull _nearFire) then { _scaler = 50 - (_nearFire distance (vehicle player)); _scaleLight = ((_scaler / 50) * 2) + _scaleLight; }; }; -//Ensure zero || above +//Ensure zero or above _scaleLight = _scaleLight max 0; //Terrain Visibility if (["grass",dayz_surfaceType] call fnc_inString) then { - _initial = _initial * 0.75; + _initial = _initial * 0.65; //0.75 _scaleMvmt = _scaleMvmt - 0.05; } else { if (["forest",dayz_surfaceType] call fnc_inString) then { @@ -108,11 +108,11 @@ if (["grass",dayz_surfaceType] call fnc_inString) then { _scaleMvmt = _scaleMvmt - 0.1; } else { if (["concrete",dayz_surfaceType] call fnc_inString) then { - _initial = _initial * 1.2; + _initial = _initial * 0.85; //1.2 _scaleMvmt = _scaleMvmt + 0.1; } else { if (["rock",dayz_surfaceType] call fnc_inString) then { - _initial = _initial * 1.1; + _initial = _initial * 0.80; //1.1 _scaleMvmt = _scaleMvmt + 0.05; }; }; @@ -132,22 +132,22 @@ if (_speed > 5) then { _speed = _speed * 0.7; } else { _speed = _speed * 0.3; - }; + }; }; */ //Are they inside a building -_building = nearestObject [(vehicle player), "Building"]; +_building = nearestObject [getPosATL (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) || ((time - dayz_firedCooldown) > 0.3)) then { +_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; +DAYZ_disVisual = (round((_initial + (_speed * 3)) * _scalePose * _scaleLight)) * 1.5; diff --git a/SQF/dayz_code/compile/player_countMagazines.sqf b/SQF/dayz_code/compile/player_countMagazines.sqf new file mode 100644 index 000000000..3b03e226a --- /dev/null +++ b/SQF/dayz_code/compile/player_countMagazines.sqf @@ -0,0 +1,58 @@ +/* +count player magazines with ammo count +value = call player_countMagazines; +return all player magazines with ammo count +*/ +private ["_dialog","_created","_magazineArray"]; +disableSerialization; +disableUserInput true; + +_dialog = findDisplay 106; +_created = false; + +if ( isNull _dialog ) then { + //startLoadingScreen [""]; + createGearDialog [player, "RscDisplayGear"]; + _dialog = findDisplay 106; + _created = true; +}; + +_magazineArray = []; + +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]; + }; + }; +}; + +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]; + }; + }; +}; + +if ( _created ) then { + closeDialog 0; + //endLoadingScreen; +}; + +disableUserInput false; +_magazineArray \ No newline at end of file diff --git a/SQF/dayz_code/compile/player_death.sqf b/SQF/dayz_code/compile/player_death.sqf index a960009d3..efa4c4a80 100644 --- a/SQF/dayz_code/compile/player_death.sqf +++ b/SQF/dayz_code/compile/player_death.sqf @@ -16,10 +16,18 @@ _playerID = [player] call FNC_GetPlayerUID; disableUserInput true; //add weapon on back to player... -//if (dayz_onBack != "") then { -// _body addWeapon dayz_onBack; -//}; - +if (dayz_onBack != "") then { + //Add weapon on back to body. + _body addWeapon dayz_onBack; + /* + //Add weapon on back to the ground. + _pos = _body modeltoWorld [1,1,0]; + //_pos set [2, 0]; + _item = createVehicle ["WeaponHolder", _pos, [], 0.0, "CAN_COLLIDE"]; + _item setPosATL [_pos select 0, _pos select 1, ((_pos select 2) + 0.1)]; + _item addWeaponCargoGlobal [dayz_onBack,1]; + */ +}; _infected = 0; if (r_player_infected && DZE_PlayerZed) then { _infected = 1; @@ -38,9 +46,11 @@ player setVariable ["NORRN_unconscious", false, true]; player setVariable ["unconsciousTime", 0, true]; player setVariable ["USEC_isCardiac",false,true]; player setVariable ["medForceUpdate",true,true]; +player setVariable ["bloodTaken", false, true]; player setVariable ["startcombattimer", 0]; r_player_unconscious = false; r_player_cardiac = false; +_model = typeOf player; _array = _this; if (count _array > 0) then { @@ -64,16 +74,40 @@ if (count _array > 0) then { _killsV = _source getVariable ["banditKills",0]; _source setVariable ["banditKills",(_killsV + 1),true]; }; + // START Musty Achievement + _killer = _source; // who did the killing + _killedachievementID = -1; + if (_killer distance _body > 200) then { + _killedachievementID = 15; // steady aim + achievement_SteadyAim = true; + }; + if (_killer distance _body > 500) then { + _killedachievementID = 16; // marksman + achievement_Marksman = true; + }; + if (_killer distance _body > 1000) then { + _killedachievementID = 17; // sniper + achievement_Sniper = true; + }; + if (_killedachievementID > -1) then { + if (dayz_playerAchievements select _killedachievementID < 1) then { + _killerID = _killer getVariable["characterID",0]; // get his characterID + dayz_playerAchievements set [_killedachievementID,1]; + achievement = [_killedachievementID, _killer, _killerID]; // publish event to server + publicVariableServer "achievement"; + }; + }; + // END Musty Achievement }; _body setVariable ["deathType",_method,true]; }; terminate dayz_musicH; terminate dayz_slowCheck; -terminate dayz_animalCheck; +//terminate dayz_animalCheck; terminate dayz_monitor1; -terminate dayz_medicalH; -terminate dayz_gui; +//terminate dayz_medicalH; +//terminate dayz_gui; r_player_dead = true; diff --git a/SQF/dayz_code/compile/player_fired.sqf b/SQF/dayz_code/compile/player_fired.sqf index 97ebfc642..79a64fec1 100644 --- a/SQF/dayz_code/compile/player_fired.sqf +++ b/SQF/dayz_code/compile/player_fired.sqf @@ -1,93 +1,116 @@ -private ["_unit","_ammo","_audible","_distance","_listTalk","_weapon","_group","_targets","_i","_projectile","_id","_caliber"]; +private ["_projectile","_unit","_ammo"]; + //[unit, weapon, muzzle, mode, ammo, magazine, projectile] -_unit = _this select 0; -_weapon = _this select 1; -_ammo = _this select 4; -_projectile = _this select 6; +_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 * 20 * _caliber); +_distance = round(_audible * 10 * _caliber); dayz_disAudial = _distance; dayz_firedCooldown = time; -// Color in the combat icon dayz_combat = 1; if (_ammo isKindOf "Melee") exitWith { - if(!(_ammo isKindOf "Chainsaw_Swing_Ammo")) then { _unit playActionNow "GestureSwing"; - [1,1] call dayz_HungerThirst; + ["Working",0,[0,1,1,0]] call dayz_NutritionSystem; }; - // harvest wood check _this call player_harvest; + // Added Nutrition-Factor for work + //[Type,Blood[Calories,Hunger,Thrist,Temp] + //["Working",0,[0,1,1,0]] call dayz_NutritionSystem; + //_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; +if ((_ammo isKindOf "SmokeShell") or (_ammo isKindOf "GrenadeHandTimedWest") or (_ammo isKindOf "G_40mm_HE")) then { + if (_ammo isKindOf "G_40mm_HE") then { dayz_disAudial = 30 }; + + [_unit,_ammo] spawn { + private ["_pos","_group","_localtargets","_remotetargets"]; + _unit = _this select 0; + _ammo = _this select 1; + + _projectile = nearestObject [_unit, _ammo]; + _pos = getPosATL _projectile; + + if (_ammo isKindOf "SmokeShell") then { + while { ((getPosATL _projectile) select 2) >= 1 } do { + _pos = getPosATL _projectile; + sleep 0.01; + }; + + _listTalk = _pos nearEntities ["zZombie_Base",50]; + + { + _group = group _x; + if (isNull group _x) then { + _group = _x; + }; + _isLocal = (local _x); + _x reveal [_projectile,4]; + _localtargets = _group getVariable ["localtargets",[]]; + _remotetargets = _group getVariable ["remotetargets",[]]; + _targets = _localtargets + _remotetargets; + if (!(_projectile in _targets)) then { + switch (_isLocal) do { + case false: { + _remotetargets set [count _remotetargets,_projectile]; + _x setVariable ["remotetargets",_remotetargets,true]; + }; + case true: { + _localtargets set [count _localtargets,_projectile]; + _x setVariable ["localtargets",_localtargets,false]; + }; + }; + }; + } forEach _listTalk; + + } else { + while { alive _projectile } do { + _pos = getPosATL _projectile; + sleep 0.01; + }; + + _listTalk = _pos nearEntities ["zZombie_Base",50]; + + { + _x setVariable ["myDest",_pos]; // removed networked var. targets should be enough + } forEach _listTalk; }; - _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; - } count _listTalk; + }; } else { - [_unit,_distance,true,(getPosATL player)] spawn player_alertZombies; + + [_unit,_distance,true,(getPosATL player)] call player_alertZombies; + //Check if need to place arrow if (_ammo isKindOf "Bolt") then { - _id = _this spawn player_crossbowBolt; + [_this] spawn player_crossbowBolt; }; if (_ammo isKindOf "GrenadeHand") then { - + if (_ammo isKindOf "ThrownObjects") then { - _id = _this spawn player_throwObject; + [_this] spawn player_throwObject; }; if (_ammo isKindOf "RoadFlare") then { //hint str(_ammo); _projectile = nearestObject [_unit, "RoadFlare"]; - _id = [_projectile,0] spawn object_roadFlare; - - /* PVS/PVC - Skaronator */ - _pos = getPosATL player; - _inRange = _pos nearEntities ["CAManBase",1250]; - { - if(isPlayer _x && _x != player) then { - PVDZE_send = [_x,"RoadFlare",[_projectile,0]]; - publicVariableServer "PVDZE_send"; - }; - } count _inRange; - - _id = _this spawn player_throwObject; + [_projectile,0] spawn object_roadFlare; + PVDZ_obj_RoadFlare = [_projectile,0]; + publicVariable "PVDZ_obj_RoadFlare"; + [_this] spawn player_throwObject; }; if (_ammo isKindOf "ChemLight") then { _projectile = nearestObject [_unit, "ChemLight"]; - _id = [_projectile,1] spawn object_roadFlare; - - /* PVS/PVC - Skaronator */ - _pos = getPosATL player; - _inRange = _pos nearEntities ["CAManBase",1250]; - { - if(isPlayer _x && _x != player) then { - PVDZE_send = [_x,"RoadFlare",[_projectile,1]]; - publicVariableServer "PVDZE_send"; - } - } count _inRange; - - _id = _this spawn player_throwObject; + [_projectile,1] spawn object_roadFlare; + PVDZ_obj_RoadFlare = [_projectile,1]; + publicVariable "PVDZ_obj_RoadFlare"; + [_this] spawn player_throwObject; }; - }; + }; }; \ No newline at end of file diff --git a/SQF/dayz_code/compile/player_forceSave.sqf b/SQF/dayz_code/compile/player_forceSave.sqf new file mode 100644 index 000000000..e0448cfc4 --- /dev/null +++ b/SQF/dayz_code/compile/player_forceSave.sqf @@ -0,0 +1,16 @@ +/* + +Opens player inventory to save + +*/ + +_magazineArray = [] call player_countMagazines; + +if ((count _magazineArray) > 0) then { + PVDZ_plr_Save = [player,[_magazineArray,dayz_onBack]]; + publicVariableServer "PVDZ_plr_Save"; +}; + +diag_log (_magazineArray); + +dayz_lastSave = diag_tickTime; diff --git a/SQF/dayz_code/compile/player_gearSet.sqf b/SQF/dayz_code/compile/player_gearSet.sqf index 857546c12..12c4155bf 100644 --- a/SQF/dayz_code/compile/player_gearSet.sqf +++ b/SQF/dayz_code/compile/player_gearSet.sqf @@ -1,9 +1,12 @@ -private ["_inventory","_wpns","_mags","_idc","_isOK"]; +private ["_inventory","_wpns","_mags","_idc","_isOK","_typedBags"]; _inventory = _this; +_typedBags = ["bloodBagANEG", "bloodBagAPOS", "bloodBagBNEG", "bloodBagBPOS", "bloodBagONEG", "bloodBagOPOS","wholeBloodBagANEG", "wholeBloodBagAPOS", "wholeBloodBagBNEG", "wholeBloodBagBPOS", "wholeBloodBagONEG", "wholeBloodBagOPOS"]; if (count _inventory > 0) then { _wpns = _inventory select 0; _mags = _inventory select 1; + dayz_onBack = if (count _inventory > 2) then { _inventory select 2 } else { "" }; + //Add inventory { private["_item","_val"]; @@ -11,17 +14,22 @@ if (count _inventory > 0) then { _idc = 109; if (typeName _x == "ARRAY") then { _item = _x select 0; - _val = _x select 1; + _val = _x select 1; } else { _item = _x; _val = -1; }; if (_item == "BoltSteel") then { _item = "WoodenArrow" }; // Convert BoltSteel to WoodenArrow + if (DZE_UseBloodTypes) then { + if (_item == "ItemBloodbag") then { _item = "bloodBagONEG" }; // Convert ItemBloodbag into universal blood type/rh bag + } else { + if (_item in _typedBags) then {_item = "ItemBloodbag"}; + }; if (_item == "ItemTent") then { _item = "ItemTentOld" }; //Is item legal? - _isOK = isClass(configFile >> "CfgMagazines" >> _item); + _isOK = isClass(configFile >> "CfgMagazines" >> _item); if (_isOK) then { if (_val != -1) then { player addMagazine [_item,_val]; @@ -31,7 +39,6 @@ if (count _inventory > 0) then { }; _idc = _idc + 1; } count _mags; - //Add weapons { if(_x in (DZE_REPLACE_WEAPONS select 0)) then { @@ -39,9 +46,9 @@ if (count _inventory > 0) then { }; //Is item legal? - _isOK = isClass(configFile >> "CfgWeapons" >> _x); + _isOK = isClass(configFile >> "CfgWeapons" >> _x); if (_isOK) then { player addWeapon _x; }; } count _wpns; -}; \ No newline at end of file +}; diff --git a/SQF/dayz_code/compile/player_humanityChange.sqf b/SQF/dayz_code/compile/player_humanityChange.sqf index ce47d050d..24c46e3af 100644 --- a/SQF/dayz_code/compile/player_humanityChange.sqf +++ b/SQF/dayz_code/compile/player_humanityChange.sqf @@ -3,22 +3,26 @@ private ["_object","_change","_humanity","_wait"]; _object = _this select 0; _change = _this select 1; _humanity = 0; +_wait = if (count _this > 2) then { _this select 2 } else { 0 }; if (_object == player) then { - _humanity = player getVariable["humanity",0]; - _humanity = _humanity + _change; - if (_change < 0) then { - _wait = _this select 2; - player setVariable["humanity",_humanity,true]; - if (player getVariable ["freeTarget",false]) then { - waitUntil{!(player getVariable ["freeTarget",false])}; + _humanity = (player getVariable["humanity",0]) + _change; + player setVariable["humanity",_humanity,true]; + if (_change < 0) then { //non-bandit player can be "punished" in next "_wait" seconds w/o loosing humanity + if ((_humanity > -2000) and (_wait > 0)) then { + player setVariable ["freeTarget",true,true]; + player setVariable ["FTcounter",((player getVariable ["FTcounter",0]) + _wait)]; + [_wait] spawn { + private ["_endtime","_wait"]; + _wait = _this select 0; + _endTime = diag_tickTime + _wait; + waitUntil { sleep 1; diag_tickTime > _endTime }; + player setVariable ["FTcounter",((player getVariable ["FTcounter",0]) - _wait)]; + if ((player getVariable ["FTcounter",0]) <= 0) then { + player setVariable ["FTcounter",0]; + player setVariable ["freeTarget",false,true]; + }; + }; }; - player setVariable ["freeTarget",true,true]; - //_timeStart = time; - uiSleep _wait; - player setVariable ["freeTarget",false,true]; - - } else { - player setVariable["humanity",_humanity,true]; }; }; \ No newline at end of file diff --git a/SQF/dayz_code/compile/player_humanityMorph.sqf b/SQF/dayz_code/compile/player_humanityMorph.sqf index a490247d4..fd14fe782 100644 --- a/SQF/dayz_code/compile/player_humanityMorph.sqf +++ b/SQF/dayz_code/compile/player_humanityMorph.sqf @@ -1,7 +1,7 @@ -private ["_updates","_playerUID","_charID","_humanity","_worldspace","_model","_friendlies","_fractures","_old","_medical","_zombieKills","_headShots","_humanKills","_banditKills","_tagList"]; -_playerUID = _this select 0; -_charID = _this select 1; -_model = _this select 2; +private ["_charID","_newmodel","_old","_updates","_humanity","_medical","_worldspace","_zombieKills","_headShots","_humanKills","_banditKills","_fractures","_wpnType","_ismelee"]; +//_playerUID = _this select 0; +_charID = _this select 1; +_model = _this select 2; _old = player; player allowDamage false; @@ -11,23 +11,24 @@ 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 = player getVariable["updatePlayer",[false,false,false,false,false]]; _updates set [0,true]; player setVariable["updatePlayer",_updates,true]; dayz_unsaved = true; //Logout -_humanity = player getVariable["humanity",0]; -_medical = player call player_sumMedical; -_worldspace = [round(direction player),getPosATL player]; -_zombieKills = player getVariable ["zombieKills",0]; -_headShots = player getVariable ["headShots",0]; -_humanKills = player getVariable ["humanKills",0]; -_banditKills = player getVariable ["banditKills",0]; -_friendlies = player getVariable ["friendlies",[]]; -_tagList = player getVariable ["tagList",[]]; +_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]; + +_achievements = player getVariable ["Achievements",[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]]; //Switch - _model call player_switchModel; +_switch = _model spawn player_switchModel; +waitUntil { scriptDone _switch }; //Login @@ -42,15 +43,21 @@ if (count _medical > 0) then { player setVariable["USEC_lowBlood",(_medical select 6),true]; player setVariable["USEC_BloodQty",(_medical select 7),true]; player setVariable["unconsciousTime",(_medical select 10),true]; - + + player setVariable["blood_type",(_medical select 11),true]; + player setVariable["rh_factor",(_medical select 12),true]; + player setVariable["messing",(_medical select 13),true]; + player setVariable["blood_testdone",(_medical select 14),true]; + //Add Wounds { - player setVariable[_x,true,true]; - //["usecBleed",[player,_x,_hit]] call broadcastRpcCallAll; - usecBleed = [player,_x,0]; - publicVariable "usecBleed"; - } count (_medical select 8); - + //diag_log format ["loop _x:1 wound:%2",_x, (USEC_typeOfWounds select _forEachIndex)]; + player setVariable["hit_"+_x,true,true]; + PVDZ_hlt_Bleed = [player, _x, 1]; + publicVariable "PVDZ_hlt_Bleed"; + } forEach (_medical select 8); + + //Add fractures _fractures = (_medical select 9); // player setVariable ["hit_legs",(_fractures select 0),true]; @@ -62,7 +69,7 @@ if (count _medical > 0) then { player setVariable ["hit_legs",0,true]; player setVariable ["hit_hands",0,true]; player setVariable ["USEC_injured",false,true]; - player setVariable ["USEC_inPain",false,true]; + player setVariable ["USEC_inPain",false,true]; }; @@ -72,13 +79,15 @@ 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]; +player setVariable["Achievements",_achievements]; player setVariable["CharacterID",_charID,true]; player setVariable["worldspace",_worldspace,true]; player setVariable["friendlies",_friendlies,true]; player setVariable["tagList",_tagList,true]; - -//code for this on the server is missing -//["PVDZE_plr_Morph",[_charID,player,_playerUID,[_zombieKills,_headShots,_humanKills,_banditKills],_humanity]] call callRpcProcedure; +PVDZ_serverStoreVar = [player,"Achievements",_achievements]; +publicVariableServer "PVDZ_serverStoreVar"; call dayz_resetSelfActions; @@ -88,18 +97,10 @@ eh_player_killed = player addeventhandler ["FiredNear",{_this call player_weapon player allowDamage true; player addWeapon "Loot"; -player addWeapon "Flare"; - -//melee check - _wpnType = primaryWeapon player; - _ismelee = (gettext (configFile >> "CfgWeapons" >> _wpnType >> "melee")); - if (_ismelee == "true") then { - call dayz_meleeMagazineCheck; - }; uiSleep 0.1; +//melee check +call dayz_meleeMagazineCheck; -if (!isNull _old) then { - // this should not be needed as player is deleted in player_switchModel? - deleteVehicle _old; -}; +uiSleep 0.1; +if !(isNull _old) then {deleteVehicle _old;}; \ No newline at end of file diff --git a/SQF/dayz_code/compile/player_login.sqf b/SQF/dayz_code/compile/player_login.sqf new file mode 100644 index 000000000..212a718bf --- /dev/null +++ b/SQF/dayz_code/compile/player_login.sqf @@ -0,0 +1,5 @@ +_unit = _this select 0; +_detail = _this select 1; +if(_unit == getPlayerUID player) then { + player setVariable["publish",_detail]; +}; \ No newline at end of file diff --git a/SQF/dayz_code/compile/player_music.sqf b/SQF/dayz_code/compile/player_music.sqf index 4e8812634..0f4456476 100644 --- a/SQF/dayz_code/compile/player_music.sqf +++ b/SQF/dayz_code/compile/player_music.sqf @@ -1,6 +1,6 @@ private ["_sound","_num","_length","_pause"]; while {!r_player_dead} do { - _num = floor(random 36); + _num = floor(random 37); _sound = "z_suspense_" + str(_num); _length = getNumber(configFile >> "cfgMusic" >> _sound >> "Duration"); _pause = ((random 5) + 2) + _length; diff --git a/SQF/dayz_code/compile/player_onPause.sqf b/SQF/dayz_code/compile/player_onPause.sqf index 076a1970e..78e997c6e 100644 --- a/SQF/dayz_code/compile/player_onPause.sqf +++ b/SQF/dayz_code/compile/player_onPause.sqf @@ -1,4 +1,4 @@ -private ["_display","_btnRespawn","_btnAbort","_timeOut","_timeMax","_btnAbortText"]; +private ["_display","_timeout","_inCombat","_playerCheck","_zedCheck"]; disableSerialization; waitUntil { _display = findDisplay 49; @@ -11,36 +11,41 @@ _btnAbort ctrlEnable false; _btnAbortText = ctrlText _btnAbort; _timeOut = 0; _timeMax = diag_tickTime+10; -dayz_lastCheckBit = time; - -// if(r_player_dead) exitWith {_btnAbort ctrlEnable true;}; + if(r_fracture_legs && !r_player_dead) then {_btnRespawn ctrlEnable true;}; - + +dayz_lastCheckSave = time; //force gear save -if (!r_player_dead && time - dayz_lastCheckBit > 10) then { - call dayz_forceSave; -}; +if (time - dayz_lastCheckSave > 10) then { + call player_forceSave; +}; -if (r_player_dead || (!alive player)) exitWith {_btnAbort ctrlEnable true; _btnAbort ctrlSetText _btnAbortText;}; -_sleep = 1; +while {(!isNull _display) and !r_player_dead} do { + _timeout = 30; + _timeout = player getVariable["combattimeout", 0]; + _inCombat = if (_timeout >= diag_tickTime) then { true } else { false }; + _playerCheck = if ({isPlayer _x} count (player nearEntities ["AllVehicles", 5]) > 1) then { true } else { false }; + //_zedCheck = if (count (player nearEntities ["zZombie_Base", 10]) > 0) then { true } else { false }; -while {!isNull _display} do { - switch true do { - case (!r_player_dead && {isPlayer _x} count (player nearEntities ["AllVehicles", 12]) > 1) : { + Switch true do { + case (_playerCheck) : { _btnAbort ctrlEnable false; + _btnAbort ctrlSetText format["%1 (in 30)", _btnAbortText]; cutText [localize "str_abort_playerclose", "PLAIN DOWN"]; - _sleep = 1; }; - case (!r_player_dead && isInTraderCity) : { + case (isInTraderCity) : { _btnAbort ctrlEnable false; cutText [(localize "str_epoch_player_12"), "PLAIN DOWN"]; _sleep = 1; }; - case (!r_player_dead && player getVariable["combattimeout", 0] >= time) : { + /*case (_zedCheck) : { _btnAbort ctrlEnable false; - //cutText ["Cannot Abort while in combat!", "PLAIN DOWN"]; - cutText [localize "str_abort_playerincombat", "PLAIN DOWN"]; - _sleep = 1; + _btnAbort ctrlSetText format["%1 (in 10)", _btnAbortText]; + cutText [localize "str_abort_zedsclose", "PLAIN DOWN"]; + };*/ + case (_inCombat and !_playerCheck) : { + _btnAbort ctrlEnable false; + _btnAbort ctrlSetText format["%1 (in %2)", _btnAbortText, ceil (_timeout - diag_tickTime)]; }; case (_timeOut < _timeMax) : { _btnAbort ctrlEnable false; @@ -51,11 +56,10 @@ while {!isNull _display} do { default { _btnAbort ctrlEnable true; _btnAbort ctrlSetText _btnAbortText; - cutText ["", "PLAIN DOWN"]; - _sleep = 1; }; }; - uiSleep _sleep; - _timeOut = diag_tickTime; + uiSleep 1; }; -cutText ["", "PLAIN DOWN"]; + +if (r_player_dead) exitWith {_btnAbort ctrlEnable true;}; + diff --git a/SQF/dayz_code/compile/player_packTent.sqf b/SQF/dayz_code/compile/player_packTent.sqf index 0667da236..7d7f02471 100644 --- a/SQF/dayz_code/compile/player_packTent.sqf +++ b/SQF/dayz_code/compile/player_packTent.sqf @@ -1,85 +1,78 @@ /* -[_obj] spawn player_packTent; +[_obj] call player_packTent; */ -private ["_activatingPlayer","_objectID","_objectUID","_obj","_ownerID","_dir","_pos","_object","_holder","_weapons","_magazines","_backpacks","_objWpnTypes","_objWpnQty","_countr","_alreadyPacking","_dis","_sfx","_classname","_location"]; - if(DZE_ActionInProgress) exitWith { cutText [(localize "str_epoch_player_13") , "PLAIN DOWN"]; }; DZE_ActionInProgress = true; -player removeAction s_player_packtent; -s_player_packtent = 1; - -_activatingPlayer = player; - _obj = _this; _ownerID = _obj getVariable["CharacterID","0"]; -_objectID = _obj getVariable["ObjectID","0"]; -_objectUID = _obj getVariable["ObjectUID","0"]; -[1,1] call dayz_HungerThirst; +_objectID = _obj getVariable["ObjectID","0"]; +_objectUID = _obj getVariable["ObjectUID","0"]; +_pickup = false; +_activatingPlayer = player; + +_packobj = getText (configFile >> "CfgVehicles" >> typeOf _obj >> "pack"); + player playActionNow "Medic"; +player removeAction s_player_packtent; +s_player_packtent = -1; +player removeAction s_player_packtentinfected; +s_player_packtentinfected = -1; + if(_objectID == "0" && _objectUID == "0") exitWith {DZE_ActionInProgress = false; s_player_packtent = -1; cutText [(localize "str_epoch_player_14"), "PLAIN DOWN"];}; if(_ownerID != dayz_characterID) exitWith {DZE_ActionInProgress = false; s_player_packtent = -1; cutText [localize "str_fail_tent_pack", "PLAIN DOWN"];}; _alreadyPacking = _obj getVariable["packing",0]; -if (_alreadyPacking == 1) exitWith {DZE_ActionInProgress = false; s_player_packtent = -1; cutText [format[(localize "str_player_beingpacked")] , "PLAIN DOWN"]}; +if (_alreadyPacking == 1) exitWith {DZE_ActionInProgress = false; s_player_packtent = -1; s_player_packtentinfected = -1; cutText [format[(localize "str_player_beingpacked")] , "PLAIN DOWN"]}; -_obj setVariable["packing",1]; +_campitems = ["IC_DomeTent","IC_Tent"]; +if (_ownerID == dayz_characterID or (typeOf _obj in _campitems)) then { _pickup = true; }; -_dir = direction _obj; +if(_pickup) then { + _obj setVariable["packing",1]; -_pos = _obj getVariable["OEMPos",(getposATL _obj)]; - -_dis=20; -_sfx = "tentpack"; -[player,_sfx,0,false,_dis] call dayz_zombieSpeak; -[player,_dis,true,(getPosATL player)] spawn player_alertZombies; - -uiSleep 3; + _dir = direction _obj; + _pos = getposATL _obj; -_classname = getText (configFile >> "CfgVehicles" >> (typeOf _obj) >> "create"); + _dis=20; + _sfx = "tentpack"; + [player,_sfx,0,false,_dis] call dayz_zombieSpeak; + [player,_dis,true,(getPosATL player)] call player_alertZombies; -if(!isNull _obj && alive _obj) then { - - _location = _pos; - - if (_location select 2 < 0) then { - _location set [2,0]; - }; + uiSleep 3; //place tent (local) - //_bag = createVehicle ["WeaponHolder_ItemTent",_pos,[], 0, "CAN_COLLIDE"]; - _object = createVehicle [_classname, _location, [], 0, "CAN_COLLIDE"]; - _object setdir _dir; - _object setposATL _pos; - player reveal _object; + _bag = createVehicle [_packobj,_pos,[], 0, "CAN_COLLIDE"]; + _bag setdir _dir; + player reveal _bag; - _holder = _object; - - _weapons = getWeaponCargo _obj; - _magazines = getMagazineCargo _obj; - _backpacks = getBackpackCargo _obj; + _holder = createVehicle ["WeaponHolder", _pos, [], 0, "CAN_COLLIDE"]; - deleteVehicle _obj; + _weapons = getWeaponCargo _obj; + _magazines = getMagazineCargo _obj; + _backpacks = getBackpackCargo _obj; + + //["PVDZ_obj_Delete",[_objectID,_objectUID]] call callRpcProcedure; + PVDZ_obj_Destroy = [_objectID,_objectUID]; + publicVariableServer "PVDZ_obj_Destroy"; if (isServer) then { - PVDZE_obj_Delete call server_deleteObj; - } else { - PVDZE_obj_Delete = [_objectID,_objectUID,_activatingPlayer]; - publicVariableServer "PVDZE_obj_Delete"; + PVDZ_obj_Destroy call server_deleteObj; }; - + deleteVehicle _obj; + //Add weapons - _objWpnTypes = _weapons select 0; - _objWpnQty = _weapons select 1; + _objWpnTypes = _weapons select 0; + _objWpnQty = _weapons select 1; _countr = 0; { _holder addweaponcargoGlobal [_x,(_objWpnQty select _countr)]; _countr = _countr + 1; - } count _objWpnTypes; - + } forEach _objWpnTypes; + //Add Magazines _objWpnTypes = _magazines select 0; _objWpnQty = _magazines select 1; @@ -87,7 +80,7 @@ if(!isNull _obj && alive _obj) then { { _holder addmagazinecargoGlobal [_x,(_objWpnQty select _countr)]; _countr = _countr + 1; - } count _objWpnTypes; + } forEach _objWpnTypes; //Add Backpacks _objWpnTypes = _backpacks select 0; @@ -96,12 +89,11 @@ if(!isNull _obj && alive _obj) then { { _holder addbackpackcargoGlobal [_x,(_objWpnQty select _countr)]; _countr = _countr + 1; - } count _objWpnTypes; - + } forEach _objWpnTypes; + cutText [localize "str_success_tent_pack", "PLAIN DOWN"]; - - player action ["Gear", _holder]; +} else { + cutText [localize "str_fail_tent_pack", "PLAIN DOWN"]; }; - s_player_packtent = -1; -DZE_ActionInProgress = false; +DZE_ActionInProgress = false; \ No newline at end of file diff --git a/SQF/dayz_code/compile/player_switchModel.sqf b/SQF/dayz_code/compile/player_switchModel.sqf index 6498d9338..09de65bc2 100644 --- a/SQF/dayz_code/compile/player_switchModel.sqf +++ b/SQF/dayz_code/compile/player_switchModel.sqf @@ -1,27 +1,47 @@ -private ["_weapons","_backpackWpn","_backpackMag","_currentWpn","_isWeapon","_backpackWpnTypes","_backpackWpnQtys","_countr","_class","_position","_dir","_currentAnim","_tagSetting","_playerUID","_countMags","_magazines","_primweapon","_secweapon","_newBackpackType","_muzzles","_oldUnit","_group","_newUnit","_playerObjName","_wpnType","_ismelee","_oldGroup"]; -if (gear_done) then {disableUserInput true;}; -_class = _this; -_position = getPosATL player; -_dir = getDir player; -_currentAnim = animationState player; +//private ["_class","_position","_dir","_group","_oldUnit","_newUnit","_currentWpn","_muzzles","_currentAnim","_playerUID","_weapons","_magazines","_primweapon","_secweapon","_newBackpackType","_backpackWpn","_backpackMag","_backpackWpnTypes","_backpackWpnQtys","_countr","_backpackmagTypes","_backpackmagQtys","_display","_createSafePos","_wpnType","_ismelee","_rndx","_rndy"]; +private ["_class","_position","_dir","_currentAnim","_playerUID","_weapons","_magazines","_primweapon","_secweapon","_newBackpackType","_backpackWpn","_backpackMag","_currentWpn","_muzzles","_display","_oldUnit","_newUnit","_backpackWpnTypes","_backpackWpnQtys","_countr","_createSafePos","_rndx","_rndy","_isWeapon","_idc","_switchUnit","_tagSetting","_countMags","_group"]; +_class = _this; _tagSetting = player getVariable["DZE_display_name",false]; -_playerUID = [player] call FNC_GetPlayerUID; -_weapons = weapons player; -_countMags = call player_countMagazines; -_magazines = _countMags select 0; -if ((_playerUID == dayz_playerUID) && (count _magazines == 0) && (count (magazines player) > 0 )) exitWith {cutText [(localize "str_epoch_player_17"), "PLAIN DOWN"]}; +disableSerialization; +//Old location system causes issues with players getting damaged during movement. +//_position = getPosATL player; +//New system testing needed. +_position = player modeltoWorld [0,0,0]; -_primweapon = primaryWeapon player; -_secweapon = secondaryWeapon player; +_dir = getDir player; +_currentAnim = animationState player; +//_currentCamera = cameraView; -if(!(_primweapon in _weapons) && _primweapon != "") then { - _weapons set [(count _weapons), _primweapon]; -}; -if(!(_secweapon in _weapons) && _secweapon != "") then { - _weapons set [(count _weapons), _secweapon]; -}; +//Get PlayerID + _playerUID = [player] call FNC_GetPlayerUID; + +//BackUp Weapons and Mags + _weapons = weapons player; + _countMags = call player_countMagazines; + _magazines = _countMags select 0; + + if ( (_playerUID == dayz_playerUID) && (count _magazines == 0) && (count (magazines player) > 0 )) exitWith {cutText [localize "str_actions_switchmodel_fail", "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 set [(count _weapons), _primweapon]; + }; + + if(!(_secweapon in _weapons) && _secweapon != "") then { + _weapons set [(count _weapons), _secweapon]; + }; + +// if(count _magazines == 0) then { +// _magazines = magazines player; +// }; //BackUp Backpack dayz_myBackpack = unitBackpack player; @@ -37,24 +57,35 @@ _muzzles = getArray(configFile >> "cfgWeapons" >> _currentWpn >> "muzzles"); if (count _muzzles > 1) then { _currentWpn = currentMuzzle player; }; - -//Secure Player for Transformation player setPosATL dayz_spawnPos; -//BackUp Player Object -_oldUnit = player; -_oldGroup = group 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)); -/**********************************/ -//DONT USE player AFTER THIS POINT// -/**********************************/ +//Secure Player for Transformation + //player setPosATL dayz_spawnPos; + +//Prevent client crash... + _display = findDisplay 106; + _display closeDisplay 0; + +//BackUp Player Object + _oldUnit = player; + +/***********************************/ +//DONT USE player AFTER THIS POINT +/***********************************/ //Create New Character -_group = createGroup west; -_newUnit = _group createUnit [_class,dayz_spawnPos,[],0,"NONE"]; +//[player] joinSilent grpNull; +_group = createGroup west; +_newUnit = _group createUnit [_class,getMarkerPos "respawn_west",[],0,"NONE"]; -_newUnit setPosATL _position; -_newUnit setDir _dir; +_newUnit setDir _dir; _newUnit setVariable ["DZE_display_name", _tagSetting, true]; @@ -106,17 +137,8 @@ if (_primweapon == "MeleeFishingPole") then { if(_secweapon != (secondaryWeapon _newUnit) && _secweapon != "") then { _newUnit addWeapon _secweapon; }; -_switchUnit = { - addSwitchableUnit _newUnit; - setPlayable _newUnit; - selectPlayer _newUnit; - removeAllWeapons _oldUnit; - {_oldUnit removeMagazine _x;} count magazines _oldUnit; - deleteVehicle _oldUnit; - if (count units _oldGroup < 1) then {deleteGroup _oldGroup;}; - if(_currentWpn != "") then {_newUnit selectWeapon _currentWpn;}; -}; -//Add && Fill BackPack + +//Add and Fill BackPack if (!isNil "_newBackpackType") then { if (_newBackpackType != "") then { _newUnit addBackpack _newBackpackType; @@ -158,18 +180,52 @@ if (!isNil "_newBackpackType") then { (unitBackpack player) addWeaponCargoGlobal [_x,(_backpackWpnQtys select _countr)]; _countr = _countr + 1; } count _backpackWpnTypes; - } else { [] call _switchUnit; }; -} else { [] call _switchUnit; }; -[objNull, player, rSwitchMove,_currentAnim] call RE; -player disableConversation true; -if (_tagSetting) then { - DZE_ForceNameTags = true; + }; }; -_wpnType = primaryWeapon player; -_ismelee = (gettext (configFile >> "CfgWeapons" >> _wpnType >> "melee")); -if (_ismelee == "true") then { - call dayz_meleeMagazineCheck; -}; +//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); -{player reveal _x} count (nearestObjects [getPosATL player, dayz_reveal, 50]); +//Make New Unit Playable (1 of these 3 commands causes crashes with gear dialog open) + //_oldUnit setPosATL [_position select 0 + cos(_dir) * 2, _position select 1 + sin(_dir) * 2, _position select 2]; + addSwitchableUnit _newUnit; + setPlayable _newUnit; + selectPlayer _newUnit; + +//Switch the units + //_createSafePos = [(getMarkerPos "respawn_west"), 2, 100, 0, 1, 20, 0] call BIS_fnc_findSafePos; + _createSafePos = getMarkerPos "respawn_west"; + _rndx = floor(random 100); + _rndy = floor(random 100); + _oldUnit setPosATL [(_createSafePos select 0) + _rndx, (_createSafePos select 1) + _rndy, 0]; + _newUnit setPosATL _position; + +//Clear and delete old Unit + removeAllWeapons _oldUnit; + {_oldUnit removeMagazine _x;} forEach magazines _oldUnit; + if !(isNull _oldUnit) then {deleteVehicle _oldUnit;}; + +// player switchCamera = _currentCamera; + if(_currentWpn != "") then {_newUnit selectWeapon _currentWpn;}; + [objNull, player, rSwitchMove,_currentAnim] call RE; + //dayz_originalPlayer attachTo [_newUnit]; + player disableConversation true; + if (_tagSetting) then { + DZE_ForceNameTags = true; + }; + +// _playerUID=getPlayerUID player; +// _playerObjName = format["player%1",_playerUID]; +// call compile format["%1 = player;",_playerObjName]; +// publicVariable _playerObjName; + + //melee check + call dayz_meleeMagazineCheck; + + //reveal all near objects. + {player reveal _x} count (nearestObjects [getPosATL player, dayz_reveal, 50]); + //All is arbitrary and will need to be changed to ["AllVehicles","WeaponHolder","Land_A_tent"] ++ others (stashes etc.) diff --git a/SQF/dayz_code/compile/player_taskHint.sqf b/SQF/dayz_code/compile/player_taskHint.sqf new file mode 100644 index 000000000..83cd86f11 --- /dev/null +++ b/SQF/dayz_code/compile/player_taskHint.sqf @@ -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; \ No newline at end of file diff --git a/SQF/dayz_code/compile/player_throwObject.sqf b/SQF/dayz_code/compile/player_throwObject.sqf index 6a8e34984..be811a580 100644 --- a/SQF/dayz_code/compile/player_throwObject.sqf +++ b/SQF/dayz_code/compile/player_throwObject.sqf @@ -1,12 +1,14 @@ -private ["_unit","_ammo","_distance","_weapon","_projectile","_endPos","_dir","_doWait","_vel"]; -_unit = _this select 0; -_weapon = _this select 1; -_ammo = _this select 4; -_projectile = _this select 6; +private ["_distance","_endPos","_doWait","_vel"]; +_obj = _this select 0; +_unit = _obj select 0; +//_weapon = _obj select 1; +_ammo = _obj select 4; +_projectile = _obj select 6; -_projectile = nearestObject [_unit, _ammo]; +waituntil {!isnil "dayz_sunRise"}; + +_projectile = nearestObject [_unit,_ammo]; _endPos = getPosATL _projectile; -_dir = 0; _doWait = true; while {_doWait} do { @@ -23,11 +25,11 @@ if (_ammo isKindOf "ChemLight") then { _distance = 10; }; if (_ammo isKindOf "RoadFlare") then { - if (call world_isDay) then { + if ((daytime < (24 - dayz_sunRise)) and (daytime > dayz_sunRise)) then { _distance = 30; } else { _distance = 60; }; }; -[_unit,_distance,false,_endPos] spawn player_alertZombies; \ No newline at end of file +[_unit,_distance,false,_endPos] call player_alertZombies; \ No newline at end of file diff --git a/SQF/dayz_code/compile/player_weaponFiredNear.sqf b/SQF/dayz_code/compile/player_weaponFiredNear.sqf index 0ec2c5958..733681825 100644 --- a/SQF/dayz_code/compile/player_weaponFiredNear.sqf +++ b/SQF/dayz_code/compile/player_weaponFiredNear.sqf @@ -52,7 +52,7 @@ private ["_unit","_evType","_recordable","_inVehicle","_isPlayer","_isRocket","_ if (_distance < ((_dmgDistance / 2) + 1)) then { //serious ballistic damage if (_isPlayer) then { - _id = [] spawn player_death; + [_unit, "head_hit", 1.51, _firer, _ammo] call fnc_usec_damageHandler; }; [_unit,4] call fnc_usec_damageUnconscious; @@ -74,7 +74,7 @@ private ["_unit","_evType","_recordable","_inVehicle","_isPlayer","_isRocket","_ [20,45] call fnc_usec_pitchWhine; //Visual , Sound // Dead if (_isPlayer) then { - _id = [] spawn player_death; + [_unit, "head_hit", 1.51, _firer, _ammo] call fnc_usec_damageHandler; }; [_unit,2] call fnc_usec_damageUnconscious; }; diff --git a/SQF/dayz_code/compile/player_zombieAttack.sqf b/SQF/dayz_code/compile/player_zombieAttack.sqf index 01621c3bd..0642808cb 100644 --- a/SQF/dayz_code/compile/player_zombieAttack.sqf +++ b/SQF/dayz_code/compile/player_zombieAttack.sqf @@ -1,101 +1,144 @@ -private ["_unit","_move","_damage","_wound","_index","_cnt","_dir","_hpList","_hp","_strH","_dam","_vehicle","_tPos","_zPos","_cantSee","_inAngle","_rnd","_openVehicles","_chance","_attackanimations","_type","_targets"]; +/* + Created exclusively for ArmA2:OA - DayZMod. + Please request permission to use/alter/distribute from project leader (R4Z0R49) AND the author (facoptere@gmail.com) +*/ +private ["_rnd","_move","_wound","_cnt","_index","_damage","_total","_movePlayer"]; +//_start = diag_tickTime; + _unit = _this select 0; _type = _this select 1; + _vehicle = (vehicle player); +_speed = speed player; +//_nextPlayerPos = player call dayz_futurePos; +_distance = [_unit, player] call BIS_fnc_distance2D; +//_viralZeds = typeOf _unit in DayZ_ViralZeds; +_isVehicle = (_vehicle != player); +//_agentPos = getPosATL _unit; -_targets = _unit getVariable ["targets",[]]; +_playerDodged = false; -if (!dayz_zedsAttackVehicles && !(_vehicle in _targets)) exitWith { - //diag_log ("not attacking vehicle" + str(_vehicle)); -}; +if (_type != "zombie") exitWith { diag_log ("not a zombie"); }; // we deal only with zombies in this function +if (_unit distance _vehicle > 3.6) exitWith { }; // distance too far according to any logic dealt here //+str(_unit distance _nextPlayerPos)+"/"+str(_areaAffect) -if ((speed _vehicle > 10)) exitWith { - //diag_log ("too fast abort attack" + str(_vehicle)); -}; - -//Do the attack -if (r_player_unconscious && _vehicle == player && _type == "zombie") then { - _rnd = (round(random 4)) + 1; - _move = "ZombieFeed" + str(_rnd); -} else { - if (_type == "zombie") then { - _rnd = (round(random 9)) + 1; +// compute the animation move +_rnd = 0; +_dist = round(_distance*10); +switch true do { + case (((toArray(animationState player) select 5) == 112) && (_distance < 2.2)) : { + _rnd = ceil(random 4); //9 + _move = "ZombieFeed" + str(_rnd); + }; + case (r_player_unconscious && ((random 3) < 1)) : { + _rnd = ceil(random 4); //9 + _move = "ZombieFeed" + str(_rnd); + }; + case ((_isVehicle) AND (_distance < 3.6)) : { // enable attack if Z is between 2.2 and 3.5. Other cases are handled in "default" + _rnd = 8; _move = "ZombieStandingAttack" + str(_rnd); - } else { - _move = "Dog_Attack"; + }; + case (((_speed >= 5) or (_speed <= -5)) and (_distance < 2.3)) : { + _rnd = 8; + _move = "ZombieStandingAttack" + str(_rnd); + }; + default { + // attack moves depends on the distance between player and Z + // we compute the distance in 10cm slots. + switch _dist do { + case 0 : {_rnd = [ 1, 4, 9, 3, 6 ];}; + case 10 : {_rnd = [ 1, 4, 9, 3, 6 ];}; + case 11 : {_rnd = [ 1, 4, 9, 3, 6 ];}; + case 12 : {_rnd = [ 1, 9, 3, 6 ];}; + case 13 : {_rnd = [ 3, 6 ];}; + case 14 : {_rnd = [ 3, 6, 7 ];}; + case 15 : {_rnd = [ 7, 5, 10 ];}; + case 16 : {_rnd = [ 7, 5, 10 ];}; + case 17 : {_rnd = [ 7, 5, 10 ];}; + case 18 : {_rnd = [ 8, 10 ];}; + case 19 : {_rnd = [ 8, 10 ];}; + case 20 : {_rnd = [ 8 ];}; + case 21 : {_rnd = [ 8 ];}; + case 22 : {_rnd = [ 8 ];}; + default { + if (_dist < 10) then { _rnd = [ 1, 2, 4, 9 ]; }; + if (_dist > 22) then { _rnd = [ 8 ]; }; + }; + }; + //diag_log ("ZedAttack: : "+str(_rnd)); + _rnd = _rnd call BIS_fnc_selectRandom; + _move = "ZombieStandingAttack" + str(_rnd); + //diag_log format ["Distance: %3/%1, Animation: %2", _distance, _rnd, _dist]; }; }; -_tPos = visiblePositionASL _vehicle; -_zPos = visiblePositionASL _unit; - -_dir = [_zpos,_tPos] call BIS_Fnc_dirTo; +//Make sure zed is facing the player +_dir = [_unit,player] call BIS_Fnc_dirTo; _unit setDir _dir; -// _unit playMove _move; - +// let's animate the Z if (local _unit) then { - _unit switchMove _move; + _unit PlayMove _move; } else { - [objNull, _unit, rSwitchMove, _move] call RE; + [objNull, _unit, rPlayMove, _move] call RE; }; -//Wait -uiSleep 0.3; +//slow it down make sure the animation isnt running after the damage +_timeout = diag_tickTime + 0.3; +waitUntil { diag_tickTime >= _timeout; }; -if (_vehicle != player) then { - _hpList = _vehicle call vehicle_getHitpoints; - _hp = _hpList call BIS_fnc_selectRandom; - _wound = getText(configFile >> "cfgVehicles" >> (typeOf _vehicle) >> "HitPoints" >> _hp >> "name"); - _damage = random 0.08; - _chance = round(random 12); - - if ((_chance % 4) == 0) then { - _openVehicles = ["ATV_Base_EP1", "Motorcycle", "Bicycle"]; - { - if (_vehicle isKindOf _x) exitWith { - player action ["eject", _vehicle]; +_deg = [player, _unit] call BIS_fnc_relativeDirTo; +_lastDodge = _unit getVariable ["lastDodge", 0]; +//1 in 5 shots +if (((diag_tickTime - _lastDodge) == 0) or ((diag_tickTime - _lastDodge) > 10)) then { + if (((_deg > 295) and (_deg < 360)) or ((_deg > 0) and (_deg < 65))) then { + _dodgeAnimations = ["amovpknlmstpsraswrfldnon"]; + if ((animationState _vehicle) in _dodgeAnimations) then { + if (dayz_dodge) exitwith { + _playerDodged = true; + dayz_dodge = false; }; - } count _openVehicles; - }; - - //diag_log ("Hitpoints " +str(_wound) + "hit points " + str(_hpList)); - - if (_wound in DZE_vehicleZwounds) then { - - _strH = "hit_" + (_wound); - _dam = _vehicle getVariable [_strH,0]; - - //diag_log ("Hitpoints " +str(_wound) +str(_total)); - - if (_dam >= 1) then { - if (r_player_blood < (r_player_bloodTotal * 0.8)) then { - _cnt = count (DAYZ_woundHit select 1); - _index = floor (random _cnt); - _index = (DAYZ_woundHit select 1) select _index; - _wound = (DAYZ_woundHit select 0) select _index; - } else { - _cnt = count (DAYZ_woundHit_ok select 1); - _index = floor (random _cnt); - _index = (DAYZ_woundHit_ok select 1) select _index; - _wound = (DAYZ_woundHit_ok select 0) select _index; - }; - _damage = 0.1 + random (1.2); - //diag_log ("START DAM: Player Hit on " + _wound + " for " + str(_damage)); - [player, _wound, _damage, _unit,"zombie"] call fnc_usec_damageHandler; - [_unit,"hit",2,false] call dayz_zombieSpeak; }; }; -} else { - //diag_log ("Animation state: " +(_currentAnim)); - _attackanimations = ["zombiestandingattack1","zombiestandingattack2","zombiestandingattack3","zombiestandingattack4","zombiestandingattack5","zombiestandingattack6","zombiestandingattack7","zombiestandingattack8","zombiestandingattack9","zombiestandingattack10","zombiefeed1","zombiefeed2","zombiefeed3","zombiefeed4","zombiefeed5"]; - if (((_unit distance player) <= dayz_areaAffect) && ((animationState _unit) in _attackanimations)) then { - //check LOS - _inAngle = [_zPos,(getdir _unit),50,_tPos] call fnc_inAngleSector; - if (_inAngle) then { - //LOS check - _cantSee = [_unit,_vehicle] call dayz_losCheck; - if (!_cantSee) then { +}; + + +if (_playerDodged) exitwith { + //systemChat ("That was close!"); + _lastDodge = _unit setVariable ["lastDodge", diag_tickTime]; +}; + +_tPos = (getPosASL _vehicle); +_zPos = (getPosASL _unit); +// compute damage for vehicle and/or the player +if (_isVehicle) then { + if ((_unit distance player) < (3.3 * 2)) then { + _hpList = _vehicle call vehicle_getHitpoints; + _hp = _hpList call BIS_fnc_selectRandom; + _wound = getText(configFile >> "cfgVehicles" >> (typeOf _vehicle) >> "HitPoints" >> _hp >> "name"); + _damage = random 0.08; + _chance = round(random 12); + + if ((_chance % 4) == 0) then { + _openVehicles = ["ATV_Base_EP1", "Motorcycle", "Bicycle"]; + { + if (_vehicle isKindOf _x) exitWith { + player action ["eject", _vehicle]; + }; + } count _openVehicles; + }; + + if (_wound IN [ "glass1", "glass2", "glass3", "glass4", "glass5", "glass6" ]) then { + _strH = "hit_" + (_wound); + _dam = _vehicle getVariable [_strH,0]; + _total = (_dam + _damage); + + //handle vehicle dmg + [_vehicle, _wound, _total, _unit, "zombie", true] call fnc_veh_handleDam; + + //diag_log ("Hitpoints " +str(_wound) +str(_total)); + + //handle player dmg + if (_total >= 1) then { if (r_player_blood < (r_player_bloodTotal * 0.8)) then { _cnt = count (DAYZ_woundHit select 1); _index = floor (random _cnt); @@ -108,11 +151,187 @@ if (_vehicle != player) then { _wound = (DAYZ_woundHit_ok select 0) select _index; }; _damage = 0.1 + random (1.2); - - //diag_log ("START DAM: Player Hit on " + _wound + " for " + str(_damage)); + //diag_log ("Player_ZombieAttack: START DAM: Player Hit on " + _wound + " for " + str(_damage)); [player, _wound, _damage, _unit,"zombie"] call fnc_usec_damageHandler; - [_unit,"hit",2,false] call dayz_zombieSpeak; }; }; + + // broadcast hit noise + _pos = getPosATL player; + if ({isPlayer _x} count (_pos nearEntities ["CAManBase",40]) > 1) then { + [_unit,"hit",0,false] call dayz_zombieSpeak; + } else { + [_unit,"hit",0,true] call dayz_zombieSpeak; + }; }; +} else { + // player by foot + if ((_unit distance player) <= 3.3) then { + + //Make sure sure evrything is processed as we attack. + _damage = 0.2 + random (1.2); + + //LOS check + _cantSee = [_vehicle,_unit] call dayz_losCheck; + if (!_cantSee) then { + if (r_player_blood < (r_player_bloodTotal * 0.8)) then { + _cnt = count (DAYZ_woundHit select 1); + _index = floor (random _cnt); + _index = (DAYZ_woundHit select 1) select _index; + _wound = (DAYZ_woundHit select 0) select _index; + } else { + _cnt = count (DAYZ_woundHit_ok select 1); + _index = floor (random _cnt); + _index = (DAYZ_woundHit_ok select 1) select _index; + _wound = (DAYZ_woundHit_ok select 0) select _index; + }; + + //Stop the Zed + _unit setVariable ["speedLimit", 0, false]; + + //_attackanimations = ["zombiestandingattack1","zombiestandingattack2","zombiestandingattack3","zombiestandingattack4","zombiestandingattack5","zombiestandingattack6","zombiestandingattack7","zombiestandingattack8","zombiestandingattack9","zombiestandingattack10","zombiefeed1","zombiefeed2","zombiefeed3","zombiefeed4","zombiefeed5"]; + + //diag_log ((animationState _unit)); + + //if ((animationState _unit) in _attackanimations) then { + if (alive _unit) then { + //Damage the player + [player, _wound, _damage, _unit, "zombie"] call fnc_usec_damageHandler; + + // check Z stance. Stand up Z if it prones/kneels. make sure zed stays standing after its frist attak + if (unitPos _unit != "UP") then { + _unit setUnitPos "UP"; + }; + //}; + + // broadcast hit noise + _pos = getPosATL player; + if ({isPlayer _x} count (_pos nearEntities ["CAManBase",40]) > 1) then { + [_unit,"hit",0,false] call dayz_zombieSpeak; + } else { + [_unit,"hit",0,true] call dayz_zombieSpeak; + }; + + // player may fall if hit... + _deg = [player, _unit] call BIS_fnc_relativeDirTo; + _lastTackle = player getVariable ["lastTackle", 0]; + _movePlayer = ""; + + //head hit, Legs, pushed from back + _knockdown = ["head_hit","legs"]; + //diag_log ("ZombieAttack: "+str(_wound)); + //_isHeadHit = (_wound == "head_hit"); + if (_wound in _knockdown) then { + if (((diag_tickTime - _lastTackle) > 7) and (_speed >= 5.62)) then { + switch true do { + /* + //Removed for now + // front + case (((_deg > 315) and (_deg <= 360)) or ((_deg > 0) and (_deg < 45))) : { + //player setVelocity [(velocity player select 0) + 5 * sin direction _unit, (velocity player select 1) + 5 * cos direction _unit, (velocity player select 2) + 1]; + // stop player + _vel = velocity player; + player setVelocity [-(_vel select 0), -(_vel select 1), 0]; + disableUserInput true; + + [diag_tickTime] call { + _t = _this select 0; + while { true } do { + if (diag_tickTime - _t > 1) exitWith {disableUserInput false;}; + }; + }; + }; + */ + // left + case (((_deg > 225) and (_deg < 315))) : { + + // rotate player 'smoothly' + [_deg] spawn { + private["_step","_i"]; + _step = 90 / 5; + _i = 0; + while { _i < 5 } do { + player setDir ((getDir player) + _step); + _i = _i + 1; + sleep 0.01; + }; + }; + + // make player dive + _movePlayer = switch (toArray(animationState player) select 17) do { + case 114 : {"ActsPercMrunSlowWrflDf_TumbleOver"}; // rifle + case 112 : {"AmovPercMsprSlowWpstDf_AmovPpneMstpSrasWpstDnon"}; // pistol + default {"ActsPercMrunSlowWrflDf_TumbleOver"}; + }; + }; + // right + case (((_deg > 45) and (_deg < 135))) : { + [_deg] spawn { + private["_step","_i"]; + _step = 90 / 5; + _i = 0; + while { _i < 5 } do { + player setDir ((getDir player) - _step); + _i = _i + 1; + sleep 0.01; + }; + }; + + // make player dive + _movePlayer = switch (toArray(animationState player) select 17) do { + case 114 : {"ActsPercMrunSlowWrflDf_TumbleOver"}; // rifle + case 112 : {"AmovPercMsprSlowWpstDf_AmovPpneMstpSrasWpstDnon"}; // pistol + default {"ActsPercMrunSlowWrflDf_TumbleOver"}; + }; + }; + // rear + case (((_deg > 135) and (_deg < 225))) : { + _movePlayer = switch (toArray(animationState player) select 17) do { + case 114 : {"ActsPercMrunSlowWrflDf_TumbleOver"}; // rifle + case 112 : {"AmovPercMsprSlowWpstDf_AmovPpneMstpSrasWpstDnon"}; // pistol + default {"ActsPercMrunSlowWrflDf_TumbleOver"}; + }; + }; + }; + + // make player dive After making sure the zed can see you. + if (_movePlayer != "") then { + player setVariable ["lastTackle", diag_tickTime]; + _doRE = ({isPlayer _x} count (player nearEntities ["AllVehicles",100]) > 1); + + if (_doRE) then { + [nil, player, rSWITCHMOVE, _movePlayer] call RE; + } else { + player switchMove _movePlayer; + }; + + if (_movePlayer == "ActsPercMrunSlowWrflDf_TumbleOver") then { + [_movePlayer, _doRE] spawn { + private ["_movePlayer","_doRE"]; + _movePlayer = _this select 0; + _doRE = _this select 1; + + waitUntil { animationState player == _movePlayer }; // just in case + + while { animationState player == _movePlayer } do { + if (speed player < 4) exitWith { /* break from loop to fix animation lockup */ }; + uiSleep 0.1; + }; + + if (_doRE) then { + [nil, player, rSWITCHMOVE, ""] call RE; + } else { + player switchMove ""; + }; + }; + }; + //diag_log(format["%1 player tackled. Weapons: cur:""%2"" anim.state:%6 (%7)--> move: %3. Angle:%4 Delta-time:%5", __FILE__, currentWeapon player, _move, _deg, time - _lastTackle, animationState player, toArray(animationState player) select 17 ]); + }; + }; + }; + }; + }; + }; // fi player by foot }; +//_stop = diag_tickTime; +//diag_log format ["%2 Execution Time: %1",_stop - _start, __FILE__]; \ No newline at end of file diff --git a/SQF/dayz_code/compile/player_zombieCheck.sqf b/SQF/dayz_code/compile/player_zombieCheck.sqf index 396cb165b..652e4d75a 100644 --- a/SQF/dayz_code/compile/player_zombieCheck.sqf +++ b/SQF/dayz_code/compile/player_zombieCheck.sqf @@ -1,110 +1,155 @@ -private ["_listTalk","_eyeDir","_attacked","_continue","_type","_chance","_last","_refObj","_inAngle","_tPos","_zPos","_cantSee","_entHeight","_delta","_targets","_pHeight","_lowBlood","_dist"]; -_refObj = vehicle player; -_listTalk = ([_refObj] call FNC_GetPos) nearEntities ["zZombie_Base",80]; -_pHeight = (getPosATL _refObj) select 2; -_attacked = false; +private ["_attacked","_chance","_near","_targeted","_localtargets","_remotetargets","_forcedSpeed"]; + +_vehicle = vehicle player; +_isVehicle = (_vehicle != player); +_speed = speed (vehicle player); +_refObj = (driver _vehicle); +_listTalk = (getPosATL _refObj) nearEntities ["Zed_Base", 100]; +_attacked = false; // at least 1 Z attacked the player +_near = false; +//_multiplier = 1; + +_inVehicle = (vehicle player != player); +_isAir = vehicle player iskindof "Air"; +_isLand = vehicle player iskindof "Land"; +_isSea = vehicle player iskindof "Sea"; +if (_isLand) then { } else { }; +if (_isAir) then { } else { }; +if (_isSea) then { } else { }; + { - _continue = true; - _type = "zombie"; - - if (alive _x && _continue) then { - + _forcedSpeed = getNumber (configFile >> "CfgVehicles" >> (typeOf _x) >> "forcedSpeed"); + //_hearingThreshold = getNumber (configFile >> "CfgVehicles" >> (typeOf _x) >> "hearingThreshold"); + //_sightThreshold = getNumber (configFile >> "CfgVehicles" >> (typeOf _x) >> "sightThreshold"); + if (!(typeof _x == "swarm_newBase")) then { + _type = "zombie"; + if (alive _x) then { + private["_dist","_attackDist"]; + _dist = (_x distance _refObj); + _group = _x; + _chance = 1; //0 / dayz_monitorPeriod; // Z verbosity + _targetedBySight = false; + _targetedBySound = false; - _dist = (_x distance _refObj); + _localtargets = _group getVariable ["localtargets",[]]; + _remotetargets = _group getVariable ["remotetargets",[]]; + _targets = _localtargets + _remotetargets; - _chance = 1; - if ((_dist < dayz_areaAffect) && !(animationState _x == "ZombieFeed")) then { - - //diag_log ("within attack range: " + str(_x)); - - [_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) && ((_delta < 1.5) && (_delta > -1.5)) ) then - { - //diag_log ("perform attack: " + str(_x)); - [_x, _type] spawn player_zombieAttack; - _x setVariable["lastAttack",time]; - }; - _attacked = true; - } else { - if (speed _x < 4) then { - [_x,"idle",(_chance + 4),true] call dayz_zombieSpeak; - //diag_log ("idle: " + str((_chance + 4))); - } else { - [_x,"chase",(_chance + 3),true] call dayz_zombieSpeak; - //diag_log ("chase: " + str((_chance + 3))); - }; - }; - //Noise Activation - _targets = _x getVariable ["targets",[]]; - if (!(_refObj in _targets) && !isNull _refObj) then { - if (_dist < DAYZ_disAudial) then { - if (DAYZ_disAudial > 80) then { - - _targets set [count _targets, (driver _refObj)]; - _x setVariable ["targets",_targets,true]; - //diag_log ("45: " + str(_targets)); - + if (_x distance player >= (dayz_areaAffect*2)) then { + if (speed _x < 4) then { + [_x,"idle",(_chance + 4),true] call dayz_zombieSpeak; } else { - - _cantSee = [_x,_refObj] call dayz_losCheck; - if (!_cantSee) then - { - _targets set [count _targets,(driver _refObj)]; - _x setVariable ["targets",_targets,true]; - //diag_log ("54: " + str(_targets)); - } - else - { - if (_dist < (DAYZ_disAudial / 2)) then - { - _targets set [count _targets,(driver _refObj)]; - //diag_log ("61: " + str(_targets)); - _x setVariable ["targets",_targets,true]; + [_x,"chase",(_chance + 3),true] call dayz_zombieSpeak; + }; + }; + + if (_x distance _refObj >= 3.3) then { + _x setVariable ["speedLimit", _forcedSpeed, false]; + }; + //if (!local _x) then { + if (_refObj in _targets) then { + _last = _x getVariable["lastAttack", 0]; + _entHeight = (getPosATL _x) select 2; + _pHeight = (getPosATL _refObj) select 2; + _delta = _pHeight - _entHeight; + _x setVariable ["speedLimit", 0, false]; + + if (_x distance _refObj <= 3.3) then { + //Force Ai to Stand + _x setUnitPos "UP"; + if (!(animationState _x == "ZombieFeed")) then { + if (((diag_tickTime - _last) > 1.5) and ((_delta < 1.5) and (_delta > -1.5))) then { + _attackResult = [_x, _type] call player_zombieAttack; + _x setVariable["lastAttack", diag_tickTime]; + }; }; + } else { + _x setVariable ["speedLimit", _forcedSpeed, false]; + }; + _attacked = true; + } else { + _x setVariable ["speedLimit", _forcedSpeed, false]; + }; + //}; + + //Block all target atteps while in a vehicle + if (!_isAir) then { + if (!(_refObj in _targets)) then { + //Noise Activation + //zed is within players audial projection + if (_dist < DAYZ_disAudial) then { + if (DAYZ_disAudial > 80) then { + _targetedBySound = true; + } else { + //if (DAYZ_disAudial > 6) then { + _chance = [_x,_dist,DAYZ_disAudial] call dayz_losChance; + //diag_log ("Visual Detection: " + str([_x,_dist]) + " " + str(_chance)); + if ((random 1) < _chance) then { + //make sure the player isnt behind a building or wall if target is in the open always target if player is making too much noise + _cantSee = [_refObj,_x] call dayz_losCheck; + if (!_cantSee) then { + _targetedBySound = true; + } else { + if (_dist < (DAYZ_disAudial / 2)) then { + _targetedBySound = true; + }; + }; + }; + //}; + }; + }; + + //Sight Activation + if (_dist < DAYZ_disVisual ) then { + _chance = [_x,_dist,DAYZ_disVisual] call dayz_losChance; + if ((random 1) < _chance) then { + _tPos = (getPosASL (vehicle player)); + _zPos = (getPosASL _x); + _targetAngle = 30; + _inAngle = [_zPos,(direction _x),_targetAngle,_tPos] call fnc_inAngleSector; + if (_inAngle) then { + _cantSee = [_refObj,_x] call dayz_losCheck; + if (!_cantSee) then { + _targetedBySight = true; + }; + }; + }; }; }; }; - }; - //Sight Activation - _targets = _x getVariable ["targets",[]]; - if (!(_refObj in _targets) && !isNull _refObj) then { - if (_dist < DAYZ_disVisual) then { - - _tPos = (getPosASL _refObj); - _zPos = (getPosASL _x); - //_eyeDir = _x call dayz_eyeDir; - _eyeDir = direction _x; - _inAngle = [_zPos,_eyeDir,30,_tPos] call fnc_inAngleSector; - //diag_log ("Angle Check: " + str(_inAngle)); - if (_inAngle) then { - - //LOS check - _cantSee = [_x,_refObj] call dayz_losCheck; - //diag_log ("LOS Check: " + str(_cantSee)); - if (!_cantSee) then { - //diag_log ("Within LOS! Target"); - _targets set [count _targets,(driver _refObj)]; - _x setVariable ["targets",_targets,true]; + + if (_targetedBySight or _targetedBySound) then { + [_x, "spotted", 0, false] call dayz_zombieSpeak; + + diag_log format["Zombie: %1, Distance: %2, Target Reason: Sight-%3,%5/Sound-%4,%6",(typeof _x),_dist,_targetedBySight,_targetedBySound,DAYZ_disVisual,DAYZ_disAudial]; + + switch (local _x) do { + case false: { + _remotetargets set [count _remotetargets,_refObj]; + _x setVariable ["remotetargets",_remotetargets,true]; + }; + case true: { + _localtargets set [count _localtargets,_refObj]; + _x setVariable ["localtargets",_localtargets,false]; }; }; }; }; }; -} count _listTalk; +} forEach _listTalk; if (_attacked) then { if (r_player_unconscious) then { - [_refObj,"scream",3,false] call dayz_zombieSpeak; + [_refObj, "scream", 6, 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; + dayz_panicCooldown = diag_ticktime; + [_refObj, "panic", 6, false] call dayz_zombieSpeak; }; }; -}; \ No newline at end of file +}; + +// return true if attacked or near. if so, player_monitor will perform its ridiculous 'while true' loop faster. +(_attacked OR _near) diff --git a/SQF/dayz_code/compile/player_zombieSwarmAttack.sqf b/SQF/dayz_code/compile/player_zombieSwarmAttack.sqf new file mode 100644 index 000000000..eef1658a9 --- /dev/null +++ b/SQF/dayz_code/compile/player_zombieSwarmAttack.sqf @@ -0,0 +1,69 @@ +private["_unit","_targets","_move","_damage","_wound","_sound","_local","_dir","_hpList","_hp","_strH","_dam","_total","_result","_vehicle","_tPos","_zPos","_cantSee","_inAngle"]; +_unit = _this select 0; +_wound = _this select 1; +_vehicle = (vehicle player); + +//_targets = _unit getVariable ["targets",[]]; +//if (!(_vehicle in _targets)) exitWith {}; + +//Do the attack +_move = "ZombieStandingAttack1"; +_rnd = 0; + +_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"); + _damage = random 0.03; + _chance = round(random 12); + + if ((_chance % 4) == 0) then { + _openVehicles = ["ATV_Base_EP1", "Motorcycle", "Bicycle"]; + { + if (_vehicle isKindOf _x) exitWith { + player action ["eject", _vehicle]; + }; + } forEach _openVehicles; + }; + + [_unit,"hit",0,false] call dayz_zombieSpeak; + + if (_wound IN [ "glass1", "glass2", "glass3", "glass4", "glass5", "glass6" ]) then { + _strH = "hit_" + (_wound); + _dam = _vehicle getVariable [_strH,0]; + _total = (_dam + _damage); + + _woundDamage = _unit getVariable ["hit_"+_wound, 0]; + // we limit how vehicle could be damaged by Z. Above 0.8, the vehicle could explode, which is ridiculous. + _damage = (if (_woundDamage < 0.8 OR {(!(_wound IN dayZ_explosiveParts))}) then {0.1} else {0.01}); + // Add damage to vehicle. the "sethit" command will be done by the gameengine for which vehicle is local + //diag_log(format["%1: Part ""%2"" damaged from vehicle, damage:+%3", __FILE__, _wound, _damage]); + _total = [_vehicle, _wound, _woundDamage + _damage, _unit, "zombie", true] call fnc_veh_handleDam; + }; +} else { + if ((_unit distance player) <= 3) then { + _tPos = (getPosASL _vehicle); + _zPos = (getPosASL _unit); + _inAngle = [_zPos,(getdir _unit),50,_tPos] call fnc_inAngleSector; + if (_inAngle) then { + _cantSee = [_unit,_vehicle] call dayz_losCheck; + if (!_cantSee) 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; + [_unit,"hit",0,false] call dayz_zombieSpeak; + }; + }; + }; +}; diff --git a/SQF/dayz_code/compile/psrnd.sqf b/SQF/dayz_code/compile/psrnd.sqf new file mode 100644 index 000000000..cbc85994b --- /dev/null +++ b/SQF/dayz_code/compile/psrnd.sqf @@ -0,0 +1,46 @@ +// (c) facoptere@gmail.com, licensed to DayZMod for the community +// +// Linear Congruential Generator +// http://en.wikipedia.org/wiki/Linear_congruential_generator +// X_{n+1} = ( a X_n + c) mod m +psrnd_period = 4096; // m + +// single precision float has 23 bit mantissa, so if m is 13bit long, then a is 10bit long and a/4 is 8bit long +// so don't pick primes number so much further 256 +psrnd_primes = [ +101, 103, 107, 109, 113, 127, 131, 137, 139, 149, +151, 157, 163, 167, 173, 179, 181, 191, 193, 197, +199, 211, 223, 227, 229, 233, 239, 241, 251, 257 ]; + +psrnd_init = { + // init pseudo random generator. seeds will be chosen randomly if you don't set them + private [ "_offx", "_offy", "_wx", "_wy", "_seeda", "_seedc" ]; + _offx = _this select 0; + _offy = _this select 1; + _wx = _this select 2; + _wy = _this select 3; + _seeda = nil; + _seedc = nil; + if (count _this > 4) then { + _seeda = _this select 4; // prime number <~ 256 + _seedc = _this select 5; // must be odd + } + else { + _seeda = psrnd_primes select floor random count psrnd_primes; + _seedc = psrnd_primes select floor random count psrnd_primes; + }; + [ _seedc, _offx, _offy, _wx / psrnd_period, _wy / psrnd_period, _seeda * 4 + 1, _seedc ] +}; + +psrnd = { + // _this = array returned by psrnd_init + private [ "_px", "_py", "_pz", "_pr" ]; + _pr = ((_this select 0) * (_this select 5) + (_this select 6)) mod psrnd_period; + _px = (_this select 1) + _pr * (_this select 3); + _pr = (_pr * (_this select 5) + (_this select 6)) mod psrnd_period; + _py = (_this select 2) + _pr * (_this select 4); + _pr = (_pr * (_this select 5) + (_this select 6)) mod psrnd_period; + _this set [0, _pr]; + + [_px, _py, _pr] +}; diff --git a/SQF/dayz_code/compile/restoreRscDisplayMultiplayerSetup.sqf b/SQF/dayz_code/compile/restoreRscDisplayMultiplayerSetup.sqf new file mode 100644 index 000000000..ccdd771e1 --- /dev/null +++ b/SQF/dayz_code/compile/restoreRscDisplayMultiplayerSetup.sqf @@ -0,0 +1,106 @@ +// (c) facoptere@gmail.com, licensed to DayZMod for the community + +// Restore the "RscDisplayMultiplayerSetup" dialog that is shortly displayed when the player is joining the game. + +#define DEF_CA_MP_roles_Title 1001 +#define DEF_CA_TextVotingTimeLeft 121 +#define DEF_TextMission 1002 +#define DEF_ValueMission 101 +#define DEF_CA_TextDescription 1004 +#define DEF_CA_ValueDescription 103 +#define DEF_TextIsland 1003 +#define DEF_ValueIsland 102 +#define DEF_TextSide 1005 +#define DEF_CA_B_West 104 +#define DEF_CA_B_East 105 +#define DEF_CA_B_Guerrila 106 +#define DEF_CA_B_Civilian 107 +#define DEF_TextRoles 1007 +#define DEF_CA_ValueRoles 109 +#define DEF_TextPool 1006 +#define DEF_CA_ValuePool 114 +#define DEF_CA_B_EnableAll 117 +#define DEF_CA_B_Lock 118 +#define DEF_CA_B_Params 128 +#define DEF_CA_B_DSinterface 1012 +#define DEF_CA_B_Kick 116 +#define DEF_CA_ButtonContinue 1 +#define DEF_CA_ButtonCancel 2 + +#define DEF_dayz_black 1017 +#define DEF_MP_roles_TitleBorder 1008 +#define DEF_SidesBack 1009 +#define DEF_SidesBorder 1010 +#define DEF_TextBack 1011 +#define DEF_TextBorder 1012 +#define DEF_ValuePoolBack 1013 +#define DEF_ValuePoolBorder 1014 +#define DEF_ValueRolesBack 1015 +#define DEF_ValueRolesBorder 1016 + + +disableSerialization; +_d = uiNameSpace getVariable 'RscDisplayMultiplayerSetup'; +{ + _c = _d displayCtrl _x; + _p = ctrlPosition _c; + _c ctrlshow true; + _y = ((_p select 1)-SafeZoneY)/SafeZoneH; + if (_y > 1) then { // widgets over 100% are the hidden ones + _y = _y - 1; // move the widget 100% upward so that it's visible + _y = _y * SafeZoneH + SafeZoneY; _p set [1, _y]; + _c ctrlSetPosition _p; _c ctrlCommit 0; + }; +} count [ + DEF_CA_MP_roles_Title, + DEF_CA_TextVotingTimeLeft, + DEF_TextMission, + DEF_ValueMission, + DEF_CA_TextDescription, + DEF_CA_ValueDescription, + DEF_TextIsland, + DEF_ValueIsland, + DEF_TextSide, + DEF_CA_B_West, + DEF_CA_B_East, + DEF_CA_B_Guerrila, + DEF_CA_B_Civilian, + DEF_CA_ValueRoles, + DEF_TextPool, + DEF_CA_ValuePool, + //DEF_CA_B_EnableAll, + //DEF_CA_B_Lock, + DEF_CA_B_Params, + DEF_CA_B_DSinterface, + //DEF_CA_B_Kick, + DEF_CA_ButtonContinue, + DEF_CA_ButtonCancel, + DEF_TextRoles, + + DEF_MP_roles_TitleBorder, + DEF_SidesBack, + DEF_SidesBorder, + DEF_TextBack, + DEF_TextBorder, + DEF_ValuePoolBack, + DEF_ValuePoolBorder, + DEF_ValueRolesBack, + DEF_ValueRolesBorder +]; + +{ + _c = _d displayCtrl _x; + _p = ctrlPosition _c; + _c ctrlshow true; + _xx = ((_p select 0)-SafeZoneX)/SafeZoneW; + if (_xx != 0.6) then { // "Pool" widgets should be at 60% + _xx = 0.60 *SafeZoneW + SafeZoneX; _p set [0, _xx]; + _w = (38/100) * SafeZoneW; _p set [2, _w]; + _c ctrlSetPosition _p; _c ctrlCommit 0; + }; +} count [ + DEF_TextPool, + DEF_CA_ValuePool +]; + +// TODO: hide DEF_dayz_black \ No newline at end of file diff --git a/SQF/dayz_code/compile/spawn_flies.sqf b/SQF/dayz_code/compile/spawn_flies.sqf new file mode 100644 index 000000000..f727c3bf2 --- /dev/null +++ b/SQF/dayz_code/compile/spawn_flies.sqf @@ -0,0 +1,6 @@ +private["_body","_id","_position"]; +_body = _this select 0; +_position = getPosATL _body; +[_position,0.1,1.5] call bis_fnc_flies; +//_id setVariable ["body",_body]; +//dayz_flyMonitor set[count dayz_flyMonitor, _id]; \ No newline at end of file diff --git a/SQF/dayz_code/compile/stream_locationCheck.sqf b/SQF/dayz_code/compile/stream_locationCheck.sqf new file mode 100644 index 000000000..079f9a29d --- /dev/null +++ b/SQF/dayz_code/compile/stream_locationCheck.sqf @@ -0,0 +1,65 @@ +//private ["_location","_distCfg","_configClass","_distAct","_rubbish","_config","_locHdr","_w8","_ahead","_forEachIndex"]; +_w8 = _this select 0; +_rubbish = dayz_Trash == 1; +{ + _location = _x select 0; + _distCfg = (_x select 2); + _configClass = _x select 1; + _distAct = player distance _location; + _ahead = (speed player) / 3.6 * 6; + + if (!(_forEachIndex in dayz_locationsActive)) then { + if ((_distAct < _distCfg + dayz_spawnArea + _ahead) and _rubbish) then { + dayz_locationsActive set [count dayz_locationsActive,_forEachIndex]; + _config = configFile >> "CfgTownGeneratorChernarus" >> _configClass; + _locHdr = configName _config; + //if (typeName _locHdr != "STRING") then { _locHdr = str _location; }; + diag_log format ["%1: creating %2 objects at '%3'", __FILE__, count _config, _locHdr]; + [_config, _w8] call stream_locationFill; // create wrecks & rubbish as local objects + + }; + } else { + if (_distAct > _distCfg + dayz_canDelete + _ahead) then { + _config = configFile >> "CfgTownGeneratorChernarus" >> _configClass; + _locHdr = configName _config; + //if (typeName _locHdr != "STRING") then { _locHdr = str _location; }; + diag_log format ["%1: removing %2 objects from '%3'", __FILE__, count _config, _locHdr]; + [_config, _w8] call stream_locationDel; // delete wrecks & rubbish + dayz_locationsActive = dayz_locationsActive - [_forEachIndex]; + }; + + }; +} forEach dayz_Locations; + +/* +_location = 0; +_distCfg = 0; +_configClass = 0; +_distAct = 0; +{ + _location = _x select 0; + _distCfg = (_x select 2); + _configClass = _x select 1; + _distAct = player distance _location; + + if (!(_forEachIndex in dayz_gridsActive)) then { + if (_distAct < _distCfg) then { + dayz_gridsActive set [count dayz_gridsActive,_forEachIndex]; + + PVDZ_gridsActive = [_forEachIndex,_location]; + publicVariableServer "PVDZ_gridsActive"; + + systemChat (str(_configClass)); + }; + } else { + if (_distAct > _distCfg) then { + dayz_gridsActive = dayz_gridsActive - [_forEachIndex]; + + PVDZ_gridsRemove = [_forEachIndex,_location]; + publicVariableServer "PVDZ_gridsRemove"; + + diag_log("Out of Range: "+str(_forEachIndex)); + }; + }; +} forEach dayz_GridSystem; +*/ diff --git a/SQF/dayz_code/compile/stream_locationDel.sqf b/SQF/dayz_code/compile/stream_locationDel.sqf new file mode 100644 index 000000000..f0eb9accc --- /dev/null +++ b/SQF/dayz_code/compile/stream_locationDel.sqf @@ -0,0 +1,16 @@ +//private ["_config","_type","_position","_object","_list"]; +_list = _this select 0; +//_w8 = _this select 1; +for "_i" from ((count _list) - 1) to 0 step -1 do +{ + _config = (_list select _i); + if (isClass(_config)) then { + _type = getText (_config >> "ctype"); + _position = getArray (_config >> "position"); + _object = nearestObject [_position,_type]; + deleteVehicle _object; + if ((_i % 25) == 0) then { sleep 0.01; }; + }; + sleep 0.001; +}; +//diag_log ("CLEAR: " + str(_this)); diff --git a/SQF/dayz_code/compile/stream_locationFill.sqf b/SQF/dayz_code/compile/stream_locationFill.sqf new file mode 100644 index 000000000..6be154252 --- /dev/null +++ b/SQF/dayz_code/compile/stream_locationFill.sqf @@ -0,0 +1,39 @@ +//private ["_config","_type","_position","_dir","_object","_list","_w8","_dis"]; +_list = _this select 0; +_w8 = _this select 1; +for "_i" from ((count _list) - 1) to 0 step -1 do +{ + _config = (_list select _i); + if (isClass(_config)) then { + _type = getText (_config >> "type"); + _position = [] + getArray (_config >> "position"); + _dir = getNumber (_config >> "direction"); + //_onFire = getNumber (_config >> "onFire"); + _dis = _position distance player; + _inVehicle = (vehicle player != player); + + if (_dis > 2) then { + _object = _type createVehicleLocal [_position select 0,_position select 1,-100]; + _object setDir _dir; + _object setPos [_position select 0,_position select 1,0]; + _object setPosATL _position; + _object allowDamage false; + _object setVariable ["", true]; // SV used by player_spawnCheck + //if (_w8 AND {((_i % 25) == 0)}) then { sleep 0.01; }; + + } else { + if (!_inVehicle) then { + _object = _type createVehicleLocal [_position select 0,_position select 1,-100]; + _object setDir _dir; + _object setPos [_position select 0,_position select 1,0]; + _object setPosATL _position; + _object allowDamage false; + _object setVariable ["", true]; // SV used by player_spawnCheck + if (_w8 AND {((_i % 25) == 0)}) then { sleep 0.01; }; + }; + }; + + }; +//sleep 0.001; +}; +//diag_log ("FILL: " + str(_list)); diff --git a/SQF/dayz_code/compile/swarm_generate.sqf b/SQF/dayz_code/compile/swarm_generate.sqf new file mode 100644 index 000000000..03db27803 --- /dev/null +++ b/SQF/dayz_code/compile/swarm_generate.sqf @@ -0,0 +1,42 @@ +private["_position","_doLoiter","_unitTypes","_isNoone","_loot","_array","_agent","_type","_radius","_method","_nearByPlayer","_attempt","_myDest","_newDest","_lootType"]; +_player = _this select 0; +_amount = _this select 1; + +_counter = 0; +_agent = objNull; + + +while {_counter < _amount} do { + + //Create the Group and populate it + _type = "swarm_newBase"; //"_unitTypes call BIS_fnc_selectRandom; + //_type = "Pastor"; + _position = [position _player,50,100,0] call fn_selectRandomLocation; + + _agent = createAgent [_type, _position, [], 0, "NONE"]; + + _agent setVariable["agentObjectSwarm",_agent,true]; + _agent setUnitPos "Middle"; + + dayz_swarmSpawnZombies = dayz_swarmSpawnZombies + 1; + dayz_spawnZombies = dayz_spawnZombies + 1; + + if (isNull _agent) exitWith { + dayz_spawnZombies = dayz_spawnZombies - 1; + dayz_swarmSpawnZombies = dayz_swarmSpawnZombies - 1; + }; + + _isAlive = alive _agent; + + //counter + _counter = _counter + 1; + + //debug + //diag_log (format["Agent: %1, Type: %2,To spawn: %3/%4",_agent,_type,_amount,_counter]); + + //Move + //[_agent, _position] call zombie_loiter; + + //Start behavior + _id = [_position,_agent,player] execFSM "\z\AddOns\dayz_code\system\fn_swarmagent.fsm"; +}; \ No newline at end of file diff --git a/SQF/dayz_code/compile/ui_changeDisplay.sqf b/SQF/dayz_code/compile/ui_changeDisplay.sqf index bf8540937..e4bd7d1b4 100644 --- a/SQF/dayz_code/compile/ui_changeDisplay.sqf +++ b/SQF/dayz_code/compile/ui_changeDisplay.sqf @@ -1,8 +1,7 @@ -private["_state"]; disableSerialization; -_state = uiNamespace getVariable ['DZ_displayUI', 0]; +//_state = uiNamespace getVariable ['DZ_displayUI', 0]; -// Hard code the GUI on && the Debug Monitor off +// Hard code the GUI on and the Debug Monitor off if (dayzState != 0) then { 3 cutRsc ["playerStatusGUI", "PLAIN",0]; //Update GUI diff --git a/SQF/dayz_code/compile/ui_selectSlot.sqf b/SQF/dayz_code/compile/ui_selectSlot.sqf index 2b5f35a7b..f4bde6f0a 100644 --- a/SQF/dayz_code/compile/ui_selectSlot.sqf +++ b/SQF/dayz_code/compile/ui_selectSlot.sqf @@ -1,61 +1,67 @@ -private ["_control","_button","_parent","_group","_pos","_item","_conf","_name","_cfgActions","_numActions","_height","_menu","_config","_type","_script","_outputOriented","_compile","_array","_outputClass","_outputType"]; +//private ["_control","_button","_parent","_group","_pos","_item","_conf","_name","_cfgActions","_numActions","_height","_menu","_config","_type","_script","_outputOriented","_compile","_array","_outputClass","_outputType"]; disableSerialization; -_control = _this select 0; -_button = _this select 1; -_parent = findDisplay 106; +_control = _this select 0; +_button = _this select 1; +_parent = findDisplay 106; -//if ((time - dayzClickTime) < 1) exitWith {}; -if (!DZE_SelfTransfuse && ((gearSlotData _control) == "ItemBloodBag")) exitWith {}; +if (carryClick) then {carryClick = false;}; +if (!DZE_SelfTransfuse && ((gearSlotData _control) in DZE_BloodBags)) exitWith {}; if (_button == 1) then { - //dayzClickTime = time; + private ["_conf","_name","_compile","_height","_item"]; _group = _parent displayCtrl 6902; - - _pos = ctrlPosition _group; - _pos set [0,((_this select 2) + 0.48)]; - _pos set [1,((_this select 3) + 0.07)]; - + + _pos = ctrlPosition _group; + _item = gearSlotData _control; - + if (mouseOverCarry) then { + _item = DayZ_onBack; + carryClick = true; + }; + + _pos set [0,((_this select 2) + 0.46)]; + _pos set [1,((_this select 3) + 0.07)]; + _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 + for "_i" from 0 to (_numActions - 1) do { - _menu = _parent displayCtrl (1600 + _i); + _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; + _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]; + _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 - && the type used for the name - */ - _array = getArray (_config >> "output"); + 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]; + _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]; + + //hint format["Obj: %1 \nHeight: %2\nPos: %3",_item,_height,_grpPos]; _group ctrlShow true; ctrlSetFocus _group; diff --git a/SQF/dayz_code/compile/veh_handleDam.sqf b/SQF/dayz_code/compile/veh_handleDam.sqf new file mode 100644 index 000000000..8813406c5 --- /dev/null +++ b/SQF/dayz_code/compile/veh_handleDam.sqf @@ -0,0 +1,56 @@ +/* + Created exclusively for ArmA2:OA - DayZMod. + Please request permission to use/alter/distribute from project leader (R4Z0R49) AND the author (facoptere@gmail.com) +*/ + +/*********************************************************** +ASSIGN DAMAGE TO A UNIT. +Called by "HandleDamage" vehicle Event Handler +or by "PVCDZ_veh_SH" PV +or by zombie_attack + +- Function fnc_veh_handleDam +- [unit, selectionName, damage, source, projectile, broadcast] call fnc_veh_handleDam; +- return : updated damage for that part +broadcast: boolean. if true, then the request will be sent to all players if the vehicle is not local. +************************************************************/ +private["_unit","_selection","_strH","_total","_damage","_needUpdate"]; + +_unit = _this select 0; +_selection = _this select 1; +_total = _this select 2; + +if (_selection != "") then { + _strH = "hit_" + _selection; +} else { + _strH = "totalDmg"; +}; + +if (_total >= 0.98) then { + _total = 1.0; +}; + +if (local _unit) then { + if (_total > 0) then { + + _unit setVariable [_strH, _total, true]; + _unit setHit [_selection, _total]; + + if (!isServer) then { + PVDZ_veh_Save = [_unit,"damage"]; + publicVariableServer "PVDZ_veh_Save"; + } else { + [_unit, "damage"] call server_updateObject; + }; + }; +} else { + //if ( (count _this > 5) AND {(_this select 5)}) then { + // vehicle is not local to this client, ask the client which vehicle is local to set damage + //_this resize 5; // delete "broadcast" boolean + PVDZ_send = [_unit,"VehHandleDam",_this]; + publicVariableServer "PVDZ_send"; + //}; +}; + +// all "HandleDamage event" functions should return the effective damage that the engine will record for that part +_total diff --git a/SQF/dayz_code/compile/veh_handleKilled.sqf b/SQF/dayz_code/compile/veh_handleKilled.sqf new file mode 100644 index 000000000..481ed6c80 --- /dev/null +++ b/SQF/dayz_code/compile/veh_handleKilled.sqf @@ -0,0 +1,18 @@ +_unit = _this select 0; +//_killer = _this select 1; + +// ask server to set global damage to 1, save to the hive +if (local _unit) then { + if (isServer) then { + [_unit, "killed"] call server_updateObject; + } else { + PVDZ_veh_Save = [_unit, "killed"]; + publicVariableServer "PVDZ_veh_Save"; + }; +}; + +// everyone removes their EH for this vehicle +_unit removeAllEventHandlers "HandleDamage"; +_unit removeAllEventHandlers "Killed"; +_unit removeAllEventHandlers "GetIn"; +_unit removeAllEventHandlers "GetOut"; \ No newline at end of file diff --git a/SQF/dayz_code/compile/veh_handleRepair.sqf b/SQF/dayz_code/compile/veh_handleRepair.sqf new file mode 100644 index 000000000..3712beffa --- /dev/null +++ b/SQF/dayz_code/compile/veh_handleRepair.sqf @@ -0,0 +1,61 @@ +/* + Created exclusively for ArmA2:OA - DayZMod. + Please request permission to use/alter/distribute from project leader (R4Z0R49) AND the author (facoptere@gmail.com) +*/ + +/*********************************************************** +REPAIR A PART OF A UNIT. +Called by "PVDZ_veh_SF" PV +or by action/repair.sqf + +- Function fnc_veh_handleRepair +- [unit, selectionName, damage, broadcast] call fnc_veh_handleRepair; +- return : 0 :) +broadcast: boolean. if true, then the request will be sent to all players if the vehicle is not local. +************************************************************/ +private ["_hitpointnames","_log"]; + +_unit = _this select 0; +_selection = _this select 1; + +_hitpointnames = []; +{ + _hitpointnames set [count _hitpointnames, getText (configFile >> "CfgVehicles" >> (typeOf _unit) >> "HitPoints" >> _x >> "name")]; +} forEach (_unit call vehicle_getHitpoints); + +if ((isNil "_selection") OR {(!(_selection IN _hitpointnames))}) exitWith {_this select 2}; + +_SVname = "hit_" + _selection; + +_log = format["%1 vehicle:%2#%3 part:""%4"" current_part_damage:%5", __FILE__, +typeOf _unit, _unit getVariable ["ObjectID",""], +_selection, _unit getVariable [_SVname, 0] ]; + +if (local _unit) then { + // only local unit can set the damage of a vehicle part + _unit setVariable [_SVname, 0, true]; + _unit setHit [_selection, 0]; + _log = format["%1. setH!t[%2,0]", _log, _selection]; + if (!isServer) then { + PVDZ_veh_Save = [_unit, "repair"]; + publicVariableServer "PVDZ_veh_Save"; + _log = _log + ". Requesting server hive write"; + } + else { + [_unit, "repair"] call server_updateObject; + _log = _log + ". Writing to hive"; + }; +} +else { + if ( (count _this > 3) AND {(_this select 3)}) then { + // vehicle is not local to this client, ask the client which vehicle is local to set damage + _this resize 3; // delete "broadcast" boolean + _log = _log + ". Broadcasting to all"; + PVDZ_veh_SF = _this; + publicVariable "PVDZ_veh_SF"; + }; +}; + +//diag_log _log; + +0 diff --git a/SQF/dayz_code/compile/veh_setFixServer.sqf b/SQF/dayz_code/compile/veh_setFixServer.sqf new file mode 100644 index 000000000..c109eae18 --- /dev/null +++ b/SQF/dayz_code/compile/veh_setFixServer.sqf @@ -0,0 +1,26 @@ +private["_unit","_selection","_strH","_damage","_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 { + if (isServer) then { + [_unit,"repair"] call server_updateObject + } else { + PVDZ_veh_Save = [_unit,"repair"]; + publicVariable "PVDZ_veh_Save"; + }; + } else { + if (isServer) then { + [_unit,"damage"] call server_updateObject + } else { + PVDZ_veh_Save = [_unit,"damage"]; + publicVariable "PVDZ_veh_Save"; + }; + }; +}; \ No newline at end of file diff --git a/SQF/dayz_code/compile/vehicle_getOut.sqf b/SQF/dayz_code/compile/vehicle_getOut.sqf new file mode 100644 index 000000000..d384118c7 --- /dev/null +++ b/SQF/dayz_code/compile/vehicle_getOut.sqf @@ -0,0 +1,31 @@ +//[vehicle, position, unit] +//Quick fix for now. +private ["_vehicle","_position","_unit","_buildables"]; + +_vehicle = _this select 0; +_position = _this select 1; +_unit = _this select 2; + +if (_unit == player) then { + _buildables = count ((getposATL _vehicle) nearObjects ["DZ_buildables", 3]); + if (_buildables > 0) then { + + switch _position do { + case ("driver"): { _unit action ["getInDriver", _vehicle]; }; + case ("cargo"): { _unit action ["getInCargo", _vehicle]; }; + case ("commander"): { _unit action ["getInCommmander", _vehicle]; }; + case ("gunner"): { _unit action ["getInGunner", _vehicle]; }; + case ("pilot"): { _unit action ["getInPilot", _vehicle]; }; + case ("turret"): { _unit action ["getInTurret", _vehicle]; }; + }; + + //Log to server RPT (could give false pos) - should help admins see who is trying to abuse this. + PVDZ_Server_LogIt = format["Player %1 exited a vehicle(%2) close to buildable object as %3",_unit, (typeof _vehicle), _position]; + publicVariableServer "PVDZ_Server_LogIt"; + + cutText ["Unable to exit vehicle too close to buildables objects", "PLAIN DOWN"]; + + }; +}; + +diag_log format["%1 - %2 - %3",_vehicle,_position,_unit]; \ No newline at end of file diff --git a/SQF/dayz_code/compile/zombie_findTargetAgent.sqf b/SQF/dayz_code/compile/zombie_findTargetAgent.sqf index 92d73340c..4fe769b8a 100644 --- a/SQF/dayz_code/compile/zombie_findTargetAgent.sqf +++ b/SQF/dayz_code/compile/zombie_findTargetAgent.sqf @@ -1,81 +1,63 @@ -private ["_agent","_target","_targets","_targetDis","_man","_manDis","_range","_objects","_refobj"]; +private ["_target","_targets","_man","_manDis","_localtargets","_remotetargets"]; _agent = _this; _target = objNull; -/* -_local = []; -_remote = []; -*/ _targets = []; -_targetDis = []; -_range = 120; +//_targetDis = []; +_range = 100; _manDis = 0; -_refobj = vehicle player; -/* -_local = _agent getVariable ["target",[]]; -//diag_log ("Local is: " + str(_local)); -_remote = _agent getVariable ["targets",[]]; -//diag_log ("Remote is: " + str(_remote)); +_localtargets = _agent getVariable ["localtargets",[]]; +_remotetargets = _agent getVariable ["remotetargets",[]]; -if (count _remote == 0) then -{ - _targets = _local; - //diag_log ("Targets is: " + str(_targets)); -} -else -{ - _targets = _local + _remote; - //diag_log ("Local + Remote targets is: " + str(_targets)); +if (isNil "_localtargets") then{ + _localtargets = []; }; -*/ +if (isNil "_remotetargets") then{ + _remotetargets = []; +}; +_targets = _localtargets + _remotetargets; -_targets = _agent getVariable ["targets",[]]; +//diag_log ("Targets: " +str(_targets)); -if (isNil "_targets") exitWith {}; +//if (isNil "_targets") exitWith {}; + //Search for objects -if (count _targets == 0) then -{ - _objects = nearestObjects [_agent,["ThrownObjects","GrenadeHandTimedWest","SmokeShell"],50]; +if (count _targets == 0) then { +//"ThrownObjects","GrenadeHandTimedWest","SmokeShell"] + _objects = _agent nearObjects ["GrenadeHand", 300]; { - private["_dis"]; - if (!(_x in _targets)) then - { - _targets set [count _targets,_x]; - _targetDis set [count _targetDis,_dis]; + if (!(_x in _targets)) then { + if (local _x) then { + _localtargets set [count _localtargets,_x]; + } else { + _remotetargets set [count _remotetargets,_x]; + }; }; - } count _objects; + } foreach _objects; }; //Find best target -if (count _targets > 0) then -{ +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 - { + _dis = _x distance _agent; + if (_dis < _manDis) then { _man = _x; _manDis = _dis; }; - if (_dis > _range) then - { - _targets = _targets - [_x]; - }; - if (_x isKindOf "SmokeShell") then - { + if (_x isKindOf "SmokeShell") then { _man = _x; _manDis = _dis; }; - } count _targets; - + } forEach _targets; _target = _man; }; //Check if too far -if (_manDis > _range) then -{ +if (_manDis > _range) then { _targets = _targets - [_target]; _target = objNull; }; diff --git a/SQF/dayz_code/compile/zombie_generate.sqf b/SQF/dayz_code/compile/zombie_generate.sqf index 6a33c69f5..c62e3c399 100644 --- a/SQF/dayz_code/compile/zombie_generate.sqf +++ b/SQF/dayz_code/compile/zombie_generate.sqf @@ -1,8 +1,20 @@ -private ["_position","_unitTypes","_radius","_method","_agent"]; +#include "\z\addons\dayz_code\loot\Loot.hpp" + +private ["_bypass","_position","_unitTypes","_radius","_method","_agent","_maxlocalspawned","_doLoiter","_wildspawns","_maxControlledZombies","_cantSee","_isok","_zPos","__FILE__","_fov","_safeDistance","_farDistance","_xasl","_eye","_ed","_deg","_skipFOV","_wildSpawns","_tooClose","_type","_loot","_array","_rnd","_lootType","_index","_weights","_loot_count","_favStance"]; _position = _this select 0; -_doLoiter = _this select 1; // wander around +_doLoiter = _this select 1; // wonder around _unitTypes = _this select 2; // class of wanted models +//_wildspawns = _this select 3; +_bypass = _this select 3; + + +_maxlocalspawned = round(dayz_spawnZombies); +//Lets check if we need to divide the amount of zeds +if (r_player_divideinvehicle > 0) then { + _maxlocalspawned = round(dayz_spawnZombies / r_player_divideinvehicle); +}; + _maxControlledZombies = round(dayz_maxLocalZombies); _cantSee = { @@ -24,140 +36,116 @@ _cantSee = { if (_xasl distance _zPos < _farDistance) then { if (_xasl distance _zPos < _safeDistance) then { _isok = false; - } - else { + } else { _eye = eyePos _x; // ASL _ed = eyeDirection _x; _ed = (_ed select 0) atan2 (_ed select 1); _deg = [_xasl, _zPos] call BIS_fnc_dirTo; _deg = (_deg - _ed + 720) % 360; if (_deg > 180) then { _deg = _deg - 360; }; - if ((abs(_deg) < _fov) && {( // in right angle sector? + if ((abs(_deg) < _fov) AND {( // in right angle sector? (!(terrainIntersectASL [_zPos, _eye]) // no terrain between? - && {(!(lineIntersects [_zPos, _eye]))}) // && no object between? + AND {(!(lineIntersects [_zPos, _eye]))}) // and no object between? )}) then { _isok = false; }; }; }; if (!_isok) exitWith {false}; - } count playableUnits; + sleep 0.001; + } forEach playableUnits; _isok }; -if ((dayz_spawnZombies < _maxControlledZombies) && (dayz_CurrentNearByZombies < dayz_maxNearByZombies) && (dayz_currentGlobalZombies < dayz_maxGlobalZeds)) then { - if ([_position, dayz_cantseefov, 10, dayz_cantseeDist] call _cantSee) then { - //Check if anyone close +_skipFOV = false; + +if ((_maxlocalspawned < _maxControlledZombies) and (dayz_CurrentNearByZombies < dayz_maxNearByZombies) and (dayz_currentGlobalZombies < dayz_maxGlobalZeds)) then { + + //if (_wildSpawns) then { + // _skipFOV = true; + // _position = [_position,150,200] call dayz_RandomLocation; + //}; + if (_bypass) then { + _skipFOV = true; + _position = [_position,3,20,1] call fn_selectRandomLocation; + }; + + if (surfaceIsWater _position) exitwith { Diag_log ("Location is in Water Abort"); }; + + if ((_skipFOV) or {([_position, 15, 10, 70] call _cantSee)}) then { _tooClose = {isPlayer _x} count (_position nearEntities ["CAManBase",30]) > 0; - if (_tooClose) exitwith { - // diag_log ("Zombie_Generate: was too close to player."); + if (_tooClose) exitwith { diag_log ("Zombie_Generate: was too close to player."); }; + + if (count _unitTypes == 0) then + { + _unitTypes = getArray (configFile >> "CfgLoot" >> "Buildings" >> "Default" >> "zombieClass"); }; - - //Add zeds if unitTypes equals 0 - if (count _unitTypes == 0) then { - if (DZE_MissionLootTable) then { - _unitTypes = []+ getArray (missionConfigFile >> "CfgBuildingLoot" >> "Default" >> "zombieClass"); - } else { - _unitTypes = []+ getArray (configFile >> "CfgBuildingLoot" >> "Default" >> "zombieClass"); - }; - }; - + // lets create an agent _type = _unitTypes call BIS_fnc_selectRandom; _radius = 5; _method = "NONE"; if (_doLoiter) then { - _radius = 40; _method = "CAN_COLLIDE"; }; - - //Check if point is in water - if (surfaceIsWater _position) exitwith { }; - - _agent = createAgent [_type, _position, [], _radius, _method]; - uiSleep 0.001; - - //add to global counter + + _agent = createAgent [_type, _position, [], _radius, _method]; + sleep 0.03; + + //add to global counter dayz_spawnZombies = dayz_spawnZombies + 1; - + dayz_CurrentNearByZombies = dayz_CurrentNearByZombies + 1; + dayz_currentGlobalZombies = dayz_currentGlobalZombies + 1; + //Add some loot - _loot = ""; - _array = []; - _rnd = random 1; - if (_rnd < 0.2) then { - _lootType = configFile >> "CfgVehicles" >> _type >> "zombieLoot"; - if (isText _lootType) then { - _array = []; - if (DZE_MissionLootTable) then { - { - _array set [count _array, _x select 0] - } forEach getArray (missionConfigFile >> "cfgLoot" >> getText(_lootType)); - } else { - { - _array set [count _array, _x select 0] - } forEach getArray (configFile >> "cfgLoot" >> getText(_lootType)); - }; - if (count _array > 0) then { - _index = dayz_CLBase find getText(_lootType); - _weights = dayz_CLChances select _index; - _loot = _array select (_weights select (floor(random (count _weights)))); - if(!isNil "_array") then { - _loot_count = getNumber(configFile >> "CfgMagazines" >> _loot >> "count"); - if(_loot_count>1) then { - _agent addMagazine [_loot, ceil(random _loot_count)]; - } else { - _agent addMagazine _loot; - }; - }; - }; + //_loot = ""; + //_array = []; + //_rnd = random 1; + if (0.7 > random 1) then + { + _lootGroup = configFile >> "CfgVehicles" >> _type >> "zombieLoot"; + if (isText _lootGroup) then + { + //_lootGroup = dayz_lootGroups find getText (_lootGroup); + _lootGroup = Loot_GetGroup(getText _lootGroup); + //[_agent, _lootGroup, 1] call loot_insert; + Loot_Insert(_agent, _lootGroup, 1); }; }; - + + _agent setVariable["agentObject",_agent]; if (!isNull _agent) then { - // sometime Z can be seen flying in very high speed while tp. Its altitude is set underground to hide that. - /* - _agtPos = getPosASL _agent; - _agtPos set [2, -3]; - _agent setPosASL _agtPos; - uiSleep 0.001; - _agtPos = +(_position); - _agtPos set [2, -3]; - _agent setPosASL _agtPos; - uiSleep 0.001; - */ _agent setDir random 360; - //_agent setPosATL _position; - uiSleep 0.001; + sleep 0.03; _position = getPosATL _agent; _favStance = ( switch ceil(random(3^0.5)^2) do { //case 3: {"DOWN"}; // prone - case 2: {"Middle"}; // Kneel - default {"UP"} // stand-up + case 2: {"middle"}; // Kneel "middle" + default {"Up"}; // stand-up } ); _agent setUnitPos _favStance; _agent setVariable ["stance", _favStance]; _agent setVariable ["BaseLocation", _position]; - _agent setVariable ["doLoiter", true]; // true: Z will be wandering, false: stay still - _agent setVariable ["myDest", _position]; - _agent setVariable ["newDest", _position]; - [_agent, _position] call zombie_loiter; + _agent setVariable ["doLoiter", _doLoiter]; // true: Z will be wandering, false: stay still + //_agent setVariable ["myDest", _position]; + //_agent setVariable ["newDest", _position]; + //[_agent, _position] call zombie_loiter; }; - //add to monitor - //dayz_zedMonitor set [count dayz_zedMonitor, _agent]; - - //Disable simulation - PVDZE_Server_Simulation = [_agent, false]; - publicVariableServer "PVDZE_Server_Simulation"; - + + //Disable simulation + PVDZ_Server_Simulation = [_agent, false]; + publicVariableServer "PVDZ_Server_Simulation"; + //Start behavior _id = [_position,_agent] execFSM "\z\AddOns\dayz_code\system\zombie_agent.fsm"; }; -}; + +}; \ No newline at end of file diff --git a/SQF/dayz_code/compile/zombie_initialize.sqf b/SQF/dayz_code/compile/zombie_initialize.sqf new file mode 100644 index 000000000..23f7c2d42 --- /dev/null +++ b/SQF/dayz_code/compile/zombie_initialize.sqf @@ -0,0 +1,3 @@ +_unit = _this select 0; +_id = _unit addeventhandler ["HandleDamage",{_this call local_zombieDamage}]; +_id = _unit addeventhandler ["Killed",{[_this,"zombieKills"] call local_eventKill}]; \ No newline at end of file diff --git a/SQF/dayz_code/system/player_monitor.fsm b/SQF/dayz_code/system/player_monitor.fsm index 467454f4c..03ec50939 100644 --- a/SQF/dayz_code/system/player_monitor.fsm +++ b/SQF/dayz_code/system/player_monitor.fsm @@ -18,7 +18,7 @@ item13[] = {"Parse_Login",2,250,-66.532227,557.409241,33.467773,607.409241,0.000 item14[] = {"Hive_Bad",4,218,125.000000,550.000000,225.000000,600.000000,10.000000,"Hive" \n "Bad"}; item15[] = {"ERROR__Wrong_HIVE",2,250,325.000000,550.000000,425.000000,600.000000,0.000000,"ERROR:" \n "Wrong HIVE" \n "Version"}; item16[] = {"Character_Setup",4,218,-175.000000,600.000000,-75.000000,650.000000,0.000000,"Character" \n "Setup"}; -item17[] = {"Phase_One",2,250,-75.000000,650.000000,25.000000,700.000000,0.000000,"Phase One"}; +item17[] = {"Phase_One",2,4346,-75.000000,650.000000,25.000000,700.000000,0.000000,"Phase One"}; item18[] = {"Response",4,218,-175.000000,700.000000,-75.000000,750.000000,0.000000,"Response"}; item19[] = {"Phase_Two",2,250,-75.000000,750.000000,25.000000,800.000000,0.000000,"Phase Two"}; item20[] = {"Dead_Player",4,218,125.000000,750.000000,225.000000,800.000000,0.000000,"Dead" \n "Player"}; @@ -33,7 +33,7 @@ item28[] = {"Display_Ready",4,218,-175.000000,1200.000000,-75.000000,1250.000000 item29[] = {"Preload_Display",2,250,-75.000000,1250.000000,25.000000,1300.000000,0.000000,"Preload" \n "Display"}; item30[] = {"Preload_Done",4,218,-175.000000,1300.000000,-75.000000,1350.000000,0.000000,"Preload" \n "Done"}; item31[] = {"Initialize",2,250,-75.000000,1350.000000,25.000000,1400.000000,0.000000,"Initialize"}; -item32[] = {"Finish",1,4346,-75.000000,1625.000000,25.000000,1675.000000,0.000000,"Finish"}; +item32[] = {"Finish",1,250,-75.000000,1625.000000,25.000000,1675.000000,0.000000,"Finish"}; item33[] = {"no_Time_Date",4,218,125.000000,950.000000,225.000000,1000.000000,0.000000,"no Time/Date"}; item34[] = {"sleep",4,218,525.000000,150.000000,625.000000,200.000000,0.000000,"sleep"}; item35[] = {"sleep",4,218,525.000000,550.000000,625.000000,600.000000,0.000000,"sleep"}; @@ -243,8 +243,8 @@ link127[] = {107,32}; link128[] = {108,109}; link129[] = {109,110}; link130[] = {110,64}; -globals[] = {0.000000,0,0,0,0,640,480,3,262,6316128,1,-321.543945,357.690063,2264.614258,769.397766,452,995,1}; -window[] = {0,-1,-1,-1,-1,734,208,1228,208,1,470}; +globals[] = {0.000000,0,0,0,0,640,480,3,262,6316128,1,-416.145355,452.291077,1642.353271,662.678894,890,1004,1}; +window[] = {2,-1,-1,-1,-1,682,156,1176,156,3,908}; *//*%FSM*/ class FSM { @@ -627,6 +627,7 @@ class FSM "player allowDamage false;" \n "_lastAte = _survival select 1;" \n "_lastDrank = _survival select 2;" \n + "_typedBags = [""bloodBagANEG"", ""bloodBagAPOS"", ""bloodBagBNEG"", ""bloodBagBPOS"", ""bloodBagONEG"", ""bloodBagOPOS"",""wholeBloodBagANEG"", ""wholeBloodBagAPOS"", ""wholeBloodBagBNEG"", ""wholeBloodBagBPOS"", ""wholeBloodBagONEG"", ""wholeBloodBagOPOS""];" \n "" \n "_usedFood = 0;" \n "_usedWater = 0;" \n @@ -676,7 +677,11 @@ class FSM " _countr = 0;" \n " {" \n " if (_x == ""BoltSteel"") then { _x = ""WoodenArrow"" }; // Convert BoltSteel to WoodenArrow" \n - " if (_x == ""ItemBloodbag"") then { _x = ""bloodBagONEG"" }; // Convert ItemBloodbag into universal blood type/rh bag" \n + " if (DZE_UseBloodTypes) then {" \n + " if (_item == ""ItemBloodbag"") then { _item = ""bloodBagONEG"" }; // Convert ItemBloodbag into universal blood type/rh bag" \n + " } else {" \n + " if (_item in _typedBags) then {_item = ""ItemBloodbag""};" \n + " };" \n " dayz_myBackpack addMagazineCargoGlobal [_x,(_backpackMagQty select _countr)];" \n " _countr = _countr + 1;" \n " } forEach _backpackMagTypes;" \n