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!

Map Exp Sharing Titan .55

Initiate Mage
Joined
Apr 10, 2008
Messages
50
Reaction score
0
Since i have a server with just me and my bro, i decided to try and make a code where if a monster is killed, it gives a part of that monsters exp to everyone in the map.

What this code does is counts how many people there are in a map, and multiplies the EXP given by the monster by the amount of players in the map and gives that amount of EXP to everyone.
e.g: 10 people in the map, Slime gets killed = 1 exp to everyone in the map.

!! NOTE !!
Do not add this in very popular servers or there will be complains about map campers (people going afk in maps and keeping all of the exp)

Steps:

#1.
Open Mobs.cpp

Add the following under the #includes
Code:
short playercount = 1;

#2.
Seach for
Code:
void Mobs::dieMob(Player* player, Mob* mob, int n){
Replace the entire function with the following
Code:
void Mobs::dieMob(Player* player, Mob* mob, int n){
    MobsPacket::dieMob(player, Maps::info[player->getMap()].Players, mob , mob->getID());
    playercount = 0;

                    for (unsigned int x=0; x<Maps::info[player->getMap()].Players.size(); x++){
                        Player* cchose;
                        cchose = Maps::info[player->getMap()].Players[x];
                        playercount++;
                    }

                    for (unsigned int x=0; x<Maps::info[player->getMap()].Players.size(); x++){
                        Player* cchose;
                        cchose = Maps::info[player->getMap()].Players[x];

                        Levels::giveEXP(cchose, mobinfo[mob->getMobID()].exp / playercount);
                    }

    Drops::dropMob(player, mob);

    vector<int>::iterator vi = mobinfo[mob->getMobID()].summon.begin();
    
    while (vi != mobinfo[mob->getMobID()].summon.end()) {
        //Mobs::spawnMob(player , *vi++);
        int mobid = *vi++;
        Mob* mobb = new Mob();
        mobs[player->getMap()].push_back(mobb);
        mobb->setPos(mob->getPos());
        mobb->setID(mobscount++);
        mobb->setMobID(mobid);
        mobb->setMapID(-1);
        mobb->setHP(mobinfo[mobid].hp);
        mobb->setMP(mobinfo[mobid].mp);
        mobb->setFH(0);
        mobb->setControl(player);
        mobb->setType(2);
        for(unsigned int j=0; j<Maps::info[player->getMap()].Players.size(); j++)
            MobsPacket::showMob(Maps::info[player->getMap()].Players[j], mobb);
    }

    

    player->quests->updateQuestMob(mob->getMobID());
    mobs[player->getMap()].erase(mobs[player->getMap()].begin()+n);
    delete mob;
}

If you have the command to change the Experience Rate, you will want to continue.
#3.

Replace the follow code
Code:
Levels::giveEXP(cchose, mobinfo[mob->getMobID()].exp / playercount);

With the following
Code:
Levels::giveEXP(cchose, mobinfo[mob->getMobID()].exp * EXPRATE / playercount);

#4. DONE!Cheers,
Mapster
 
Last edited:
Initiate Mage
Joined
Jun 24, 2008
Messages
76
Reaction score
0
Re: [Release]Map Exp Sharing Titan .55

wow...very nice :)
 
Initiate Mage
Joined
Apr 10, 2008
Messages
50
Reaction score
0
Re: [Release]Map Exp Sharing Titan .55

Thanks, I may need to add in a few little funtions to make it fair on more popular servers.
 
Initiate Mage
Joined
Apr 4, 2008
Messages
27
Reaction score
0
Re: [Release]Map Exp Sharing Titan .55

Can this code be used on like only one map and not all maps like a map for fun and stuff like that?
 
Initiate Mage
Joined
Apr 10, 2008
Messages
50
Reaction score
0
Re: [Release]Map Exp Sharing Titan .55

It will be possible if someone is able to get the mapid check going, it won't work for me.
 
Initiate Mage
Joined
Apr 8, 2008
Messages
47
Reaction score
0
Re: [Release]Map Exp Sharing Titan .55

Nice coding, try doing it only for parties only
 
Initiate Mage
Joined
Apr 10, 2008
Messages
50
Reaction score
0
Re: [Release]Map Exp Sharing Titan .55

in order to do that i'll need to do a heap of coding which i'm not up for atm.
someone else can take over if they know what they are doing.
 
Back
Top