From f0c46a0764e3d44e415273351032e6ad0dd03367 Mon Sep 17 00:00:00 2001 From: ebaydayz Date: Tue, 19 Apr 2016 16:51:20 -0400 Subject: [PATCH] Use Epoch player_harvest instead of player_chopWood --- .../Configs/CfgWeapons/Melee/Hatchet.hpp | 4 +-- .../Configs/CfgWeapons/Tools/Hatchet.hpp | 4 +-- SQF/dayz_code/actions/player_chopWood.sqf | 24 ++----------- SQF/dayz_code/actions/player_findLights.sqf | 2 +- SQF/dayz_code/actions/player_harvestPlant.sqf | 2 +- ...e_getModelName.sqf => fn_getModelName.sqf} | 2 ++ SQF/dayz_code/compile/fn_lightFunctions.sqf | 2 +- SQF/dayz_code/compile/player_harvest.sqf | 34 ++++++------------- SQF/dayz_code/init/compiles.sqf | 4 +-- SQF/dayz_code/init/publicEH.sqf | 6 +++- SQF/dayz_code/init/variables.sqf | 2 +- 11 files changed, 30 insertions(+), 56 deletions(-) rename SQF/dayz_code/compile/{dze_getModelName.sqf => fn_getModelName.sqf} (87%) diff --git a/SQF/dayz_code/Configs/CfgWeapons/Melee/Hatchet.hpp b/SQF/dayz_code/Configs/CfgWeapons/Melee/Hatchet.hpp index 5a5e5a778..2d2de4538 100644 --- a/SQF/dayz_code/Configs/CfgWeapons/Melee/Hatchet.hpp +++ b/SQF/dayz_code/Configs/CfgWeapons/Melee/Hatchet.hpp @@ -13,11 +13,11 @@ class MeleeHatchet : MeleeWeapon class ItemActions { - class Use + /*class Use // Must hit tree to chop wood on Epoch, see player_harvest { text = $STR_ACTIONS_CHOPWOOD; script = "spawn player_chopWood"; - }; + };*/ class Toolbelt { diff --git a/SQF/dayz_code/Configs/CfgWeapons/Tools/Hatchet.hpp b/SQF/dayz_code/Configs/CfgWeapons/Tools/Hatchet.hpp index 4c8602a92..98cf4ce03 100644 --- a/SQF/dayz_code/Configs/CfgWeapons/Tools/Hatchet.hpp +++ b/SQF/dayz_code/Configs/CfgWeapons/Tools/Hatchet.hpp @@ -9,11 +9,11 @@ class ItemHatchet : ItemCore class ItemActions { - class Use + /*class Use // Must hit tree to chop wood on Epoch, see player_harvest { text = $STR_ACTIONS_CHOPWOOD; script = "spawn player_chopWood;"; - }; + };*/ class ToBack { diff --git a/SQF/dayz_code/actions/player_chopWood.sqf b/SQF/dayz_code/actions/player_chopWood.sqf index dc44c2155..b4769e8db 100644 --- a/SQF/dayz_code/actions/player_chopWood.sqf +++ b/SQF/dayz_code/actions/player_chopWood.sqf @@ -1,5 +1,5 @@ -private ["_item","_result","_dis","_sfx","_num","_breaking","_countOut","_woodCutting","_trees","_findNearestTree","_objInfo","_lenInfo","_objName","_i","_k","_counter","_isOk","_proceed","_animState","_started","_finished","_isMedic","_itemOut"]; +private ["_item","_result","_dis","_sfx","_num","_breaking","_countOut","_woodCutting","_findNearestTree","_objName","_counter","_isOk","_proceed","_animState","_started","_finished","_isMedic","_itemOut"]; //if (!isnil "faco_player_chopWood") exitWith { _this call faco_player_chopWood }; @@ -15,29 +15,11 @@ if (["forest",dayz_surfaceType] call fnc_inString) then { _woodCutting = true; } else { - // allowed trees list move this later - _trees = ["ind_timbers.p3d","t_larix3s.p3d","t_pyrus2s.p3d","str_briza_kriva.p3d","dd_borovice.p3d","les_singlestrom_b.p3d","les_singlestrom.p3d","smrk_velky.p3d","smrk_siroky.p3d","smrk_maly.p3d","les_buk.p3d","str krovisko vysoke.p3d","str_fikovnik_ker.p3d","str_fikovnik.p3d","str vrba.p3d","hrusen2.p3d","str dub jiny.p3d","str lipa.p3d","str briza.p3d","p_akat02s.p3d","jablon.p3d","p_buk.p3d","str_topol.p3d","str_topol2.p3d","p_osika.p3d","t_picea3f.p3d","t_picea2s.p3d","t_picea1s.p3d","t_fagus2w.p3d","t_fagus2s.p3d","t_fagus2f.p3d","t_betula1f.p3d","t_betula2f.p3d","t_betula2s.p3d","t_betula2w.p3d","t_alnus2s.p3d","t_acer2s.p3d","t_populus3s.p3d","t_quercus2f.p3d","t_sorbus2s.p3d","t_malus1s.p3d","t_salix2s.p3d","t_picea1s_w.p3d","t_picea2s_w.p3d","t_ficusb2s_ep1.p3d","t_populusb2s_ep1.p3d","t_populusf2s_ep1.p3d","t_amygdalusc2s_ep1.p3d","t_ficusb2s_ep1.p3d","t_pistacial2s_ep1.p3d","t_pinuse2s_ep1.p3d","t_pinuss3s_ep1.p3d","t_prunuss2s_ep1.p3d","t_pinusn2s.p3d","t_pinusn1s.p3d","t_pinuss2f.p3d","t_poplar2f_dead_pmc.p3d","misc_torzotree_pmc.p3d","misc_burnspruce_pmc.p3d","brg_cocunutpalm8.p3d","brg_umbrella_acacia01b.p3d","brg_jungle_tree_canopy_1.p3d","brg_jungle_tree_canopy_2.p3d","brg_cocunutpalm4.p3d","brg_cocunutpalm3.p3d","palm_01.p3d","palm_02.p3d","palm_03.p3d","palm_04.p3d","palm_09.p3d","palm_10.p3d","brg_cocunutpalm2.p3d","brg_jungle_tree_antiaris.p3d","brg_cocunutpalm1.p3d"]; _findNearestTree = objNull; - { - _objInfo = toArray(str(_x)); - _lenInfo = count _objInfo - 1; - _objName = []; - _i = 0; - // determine where the object name starts - { - if (58 == _objInfo select _i) exitWith {}; - _i = _i + 1; - } forEach _objInfo; - _i = _i + 2; // skip the ": " part - - for "_k" from _i to _lenInfo do { - _objName = _objName + [_objInfo select _k]; - }; - _objName = toLower(toString(_objName)); - + _objName = _x call fn_getModelName; // Exit since we found a tree - if (_objName in _trees) exitWith { _findNearestTree = _x; }; + if (_objName in dayz_trees) exitWith { _findNearestTree = _x; }; } foreach nearestObjects [getPosATL player, [], 8]; _countOut = floor(random 3) + 2; diff --git a/SQF/dayz_code/actions/player_findLights.sqf b/SQF/dayz_code/actions/player_findLights.sqf index 0d3c23a2f..12822947e 100644 --- a/SQF/dayz_code/actions/player_findLights.sqf +++ b/SQF/dayz_code/actions/player_findLights.sqf @@ -13,7 +13,7 @@ _findNearestlight = []; if (alive _x) then { - _objName = _x call DZE_getModelName; + _objName = _x call fn_getModelName; if (_objName in _lights) then { _findNearestlight set [(count _findNearestlight),_x]; diff --git a/SQF/dayz_code/actions/player_harvestPlant.sqf b/SQF/dayz_code/actions/player_harvestPlant.sqf index 69fd14c0e..2c17464c6 100644 --- a/SQF/dayz_code/actions/player_harvestPlant.sqf +++ b/SQF/dayz_code/actions/player_harvestPlant.sqf @@ -23,7 +23,7 @@ _findNearestTree = []; if (alive _x) then { - _objName = _x call DZE_getModelName; + _objName = _x call fn_getModelName; // Exit since we found a tree if (_objName in _trees) exitWith { diff --git a/SQF/dayz_code/compile/dze_getModelName.sqf b/SQF/dayz_code/compile/fn_getModelName.sqf similarity index 87% rename from SQF/dayz_code/compile/dze_getModelName.sqf rename to SQF/dayz_code/compile/fn_getModelName.sqf index ff73db1c8..c1120a6da 100644 --- a/SQF/dayz_code/compile/dze_getModelName.sqf +++ b/SQF/dayz_code/compile/fn_getModelName.sqf @@ -1,3 +1,5 @@ +private ["_i","_k","_lenInfo","_objInfo","_objName"]; + _objInfo = toArray(str(_this)); _lenInfo = count _objInfo - 1; _objName = []; diff --git a/SQF/dayz_code/compile/fn_lightFunctions.sqf b/SQF/dayz_code/compile/fn_lightFunctions.sqf index eebe0ef49..18b376df3 100644 --- a/SQF/dayz_code/compile/fn_lightFunctions.sqf +++ b/SQF/dayz_code/compile/fn_lightFunctions.sqf @@ -14,7 +14,7 @@ _lights = ["a_fuelstation_sign.p3d","lampa_ind_zebr.p3d","lampa_ind.p3d","lampa_ if (alive _x) then { - _objName = _x call DZE_getModelName; + _objName = _x call fn_getModelName; if (_objName in _lights) then { diff --git a/SQF/dayz_code/compile/player_harvest.sqf b/SQF/dayz_code/compile/player_harvest.sqf index 3455572df..766f35931 100644 --- a/SQF/dayz_code/compile/player_harvest.sqf +++ b/SQF/dayz_code/compile/player_harvest.sqf @@ -12,10 +12,10 @@ if (_ammo isKindOf "Hatchet_Swing_Ammo" || _ammo isKindOf "Chainsaw_Swing_Ammo") if (alive _x) then { - _objName = _x call DZE_getModelName; + _objName = _x call fn_getModelName; // Exit since we found a tree - if (_objName in DZE_trees) exitWith { + if (_objName in dayz_trees) exitWith { _findNearestTree set [(count _findNearestTree),_x]; }; }; @@ -39,34 +39,20 @@ if (_ammo isKindOf "Hatchet_Swing_Ammo" || _ammo isKindOf "Chainsaw_Swing_Ammo") if (_damage < 0.99) then { if("" == typeOf _tree) then { - _tree setDamage 0.99; + PVDZ_objgather_Knockdown = [_tree,player]; // Ask server to setDamage on tree + publicVariableServer "PVDZ_objgather_Knockdown"; }; }; //diag_log ("DAMAGE: " + str(damage _tree)); - if (round(random 1) > 0.5) then { + _itemOut = if (_ammo isKindOf "Chainsaw_Swing_Ammo") then {"PartWoodLumber"} else {"ItemLog"}; // Log can be crafted to > 2x plank > 4x woodpile + _itemOut call fn_dropItem; - _countOut = 1; - _itemOut = "PartWoodPile"; - - if(_ammo isKindOf "Chainsaw_Swing_Ammo") then { - _itemOut = "PartWoodLumber"; - }; - - _nearByPile= nearestObjects [getPosATL player, ["WeaponHolder"],2]; - if (count _nearByPile == 0) then { - _item = createVehicle ["WeaponHolder", getPosATL player, [], 1, "CAN_COLLIDE"]; - _item addMagazineCargoGlobal [_itemOut,_countOut]; - player reveal _item; - } else { - _item = _nearByPile select 0; - _item addMagazineCargoGlobal [_itemOut,_countOut]; - }; - - _distance = 60; - [player,_distance,false,getPosATL player] spawn player_alertZombies; - }; + _distance = 60; + [player,_distance,false,getPosATL player] spawn player_alertZombies; + // Working-Factor for chopping wood. + ["Working",0,[100,15,10,0]] call dayz_NutritionSystem; }; DZE_TEMP_treedmg = _damage; }; diff --git a/SQF/dayz_code/init/compiles.sqf b/SQF/dayz_code/init/compiles.sqf index b7ae65e34..f5aba9880 100644 --- a/SQF/dayz_code/init/compiles.sqf +++ b/SQF/dayz_code/init/compiles.sqf @@ -84,7 +84,7 @@ if (!isDedicated) then { player_removeAttachment = compile preprocessFileLineNumbers "\z\addons\dayz_code\actions\player_removeAttachment.sqf"; player_fillWater = compile preprocessFileLineNumbers "\z\addons\dayz_code\actions\water_fill.sqf"; player_makeFire = compile preprocessFileLineNumbers "\z\addons\dayz_code\actions\player_makefire.sqf"; - player_chopWood = compile preprocessFileLineNumbers "\z\addons\dayz_code\actions\player_chopWood.sqf"; + //player_chopWood = compile preprocessFileLineNumbers "\z\addons\dayz_code\actions\player_chopWood.sqf"; //Epoch uses player_harvest instead player_mineStone = compile preprocessFileLineNumbers "\z\addons\dayz_code\actions\player_mineStone.sqf"; if (DZE_modularBuild) then { player_build = compile preprocessFileLineNumbers "\z\addons\dayz_code\actions\modular_build.sqf"; @@ -144,7 +144,6 @@ if (!isDedicated) then { // EPOCH ADDITIONS autoRunOff = {autoRunActive = false; terminate autoRunThread; player playActionNow "Stop";}; dog_findTargetAgent = compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\dog_findTargetAgent.sqf"; - dze_getModelName = compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\dze_getModelName.sqf"; dze_isnearest_player = compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\dze_isNearestPlayer.sqf"; dze_surrender_off = {player setVariable ["DZE_Surrendered",false,true]; DZE_Surrender = false;}; epoch_tempKeys = compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\epoch_tempKeys.sqf"; @@ -549,6 +548,7 @@ player_projectileNear = compile preprocessFileLineNumbers "\z\addons\dayz_code\c player_bloodCalc = compile preprocessFileLineNumbers "\z\addons\dayz_code\medical\bloodCalc.sqf"; fn_selectRandomLocation = compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\fn_selectRandomLocation.sqf"; fn_chance = compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\fn_selectRandomChance.sqf"; +fn_getModelName = compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\fn_getModelName.sqf"; fn_niceSpot = compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\fn_niceSpot.sqf"; fnc_Obj_handleDam = compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\obj_handleDam.sqf"; object_roadFlare = compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\object_roadFlare.sqf"; diff --git a/SQF/dayz_code/init/publicEH.sqf b/SQF/dayz_code/init/publicEH.sqf index b2c8cadef..aa06f3cf9 100644 --- a/SQF/dayz_code/init/publicEH.sqf +++ b/SQF/dayz_code/init/publicEH.sqf @@ -153,10 +153,14 @@ if (isServer) then { _tree = (_this select 1) select 0; _player = (_this select 1) select 1; _dis = _player distance _tree; + _name = if (alive _player) then {name _player} else {"unknown"}; + _uid = getPlayerUID _player; + _treeModel = _tree call fn_getModelName; - if (_dis < 30) then { + if ((_dis < 30) && (_treeModel in dayz_trees) && (_uid != "")) then { _tree setDamage 1; deleteVehicle _tree; + diag_log format["Server setDamage on tree %1 chopped down by %2(%3)",_treeModel,_name,_uid]; }; }; diff --git a/SQF/dayz_code/init/variables.sqf b/SQF/dayz_code/init/variables.sqf index 572d6ca20..670fc43fd 100644 --- a/SQF/dayz_code/init/variables.sqf +++ b/SQF/dayz_code/init/variables.sqf @@ -52,6 +52,7 @@ DayZ_GearedObjects = ["Car","Helicopter","Motorcycle","Ship","TentStorage_base", DayZ_RestingAnims = ["amovpsitmstpsnonwpstdnon_ground","amovpsitmstpsnonwpstdnon_smoking","amovpsitmstpsraswrfldnon_weaponcheck1","amovpsitmstpsraswrfldnon"]; dayz_typedBags = ["bloodTester","bloodBagANEG","bloodBagAPOS","bloodBagBNEG","bloodBagBPOS","bloodBagABNEG","bloodBagABPOS","bloodBagONEG","bloodBagOPOS","wholeBloodBagANEG","wholeBloodBagAPOS","wholeBloodBagBNEG","wholeBloodBagBPOS","wholeBloodBagABNEG","wholeBloodBagABPOS","wholeBloodBagONEG","wholeBloodBagOPOS"]; dayz_playerAchievements = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]; +dayz_trees = ["ind_timbers.p3d","t_picea2s_snow.p3d","b_corylus.p3d","t_quercus3s.p3d","t_larix3s.p3d","t_pyrus2s.p3d","str_briza_kriva.p3d","dd_borovice.p3d","les_singlestrom_b.p3d","les_singlestrom.p3d","smrk_velky.p3d","smrk_siroky.p3d","smrk_maly.p3d","les_buk.p3d","str krovisko vysoke.p3d","str_fikovnik_ker.p3d","str_fikovnik.p3d","str vrba.p3d","hrusen2.p3d","str dub jiny.p3d","str lipa.p3d","str briza.p3d","p_akat02s.p3d","jablon.p3d","p_buk.p3d","str_topol.p3d","str_topol2.p3d","p_osika.p3d","t_picea3f.p3d","t_picea2s.p3d","t_picea1s.p3d","t_fagus2w.p3d","t_fagus2s.p3d","t_fagus2f.p3d","t_betula1f.p3d","t_betula2f.p3d","t_betula2s.p3d","t_betula2w.p3d","t_alnus2s.p3d","t_acer2s.p3d","t_populus3s.p3d","t_quercus2f.p3d","t_sorbus2s.p3d","t_malus1s.p3d","t_salix2s.p3d","t_picea1s_w.p3d","t_picea2s_w.p3d","t_ficusb2s_ep1.p3d","t_populusb2s_ep1.p3d","t_populusf2s_ep1.p3d","t_amygdalusc2s_ep1.p3d","t_pistacial2s_ep1.p3d","t_pinuse2s_ep1.p3d","t_pinuss3s_ep1.p3d","t_prunuss2s_ep1.p3d","t_pinusn2s.p3d","t_pinusn1s.p3d","t_pinuss2f.p3d","t_poplar2f_dead_pmc.p3d","misc_torzotree_pmc.p3d","misc_burnspruce_pmc.p3d","brg_cocunutpalm8.p3d","brg_umbrella_acacia01b.p3d","brg_jungle_tree_canopy_1.p3d","brg_jungle_tree_canopy_2.p3d","brg_cocunutpalm4.p3d","brg_cocunutpalm3.p3d","palm_01.p3d","palm_02.p3d","palm_03.p3d","palm_04.p3d","palm_09.p3d","palm_10.p3d","brg_cocunutpalm2.p3d","brg_jungle_tree_antiaris.p3d","brg_cocunutpalm1.p3d","str habr.p3d","brg_bird_1.p3d","brg_bird_2.p3d","brg_bird_3.p3d","brg_umbrella_acacia02b.p3d","brg_africandoumpalm_1.p3d","brg_umbrella_acacia04b.p3d","brg_datepalm_4.p3d","brg_datepalm_1.p3d","brg_umbrella_acacia03b.p3d","brg_bottle_4.p3d","brg_aloe1.p3d","brg_umbrella_acacia03.p3d","brg_umbrella_acacia01.p3d","brg_umbrella_acacia04.p3d","brg_aloe2.p3d","brg_umbrella_acacia02.p3d","brg_aloe3.p3d","brg_bottle_1.p3d","brg_datepalm_3.p3d","brg_datepalm_2.p3d","brg_baobab_1.p3d","brg_bottle_2.p3d","brg_bottle_3.p3d"]; Dayz_meatraw = [ @@ -646,7 +647,6 @@ if (!isDedicated) then { DZE_F = false; DZE_cancelBuilding = false; DZE_PZATTACK = false; - DZE_trees = ["t_picea2s_snow.p3d","b_corylus.p3d","t_quercus3s.p3d","t_larix3s.p3d","t_pyrus2s.p3d","str_briza_kriva.p3d","dd_borovice.p3d","les_singlestrom_b.p3d","les_singlestrom.p3d","smrk_velky.p3d","smrk_siroky.p3d","smrk_maly.p3d","les_buk.p3d","str krovisko vysoke.p3d","str_fikovnik_ker.p3d","str_fikovnik.p3d","str vrba.p3d","hrusen2.p3d","str dub jiny.p3d","str lipa.p3d","str briza.p3d","p_akat02s.p3d","jablon.p3d","p_buk.p3d","str_topol.p3d","str_topol2.p3d","p_osika.p3d","t_picea3f.p3d","t_picea2s.p3d","t_picea1s.p3d","t_fagus2w.p3d","t_fagus2s.p3d","t_fagus2f.p3d","t_betula1f.p3d","t_betula2f.p3d","t_betula2s.p3d","t_betula2w.p3d","t_alnus2s.p3d","t_acer2s.p3d","t_populus3s.p3d","t_quercus2f.p3d","t_sorbus2s.p3d","t_malus1s.p3d","t_salix2s.p3d","t_picea1s_w.p3d","t_picea2s_w.p3d","t_ficusb2s_ep1.p3d","t_populusb2s_ep1.p3d","t_populusf2s_ep1.p3d","t_amygdalusc2s_ep1.p3d","t_pistacial2s_ep1.p3d","t_pinuse2s_ep1.p3d","t_pinuss3s_ep1.p3d","t_prunuss2s_ep1.p3d","t_pinusn2s.p3d","t_pinusn1s.p3d","t_pinuss2f.p3d","t_poplar2f_dead_pmc.p3d","misc_torzotree_pmc.p3d","misc_burnspruce_pmc.p3d","brg_cocunutpalm8.p3d","brg_umbrella_acacia01b.p3d","brg_jungle_tree_canopy_1.p3d","brg_jungle_tree_canopy_2.p3d","brg_cocunutpalm4.p3d","brg_cocunutpalm3.p3d","palm_01.p3d","palm_02.p3d","palm_03.p3d","palm_04.p3d","palm_09.p3d","palm_10.p3d","brg_cocunutpalm2.p3d","brg_jungle_tree_antiaris.p3d","brg_cocunutpalm1.p3d","str habr.p3d","brg_bird_1.p3d","brg_bird_2.p3d","brg_bird_3.p3d","brg_umbrella_acacia02b.p3d","brg_africandoumpalm_1.p3d","brg_umbrella_acacia04b.p3d","brg_datepalm_4.p3d","brg_datepalm_1.p3d","brg_umbrella_acacia03b.p3d","brg_bottle_4.p3d","brg_aloe1.p3d","brg_umbrella_acacia03.p3d","brg_umbrella_acacia01.p3d","brg_umbrella_acacia04.p3d","brg_aloe2.p3d","brg_umbrella_acacia02.p3d","brg_aloe3.p3d","brg_bottle_1.p3d","brg_datepalm_3.p3d","brg_datepalm_2.p3d","brg_baobab_1.p3d","brg_bottle_2.p3d","brg_bottle_3.p3d"]; DZE_TEMP_treedmg = 1; DZE_Surrender = false; DZE_Quarantine = false;