How do I loot items?

0 favourites
  • 3 posts
From the Asset Store
Perfect, complete, easy to use to use, out-of-the-box inventory system
  • Hi

    I've been thinking lately how to create a loot system. I would like a given monster to drop items assigned to it. While it's easy to do, after creating families for enemies and items, I don't know how to combine it with each other. I tried creating different variables for item families or enemies but still nothing.

    For example, a Goblin should drop a sword when killed, so for sword I created a variable ID=0, but now how to force the game that when the goblin's life is equal to or less than 0, it creates an object after the item's ID, i.e. in this case ID=0, which is a sword.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • It's easier if you use text variables - Loot=sword. Otherwise, if you have many loot types, you'll forget what all those numerical IDs correspond to.

    So if you define this Loot variable on the Enemies family, you can specify which enemy carries which loot, either directly on the layout, or when enemies are spawned.

    When an enemy is killed in Enemies On Destroyed (or in a similar event) you can do this:

    Enemies compare variable Loot=sword : Spawn a sword
    Else Enemies compare variable Loot=gold : Spawn a coin
    

    You can even put the exact name of the sprites which should be spawned in the Loot variable, and then use "Create object by name" action.

    Enemies On Destroyed : Create Object By Name Enemies.Loot
    
  • And this is what i want too achive... Thanks dop2000 :)!

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)