// HP/MP Regeneration Function bool CPlayer::Regeneration() { if (Stats->MaxHP==Stats->HP && Stats->MaxMP== Stats->MP) { lastRegenTime=0; return true; } //LMA REGEN bool is_first_regen=false; if (lastRegenTime==0) { is_first_regen=true; } clock_t etime = clock() - lastRegenTime; if( etime >= 8 * CLOCKS_PER_SEC && Stats->HP > 0 ) { unsigned int hpamount = GetHPRegenAmount( ); unsigned int mpamount = GetMPRegenAmount( ); Stats->HP += hpamount; Stats->MP += mpamount; if( Stats->HP > Stats->MaxHP) Stats->HP = Stats->MaxHP; if( Stats->MP > Stats->MaxMP ) Stats->MP = Stats->MaxMP; if (Stats->MaxHP==Stats->HP && Stats->MaxMP== Stats->MP) lastRegenTime=0; else lastRegenTime = clock(); } return true; }
// HP/MP Regeneration Function bool CPlayer::Regeneration() { if (Stats->MaxHP == Stats->HP && Stats->MaxMP == Stats->MP) { lastRegenTime = 0; return true; } bool is_first_regen = false; if (lastRegenTime == 0) { is_first_regen = true; } clock_t etime = clock() - lastRegenTime; if( etime >= 8 * CLOCKS_PER_SEC && Stats->HP > 0 ) { //Log(MSG_INFO,"Regeneration function. Character %i HP on entry %i", clientid, Stats->HP); unsigned int hpamount = GetHPRegenAmount( ); unsigned int mpamount = GetMPRegenAmount( ); Stats->HP += hpamount; Stats->MP += mpamount; if( Stats->HP > Stats->MaxHP) Stats->HP = Stats->MaxHP; if( Stats->MP > Stats->MaxMP ) Stats->MP = Stats->MaxMP; BEGINPACKET( pak, 0x7ec ); ADDWORD( pak, Stats->HP); ADDWORD( pak, Stats->MP ); client->SendPacket( &pak ); if (Stats->MaxHP == Stats->HP && Stats->MaxMP == Stats->MP) lastRegenTime = 0; else lastRegenTime = clock(); //Log(MSG_INFO,"Regeneration function. Character %i HP on exit %i clock time %i", clientid, Stats->HP, lastRegenTime); } return true; }