Logic behind Loot generation

For discussions about game development that does not fit in any of the other topics.
Post Reply
Zykal
Posts: 31
Joined: Thu Nov 29, 2012 4:38 am

Logic behind Loot generation

Post by Zykal »

I'm working on a loot generator, just the logic for the moment.

Basically I have diff items like swords axes dagger etc etc , which have different tiers of quality, craft quality, worth, speed, att, def,

a dagger of quality tier 1 can have a min damage of 0-1 and a max damage of 2-4

All of these are viable 0-4,0-3,0-2,1-4,1-3,1-2

A tier 2 can have a min damage of 2-4 and a max of 4-6

2-4,2-5,2-6,3-4,3-5,3-6,4-4,4-5,4-6,

so an dagger might look like these as far as stats

Dagger - quality tier 1 - Min damage 0 - max damage 3 - Att +3 - Def +1 - Speed 2 - Worth 12893 - Craft quality 4 -

Or

Dagger - quality tier 1 - Min damage 1 - max damage 3 - Att +6 - Def +4 - Speed 1 - Worth 18341 - Craft quality 8 -

The possibilities are immense really.

I am having 2 issues. One where and how do i store all this information? Do i store it in the DB for each weapon type and quality tier?

So i'd have DB entries for dagger

Quality tier - Min Min Damage - Max Min Damage -Min Max Damage- Max Max damage- Min ATT -Max Att -Min Def -Max def
1 0 1 2 4 0 4 0 8
2 2 4 4 6 2 6 3 12
and so on and so on?

So then once it picked a quality tier then a weapon in this case dagger it'd goto the quality tier then randomly start picking attributes?


The other issue I am having is that say on a quality tier 2 dagger by default the chance of getting 2 3 or 4 for the minimum damage is 33% what If I want to make chance of getting a 2 50%, 3 30%, and a 4 20%.


thanks a ton for all the help this community has been in the past i've learned so much reading here.
Zykal
Posts: 31
Joined: Thu Nov 29, 2012 4:38 am

Re: Logic behind Loot generation

Post by Zykal »

Must be scarier then i thought it was :)
User avatar
Xaos
Posts: 940
Joined: Wed Jan 11, 2012 4:01 am

Re: Logic behind Loot generation

Post by Xaos »

There are two ways you can go about this, I suppose.

The first is kind of what you're thinking. Make a bunch of weapons in a database, create an array for after battles/event/quests and call one random weapon, and insert it into the player's inventory.

The second is you could create a random weapon generator script. and have it run after the battle/event/quests. Have it randomly create a name and randomly assign attributes. If you want to keep your tier idea, which I'm sure you do, you could randomly assign points. If they have this range of points, they're in one tier, and etc. and assing those points to the attributes.
User avatar
Jackolantern
Posts: 10891
Joined: Wed Jul 01, 2009 11:00 pm

Re: Logic behind Loot generation

Post by Jackolantern »

As far as the question of where you keep this info, you would want to keep all of these limits and ranges for various weapon types and tiers in the database. That would allow you to write a generic weapon creation script and store specific weapons in the database.
The indelible lord of tl;dr
Zykal
Posts: 31
Joined: Thu Nov 29, 2012 4:38 am

Re: Logic behind Loot generation

Post by Zykal »

I planned on making it random that's my whole goal, i hate static loot gens.

I know it needs to go into the database i worded that bad.

I think what i'm trying to get across is in the database i need to set mins and maxes for the weapons for each tier then write a function to randomly pick numbers between the mins and maxes for each attribute.

So a Minimum quality 1 dagger spec would be

0 min damage 2 max damage att+ 0 def+0 speed 5 craft 1 worth xxx

a max quality 1 dagger would be

1 min damage 4 max damage att+10 Def + 15 speed 0 craft 10 worth xxx

So in my data base i think it should look like this.

