Welcome!

Join our community of MMO enthusiasts and game developers! By registering, you'll gain access to discussions on the latest developments in MMO server files and collaborate with like-minded individuals. Join us today and unlock the potential of MMO server development!

Join Today!

[Release] Optional meso dropping from database

Banned
Banned
Joined
Jun 8, 2007
Messages
165
Reaction score
8
Might be a bit confusing title, but it lets you set a min/max meso drop for a monster id in the database, so the monster drops an amount between min/max. Useful for e.g. leprechauns. Uses the normal formula if the monsterid isn't found in the database.

First, execute this query:
Code:
CREATE TABLE `mesodrops` (
`id` INT NOT NULL AUTO_INCREMENT ,
`monsterid` INT DEFAULT '0' NOT NULL ,
`min` INT DEFAULT '0' NOT NULL ,
`max` INT DEFAULT '0' NOT NULL ,
PRIMARY KEY ( `id` )
) TYPE = innodb;
In MapleMap.java, replace this:
Code:
if (drop == -1) { // meso
                    final int mesoRate = ChannelServer.getInstance(dropOwner.getClient().getChannel()).getMesoRate();
                    Random r = new Random();
                    double mesoDecrease = Math.pow(0.93, monster.getExp() / 300.0);
                    if (mesoDecrease > 1.0) {
                        mesoDecrease = 1.0;
                    }
                    int tempmeso = Math.min(30000, (int) (mesoDecrease * (monster.getExp()) *
                        (1.0 + r.nextInt(20)) / 10.0));
                    if(dropOwner.getBuffedValue(MapleBuffStat.MESOUP) != null) {
                        tempmeso = (int) (tempmeso * dropOwner.getBuffedValue(MapleBuffStat.MESOUP).doubleValue() / 100.0);
                    }
                    
                    final int meso = tempmeso;
by this:
Code:
if (drop == -1) { // meso
                                    boolean dbmeso = false;
                                    int meso = 0;
                                    Random r = new Random();
                                    try{
                                        Connection con = DatabaseConnection.getConnection();
                                        PreparedStatement ps = con.prepareStatement("SELECT min, max FROM mesodrops WHERE monsterid = ?");
                                        ps.setInt(1, monster.getId());
                                        ResultSet rs = ps.executeQuery();
                                        while(rs.next()){
                                            int min = rs.getInt("min");
                                            int max = rs.getInt("max");
                                            meso = r.nextInt(max-min)+min;
                                            dbmeso = true;
                                        }
                                    }catch(Exception e){
                                        log.error("error in retrieving mesos dropped from db.", e);
                                    }
                                    if(!dbmeso){
                    double mesoDecrease = Math.pow(0.93, monster.getExp() / 300.0);
                    if (mesoDecrease > 1.0) {
                        mesoDecrease = 1.0;
                    }
                    int tempmeso = Math.min(30000, (int) (mesoDecrease * (monster.getExp()) *
                        (1.0 + r.nextInt(20)) / 10.0));
                    if(dropOwner.getBuffedValue(MapleBuffStat.MESOUP) != null) {
                        tempmeso = (int) (tempmeso * dropOwner.getBuffedValue(MapleBuffStat.MESOUP).doubleValue() / 100.0);
                    }
                    
                    meso = tempmeso;
                                    }
                                    final int mesoRate = ChannelServer.getInstance(dropOwner.getClient().getChannel()).getMesoRate();
                                    final int finalmeso = meso;
Replace:
Code:
spawnMesoDrop(meso * mesoRate, meso, dropPos, dropMonster, dropChar, isBoss);
by:
Code:
spawnMesoDrop(finalmeso * mesoRate, finalmeso, dropPos, dropMonster, dropChar, isBoss);
Add these imports on top:
Code:
import java.sql.ResultSet;
import java.sql.Connection;
import java.sql.PreparedStatement;
import net.sf.odinms.database.DatabaseConnection;
Now, add any monster id with the min/max to the database you like! =)
Note: be aware of the meso rate, which is still in effect.
 
Last edited:
Initiate Mage
Joined
Jun 11, 2008
Messages
48
Reaction score
0
so what i done wrong o.0

Code:
init:
deps-jar:
Compiling 2 source files to C:\Documents and Settings\sTaT!cvX CeV\Desktop\CeVMs V2\build\classes
C:\Documents and Settings\sTaT!cvX CeV\Desktop\CeVMs V2\src\net\sf\odinms\server\maps\MapleMap.java:347: local variable meso is accessed from within inner class; needs to be declared final
                                                                spawnMesoDrop(meso * mesoRate, meso, dropPos, dropMonster, dropChar, isBoss);
                                                                              ^
C:\Documents and Settings\sTaT!cvX CeV\Desktop\CeVMs V2\src\net\sf\odinms\server\maps\MapleMap.java:347: local variable meso is accessed from within inner class; needs to be declared final
                                                                spawnMesoDrop(meso * mesoRate, meso, dropPos, dropMonster, dropChar, isBoss);
                                                                                               ^
2 errors
BUILD FAILED (total time: 0 seconds)
 
Banned
Banned
Joined
Jun 8, 2007
Messages
165
Reaction score
8
People, I made an error which made normal money without database not show. I have fixed this in the first post. Just replace the part you added with the new part.
 
for(alive>0){makeMoney()}
Member
Joined
Aug 1, 2006
Messages
357
Reaction score
68
Great release, adding to my server ASAP!
 
Banned
Banned
Joined
Jun 8, 2007
Messages
165
Reaction score
8
Oh and btw:
replace:
Code:
spawnMesoDrop(meso * mesoRate, meso, dropPos, dropMonster, dropChar, isBoss);
by:
Code:
spawnMesoDrop(finalmeso * mesoRate, finalmeso, dropPos, dropMonster, dropChar, isBoss);
 
Junior Spellweaver
Joined
Mar 1, 2008
Messages
165
Reaction score
6
Pretty nice, now to remake the entire mesos drop for each monster! lol not really the thing everyone wants to do.
 
Back
Top