*Fix a crash caused by pet.

*Make pet class derived from guardian class.

--HG--
branch : trunk
This commit is contained in:
megamage
2009-03-25 21:32:34 -06:00
parent ebf53a4820
commit 1c2eab4110
11 changed files with 130 additions and 141 deletions
+1 -1
View File
@@ -957,7 +957,7 @@ void BattleGround::RemovePlayerAtLeave(uint64 guid, bool Transport, bool SendPac
// summon old pet if there was one and there isn't a current pet
if(!plr->GetPet() && plr->GetTemporaryUnsummonedPetNumber())
{
Pet* NewPet = new Pet;
Pet* NewPet = new Pet(plr);
if(!NewPet->LoadPetFromDB(plr, 0, (plr)->GetTemporaryUnsummonedPetNumber(), true))
delete NewPet;
+2 -3
View File
@@ -4339,7 +4339,7 @@ bool ChatHandler::HandleCreatePetCommand(const char* args)
}
// Everything looks OK, create new pet
Pet* pet = new Pet(HUNTER_PET);
Pet* pet = new Pet(player, HUNTER_PET);
if(!pet->CreateBaseAtCreature(creatureTarget))
{
@@ -4352,7 +4352,6 @@ bool ChatHandler::HandleCreatePetCommand(const char* args)
creatureTarget->RemoveCorpse();
creatureTarget->SetHealth(0); // just for nice GM-mode view
pet->SetUInt64Value(UNIT_FIELD_SUMMONEDBY, player->GetGUID());
pet->SetUInt64Value(UNIT_FIELD_CREATEDBY, player->GetGUID());
pet->SetUInt32Value(UNIT_FIELD_FACTIONTEMPLATE, player->getFaction());
@@ -4372,7 +4371,7 @@ bool ChatHandler::HandleCreatePetCommand(const char* args)
pet->InitPetCreateSpells();
pet->SetHealth(pet->GetMaxHealth());
MapManager::Instance().GetMap(pet->GetMapId(), pet)->Add((Creature*)pet);
pet->GetMap()->Add((Creature*)pet);
// visual effect for levelup
pet->SetUInt32Value(UNIT_FIELD_LEVEL,creatureTarget->getLevel());
+1 -1
View File
@@ -159,7 +159,7 @@ void WorldSession::HandleMoveWorldportAckOpcode()
// resummon pet
if(GetPlayer()->m_temporaryUnsummonedPetNumber)
{
Pet* NewPet = new Pet;
Pet* NewPet = new Pet(GetPlayer());
if(!NewPet->LoadPetFromDB(GetPlayer(), 0, GetPlayer()->m_temporaryUnsummonedPetNumber, true))
delete NewPet;
+2 -2
View File
@@ -666,7 +666,7 @@ void WorldSession::HandleUnstablePet( WorldPacket & recv_data )
Field *fields = result->Fetch();
uint32 petentry = fields[0].GetUInt32();
newpet = new Pet(HUNTER_PET);
newpet = new Pet(_player, HUNTER_PET);
if(!newpet->LoadPetFromDB(_player,petentry,petnumber))
{
delete newpet;
@@ -770,7 +770,7 @@ void WorldSession::HandleStableSwapPet( WorldPacket & recv_data )
_player->RemovePet(pet,pet->isAlive() ? PetSaveMode(slot) : PET_SAVE_AS_DELETED);
// summon unstabled pet
Pet *newpet = new Pet;
Pet *newpet = new Pet(_player);
if(!newpet->LoadPetFromDB(_player,petentry,pet_number))
{
delete newpet;
+17 -15
View File
@@ -1156,33 +1156,35 @@ void WorldObject::SetWorldObject(bool on)
void WorldObject::setActive( bool on )
{
if(m_isActive==on)
if(m_isActive == on)
return;
if(GetTypeId() == TYPEID_PLAYER)
return;
bool world = IsInWorld();
Map* map;
if(world)
{
map = GetMap();
if(GetTypeId() == TYPEID_UNIT)
map->RemoveFromActive((Creature*)this);
else if(GetTypeId() == TYPEID_DYNAMICOBJECT)
map->RemoveFromActive((DynamicObject*)this);
}
m_isActive = on;
if(world)
if(!IsInWorld())
return;
Map *map = FindMap();
if(!map)
return;
if(on)
{
if(GetTypeId() == TYPEID_UNIT)
map->AddToActive((Creature*)this);
else if(GetTypeId() == TYPEID_DYNAMICOBJECT)
map->AddToActive((DynamicObject*)this);
}
else
{
if(GetTypeId() == TYPEID_UNIT)
map->RemoveFromActive((Creature*)this);
else if(GetTypeId() == TYPEID_DYNAMICOBJECT)
map->RemoveFromActive((DynamicObject*)this);
}
}
void WorldObject::_Create( uint32 guidlow, HighGuid guidhigh, uint32 mapid, uint32 phaseMask )
@@ -1767,7 +1769,7 @@ Vehicle* WorldObject::SummonVehicle(uint32 entry, float x, float y, float z, flo
Pet* Player::SummonPet(uint32 entry, float x, float y, float z, float ang, PetType petType, uint32 duration)
{
Pet* pet = new Pet(petType);
Pet* pet = new Pet(this, petType);
if(petType == SUMMON_PET && pet->LoadPetFromDB(this, entry))
{
+68 -52
View File
@@ -39,8 +39,8 @@ char const* petTypeSuffix[MAX_PET_TYPE] =
"'s Companion" // MINI_PET
};
Pet::Pet(PetType type) :
Creature(), m_petType(type), m_removed(false), m_happinessTimer(7500), m_duration(0), m_bonusdamage(0),
Pet::Pet(Player *owner, PetType type) : Guardian(NULL, owner),
m_petType(type), m_removed(false), m_happinessTimer(7500), m_duration(0),
m_resetTalentsCost(0), m_resetTalentsTime(0), m_usedTalentCount(0), m_auraRaidUpdateMask(0), m_loading(false),
m_declinedname(NULL)
{
@@ -48,9 +48,6 @@ m_declinedname(NULL)
m_name = "Pet";
m_regenTimer = 4000;
// pets always have a charminfo, even if they are not actually charmed
InitCharmInfo();
if(type == POSSESSED_PET) // always passive
SetReactState(REACT_PASSIVE);
}
@@ -181,8 +178,6 @@ bool Pet::LoadPetFromDB( Player* owner, uint32 petentry, uint32 petnumber, bool
else
m_charmInfo->SetPetNumber(pet_number, false);
owner->SetPet(this, true);
SetDisplayId(fields[3].GetUInt32());
SetNativeDisplayId(fields[3].GetUInt32());
uint32 petlevel = fields[4].GetUInt32();
@@ -214,6 +209,10 @@ bool Pet::LoadPetFromDB( Player* owner, uint32 petentry, uint32 petnumber, bool
sLog.outError("Pet have incorrect type (%u) for pet loading.", getPetType());
}
owner->SetPet(this, true);
AIM_Initialize();
map->Add((Creature*)this);
InitStatsForLevel(petlevel);
SetUInt32Value(UNIT_FIELD_PET_NAME_TIMESTAMP, time(NULL));
SetUInt32Value(UNIT_FIELD_PETEXPERIENCE, fields[5].GetUInt32());
@@ -309,9 +308,6 @@ bool Pet::LoadPetFromDB( Player* owner, uint32 petentry, uint32 petnumber, bool
SetPower(POWER_MANA, savedmana > GetMaxPower(POWER_MANA) ? GetMaxPower(POWER_MANA) : savedmana);
}
AIM_Initialize();
map->Add((Creature*)this);
// Spells should be loaded after pet is added to map, because in CheckCast is check on it
_LoadSpells();
_LoadSpellCooldowns();
@@ -772,21 +768,27 @@ bool Pet::CreateBaseAtCreature(Creature* creature)
return true;
}
bool Pet::InitStatsForLevel(uint32 petlevel)
bool Guardian::InitStatsForLevel(uint32 petlevel)
{
CreatureInfo const *cinfo = GetCreatureInfo();
assert(cinfo);
Unit* owner = GetOwner();
if(!owner)
SetLevel(petlevel);
PetType petType = MAX_PET_TYPE;
if(HasSummonMask(SUMMON_MASK_PET) && m_owner->GetTypeId() == TYPEID_PLAYER)
{
sLog.outError("attempt to summon pet (Entry %u) without owner! Attempt terminated.", cinfo->Entry);
return false;
if(m_owner->getClass() == CLASS_WARLOCK)
petType = SUMMON_PET;
else if(m_owner->getClass() == CLASS_HUNTER)
petType = HUNTER_PET;
else
sLog.outError("Unknown type pet %u is summoned by player class %u", GetEntry(), m_owner->getClass());
((Pet*)this)->learnLevelupSpells();
}
uint32 creature_ID = (getPetType() == HUNTER_PET) ? 1 : cinfo->Entry;
SetLevel(petlevel);
uint32 creature_ID = (petType == HUNTER_PET) ? 1 : cinfo->Entry;
SetMeleeDamageSchool(SpellSchools(cinfo->dmgschool));
@@ -799,7 +801,7 @@ bool Pet::InitStatsForLevel(uint32 petlevel)
SetFloatValue(UNIT_MOD_CAST_SPEED, 1.0);
CreatureFamilyEntry const* cFamily = sCreatureFamilyStore.LookupEntry(cinfo->family);
if(cFamily && cFamily->minScale > 0.0f && getPetType()==HUNTER_PET)
if(cFamily && cFamily->minScale > 0.0f && petType==HUNTER_PET)
{
float scale;
if (getLevel() >= cFamily->maxScaleLevel)
@@ -815,7 +817,7 @@ bool Pet::InitStatsForLevel(uint32 petlevel)
int32 createResistance[MAX_SPELL_SCHOOL] = {0,0,0,0,0,0,0};
if(cinfo && getPetType() != HUNTER_PET)
if(cinfo && petType != HUNTER_PET)
{
createResistance[SPELL_SCHOOL_HOLY] = cinfo->resistance1;
createResistance[SPELL_SCHOOL_FIRE] = cinfo->resistance2;
@@ -825,39 +827,16 @@ bool Pet::InitStatsForLevel(uint32 petlevel)
createResistance[SPELL_SCHOOL_ARCANE] = cinfo->resistance6;
}
switch(getPetType())
switch(petType)
{
case SUMMON_PET:
{
if(owner->GetTypeId() == TYPEID_PLAYER)
{
switch(owner->getClass())
{
case CLASS_WARLOCK:
{
//the damage bonus used for pets is either fire or shadow damage, whatever is higher
uint32 fire = owner->GetUInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_POS + SPELL_SCHOOL_FIRE);
uint32 shadow = owner->GetUInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_POS + SPELL_SCHOOL_SHADOW);
uint32 val = (fire > shadow) ? fire : shadow;
learnLevelupSpells();
SetBonusDamage(int32 (val * 0.15f));
//bonusAP += val * 0.57;
break;
}
case CLASS_MAGE:
{
//40% damage bonus of mage's frost damage
float val = owner->GetUInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_POS + SPELL_SCHOOL_FROST) * 0.4;
if(val < 0)
val = 0;
SetBonusDamage( int32(val));
break;
}
default:
break;
}
}
//the damage bonus used for pets is either fire or shadow damage, whatever is higher
uint32 fire = m_owner->GetUInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_POS + SPELL_SCHOOL_FIRE);
uint32 shadow = m_owner->GetUInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_POS + SPELL_SCHOOL_SHADOW);
uint32 val = (fire > shadow) ? fire : shadow;
SetBonusDamage(int32 (val * 0.15f));
//bonusAP += val * 0.57;
SetBaseWeaponDamage(BASE_ATTACK, MINDAMAGE, float(petlevel - (petlevel / 4)) );
SetBaseWeaponDamage(BASE_ATTACK, MAXDAMAGE, float(petlevel + (petlevel / 4)) );
@@ -897,7 +876,6 @@ bool Pet::InitStatsForLevel(uint32 petlevel)
case HUNTER_PET:
{
SetUInt32Value(UNIT_FIELD_PETNEXTLEVELEXP, objmgr.GetXPForLevel(petlevel)/4);
learnLevelupSpells();
//these formula may not be correct; however, it is designed to be close to what it should be
//this makes dps 0.5 of pets level
SetBaseWeaponDamage(BASE_ATTACK, MINDAMAGE, float(petlevel - (petlevel / 4)) );
@@ -934,7 +912,45 @@ bool Pet::InitStatsForLevel(uint32 petlevel)
break;
}
default:
sLog.outError("Pet have incorrect type (%u) for levelup.", getPetType());
switch(GetEntry())
{
case 510: // mage Water Elemental
{
//40% damage bonus of mage's frost damage
float val = m_owner->GetUInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_POS + SPELL_SCHOOL_FROST) * 0.4;
if(val < 0)
val = 0;
SetBonusDamage( int32(val));
break;
}
case 1964: //force of nature
SetCreateHealth(30 + 30*petlevel);
SetBaseWeaponDamage(BASE_ATTACK, MINDAMAGE, float(petlevel * 2.5f - (petlevel / 2)));
SetBaseWeaponDamage(BASE_ATTACK, MAXDAMAGE, float(petlevel * 2.5f + (petlevel / 2)));
break;
case 15352: //earth elemental 36213
SetCreateHealth(100 + 120*petlevel);
SetBaseWeaponDamage(BASE_ATTACK, MINDAMAGE, float(petlevel - (petlevel / 4)));
SetBaseWeaponDamage(BASE_ATTACK, MAXDAMAGE, float(petlevel + (petlevel / 4)));
break;
case 15438: //fire elemental
SetCreateHealth(40*petlevel);
SetCreateMana(28 + 10*petlevel);
SetBaseWeaponDamage(BASE_ATTACK, MINDAMAGE, float(petlevel * 4 - petlevel));
SetBaseWeaponDamage(BASE_ATTACK, MAXDAMAGE, float(petlevel * 4 + petlevel));
break;
default:
SetCreateMana(28 + 10*petlevel);
SetCreateHealth(28 + 30*petlevel);
// FIXME: this is wrong formula, possible each guardian pet have own damage formula
//these formula may not be correct; however, it is designed to be close to what it should be
//this makes dps 0.5 of pets level
SetBaseWeaponDamage(BASE_ATTACK, MINDAMAGE, float(petlevel - (petlevel / 4)));
//damage range is then petlevel / 2
SetBaseWeaponDamage(BASE_ATTACK, MAXDAMAGE, float(petlevel + (petlevel / 4)));
break;
}
//sLog.outError("Pet have incorrect type (%u) for levelup.", petType);
break;
}
+3 -8
View File
@@ -22,8 +22,8 @@
#define TRINITYCORE_PET_H
#include "ObjectDefines.h"
#include "Creature.h"
#include "Unit.h"
#include "TemporarySummon.h"
enum PetType
{
@@ -117,10 +117,10 @@ typedef std::vector<uint32> AutoSpellList;
#define PET_FOLLOW_DIST 1
#define PET_FOLLOW_ANGLE (M_PI/2)
class Pet : public Creature
class Pet : public Guardian
{
public:
explicit Pet(PetType type = MAX_PET_TYPE);
explicit Pet(Player *owner, PetType type = MAX_PET_TYPE);
virtual ~Pet();
void AddToWorld();
@@ -155,14 +155,10 @@ class Pet : public Creature
HappinessState GetHappinessState();
void GivePetXP(uint32 xp);
void GivePetLevel(uint32 level);
bool InitStatsForLevel(uint32 level);
bool HaveInDiet(ItemPrototype const* item) const;
uint32 GetCurrentFoodBenefitLevel(uint32 itemlevel);
void SetDuration(int32 dur) { m_duration = dur; }
int32 GetBonusDamage() { return m_bonusdamage; }
void SetBonusDamage(int32 damage) { m_bonusdamage = damage; }
bool UpdateStats(Stats stat);
bool UpdateAllStats();
void UpdateResistances(uint32 school);
@@ -226,7 +222,6 @@ class Pet : public Creature
uint32 m_happinessTimer;
PetType m_petType;
int32 m_duration; // time until unsummon (used mostly for summoned guardians and not used for controlled pets)
int32 m_bonusdamage;
uint64 m_auraRaidUpdateMask;
bool m_loading;
+12 -12
View File
@@ -1710,7 +1710,7 @@ bool Player::TeleportTo(uint32 mapid, float x, float y, float z, float orientati
// resummon pet
if(pet && m_temporaryUnsummonedPetNumber)
{
Pet* NewPet = new Pet;
Pet* NewPet = new Pet(this);
if(!NewPet->LoadPetFromDB(this, 0, m_temporaryUnsummonedPetNumber, true))
delete NewPet;
@@ -15535,7 +15535,7 @@ void Player::LoadPet()
// just not added to the map
if(IsInWorld())
{
Pet *pet = new Pet;
Pet *pet = new Pet(this);
if(!pet->LoadPetFromDB(this,0,0,true))
delete pet;
}
@@ -17028,16 +17028,6 @@ void Player::RemovePet(Pet* pet, PetSaveMode mode, bool returnreagent)
if(!pet || pet->GetOwnerGUID()!=GetGUID())
return;
// only if current pet in slot
switch(pet->getPetType())
{
case POSSESSED_PET:
pet->RemoveCharmedOrPossessedBy(NULL);
default:
SetPet(pet, false);
break;
}
pet->CombatStop();
if(returnreagent)
@@ -17056,6 +17046,16 @@ void Player::RemovePet(Pet* pet, PetSaveMode mode, bool returnreagent)
pet->SavePetToDB(mode);
// only if current pet in slot
switch(pet->getPetType())
{
case POSSESSED_PET:
pet->RemoveCharmedOrPossessedBy(NULL);
default:
SetPet(pet, false);
break;
}
pet->CleanupsBeforeDelete();
pet->AddObjectToRemoveList();
pet->m_removed = true;
+7 -36
View File
@@ -18,11 +18,11 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "TemporarySummon.h"
#include "Log.h"
#include "ObjectAccessor.h"
#include "CreatureAI.h"
#include "ObjectMgr.h"
#include "TemporarySummon.h"
TempSummon::TempSummon(SummonPropertiesEntry const *properties, Unit *owner) :
Creature(), m_type(TEMPSUMMON_MANUAL_DESPAWN), m_timer(0), m_lifetime(0)
@@ -32,6 +32,11 @@ Creature(), m_type(TEMPSUMMON_MANUAL_DESPAWN), m_timer(0), m_lifetime(0)
m_summonMask |= SUMMON_MASK_SUMMON;
}
Unit* TempSummon::GetSummoner() const
{
return m_summonerGUID ? ObjectAccessor::GetUnit(*this, m_summonerGUID) : NULL;
}
void TempSummon::Update( uint32 diff )
{
if (m_deathState == DEAD)
@@ -234,7 +239,7 @@ void TempSummon::SaveToDB()
}
Guardian::Guardian(SummonPropertiesEntry const *properties, Unit *owner) : TempSummon(properties, owner)
, m_owner(owner)
, m_owner(owner), m_bonusdamage(0)
{
m_summonMask |= SUMMON_MASK_GUARDIAN;
InitCharmInfo();
@@ -257,40 +262,6 @@ void Guardian::InitSummon(uint32 duration)
}
}
void Guardian::InitStatsForLevel(uint32 petlevel)
{
SetLevel(petlevel);
switch(GetEntry())
{
case 1964: //force of nature
SetCreateHealth(30 + 30*petlevel);
SetBaseWeaponDamage(BASE_ATTACK, MINDAMAGE, float(petlevel * 2.5f - (petlevel / 2)));
SetBaseWeaponDamage(BASE_ATTACK, MAXDAMAGE, float(petlevel * 2.5f + (petlevel / 2)));
break;
case 15352: //earth elemental 36213
SetCreateHealth(100 + 120*petlevel);
SetBaseWeaponDamage(BASE_ATTACK, MINDAMAGE, float(petlevel - (petlevel / 4)));
SetBaseWeaponDamage(BASE_ATTACK, MAXDAMAGE, float(petlevel + (petlevel / 4)));
break;
case 15438: //fire elemental
SetCreateHealth(40*petlevel);
SetCreateMana(28 + 10*petlevel);
SetBaseWeaponDamage(BASE_ATTACK, MINDAMAGE, float(petlevel * 4 - petlevel));
SetBaseWeaponDamage(BASE_ATTACK, MAXDAMAGE, float(petlevel * 4 + petlevel));
break;
default:
SetCreateMana(28 + 10*petlevel);
SetCreateHealth(28 + 30*petlevel);
// FIXME: this is wrong formula, possible each guardian pet have own damage formula
//these formula may not be correct; however, it is designed to be close to what it should be
//this makes dps 0.5 of pets level
SetBaseWeaponDamage(BASE_ATTACK, MINDAMAGE, float(petlevel - (petlevel / 4)));
//damage range is then petlevel / 2
SetBaseWeaponDamage(BASE_ATTACK, MAXDAMAGE, float(petlevel + (petlevel / 4)));
break;
}
}
void Guardian::RemoveFromWorld()
{
if(!IsInWorld())
+6 -3
View File
@@ -22,7 +22,6 @@
#define TRINITYCORE_TEMPSUMMON_H
#include "Creature.h"
#include "ObjectAccessor.h"
class TempSummon : public Creature
{
@@ -35,7 +34,7 @@ class TempSummon : public Creature
void RemoveFromWorld();
void SetTempSummonType(TempSummonType type);
void SaveToDB();
Unit* GetSummoner() const { return m_summonerGUID ? ObjectAccessor::GetUnit(*this, m_summonerGUID) : NULL; }
Unit* GetSummoner() const;
SummonPropertiesEntry const *m_Properties;
private:
@@ -52,9 +51,13 @@ class Guardian : public TempSummon
bool Create(uint32 guidlow, Map *map, uint32 phaseMask, uint32 Entry, uint32 pet_number);
void InitSummon(uint32 duration);
void RemoveFromWorld();
void InitStatsForLevel(uint32 level);
bool InitStatsForLevel(uint32 level);
int32 GetBonusDamage() { return m_bonusdamage; }
void SetBonusDamage(int32 damage) { m_bonusdamage = damage; }
protected:
Unit *m_owner;
int32 m_bonusdamage;
};
#endif
+11 -8
View File
@@ -8275,7 +8275,7 @@ Pet* Unit::GetPet() const
return pet;
sLog.outError("Unit::GetPet: Pet %u not exist.",GUID_LOPART(pet_guid));
const_cast<Unit*>(this)->SetPet(NULL, false);
const_cast<Unit*>(this)->SetUInt64Value(UNIT_FIELD_SUMMON, 0);
}
return NULL;
@@ -8289,7 +8289,7 @@ Unit* Unit::GetCharm() const
return pet;
sLog.outError("Unit::GetCharm: Charmed creature %u not exist.",GUID_LOPART(charm_guid));
const_cast<Unit*>(this)->SetCharm(NULL, false);
const_cast<Unit*>(this)->SetUInt64Value(UNIT_FIELD_CHARM, 0);
}
return NULL;
@@ -8755,8 +8755,8 @@ uint32 Unit::SpellDamageBonus(Unit *pVictim, SpellEntry const *spellProto, uint3
int32 TakenAdvertisedBenefit = SpellBaseDamageBonusForVictim(GetSpellSchoolMask(spellProto), pVictim);
// Pets just add their bonus damage to their spell damage
// note that their spell damage is just gain of their own auras
if (GetTypeId() == TYPEID_UNIT && ((Creature*)this)->isPet())
DoneAdvertisedBenefit += ((Pet*)this)->GetBonusDamage();
if (GetTypeId() == TYPEID_UNIT && ((Creature*)this)->HasSummonMask(SUMMON_MASK_GUARDIAN))
DoneAdvertisedBenefit += ((Guardian*)this)->GetBonusDamage();
// Check for table values
float coeff;
@@ -9753,7 +9753,7 @@ void Unit::Unmount()
// (it could probably happen when logging in after a previous crash)
if(GetTypeId() == TYPEID_PLAYER && IsInWorld() && ((Player*)this)->GetTemporaryUnsummonedPetNumber() && isAlive())
{
Pet* NewPet = new Pet;
Pet* NewPet = new Pet((Player*)this);
if(!NewPet->LoadPetFromDB((Player*)this, 0, ((Player*)this)->GetTemporaryUnsummonedPetNumber(), true))
delete NewPet;
@@ -12462,7 +12462,10 @@ void Unit::RemovePetAura(PetAura const* petSpell)
Pet* Unit::CreateTamedPetFrom(Creature* creatureTarget,uint32 spell_id)
{
Pet* pet = new Pet(HUNTER_PET);
if(GetTypeId()!=TYPEID_PLAYER)
return NULL;
Pet* pet = new Pet((Player*)this, HUNTER_PET);
if(!pet->CreateBaseAtCreature(creatureTarget))
{
@@ -13116,7 +13119,7 @@ void Unit::SetCharmedOrPossessedBy(Unit* charmer, bool possess)
// Pets already have a properly initialized CharmInfo, don't overwrite it.
if(GetTypeId() == TYPEID_PLAYER || GetTypeId() == TYPEID_UNIT
&& !((Creature*)this)->HasSummonMask(SUMMON_MASK_GUARDIAN) && !((Creature*)this)->isPet())
&& !((Creature*)this)->HasSummonMask(SUMMON_MASK_GUARDIAN))
{
CharmInfo *charmInfo = InitCharmInfo();
if(possess)
@@ -13239,7 +13242,7 @@ void Unit::RemoveCharmedOrPossessedBy(Unit *charmer)
//a guardian should always have charminfo
if(GetTypeId() == TYPEID_PLAYER || GetTypeId() == TYPEID_UNIT
&& !((Creature*)this)->HasSummonMask(SUMMON_MASK_GUARDIAN) && !((Creature*)this)->isPet())
&& !((Creature*)this)->HasSummonMask(SUMMON_MASK_GUARDIAN))
{
DeleteCharmInfo();
}