How do I handle loot in a card based game?

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

    I am working on a prototype of an idea where items in the game act as cards. Imagine a regular RPG (for the sake of explanation) where each sword, bow, staff, armor, potion, etc... is just a card similar to card games.

    Now the conundrum I am encountering is how to effectively handle loot without too much hassle (if that is even possible).

    Right now, I am thinking of two ways:

    1- Each item is a separate sprite that belongs to a type family. So MeleeWeapons family in C3 would contain swords and daggers for example while RangedWeapons would contain bows and crossbows. I'd manually apply a sprite appropriate for the item and add family variables such as name, damage, range, durability and skill.

    This would require that when, say, I loot a chest, I would have to generate a random number from 0 to how many types of items I have in the game. Each type has a number ID and that random number decides the family I'll create an item from. Then another random number from 0 to max family member size to choose which item in the family to specifically create for the player.

    2- I create a XML/JSON file with all the items. I load up the JSON/XML file at the start. I create a single sprite called "LootItem" for example that spawns when the player loots the chest from the first example. Then at that moment, I randomly pick an ID from the XML/JSON file instead of the above method. The issue here will be that I need a specific PNG for each item and to my knowledge, I can't reference "X.png" in the JSON to load it in a sprite, I'd have to apply it as an animation or frame and know these animation names/frame number by heart to reference in the code. Not to mention the sprite will need to cater to every possible item type's setup. A weapon may have damage and range but a potion won't need those things for example so it might get confusing as the game gets more complex.

    To me, the first solution is more work generally speaking than the second but it is far easier to maintain. If an item changes I just change the specific sprite for it. The ID ranges would require me to remember to change if let's say a family of items became 5 instead of 6.

    The second method seems to save time at first but the issue with loading the art file would make it a complete mess if I decide to use "X.png" for weaponA instead of WeaponB or if any of the IDs changed for any reason. Not to mention the whole mess from dealing with different types of items that do different things, if not for anything, then when I display a tooltip so I don't display "damage: 5" for an HP potion. I am also not a fan of how you extract information from JSON/XML it just feels off in the events sheet.

    What do you folks think? Any feedback/ideas/suggestions are welcome.

    Note I don't want to jump into coding for this setup.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Probably 1 because 2 means you load all the graphics in one object which is bad for image memory usage. To store the loot though like in an inventory I would use an array.

  • If I were given a case like this, I would separate the card objects as icon from the real objects themselves (weapons, potions, armor, etc.). For card objects, I will just create one sprite with icon images for all the real objects. I prefer playing with JSON for data processing which contains all the attributes of the real objects which are used as references for game logic (Data Driven). The sprite for the card is only used as an icon for the real object. Card sprites also do not store the attributes of the real object. It's all in JSON. I will name all animations according to the object ID in JSON and then group them with animation subfolders so that they are easy to organize, for example:

    subfolder1: weapon, subfolder2: warrior indicating that it is a weapon used by the warrior class and so on.

  • Probably 1 because 2 means you load all the graphics in one object which is bad for image memory usage. To store the loot though like in an inventory I would use an array.

    I didn't think of that, thank you very much for the heads up on this!

    If I were given a case like this, I would separate the card objects as icon from the real objects themselves (weapons, potions, armor, etc.). For card objects, I will just create one sprite with icon images for all the real objects. I prefer playing with JSON for data processing which contains all the attributes of the real objects that are used as references for game logic (Data Driven).

    I am familiar a bit with Data Driven Design. The question here is, how do you link the graphical object with the specific section of JSON that relates to it? You'll need some reference somewhere from/to either. Or is that what the animation name to ID for? So you'll have say "Sword of Darkness +3" in the JSON with "id" : 4 and then name the animation to "4" and reference the JSON data from there?

    If that is the case, how do you make sure that if for any reason you change a reference you update the corresponding ones?

  • Because I rarely think about changing references from master data.

    I prepared everything carefully from the start, then continued my journey

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