Fires of Heaven Guild Message Board  

Go Back   Fires of Heaven Guild Message Board > Fires of Heaven Related Forums > Uberworlds Development Forum
User Name
Password
ForumSpy Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Old 08-21-2008, 12:42 AM   #1 (permalink)
sh1by
Mugu mugu?
 
sh1by's Avatar
 
Join Date: Jan 2003
Posts: 79
-4 Internets
Send a message via AIM to sh1by
Theoretical Item Drop System

So I'm working on an item drop rate system for a game I'm working on and I am brainstorming ideas on how to set it up for the enemies in the game. I'm having a little trouble coming up with an *efficient* method to handle drop rates and setting up drops off certain mobs.

What I'm thinking is something along the lines of (layman's terms):

1: Set up item groups which contain lists of similar items. (example: boars in durotar dropping the same shit as other level 1-4 mobs in the area... minor healing potions, shitty greens, etc.)

2: Assign an item group to a mob.

3: When player kills mob, draw a random integer "z" between "x" and "y". If z = whatever the % of drop is, drop item. So for instance, if I have an item that has a 26.5% chance of dropping I'd imagine the formula would look something like:
x=1
y=1000
if z <= 265 then drop item.
else do nothing

When all is said and done, this doesn't feel efficient and I'm at a road block of how else to handle the situation, so I thought I'd ask around here. Essentially I want some kind of formula that handles itself. I'd like to be able to assign each item a drop%, attach it to an item group, attach the item group to a mob, and go, but I'm not really sure how to do this... Some kind of system where all I do is change the mob and tweak the numbers/items would be awesome.

If anything else it provides for some decent discussion that may be useful for other projects you guys are working on

Thanks for the help.
sh1by is offline   Reply With Quote
Old 08-21-2008, 03:05 AM   #2 (permalink)
Zarcath
Read Farmer
 
Zarcath's Avatar
 
Join Date: Jan 2004
Location: Hawaii
Posts: 5,201
+19 Internets
Not certain I understand what you're trying to do. Are you trying to get the drop percent of the loot group to = % you determine? or are you trying to get the drop percent of the mob to a % of loot groups?

I would do something like this

Boar Loot Table
Generic Loot A AND/OR
Boar Loot A AND/OR

and then in Generic Loot A group, fill in 1-100 of possible items. If you want a random green to have a higher chance of dropping, fill in more entries. So blocks 1-30 would be greens, 31-59 is a portion, 60-100 is grey items.

so toggle AND/OR to allow for 2 drop checks to be made or for quest specific items that are on Boat Loot Table or whatever.

Obviously if it's Generic Loot OR Boar Loot it'll automatically divide it by 50% chance of generic or boar loot. Add additional OR entries if you want to change the % it favors. So

Generic Loot OR
Generic Loot OR
Boar Loot OR

and then you have a 66% chance for Generic Loot and 33% for Boat Loot, when it decides which table to pull from it checks the list and generates the loot.

I'll see if I can find the doc we used in winter's roar but i might have lost it.

Last edited by Zarcath : 08-21-2008 at 03:07 AM.
Zarcath is offline   Reply With Quote
Old 08-21-2008, 06:01 AM   #3 (permalink)
Cloud9_
Registered User
 
Join Date: Jul 2002
Location: Los Angeles California
Posts: 228
+9 Internets
Send a message via ICQ to Cloud9_
what system are you using? programming it yourself or scripting it within another system?

In my RPG the item drops are pretty easy... and the lookup method is just something like

Code:
int random = Random(1,100); Item item = new Item(); foreach (Item dropTableItem in monster.ItemsToDrop) { if (random > item.DropPercent ) { item = dropTableItem } }
basically it cycles through all the items and chooses the item with the highest drop percent that it actually rolled. ItemsToDrop could be taken from anything, custom loot table, generic loot table, dungeon specific loot table, etc.
Cloud9_ is offline   Reply With Quote
Old 08-24-2008, 02:56 PM   #4 (permalink)
Thug
Registered User
 
