Sign in to follow this  
Samuel_XMA

[Question] In which ways are loot systems implemented?

Recommended Posts

Hello, my name is Samuel. This is my first post at GDNET - apologies if I make any of the usual mistakes. I'm pretty new to programming but not computing in general. I know MMO questions are often met with some trepidation around here (usually for good reason) so please understand the question is purely out of interest and not because I want to make the 'latest greatest'. Question: In what ways are loot systems in MMOs often implemented? I'm not looking for a complete outline of how to design and write one, I'm just curious as to how they are normally implemented (database tables, arrays - I've really no idea). Thanks for taking the time to read this and for any feedback, Samuel_XMA.

Share this post


Link to post
Share on other sites
I've just realised that what I wrote may have been lacking a little.

I should have added that I'd like to know how the 'systems' are structured (tables, arrays in memory), how they are replenished and how what is dropped is worked out (straight-forward probability: some items having greater probability of being selected?).

Apologies for any 'newbie terminology' and understanding.


Samuel_XMA.

Share this post


Link to post
Share on other sites
i find the question very vague. i din't really understand to what do you reffer by `loot systems`. Do you want to know how the server stores data about items, upgrades, charater info(level,items?)? or how this data is transformed and transfered to your computer so that items are all in place? or what are the inner workings of actual storage space of such data, what are the common data structures used used to represent everything?.

i can only explain a simple design for what items a creature droppes.
You can rate items by level/money/etc and any creature droppes items of a certain value. You can simply do a random select from the database choosing some items of that value.

Share this post


Link to post
Share on other sites
Well...
List<Item *> Entity::generateLoot();


Quote:
I'm just curious as to how they are normally implemented (database tables, arrays - I've really no idea).


It doesn't really matter, it would come down to management requirements. Who produces the tables, how often does it change, is it static, dynamic, does it depend on some context or is it idempotent...

But the basic idea is, any entity may generate a number of items (perhaps on death). The interface above covers that.

Share this post


Link to post
Share on other sites
Quote:
Original post by Makaan
i find the question very vague. i din't really understand to what do you reffer by `loot systems`.



I guess what I was after knowing was how the server manages which NPCs drop what and how the available 'loot' is, for lack of a better word, stored.

Whether it be held in a single database table and the drop be based on a factor such as the NPCs privilege level (lower level NPCs only have access to items below a certain threshold) or perhaps a loot list per 'type' of NPC.

I can see that what I asked was a very open-ended question. And as Antheus said it depends upon the management needs.

Simply thinking it through like I just have done highlights his point well.

