- Joined
- Apr 10, 2008
- Messages
- 131
- Reaction score
- 45
I didn't see this around, so correct me if I missed something.
Drain will not increase your HP past your base maximum no matter what (important if you have HP equips) unless you apply this fix to it.
http://forum.ragezone.com/f427/release-making-server-recognize-hp-mp-equips-389451/
On to the code:
1. Open up Mobs.cpp
2. Find void Mobs::damageMobS
3. Replace with:
4. ????
5. PROFIT!
Drain will not increase your HP past your base maximum no matter what (important if you have HP equips) unless you apply this fix to it.
http://forum.ragezone.com/f427/release-making-server-recognize-hp-mp-equips-389451/
On to the code:
1. Open up Mobs.cpp
2. Find void Mobs::damageMobS
3. Replace with:
PHP:
void Mobs::damageMobS(Player* player, unsigned char* packet, int size){
int itemid=0;
int pos=getInt(packet+14);
for(int i=0; i<player->inv->getItemNum(); i++){
if(player->inv->getItem(i)->pos == pos && player->inv->getItem(i)->inv == 2){
itemid = player->inv->getItem(i)->id;
break;
}
}
MobsPacket::damageMobS(player, Maps::info[player->getMap()].Players, packet, itemid);
int howmany = packet[1]/0x10;
int hits = packet[1]%0x10;
int map = player->getMap();
int skillid = getInt(packet+2);
int mhp = -1;
int totaldmg = 0;
if(skillid > 0)
Skills::useAttackSkill(player, skillid);
for(int i=0; i<howmany; i++){
int mobid = getInt(packet+19+i*(22+4*(hits-1)));
for(int k=0; k<hits; k++){
int damage = getInt(packet+37+i*(22+4*(hits-1))+k*4);
for(unsigned int j=0; j<mobs[map].size(); j++){
if(mobs[map][j]->getID() == mobid){
mobs[map][j]->setHP(mobs[map][j]->getHP()-damage);
mhp = -1;
totaldmg = totaldmg + damage;
mhp = mobinfo[mobs[map][j]->getMobID()].hp;
MobsPacket::showHP(player, mobid ,mobs[map][j]->getHP()*100/mhp);
if(mobs[map][j]->getHP() <= 0){
dieMob(player, mobs[map][j], j);
}
break;
}
}
}
}
if (skillid == 4101005 && totaldmg != 0) {
int hpamt = Skills::skills[4101005][player->skills->getSkillLevel(4101005)].x;
int healing = (int)((totaldmg * hpamt) / 100);
unsigned short pmhp = player->getMHP();
unsigned short php = player->getHP();
if (healing > mhp) { healing = mhp; }
if (healing > (pmhp / 2)) { healing = (pmhp / 2); }
int healed = php + healing;
if (healed > pmhp) { healed = pmhp; }
player->setHP(healed);
}
}
5. PROFIT!
PHP:
Changes:
1. Moved
int mhp = -1;
outside the loop so as to increase the scope beyond the loop. Needed for later referencing.
2. Added
int totaldmg = 0;
for counting inside the loop for two reasons: One, to determine how much HP to gain and two, to determine if a hit actually occurred.
3. Added
mhp = -1;
inside the loop where it was originally initialized. No special reason other than not wanting to break it in case of unforeseen error.
4. Added
totaldmg = totaldmg + damage;
inside the loop to count damage.
5. Added
if (skillid == 4101005 && totaldmg != 0) {
int hpamt = Skills::skills[4101005][player->skills->getSkillLevel(4101005)].x;
int healing = (int)((totaldmg * hpamt) / 100);
unsigned short pmhp = player->getMHP();
unsigned short php = player->getHP();
if (healing > mhp) { healing = mhp; }
if (healing > (pmhp / 2)) { healing = (pmhp / 2); }
int healed = php + healing;
if (healed > pmhp) { healed = pmhp; }
player->setHP(healed);
}
to the end of the function. Obviously, everything that has to do with Drain.
Last edited:

