DepleteBy virtual
* Update inventory_util.zs Added ExtraDepletionBehavior() functionality to TakeInventory and UseInventory * Update inventory.zs Added ExtraDepletionBehavior (int takeAmount) function * Update inventory_util.zs ExtraDepletionBehavior now requires at least 1 item in reserve to work * Replaced ExtraDepletion with DepleteBy Logic Shoutout to RicardoLuis0 * Replaced ExtraDepletion with DepleteBy Logic Shoutout to RicardoLuis0 * Update inventory_util.zs added sv_infiniteinventory checks for takeinventory for custominventory items, restored support for sv_infiniteinventory useinventory items * Update inventory.zs cleaned up DepleteBy - removing unnecessary "--Amount <= 0 && usedItem" check and usedItem bool * Update inventory_util.zs removed unnecessary sv_infiniteinventory check * Update inventory.zs amount is integer, depleteordestroy should occur when amount is less than 1
This commit is contained in:
parent
502af6adb9
commit
9c383e9379
2 changed files with 24 additions and 11 deletions
|
|
@ -923,6 +923,25 @@ class Inventory : Actor
|
|||
}
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
//
|
||||
// Inventory :: DepleteBy
|
||||
//
|
||||
// Handles item depletion when using or taking items
|
||||
//
|
||||
//===========================================================================
|
||||
virtual void DepleteBy(int by)
|
||||
{
|
||||
if (amount < 1 || by >= amount)
|
||||
{
|
||||
DepleteOrDestroy();
|
||||
}
|
||||
else
|
||||
{
|
||||
amount -= by;
|
||||
}
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
//
|
||||
// Inventory :: DepleteOrDestroy
|
||||
|
|
|
|||
|
|
@ -146,11 +146,7 @@ extend class Actor
|
|||
|
||||
if (!fromdecorate)
|
||||
{
|
||||
item.Amount -= amount;
|
||||
if (item.Amount <= 0)
|
||||
{
|
||||
item.DepleteOrDestroy();
|
||||
}
|
||||
item.DepleteBy(amount);
|
||||
// It won't be used in non-decorate context, so return false here
|
||||
return false;
|
||||
}
|
||||
|
|
@ -169,11 +165,10 @@ extend class Actor
|
|||
// Nothing to do here, except maybe res = false;? Would it make sense?
|
||||
result = false;
|
||||
}
|
||||
else if (!amount || amount >= item.Amount)
|
||||
else
|
||||
{
|
||||
item.DepleteOrDestroy();
|
||||
item.DepleteBy(amount);
|
||||
}
|
||||
else item.Amount -= amount;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
|
@ -271,10 +266,9 @@ extend class Actor
|
|||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (--item.Amount <= 0)
|
||||
else
|
||||
{
|
||||
item.DepleteOrDestroy ();
|
||||
item.DepleteBy(1); //useinventory can only really use one item at a time
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue