-
Notifications
You must be signed in to change notification settings - Fork 310
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
rework fn_useItem.sqf to use edible attribute (#578)
* rework fn_useItem.sqf to use edible attribute * Remove redundant case * Get the "edible" value from the config once
- Loading branch information
1 parent
44a18d3
commit 9b98410
Showing
1 changed file
with
20 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,20 +6,31 @@ | |
Description: | ||
Main function for item effects and functionality through the player menu. | ||
*/ | ||
private "_item"; | ||
disableSerialization; | ||
if ((lbCurSel 2005) isEqualTo -1) exitWith {hint localize "STR_ISTR_SelectItemFirst";}; | ||
_item = CONTROL_DATA(2005); | ||
private _item = CONTROL_DATA(2005); | ||
private _edible = M_CONFIG(getNumber, "VirtualItems", _item, "edible"); | ||
|
||
if !(_edible isEqualTo -1) exitWith { | ||
if ([false, _item, 1] call life_fnc_handleInv) then { | ||
private _sum = life_hunger + _edible; | ||
|
||
life_hunger = (_sum max 5) min 100; //never below 5 or above 100 | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
Leigham
Contributor
|
||
|
||
[] call life_fnc_p_updateMenu; | ||
[] call life_fnc_hudUpdate; | ||
}; | ||
}; | ||
|
||
switch (true) do { | ||
case (_item in ["waterBottle","coffee","redgull"]): { | ||
if ([false,_item,1] call life_fnc_handleInv) then { | ||
case (_item in ["waterBottle", "coffee", "redgull"]): { | ||
if ([false, _item, 1] call life_fnc_handleInv) then { | ||
life_thirst = 100; | ||
if (LIFE_SETTINGS(getNumber,"enable_fatigue") isEqualTo 1) then {player setFatigue 0;}; | ||
if (_item isEqualTo "redgull" && {LIFE_SETTINGS(getNumber,"enable_fatigue") isEqualTo 1}) then { | ||
if (LIFE_SETTINGS(getNumber, "enable_fatigue") isEqualTo 1) then {player setFatigue 0;}; | ||
if (_item isEqualTo "redgull" && {LIFE_SETTINGS(getNumber, "enable_fatigue") isEqualTo 1}) then { | ||
[] spawn { | ||
life_redgull_effect = time; | ||
titleText[localize "STR_ISTR_RedGullEffect","PLAIN"]; | ||
titleText[localize "STR_ISTR_RedGullEffect", "PLAIN"]; | ||
player enableFatigue false; | ||
waitUntil {!alive player || ((time - life_redgull_effect) > (3 * 60))}; | ||
player enableFatigue true; | ||
|
@@ -55,7 +66,7 @@ switch (true) do { | |
|
||
case (_item isEqualTo "spikeStrip"): { | ||
if (!isNull life_spikestrip) exitWith {hint localize "STR_ISTR_SpikesDeployment"; closeDialog 0}; | ||
if ([false,_item,1] call life_fnc_handleInv) then { | ||
if ([false, _item, 1] call life_fnc_handleInv) then { | ||
[] spawn life_fnc_spikeStrip; | ||
closeDialog 0; | ||
}; | ||
|
@@ -77,24 +88,10 @@ switch (true) do { | |
closeDialog 0; | ||
}; | ||
|
||
case (_item in ["apple","rabbit","salema","ornate","mackerel","tuna","mullet","catshark","turtle_soup","hen","rooster","sheep","goat","donuts","tbacon","peach"]): { | ||
if (!(M_CONFIG(getNumber,"VirtualItems",_item,"edible") isEqualTo -1)) then { | ||
if ([false,_item,1] call life_fnc_handleInv) then { | ||
_val = M_CONFIG(getNumber,"VirtualItems",_item,"edible"); | ||
_sum = life_hunger + _val; | ||
switch (true) do { | ||
case (_val < 0 && _sum < 1): {life_hunger = 5;}; //This adds the ability to set the entry edible to a negative value and decrease the hunger without death | ||
case (_sum > 100): {life_hunger = 100;}; | ||
default {life_hunger = _sum;}; | ||
}; | ||
}; | ||
}; | ||
}; | ||
|
||
default { | ||
hint localize "STR_ISTR_NotUsable"; | ||
}; | ||
}; | ||
|
||
[] call life_fnc_p_updateMenu; | ||
[] call life_fnc_hudUpdate; | ||
[] call life_fnc_hudUpdate; |
Shouldn't it be?
life_hunger = (_sum max 100) min 5;