question

kospy avatar image
kospy asked

NPC inventory and drop table

My goal is to generate an inventory for each spawned NPC, similar to Fallout3 or Skyrim.

The inventory will be used to equip the NPC (melee/ranged weapon, shield or not, apparel for each body slot).

I thought about using container with some drop tables however I doesn't seem possible to generate an item list without granting the container item to the player inventory.

Is there a solution other than granting the container item to one player, retrieving the item list with UnlockContainerInstance or UnlockContainerItem and revoke each granted items after? Seem pretty cumbersome and unefficient (API requests).

Another idea is to use EvaluateRandomResultTable or GetRandomResultTables, but I didn't find a way to use it for what I want to do. A simple function like "EvaluateResultTable" for a container item ID would be much better for me.

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
brendan avatar image
brendan answered

The inventory system is designed around adding inventory to a player or a player's character - it's not really designed for NPCs, since they're not defined entities in our service. What many games in that genre do is actually to have defined sets of items for different NPC groups (gangs, etc.), with one or two items on each of them being randomly generated - the rest is just their "standard set". But there are others, like the Diablo series, where treasure from monsters is much more randomly generated. In any case though, your best bet would be to just use GetRandomResultTables on your server to get the tables, and use them in your server code to do random draws of items, rather than calling EvaluateRandomResultTable multiple times for each NPC. If you're using Cloud Script, it's going to come down to how many items you need to give the NPC - if it'll work in the API/time limits, then you could use EvaluateRandomResultTable there. Otherwise, you could either use GetRandomResultTables and do a more manual evaluation in the script.

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.