Prevent drop melee weapon dupe

Also simplified player_addToolbelt by removing unnecessary code.

See: https://github.com/EpochModTeam/DayZ-Epoch/pull/1916
This commit is contained in:
ebayShopper
2017-03-25 16:27:58 -04:00
parent 289a042e1d
commit 87abb204e9
3 changed files with 36 additions and 49 deletions

View File

@@ -14,6 +14,7 @@
[FIXED] Sharpening a knife will no longer delete one if the player already had a fully sharpened knife on their toolbelt (duplicate weapon). [FIXED] Sharpening a knife will no longer delete one if the player already had a fully sharpened knife on their toolbelt (duplicate weapon).
[FIXED] Swimming in air or ground after relog, clothes change and respawn on certain maps. #1913 @Cherdenko [FIXED] Swimming in air or ground after relog, clothes change and respawn on certain maps. #1913 @Cherdenko
[FIXED] Arma cheats enterable on map display and create marker text box. #1915 @BigEgg17 [FIXED] Arma cheats enterable on map display and create marker text box. #1915 @BigEgg17
[FIXED] It is no longer possible to duplicate melee weapons by double clicking to drop and right clicking at the same time. @F507DMT
[NOTE] Fixes below are included in the mission file and server pbo as part of server package 1.0.6.1A (March 10th 2017) [NOTE] Fixes below are included in the mission file and server pbo as part of server package 1.0.6.1A (March 10th 2017)
[FIXED] Fixed food and drink going down 10x faster from melee and other "working" actions. [FIXED] Fixed food and drink going down 10x faster from melee and other "working" actions.

View File

