mirror of
https://github.com/EpochModTeam/DayZ-Epoch.git
synced 2026-02-21 15:40:50 +03:00
Fix tool loss due to duplicate matchbox and knife issue #1849
This commit is contained in:
@@ -12,18 +12,7 @@ _this: string - toolbelt item classname to check and add
|
||||
How to use:
|
||||
"ItemSledge" call player_addDuplicateTool;
|
||||
*/
|
||||
private ["_bag","_dropOnFloor"];
|
||||
|
||||
_dropOnFloor = {
|
||||
private ["_location","_object"];
|
||||
systemChat format[localize "str_epoch_player_314",_this];
|
||||
_location = player modeltoworld [0,0.3,0];
|
||||
if ((_location select 2) < 0) then {_location set [2,0];};
|
||||
_object = createVehicle ["WeaponHolder",_location,[],0,"CAN_COLLIDE"];
|
||||
if (surfaceIsWater _location) then {_object setPosASL (getPosASL player);} else {_object setPosATL _location;};
|
||||
_object setVariable ["permaLoot",true];
|
||||
_object addWeaponCargoGlobal [_this,1];
|
||||
};
|
||||
private "_bag";
|
||||
|
||||
if (_this in items player) then {
|
||||
_bag = unitBackpack player;
|
||||
@@ -31,7 +20,8 @@ if (_this in items player) then {
|
||||
systemChat format[localize "str_epoch_player_313",_this];
|
||||
_bag addWeaponCargoGlobal [_this,1];
|
||||
} else {
|
||||
_this call _dropOnFloor;
|
||||
[_this,2,1] call fn_dropItem;
|
||||
systemChat format[localize "str_epoch_player_314",_this];
|
||||
};
|
||||
} else {
|
||||
//Remove melee magazines (BIS_fnc_invAdd fix)
|
||||
@@ -39,7 +29,8 @@ if (_this in items player) then {
|
||||
|
||||
if !([player,_this] call BIS_fnc_invAdd) then {
|
||||
systemChat localize "str_epoch_player_107";
|
||||
_this call _dropOnFloor;
|
||||
[_this,2,1] call fn_dropItem;
|
||||
systemChat format[localize "str_epoch_player_314",_this];
|
||||
};
|
||||
true call dz_fn_meleeMagazines;
|
||||
};
|
||||
@@ -1,11 +1,13 @@
|
||||
private ["_item","_pos","_nearByPile","_holder"];
|
||||
private ["_amount","_item","_pos","_nearByPile","_holder","_type"];
|
||||
|
||||
//Radius to search for holder
|
||||
#define PILE_SEARCH_RADIUS 2
|
||||
//Location to offset the holder
|
||||
#define PILE_OFFSET [0,0,0]
|
||||
|
||||
_item = _this;
|
||||
_item = _this select 0;
|
||||
_type = _this select 1;
|
||||
_amount = _this select 2;
|
||||
_holder = objNull;
|
||||
|
||||
//Lets get the location of the player in the world
|
||||
@@ -32,7 +34,11 @@ if (count _nearByPile == 0) then {
|
||||
};
|
||||
|
||||
//Add the item to the holder or to the newly created holder.
|
||||
_holder addMagazineCargoGlobal [_item,1];
|
||||
switch _type do {
|
||||
case 1: {_holder addMagazineCargoGlobal [_item,_amount];};
|
||||
case 2: {_holder addWeaponCargoGlobal [_item,_amount];};
|
||||
case 3: {_holder addBackpackCargoGlobal [_item,_amount];};
|
||||
};
|
||||
|
||||
//Revel the item
|
||||
player reveal _holder;
|
||||
49
SQF/dayz_code/compile/fn_dynamicTool.sqf
Normal file
49
SQF/dayz_code/compile/fn_dynamicTool.sqf
Normal file
@@ -0,0 +1,49 @@
|
||||
private ["_chance","_dynamic","_hasTool","_message","_needed","_newItem","_oneLeft","_remaining","_toolBelt"];
|
||||
|
||||
_chance = _this select 1;
|
||||
_toolBelt = items player;
|
||||
|
||||
switch (_this select 0) do {
|
||||
case "matches": {
|
||||
_dynamic = dayz_matchboxCount;
|
||||
_newItem = "qtyRemaining";
|
||||
_needed = DayZ_Ignitors;
|
||||
_message = "str_info_limitedbox";
|
||||
};
|
||||
case "knives": {
|
||||
_dynamic = dayz_knifeDulling;
|
||||
_newItem = "sharpnessRemaining";
|
||||
_needed = Dayz_Gutting;
|
||||
_message = "str_info_bluntknife";
|
||||
};
|
||||
};
|
||||
|
||||
{
|
||||
_hasTool = _x in _toolBelt;
|
||||
if (_hasTool && !_dynamic) exitWith {};
|
||||
|
||||
_oneLeft = _x in ["Item1Matchbox","ItemKnife1"];
|
||||
_remaining = getText (configFile >> "CfgWeapons" >> _x >> _newItem);
|
||||
|
||||
// Use lowest quantity matches first to prevent duplicate tool being added
|
||||
// Use knife with least remaining uses first, except dull knife
|
||||
if (_hasTool && (!(_remaining in _toolBelt) or _oneLeft)) exitWith {
|
||||
if (_x in ["ItemKnife","ItemMatchbox"]) then {
|
||||
if ([_chance] call fn_chance) then {
|
||||
player removeWeapon _x;
|
||||
player addWeapon _remaining;
|
||||
localize _message call dayz_rollingMessages;
|
||||
};
|
||||
} else {
|
||||
player removeWeapon _x;
|
||||
if (_remaining in _toolBelt) then {
|
||||
//Drop dull knife or empty matchbox if player already has one. Prevents duplicate tool.
|
||||
player removeWeapon _remaining;
|
||||
[_remaining,2,1] call fn_dropItem;
|
||||
};
|
||||
player addWeapon _remaining;
|
||||
};
|
||||
};
|
||||
} forEach _needed;
|
||||
|
||||
_hasTool
|
||||
@@ -7,7 +7,7 @@ scriptName "Functions\misc\fn_selfActions.sqf";
|
||||
if (dayz_actionInProgress) exitWith {};
|
||||
private ["_canPickLight","_text","_unlock","_lock","_totalKeys","_temp_keys","_temp_keys_names",
|
||||
"_hasKey","_oldOwner","_hasAttached","_isZombie","_isHarvested","_isMan","_isFuel","_hasRawMeat","_hastinitem","_player_deleteBuild",
|
||||
"_player_lockUnlock_crtl","_displayName","_hasIgnators","_menu","_menu1","_allowTow","_liftHeli","_found","_posL","_posC","_height","_attached",
|
||||
"_player_lockUnlock_crtl","_displayName","_hasIgnitors","_menu","_menu1","_allowTow","_liftHeli","_found","_posL","_posC","_height","_attached",
|
||||
"_combi","_findNearestGen","_humanity_logic","_low_high","_cancel","_buy","_buyV","_humanity","_traderMenu","_warn","_typeOfCursorTarget",
|
||||
"_isVehicle","_isBicycle","_isDestructable","_isGenerator","_ownerID","_isVehicletype","_hasBarrel","_hasFuel20","_hasFuel5","_hasEmptyFuelCan",
|
||||
"_itemsPlayer","_hasToolbox","_hasbottleitem","_isAlive","_isPlant","_istypeTent","_upgradeItems","_isDisallowRefuel","_isDog",
|
||||
@@ -453,8 +453,8 @@ if (!isNull _cursorTarget && !_inVehicle && !_isPZombie && (player distance _cur
|
||||
};
|
||||
//other tents
|
||||
if (_istypeTent) then {
|
||||
_hasIgnators = {_x in DayZ_Ignitors} count _itemsPlayer > 0;
|
||||
if ((_hasFuel20 or _hasFuel5 or _hasBarrel) && _hasIgnators) then {
|
||||
_hasIgnitors = {_x in DayZ_Ignitors} count _itemsPlayer > 0;
|
||||
if ((_hasFuel20 or _hasFuel5 or _hasBarrel) && _hasIgnitors) then {
|
||||
if (s_player_destroytent < 0) then {
|
||||
s_player_destroytent = player addAction [localize "str_actions_self_destroytent", "\z\addons\dayz_code\actions\player_destroyTent.sqf",_cursorTarget, 0, false, true];
|
||||
};
|
||||
|
||||
@@ -34,7 +34,7 @@ if (_ammo isKindOf "Hatchet_Swing_Ammo" || _ammo isKindOf "Chainsaw_Swing_Ammo")
|
||||
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;
|
||||
[_itemOut,1,1] call fn_dropItem;
|
||||
|
||||
_distance = 60;
|
||||
[player,_distance,false,getPosATL player] spawn player_alertZombies;
|
||||
|
||||
Reference in New Issue
Block a user