Thanks guys and please forgive any spelling mistakes (I'm not feeling too good).

Samuel.

Share this post


Link to post
Share on other sites
havind a loot list for every NPC is out of the question because there is too much data and this would be too heavy on the database.

A simple solution: the server will hold a database table with all the items available. Each entry on the table represents a item. Each iteam can have a price or a level or a rating, or type, power etc. This is just to make sure a cheap NPC will not drop the ultimate hammer of Thor that will destory the world.

When you kill a NPC the server knows what level the NPC was. So it will simply select from tha table a number of items of that certain level. In general it would be faster to store as litle data as possible for every NPC. The server will do any computation base on the type of the NPC in order to figure out what items will it drop , or how much money will it give you. Keep in mind that the server can take you as a factor in this selection of items. It would be useles to give you a powerfull warrior item when you are a mage.


Share this post


Link to post
Share on other sites
Quote:
Original post by Makaan
havind a loot list for every NPC is out of the question because there is too much data and this would be too heavy on the database.

A simple solution: the server will hold a database table with all the items available. Each entry on the table represents a item. Each iteam can have a price or a level or a rating, or type, power etc. This is just to make sure a cheap NPC will not drop the ultimate hammer of Thor that will destory the world.

When you kill a NPC the server knows what level the NPC was. So it will simply select from tha table a number of items of that certain level. In general it would be faster to store as litle data as possible for every NPC. The server will do any computation base on the type of the NPC in order to figure out what items will it drop , or how much money will it give you. Keep in mind that the server can take you as a factor in this selection of items. It would be useles to give you a powerfull warrior item when you are a mage.


Hi Makaan

Thanks for the additional explanation. What you said makes perfect sense.

I guess the best way to create a 'loot system' is to think through what you need it to be able to do.

Thanks,
Sam.

Share this post


Link to post
Share on other sites
Just thinking out loud here:
Just store the loot on the client:
- It is YOUR loot
- It is acceptable to lose the option to loot the current loot after logging out
- After a timeout the loot is deleted.
- optionally: move the loot after the timeout to a general loot on the server so others can loot it.

I do not like the final option because I think that loot should fit te player's level. Otherwise you will see a lot of n00bs waiting near battlefields for high level loot.

It all depends on what you want and what is 'realistic' in your MMO world.

[Edited by - ernow on December 29, 2009 7:27:50 AM]

Share this post


Link to post
Share on other sites
In Lineage 2 (lineage2.com) all of the loot is separated by mob's so that each mob is unique. For example, a "dire wolf" will drop 2 or 3 specific materials and a "black wolf" will drop 1 or 2 specific materials and a rare chance for a "black knife." If you take a look at L2J which is a emulation server for L2 (l2jserver.com) you will see that all of the drops are stored in a database. For the official servers that NCSoft runs, the drops are stored in a giant text file that is parsed when the NPC server is launched. Different MMO's have different ways of handling loot though so some of the above posts will work as well.

Share this post


Link to post
Share on other sites
In an online game project I worked on, the loot list of each mob was customized entirely by hand, as a list of unique identifiers representing each item. This was a few years ago.

These days, I would blend this approach with a more global loot system that others have brought up so far. In a lot of games today, some items will only drop from a specific mob, and some will drop from a wide variety of mobs. So one possibility right off the top of my head would be a per-mob list (for things like quest items or boss drops) and some number of generic lists that can be attached to each mob but quickly modified as a whole. For example, creatures like wolves or bears would usually drop some kind of meat.

It really depends on exactly what your needs are, though.

Share this post


Link to post
Share on other sites
Thank you ernow, phear- and Valkoran. I really appreciate you taking the time to share your experience with me.

I suppose that there really is no correct way of implementing such a system. It depends almost entirely on what you'd like the system to be able to do (and then how robust and flexible you'd like it to be, as well).

Thanks guys.

Best wishes,
Sam.

Share this post


Link to post
Share on other sites
Quote:
Original post by ernow

- optionally: move the loot after the timeout to a general loot on the server so others can loot it.

I do not like the final option because I think that loot should fit te player's level. Otherwise you will see a lot of n00bs waiting near battlefields foor high level loot.


What you said here is interesting, and as you said afterwards, depends on the MMO. I quite like the idea that enterprising 'newbies' can acquire loot beyond their level if they are willing to take a risk. You'd have to limit what they can use though, otherwise you might end up with newbies with very unbalanced equipment! :-)

Thanks,
Sam.

Share this post


Link to post
Share on other sites
Quote:
Original post by ernow
Just store the loot on the client


I'd like to point out the number one rule regarding online games: Don't store any important data on the client.

If you were to follow that, there's a chance, even if small, that someone could be using a hacked/unofficial client and could edit their loot, so they could suddently have The Ultimate Holy Crap Run It's Going To Kill Us weapon.

Regarding how loot is generated, the most simple yet effective way i can think of would be to create a table that would contain the loot ID, name, flags, and chance of appearing, a NPC Type table that'd have basic NPC information such as ID, name, flags, stats, and loot IDs, and finally each NPC would be a NPC "instance" that would refer to a NPC ID.

That way you'd only need to store the NPC health and position per NPC, saving up a lot of DB space and even possibly bandwidth.

Share this post


Link to post
Share on other sites
In my server protoype I have a script file for each monster on the server side which is something like this:


drop1 = "Sword"
drop1_chance = 21 //percent
drop2 = "none"
drop2_chance = 22
drop3 = "none"
drop3_chance = 23
drop4 = "none"
drop4_chance = 24


so each monster can drop 4 items, then theres just an array of items in the server with Sword as the name field, and it would match them up like that.

I like it like this because each monster drops only certain equipment, I could also make a large database with items and just have a monster have a certain chance to drop a random item.

Share this post


Link to post
Share on other sites
Quote:
Original post by nuno_silva_pt

...so they could suddently have The Ultimate Holy Crap Run It's Going To Kill Us weapon.


Heh, you can tell you've played a few MMOs! :-)

I did think that storing things on the client was a bad idea. I was attempting to work out how to 'hack' (spoof / fake) TCP packets when I was fourteen. So yes, there will almost certainly be someone that is 'curious' enough, or determined enough, to give it a fair go.

I wasn't sure whether he meant an RPG rather than MMO in the above instance, though.

Thank you also rgibson11 for sharing your experience. It's good to know how people are actually doing it (even if they are personal projects rather than live MMOs or ORPGs).


Thank you to everyone for your answers. I'm now excited rather than daunted by the idea of implementing such a system (albeit possibly in the far future).

I tend to always be looking for the 'right' way of doing things when in fact the 'right' way of putting the system together is to think it through and work out your needs (as well as to consider pitfalls).

Thanks guys,
Sam.



Share this post


Link to post
Share on other sites
Quote:
Original post by nuno_silva_pt
Quote:
Original post by ernow
Just store the loot on the client


I'd like to point out the number one rule regarding online games: Don't store any important data on the client.

If you were to follow that, there's a chance, even if small, that someone could be using a hacked/unofficial client and could edit their loot, so they could suddently have The Ultimate Holy Crap Run It's Going To Kill Us weapon.


Of course you're toast as soon as someone is able to hack the client but not just for loot and other data. A solution might be to only use the client to store available loot. Perhaps even encrypted with a public key.
- Killing an enemy causes a call to the server.
- The server generates an encrypted loot item and passes it back to the client and forgets all about it.
- Picking it up would cause a call to the server passing the encrypted item.
- The server would decrypt with the private key.

This way the client keeps the loot safely.

Share this post


Link to post
Share on other sites
But how is this useful?

- First of all, at some time the loot items are going to be stored on the server, unless they decayed (see below).
- The server will need to convert back and forth items once you pick them up, which is more complicated compared to just setting a "picked up" flag or updating inventory IDs for server-stored item.
- The server will also need to know about the loot lying on the ground to be able to tell other clients about it.
- Last, the server will need to store the loot items for loot decay.

Share this post


Link to post
Share on other sites
Quote:
Original post by ernow

Of course you're toast as soon as someone is able to hack the client but not just for loot and other data. A solution might be to only use the client to store available loot. Perhaps even encrypted with a public key.
- Killing an enemy causes a call to the server.
- The server generates an encrypted loot item and passes it back to the client and forgets all about it.


So, how does server determine that the powerful axe you are wielding and using to kill other players was actually "available" and "generated by call to server", and it's not just some random item that player conjured up. 500 times.

Quote:
- The server would decrypt with the private key.


The problem with encryption is that both, client and server need to know the contents of the payload. As such, they both have adequate information to decrypt and modify the contents. Encryption in this case prevents only man-in-the-middle attacks, which are not an important problem anyway. Strength of key is irrelevant in this case.

The biggest flaw here is that "server forgets about it". If you look at authentication systems, server never forgets about client. Upon login, it generates a secret (something from server, something from client, something random) and uses that to verify actions. This secret is never shared with client, and if server were compromised in appropriate way, the encryption fails.

Simple conclusion is that server must never forget about original item - at which point the concept of storing anything on client becomes moot.

Besides - what advantage would server forgetting about items bring?

Share this post


Link to post
Share on other sites
Again, my idea is just what it is: an idea about how you could implement it.

The main advantage of the idea is not storing all loot of all players all the time on the server.

As with any option, there are pros and cons.

In my solution the clients doesn't need to know the content of the loot item. and only when an item is picked up it gets pushed back to the server.

Another option would be to mark the potential loot with some stats (player level, enemy level, etc) send that to the client (encrypted), store it at the client, and send that to the server when picking up the loot and have the server generate the actual loot.

The secret you keep is the private key that is kept at the server and that is used to encrypt the data that is stored on the client.

I´ll stop defending my system right here; it was just an example.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this