How do I create a random loot system?

0 favourites
  • 4 posts
From the Asset Store
Fully commented source code/event sheet & sprites to create a space shooter game
  • To start off, I need to say I am not an experienced game designer whatsoever. If there's some complex way to go about solving this that I don't know, it's probably because of my own ignorance of concepts of programming and math. I am really familiar with algebra, and I get all basic calculations with variables and such. Just not much more complex things beyond that.

    Anyways, I want to try creating a randomized loot system, akin to Diablo or Borderlands. When the enemy dies, the player awarded with an item. That item will have possible types, like a weapon or armor. That weapon or armor will have its own qualities that are randomized, in the form of affixes. Affixes will be any sort of modifier, like a bonus to damage, or resistance, or some key stat.

    My objectives are to:

    A.Randomly generate items with varying values and stats

    B.Allow for weapons and armor that can have a wide array of stats but only randomly selected stats will roll on that item (Limited # of affixes)

    C.Create items that can be saved and loaded, without performance hits during creation and loading

    D.Allow for unique items and affixes (I.E., named items with own personal trait unique solely to that specific item)

    I've been spending a few days thinking of what ways to go about doing this, and I've been searching around the forums as well. I was thinking of making parent objects ("item_weapon," "item_armor," "item_consumable") and creating instances of those with instance variables to contain the affixes. I figured for each one of those items, I could have an instance variable for each possible affix, but I realized that each item would have tons of instance variables because of the sheer amount of possible affixes on them, and it would be difficult to display only the affixes that actually have values. I couldn't see way to (for example) loop through each instance variable for an item and see which ones actually rolled and have a value, and then display only those values in the item description. (if that could actually work somehow, please let me know)

    So I'm little bit lost. I guessed another solution might lie in arrays but I'm unsure of how to use arrays for this. So my main questions are:

    1.Could my old method work, using instance variables that are all present for that object but only some have value?

    2.Could arrays be used in some way?

    3.Do I need to learn to script in order to make this work?

    (Thank you to anyone who replies, I will happily elaborate if I was too vague or missing any points or information)

  • If you need a system that can handle a ton of items like something in the realms of Diablo. I would make files for treasure tables probably using this CSV plugin https://www.scirra.com/forum/plugin-csv-csv2array-csv2dictionary_t64326?&hilit=csv. I would tag the treasure table number/level/tier to the enemy or scale of random tables to choose. For the base item set stat scales and probability value to use magic or improved item and then use similar table for affixes (example tier1 affixes or tier1 shield affixes).

    About Diablo 2 loot generator

    I don't think there would be much lag at least if the files are on local disk, but if there would you could generate the items when the map loads.

    And my answers for the questions.

    1. Not the best way. I would make array or dictionary object container for the enemy where to generate the items from external sources.

    2. They could not sure you necessarily need to.

    3. No.

    Not sure if this helped, but there are quite a few ways on doing this and I don't know what is the optimal.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • kyatric did this awhile ago I guess it is a great place to start.

  • Excellent! Thank you very much to both of you, you helped immensely. Exactly what I was looking for.

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