Quality tier 1 -- Min Min damage 0 -- Min Max damage 1 -- Min Max damage 2 -- Max max Damage 4-- Min +att 0 --Max Att+ 10 -- Min Def+ 0 -- Max Def+ 15 -- Min Speed 0 -- Max Speed 5-- Min Craft 1 -- Max craft 10 --

Then I'd use a formula to randomly pic numbers in those catagories.

Randomly pic a number for Min Damage between 0-1 Pic a number for Max damage between 2-4 , Att+ 0-10 and so on.
So theoretically everytime i run this function i'd get a different weapon to a point.

I think that's the best way for it to work.

If that works like i think it should the real issue i think I'm having is I do not want the loot generator to have an equal chance of spitting out a perfect weapon and a crap weapon. I want a perfect weapon to be ultra rare. So I need some way to weight the randomization.
User avatar
Ark
Posts: 427
Joined: Wed Jun 01, 2011 10:25 pm

Re: Logic behind Loot generation

Post by Ark »

If that works like i think it should the real issue i think I'm having is I do not want the loot generator to have an equal chance of spitting out a perfect weapon and a crap weapon. I want a perfect weapon to be ultra rare. So I need some way to weight the randomization.
You could use probabilities then. you could make that a dragon sword will spawn 1 / 10 chances, while a dagger to spawn will have a probability of 7 / 10 chances.
Orgullo Catracho
User avatar
Jackolantern
Posts: 10891
Joined: Wed Jul 01, 2009 11:00 pm

Re: Logic behind Loot generation

Post by Jackolantern »

Yep! All you would need to do is roll a random number from 1 to 1000, and then if it is between 300 - 1000, make a regular weapon, 75 - 299, make a rare weapon, and 1 - 74, make a very rare item, or of course whatever odds you want :)
The indelible lord of tl;dr
User avatar
Callan S.
Posts: 2042
Joined: Sun Jan 24, 2010 5:43 am

Re: Logic behind Loot generation

Post by Callan S. »

[subversive agenda] Or have a historical record, gerenrated perhaps like dwarf fortrees generates a past world, to create the stats instead of an arbitrary dice roll based not on any history at all.[/subversive agenda]

Just feel a need for randomness ISN'T. It's a need for the complex history of the past which is so complex that to our minds it seems a morass of randomness.

Okay, enough naughty trying to influence design culture from me! ;)
Zykal
Posts: 31
Joined: Thu Nov 29, 2012 4:38 am

Re: Logic behind Loot generation

Post by Zykal »

Thanks for all the replies I've been busy this last week.

Yeah the dice roll for the rarity could be a simple solution will have to see if i like how it works out. i think i will need to do major tweaking in the DB to get this to work correctly. I will probably have to double or triple the amount of tiers i am thinking.

Thats basically what I'm looking at Oroton, as far as the tolerance thats a good idea will have to think on that.

As far as the dagger with a 4-4 damage yes that is possible, since the weapons will be going thru a damage formula that is based on there skill in that weapon and some of their attributes vs enemy defense the damage of 4 is very relative.
Zykal
Posts: 31
Joined: Thu Nov 29, 2012 4:38 am

Re: Logic behind Loot generation

Post by Zykal »

ok so i had a few minutes to mess around threw up a DB and some testing code.

short story I got it to randomly create weapons Yay

8 - 13 + 9 att + 1 def
4 - 8 + 7 att + 11 def
4 - 10 + 8 att + 9 def
8 - 9 + 5 att + 7 def
7 - 9 + 14 att + 8 def
7 - 10 + 14 att + 8 def
7 - 8 + 6 att + 10 def
8 - 11 + 0 att + 10 def
6 - 14 + 13 att + 11 def
6 - 8 + 7 att + 8 def
4 - 15 + 14 att + 6 def
5 - 9 + 13 att + 0 def
5 - 10 + 6 att + 9 def
8 - 10 + 0 att + 13 def
6 - 13 + 15 att + 14 def

Now that the basics work time to start tweaking it to get rid of bad rolls and such like 8-9 on a sword :/
Post Reply

Return to “General Development”