• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Random Item Generation

S

SYSTEM_FAILURE

Guest
Hey Guys, this is my 1st post on this forum. I've been using game maker studio 2 for about 2 years now, I've progressed a lot by reading books, youtube videos, and forums posts. I'm working on a Rogue-lite action RPG and I'm pleased with the progress I've made so far, however i have ran into a problem which im hoping you guys can advise on.

Problem 1.
I would like to have a randomised loot system in the game. Much like Diablo, grim dawn, torchlight e.t.c, where an item can drop with given stats, then the same item can drop again with different stats. Im not sure how to allocate a unique ID to each new item generated. I've been experimenting with arrays, ds_lists, ds_maps and ds_grids and would really appreciate some advice on this one :)

Problem 2.
There will be a total of 12 main types of items (to determine equipment slot).
There will be a total of 6 different rarities of item. (Rarity already implemented)
The rarity will determine how many stats an item has.
The item needs to pick 'x' number of stats to apply to the item on creation.
I've divided the item stats into 2 groups, random stats, and generic stats.
Generic stats are present in all items, like the item sprite, the item sell value, name, rarity e.t.c
Randomised stats are like strength, attackSpeed, criticalDamage e.t.c (there's a list of 50+)
The item will be given a 'level' relative to the player, and the stat values will be relative to the item level (to scale as character progresses)
Some items types will have default stats, like a weapon would have min & max damage, but a piece of armour wouldn't have this. The list goes on
I would like some advice on how i should tackle the allocation of stats each time an item is generated. :)

Problem 3.
Storage and saving. What do i need to be doing in order to using the above system so that it is efficient.

I am new to programming language but ultra-keen to learn and really appreciate any advice
 
Last edited by a moderator:

Nocturne

Friendly Tyrant
Forum Staff
Admin
I would like to have a randomised loot system in the game. Much like Diablo, grim dawn, torchlight e.t.c, where an item can drop with given stats, then the same item can drop again with different stats. Im not sure how to allocate a unique ID to each new item generated. I've been experimenting with arrays, ds_lists, ds_maps and ds_grids and would really appreciate some advice on this one :)
What do you mean by a random ID? You want a random unique identifier string/value? Or a random ID name like "fire breathing dirk of the greater gods" and stuff?

I would like some advice on how i should tackle the allocation of stats each time an item is generated. :)
Okay... From the sound of things you have this very well thought out, so now, just go through the list and make each part one at a time. Perosnally I'd use a DS grid, where the first column of the grid is the item type, the second the rarity, the third the level, and then the rest of the columns are each a different stat (ie: use the DS list like a table). You can then check the item rarity and/or level to find out how many stats it should have and retrieve them from the next columns of the ds grid. The rest of it just maths, and there's a whole lot been written on this! Good video here, actually:

Storage and saving. What do i need to be doing in order to using the above system so that it is efficient.
If you go with a DS grid approach (or any data structure) you can write out the contents as a string and then save them to a file. This is not exactly efficient as the string produced has a lot of additional data that isn't related to just the contents of the structure. However it works well and is easy to implement. The other way to go is to start using buffers for everything. This is a LOT more complex, but will permit a lot more data to be saved in a much smaller file, especially if you start using bit-shifting and stuff to compress the data.
 
Last edited:
S

SYSTEM_FAILURE

Guest
Hi Nocture, thanks for the reply, I was beginning to think no one would.
What do you mean by a random ID? You want a random unique identifier string/value? Or a random ID name like "fire breathing dirk of the greater gods" and stuff?
Well each item has to be given a unique ID since a situation could occur where you have 2 of the same item in your inventory, the inventory uses the ID to move items around carrying all their associated stats with it when moving them from slot to slot. But if i have 2 items with the same ID this breaks the inventory. The IDs purpose is to store unique information on that item. I've recently been given some tips on how i can handle this so I shall spend some time figuring that out.

I think its best i avoid using buffers since I am relatively new to programming language and I already feel like this is difficult. But i do enjoy the difficulty, I love problem solving and I'm obsessive too. It's a great feeling when you finally solve this issue especially when you do it alone without and guide. But yeah this is the 1st time i felt like i needed some help. I have some replies on the facebook user group which i will look into this weekend. I think perhaps the questions i asked are too much, maybe its better if i ask a smaller more specific question it will be easier for you guys to answer :)
 

Nocturne

Friendly Tyrant
Forum Staff
Admin
I think perhaps the questions i asked are too much, maybe its better if i ask a smaller more specific question it will be easier for you guys to answer
Yup, I agree. You'll always get better and faster replies on single questions with a concrete goal. Good luck with your game!
 
Top