EDIT: Reworked and renamed.
Pull Request
Items could pick and choose whom they can enter, but never the other way around.
This PR adds functionality to fix this issue, allowing those with the +PICKUP flag the ability to filter what items they can pick up.
Simply override the CanTouchItem(Inventory item) function. Return true to signify the actor can attempt to pick up the item, false if they cannot.
CanTouchItem Virtual
Moderator: GZDoom Developers
- Major Cooke
- Posts: 8170
- Joined: Sun Jan 28, 2007 3:55 pm
- Preferred Pronouns: He/Him
- Location: QZDoom Maintenance Team
CanTouchItem Virtual
Last edited by Major Cooke on Sun Mar 03, 2019 1:29 pm, edited 2 times in total.
- Graf Zahl
- Lead GZDoom+Raze Developer
- Posts: 49056
- Joined: Sat Jul 19, 2003 10:19 am
- Location: Germany
Re: CanPickupItem Virtual
Why did you add this in two places and added a special handling to CallTryPickup? Such things need commenting because it is not apparent why it is necessary.
- Major Cooke
- Posts: 8170
- Joined: Sun Jan 28, 2007 3:55 pm
- Preferred Pronouns: He/Him
- Location: QZDoom Maintenance Team
Re: CanTouchItem Virtual
Simplified and renamed it accordingly so it's delegated to Touch only.
- Major Cooke
- Posts: 8170
- Joined: Sun Jan 28, 2007 3:55 pm
- Preferred Pronouns: He/Him
- Location: QZDoom Maintenance Team
Re: CanTouchItem Virtual
I'm going to introduce CanUseItem as well. I just found myself wishing that I could block certain inventory items from being usable while under a certain condition. I.e. activating powerups while morphed (at least some of them).
The only problem is, this area is a bit more sticky and I'm not entirely sure where I should place the check... Would it be best to just put this in CustomInventory's Use override?
The only problem is, this area is a bit more sticky and I'm not entirely sure where I should place the check... Would it be best to just put this in CustomInventory's Use override?
Code: Select all
//===========================================================================
//
// ACustomInventory :: Use
//
//===========================================================================
override bool Use (bool pickup)
{
if (!pickup && Owner && !Owner.CanUseItem(self))
return false;
return CallStateChain (Owner, FindState('Use'));
}
- Graf Zahl
- Lead GZDoom+Raze Developer
- Posts: 49056
- Joined: Sat Jul 19, 2003 10:19 am
- Location: Germany
Re: CanTouchItem Virtual
No, that won't help much. To pull this off you'd have to wrap the virtual Use call into another function, similar to CallTryPickup and do the check there.
Of course you have to do this for all Use calls everywhere and that's going to be a bit tricky.
Of course you have to do this for all Use calls everywhere and that's going to be a bit tricky.
- Major Cooke
- Posts: 8170
- Joined: Sun Jan 28, 2007 3:55 pm
- Preferred Pronouns: He/Him
- Location: QZDoom Maintenance Team
Re: CanTouchItem Virtual
Understood. That'll be something for me to think about as a separate PR, but not until after this one has been merged.
I also opened a completely new PR when I reworked it to ensure this is clean.
I also opened a completely new PR when I reworked it to ensure this is clean.
- Major Cooke
- Posts: 8170
- Joined: Sun Jan 28, 2007 3:55 pm
- Preferred Pronouns: He/Him
- Location: QZDoom Maintenance Team
Re: CanTouchItem Virtual
New PR to fix merge conflict.
Re: CanTouchItem Virtual
This seems to have gotten added. https://github.com/coelckers/gzdoom/com ... 8ee2fac032