Join Date: May 2003
Posts: 157
-1 Internets
Hmm, maybe move the int random = .... to the inside of the loop.

The way you have it now, you're pretty much guaranteed only 100 different possible drop combinations.
Thug is offline   Reply With Quote
Old 08-24-2008, 10:57 PM   #5 (permalink)
Cloud9_
Registered User
 
Join Date: Jul 2002
Location: Los Angeles California
Posts: 228
+9 Internets
Send a message via ICQ to Cloud9_
yeah, its jsut something i typed up too quick... the actual drop code i have in my project is:

Code:
/// /// Returns random combat rewards based on the monsters drop table /// public List CombatRewards { get { //list of rewards to return List rewards = new List(); for (int i = 0; i < numberOfItemsToDrop.GenerateValue; i++) { //generate a random number between 0 and 1 float random = RNG.GetRandomFloat(0, 1); //cycle through the combat rewards. If the random number //is higher than the drop%, mark item. if the marked item //is the highest item available to drop, add that to combat //rewards. CombatReward rewarded = null; foreach (CombatReward combatReward in combatRewards) { if (random >= 1f - combatReward.DropPercentage) { if (rewarded == null) { rewarded = combatReward; } else if (rewarded != null && rewarded.DropPercentage > combatReward.DropPercentage) { rewarded = combatReward; } } }//end foreach if (rewarded != null) { rewards.Add(rewarded.ItemDropped); } } //return the rewards return rewards; }//end get }
Cloud9_ is offline   Reply With Quote
Old 08-25-2008, 02:48 AM   #6 (permalink)
slitz
euro scum
 
slitz's Avatar
 
Join Date: Aug 2002
Location: Sweden
Posts: 807
-10 Internets
I dunno if I would hard code it like that actually.
Another solution (which is better imo at least) is to just include different formulas in a database table and use regular expressions to parse the formula.
That way you can just change the formula at runtime whenever you want, instead of having to recompile just to change a single formula.
I guess it's a bit overkill in some cases though...

edit: this is if you're using a database in the first case anyway. If your project is small enough where you even hard code items, then it doesn't matter.
__________________

Last edited by slitz : 08-25-2008 at 04:17 AM.
slitz is offline   Reply With Quote
Old 08-25-2008, 07:09 AM   #7 (permalink)
Cloud9_
Registered User
 
Join Date: Jul 2002
Location: Los Angeles California
Posts: 228
+9 Internets
Send a message via ICQ to Cloud9_
Quote:
Originally Posted by slitz View Post
I dunno if I would hard code it like that actually.
Another solution (which is better imo at least) is to just include different formulas in a database table and use regular expressions to parse the formula.
That way you can just change the formula at runtime whenever you want, instead of having to recompile just to change a single formula.
I guess it's a bit overkill in some cases though...

edit: this is if you're using a database in the first case anyway. If your project is small enough where you even hard code items, then it doesn't matter.
my items and everything are XML. Basically the monster is given a list of guaranteed drop items (if any), a grouping of drops based on a given value w/ potential drop percent (IE: level range, again, if any), and a list of potential drops and the percent it would drop. (if any). IE:

This is XML, but apparently the forum didn't like the tags
Code:
Drops Gold Min="1" Max="3" / ItemsToDrop Min="1" Max="1" Weapon Asset="Content//Equipment//Weapon//OrcSlayer.xml" Percent="10" / Armor Asset="Content//Equipment//Boots//BustedBoots.xml" Percent="20" / /ItemsToDrop GuaranteedDrops /GuaranteedDrops /Drops
Cloud9_ is offline   Reply With Quote
Old 08-25-2008, 10:15 AM   #8 (permalink)
slitz
euro scum
 
slitz's Avatar
 
Join Date: Aug 2002
Location: Sweden
Posts: 807
-10 Internets
Yeah that's one way to do it, but it wasn't what I was talking about.
Basically, you've made the formula itself static while keeping the variables changable. What I'm talking about is making the formula itself changable.

Lets use a very simple example:

Code:
public double getPrice(double rarity, int durability, Material material){ return (rarity*durability)/material.getPrice(); }
Now what I've done here is hardcoded the formula. No matter what I do the price will always be rarity*durability/material.getPrice();
In some cases this will never ever change, but in other cases it might! (combat formulas etc)

Code:
public double getPrice(Formula formula, Item item){ // parsing logics here which apply formula with item variables }
Now all of a sudden I can change the formula of a item at runtime, as long as I have a functioning evalutor (which isn't hard to do). Meaning, I can even read the formula from a XML file / database.
Note this is rather complex way of doing it if you ask me, so it shouldn't be used if you only need one formula for combat/item values/item droprate/whatever, but if you're looking for a bigger project I think that it sounds like a good idea in theory at least 8).
__________________
slitz is offline   Reply With Quote
Old 08-25-2008, 10:53 AM   #9 (permalink)
Tenks
Registered User
 
Join Date: Nov 2003
Posts: 473
-15 Internets
The strategy pattern pops in to say hello
Tenks is offline   Reply With Quote
Old 08-25-2008, 10:57 AM   #10 (permalink)
Cloud9_
Registered User
 
Join Date: Jul 2002
Location: Los Angeles California
Posts: 228
+9 Internets
Send a message via ICQ to Cloud9_
Quote:
Originally Posted by Tenks View Post
The strategy pattern pops in to say hello
I keep meaning to read up on patterns... i kinda know squat about them

And I see what you're saying about keeping the formula dynamic. I can see how that could be useful for some projects.
Cloud9_ is offline   Reply With Quote
Old 08-26-2008, 10:33 AM   #11 (permalink)
Tenks
Registered User
 
Join Date: Nov 2003
Posts: 473
-15 Internets
Strategy is one of the widest used and probably easiest to understand. Hell, you probably use it without even knowing it.

The underlying problem the strategy pattern solves is how to solve the problem where you do the same thing with different algorithms.

The solution is to just create an Interface and have various classes implement said interface.

So lets say you have an interface (Dropable) that has a getDropRate() method.

You then have three item classes:

NormalItem : Dropable
MagicalItem : Dropable
EpicItem : Dropable

Dropable drop = new EpicItem()
float rate = drop.getDropRate()


Obviously the way its implemented now is sloppy and has no value what so ever, but you get the idea. It serves you very well if you are populating things via XML inverting the control and injecting dependency.
Tenks is offline   Reply With Quote
Old 08-27-2008, 07:39 AM   #12 (permalink)
Cloud9_
Registered User
 
Join Date: Jul 2002
Location: Los Angeles California
Posts: 228
+9 Internets
Send a message via ICQ to Cloud9_
Quote:
Originally Posted by Tenks View Post
Strategy is one of the widest used and probably easiest to understand. Hell, you probably use it without even knowing it.

The underlying problem the strategy pattern solves is how to solve the problem where you do the same thing with different algorithms.

The solution is to just create an Interface and have various classes implement said interface.

So lets say you have an interface (Dropable) that has a getDropRate() method.

You then have three item classes:

NormalItem : Dropable
MagicalItem : Dropable
EpicItem : Dropable

Dropable drop = new EpicItem()
float rate = drop.getDropRate()


Obviously the way its implemented now is sloppy and has no value what so ever, but you get the idea. It serves you very well if you are populating things via XML inverting the control and injecting dependency.
yeah that code is all over my project, mostly for weapon damage and skill damange and stuff.
Cloud9_ is offline   Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is On
Trackbacks are On
Pingbacks are On
Refbacks are On
uberguilds network



All times are GMT -7. The time now is 03:11 AM.


Powered by vBulletin® Version 3.6.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.0.0 RC6