From b667d01c1c8a14e2e4289fa1f19b3983b642fe9c Mon Sep 17 00:00:00 2001 From: icomrade Date: Mon, 29 Feb 2016 10:45:53 -0500 Subject: [PATCH] Actions Done --- SQF/dayz_code/NOTE.txt | 9 + SQF/dayz_code/actions/ammo.sqf | 5 +- SQF/dayz_code/actions/boil.sqf | 96 ++-- SQF/dayz_code/actions/cook.sqf | 78 +-- SQF/dayz_code/actions/fire_pack.sqf | 7 +- SQF/dayz_code/actions/gather_meat.sqf | 151 +++--- SQF/dayz_code/actions/gather_zparts.sqf | 157 +++--- SQF/dayz_code/actions/object_pickup.sqf | 116 +++-- SQF/dayz_code/actions/player_addToolbelt.sqf | 117 ++--- SQF/dayz_code/actions/player_addtoBack.sqf | 5 +- .../actions/player_build_vanilla.sqf | 405 ++++++++++++++++ .../actions/player_craftItem_vanilla.sqf | 185 +++++++ SQF/dayz_code/actions/player_drinkWater.sqf | 4 +- SQF/dayz_code/actions/player_dropWeapon.sqf | 2 + SQF/dayz_code/actions/player_flipvehicle.sqf | 3 +- .../actions/player_goFishing_vanilla.sqf | 160 ++++++ SQF/dayz_code/actions/player_makefire.sqf | 91 +++- SQF/dayz_code/actions/player_setTrap.sqf | 38 +- SQF/dayz_code/actions/player_sleep.sqf | 136 ++++-- SQF/dayz_code/actions/player_switchWeapon.sqf | 455 ++++++++++-------- SQF/dayz_code/actions/player_useMeds.sqf | 86 +++- SQF/dayz_code/actions/refuel.sqf | 203 +++----- SQF/dayz_code/actions/repair.sqf | 160 ++---- SQF/dayz_code/actions/repair_vehicle.sqf | 60 +-- SQF/dayz_code/actions/salvage.sqf | 113 ++--- SQF/dayz_code/actions/salvage_vehicle.sqf | 109 +++-- SQF/dayz_code/actions/siphonFuel.sqf | 101 ++-- 27 files changed, 1958 insertions(+), 1094 deletions(-) create mode 100644 SQF/dayz_code/actions/player_build_vanilla.sqf create mode 100644 SQF/dayz_code/actions/player_craftItem_vanilla.sqf create mode 100644 SQF/dayz_code/actions/player_goFishing_vanilla.sqf diff --git a/SQF/dayz_code/NOTE.txt b/SQF/dayz_code/NOTE.txt index b10d1810d..42ff9747e 100644 --- a/SQF/dayz_code/NOTE.txt +++ b/SQF/dayz_code/NOTE.txt @@ -80,6 +80,15 @@ player getVariable ["OpenTarget",false]; CHANGE TO player getVariable ["freeTarget",false]; +//////////////////////////////////////// +SELF ACTIONS VARIABLES +//////////////////////////////////////// +s_player_boil = -1; is now a_player_boil = true; +a_player_cooking = true; -- NEW, old -1 var is still used??? +PVCDZ_obj_GutBody IS NOW PVDZE_plr_GutBody +MAKE SURE "ItemFuelBarrel" is in refuel can list +PVDZE_obj_Delete is PVDZ_obj_Destroy with 3 array elements + ////////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/actions/ammo.sqf b/SQF/dayz_code/actions/ammo.sqf index f1d4df634..fc1e6458a 100644 --- a/SQF/dayz_code/actions/ammo.sqf +++ b/SQF/dayz_code/actions/ammo.sqf @@ -18,8 +18,7 @@ if (_ammo != "") then { _vehicle removeMagazineTurret [_ammo,_turret]; _vehicle addMagazineTurret [_ammo,_turret]; player removeMagazine _ammo; - - cutText [format[(localize "str_epoch_player_127"),_ammoType], "PLAIN DOWN"]; + cutText [format [localize "str_player_ammo_successful",_ammoType], "PLAIN DOWN"]; } else { - cutText [format[(localize "str_epoch_player_128"),_text], "PLAIN DOWN"]; + cutText [format [localize "str_player_ammo_fail",_text], "PLAIN DOWN"]; }; \ No newline at end of file diff --git a/SQF/dayz_code/actions/boil.sqf b/SQF/dayz_code/actions/boil.sqf index ac58e7855..3a5f71a74 100644 --- a/SQF/dayz_code/actions/boil.sqf +++ b/SQF/dayz_code/actions/boil.sqf @@ -1,56 +1,80 @@ -private ["_hasbottleitem","_hastinitem","_bottletext","_tin1text","_tin2text","_tintext","_qty","_dis","_sfx","_removed"]; +private ["_bottletext","_tin1text","_tin2text","_tintext","_hasbottleitem","_hastinitem","_qty","_dis","_sfx"]; if(DZE_ActionInProgress) exitWith { cutText [(localize "str_epoch_player_22") , "PLAIN DOWN"]; }; DZE_ActionInProgress = true; -player removeAction s_player_boil; -s_player_boil = 1; +_bottletext = getText (configFile >> "CfgMagazines" >> "ItemWaterBottle" >> "displayName"); +_tin1text = getText (configFile >> "CfgMagazines" >> "TrashTinCan" >> "displayName"); +_tin2text = getText (configFile >> "CfgMagazines" >> "ItemSodaEmpty" >> "displayName"); +_tintext = format["%1 / %2",_tin1text,_tin2text]; +_bottleInfected = false; -_hasbottleitem = "ItemWaterbottle" in magazines player; +_hasbottleitem = (("ItemWaterBottle" in magazines player) || ("ItemWaterBottleInfected" in magazines player) || ("ItemWaterBottleSafe" in magazines player)); _hastinitem = false; +a_player_boil = true; + +player removeAction s_player_boil; +//s_player_boil = -1; + +if ("ItemWaterBottleInfected" in magazines player) then { + _bottleInfected = true; +}; + { if (_x in magazines player) then { _hastinitem = true; }; -} count boil_tin_cans; +} forEach boil_tin_cans; -_bottletext = getText (configFile >> "CfgMagazines" >> "ItemWaterbottle" >> "displayName"); -_tin1text = getText (configFile >> "CfgMagazines" >> "TrashTinCan" >> "displayName"); -_tin2text = getText (configFile >> "CfgMagazines" >> "ItemSodaEmpty" >> "displayName"); -_tintext = format["%1 / %2",_tin1text,_tin2text]; -if (!_hasbottleitem) exitWith {DZE_ActionInProgress = false; cutText [format[(localize "str_player_31"),_bottletext,"fill"] , "PLAIN DOWN"]}; -if (!_hastinitem) exitWith {DZE_ActionInProgress = false; cutText [format[(localize "str_player_31"),_tintext,"fill"] , "PLAIN DOWN"]}; -_removed = 0; +if (!_hasbottleitem) exitWith {cutText [DZE_ActionInProgress = false; format [localize "str_player_31",_bottletext,localize "str_player_31_fill"] , "PLAIN DOWN"]; a_player_boil = false;}; +if (!_hastinitem) exitWith {DZE_ActionInProgress = false; cutText [format [localize "str_player_31",_tintext,localize "str_player_31_fill"] , "PLAIN DOWN"]; a_player_boil = false;}; -if (_hasbottleitem && _hastinitem) then { - _qty = {_x == "ItemWaterbottle"} count magazines player; - if ("ItemWaterbottle" in magazines player) then { - - _removed = _removed + ([player,"ItemWaterbottle",_qty] call BIS_fnc_invRemove); - [1,1] call dayz_HungerThirst; - player playActionNow "Medic"; - uiSleep 1; - - _dis=10; - _sfx = "cook"; - [player,_sfx,0,false,_dis] call dayz_zombieSpeak; - [player,_dis,true,(getPosATL player)] spawn player_alertZombies; - - uiSleep 5; - - // Add back only number of removed - for "_x" from 1 to _removed do { - player addMagazine "ItemWaterbottleBoiled"; +if (_hasbottleitem and _hastinitem) then { + _qty = 0; + _qty = _qty + ({_x == "ItemWaterBottleInfected"} count magazines player); + _qty = _qty + ({_x == "ItemWaterBottle"} count magazines player); + _qty = _qty + ({_x == "ItemWaterBottleSafe"} count magazines player); + + player playActionNow "Medic"; + sleep 1; + _dis=10; + _sfx = "cook"; + [player,_sfx,0,false,_dis] call dayz_zombieSpeak; + [player,_dis,true,(getPosATL player)] call player_alertZombies; + uiSleep 5; + + for "_x" from 1 to _qty do { + if ("ItemWaterBottleInfected" in magazines player) then { + player removeMagazine "ItemWaterBottleInfected"; + } else { + if ("ItemWaterBottleSafe" in magazines player) then { + player removeMagazine "ItemWaterBottleSafe"; + } else { + player removeMagazine "ItemWaterBottle"; + }; }; - cutText [format[(localize "str_player_01"),_qty], "PLAIN DOWN"]; - } else { - cutText [(localize "str_player_02") , "PLAIN DOWN"]; + //if ([0.1] call fn_chance) then { + //player addMagazine "ItemWaterBottleDmg"; + //systemChat (localize ("str_waterbottle_broke")); + //_msg = localize "str_waterbottle_broke"; + //_msg call dayz_rollingMessages; + //} else { + player addMagazine "ItemWaterBottleBoiled"; + //}; + }; + //cutText [format [localize "str_player_boiledwater",_qty], "PLAIN DOWN"]; + _msg = format [localize "str_player_boiledwater",_qty]; + _msg call dayz_rollingMessages; +} else { + //cutText [localize "str_player_02", "PLAIN DOWN"]; + _msg = format [localize "str_player_boiledwater",_qty]; + _msg = localize "str_player_02"; + _msg call dayz_rollingMessages; }; -s_player_boil = -1; - +a_player_boil = false; DZE_ActionInProgress = false; \ No newline at end of file diff --git a/SQF/dayz_code/actions/cook.sqf b/SQF/dayz_code/actions/cook.sqf index bd2b5eb3a..f08a400d7 100644 --- a/SQF/dayz_code/actions/cook.sqf +++ b/SQF/dayz_code/actions/cook.sqf @@ -1,80 +1,38 @@ -private ["_text","_rawmeat","_cookedmeat","_meat","_meatcooked","_qty","_started","_finished","_animState","_isMedic","_removed","_dis","_sfx","_textraw"]; +private ["_rawmeat","_cookedmeat","_meat","_meatcooked","_text","_qty","_dis","_sfx"]; if(DZE_ActionInProgress) exitWith { cutText [(localize "str_epoch_player_23") , "PLAIN DOWN"]; }; DZE_ActionInProgress = true; -// diag_log ("Cook Enabled"); +//diag_log ("Cook Enabled"); player removeAction s_player_cook; -s_player_cook = 1; - -_rawmeat = meatraw; -_cookedmeat = meatcooked; - +s_player_cook = -1; +_rawmeat = Dayz_meatraw; +_cookedmeat = Dayz_meatcooked; +a_player_cooking = true; { _meat = _x; _meatcooked = _cookedmeat select (_rawmeat find _meat); - _removed = 0; if (_meat in magazines player) then { - _textraw = getText (configFile >> "CfgMagazines" >> _meat >> "displayName"); - _text = getText (configFile >> "CfgMagazines" >> _meatcooked >> "displayName"); - + _text = getText (configFile >> "CfgMagazines" >> _meatcooked >> "displayName"); _qty = {_x == _meat} count magazines player; - - cutText [format[(localize "str_epoch_player_129"),_textraw], "PLAIN DOWN"]; - [1,1] call dayz_HungerThirst; player playActionNow "Medic"; - + _dis=6; _sfx = "cook"; - [player,_sfx,0,false,_dis] call dayz_zombieSpeak; - [player,_dis,true,(getPosATL player)] spawn player_alertZombies; - - r_interrupt = false; - _animState = animationState player; - r_doLoop = true; - _started = false; - _finished = false; - - while {r_doLoop} do { - _animState = animationState player; - _isMedic = ["medic",_animState] call fnc_inString; - if (_isMedic) then { - _started = true; - }; - if (_started && !_isMedic) then { - r_doLoop = false; - _finished = true; - }; - if (r_interrupt) then { - r_doLoop = false; - }; - uiSleep 0.1; - }; - r_doLoop = false; - - - if (_finished) then { - - _removed = _removed + ([player,_meat,_qty] call BIS_fnc_invRemove); - for "_x" from 1 to _removed do { - player addMagazine _meatcooked; - }; - - cutText [format[(localize "str_success_cooked"),_qty,_text], "PLAIN DOWN"]; - - } else { - r_interrupt = false; - if (vehicle player == player) then { - [objNull, player, rSwitchMove,""] call RE; - player playActionNow "stop"; - }; - - cutText [format[(localize "str_epoch_player_130"),_textraw], "PLAIN DOWN"]; + [player,_sfx,0,false,_dis] call dayz_zombieSpeak; + [player,_dis,true,(getPosATL player)] call player_alertZombies; + + uiSleep _qty; + for "_x" from 1 to _qty do { + player removeMagazine _meat; + player addMagazine _meatcooked; + if !(_meat in magazines player) exitWith {cutText [format [localize "str_player_31",_text,localize "str_player_31_cook"] , "PLAIN DOWN"]}; }; + cutText [format [localize "str_success_cooked",_qty,_text], "PLAIN DOWN"]; }; } forEach _rawmeat; -s_player_cook = -1; +a_player_cooking = false; DZE_ActionInProgress = false; \ No newline at end of file diff --git a/SQF/dayz_code/actions/fire_pack.sqf b/SQF/dayz_code/actions/fire_pack.sqf index 8b898788c..fb6a5e0fd 100644 --- a/SQF/dayz_code/actions/fire_pack.sqf +++ b/SQF/dayz_code/actions/fire_pack.sqf @@ -1,14 +1,11 @@ private["_obj"]; _obj = _this select 3; - -player removeAction s_player_fireout; -s_player_fireout = 1; -[1,1] call dayz_HungerThirst; player playActionNow "Medic"; -uiSleep 6; +sleep 6; if(_obj isKindOf "Land_fire") then { dayz_hasFire = objNull; deleteVehicle _obj; }; cutText [localize "str_fireplace_removed", "PLAIN DOWN"]; +player removeAction s_player_fireout; s_player_fireout = -1; \ No newline at end of file diff --git a/SQF/dayz_code/actions/gather_meat.sqf b/SQF/dayz_code/actions/gather_meat.sqf index a18346dbf..c51f40042 100644 --- a/SQF/dayz_code/actions/gather_meat.sqf +++ b/SQF/dayz_code/actions/gather_meat.sqf @@ -1,90 +1,101 @@ -private ["_item","_hasKnife","_hasKnifeBlunt","_hasHarvested","_qty","_text","_string","_type","_started","_finished","_animState","_isMedic","_isListed","_config"]; +private ["_item", "_type", "_hasHarvested", "_config", "_knifeArray", "_PlayerNear", "_isListed", "_activeKnife", "_text", "_dis", "_sfx", "_sharpnessRemaining"]; if(DZE_ActionInProgress) exitWith { cutText [(localize "str_epoch_player_29") , "PLAIN DOWN"]; }; DZE_ActionInProgress = true; -player removeAction s_player_butcher; -s_player_butcher = 1; - _item = _this select 3; -_hasKnife = "ItemKnife" in items player; -_hasKnifeBlunt = "ItemKnifeBlunt" in items player; _type = typeOf _item; _hasHarvested = _item getVariable["meatHarvested",false]; -_config = configFile >> "CfgSurvival" >> "Meat" >> _type; +_config = configFile >> "CfgSurvival" >> "Meat" >> _type; -if ((_hasKnife || _hasKnifeBlunt) && !_hasHarvested) then { - //Get Animal Type - _isListed = isClass (_config); - _text = getText (configFile >> "CfgVehicles" >> _type >> "displayName"); +_knifeArray = []; + +player removeAction s_player_butcher; +s_player_butcher = -1; + +_PlayerNear = {isPlayer _x} count ((getPosATL _item) nearEntities ["CAManBase", 10]) > 1; +if (_PlayerNear) exitWith {cutText [localize "str_pickup_limit_5", "PLAIN DOWN"]}; + +//Count how many active tools the player has +{ + if (_x IN items player) then { + _knifeArray set [count _knifeArray, _x]; + }; +} count Dayz_Gutting; + +if ((count _knifeArray) < 1) exitwith { cutText [localize "str_cannotgut", "PLAIN DOWN"] }; + + +if ((count _knifeArray > 0) and !_hasHarvested) then { + private ["_qty"]; - [1,1] call dayz_HungerThirst; - // force animation + //Select random can from array + _activeKnife = _knifeArray call BIS_fnc_selectRandom; + + //Get Animal Type + _isListed = isClass (_config); + _text = getText (configFile >> "CfgVehicles" >> _type >> "displayName"); + player playActionNow "Medic"; - // Alert zombies - [player,10,true,(getPosATL player)] spawn player_alertZombies; + _dis=10; + _sfx = "gut"; + [player,_sfx,0,false,_dis] call dayz_zombieSpeak; + [player,_dis,true,(getPosATL player)] call player_alertZombies; - r_interrupt = false; - _animState = animationState player; - r_doLoop = true; - _started = false; - _finished = false; - - while {r_doLoop} do { - _animState = animationState player; - _isMedic = ["medic",_animState] call fnc_inString; - if (_isMedic) then { - _started = true; - }; - if (_started && !_isMedic) then { - r_doLoop = false; - _finished = true; - }; - if (r_interrupt) then { - r_doLoop = false; - }; - uiSleep 0.1; - }; - r_doLoop = false; + // Added Nutrition-Factor for work + ["Working",0,[20,40,15,0]] call dayz_NutritionSystem; - if (!_finished) exitWith { - r_interrupt = false; - if (vehicle player == player) then { - [objNull, player, rSwitchMove,""] call RE; - player playActionNow "stop"; - }; - cutText [(localize "str_epoch_player_30") , "PLAIN DOWN"]; - //_abort = true; + _item setVariable ["meatHarvested",true,true]; + + _qty = 2; + if (_isListed) then { + _qty = getNumber (_config >> "yield"); }; - _hasHarvested = _item getVariable["meatHarvested",false]; - - if(_finished && !_hasHarvested) then { + if (_activeKnife == "ItemKnifeBlunt") then { _qty = round(_qty / 2); }; - _item setVariable["meatHarvested",true,true]; - - // Play sound since we finished - [player,"gut",0,false,10] call dayz_zombieSpeak; - - _qty = 2; - if (_isListed) then { - _qty = getNumber (_config >> "yield"); - }; - - if (_hasKnifeBlunt) then { _qty = round(_qty / 2); }; - - if (local _item) then { - [_item,_qty] spawn local_gutObject; - } else { - //Leave this as PV instead of PVS/PVC - Skaronator - PVDZE_plr_GutBody =[_item,_qty]; - publicVariable "PVDZE_plr_GutBody"; - }; + if (local _item) then { + [_item,_qty] spawn local_gutObject; //leave as spawn (sleeping in loops will work but can freeze the script) + } else { + PVDZE_plr_GutBody =[_item,_qty]; + publicVariable "PVDZE_plr_GutBody"; - _string = format[localize "str_success_gutted_animal",_text,_qty]; - cutText [_string, "PLAIN DOWN"]; + //achievement system + if (!achievement_Gut) then { + achievement_Gut = true; + }; }; + + //_sharpnessRemaining = getText (configFile >> "cfgWeapons" >> _activeKnife >> "sharpnessRemaining"); + + /* switch _activeKnife do { + case "ItemKnife" : { + //_chance = getNumber (configFile >> "cfgWeapons" >> _activeKnife >> "chance"); + if ([0.2] call fn_chance) then { + player removeWeapon _activeKnife; + player addWeapon _sharpnessRemaining; + + //systemChat (localize "str_info_bluntknife"); + _msg = localize "str_info_bluntknife"; + _msg call dayz_rollingMessages; + }; + }; + case "ItemKnifeBlunt" : { + //do nothing + }; + default { + player removeWeapon _activeKnife; + player addWeapon _sharpnessRemaining; + }; + }; */ + + uisleep 6; + _string = format[localize "str_success_gutted_animal",_text,_qty]; + + closedialog 0; + uisleep 0.02; + //cutText [_string, "PLAIN DOWN"]; + _string call dayz_rollingMessages; }; -s_player_butcher = -1; DZE_ActionInProgress = false; \ No newline at end of file diff --git a/SQF/dayz_code/actions/gather_zparts.sqf b/SQF/dayz_code/actions/gather_zparts.sqf index 8953db93e..4770391ec 100644 --- a/SQF/dayz_code/actions/gather_zparts.sqf +++ b/SQF/dayz_code/actions/gather_zparts.sqf @@ -1,92 +1,101 @@ -private ["_hasKnife","_qty","_item","_text","_string","_type","_started","_finished","_animState","_isMedic","_hasHarvested","_hasKnifeBlunt","_humanity"]; +private ["_item", "_type", "_hasHarvested", "_config", "_knifeArray", "_PlayerNear", "_isListed", "_activeKnife", "_text", "_dis", "_sfx", "_sharpnessRemaining"]; -if(DZE_ActionInProgress) exitWith { cutText [(localize "str_epoch_player_31") , "PLAIN DOWN"]; }; +if(DZE_ActionInProgress) exitWith { cutText [(localize "str_epoch_player_29") , "PLAIN DOWN"]; }; DZE_ActionInProgress = true; -player removeAction s_player_butcher; -s_player_butcher = 1; - _item = _this select 3; -_hasKnife = "ItemKnife" in items player; -_hasKnifeBlunt = "ItemKnifeBlunt" in items player; _type = typeOf _item; _hasHarvested = _item getVariable["meatHarvested",false]; -//_config = configFile >> "CfgSurvival" >> "Meat" >> _type; +_config = configFile >> "CfgSurvival" >> "Meat" >> _type; -if ((_hasKnife || _hasKnifeBlunt) && !_hasHarvested) then { - //Get Animal Type - //_loop = true; - //_isListed = isClass (_config); - _text = getText (configFile >> "CfgVehicles" >> _type >> "displayName"); +_knifeArray = []; + +player removeAction s_player_butcher; +s_player_butcher = -1; + +_PlayerNear = {isPlayer _x} count ((getPosATL _item) nearEntities ["CAManBase", 10]) > 1; +if (_PlayerNear) exitWith {cutText [localize "str_pickup_limit_5", "PLAIN DOWN"]}; + +//Count how many active tools the player has +{ + if (_x IN items player) then { + _knifeArray set [count _knifeArray, _x]; + }; +} count Dayz_Gutting; + +if ((count _knifeArray) < 1) exitwith { cutText [localize "str_cannotgut", "PLAIN DOWN"] }; + + +if ((count _knifeArray > 0) and !_hasHarvested) then { + private ["_qty"]; - [1,1] call dayz_HungerThirst; - // force animation + //Select random can from array + _activeKnife = _knifeArray call BIS_fnc_selectRandom; + + //Get Animal Type + _isListed = isClass (_config); + _text = getText (configFile >> "CfgVehicles" >> _type >> "displayName"); + player playActionNow "Medic"; - // Alert zombies - [player,50,true,(getPosATL player)] spawn player_alertZombies; + _dis=10; + _sfx = "gut"; + [player,_sfx,0,false,_dis] call dayz_zombieSpeak; + [player,_dis,true,(getPosATL player)] call player_alertZombies; - r_interrupt = false; - _animState = animationState player; - r_doLoop = true; - _started = false; - _finished = false; - - while {r_doLoop} do { - _animState = animationState player; - _isMedic = ["medic",_animState] call fnc_inString; - if (_isMedic) then { - _started = true; - }; - if (_started && !_isMedic) then { - r_doLoop = false; - _finished = true; - }; - if (r_interrupt) then { - r_doLoop = false; - }; - uiSleep 0.1; - }; - r_doLoop = false; + // Added Nutrition-Factor for work + ["Working",0,[20,40,15,0]] call dayz_NutritionSystem; - if (!_finished) exitWith { - r_interrupt = false; - if (vehicle player == player) then { - [objNull, player, rSwitchMove,""] call RE; - player playActionNow "stop"; - }; - cutText [(localize "str_epoch_player_30") , "PLAIN DOWN"]; - //_abort = true; + _item setVariable ["meatHarvested",true,true]; + + _qty = 2; + if (_isListed) then { + _qty = getNumber (_config >> "yield"); }; - _hasHarvested = _item getVariable["meatHarvested",false]; - - if(_finished && !_hasHarvested) then { + if (_activeKnife == "ItemKnifeBlunt") then { _qty = round(_qty / 2); }; - _item setVariable["meatHarvested",true,true]; - - // Play sound since we finished - [player,"gut",0,false,10] call dayz_zombieSpeak; - - _qty = 1; - if (local _item) then { - [_item,_qty] spawn local_gutObjectZ; - } else { - //Leave this as PV instead of PVS/PVC - Skaronator - //Also not sure if we need this - PVDZE_plr_GutBodyZ = [_item,_qty]; - publicVariable "PVDZE_plr_GutBodyZ"; - }; - - // Reduce humanity for gutting zeds - _humanity = player getVariable["humanity",0]; - _humanity = _humanity - 10; - player setVariable["humanity",_humanity,true]; - - - _string = format["Successfully Gutted Zombie",_text,_qty]; - cutText [_string, "PLAIN DOWN"]; + if (local _item) then { + [_item,_qty] spawn local_gutObject; //leave as spawn (sleeping in loops will work but can freeze the script) + } else { + PVDZE_plr_GutBodyZ = [_item,_qty]; + publicVariable "PVDZE_plr_GutBodyZ"; }; + + //_sharpnessRemaining = getText (configFile >> "cfgWeapons" >> _activeKnife >> "sharpnessRemaining"); + + /* switch _activeKnife do { + case "ItemKnife" : { + //_chance = getNumber (configFile >> "cfgWeapons" >> _activeKnife >> "chance"); + if ([0.2] call fn_chance) then { + player removeWeapon _activeKnife; + player addWeapon _sharpnessRemaining; + + //systemChat (localize "str_info_bluntknife"); + _msg = localize "str_info_bluntknife"; + _msg call dayz_rollingMessages; + }; + }; + case "ItemKnifeBlunt" : { + //do nothing + }; + default { + player removeWeapon _activeKnife; + player addWeapon _sharpnessRemaining; + }; + }; */ + // Reduce humanity for gutting zeds + _humanity = player getVariable["humanity",0]; + _humanity = _humanity - 10; + player setVariable["humanity",_humanity,true]; + + uisleep 6; + _string = format["Successfully Gutted Zombie",_text,_qty]; + //cutText [_string, "PLAIN DOWN"]; + + closedialog 0; + uisleep 0.02; + //cutText [_string, "PLAIN DOWN"]; + _string call dayz_rollingMessages; }; -s_player_butcher = -1; DZE_ActionInProgress = false; \ No newline at end of file diff --git a/SQF/dayz_code/actions/object_pickup.sqf b/SQF/dayz_code/actions/object_pickup.sqf index 8a51cbe54..f88f44db4 100644 --- a/SQF/dayz_code/actions/object_pickup.sqf +++ b/SQF/dayz_code/actions/object_pickup.sqf @@ -1,60 +1,110 @@ -private ["_array","_type","_classname","_holder","_config","_isOk","_muzzles","_playerID","_claimedBy","_text","_playerNear","_obj","_qty"]; - -// Exit if player zombie -if(player isKindOf "PZombie_VB") exitWith {}; - -if (!DZE_CanPickup) exitWith { cutText [(localize "str_epoch_player_38") , "PLAIN DOWN"]; }; -DZE_CanPickup = false; +private ["_array","_type","_classname","_holder","_playerID","_text","_broken","_claimedBy","_config","_isOk","_PlayerNear","_wpn","_ismelee"]; _array = _this select 3; _type = _array select 0; _classname = _array select 1; _holder = _array select 2; -// if holder is null disallow pickup for 5 seconds -if(isNull _holder) exitWith { - DZE_CanPickup = true; -}; - // Check if closest player _PlayerNear = _holder call dze_isnearest_player; if (_PlayerNear) exitWith {cutText [localize "str_pickup_limit_4", "PLAIN DOWN"]}; + +if (player distance _holder > 3) exitwith { localize "str_pickup_limit_1","PLAIN DOWN" }; + +_playerID = getPlayerUID player; +player removeAction s_player_holderPickup; _text = getText (configFile >> _type >> _classname >> "displayName"); +if (!canPickup || !DZE_CanPickup) exitwith { + if (pickupInit) then { + cutText [localize "str_pickup_limit_2","PLAIN DOWN"]; + } else { + cutText [localize "str_pickup_limit_3","PLAIN DOWN"]; + }; +}; + +_claimedBy = _holder getVariable "claimed"; + +if (isnil "claimed") then { + _holder setVariable["claimed",_playerID,true]; +}; + +canPickup = false; +DZE_CanPickup = false; + +if(_classname isKindOf "TrapBear") exitwith {DZE_CanPickup = true; deleteVehicle _holder; }; + player playActionNow "PutDown"; -if(_classname isKindOf "TrapBear") exitwith {DZE_CanPickup = true; deleteVehicle _holder;}; +//Adding random chance of arrow is re-usable on pickup +_broken = false; + +if(_classname == "WoodenArrow") then { + if ([0.15] call fn_chance) then { + _broken = true; + }; +}; + +if (_broken) exitWith {DZE_CanPickup = true; deleteVehicle _holder; cutText [localize "str_broken_arrow", "PLAIN DOWN"]; }; + +sleep 0.25; //Why are we waiting? Animation + +_claimedBy = _holder getVariable["claimed","0"]; + +if (_claimedBy != _playerID) exitWith { cutText [format [localize "str_player_beinglooted",_text] , "PLAIN DOWN"]; }; if(_classname isKindOf "Bag_Base_EP1") exitwith { + _PlayerNear = {isPlayer _x} count ((getPosATL _holder) nearEntities ["CAManBase", 10]) > 1; + if (_PlayerNear) exitWith {DZE_CanPickup = true; cutText [localize "str_pickup_limit_4", "PLAIN DOWN"]}; + + diag_log("Picked up a bag: " + _classname); - // diag_log("Picked up a bag: " + _classname); - if(_classname == typeOf _holder) then { + _hasBag = unitBackpack player; + + if (isNull _hasBag) then { + player action ["TakeBag", _holder]; + } else { + player action ["putbag", player]; + + uisleep 0.03; + player action ["TakeBag", _holder]; }; DZE_CanPickup = true; + //Lets wait to make sure the player has some kind of backpack. + waitUntil { !isNull (unitBackpack player) }; + + uisleep 0.03; + + //Lets call inventory save + PVDZ_plr_Save = [player,nil,false]; + publicVariableServer "PVDZ_plr_Save"; }; -_obj = nearestObjects [(getPosATL player), [(typeOf _holder)], 5]; -_qty = count _obj; +_config = (configFile >> _type >> _classname); -if(_qty >= 1) then { - _config = (configFile >> _type >> _classname); - _isOk = [player,_config] call BIS_fnc_invAdd; - if (_isOk) then { - deleteVehicle _holder; - if (_classname in ["MeleeHatchet_DZE","MeleeCrowbar","MeleeMachete","MeleeFishingPole","MeleeSledge"]) then { - if (_type == "cfgWeapons") then { - _muzzles = getArray(configFile >> "cfgWeapons" >> _classname >> "muzzles"); - //_wtype = ((weapons player) select 0); - if (count _muzzles > 1) then { - player selectWeapon (_muzzles select 0); - } else { - player selectWeapon _classname; - }; - }; - }; +//Remove melee magazines (BIS_fnc_invAdd fix) +{player removeMagazines _x} forEach MeleeMagazines; + +_isOk = [player,_config] call BIS_fnc_invAdd; + +if (_isOk) then { + deleteVehicle _holder; +} else { + if (!_isOk) exitWith { + _holder setVariable["claimed",0,true]; + cutText [localize "str_player_24", "PLAIN DOWN"]; }; }; +uisleep 3; + +//adding melee mags back if needed +_wpn = primaryWeapon player; +//diag_log format["Classname: %1, WPN: %2", _classname,_wpn]; +_ismelee = (getNumber (configFile >> "CfgWeapons" >> _wpn >> "melee") == 1); +if (_ismelee) then { + call dayz_meleeMagazineCheck; +}; DZE_CanPickup = true; \ No newline at end of file diff --git a/SQF/dayz_code/actions/player_addToolbelt.sqf b/SQF/dayz_code/actions/player_addToolbelt.sqf index 1e609f3c8..dac389283 100644 --- a/SQF/dayz_code/actions/player_addToolbelt.sqf +++ b/SQF/dayz_code/actions/player_addToolbelt.sqf @@ -1,94 +1,65 @@ -private ["_item","_config","_onLadder","_create","_isOk","_config2","_magType","_meleeNum","_muzzles","_wtype","_type","_hastoolweapon","_text"]; - +private ["_item","_config","_onLadder","_hastoolweapon","_onBack","_text","_create","_config2","_melee2tb","_isOk"]; +disableSerialization; +_item = _this; +_config = configFile >> "cfgWeapons" >> _item; +_onBack = dayz_onBack in MeleeWeapons; if(DZE_ActionInProgress) exitWith { cutText [(localize "str_epoch_player_39") , "PLAIN DOWN"]; }; DZE_ActionInProgress = true; -_item = _this; -_config = configFile >> "cfgWeapons" >> _item; +_onLadder = (getNumber (configFile >> "CfgMovesMaleSdr" >> "States" >> (animationState player) >> "onLadder")) == 1; +if (_onLadder) exitWith {DZE_ActionInProgress = false; cutText [localize "str_player_21", "PLAIN DOWN"]}; -_onLadder = (getNumber (configFile >> "CfgMovesMaleSdr" >> "States" >> (animationState player) >> "onLadder")) == 1; -if (_onLadder) exitWith {DZE_ActionInProgress = false; cutText [(localize "str_player_21") , "PLAIN DOWN"]}; - -_hastoolweapon = _this in weapons player; +_hastoolweapon = _item in weapons player; _text = getText (_config >> "displayName"); -if (!_hastoolweapon) exitWith {DZE_ActionInProgress = false; cutText [format[(localize "str_player_30"),_text] , "PLAIN DOWN"]}; +if (!_hastoolweapon and !_onBack) exitWith {DZE_ActionInProgress = false; cutText [format [localize "str_player_30",_text] , "PLAIN DOWN"]}; call gear_ui_init; //Add new item -_create = getArray (_config >> "ItemActions" >> "Toolbelt" >> "output") select 0; -_config2 = configFile >> "cfgWeapons" >> _create; +_create = getArray (_config >> "ItemActions" >> "Toolbelt" >> "output") select 0; +_config2 = configFile >> "cfgWeapons" >> _create; -//Remove magazines if needed -if (_item in ["MeleeHatchet_DZE","MeleeCrowbar","MeleeMachete","MeleeFishingPole","MeleeSledge"]) then { - _magType = ([] + getArray (configFile >> "cfgWeapons" >> _item >> "magazines")) select 0; - _meleeNum = ({_x == _magType} count magazines player); - for "_i" from 1 to _meleeNum do { - player removeMagazine _magType; +//removing current melee weapon if new melee selected +_melee2tb = ""; +if ((_item in ["MeleeHatchet_DZE","MeleeCrowbar","MeleeMachete","MeleeFishingPole","MeleeSledge"]) || _item == DayZ_onBack) then { + if (!carryClick) then { + //free primary slot for new melee (remember item to add after) + switch (primaryWeapon player) do { + case "MeleeHatchet_DZE": { if (!("ItemHatchet_DZE" in weapons player)) then { player removeWeapon "MeleeHatchet_DZE"; _melee2tb = "ItemHatchet_DZE"; }; }; + case "MeleeCrowbar": { if (!("ItemCrowbar" in weapons player)) then { player removeWeapon "MeleeCrowbar"; _melee2tb = "ItemCrowbar"; }; }; + case "MeleeMachete": { if (!("ItemMachete" in weapons player)) then { player removeWeapon "MeleeMachete"; _melee2tb = "ItemMachete"; }; }; + case "MeleeFishingPole": {player removeWeapon "MeleeFishingPole"; _melee2tb = "ItemFishingPole";}; + case "MeleeSledge": {player removeWeapon "MeleeSledge"; _melee2tb = "ItemSledge";}; + }; + } else { + if (DayZ_onBack != "" || _item == DayZ_onBack) then { + switch DayZ_onBack do { + case "MeleeHatchet_DZE": { if (!("ItemHatchet_DZE" in weapons player)) then { dayz_onBack = ""; _melee2tb = "ItemHatchet_DZE"; }; }; + case "MeleeCrowbar": { if (!("ItemCrowbar" in weapons player)) then { dayz_onBack = ""; _melee2tb = "ItemCrowbar"; }; }; + case "MeleeMachete": { if (!("ItemMachete" in weapons player)) then { dayz_onBack = ""; _melee2tb = "ItemMachete"; }; }; + case "MeleeFishingPole": {dayz_onBack = ""; _melee2tb = "ItemFishingPole";}; + case "MeleeSledge": {dayz_onBack = ""; _melee2tb = "ItemSledge";}; + }; + carryClick = false; + ((findDisplay 106) displayCtrl 1209) ctrlSetText ""; + }; }; }; -if (_item in ["ItemHatchet_DZE","ItemCrowbar","ItemMachete","ItemFishingPole","ItemSledge"]) then { - switch (primaryWeapon player) do - { - case "MeleeHatchet_DZE": { "MeleeHatchet_DZE" call player_addToolbelt }; - case "MeleeCrowbar": { "MeleeCrowbar" call player_addToolbelt }; - case "MeleeMachete": { "MeleeMachete" call player_addToolbelt }; - case "MeleeFishingPole": { "MeleeFishingPole" call player_addToolbelt }; - case "MeleeSledge": { "MeleeSledge" call player_addToolbelt }; - }; -}; +//Remove melee magazines (BIS_fnc_invAdd fix) (add new melee ammo to array if needed) +{player removeMagazines _x} forEach ["Hatchet_Swing","sledge_swing","Crowbar_Swing","Machete_Swing","Fishing_Swing"]; _isOk = [player,_config2] call BIS_fnc_invAdd; - if (_isOk) then { - //Remove item player removeWeapon _item; - - if (vehicle player != player) then { - _display = findDisplay 106; - _display closeDisplay 0; - }; - - //Add magazines if needed - if (_create in ["MeleeHatchet_DZE","MeleeCrowbar","MeleeMachete","MeleeFishingPole","MeleeSledge"]) then { - if (_create == "MeleeCrowbar") then { - player addMagazine 'crowbar_swing'; + //adding old melee converted to Item on place of removed _item + if (_melee2tb != "") then { + //we know there is place to add item but to prevent BE spam using _config2 + _config2 = _melee2tb; + _isOk = [player,_config2] call BIS_fnc_invAdd; }; - if (_create == "MeleeSledge") then { - player addMagazine 'sledge_swing'; - }; - if (_create == "MeleeHatchet_DZE") then { - player addMagazine 'Hatchet_swing'; - }; - if (_create == "MeleeMachete") then { - player addMagazine 'Machete_swing'; - }; - if (_create == "MeleeFishingPole") then { - player addMagazine 'Fishing_Swing'; - }; - }; - } else { - cutText [localize "STR_DAYZ_CODE_2", "PLAIN DOWN"]; - - //Add magazines back - if (_item in ["MeleeHatchet_DZE","MeleeCrowbar","MeleeMachete","MeleeFishingPole","MeleeSledge"]) then { - if (_item == "MeleeCrowbar") then { - player addMagazine 'crowbar_swing'; - }; - if (_item == "MeleeSledge") then { - player addMagazine 'sledge_swing'; - }; - if (_item == "MeleeHatchet_DZE") then { - player addMagazine 'Hatchet_Swing'; - }; - if (_item == "MeleeMachete") then { - player addMagazine 'Machete_swing'; - }; - if (_item == "MeleeFishingPole") then { - player addMagazine 'Fishing_Swing'; - }; - }; + closeDialog 0; + cutText [localize "str_player_24", "PLAIN DOWN"]; }; DZE_ActionInProgress = false; diff --git a/SQF/dayz_code/actions/player_addtoBack.sqf b/SQF/dayz_code/actions/player_addtoBack.sqf index 3380d6e8a..6b2ac3fb4 100644 --- a/SQF/dayz_code/actions/player_addtoBack.sqf +++ b/SQF/dayz_code/actions/player_addtoBack.sqf @@ -14,13 +14,14 @@ if (dayZ_OnBack != "") exitWith {closeDialog 0; cutText [format [localize "str_p call gear_ui_init; -if (_item in ["ItemHatchet","ItemCrowbar","ItemMachete","ItemFishingPole"]) then { +if (_item in ["ItemHatchet_DZE","ItemCrowbar","ItemMachete","ItemFishingPole","ItemSledge"]) then { //free primary slot for new melee (remember item to add after) switch (_item) do { - case "ItemHatchet": {player removeWeapon "ItemHatchet"; dayz_onBack = "MeleeHatchet";}; + case "ItemHatchet_DZE": {player removeWeapon "ItemHatchet_DZE"; dayz_onBack = "MeleeHatchet_DZE";}; case "ItemCrowbar": {player removeWeapon "ItemCrowbar"; dayz_onBack = "MeleeCrowbar";}; case "ItemMachete": {player removeWeapon "ItemMachete"; dayz_onBack = "MeleeMachete";}; case "ItemFishingPole": {player removeWeapon "ItemFishingPole"; dayz_onBack = "MeleeFishingPole";}; + case "ItemSledge": {player removeWeapon "ItemSledge"; dayz_onBack = "MeleeSledge";}; }; disableSerialization; [[(findDisplay 106)],"onLBSelChanged"] execVM "\z\addons\dayz_code\system\handleGear.sqf"; //update back diff --git a/SQF/dayz_code/actions/player_build_vanilla.sqf b/SQF/dayz_code/actions/player_build_vanilla.sqf new file mode 100644 index 000000000..c07f18364 --- /dev/null +++ b/SQF/dayz_code/actions/player_build_vanilla.sqf @@ -0,0 +1,405 @@ +// (c) facoptere@gmail.com, licensed to DayZMod for the community +private ["_classType","_item","_action","_missingTools","_missingItem","_emergingLevel","_isClass","_classname","_requiredTools","_requiredParts ","_ghost","_placement","_text","_onLadder","_isWater","_object","_string","_actionBuildHidden","_getBeams","_o","_offset","_rot","_r","_p","_bn","_bb","_h","_bx","_by","_minElevation","_maxElevation","_insideCheck","_building","_unit","_bbb","_ubb","_check","_min","_max","_myX","_myY","_checkBuildingCollision","_objColliding","_inside","_checkOnRoad","_roadCollide","_checkBeam2Magnet","_a","_beams","_best","_b","_d","_checkNotBuried","_elevation","_position","_delta","_overElevation","_maxplanting","_safeDistance","_dir","_angleRef","_tmp","_actionCancel","_sfx","_actionBuild"]; + +/* +Needs a full rewrite to keep up with the demand of everything we plan to add. +*/ + +call gear_ui_init; +closeDialog 1; + +_item = _this select 0; +_action = _this select 1; +_classType = "ItemActions"; + +if (count _this > 2) then { + _classType = _this select 2; +}; + +_emergingLevel = 1.1; +r_action_count = 1; + +_isClass = switch (1==1) do { + case (isClass (configFile >> "CfgMagazines" >> _item)): {"CfgMagazines"}; + case (isClass (configFile >> "CfgWeapons" >> _item)): {"CfgWeapons"}; +}; + +//need to swap all build systems to this "ItemActions" +_classname = getText (configFile >> _isClass >> _item >> _classType >> _action >> "create"); +_requiredTools = getArray (configFile >> _isClass >> _item >> _classType >> _action >> "require"); +_requiredParts = getArray (configFile >> _isClass >> _item >> _classType >> _action >> "consume"); +_ghost = getText (configFile >> _isClass >> _item >> _classType >> _action >> "ghost"); +//need to move to array and separate what checks need to be done. +_byPassChecks = getText (configFile >> _isClass >> _item >> _classType >> _action >> "byPass"); + +if (_byPassChecks == "") then { _byPassChecks = "BaseItems" }; +if (_ghost == "") then { _ghost = _classname; }; + +_text = getText (configFile >> "CfgVehicles" >> _classname >> "displayName"); +_keepOnSlope = 0 == (getNumber (configFile >> "CfgVehicles" >> _classname >> "canbevertical")); + +_onLadder = {getNumber (configFile >> "CfgMovesMaleSdr" >> "States" >> (animationState player) >> "onLadder") == 1}; +_isWater = {(surfaceIsWater (getPosATL _object)) or dayz_isSwimming}; + +if (0 != count Dayz_constructionContext) then { + r_action_count = 0; + //cutText [localize "str_already_building", "PLAIN DOWN"]; + _msg = localize "str_already_building"; + _msg call dayz_rollingMessages; + diag_log [ diag_ticktime, __FILE__, 'already building, exiting', Dayz_constructionContext, typeName Dayz_constructionContext]; +}; + +// item is missin - this really is pointless but it aint broke so dont fix it +if (isClass (configFile >> _isClass >> _item)) then { + if ((!(_item IN magazines player))) exitWith { + _string = switch true do { + case (_item isKindOf "Land_A_tent"): {"str_player_31_pitch"}; + default {"str_player_31_build"}; + }; + //cutText [format [localize "str_player_31",_text,(localize _string)] , "PLAIN DOWN"]; + _msg = format [localize "str_player_31",_text,(localize _string)]; + _msg call dayz_rollingMessages; + //diag_log(format["player_build: item:%1 require:%2 Player items:%3 magazines:%4", _item, _requiredTools, (items player), (magazines player)]); + }; +}; + +// lets check player has requiredTools for upgrade +_ok = true; +_missing = ""; +{ + if (!(_x IN items player)) exitWith { + //systemchat("Missing tools for upgrade." +str()); + _missing = getText (configFile >> "CfgWeapons" >> _x >> "displayName"); + _ok = false; + }; +} count _requiredTools; + +if (!_ok) exitWith { + r_action_count = 0; + //cutText [format [localize "str_player_31_missingtools",_text,_missing] , "PLAIN DOWN"]; + _msg = format [localize "str_player_31_missingtools",_text,_missing]; + _msg call dayz_rollingMessages; +}; + +// lets check player has requiredParts for upgrade +_ok = true; +_upgradeParts = []; +{ + if (!(_x IN magazines player)) exitWith { + _missing = getText (configFile >> "CfgMagazines" >> _x >> "displayName"); + _ok = false; + }; + if (_x IN magazines player) then { + _upgradeParts set [count _upgradeParts, _x]; + player removeMagazine _x; + }; +} count _requiredParts; +if (!_ok) exitWith { + { player addMagazine _x; } foreach _upgradeParts; + r_action_count = 0; + // cutText [format [localize "str_player_31", _missing, localize "str_player_31_build"] , "PLAIN DOWN"]; + _msg = format [localize "str_player_31", _missing, localize "str_player_31_build"]; + _msg call dayz_rollingMessages; +}; + + +//cutText [localize "str_player_build_rotate", "PLAIN DOWN"]; +_msg = localize "str_player_build_rotate"; +_msg call dayz_rollingMessages; + +//Get fence beams based on model +_getBeams = { + private [ "_p", "_r", "_bn", "_bb", "_bx", "_by" ]; + + _o = _this select 0; + _offset = _this select 1; + _rot = _this select 2; + _r = []; + + for "_bn" from 1 to 4 do { + _p = _o selectionPosition Format [ "beam%1", _bn ]; + if (_p distance [0,0,0] == 0) exitWith { + if (_bn == 1) then { // no memory points defined + _bb = boundingBox _o; + _h = _offset + ((_o worldToModel (getPosATL _o)) select 2); + _p = [ (_bb select 0) select 0, 0, _h ]; + _r set [ 0, _o modelToWorld _p]; + _p = [ (_bb select 1) select 0, 0, _h ]; + _r set [ 1, _o modelToWorld _p]; + }; + }; + if (_rot != 0) then { + _bx = _p select 0; + _by = _p select 1; + _p set [0, (_bx * cos _rot) - (_by * sin _rot)]; + _p set [1, (_bx * sin _rot) + (_by * cos _rot)]; + }; + _p set [2, (_p select 2) + _offset]; + + _r set [ count _r, _o modelToWorld _p]; + }; + _r +}; + +_minElevation = { + private "_r"; + + _r = 400; + { _r = _r min (_x select 2); } count _this; + + _r +}; + +_maxElevation = { + private "_r"; + + _r = -400; + { _r = _r max (_x select 2); } count _this; + + _r +}; + +//Is the placed object inside another object +_insideCheck = { + private ["_bbb","_building","_ubb","_unit","_check","_min","_max","_myX","_p","_myY"]; + + _building = _this select 0; + _unit = _this select 1; + if ((typeOf _building != "") and {( + (sizeOf (typeOf _building) < 8) or {(_unit distance _building > (sizeOf (typeOf _building) + sizeOf (typeOf _unit))/2)} + )}) exitwith {false}; + + _bbb = boundingBox _building; + _ubb = boundingBox _unit; + + _check = { + _min = _bbb select 0; + _max = _bbb select 1; + _myX = _p select 0; + _myY = _p select 1; + + (((_myX > (_min select 0)) and {(_myX < (_max select 0))}) and {((_myY > (_min select 1)) and {(_myY < (_max select 1))})}) + }; + + _p = _building worldToModel (_unit modelToWorld [ (_ubb select 0) select 0, (_ubb select 0) select 1, 0]); + if (call _check) exitWith {true}; + _p = _building worldToModel (_unit modelToWorld [ (_ubb select 0) select 0, (_ubb select 1) select 1, 0]); + if (call _check) exitWith {true}; + _p = _building worldToModel (_unit modelToWorld [ (_ubb select 1) select 0, (_ubb select 1) select 1, 0]); + if (call _check) exitWith {true}; + _p = _building worldToModel (_unit modelToWorld [ (_ubb select 1) select 0, (_ubb select 0) select 1, 0]); + if (call _check) exitWith {true}; + + false +}; + +//check if building being placed and objects around placement is free to be built on. +//Fence owners must build all the foundations by one player anyone can still upgrade (pending lock build level) +_checkBuildingCollision = { + _objColliding = objNull; + { + _inside = false; + _ownerID = _x getVariable ["ownerArray",[]]; + + if (count _ownerID > 0) then { _ownerID = _ownerID select 0; } else { _ownerID = (getPlayerUID player); }; + + //and (!(_x isKindOf "DZ_buildables")) Not used + + if(_ownerID != (getPlayerUID player)) then { + if ((!isNull _x) and (!(_x == player)) and (!(_x == _object)) and (!(_x IN DayZ_SafeObjects)) + and (!((typeOf _x == "CamoNet_DZ") or {(_x isKindOf "Land_CamoNet_EAST")}))) then { + if ((_x isKindOf "Building") or (_x isKindOf "AllVehicles")) then { + _inside = [_x, _object] call _insideCheck; + + /* + if (!_inside) then { + _inside = [_object, _x] call _insideCheck; + }; + */ + }; + }; + }; + if (_inside) exitWith { _objColliding = _x; }; + } forEach (nearestObjects [_object, ["Building", "Air", "LandVehicle", "Ship", "DZ_buildables"], 35]); + (!isNull _objColliding) + // _objColliding contains the building that collides with the ghost object +}; + +//Is placement on a road? +_checkOnRoad = { + _roadCollide = false; + { + _x set [2,0]; + if (isOnRoad _x) exitWith { _roadCollide = true;}; + } forEach ([_object, 0,0] call _getBeams); + _roadCollide +}; + +//Make the object attach to beams if it can +_checkBeam2Magnet = { + _a = []; + { + if ((!isNull _x) and (_x != _object)) then { _a = _a + ([_x, 0,0] call _getBeams); }; + } forEach (nearestObjects [getPosATL _object, ["DZ_buildables"], 15]); + + _beams = [_object, 0,0] call _getBeams; + _best = [50,[0,0,0],[0,0,0]]; + { + _b = _x; + { + _d = [_x, _b] call BIS_fnc_distance2D; + if (_d < _best select 0) then { + _best = [_d,_b,_x]; + }; + } forEach _a; + } count _beams; + // _best contains the best beam to dock to. [ distance, coor of beam found around, coor of beam of ghost object ] +}; + +_checkNotBuried = { + // lift up the object so that any beams are buried, but also don't lift further the planting level (straight placement only) + _elevation = _position select 2; + _delta = 0; + _overElevation = 0; + _beams = [_object, 0,0] call _getBeams; + if (_elevation < 0) then { _delta = -_elevation; } + else { + _overElevation = _beams call _minElevation; + if (_overElevation>0.05) then { // bury the object so that posATL is still positif and all beams are above the ground + _delta = - (_overElevation min _elevation); + }; + if (_overElevation < -0.05) then { // lift up the object because a beam is burried + _delta = - _overElevation + 0.10; + }; + }; + _position set [ 2, _elevation + _delta ]; + _maxplanting = _beams call _maxElevation; + // _maxplanting is the height of the emerging foundations, must not be so high because we don't want some "floating" foundations +}; + +_object = _ghost createVehicleLocal getMarkerpos "respawn_west"; +_safeDistance = 0.5 + (sizeOf _ghost) * 0.5; // beware of hedgehogs +_dir = getDir player; +_object setDir _dir; +Dayz_constructionContext = [_object, round (_dir/5)*5, cameraView, false, true, _keepOnSlope]; + // ghost, angle, previous camera, build view on/off, continue on/off, slope on/off +_posReference = getPosATL player; +_objColliding = objNull; +_best = [50,[0,0,0],[0,0,0]]; +_maxplanting = 10; +_position = getPosATL _object; + +_actionBuildHidden = true; +_actionCancel = player addAction [localize "str_player_build_cancel", "\z\addons\dayz_code\actions\object_build.sqf", [_object, _requiredParts, _classname, _text, false, 0, "none"], 1, true, true, "", "0 != count Dayz_constructionContext"]; + +while {r_action_count != 0 and Dayz_constructionContext select 4} do { + + // force the angle so that the ghost is showing always the same side + _angleRef=Dayz_constructionContext select 1; + _dir = _angleRef - (getDir player); + if (_dir > 180) then {_dir = _dir - 360}; + if (_dir < -180) then {_dir = _dir + 360}; + if (_dir < -75) then { + _angleRef = ceil(((getDir player) - 75)/5)*5; + Dayz_constructionContext set [ 1, _angleRef]; + }; + if (_dir > 75) then { + _angleRef = floor(((getDir player) + 75)/5)*5; + Dayz_constructionContext set [ 1, _angleRef]; + }; + + // move object according to player position + if ((abs(([_object, player] call BIS_fnc_distance2D) - _safeDistance) > (if (_best select 0 < 0.50) then {0.50} else {0.05})) + or (abs([player, _object] call BIS_fnc_relativeDirTo) > (if (_best select 0 < 0.50) then {5} else {1})) or (r_interrupt)) then { + r_interrupt = false; + _object setDir _angleRef; + _tmp = player modelToWorld [0, _safeDistance,0]; + if (Dayz_constructionContext select 5 or _keepOnSlope) then { + _tmp set [2, 0]; + _object setVectorUp surfaceNormal _tmp; + } + else { + _tmp set [2, _position select 2]; + _object setVectorUp [0,0,1]; + }; + _position = +(_tmp); + _object setPosATL _position; + + // check now that ghost is not colliding + call _checkBuildingCollision; + }; + + // try to dock a beam from current ghost to another beams nearby + call _checkBeam2Magnet; + if (_best select 0 < 0.50) then { + _position = [ + (_position select 0) + ((_best select 2) select 0) - ((_best select 1) select 0), + (_position select 1) + ((_best select 2) select 1) - ((_best select 1) select 1), + _position select 2 + ]; + _object setPosATL _position; + }; + + if (Dayz_constructionContext select 5 or _keepOnSlope) then { + _maxplanting = 0; + _position set [2, 0]; + } + else { + // adjust the elevation of the object according to slope and beams to keep them visible (straight placement only) + call _checkNotBuried; + }; + _object setPosATL _position; + + if ((((vehicle player) != player or _posReference distance player > 20 or 0 != player getVariable["startcombattimer",0]) or {(!alive player)}) or {((call _onLadder) or {(call _isWater)})}) exitWith { + [[],[],[],[_object, _requiredParts , _classname, _text, false, 0, "none"]] call object_build; + }; + + if (_byPassChecks == "byPassRoadCheck") then { + if (isNull _objColliding and _maxplanting <= _emergingLevel) then { // placement is fine, enable "Build" in the menu + if (_actionBuildHidden) then { + _actionBuildHidden = false; + player removeAction _actionCancel; + _sfx = if (_object isKindOf "Land_A_tent") then {"tentunpack"} else {"repair"}; + _actionBuild = player addAction [localize "str_player_build_complete", "\z\addons\dayz_code\actions\object_build.sqf", [_object, _requiredParts , _classname, _text, true, 20, _sfx], 1, true, true, "", "0 != count Dayz_constructionContext"]; + _actionCancel = player addAction [localize "str_player_build_cancel", "\z\addons\dayz_code\actions\object_build.sqf", [_object, _requiredParts , _classname, _text, false, 0, "none"], 1, true, true, "", "0 != count Dayz_constructionContext"]; + }; + } else { + if (!_actionBuildHidden) then { + _actionBuildHidden = true; + player removeAction _actionBuild; + }; + }; + }; + + if (_byPassChecks == "BaseItems") then { + if (isNull _objColliding and _maxplanting <= _emergingLevel and !(call _checkOnRoad)) then { // placement is fine, enable "Build" in the menu + if (_actionBuildHidden) then { + _actionBuildHidden = false; + player removeAction _actionCancel; + _sfx = if (_object isKindOf "Land_A_tent") then {"tentunpack"} else {"repair"}; + _actionBuild = player addAction [localize "str_player_build_complete", "\z\addons\dayz_code\actions\object_build.sqf", [_object, _requiredParts , _classname, _text, true, 20, _sfx], 1, true, true, "", "0 != count Dayz_constructionContext"]; + _actionCancel = player addAction [localize "str_player_build_cancel", "\z\addons\dayz_code\actions\object_build.sqf", [_object, _requiredParts , _classname, _text, false, 0, "none"], 1, true, true, "", "0 != count Dayz_constructionContext"]; + }; + } else { + if (!_actionBuildHidden) then { + _actionBuildHidden = true; + player removeAction _actionBuild; + }; + }; + }; + sleep 0.03; +}; + +if (!_actionBuildHidden) then { // player can't build until all is fine + _actionBuildHidden = true; + player removeAction _actionBuild; +}; +player removeAction _actionCancel; + +if (Dayz_constructionContext select 3) then { // "build" camera was on, switch it off + call fn_buildCamera; +}; + +Dayz_constructionContext = []; +r_action_count = 0; +//systemChat "Dayz_constructionContext reset"; diff --git a/SQF/dayz_code/actions/player_craftItem_vanilla.sqf b/SQF/dayz_code/actions/player_craftItem_vanilla.sqf new file mode 100644 index 000000000..0b6c70e16 --- /dev/null +++ b/SQF/dayz_code/actions/player_craftItem_vanilla.sqf @@ -0,0 +1,185 @@ +/* + Created by r4z0r49 exclusively for DayZMod. + craft from rightclick options. + + text = "Wooden Plank"; + script = "spawn player_craftItem;"; + requiretools[] = {"ItemHatchet"}; + output[] = {{"ItemPlank","CfgMagazines",2}}; + input[] = {{"ItemLog","CfgMagazines",1}}; + failChance = 1; +*/ +//diag_log("crafting system"); +private["_config","_input","_output","_required","_failChance","_hasInput","_availabeSpace"]; + +//diag_log(str(isnil "r_player_crafting")); + +//Process has started +if( (animationState player) IN [ "ainvpknlmstpslaywrfldnon_medic" ]) exitwith {}; + + +//Config class of right click item +_classname = _this; +//diag_log (str(_classname)); + +//Check what class the item is. +_isClass = switch (1==1) do { + case (isClass (configFile >> "CfgMagazines" >> _classname)): {"CfgMagazines"}; + case (isClass (configFile >> "CfgWeapons" >> _classname)): {"CfgWeapons"}; +}; + +_config = (configFile >> _isClass >> _classname >> "ItemActions" >> "Crafting"); + +//Check for normal blocked systems +_onLadder = (getNumber (configFile >> "CfgMovesMaleSdr" >> "States" >> (animationState player) >> "onLadder")) == 1; + +if(!r_drag_sqf and !r_player_unconscious and !_onLadder) then { + + _input = getArray (_config >> "input"); + //diag_log (str(_input)); + _output = getArray (_config >> "output"); + //diag_log (str(_output)); + _required = getArray (_config >> "requiretools"); + //diag_log (str(_required)); + _failChance = getNumber (_config >> "failChance"); + //diag_log (str(_failChance)); + + // lets check player has requiredTools for upgrade + _hasTools = true; + { + if (_x == "ItemHatchet") then { + if (!("MeleeHatchet" in weapons player)) then { + if (!(DayZ_onBack == "MeleeHatchet")) then { + if (!(_x IN items player)) then { + systemChat format[localize "str_cannotCraft", _x]; + _hasTools = false; + }; + }; + }; + }; + } count _required; + + if (!_hasTools) exitwith {}; + + _hasInput = true; + { + private ["_avail"]; + _selection = _x select 1; + _item = _x select 0; + _amount = _x select 2; + + switch (_selection) do { + case "CfgWeapons": + { + _avail = {_x == _item} count weapons player; + }; + case "CfgMagazines": + { + _avail = {_x == _item} count magazines player; + }; + }; + + if (_avail < _amount) exitWith { + _hasInput = false; + _itemName = getText(configFile >> _selection >> _item >> "displayName"); + cutText [format [localize "str_crafting_missing",(_amount - _avail),_itemName], "PLAIN DOWN"]; + }; + } forEach (_input); + + if (_hasInput) then { + _freeSlots = [player] call BIS_fnc_invSlotsEmpty; + { + _item = _x select 0; + _amount = _x select 2; + _slotType = [_item] call BIS_fnc_invSlotType; + for "_i" from 1 to _amount do { + for "_j" from 1 to (count _slotType) do { + if ((_slotType select _j) > 0) then { + _freeSlots set[_j, ((_freeSlots select _j) + (_slotType select _j))]; + }; + }; + }; + } forEach _input; + + _availabeSpace = true; + { + _item = _x select 0; + _amount = _x select 2; + _slotType = [_item] call BIS_fnc_invSlotType; + for "_i" from 1 to _amount do { + for "_j" from 1 to (count _slotType) do { + if ((_slotType select _j) > 0) then { + _freeSlots set[_j, ((_freeSlots select _j) - (_slotType select _j))]; + if (_freeSlots select _j < 0) exitWith { + _availabeSpace = false; + cutText [localize "str_crafting_space", "PLAIN DOWN"]; + }; + }; + }; + }; + } forEach _output; + //sleep 1; + + if (_availabeSpace) then { + //player playActionNow "PutDown"; + call gear_ui_init; + closeDialog 1; + player playActionNow "Medic"; + sleep 2; + //setup alert and speak + _dis=20; + _sfx = "chopwood"; + [player,_sfx,0,false,_dis] call dayz_zombieSpeak; + [player,_dis,true,(getPosATL player)] call player_alertZombies; + + { + _item = _x select 0; + _amount = _x select 2; + for "_i" from 1 to _amount do { + _selection = _x select 1; + switch (_selection) do { + case "CfgWeapons": + { + player removeWeapon _item; + }; + case "CfgMagazines": + { + player removeMagazine _item; + }; + }; + //sleep 0.1; + }; + } forEach _input; + sleep 3; + { + _item = _x select 0; + _selection = _x select 1; + _amount = _x select 2; + _itemName = getText(configFile >> _selection >> _item >> "displayName"); + for "_i" from 1 to _amount do { + if (random 1 > _failChance) then { + switch (_selection) do { + case "CfgWeapons": + { + player addWeapon _item; + }; + case "CfgMagazines": + { + player addMagazine _item; + }; + case "CfgVehicles": + { + player addBackpack _item; + }; + }; + cutText [format [localize "str_crafting_success",_itemName], "PLAIN DOWN"]; + //sleep 2; + } else { + cutText [format [localize "str_crafting_failed",_itemName], "PLAIN DOWN"]; + //sleep 2; + }; + }; + } forEach _output; + }; + }; +}; \ No newline at end of file diff --git a/SQF/dayz_code/actions/player_drinkWater.sqf b/SQF/dayz_code/actions/player_drinkWater.sqf index 66db66618..5eec54b9e 100644 --- a/SQF/dayz_code/actions/player_drinkWater.sqf +++ b/SQF/dayz_code/actions/player_drinkWater.sqf @@ -53,10 +53,10 @@ if (!_canFill) then { }; if (_canFill) then { - _chance = 0.1; + _chance = 0.05; if (_itemorignal in boil_tin_cans) then { - _chance = 0.06; + _chance = 0.03; ["FoodDrink",0,[0,0,300,0]] call dayz_NutritionSystem; //[Energy,food,water,temp] } else { _chance = 0.03; diff --git a/SQF/dayz_code/actions/player_dropWeapon.sqf b/SQF/dayz_code/actions/player_dropWeapon.sqf index 0fc4b827f..1ed11175f 100644 --- a/SQF/dayz_code/actions/player_dropWeapon.sqf +++ b/SQF/dayz_code/actions/player_dropWeapon.sqf @@ -17,6 +17,8 @@ if ((dayz_onBack != "") && (dayz_onBack in MeleeWeapons) && carryClick) then { case "MeleeHatchet": {_item = "ItemHatchet"; dayz_onBack = "";}; case "MeleeCrowbar": {_item = "ItemCrowbar"; dayz_onBack = "";}; case "MeleeMachete": {_item = "ItemMachete"; dayz_onBack = "";}; + case "MeleeSledge": {_item = "ItemSledge"; dayz_onBack = "";}; + case "MeleeFishingPole": {_item = "ItemFishingPole"; dayz_onBack = "";}; }; carryClick = false; ((findDisplay 106) displayCtrl 1209) ctrlSetText ""; diff --git a/SQF/dayz_code/actions/player_flipvehicle.sqf b/SQF/dayz_code/actions/player_flipvehicle.sqf index 0191965aa..79f566e67 100644 --- a/SQF/dayz_code/actions/player_flipvehicle.sqf +++ b/SQF/dayz_code/actions/player_flipvehicle.sqf @@ -14,8 +14,9 @@ waitUntil { animationState player != "amovpknlmstpslowwrfldnon_amovpercmstpsrasw uiSleep 2; //_object setpos _position; _object setvectorup [0,0,1]; -[player,"scream",0,true] call dayz_zombieSpeak; +//[player,"scream",0,true] call dayz_zombieSpeak; [player,20,true,(getPosATL player)] spawn player_alertZombies; +["Working",0,[20,40,15,0]] call dayz_NutritionSystem; uiSleep 3; diff --git a/SQF/dayz_code/actions/player_goFishing_vanilla.sqf b/SQF/dayz_code/actions/player_goFishing_vanilla.sqf new file mode 100644 index 000000000..d3cab952f --- /dev/null +++ b/SQF/dayz_code/actions/player_goFishing_vanilla.sqf @@ -0,0 +1,160 @@ +/* + DayZ Fishing + Usage: spawn player_goFishing; + Made for DayZ Mod please ask permission to use/edit/distrubute email vbawol@veteranbastards.com. + fixed by facoptere@gmail.com for dayzmod +*/ +private ["_linecastmax","_linecastmin","_num","_position","_ispond","_objectsPond","_isPondNearBy","_isOk","_counter", +"_vehicle","_inVehicle","_rnd","_itemOut","_text","_item","_itemtodrop","_result", "_elevation"]; + +//if (!isNil "faco_goFishing") exitWith { _this call faco_goFishing }; + +_vehicle = _this select 3; +_vehicle removeAction (_this select 2); +s_player_fishing = -1; +s_player_fishing_veh = -1; + +if(dayz_fishingInprogress) exitWith { cutText [localize "str_fishing_inprogress", "PLAIN DOWN"];}; +dayz_fishingInprogress = true; + +//line distance +_linecastmax = 67; + +_isOk = false; +_inBoat = (player != vehicle player) and {((vehicle player) isKindOf "Ship")}; +for "_i" from 1 to 10 do { + _num = floor(random (2 * _linecastmax / 3) + _linecastmax / 3); + _position = if (_inBoat) then { (vehicle player) modeltoworld [-_num, 0 ,0] } else { player modeltoworld [0,_num,0] }; + _elevation = _position select 2; + /* + _position set [ 2, 1 ]; + _position = ASLToATL _position; + if (_position select 2 < 1) then { _position set [2, 1];}; + if (isNil "tutu") then { + tutu = "Sign_sphere100cm_EP1" createVehicleLocal _position; + } + else { + tutu setPosATL _position; + }; + */ + _ispond = if (_elevation < 0.5 or surfaceIsWater _position) then { false } else { // riverbed must be at 0.5 m depth at least + private [ "_ret","_bb","_w2m" ]; + _position set [ 2, _elevation - 0.5 ]; + _ret = false; + { + { + _w2m = _x worldToModel _position; + _bb = (boundingbox _x) select 1; + _linecastmax = _linecastmax min ((_bb select 0) min (_bb select 1)); + //_dir = [player, _x] call BIS_fnc_relativeDirTo; if (_dir > 180) then {_dir = _dir - 360}; + if ((("" == typeOf _x) and ((_w2m select 2) < 0.5)) and {((abs(_w2m select 0) < (_bb select 0)) and (abs(_w2m select 1) < (_bb select 1)))}) exitWith { // ponds + _ret = true; + }; + } count (nearestObjects [_x, [], 2]); // find ponds + if (_ret) exitWith {}; + } foreach nearestObjects [_position, ["waterHoleProxy"], 45]; // find waterholeproxy close to pond centers + _ret + }; +// diag_log [ _position, _elevation, surfaceIsWater _position, _linecastmax, _ispond, "=>", ((surfaceIsWater _position or _ispond) and ((player == vehicle player) or {((vehicle player) isKindOf "Ship")})) ]; + if ((surfaceIsWater _position or _ispond) and ((player == vehicle player) or {((vehicle player) isKindOf "Ship")})) exitWith { + _isOk = true; + }; +}; + +if (!_isOk) exitWith { + dayz_fishingInprogress = false; + cutText [localize "str_fishing_watercheck" , "PLAIN DOWN"]; +}; + +_counter = 0; + +// swing fishingpole +player playActionNow "GestureSwing"; + +// Alert zeds +[player,3,true,(getPosATL player)] call player_alertZombies; + +r_interrupt = false; + +while {_isOk} do { + if(dayz_isSwimming) exitWith {cutText [localize "str_player_26", "PLAIN DOWN"];_isOk = false;}; + if !((currentWeapon player) in Dayz_fishingItems or (player != vehicle player and !((vehicle player) isKindOf "Ship"))) exitwith { + cutText [localize "str_fishing_canceled", "PLAIN DOWN"]; + _isOk = false; + }; + if (r_interrupt) then { + _isOk = false; + cutText [localize "str_fishing_canceled", "PLAIN DOWN"]; + } else { + //make sure the player isnt swimming + + // wait for animation + sleep 2; + + // check if player is in boat + _vehicle = vehicle player; + if ((_vehicle != player) and (_vehicle isKindOf "Ship")) then { + _inVehicle = true; + _rnd = 75; + } else { + _inVehicle = false; + _rnd = 100; + }; + //Check for rain fish are more active during the rain. + if (rain > 0) then {_rnd = _rnd / 2;}; + + // 1% chance to catch anything + if((random _rnd) <= 5) then { + // Just the one fish for now + _itemOut = []; + _itemOut = switch (true) do { + case ((_num > 30) and (_num <= 45)) : { ["FishRawTrout","FishRawTrout","FishRawTrout","FishRawTrout","FishRawTrout","FishRawTrout","FishRawTrout"]; }; + case ((_num > 45) and (_num <= 60)) : { ["FishRawTrout","FishRawTrout","FishRawTrout","FishRawTrout","FishRawTrout","FishRawSeaBass","FishRawSeaBass"]; }; + case ((_num > 60)) : { ["FishRawTrout","FishRawTrout","FishRawTrout","FishRawTrout","FishRawSeaBass","FishRawSeaBass","FishRawTuna"]; }; + default { ["FishRawTrout"]; }; + }; + _itemOut = _itemOut call BIS_fnc_selectRandom; + _text = getText (configFile >> "CfgMagazines" >> _itemOut >> "displayName"); + if(_inVehicle) then { + _item = _vehicle; + _itemtodrop = _itemOut; + _item addMagazineCargoGlobal [_itemtodrop,1]; + //Let the player know what he caught + cutText [format [localize "str_fishing_success",_text], "PLAIN DOWN"]; + } else { + call gear_ui_init; + //Remove melee magazines (BIS_fnc_invAdd fix) + {player removeMagazines _x} forEach MeleeMagazines; + _result = [player,_itemOut] call BIS_fnc_invAdd; + if (_result) then { + //Let the player know what he caught + cutText [format [localize "str_fishing_success",_text], "PLAIN DOWN"]; + } else { + cutText [format [localize "str_fishing_noroom",_text], "PLAIN DOWN"]; + }; + //adding melee mags back if needed + call dayz_meleeMagazineCheck; + }; + + //"Working",0,[cal,thirst,hunger] + ["Working",0,[3,2,8,0]] call dayz_NutritionSystem; + _isOk = false; + } else { + + switch (true) do { + case (_counter == 0) : { cutText [format [localize "str_fishing_cast",_num], "PLAIN DOWN"]; }; + case (_counter == 4) : { cutText [localize "str_fishing_pull", "PLAIN DOWN"]; player playActionNow "GesturePoint"; }; + case (_counter == 8) : { cutText [localize "str_fishing_pull", "PLAIN DOWN"]; player playActionNow "GesturePoint"; }; + default { cutText [localize "str_fishing_nibble", "PLAIN DOWN"]; }; + }; + _counter = _counter + 1; + + if(_counter == 12) then { + _isOk = false; + sleep 1; + cutText [localize "str_fishing_failed", "PLAIN DOWN"]; + }; + }; + }; +}; +dayz_fishingInprogress = false; diff --git a/SQF/dayz_code/actions/player_makefire.sqf b/SQF/dayz_code/actions/player_makefire.sqf index ee7863e19..05e31897b 100644 --- a/SQF/dayz_code/actions/player_makefire.sqf +++ b/SQF/dayz_code/actions/player_makefire.sqf @@ -1,30 +1,71 @@ -private ["_location","_isOk","_dir","_classname","_fire","_hasWood"]; -_location = player modeltoworld [0,0.3,0]; -if ((_location select 2) < 0) then { - _location set [2,0]; -}; -//_location set [2,0]; -_isOk = true; //count (_location isFlatEmpty [0.3,0,0,4,0,false,player]) > 0; -_hasWood = "PartWoodPile" in magazines player; +private ["_item","_config","_text","_booleans","_worldspace","_dir","_location","_dis","_fire"]; -if (_hasWood) then { - if (_isOk) then { - player removeMagazine "PartWoodPile"; - _dir = getDir player; - _classname = "Land_Fire_DZ"; - [1,1] call dayz_HungerThirst; - player playActionNow "Medic"; - uiSleep 6; - _fire = createVehicle [_classname, _location, [], 0, "CAN_COLLIDE"]; - _fire setDir _dir; - player reveal _fire; - - _fire spawn player_fireMonitor; - - cutText [localize "str_fireplace_01", "PLAIN DOWN"]; +_tool = _this; +call gear_ui_init; +closeDialog 0; + +_item = "ItemLog"; +_itemPile = "PartWoodPile"; + +_config = configFile >> "CfgMagazines" >> _item; +_text = getText (_config >> "displayName"); + +// item is missing or tools are missing +if ((!(_item IN magazines player)) && (!(_itemPile in magazines player))) exitWith { + //cutText [localize "str_player_22", "PLAIN DOWN"]; + (localize "str_player_22") call dayz_rollingMessages; +}; + +_booleans = []; //testonLadder, testSea, testPond, testBuilding, testSlope, testDistance +_worldspace = ["Land_Fire_DZ", player, _booleans] call fn_niceSpot; + +// player on ladder or in a vehicle +if (_booleans select 0) exitWith { cutText [localize "str_player_21", "PLAIN DOWN"]; }; + +// object would be in the water (pool or sea) +if ((_booleans select 1) OR (_booleans select 2)) exitWith { cutText [localize "str_player_26", "PLAIN DOWN"]; }; + +if ((count _worldspace) == 2) then { + if (_item in magazines player) then { + player removeMagazine _item; } else { - cutText [localize "str_fireplace_02", "PLAIN DOWN"]; + player removeMagazine _itemPile; }; + _dir = _worldspace select 0; + _location = _worldspace select 1; + + player playActionNow "Medic"; + sleep 1; + // fireplace location may not be in front of player (but in 99% time it should) + player setDir _dir; + player setPosATL (getPosATL player); + + _dis=20; + [player,_dis,true,(getPosATL player)] call player_alertZombies; + + // Added Nutrition-Factor for work + ["Working",0,[20,40,15,0]] call dayz_NutritionSystem; + + sleep 5; + + _fire = createVehicle ["Land_Fire_DZ", getMarkerpos "respawn_west", [], 0, "CAN_COLLIDE"]; + _fire setDir _dir; + _fire setPos _location; // follow terrain slope + player reveal _fire; + + [_fire,true] call dayz_inflame; + _fire spawn player_fireMonitor; + + + if (dayz_playerAchievements select 14 < 1) then { + // Firestarter + dayz_playerAchievements set [14,1]; + achievement = [14, player, dayz_characterID]; + publicVariableServer "achievement"; + }; + //cutText [localize "str_fireplace_01", "PLAIN DOWN"]; + (localize "str_fireplace_01") call dayz_rollingMessages; } else { - cutText [localize "str_player_22", "PLAIN DOWN"]; + //cutText [localize "str_fireplace_02", "PLAIN DOWN"]; + (localize "str_fireplace_0") call dayz_rollingMessages; }; \ No newline at end of file diff --git a/SQF/dayz_code/actions/player_setTrap.sqf b/SQF/dayz_code/actions/player_setTrap.sqf index 5e67dc31c..fa1133d58 100644 --- a/SQF/dayz_code/actions/player_setTrap.sqf +++ b/SQF/dayz_code/actions/player_setTrap.sqf @@ -1,29 +1,39 @@ -private ["_item","_onLadder","_classname","_text","_hastrapitem","_location","_object","_dir"]; -_item = _this; -// _config = configFile >> "CfgWeapons" >> _item; +private["_item","_config","_onLadder","_classname","_text","_consume","_hastrapitem","_location","_object"]; -_onLadder = (getNumber (configFile >> "CfgMovesMaleSdr" >> "States" >> (animationState player) >> "onLadder")) == 1; -if (_onLadder) exitWith {cutText [(localize "str_player_21") , "PLAIN DOWN"]}; +_item = _this; +_config = configFile >> "CfgWeapons" >> _item; + +if (r_action_count != 1) exitWith { cutText [localize "str_player_actionslimit", "PLAIN DOWN"]; }; + +_onLadder = (getNumber (configFile >> "CfgMovesMaleSdr" >> "States" >> (animationState player) >> "onLadder")) == 1; +if (_onLadder) exitWith { r_action_count = 0; cutText [localize "str_player_21", "PLAIN DOWN"]}; call gear_ui_init; -_classname = getText (configFile >> "CfgMagazines" >> _item >> "ItemActions" >> "Build" >> "create"); -_text = getText (configFile >> "CfgVehicles" >> _classname >> "displayName"); -//_consume = ([] + getArray (_config >> "magazines")) select 0; +_classname = getText (configFile >> "CfgMagazines" >> _item >> "ItemActions" >> "Build" >> "create"); +_text = getText (configFile >> "CfgVehicles" >> _classname >> "displayName"); +_consume = ([] + getArray (_config >> "magazines")) select 0; -_hastrapitem = _this in magazines player; +_hastrapitem = _item in magazines player; -if (!_hastrapitem) exitWith {cutText [format[(localize "str_player_31"),_text,"place"] , "PLAIN DOWN"]}; +if (!_hastrapitem) exitWith { r_action_count = 0; cutText [format [localize "str_player_31",_text,localize "str_player_31_place"] , "PLAIN DOWN"]}; player removeMagazine _item; _location = getPosATL player; player playActionNow "PutDown"; -uiSleep 1; +sleep 1; _object = createVehicle [_classname, _location, [], 0, "CAN_COLLIDE"]; -_dir = getDir player; -_object setDir _dir; +_object setDir (getDir player); + +_object setVariable ["armed", false, true]; + +PVDZ_obj_Publish = [dayz_characterID,_object,[getDir _object, getPosATL _object],[["armed", _object getVariable "armed"]]]; +publicVariableServer "PVDZ_obj_Publish"; +diag_log [diag_ticktime, __FILE__, "New Networked object, request to save to hive. PVDZ_obj_Publish:", PVDZ_obj_Publish]; + player reveal _object; -cutText [format[localize "str_build_01",_text], "PLAIN DOWN"]; \ No newline at end of file +r_action_count = 0; +cutText [format [localize "str_build_01",_text], "PLAIN DOWN"]; \ No newline at end of file diff --git a/SQF/dayz_code/actions/player_sleep.sqf b/SQF/dayz_code/actions/player_sleep.sqf index 4be170bfc..fbd84e731 100644 --- a/SQF/dayz_code/actions/player_sleep.sqf +++ b/SQF/dayz_code/actions/player_sleep.sqf @@ -1,50 +1,110 @@ +private ["_playArray","_lastRest","_blood"]; +//_timesincedrink = time - dayz_lastDrink; +//_bloodinc =100; Removed for now(untested) due to it not needed yet + //http://community.bistudio.com/wiki/ArmA2:_Moves -player playMove "amovpsitmstpsraswrfldnon_smoking"; // - Sitting smoking +_sleepArray = ["aidlppnemstpsnonwnondnon_sleepc_laydown","aidlppnemstpsnonwnondnon_sleepc_lookaround","aidlppnemstpsnonwnondnon_sleepc_scratch","aidlppnemstpsnonwnondnon_sleepc_sleep","aidlppnemstpsnonwnondnon_sleepc_sleep0"]; -waitUntil { animationState player != "amovpsitmstpsraswrfldnon_smoking"}; +//not in a vehicle +//_playArray = _sleepArray call BIS_fnc_selectRandom; +player playmove "AidlPpneMstpSnonWnonDnon_SleepC_sleep"; + +r_interrupt = false; +_animState = animationState player; +r_doLoop = true; +_started = false; +_finished = false; +_timer = diag_tickTime; +_i = 0; +_r = 0; +_blood = 0; +_cureAttempt = 0; +_lastRest = player getVariable ["lastRest", 0]; -uiSleep 5; +while {r_doLoop} do { + _isAsleep = (animationState player) in _sleepArray; -player playMove "amovpsitmstpsraswrfldnon_weaponcheck1"; // - Sitting checking weapon + if (_isAsleep and !_started) then { + + _started = true; + }; -waitUntil { animationState player != "amovpsitmstpsraswrfldnon_weaponcheck1"}; + if (_started) then { + if (!r_player_unconscious) then { + + if (r_player_infected) then { + //every 30 seconds run Random Chance to cure infection + if (diag_ticktime - _lastRest > 30) then { + //Save the amount so if the player interrupts + player setVariable ["lastRest", diag_ticktime]; + //Update the local value. + _lastRest = diag_ticktime; + + //10% chance of cure to infection every 60 seconds of sleeping + _cureChance = 0.10 + _cureAttempt; + if ([_cureChance] call fn_chance) then { + r_player_infected = false; + player setVariable["USEC_infected",false,false]; + + PVDZ_serverStoreVar = [player,"USEC_infected",false]; + publicVariableServer "PVDZ_serverStoreVar"; + } else { + _infectedStatus = if (r_player_infected) then { "Infected" } else { "Cured" }; + _cureAttempt = _cureAttempt + 0.01; + cutText [format [localize "str_sleepInfection",r_player_blood,_infectedStatus], "PLAIN DOWN"]; + }; + }; + }; + + //make sure player isnt infected or inpain. + if (!r_player_injured AND !r_player_infected AND !(r_player_Sepsis select 0)) then { + //Give 53 + random amount of blood every 16 secs if player isn't injured. + if ((diag_tickTime - _timer) >= 16) then { + if (r_player_blood < 12000) then { + //Make the random amount of blood you can gain equal to the percentage of blood you have. + _randomamount = round(random (r_player_blood/12000*100)); + _blood = 53 + _randomamount; //Max Possible 153. + }; + + //Lets make sure we do go over the max amount + if ((r_player_blood - 12000) < _blood) then { + r_player_bloodregen = r_player_bloodregen + _blood; + } else { + r_player_blood = 12000; + }; + + _timer = diag_tickTime; + _infectedStatus = if (r_player_infected) then { "Yes" } else { "Cured" }; + cutText [format [localize "str_sleepStats",_blood,r_player_blood], "PLAIN DOWN"]; + }; + + }; + + if (!_isAsleep) then { + //_playArray = _sleepArray call BIS_fnc_selectRandom; + player switchMove "AidlPpneMstpSnonWnonDnon_SleepC_sleep"; + }; + }; -uiSleep 5; + if (r_interrupt ) then { + r_doLoop = false; + }; + sleep 0.1; + }; +}; -player playMove "AidlPpneMstpSnonWnonDnon_SleepC_layDown"; +r_doLoop = false; -waitUntil { animationState player != "AidlPpneMstpSnonWnonDnon_SleepC_layDown"}; - -uiSleep 5; - -player playMove "AidlPpneMstpSnonWnonDnon_SleepC_lookAround"; - -waitUntil { animationState player != "AidlPpneMstpSnonWnonDnon_SleepC_lookAround"}; - -uiSleep 5; - -player playMove "AidlPpneMstpSnonWnonDnon_SleepC_scratch"; - -waitUntil { animationState player != "AidlPpneMstpSnonWnonDnon_SleepC_scratch"}; - -uiSleep 5; - -player playMove "AidlPpneMstpSnonWnonDnon_SleepC_sleep"; - -waitUntil { animationState player != "AidlPpneMstpSnonWnonDnon_SleepC_sleep"}; - -uiSleep 5; - -player playMove "AidlPpneMstpSnonWnonDnon_SleepC_sleep0"; - -waitUntil { animationState player != "AidlPpneMstpSnonWnonDnon_SleepC_sleep0"}; - -uiSleep 5; - -player playMove "AidlPpneMstpSnonWnonDnon_SleepC_standUp"; - -waitUntil { animationState player != "AidlPpneMstpSnonWnonDnon_SleepC_standUp"}; +if (r_interrupt) then { + systemChat(localize ("str_endSleepStandUp")); + r_interrupt = false; + player playmoveNow ""; + player playActionNow "stop"; +}; +//Removed due to player sync returning [] +//PVDZ_plr_Save = [player,nil,true,dayz_playerAchievements]; +//publicVariableServer "PVDZ_plr_Save"; R3F_TIRED_Accumulator = 0; diff --git a/SQF/dayz_code/actions/player_switchWeapon.sqf b/SQF/dayz_code/actions/player_switchWeapon.sqf index 16f1cdd48..066969df8 100644 --- a/SQF/dayz_code/actions/player_switchWeapon.sqf +++ b/SQF/dayz_code/actions/player_switchWeapon.sqf @@ -1,214 +1,281 @@ -private ["_event", "_onLadder", "_inVehicle", "_isOk", "_primary", "_current", "_rifle", "_pistol", "_melee"]; -_event = if (count _this > 1) then { _this select 3 } else { _this select 0 }; +#include "\z\addons\dayz_code\util\mutex.hpp" +#include "\z\addons\dayz_code\util\player.hpp" -_findRifle = { - private ["_return", "_primary"]; - _return = ""; - _primary = primaryWeapon player; +#define BANDAID - if (_primary != "") then { - if !(_primary in MeleeWeapons) then { - _return = _primary; - }; - }; +#define TIMEOUT 2 - if (dayz_onBack != "" && _return == "") then { - if !(dayz_onBack in MeleeWeapons) then { - _return = dayz_onBack; - }; - }; +#define IS_PRIMARY(wpn) (getNumber (configFile >> "CfgWeapons" >> wpn >> "type") == 1) +#define MELEE(wpn) getNumber (configFile >> "CfgWeapons" >> wpn >> "melee") +#define IS_MELEE(wpn) (MELEE(wpn) == 1) - _return; -}; +//0 if not found, 1 if in primary slot, 2 if on back +#define FIND_RIFLE() (0 call dz_fn_switchWeapon_find) +#define FIND_MELEE() (1 call dz_fn_switchWeapon_find) -_findMelee = { - private ["_return", "_primary"]; - _return = ""; +dz_switchWeapon_mutex = Mutex_New(); - _primary = primaryWeapon player; - - if (_primary != "") then { - if (_primary in MeleeWeapons) then { - _return = _primary; - }; - }; - - if (dayz_onBack != "" && _return == "") then { - if (dayz_onBack in MeleeWeapons) then { - _return = dayz_onBack; - }; - }; - - _return; -}; - -_findPistol = { - private ["_return"]; - _return = ""; - - { - if (getNumber (configFile >> "CfgWeapons" >> _x >> "type") == 2) then { - _return = _x; - }; - } foreach (weapons player); - - _return; -}; - -_selectMuzzle = { - private ["_return", "_wpn", "_muzzles"]; - _wpn = _this select 0; - _muzzles = getArray(configFile >> "cfgWeapons" >> _wpn >> "muzzles"); - - if (_muzzles select 0 != "this") then { - _return = (_muzzles select 0); - } else { - _return = _wpn; - }; - - _return; -}; - -_clearActions = { - if (s_player_equip_carry > -1) then { - player removeAction s_player_equip_carry; - s_player_equip_carry = -1; - }; -}; - -_switchPrimary = { - private ["_primary", "_current"]; - _primary = primaryWeapon player; +//0: switch rifle/melee instantly and update gear +//1: switch rifle/melee with animation +//2: switch to rifle +//3: switch to pistol +//4: switch to melee +dz_fn_switchWeapon = +{ + if (vehicle player != player) exitWith {}; + if Player_IsOnLadder() exitWith {}; + + private ["_current", "_primary", "_secondary"]; + _current = currentWeapon player; - _timer = 0; - - [] call _clearActions; - if (_primary != "") then { - // check if player is still in the 'open gear' animation state and force him out of it (caused major issues) - _animState = animationState player; - - switch (true) do { - // current weapon is a rifle - case (_animState == "amovpknlmstpsraswrfldnon_gear" || _animState == "amovpercmstpsraswrfldnon_gear"): { - player playMove "amovpknlmstpslowwrfldnon_amovpknlmstpsraswrfldnon"; - waitUntil { animationState player == "amovpknlmstpslowwrfldnon_amovpknlmstpsraswrfldnon" }; + + switch _this do + { + //Instantly switch primary and carry, also update gear + case 0: + { + if (IS_PRIMARY(_current)) then + { true call dz_fn_switchWeapon_swap; } + else + { false call dz_fn_switchWeapon_swap; }; + + /*call _swapWeapons; + if (IS_PRIMARY(_current)) then + { player selectWeapon primaryWeapon player; };*/ + + [[(findDisplay 106)],"onLBSelChanged"] execVM "\z\addons\dayz_code\system\handleGear.sqf"; + }; + + //Switch primary and carry + case 1: + { + if (dayz_quickSwitch) then + { + true call dz_fn_switchWeapon_swap; + #ifdef BANDAID + call dayz_meleeMagazineCheck; + #endif + } + else + { call dz_fn_switchWeapon_swapSecure; }; + }; + + //Switch to rifle + case 2: + { + //No current weapon + if (_current == "") exitWith + { + switch FIND_RIFLE() do + { + //In primary + case 1: + { + player selectWeapon primaryWeapon player; + }; + + //On back + case 2: + { + true call dz_fn_switchWeapon_swap; + }; + }; }; - // current weapon is a pistol - case (_animState == "amovpknlmstpsraswpstdnon_gear" || _animState == "amovpercmstpsraswpstdnon_gear"): { - player playMove "amovpknlmstpslowwpstdnon_gear_amovpknlmstpsraswpstdnon"; - waitUntil { animationState player == "amovpknlmstpslowwpstdnon_gear_amovpknlmstpsraswpstdnon" }; + + //Current weapon is primary + if (IS_PRIMARY(_current)) exitWith + { + //if current is melee and on back is rifle + if (IS_MELEE(_current) && { !IS_MELEE(dayz_onBack) }) then + { + if (dayz_quickSwitch) then + { true call dz_fn_switchWeapon_swap; } + else + { call dz_fn_switchWeapon_swapSecure; }; + }; }; - // is standing with weapon lowered - case (["aidlpercmstpslowwrfldnon", _animState] call fnc_inString): { - player playMove "amovpercmstpslowwrfldnon_amovpercmstpsraswrfldnon"; - waitUntil { animationState player == "amovpercmstpslowwrfldnon_amovpercmstpsraswrfldnon" }; + + //Current is pistol + switch FIND_RIFLE() do + { + //In primary + case 1: + { + player selectWeapon primaryWeapon player; + }; + + //On back + case 2: + { + if (diag_tickTime - dz_switchWeapon_pistolTime < 1) exitWith {}; + true call dz_fn_switchWeapon_swap; + }; }; }; - - player removeWeapon _primary; - - // make sure animation is playing to prevent instant switch (if current weapon is not pisol) - if (!dayz_quickSwitch) then { - if (_current != [] call _findPistol) then { - _timeout = diag_tickTime + 2; - _animArray = [ - "amovpercmstpsraswrfldnon_amovpercmstpsnonwnondnon", // is standing, has no pistol / is crouched, has no pistol - "amovpercmstpsraswrfldnon_amovpercmstpsraswpstdnon", // is standing, has pistol - "amovpknlmstpsraswrfldnon_amovpknlmstpsraswpstdnon", // is crouched, has pistol - "amovppnemstpsraswrfldnon_amovppnemstpsnonwnondnon", // is prone, has no pistol - "amovppnemstpsraswrfldnon_amovppnemstpsraswpstdnon" // is prone, has pistol - ]; - - waitUntil { (animationState player) in _animArray || diag_tickTime >= _timeout }; - waitUntil { !((animationState player) in _animArray) || diag_tickTime >= _timeout }; + + //Switch to pistol + case 3: + { + //If current weapon is primary + if (IS_PRIMARY(_current)) then + { + _secondary = Player_GetSidearm(); + if (!isNil "_secondary") then + { + player selectWeapon _secondary; + dz_switchWeapon_pistolTime = diag_tickTime; + }; }; }; + + //Switch to melee + case 4: + { + //No current weapon + if (_current == "") exitWith + { + switch FIND_MELEE() do + { + //In primary + case 1: + { + player selectWeapon primaryWeapon player; + }; + + //On back + case 2: + { + true call dz_fn_switchWeapon_swap; + #ifdef BANDAID + call dayz_meleeMagazineCheck; + #endif + }; + }; + }; + + //Current weapon is primary + if (IS_PRIMARY(_current)) exitWith + { + //if current is rifle and on back is melee + if (!IS_MELEE(_current) && { IS_MELEE(dayz_onBack) }) then + { + if (dayz_quickSwitch) then + { + true call dz_fn_switchWeapon_swap; + #ifdef BANDAID + call dayz_meleeMagazineCheck; + #endif + } + else + { call dz_fn_switchWeapon_swapSecure; }; + }; + }; + + //Current is pistol + //Find melee weapon + switch FIND_MELEE() do + { + //In primary + case 1: + { + player selectWeapon primaryWeapon player; + }; + + //On back + case 2: + { + if (diag_tickTime - dz_switchWeapon_pistolTime < 1) exitWith {}; + true call dz_fn_switchWeapon_swap; + }; + }; + }; + }; +}; + +//See FIND_RIFLE() and FIND_MELEE() +dz_fn_switchWeapon_find = +{ + _primary = primaryWeapon player; + + if (_primary != "" && { _this == MELEE(_primary) }) + exitWith { 1 }; + + if (dayz_onBack != "" && { _this == MELEE(dayz_onBack) }) + exitWith { 2 }; + + 0 +}; + +//Swaps rifle / melee instantly without animation +dz_fn_switchWeapon_swap = +{ + if (dayz_onBack == "") then + { + //Must be in a single statement to ensure atomicity in the scheduled environment. + dayz_onBack = + [ + primaryWeapon player, + player removeWeapon primaryWeapon player + ] select 0; + } + else + { + dayz_onBack = + [ + primaryWeapon player, + player removeWeapon primaryWeapon player, + player addWeapon dayz_onBack + ] select 0; }; - if (dayz_onBack != "") then { - player addWeapon dayz_onBack; - player selectWeapon ([dayz_onBack] call _selectMuzzle); - }; - - dayz_onBack = _primary; - - call dayz_meleeMagazineCheck; + if (_this) then + { player selectWeapon primaryWeapon player; }; }; -_switchPrimaryUI = { - private ["_primary", "_current"]; - _primary = primaryWeapon player; - _current = currentWeapon player; - - [] call _clearActions; - - if (_primary != "") then { - player removeWeapon _primary; - }; - - if (dayz_onBack != "") then { - player addWeapon dayz_onBack; - - if (_primary == _current) then { - player selectWeapon ([dayz_onBack] call _selectMuzzle); - }; - }; - - dayz_onBack = _primary; - - [[(findDisplay 106)],"onLBSelChanged"] execVM "\z\addons\dayz_code\system\handleGear.sqf"; // update gear dialog +//Swaps rifle / melee forcing an animation +dz_fn_switchWeapon_swapSecure = +{ + if (!Mutex_TryLock_Fast(dz_switchWeapon_mutex)) exitWith {}; + + //animation states are in the form "AmovPerc...", "AmovPknl...", "AmovPpne..." + dz_switchWeapon_anim = format + [ + "AmovP%1MstpSrasWrflDnon_AmovP%1MstpSrasWpstDnon", + //Switch on the 6th letter of the animation class + switch ((toArray animationState player) select 5) do + { + case 101: { "erc" }; //e for erc for erected + case 107: { "knl" }; //k for knl for kneeling + case 112: { "pne" }; //p for pne for prone + } + ]; + + //Add AnimDone event handler to wait until current weapon is put away + dz_switchWeapon_handler = player addEventHandler ["AnimDone", dz_fn_switchWeapon_animDone]; + player playMoveNow dz_switchWeapon_anim; + dz_switchWeapon_time = diag_tickTime; }; -_onLadder = (getNumber (configFile >> "CfgMovesMaleSdr" >> "States" >> (animationState player) >> "onLadder")) == 1; -_inVehicle = (vehicle player != player); -_isOK = (!_onLadder && !_inVehicle && !r_player_unconscious && !dayz_onBackActive); - -if (_isOK) then { dayz_onBackActive = true }; - -switch (_event) do { - case "action": { - if (_isOK) then { - [] call _switchPrimary; - }; +dz_fn_switchWeapon_animDone = +{ + //Wait at most TIMEOUT seconds + if (dz_switchWeapon_time - diag_tickTime > TIMEOUT) exitWith + { + player removeEventHandler ["AnimDone", dz_switchWeapon_handler]; + Mutex_Unlock(dz_switchWeapon_mutex); }; - case "gear": { - [] call _switchPrimaryUI; - }; - case "rifle": { - if (_isOK) then { - _rifle = [] call _findRifle; - - if (_rifle != "") then { - if (_rifle == dayz_onBack) then { - [] call _switchPrimary; - } else { - player selectWeapon ([_rifle] call _selectMuzzle); - }; - }; - }; - }; - case "pistol": { - if (_isOK) then { - _pistol = [] call _findPistol; - - if (_pistol != "") then { - player selectWeapon ([_pistol] call _selectMuzzle); - }; - }; - }; - case "melee": { - if (_isOK) then { - _melee = [] call _findMelee; - - if (_melee != "") then { - if (_melee == dayz_onBack) then { - [] call _switchPrimary; - } else { - player selectWeapon ([_melee] call _selectMuzzle); - }; - }; - }; - }; -}; - -if (_isOK) then { dayz_onBackActive = false }; + + //Check if finished animation is the correct one + if ((_this select 1) != dz_switchWeapon_anim) exitWith {}; + + true call dz_fn_switchWeapon_swap; + + //Remove eventhandler + player removeEventHandler ["AnimDone", dz_switchWeapon_handler]; + Mutex_Unlock(dz_switchWeapon_mutex); + + #ifdef BANDAID + if (IS_MELEE(primaryWeapon player)) then + { call dayz_meleeMagazineCheck; }; + #endif +}; \ No newline at end of file diff --git a/SQF/dayz_code/actions/player_useMeds.sqf b/SQF/dayz_code/actions/player_useMeds.sqf index ae6aed930..9ef0a5625 100644 --- a/SQF/dayz_code/actions/player_useMeds.sqf +++ b/SQF/dayz_code/actions/player_useMeds.sqf @@ -1,34 +1,102 @@ -private ["_item","_id","_onLadder","_hasmeditem","_config","_text"]; +private["_item","_onLadder","_hasmeditem","_config","_text","_id"]; + _item = _this; call gear_ui_init; -_onLadder = (getNumber (configFile >> "CfgMovesMaleSdr" >> "States" >> (animationState player) >> "onLadder")) == 1; -if (_onLadder) exitWith {cutText [(localize "str_player_21") , "PLAIN DOWN"]}; +closeDialog 0; +_onLadder = (getNumber (configFile >> "CfgMovesMaleSdr" >> "States" >> (animationState player) >> "onLadder")) == 1; +if (_onLadder) exitWith {cutText [localize "str_player_21", "PLAIN DOWN"]}; -_hasmeditem = _this in magazines player; +_hasmeditem = _item in magazines player; _config = configFile >> "CfgMagazines" >> _item; _text = getText (_config >> "displayName"); -if (!_hasmeditem) exitWith {cutText [format[(localize "str_player_31"),_text,"use"] , "PLAIN DOWN"]}; +if (!_hasmeditem) exitWith {cutText [format [localize "str_player_31",_text,localize "str_player_31_use"] , "PLAIN DOWN"]}; + switch (_item) do { case "ItemBandage": { - _id = [0,0,0,[player]] execVM "\z\addons\dayz_code\medical\bandage.sqf"; + _id = [0,0,0,[player,"ItemBandage"]] execVM "\z\addons\dayz_code\medical\bandage.sqf"; }; case "ItemMorphine": { _id = [0,0,0,[player]] execVM "\z\addons\dayz_code\medical\morphine.sqf"; }; + case "equip_woodensplint": { + _id = [0,0,0,[player,"equip_woodensplint"]] execVM "\z\addons\dayz_code\medical\brokeBones.sqf"; + }; case "ItemPainkiller": { _id = [0,0,0,[player]] execVM "\z\addons\dayz_code\medical\painkiller.sqf"; }; + //Antibiotic's system case "ItemAntibiotic": { - _id = [0,0,0,[player]] execVM "\z\addons\dayz_code\medical\antibiotics.sqf"; + _id = [player,"ItemAntibiotic"] execVM "\z\addons\dayz_code\medical\antibiotics.sqf"; }; - case "ItemBloodbag": { - _id = [0,0,0,[player]] execVM "\z\addons\dayz_code\medical\self_transfusion.sqf"; + case "ItemAntibiotic1": { + _id = [player,"ItemAntibiotic1"] execVM "\z\addons\dayz_code\medical\antibiotics.sqf"; + }; + case "ItemAntibiotic2": { + _id = [player,"ItemAntibiotic2"] execVM "\z\addons\dayz_code\medical\antibiotics.sqf"; + }; + case "ItemAntibiotic3": { + _id = [player,"ItemAntibiotic3"] execVM "\z\addons\dayz_code\medical\antibiotics.sqf"; + }; + case "ItemAntibiotic4": { + _id = [player,"ItemAntibiotic4"] execVM "\z\addons\dayz_code\medical\antibiotics.sqf"; + }; + case "ItemAntibiotic5": { + _id = [player,"ItemAntibiotic5"] execVM "\z\addons\dayz_code\medical\antibiotics.sqf"; + }; + case "ItemAntibiotic6": { + _id = [player,"ItemAntibiotic6"] execVM "\z\addons\dayz_code\medical\antibiotics.sqf"; + }; + case "ItemAntibacterialWipe": { + _id = [0,0,0,[player]] execVM "\z\addons\dayz_code\medical\wipes.sqf"; }; case "ItemHeatPack": { player removeMagazine "ItemHeatPack"; dayz_temperatur = (dayz_temperatur + 5) min dayz_temperaturmax; cutText [localize "str_player_27", "PLAIN DOWN"]; }; + case "bloodTester": { + _id = [0,0,0,[player]] execVM "\z\addons\dayz_code\medical\blood_test.sqf"; + }; + case "transfusionKit": { + _id = [0,0,0,[player]] execVM "\z\addons\dayz_code\medical\fillBloodBag.sqf"; + }; + case "emptyBloodBag": { + _id = [0,0,0,[player]] execVM "\z\addons\dayz_code\medical\fillBloodBag.sqf"; + }; + case "ItemSepsisBandage": { + _id = [0,0,0,[player,"ItemSepsisBandage"]] execVM "\z\addons\dayz_code\medical\bandage.sqf"; + }; + case "wholeBloodBagANEG": { + _id = [player,"wholeBloodBagANEG"] execVM "\z\addons\dayz_code\medical\selfbloodbag.sqf"; + }; + case "wholeBloodBagAPOS": { + _id = [player,"wholeBloodBagAPOS"] execVM "\z\addons\dayz_code\medical\selfbloodbag.sqf"; + }; + case "wholeBloodBagBNEG": { + _id = [player,"wholeBloodBagBNEG"] execVM "\z\addons\dayz_code\medical\selfbloodbag.sqf"; + }; + case "wholeBloodBagBPOS": { + _id = [player,"wholeBloodBagBPOS"] execVM "\z\addons\dayz_code\medical\selfbloodbag.sqf"; + }; + case "wholeBloodBagABNEG": { + _id = [player,"wholeBloodBagABNEG"] execVM "\z\addons\dayz_code\medical\selfbloodbag.sqf"; + }; + case "wholeBloodBagABPOS": { + _id = [player,"wholeBloodBagABPOS"] execVM "\z\addons\dayz_code\medical\selfbloodbag.sqf"; + }; + case "wholeBloodBagONEG": { + _id = [player,"wholeBloodBagONEG"] execVM "\z\addons\dayz_code\medical\selfbloodbag.sqf"; + }; + case "wholeBloodBagOPOS": { + _id = [player,"wholeBloodBagOPOS"] execVM "\z\addons\dayz_code\medical\selfbloodbag.sqf"; + }; + case "ItemBloodbag": { + _id = [0,0,0,[player]] execVM "\z\addons\dayz_code\medical\self_transfusion.sqf"; + }; +}; +if (vehicle player != player) then { + _display = findDisplay 106; + _display closeDisplay 0; }; \ No newline at end of file diff --git a/SQF/dayz_code/actions/refuel.sqf b/SQF/dayz_code/actions/refuel.sqf index a08bf29a0..6598ec8f3 100644 --- a/SQF/dayz_code/actions/refuel.sqf +++ b/SQF/dayz_code/actions/refuel.sqf @@ -1,151 +1,84 @@ -private ["_vehicle","_curFuel","_newFuel","_started","_finished","_animState","_isMedic","_location1","_location2","_abort","_canName","_canSize","_configCan","_configVeh","_capacity","_nameText","_availableCans","_canText"]; +private["_vehicle","_canSize","_configVeh","_capacity","_nameType","_curFuel","_newFuel","_dis","_sfx","_fueling"]; if(DZE_ActionInProgress) exitWith { cutText [(localize "str_epoch_player_24") , "PLAIN DOWN"] }; DZE_ActionInProgress = true; -// Use target from addaction -_vehicle = _this select 0; +_vehicle = cursorTarget; +_array = _this select 3; +_cantype = _array select 0; +_canSize = getNumber(configFile >> "cfgMagazines" >> _cantype >> "fuelQuantity"); +_emptycan = getText(configFile >> "cfgMagazines" >> _cantype >> "emptycan"); +_configVeh = configFile >> "cfgVehicles" >> TypeOf(_vehicle); +_capacity = getNumber(_configVeh >> "fuelCapacity"); +_nameType = getText(_configVeh >> "displayName"); +_curFuel = ((fuel _vehicle) * _capacity); +_newFuel = (_curFuel + _canSize); +_fueling = player getVariable ["fueling",false]; +_isMan = _vehicle isKindOf "Man"; +_isAnimal = _vehicle isKindOf "Animal"; +_isZombie = _vehicle isKindOf "zZombie_base"; -_abort = false; +if (_isMan or _isAnimal or _isZombie) exitWith {DZE_ActionInProgress = false; cutText [localize "str_refuel_notvehicle", "PLAIN DOWN"] }; +if (fuel _vehicle == 1) exitwith {DZE_ActionInProgress = false;}; -// Static vehicle fuel information -_configVeh = configFile >> "cfgVehicles" >> TypeOf(_vehicle); -_capacity = getNumber(_configVeh >> "fuelCapacity"); -_nameText = getText(_configVeh >> "displayName"); +player removeAction s_player_fillfuel + _capacity; -// _availableCansEmpty = ["ItemJerrycanEmpty","ItemFuelBarrelEmpty"]; -_availableCans = ["ItemJerrycan","ItemFuelBarrel"]; +a_player_jerryfilling = true; +player setVariable ["fueling", true]; -// Loop to find containers that can could hold fuel && fill them -{ - _configCan = configFile >> "CfgMagazines" >> _x; +if (!_fueling) then { + [player] allowGetIn false; - if(_x in _availableCans) then { - - // Get full can size - _canName = _x; - _canSize = getNumber(_configCan >> "fuelQuantity"); - _canText = getText(_configCan >> "displayName"); - - _curFuel = ((fuel _vehicle) * _capacity); - _newFuel = (_curFuel + _canSize); + if (_newFuel > _capacity) then {_newFuel = _capacity}; + _newFuel = (_newFuel / _capacity); - if (_newFuel <= _capacity) then { + player removeMagazine _cantype; + player addMagazine _emptycan; + player playActionNow "Medic"; - // calculate new fuel - _newFuel = (_newFuel / _capacity); + _dis=5; + _sfx = "refuel"; + [player,_sfx,0,false,_dis] call dayz_zombieSpeak; + [player,_dis,true,(getPosATL player)] call player_alertZombies; - //diag_log ("refuel check: " + str(_newFuel) + " / " + str(_capacity)); + // Added Nutrition-Factor for work + ["Working",0,[20,40,15,0]] call dayz_NutritionSystem; - cutText [format[(localize "str_epoch_player_160"),_canText], "PLAIN DOWN"]; - - // alert zombies - [player,20,true,(getPosATL player)] spawn player_alertZombies; - - _finished = false; - - if(!dayz_isSwimming) then { - - [1,1] call dayz_HungerThirst; - // force animation - player playActionNow "Medic"; - - r_interrupt = false; - _animState = animationState player; - r_doLoop = true; - _started = false; - - while {r_doLoop} do { - _animState = animationState player; - _isMedic = ["medic",_animState] call fnc_inString; - if (_isMedic) then { - _started = true; - }; - if (_started && !_isMedic) then { - r_doLoop = false; - _finished = true; - }; - if (r_interrupt) then { - r_doLoop = false; - }; - if (vehicle player != player) then { - r_doLoop = false; - }; - uiSleep 0.1; - }; - r_doLoop = false; - - if(!_finished) then { - r_interrupt = false; - if (vehicle player == player) then { - [objNull, player, rSwitchMove,""] call RE; - player playActionNow "stop"; - }; - }; - - } else { - // Alternate method in water make sure player stays in one spot for 6 seconds - _location1 = getPosATL player; - uiSleep 6; - _location2 = getPosATL player; - if(_location1 distance _location2 < 3) then { - _finished = true; - }; - }; - - if (_finished) then { - - // Get vehicle fuel levels again - _curFuel = ((fuel _vehicle) * _capacity); - _newFuel = (_curFuel + _canSize); - - if (_newFuel <= _capacity) then { - - // calculate minimum needed fuel - _newFuel = (_newFuel / _capacity); - - if(([player,_canName] call BIS_fnc_invRemove) == 1) then { - - /* PVS/PVC - Skaronator */ - if (local _vehicle) then { - [_vehicle,_newFuel] call local_setFuel; - } else { - PVDZE_send = [_vehicle,"SFuel",[_vehicle,_newFuel]]; - publicVariableServer "PVDZE_send"; - }; - - // Play sound - [player,"refuel",0,false] call dayz_zombieSpeak; - player addMagazine _canName+"Empty"; - cutText [format[localize "str_player_05",_nameText,_canSize], "PLAIN DOWN"]; - - call fnc_usec_medic_removeActions; - r_action = false; - - uiSleep 1; - } else { - _abort = true; - }; - - } else { - cutText [format[(localize "str_epoch_player_161"),_nameText], "PLAIN DOWN"]; - _abort = true; - }; - - } else { - cutText [(localize "str_epoch_player_87") , "PLAIN DOWN"]; - _abort = true; - }; - - } else { - cutText [format[(localize "str_epoch_player_161"),_nameText], "PLAIN DOWN"]; - _abort = true; - }; + r_doLoop = true; + _started = false; + _finished = false; + while {r_doLoop} do { + _animState = animationState player; + _isRefuel = ["medic",_animState] call fnc_inString; + if (_isRefuel or dayz_isSwimming) then { + _started = true; + }; + if (_started and !_isRefuel) then { + r_doLoop = false; + _finished = true; + }; + uisleep 0.1; }; - - // exit if abort flag was set - if(_abort) exitWith {}; + r_doLoop = false; -} count magazines player; + if (_finished) then { + if (local _vehicle) then { + [_vehicle,_newFuel] call local_setFuel; + } else { + PVDZE_send = [_vehicle,"SFuel",[_vehicle,_newFuel]]; + publicVariableServer "PVDZE_send"; + }; -DZE_ActionInProgress = false; \ No newline at end of file + cutText [format [localize "str_player_05",_nameType,_canSize], "PLAIN DOWN"]; + uisleep 1; + + call fnc_usec_medic_removeActions; + }; + [player] allowGetIn true; +} else { + cutText [localize "str_refuel_fail","PLAIN DOWN"]; +}; +a_player_jerryfilling = false; +r_action = false; +player setVariable ["fueling", false]; +DZE_ActionInProgress = false; diff --git a/SQF/dayz_code/actions/repair.sqf b/SQF/dayz_code/actions/repair.sqf index ebfbb9220..659b57a3d 100644 --- a/SQF/dayz_code/actions/repair.sqf +++ b/SQF/dayz_code/actions/repair.sqf @@ -1,128 +1,58 @@ -private ["_vehicle","_part","_hitpoint","_type","_selection","_array","_started","_finished","_animState","_isMedic","_num_removed","_damage","_dis","_sfx","_allFixed","_id","_hasToolbox","_section","_nameType","_namePart","_hitpoints"]; - +private["_id","_array","_vehicle","_part","_hitpoint","_type","_hasToolbox","_section","_nameType","_namePart","_damage","_selection","_dis","_sfx","_hitpoints","_allFixed"]; if(DZE_ActionInProgress) exitWith { cutText [(localize "str_epoch_player_92") , "PLAIN DOWN"]; }; DZE_ActionInProgress = true; _id = _this select 2; -_array = _this select 3; -_vehicle = _array select 0; -_part = _array select 1; +_array = _this select 3; +_vehicle = _array select 0; +_part = _array select 1; _hitpoint = _array select 2; -_type = typeOf _vehicle; - -// -_hasToolbox = "ItemToolbox" in items player; -_section = _part in magazines player; - -// moving this here because we need to know which part needed if we don't have it -_nameType = getText(configFile >> "cfgVehicles" >> _type >> "displayName"); -_namePart = getText(configFile >> "cfgMagazines" >> _part >> "displayName"); - -s_player_repair_crtl = 1; - -if (_section && _hasToolbox) then { - - [1,1] call dayz_HungerThirst; - player playActionNow "Medic"; - - _dis=20; - _sfx = "repair"; - [player,_sfx,0,false,_dis] call dayz_zombieSpeak; - [player,_dis,true,(getPosATL player)] spawn player_alertZombies; - - r_interrupt = false; - _animState = animationState player; - r_doLoop = true; - _started = false; - _finished = false; - - while {r_doLoop} do { - _animState = animationState player; - _isMedic = ["medic",_animState] call fnc_inString; - if (_isMedic) then { - _started = true; - }; - if (_started && !_isMedic) then { - r_doLoop = false; - _finished = true; - }; - if (r_interrupt) then { - r_doLoop = false; - }; - uiSleep 0.1; - }; - r_doLoop = false; +_type = typeOf _vehicle; - if (_finished) then { - - _damage = [_vehicle,_hitpoint] call object_getHit; - _vehicle removeAction _id; - - //dont waste loot on undamaged parts - if (_damage > 0) then { - - // ensure part was removed - _num_removed = ([player,_part] call BIS_fnc_invRemove); - - if(_num_removed == 1) then { - - //Fix the part - _selection = getText(configFile >> "cfgVehicles" >> _type >> "HitPoints" >> _hitpoint >> "name"); - - //vehicle is owned by whoever is in it, so we have to have each client try && fix it - PVDZE_veh_SFix = [_vehicle,_selection,0]; - publicVariable "PVDZE_veh_SFix"; - if (local _vehicle) then { - PVDZE_veh_SFix call object_setFixServer; - }; - - _vehicle setvelocity [0,0,1]; - - //Success! - cutText [format[(localize "str_epoch_player_166"),_namePart,_nameType], "PLAIN DOWN"]; - - }; - - }; - - } else { - r_interrupt = false; - if (vehicle player == player) then { - [objNull, player, rSwitchMove,""] call RE; - player playActionNow "stop"; - }; - cutText [(localize "str_epoch_player_93"), "PLAIN DOWN"]; - }; - -} else { - cutText [format[(localize "str_epoch_player_167"),_namePart], "PLAIN DOWN"]; -}; - -{dayz_myCursorTarget removeAction _x} count s_player_repairActions;s_player_repairActions = []; +{dayz_myCursorTarget removeAction _x} forEach s_player_repairActions;s_player_repairActions = []; dayz_myCursorTarget = objNull; -//check if repaired fully -_hitpoints = _vehicle call vehicle_getHitpoints; -_allFixed = true; -{ - _damage = [_vehicle,_x] call object_getHit; - if (_damage > 0) exitWith { - _allFixed = false; - }; -} count _hitpoints; +//diag_log(format["%1 %2", __FILE__, _this]); -//update if repaired -if (_allFixed) then { - _vehicle setDamage 0; - //["PVDZE_veh_Update",[_vehicle,"repair"]] call callRpcProcedure; - PVDZE_veh_SFix = [_vehicle,_selection,0]; - publicVariable "PVDZE_veh_SFix"; - if (local _vehicle) then { - PVDZE_veh_SFix call object_setFixServer; +_hasToolbox = "ItemToolbox" in items player; +_section = _part in magazines player; + +//moving this here because we need to know which part needed if we don't have it +_nameType = getText(configFile >> "cfgVehicles" >> _type >> "displayName"); +_namePart = getText(configFile >> "cfgMagazines" >> _part >> "displayName"); + +if (_section and _hasToolbox) then { + player removeMagazine _part; + player playActionNow "Medic"; + uisleep 1; + + _dis=20; + _sfx = "repair"; + [player,_sfx,0,false,_dis] call dayz_zombieSpeak; + [player,_dis,true,(getPosATL player)] call player_alertZombies; + + // Added Nutrition-Factor for work + ["Working",0,[20,40,15,0]] call dayz_NutritionSystem; + + uisleep 5; + + _damage = [_vehicle,_hitpoint] call object_getHit; + _vehicle removeAction _id; + //dont waste loot on undamaged parts + if (_damage > 0) then { + //Fix the part + _selection = getText(configFile >> "cfgVehicles" >> _type >> "HitPoints" >> _hitpoint >> "name"); + + [_vehicle, _selection, 0, true] call fnc_veh_handleRepair; + _vehicle setvelocity [0,0,1]; + + //Success! + cutText [format [localize "str_player_04",_namePart,_nameType], "PLAIN DOWN"]; + } else { + player addMagazine _part; }; +} else { + cutText [format [localize "str_player_03",_namePart], "PLAIN DOWN"]; }; - -s_player_repair_crtl = -1; - DZE_ActionInProgress = false; \ No newline at end of file diff --git a/SQF/dayz_code/actions/repair_vehicle.sqf b/SQF/dayz_code/actions/repair_vehicle.sqf index 2bbd5501c..1120187f0 100644 --- a/SQF/dayz_code/actions/repair_vehicle.sqf +++ b/SQF/dayz_code/actions/repair_vehicle.sqf @@ -1,67 +1,43 @@ -private ["_part","_cancel","_color","_allFixed","_percent","_string","_handle","_damage","_cmpt","_vehicle","_hitpoints"]; +private ["_part","_cancel","_color","_string","_handle","_damage","_cmpt","_vehicle","_hitpoints","_damagePercent","_configVeh"]; _vehicle = _this select 3; +{dayz_myCursorTarget removeAction _x} forEach s_player_repairActions;s_player_repairActions = []; +dayz_myCursorTarget = _vehicle; -{dayz_myCursorTarget removeAction _x} count s_player_repairActions;s_player_repairActions = []; -// dayz_myCursorTarget = _vehicle; - -_allFixed = true; _hitpoints = _vehicle call vehicle_getHitpoints; -{ +{ _damage = [_vehicle,_x] call object_getHit; - _part = "PartGeneric"; - //change "HitPart" to " - Part" rather than complicated string replace _cmpt = toArray (_x); _cmpt set [0,20]; _cmpt set [1,toArray ("-") select 0]; _cmpt set [2,20]; _cmpt = toString _cmpt; - - if(["Engine",_x,false] call fnc_inString) then { - _part = "PartEngine"; - }; - - if(["HRotor",_x,false] call fnc_inString) then { - _part = "PartVRotor"; //yes you need PartVRotor to fix HRotor LOL - }; - if(["Fuel",_x,false] call fnc_inString) then { - _part = "PartFueltank"; - }; - - if(["Wheel",_x,false] call fnc_inString) then { - _part = "PartWheel"; - }; - - if(["Glass",_x,false] call fnc_inString) then { - _part = "PartGlass"; - }; + _configVeh = configFile >> "cfgVehicles" >> "RepairParts" >> _x; + _part = getText(_configVeh >> "part"); + if (isnil ("_part")) then { _part = "PartGeneric"; }; // get every damaged part no matter how tiny damage is! + _damagePercent = str(round(_damage * 100))+"% Damage"; if (_damage > 0) then { - - _allFixed = false; - _color = "color='#ffff00'"; //yellow - if (_damage >= 0.5) then {_color = "color='#ff8800'";}; //orange - if (_damage >= 0.9) then {_color = "color='#ff0000'";}; //red + if ((_damage >= 0) and (_damage <= 0.25)) then {_color = "color='#00ff00'";}; //green + if ((_damage >= 0.26) and (_damage <= 0.50)) then {_color = "color='#ffff00'";}; //yellow + if ((_damage >= 0.51) and (_damage <= 0.75)) then {_color = "color='#ff8800'";}; //orange + if ((_damage >= 0.76) and (_damage <= 1)) then {_color = "color='#ff0000'";}; //red + _cmpt = format[localize "str_actions_medical_09",_cmpt,_damagePercent]; - _percent = round(_damage*100); - _string = format["Repair%1 (%3 %4)",_cmpt,_color,_percent,"%"]; //Repair - Part + _string = format["%2",_color,_cmpt]; //Repair - Part _handle = dayz_myCursorTarget addAction [_string, "\z\addons\dayz_code\actions\repair.sqf",[_vehicle,_part,_x], 0, false, true, "",""]; s_player_repairActions set [count s_player_repairActions,_handle]; }; -} count _hitpoints; -if (_allFixed) then { - _vehicle setDamage 0; -}; +} forEach _hitpoints; if(count _hitpoints > 0 ) then { - - _cancel = dayz_myCursorTarget addAction [localize "STR_EPOCH_PLAYER_CANCEL", "\z\addons\dayz_code\actions\repair_cancel.sqf","repair", 0, true, false, "",""]; + //ArmA OA String + _cancel = dayz_myCursorTarget addAction [localize "str_action_cancel_action", "\z\addons\dayz_code\actions\repair_cancel.sqf","repair", 0, true, false, "",""]; s_player_repairActions set [count s_player_repairActions,_cancel]; - s_player_repair_crtl = 1; -}; +}; \ No newline at end of file diff --git a/SQF/dayz_code/actions/salvage.sqf b/SQF/dayz_code/actions/salvage.sqf index c5f233456..382f5e7ff 100644 --- a/SQF/dayz_code/actions/salvage.sqf +++ b/SQF/dayz_code/actions/salvage.sqf @@ -1,9 +1,8 @@ private ["_vehicle","_part","_hitpoint","_type","_selection","_array","_started","_finished","_animState","_isMedic","_isOK","_brokenPart","_findPercent","_damage","_hasToolbox","_nameType","_namePart"]; -if(DZE_ActionInProgress) exitWith { cutText [(localize "str_epoch_player_94") , "PLAIN DOWN"]; }; -DZE_ActionInProgress = true; +if (dayz_salvageInProgress) exitWith {cutText [localize "str_salvage_inprogress", "PLAIN DOWN"]; }; +dayz_salvageInProgress = true; -//_id = _this select 2; _array = _this select 3; _vehicle = _array select 0; _part = _array select 1; @@ -12,110 +11,102 @@ _type = typeOf _vehicle; _isOK = false; _brokenPart = false; +_started = false; +_finished = false; -// -_hasToolbox = "ItemToolbox" in items player; +_hasToolbox = "ItemToolbox" in items player; -// moving this here because we need to know which part needed if we don't have it -_nameType = getText(configFile >> "cfgVehicles" >> _type >> "displayName"); -_namePart = getText(configFile >> "cfgMagazines" >> _part >> "displayName"); +_nameType = getText(configFile >> "cfgVehicles" >> _type >> "displayName"); +_namePart = getText(configFile >> "cfgMagazines" >> _part >> "displayName"); -{_vehicle removeAction _x} count s_player_repairActions;s_player_repairActions = []; +{_vehicle removeAction _x} forEach s_player_repairActions; + s_player_repairActions = []; s_player_repair_crtl = 1; if (_hasToolbox) then { - [1,1] call dayz_HungerThirst; player playActionNow "Medic"; [player,"repair",0,false] call dayz_zombieSpeak; - [player,50,true,(getPosATL player)] spawn player_alertZombies; + [player,50,true,(getPosATL player)] call player_alertZombies; + + // Added Nutrition-Factor for work + ["Working",0,[20,40,15,0]] call dayz_NutritionSystem; r_interrupt = false; _animState = animationState player; r_doLoop = true; - _started = false; - _finished = false; while {r_doLoop} do { _animState = animationState player; _isMedic = ["medic",_animState] call fnc_inString; - if (_isMedic) then { - _started = true; - }; - if (_started && !_isMedic) then { - r_doLoop = false; - _finished = true; - }; - if (r_interrupt) then { - r_doLoop = false; - }; - uiSleep 0.1; + if (_isMedic) then { _started = true; }; + if (_started and !_isMedic) then { r_doLoop = false; _finished = true; }; + if (r_interrupt) then { r_doLoop = false; }; + sleep 0.1; }; r_doLoop = false; - if (_finished) then { - _damage = [_vehicle,_hitpoint] call object_getHit; - // _vehicle removeAction _id; - - //dont allow removal of damaged parts if (_damage < 1) then { - + _BreakableParts = ["HitGlass1","HitGlass2","HitGlass3","HitGlass4","HitGlass5","HitGlass6","HitLGlass","HitRGlass","HitEngine","HitFuel","HitHRotor"]; + if (_hitpoint in _BreakableParts) then { _findPercent = (1 - _damage) * 10; if(ceil (random _findPercent) == 1) then { - _isOK = true; - _brokenPart = true; + _isOK = true; + _brokenPart = true; + } else { + _isOK = [player,_part] call BIS_fnc_invAdd; + _brokenPart = false; + }; } else { + //Remove melee ammo due to the way ammo is working. + {player removeMagazines _x} count MeleeMagazines; + _isOK = [player,_part] call BIS_fnc_invAdd; _brokenPart = false; }; - - if (_isOK) then { - - //break the part - _selection = getText(configFile >> "cfgVehicles" >> _type >> "HitPoints" >> _hitpoint >> "name"); - //vehicle is owned by whoever is in it, so we have to have each client try && fix it - //["PVDZE_veh_SFix",[_vehicle,_selection,1],_vehicle] call broadcastRpcCallIfLocal; - - PVDZE_veh_SFix = [_vehicle,_selection,1]; - publicVariable "PVDZE_veh_SFix"; - if (local _vehicle) then { - PVDZE_veh_SFix call object_setFixServer; - }; - - _vehicle setvelocity [0,0,1]; - - if(_brokenPart) then { - //Failed! - cutText [format[(localize "str_epoch_player_168"),_namePart,_nameType], "PLAIN DOWN"]; + if (_isOK) then { + _selection = getText(configFile >> "cfgVehicles" >> _type >> "HitPoints" >> _hitpoint >> "name"); + if ((_hitpoint == "HitEngine") or (_hitpoint == "HitFuel")) then { + [_vehicle, _selection, 0.89] call fnc_veh_handleDam; } else { - //Success! - cutText [format[(localize "str_epoch_player_169"),_namePart,_nameType], "PLAIN DOWN"]; + [_vehicle, _selection, 1] call fnc_veh_handleDam; + }; + _vehicle call fnc_veh_ResetEH; + _vehicle setvelocity [0,0,1]; + if(_brokenPart) then { + cutText [format [localize "str_salvage_destroyed",_namePart,_nameType], "PLAIN DOWN"]; + } else { + cutText [format [localize "str_salvage_removed",_namePart,_nameType], "PLAIN DOWN"]; }; - } else { - cutText [localize "STR_DAYZ_CODE_2", "PLAIN DOWN"]; + cutText [localize "str_player_24", "PLAIN DOWN"]; }; - }; - } else { r_interrupt = false; if (vehicle player == player) then { [objNull, player, rSwitchMove,""] call RE; player playActionNow "stop"; }; - cutText [(localize "str_epoch_player_95"), "PLAIN DOWN"]; + cutText [localize "str_salvage_canceled", "PLAIN DOWN"]; }; - } else { - cutText [format[(localize "str_epoch_player_170"),_namePart], "PLAIN DOWN"]; + cutText [format [localize "str_salvage_toolbox",_namePart], "PLAIN DOWN"]; }; dayz_myCursorTarget = objNull; s_player_repair_crtl = -1; -DZE_ActionInProgress = false; +dayz_salvageInProgress = false; + +//adding melee mags back if needed +_wpn = primaryWeapon player; +//diag_log format["Classname: %1, WPN: %2", _classname,_wpn]; +_ismelee = (getNumber (configFile >> "CfgWeapons" >> _wpn >> "melee") == 1); +if (_ismelee) then { + call dayz_meleeMagazineCheck; +}; diff --git a/SQF/dayz_code/actions/salvage_vehicle.sqf b/SQF/dayz_code/actions/salvage_vehicle.sqf index 808915101..667c29c13 100644 --- a/SQF/dayz_code/actions/salvage_vehicle.sqf +++ b/SQF/dayz_code/actions/salvage_vehicle.sqf @@ -1,67 +1,74 @@ -private ["_part","_cancel","_color","_percent","_string","_handle","_damage","_cmpt","_vehicle","_hitpoints"]; +private ["_part","_color"]; _vehicle = _this select 3; +{dayz_myCursorTarget removeAction _x} forEach s_player_repairActions;s_player_repairActions = []; -{dayz_myCursorTarget removeAction _x} count s_player_repairActions;s_player_repairActions = []; -// dayz_myCursorTarget = _vehicle; +_PlayerNear = {isPlayer _x} count ((getPosATL _vehicle) nearEntities ["CAManBase", 10]) > 1; +if (_PlayerNear) exitWith {dayz_myCursorTarget = objNull; cutText [localize "str_pickup_limit_5", "PLAIN DOWN"];}; -// _allFixed = true; +dayz_myCursorTarget = _vehicle; _hitpoints = _vehicle call vehicle_getHitpoints; -// diag_log format["DEBUG SALVAGE: %1", _hitpoints]; -{ + +_cursorTarget = cursorTarget; +_isATV = typeof _cursorTarget in ["ATV_US_EP1","ATV_CZ_EP1"]; +_is6WheelType = typeOf _cursorTarget in ["V3S_Civ","Ural_TK_CIV_EP1"]; +_HasNoGlassKind = (_cursorTarget iskindof "Motorcycle") or (_cursorTarget iskindof "Bicycle"); + +_6WheelTypeArray = ["HitLMWheel","HitRMWheel"]; +_NoGlassArray = ["HitGlass1","HitGlass2","HitGlass3","HitGlass4","HitGlass5","HitGlass6","HitLGlass","HitRGlass"]; +_NoExtraWheelsArray = ["wheel_1_4_steering","wheel_2_4_steering","wheel_1_3_steering","wheel_2_3_steering"]; +_RemovedPartsArray = ["motor","HitEngine","HitLF2Wheel","HitRF2Wheel","HitBody","HitMissiles","HitHull","HitVRotor"]; + +if (_isATV or _HasNoGlassKind) then { + _hitpoints = _hitpoints - _NoGlassArray; +}; + +if (_cursorTarget iskindof "tractor") then { + _hitpoints = _hitpoints - ["motor","HitLFWheel","HitRFWheel","HitLBWheel","HitRBWheel","HitLF2Wheel","HitRF2Wheel","HitLMWheel","HitRMWheel"]; +}; + +if ((_cursorTarget iskindof "Bicycle") or (_cursorTarget iskindof "Motocycle")) then { + _hitpoints = _hitpoints - ["HitEngine","HitFuel"]; +}; + +if (_is6WheelType) then { + _hitpoints = _hitpoints + _6WheelTypeArray; +} else { + _hitpoints = _hitpoints - _6WheelTypeArray; +}; + +{ _damage = [_vehicle,_x] call object_getHit; - _part = "PartGeneric"; - - //change "HitPart" to " - Part" rather than complicated string replace - _cmpt = toArray (_x); - _cmpt set [0,20]; - _cmpt set [1,toArray ("-") select 0]; - _cmpt set [2,20]; - _cmpt = toString _cmpt; - if(["Engine",_x,false] call fnc_inString) then { - _part = "PartEngine"; - }; - - if(["HRotor",_x,false] call fnc_inString) then { - _part = "PartVRotor"; //yes you need PartVRotor to fix HRotor LOL - }; + if (!(_x in _RemovedPartsArray)) then { + _cmpt = toArray (_x); + _cmpt set [0,20]; + _cmpt set [1,toArray ("-") select 0]; + _cmpt set [2,20]; + _cmpt = toString _cmpt; - if(["Fuel",_x,false] call fnc_inString) then { - _part = "PartFueltank"; - }; + _configVeh = configFile >> "cfgVehicles" >> "RepairParts" >> _x; + _part = getText(_configVeh >> "part"); + if (isNil "_part") then { _part = "PartGeneric"; }; - if(["Wheel",_x,false] call fnc_inString) then { - _part = "PartWheel"; - }; - - if(["Glass",_x,false] call fnc_inString) then { - _part = "PartGlass"; - }; - - // allow removal of any lightly damaged parts - if (_damage < 1 && _damage > 0) then { - - // Do not allow removal of engine || fueltanks - if( _part == "PartGlass" || _part == "PartWheel" ) then { - - _color = "color='#ffff00'"; //yellow - if (_damage >= 0.5) then {_color = "color='#ff8800'";}; //orange - if (_damage >= 0.9) then {_color = "color='#ff0000'";}; //red - - _percent = round(_damage*100); - _string = format["Remove%1 (%3 %4)",_cmpt,_color,_percent,"%"]; //Remove - Part + //get every damaged part no matter how tiny damage is! + _damagePercent = str(round(_damage * 100))+"% Damage"; + if (_damage < 1) then { + if ((_damage >= 0) and (_damage <= 0.25)) then {_color = "color='#00ff00'";}; //green + if ((_damage >= 0.26) and (_damage <= 0.50)) then {_color = "color='#ffff00'";}; //yellow + if ((_damage >= 0.51) and (_damage <= 0.75)) then {_color = "color='#ff8800'";}; //orange + if ((_damage >= 0.76) and (_damage <= 1)) then {_color = "color='#ff0000'";}; //red + _string = format[localize "str_actions_repair_01",_cmpt,_damagePercent]; + _string = format["%2",_color,_string]; //Remove - Part _handle = dayz_myCursorTarget addAction [_string, "\z\addons\dayz_code\actions\salvage.sqf",[_vehicle,_part,_x], 0, false, true, "",""]; s_player_repairActions set [count s_player_repairActions,_handle]; - }; }; +} forEach _hitpoints; -} count _hitpoints; - -if(count _hitpoints > 0 ) then { - - _cancel = dayz_myCursorTarget addAction [localize "STR_EPOCH_PLAYER_CANCEL", "\z\addons\dayz_code\actions\repair_cancel.sqf","repair", 0, true, false, "",""]; +if (count _hitpoints > 0 ) then { + //ArmA OA String + _cancel = dayz_myCursorTarget addAction [localize "str_action_cancel_action", "\z\addons\dayz_code\actions\repair_cancel.sqf","repair", 0, true, false, "",""]; s_player_repairActions set [count s_player_repairActions,_cancel]; s_player_repair_crtl = 1; -}; +}; \ No newline at end of file diff --git a/SQF/dayz_code/actions/siphonFuel.sqf b/SQF/dayz_code/actions/siphonFuel.sqf index 3a2e2599d..05aeff566 100644 --- a/SQF/dayz_code/actions/siphonFuel.sqf +++ b/SQF/dayz_code/actions/siphonFuel.sqf @@ -1,29 +1,32 @@ -private ["_vehicle","_curFuel","_newFuel","_started","_finished","_animState","_isMedic","_location1","_location2","_abort","_canNameEmpty","_canSizeEmpty","_canTypeEmpty","_canName","_canSize","_configCanEmpty","_configVeh","_capacity","_nameText","_availableCansEmpty"]; +private ["_vehicle","_curFuel","_newFuel","_started","_finished","_animState","_isMedic","_location1","_location2","_abort","_canNameEmpty","_canSizeEmpty","_canTypeEmpty","_canName","_canSize","_configCanEmpty","_configVeh","_capacity","_nameText","_availableCansEmpty","_hasHose"]; -if(DZE_ActionInProgress) exitWith { cutText [(localize "str_epoch_player_98") , "PLAIN DOWN"] }; -DZE_ActionInProgress = true; +player removeAction s_player_siphonfuel; +_hasHose = "equip_hose" in magazines player; -// Use target from addaction -_vehicle = _this select 0; +if (dayz_siphonFuelInProgress) exitWith { cutText [localize "str_siphon_inprogress", "PLAIN DOWN"] }; +if (!_hasHose) exitWith {cutText [localize "str_siphon_hose", "PLAIN DOWN"] }; +_PlayerNear = {isPlayer _x} count ((getPosATL _vehicle) nearEntities ["CAManBase", 10]) > 1; +if (_PlayerNear) exitWith {cutText [localize "str_pickup_limit_5", "PLAIN DOWN"];}; +dayz_siphonFuelInProgress = true; +_vehicle = _this select 3; _abort = false; // Static vehicle fuel information _configVeh = configFile >> "cfgVehicles" >> TypeOf(_vehicle); _capacity = getNumber(_configVeh >> "fuelCapacity"); _nameText = getText(_configVeh >> "displayName"); +_isMan = _vehicle isKindOf "Man"; +_isAnimal = _vehicle isKindOf "Animal"; +_isZombie = _vehicle isKindOf "zZombie_base"; -_availableCansEmpty = ["ItemJerrycanEmpty","ItemFuelBarrelEmpty"]; -// _availableCans = ["ItemJerrycan","ItemFuelBarrel"]; +if (_isMan or _isAnimal or _isZombie) exitWith { cutText [localize "str_siphon_notvehicle", "PLAIN DOWN"] }; -// Loop to find containers that can could hold fuel && fill them +// Loop to find containers that can could hold fuel and fill them { _configCanEmpty = configFile >> "CfgMagazines" >> _x; //diag_log format["Looking for: %1", _x]; - if(_x in _availableCansEmpty) then { - - //diag_log format["gas fuelQuantity config : %1", _x]; - + if(_x in DayZ_fuelCansEmpty) then { // Get Empty can size _canNameEmpty = _x; _canSizeEmpty = getNumber(_configCanEmpty >> "fuelQuantity"); @@ -34,28 +37,25 @@ _availableCansEmpty = ["ItemJerrycanEmpty","ItemFuelBarrelEmpty"]; _canSize = getNumber(configFile >> "cfgMagazines" >> _canName >> "fuelQuantity"); // is empty - if(_canSizeEmpty == 0) then { - - //diag_log format["is empty fuelQuantity : %1", _x]; - + if(_canSizeEmpty == 0) then { _curFuel = ((fuel _vehicle) * _capacity); _newFuel = (_curFuel - _canSize); // calculate new fuel - _newFuel = (_newFuel / _capacity); + if (_capacity == 0) then { + _newFuel = 0; + } else { + _newFuel = (_newFuel / _capacity); + }; if (_newFuel > 0) then { - - cutText [format[(localize "str_epoch_player_133"),_canTypeEmpty], "PLAIN DOWN"]; + cutText [format [localize "str_siphon_preparing",_canTypeEmpty], "PLAIN DOWN"]; + _finished = false; // alert zombies - [player,20,true,(getPosATL player)] spawn player_alertZombies; - - _finished = false; + [player,20,true,(getPosATL player)] call player_alertZombies; if(!dayz_isSwimming) then { - - [1,1] call dayz_HungerThirst; // force animation player playActionNow "Medic"; @@ -70,14 +70,14 @@ _availableCansEmpty = ["ItemJerrycanEmpty","ItemFuelBarrelEmpty"]; if (_isMedic) then { _started = true; }; - if (_started && !_isMedic) then { + if (_started and !_isMedic) then { r_doLoop = false; _finished = true; }; if (r_interrupt) then { r_doLoop = false; }; - uiSleep 0.1; + sleep 0.1; }; r_doLoop = false; @@ -88,11 +88,10 @@ _availableCansEmpty = ["ItemJerrycanEmpty","ItemFuelBarrelEmpty"]; player playActionNow "stop"; }; }; - } else { // Alternate method in water make sure player stays in one spot for 6 seconds _location1 = getPosATL player; - uiSleep 6; + sleep 6; _location2 = getPosATL player; if(_location1 distance _location2 < 3) then { _finished = true; @@ -100,19 +99,19 @@ _availableCansEmpty = ["ItemJerrycanEmpty","ItemFuelBarrelEmpty"]; }; if (_finished) then { - // Get vehicle fuel levels again _curFuel = ((fuel _vehicle) * _capacity); _newFuel = (_curFuel - _canSize); // calculate minimum needed fuel - _newFuel = (_newFuel / _capacity); + if (_capacity == 0) then { + _newFuel = 0; + } else { + _newFuel = (_newFuel / _capacity); + }; if (_newFuel > 0) then { - if(([player,_canNameEmpty] call BIS_fnc_invRemove) == 1) then { - - /* PVS/PVC - Skaronator */ if (local _vehicle) then { [_vehicle,_newFuel] call local_setFuel; } else { @@ -122,37 +121,37 @@ _availableCansEmpty = ["ItemJerrycanEmpty","ItemFuelBarrelEmpty"]; // Play sound [player,"refuel",0,false] call dayz_zombieSpeak; + + // Add filled can player addMagazine _canName; - cutText [format[(localize "str_epoch_player_171"),_nameText,_canSize], "PLAIN DOWN"]; + + // Added Nutrition-Factor for work + ["Working",0,[20,40,15,0]] call dayz_NutritionSystem; + + cutText [format [localize "str_siphon_drained",_nameText,_canSize], "PLAIN DOWN"]; call fnc_usec_medic_removeActions; r_action = false; - uiSleep 1; + sleep 1; } else { _abort = true; - }; - + }; } else { - cutText [format[(localize "str_epoch_player_172"),_nameText], "PLAIN DOWN"]; + cutText [format [localize "str_siphon_notenough",_nameText], "PLAIN DOWN"]; _abort = true; - }; - + }; } else { - cutText [(localize "str_epoch_player_35") , "PLAIN DOWN"]; + cutText [localize "str_siphon_canceled", "PLAIN DOWN"]; _abort = true; - }; - + }; } else { - cutText [format[(localize "str_epoch_player_172"),_nameText], "PLAIN DOWN"]; + cutText [format [localize "str_siphon_notenough",_nameText], "PLAIN DOWN"]; _abort = true; - }; - }; + }; + }; }; - - // exit if abort flag was set if(_abort) exitWith {}; +} forEach magazines player; -} count magazines player; - -DZE_ActionInProgress = false; +dayz_siphonFuelInProgress = false; \ No newline at end of file