- 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
#2.
Seach for
Replace the entire function with the following
If you have the command to change the Experience Rate, you will want to continue.
#3.
Replace the follow code
With the following
#4. DONE!Cheers,
Mapster
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){
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: