Adding items to npc's

Avatar

By r1g1l 4 May 2016 19:16

New member · 3 comments

Hey everybody, I was wondering how i could add an item in an npc's inventory.
I have copied the core.components.event.actions.Player().add_item() function, with few modifications,  to the Npc class
as a working fix for testing purposes on my own repo.
But is their already an appropriate way to do this that i haven't stumbled across yet?

Avatar

By ShadowApex 6 May 2016 20:18

Lead Developer · 374 comments

Hi,

There's actually no current way to add items to an NPC's inventory right now, so I think you're on the right track with using the add_item action as a base. Currently items are added to the player's inventory via core.components.event.actions.player.add_item, as you mentioned in your comment.

I think it might actually be better if we moved the add_item() logic itself into the base Player class in core.components.player, and then just call that method in the event action. Since the NPC class inherits from the Player class, both would have the add_item method that way, and we could create map event actions for both adding items to the player and npcs.


Avatar

By r1g1l 7 May 2016 22:20

New member · 3 comments

That sounds like the best way to do it.
   Now that i think about it, that would mean we could get rid of the 'game' argument,
since it would always be in the same namespace as the inventory it is trying to change.