@@ -1,14 +1,25 @@
/*
This script handles three different cases:
1. Adding dayz_onBack to toolbelt
2. Adding primary to toolbelt
3. Removing tool from toolbelt and converting it to primary
*/
if (dayz_actionInProgress) exitWith {localize "str_epoch_player_39" call dayz_rollingMessages;}; if (dayz_actionInProgress) exitWith {localize "str_epoch_player_39" call dayz_rollingMessages;};
dayz_actionInProgress = true; dayz_actionInProgress = true;
private ["_item","_config","_onLadder","_hastoolweapon","_onBack","_text","_create","_config2","_melee2tb","_isOk"];
private ["_item","_config","_onLadder","_text","_create","_config2","_primaryFull","_removed","_toolsFull"];
disableSerialization; disableSerialization;
_item = _this; _item = _this;
_config = configFile >> "cfgWeapons" >> _item; _config = configFile >> "cfgWeapons" >> _item;
_onBack = dayz_onBack in MeleeWeapons; _create = getArray (_config >> "ItemActions" >> "Toolbelt" >> "output") select 0;
_config2 = configFile >> "cfgWeapons" >> _create;
_toolsFull = getNumber (_config2 >> "type") == 131072 && ({getNumber (configFile >> "CfgWeapons" >> _x >> "type") == 131072} count (weapons player)) >= 12;
_primaryFull = getNumber (_config2 >> "type") == 1 && (primaryWeapon player != "");
_removed = false;
//Check if toolbelt is full before removing melee if (player hasWeapon _create or _toolsFull or _primaryFull) exitWith {
if (getNumber (_config >> "type") == 1 && ({getNumber (configFile >> "CfgWeapons" >> _x >> "type") == 131072} count (weapons player)) >= 12) exitWith {
localize "str_player_24" call dayz_rollingMessages; localize "str_player_24" call dayz_rollingMessages;
dayz_actionInProgress = false; dayz_actionInProgress = false;
}; };
@@ -16,57 +27,27 @@ if (getNumber (_config >> "type") == 1 && ({getNumber (configFile >> "CfgWeapons
_onLadder = (getNumber (configFile >> "CfgMovesMaleSdr" >> "States" >> (animationState player) >> "onLadder")) == 1; _onLadder = (getNumber (configFile >> "CfgMovesMaleSdr" >> "States" >> (animationState player) >> "onLadder")) == 1;
if (_onLadder) exitWith {localize "str_player_21" call dayz_rollingMessages; dayz_actionInProgress = false;}; if (_onLadder) exitWith {localize "str_player_21" call dayz_rollingMessages; dayz_actionInProgress = false;};
_hastoolweapon = _item in weapons player; //Make sure the player still has the tool this script was spawned with
_text = getText (_config >> "displayName"); _text = getText (_config >> "displayName");
if (!_hastoolweapon and !_onBack) exitWith {format[localize "str_player_30",_text] call dayz_rollingMessages; dayz_actionInProgress = false;}; if ((dayz_onBack != _item && carryClick) or (!(player hasWeapon _item) && !carryClick)) exitWith {
format[localize "str_player_30",_text] call dayz_rollingMessages;
dayz_actionInProgress = false;
};
call gear_ui_init; call gear_ui_init;
//Add new item if (_item == dayz_onBack && carryClick) then {
_create = getArray (_config >> "ItemActions" >> "Toolbelt" >> "output") select 0; dayz_onBack = "";
_config2 = configFile >> "cfgWeapons" >> _create; carryClick = false;
((findDisplay 106) displayCtrl 1209) ctrlSetText "";
//removing current melee weapon if new melee selected _removed = true;
_melee2tb = "";
if ((_item in ["ItemHatchet","ItemCrowbar","ItemMachete","ItemFishingPole","ItemSledge"]) || _item == DayZ_onBack) then {
if (!carryClick) then {
//free primary slot for new melee (remember item to add after)
switch (primaryWeapon player) do {
case "MeleeHatchet": {if !("ItemHatchet" in weapons player) then {player removeWeapon "MeleeHatchet"; _melee2tb = "ItemHatchet";};};
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": {if !("ItemSledge" in weapons player) then {player removeWeapon "MeleeSledge"; _melee2tb = "ItemSledge";};};
};
} else {
if (DayZ_onBack != "" || _item == DayZ_onBack) then {
switch DayZ_onBack do {
case "MeleeHatchet": {if !("ItemHatchet" in weapons player) then {dayz_onBack = ""; _melee2tb = "ItemHatchet";};};
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": {if !("ItemSledge" in weapons player) then {dayz_onBack = ""; _melee2tb = "ItemSledge";};};
};
carryClick = false;
((findDisplay 106) displayCtrl 1209) ctrlSetText "";
};
};
}; };
//Remove melee magazines (BIS_fnc_invAdd fix) (add new melee ammo to array if needed) if (_removed or {([player,_config] call BIS_fnc_invRemove) == 1}) then {
{player removeMagazines _x} count ["Hatchet_Swing","Crowbar_Swing","Machete_Swing","Fishing_Swing","Sledge_Swing"]; player addWeapon _create;
_isOk = [player,_config2] call BIS_fnc_invAdd;
if (_isOk) then {
player removeWeapon _item;
//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;
};
} else { } else {
closeDialog 0; closeDialog 0;
localize "str_player_24" call dayz_rollingMessages; format[localize "str_player_30",_text] call dayz_rollingMessages;
}; };
dayz_actionInProgress = false; dayz_actionInProgress = false;

View File

@@ -5,6 +5,11 @@ _item = _this;
_config = configFile >> "CfgWeapons" >> _item; _config = configFile >> "CfgWeapons" >> _item;
_droppedType = getText (_config >> "droppeditem"); _droppedType = getText (_config >> "droppeditem");
//Make sure the player still has the tool this script was spawned with
if ((dayz_onBack != _item && carryClick) or (!(player hasWeapon _item) && !carryClick)) exitWith {
format[localize "str_player_30",getText (_config >> "displayName")] call dayz_rollingMessages;
};
_onLadder = (getNumber (configFile >> "CfgMovesMaleSdr" >> "States" >> (animationState player) >> "onLadder")) == 1; _onLadder = (getNumber (configFile >> "CfgMovesMaleSdr" >> "States" >> (animationState player) >> "onLadder")) == 1;
if (_onLadder) exitWith { localize "str_player_21" call dayz_rollingMessages; }; if (_onLadder) exitWith { localize "str_player_21" call dayz_rollingMessages; };
if (dayz_actionInProgress) exitWith { localize "str_player_actionslimit" call dayz_rollingMessages; }; if (dayz_actionInProgress) exitWith { localize "str_player_actionslimit" call dayz_rollingMessages; };
@@ -14,7 +19,7 @@ call gear_ui_init;
_consume = ([] + getArray (_config >> "magazines")) select 0; _consume = ([] + getArray (_config >> "magazines")) select 0;
if ((dayz_onBack != "") && (dayz_onBack in MeleeWeapons) && carryClick) then { if (_item == dayz_onBack && carryClick) then {
switch DayZ_onBack do { switch DayZ_onBack do {
case "MeleeHatchet": {_item = "ItemHatchet"; dayz_onBack = "";}; case "MeleeHatchet": {_item = "ItemHatchet"; dayz_onBack = "";};
case "MeleeCrowbar": {_item = "ItemCrowbar"; dayz_onBack = "";}; case "MeleeCrowbar": {_item = "ItemCrowbar"; dayz_onBack = "";};