CanTouchItem Virtual

Post a reply

Smilies
:D :) :( :o :shock: :? 8-) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :wink: :geek: :ugeek: :!: :?: :idea: :arrow: :| :mrgreen: :3: :wub: >:( :blergh:
View more smilies

BBCode is OFF
Smilies are ON

Topic review
   

Expand view Topic review: CanTouchItem Virtual

Re: CanTouchItem Virtual

by Rachael » Mon Mar 04, 2019 12:38 pm

Re: CanTouchItem Virtual

by Major Cooke » Sun Mar 03, 2019 1:29 pm

New PR to fix merge conflict.

Re: CanTouchItem Virtual

by Major Cooke » Fri Feb 01, 2019 11:42 am

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.

Re: CanTouchItem Virtual

by Graf Zahl » Sun Jan 06, 2019 3:13 pm

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.

Re: CanTouchItem Virtual

by Major Cooke » Sun Jan 06, 2019 2:44 pm

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?

Code: Select all

//===========================================================================
//
// ACustomInventory :: Use
//
//===========================================================================

override bool Use (bool pickup)
{
	if (!pickup && Owner && !Owner.CanUseItem(self))
		return false;
	return CallStateChain (Owner, FindState('Use'));
}

Re: CanTouchItem Virtual

by Major Cooke » Fri Jan 04, 2019 10:27 am

Simplified and renamed it accordingly so it's delegated to Touch only.

Re: CanPickupItem Virtual

by Graf Zahl » Fri Jan 04, 2019 12:40 am

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.

CanTouchItem Virtual

by Major Cooke » Thu Jan 03, 2019 6:21 pm

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.

Top