Files
DayZ-Epoch/SQF/dayz_code/compile/player_harvest.sqf
icomrade f186e256cb Tree chopping changes
Allow player to get more than 1 item out of a single tree. Using ItemLog
would allow the player to get too much wood if using a hatchet so I
changed it back to PartWoodPile.
2016-08-10 13:06:20 -04:00

48 lines
1.5 KiB
Plaintext

private ["_unit","_ammo","_distance","_weapon","_projectile","_endPos","_dir","_doWait","_vel"];
_unit = _this select 0;
_weapon = _this select 1;
_ammo = _this select 4;
_projectile = _this select 6;
if (_ammo isKindOf "Hatchet_Swing_Ammo" || _ammo isKindOf "Chainsaw_Swing_Ammo") then {
_findNearestTree = [];
{
if (("" == typeOf _x) && {alive _x}) then {
_objName = _x call fn_getModelName;
// Exit since we found a tree
if (_objName in dayz_trees) exitWith { _findNearestTree set [count _findNearestTree,_x]; };
};
} count nearestObjects [getPosATL player, [], 20];
//diag_log ("POSITION: " + str(_endPos));
if (count _findNearestTree > 0) then {
_tree = _findNearestTree select 0;
// get 2d distance
_distance2d = [player, _tree] call BIS_fnc_distance2D;
if(_distance2d <= 5) then {
// damage must be going down
_damage = damage _tree;
if (DZE_TEMP_treedmg < _damage) then {
if (_damage < 0.99 && {(random 1) > 0.7}) then {
PVDZ_objgather_Knockdown = [_tree,player]; // Ask server to setDamage on tree
publicVariableServer "PVDZ_objgather_Knockdown";
};
_itemOut = if (_ammo isKindOf "Chainsaw_Swing_Ammo") then {"PartWoodLumber"} else {"PartWoodPile"}; // Log can be crafted to > 2x plank > 4x woodpile
_itemOut call fn_dropItem;
_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;
};
};
};