Fixed some problems with pets, port from tc1, by krz, thx Frankir.
--HG-- branch : trunk
This commit is contained in:
+8
-3
@@ -262,8 +262,13 @@ bool Pet::LoadPetFromDB( Player* owner, uint32 petentry, uint32 petnumber, bool
|
|||||||
{
|
{
|
||||||
uint32 savedhealth = fields[10].GetUInt32();
|
uint32 savedhealth = fields[10].GetUInt32();
|
||||||
uint32 savedmana = fields[11].GetUInt32();
|
uint32 savedmana = fields[11].GetUInt32();
|
||||||
SetHealth(savedhealth > GetMaxHealth() ? GetMaxHealth() : savedhealth);
|
if(!savedhealth && getPetType() == HUNTER_PET)
|
||||||
SetPower(POWER_MANA, savedmana > GetMaxPower(POWER_MANA) ? GetMaxPower(POWER_MANA) : savedmana);
|
setDeathState(JUST_DIED);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
SetHealth(savedhealth > GetMaxHealth() ? GetMaxHealth() : savedhealth);
|
||||||
|
SetPower(POWER_MANA, savedmana > GetMaxPower(POWER_MANA) ? GetMaxPower(POWER_MANA) : savedmana);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// set current pet as current
|
// set current pet as current
|
||||||
@@ -433,7 +438,7 @@ void Pet::SavePetToDB(PetSaveMode mode)
|
|||||||
<< uint32(mode) << ", '"
|
<< uint32(mode) << ", '"
|
||||||
<< name.c_str() << "', "
|
<< name.c_str() << "', "
|
||||||
<< uint32((GetByteValue(UNIT_FIELD_BYTES_2, 2) == UNIT_RENAME_ALLOWED)?0:1) << ", "
|
<< uint32((GetByteValue(UNIT_FIELD_BYTES_2, 2) == UNIT_RENAME_ALLOWED)?0:1) << ", "
|
||||||
<< (curhealth<1?1:curhealth) << ", "
|
<< curhealth << ", "
|
||||||
<< curmana << ", "
|
<< curmana << ", "
|
||||||
<< GetPower(POWER_HAPPINESS) << ", '";
|
<< GetPower(POWER_HAPPINESS) << ", '";
|
||||||
|
|
||||||
|
|||||||
@@ -77,6 +77,9 @@ void PetAI::_stopAttack()
|
|||||||
|
|
||||||
void PetAI::UpdateAI(const uint32 diff)
|
void PetAI::UpdateAI(const uint32 diff)
|
||||||
{
|
{
|
||||||
|
if (!m_creature->isAlive())
|
||||||
|
return;
|
||||||
|
|
||||||
Unit* owner = m_creature->GetCharmerOrOwner();
|
Unit* owner = m_creature->GetCharmerOrOwner();
|
||||||
|
|
||||||
if(m_updateAlliesTimer <= diff)
|
if(m_updateAlliesTimer <= diff)
|
||||||
|
|||||||
@@ -58,6 +58,9 @@ void WorldSession::HandlePetAction( WorldPacket & recv_data )
|
|||||||
sLog.outError("HandlePetAction.Pet %u isn't pet of player %s.", uint32(GUID_LOPART(guid1)), GetPlayer()->GetName() );
|
sLog.outError("HandlePetAction.Pet %u isn't pet of player %s.", uint32(GUID_LOPART(guid1)), GetPlayer()->GetName() );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!pet->isAlive())
|
||||||
|
return;
|
||||||
|
|
||||||
//TODO: allow control charmed player?
|
//TODO: allow control charmed player?
|
||||||
if(pet->GetTypeId() == TYPEID_PLAYER && !(flag == ACT_COMMAND && spellid == COMMAND_ATTACK))
|
if(pet->GetTypeId() == TYPEID_PLAYER && !(flag == ACT_COMMAND && spellid == COMMAND_ATTACK))
|
||||||
|
|||||||
@@ -6839,6 +6839,10 @@ void Spell::EffectSummonDeadPet(uint32 /*i*/)
|
|||||||
if(damage < 0)
|
if(damage < 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
float x,y,z;
|
||||||
|
_player->GetPosition(x, y, z);
|
||||||
|
_player->GetMap()->CreatureRelocation(pet, x, y, z, _player->GetOrientation());
|
||||||
|
|
||||||
pet->SetUInt32Value(UNIT_DYNAMIC_FLAGS, 0);
|
pet->SetUInt32Value(UNIT_DYNAMIC_FLAGS, 0);
|
||||||
pet->RemoveFlag (UNIT_FIELD_FLAGS, UNIT_FLAG_SKINNABLE);
|
pet->RemoveFlag (UNIT_FIELD_FLAGS, UNIT_FLAG_SKINNABLE);
|
||||||
pet->setDeathState( ALIVE );
|
pet->setDeathState( ALIVE );
|
||||||
|
|||||||
Reference in New Issue
Block a user