Taking Items from NPC?

TommyDutch
08 Nov 2015, 13:18
I am trying to have it so you can take items off a sleeping NPC in my game, but i cant figure out how. Any suggestions?

XanMag
08 Nov 2015, 14:51
For me, it kind of depends how many items you want to take off of the NPC. 1? 10? Is the NPC always asleep? Or does the NPC fall asleep?

If it is an awake and a sleeping NPC (which I assume it is), I would make two NPC characters. Whatever triggers the NPC to fall asleep - just add a script that removes the awake NPC (and his objects) from the room and the sleeping one to the room (and a second set of his objects). And vice versa for whatever event that wakes the sleeping NPC. If you try to take objects from the awake NPC, simply put in the inventory tab under 'take' something like "You dare not take that from the NPC if he is awake!" and under the 'take' for the sleeping NPC add a comment like "You quietly take the object from the sleeping NPC." and add the object to your inventory.

There are other ways to do this, but for simplicity's sake, I believe this to be the easiest. Just copy everything and move object and NPC from/to room.

Let me know if you have any questions. If you need me to, I will supply sample code for it.

Good luck.

XanMag

Anonynn
08 Nov 2015, 17:05
Yeah, that's how I'd do it. Make a sleeping NPC and an awake one. Put the items as children on the sleeping npc then the player can "look at NPC" or whatever and see the items he/she/it are holding :)