Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » zMUD General Discussion
Qweth
Newbie


Joined: 10 Sep 2010
Posts: 5

PostPosted: Fri Sep 10, 2010 9:18 am   

Gold Database
 
I am looking to have a database or other method of recording the average amount of gold that is dropped by different mobs.
I wanted to get the info from the mud text "You get number coins from the corpse of mobname. "
I could do this from zmud help into a database or something except how do I store multiple coin values for each mob in order to obtain the average?

Any help would be awesome, thanks for your time,
Bob
Reply with quote
Tech
GURU


Joined: 18 Oct 2000
Posts: 2733
Location: Atlanta, USA

PostPosted: Fri Sep 10, 2010 4:31 pm   
 
There are several approaches. The simplest would be to create a db with two fields, one for the mobname and one for a list of all coin drops. The data would end up looking something like the following:
Code:
Name: Goblin   Gold:  {10|20|5|200|30|15|15}


The drawback to that is that it can get very big. If all you're interested in is the average gold drop that a 3 field database may be more efficient. You would essentially keep a running total of the average gold drop. The db fields would be mobname, mobkilled, avg_gold. The data would look something like the following:
Code:
Name: Goblin   Killed: 217  Avg Gold:  17.8
_________________
Asati di tempari!
Reply with quote
Qweth
Newbie


Joined: 10 Sep 2010
Posts: 5

PostPosted: Thu Dec 16, 2010 12:51 pm   
 
Right.. I think I would like either of those, or even keep 20-30 values of gold dropped, and also an average. Unfortunately I would not know how to derive average gold drop from having # mobs killed and a previous average. Or how to get a DB field which would be the average of all the values of gold as in your first example.


Once again, thank you for your time.
Bob
Reply with quote
Tech
GURU


Joined: 18 Oct 2000
Posts: 2733
Location: Atlanta, USA

PostPosted: Thu Dec 16, 2010 4:58 pm   
 
To get the new average it's fairly simple.

If PA is the previous average, and NK is the number killed then you can get the new average by this formula

Code:
NA = ((PA * NK) + EK) / (NK + 1)


Where NA is the new average and EK is the experience you got from that last kill. You would store the new average and add one (1) to NK. As for working with Database Variables, you should just read up on how to use them. Other commands and functions you'll find useful are #ADDKEY, %dbkey and #SHOWDB.
_________________
Asati di tempari!
Reply with quote
Qweth
Newbie


Joined: 10 Sep 2010
Posts: 5

PostPosted: Fri Dec 17, 2010 4:53 am   Nice!
 
Awesome. Thank you for the formula. You have been way helpful, I figured out the DB once so 3 fields should not be difficult.

Peace
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » zMUD General Discussion All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

© 2009 Zugg Software. Hosted by Wolfpaw.net