-
Notifications
You must be signed in to change notification settings - Fork 553
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ExtraDepletionBehavior #2615
base: master
Are you sure you want to change the base?
ExtraDepletionBehavior #2615
Conversation
Added ExtraDepletionBehavior() functionality to TakeInventory and UseInventory
Added ExtraDepletionBehavior (int takeAmount) function
ExtraDepletionBehavior now requires at least 1 item in reserve to work
hmm, what about renaming it to DepleteBy and moving the whole depletion logic to it?
|
Moving the depletion logic to it was the original concept (see here: https://forum.zdoom.org/viewtopic.php?t=79266 and combining the two would definitely be the way to go. My idea was more a functioning proof of concept. Hmm. |
Shoutout to RicardoLuis0
Shoutout to RicardoLuis0
Alright I've just changed HandleDecrement to DepleteBy behavior as per @RicardoLuis0 's suggestion. Also tested it privately and it works perfectly. Though I am not sure if usedItem is necessary or not, I only threw it in because it was present in UsedInventory, and I want to try an avoid any inadvertent effects from not including it. |
wouldn't this |
|
Don't forget there's infinite ammo powerups, and the "infinite ammo/items" gameplay options. |
added sv_infiniteinventory checks for takeinventory for custominventory items, restored support for sv_infiniteinventory useinventory items
cleaned up DepleteBy - removing unnecessary "--Amount <= 0 && usedItem" check and usedItem bool
Alright, both are done. Additionally threw in a sv_infiniteinventory check for custominventory items when they are taken with the cvar active. Tested, and all good, so that should be it at the moment. |
if (notakeinfinite && | ||
(sv_infiniteammo || (player && FindInventory('PowerInfiniteAmmo', true))) && (item is 'Ammo')) | ||
(sv_infiniteammo || (player && FindInventory('PowerInfiniteAmmo', true))) && (item is 'Ammo') | ||
|| sv_infiniteinventory && item is 'CustomInventory') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was wrong. TakeInventory is never called if sv_infiniteinventory is true, so this part alone should be reverted. Otherwise this could cause some problems.
Sorry about that.
//=========================================================================== | ||
virtual void DepleteBy(int by) | ||
{ | ||
if (!amount || by >= amount) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The check here should be amount < 1
, not !amount
.
amount
is an integer and it can be negative.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Both changes pushed now.
removed unnecessary sv_infiniteinventory check
amount is integer, depleteordestroy should occur when amount is less than 1
ExtraDepletionBehavior is a dynamic way of expanding upon TakeInventory and UseInventory* with additional behaviour, whilst also preventing code bloat from custom inventory use and take functions.
Extremely useful for weight systems, requires at least 1 item in reserve to function (use DetachFromOwner for when the final item is dropped)
*SetInventory should also be theoretically supported, at least on the takeinventory side