How to prevent player from examining items on NPCs?

I think the title pretty much says it all… like when a NPC is carrying an item (by + in NPC declaration), or if I give the NPC something (item.moveInto), I can still examine and otherwise interact with the items. Why is that the case? Or is there a separate “hide it from others’ view” property on items? Thanks!

Edit: For my particular use case I was able to use class Hidden and “discover” the item when the NPC gives it to the player; just wondering if there’s any better way to achieve this… after all, it doesn’t make sense that one can examine things someone else is holding.

Thanks!

Much of the behaviour for interacting with items in an NPC’s inventory is disallowed by their afterAction method. If you’ve overriden this method in the NPC or any of their ActorStates, make sure you call inherited(). I’ve been caught out by that before…

That said, examining, and other actions that don’t involve taking the item off the NPC are not disallowed by default.

If the desired behaviour is that the NPC should “give” the player character something that the player will not previously have seen in their inventory, why not start with the item in nowhere instead of in the NPC who gives it? (Place the declaration for the item at the very top or bottom of the file, or otherwise outside any nested +s.)

Wwwwwwwwwwwhy not?

If there’s something about it that you want to hide until after the player is holding the item, you can use IF statements.

desc() { if(location==RentACop) "The rent-a-cop is brandishing a huge taser. I wouldn't mess with him while he's got this thing. "; else if(location==gPlayerChar) "With big tasers come big responsibility. Try not to zap any innocents. "; else "Who left this lying around? Seems pretty dangerous. You should pick it up before someone gets hurt. "; //note this doesn't account for the situation where this is in a container that is held by the player }

I guess I just had the idea that “examine” is supposed to be looking at the item at close distance, hence if the npc has something on them, it could very well be inside their pocket or otherwise hidden from view, so that the player cannot see them.

However, I took your advice and simply initiated the object to be nowhere, and everything worked great. Thanks a lot!

I know what you mean. A synonym for ‘examine’ is actually ‘look at’ or ‘l at’, which seems more apt to me, but also requires more typing.

I think most modern games use it to really mean “describe [object] to me”.

You’re welcome. :smiley: