|
| | #1 (permalink) |
| Mugu mugu? Join Date: Jan 2003
Posts: 79
| 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. |
| | |
| | #2 (permalink) |
| Read Farmer 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. |
| | |
| | #3 (permalink) |
| Registered User Join Date: Jul 2002 Location: Los Angeles California
Posts: 228
+9 Internets | 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:
|
| | |
| | #5 (permalink) |
| Registered User Join Date: Jul 2002 Location: Los Angeles California
Posts: 228
+9 Internets | yeah, its jsut something i typed up too quick... the actual drop code i have in my project is: Code:
|
| | |
| | #6 (permalink) |
| euro scum Join Date: Aug 2002 Location: Sweden
Posts: 807
| 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. |
| | |
| | #7 (permalink) | |
| Registered User Join Date: Jul 2002 Location: Los Angeles California
Posts: 228
+9 Internets | Quote:
This is XML, but apparently the forum didn't like the tags Code:
| |
| | |
| | #8 (permalink) |
| euro scum Join Date: Aug 2002 Location: Sweden
Posts: 807
| 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:
In some cases this will never ever change, but in other cases it might! (combat formulas etc) Code:
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). |
| | |
| | #11 (permalink) |
| Registered User Join Date: Nov 2003
Posts: 473
| 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. |
| | |
| | #12 (permalink) | |
| Registered User Join Date: Jul 2002 Location: Los Angeles California
Posts: 228
+9 Internets | Quote:
| |
| | |
![]() |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
| |