[7971] Implement support exotic pets limtations related to hunter telent 53270.

Note: before this commit hunters can tame exotic pets like any other.
      After patch like not propertly contriolled pets will auto-dismiss at loading
      if talent not learned.
This commit is contained in:
VladimirMangos 2009-06-06 21:14:43 +04:00
parent 01d93fa10d
commit 5ac6b2f34b
10 changed files with 106 additions and 39 deletions

View file

@ -235,9 +235,13 @@ struct CreatureInfo
return SKILL_SKINNING; // normal case
}
bool isTameable() const
bool isTameable(bool exotic) const
{
return type == CREATURE_TYPE_BEAST && family != 0 && (type_flags & CREATURE_TYPEFLAGS_TAMEABLE);
if(type != CREATURE_TYPE_BEAST || family == 0 || (type_flags & CREATURE_TYPEFLAGS_TAMEABLE)==0)
return false;
// if can tame exotic then can tame any temable
return exotic || (type_flags & CREATURE_TYPEFLAGS_EXOTIC)==0;
}
};

View file

@ -1786,7 +1786,7 @@ bool ChatHandler::HandleNpcTameCommand(const char* /*args*/)
CreatureInfo const* cInfo = creatureTarget->GetCreatureInfo();
if (!cInfo->isTameable ())
if (!cInfo->isTameable (player->CanTameExoticPets()))
{
PSendSysMessage (LANG_CREATURE_NON_TAMEABLE,cInfo->Entry);
SetSentErrorMessage (true);

View file

@ -582,11 +582,10 @@ void WorldSession::HandleStablePet( WorldPacket & recv_data )
Pet *pet = _player->GetPet();
WorldPacket data(SMSG_STABLE_RESULT, 200); // guess size
// can't place in stable dead pet
if(!pet||!pet->isAlive()||pet->getPetType()!=HUNTER_PET)
{
WorldPacket data(SMSG_STABLE_RESULT, 1);
data << uint8(0x06);
SendPacket(&data);
return;
@ -615,6 +614,7 @@ void WorldSession::HandleStablePet( WorldPacket & recv_data )
delete result;
}
WorldPacket data(SMSG_STABLE_RESULT, 1);
if( free_slot > 0 && free_slot <= GetPlayer()->m_stableSlots)
{
_player->RemovePet(pet,PetSaveMode(free_slot));
@ -647,11 +647,40 @@ void WorldSession::HandleUnstablePet( WorldPacket & recv_data )
if(GetPlayer()->hasUnitState(UNIT_STAT_DIED))
GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH);
WorldPacket data(SMSG_STABLE_RESULT, 200); // guess size
uint32 creature_id = 0;
{
QueryResult *result = CharacterDatabase.PQuery("SELECT entry FROM character_pet WHERE owner = '%u' AND id = '%u' AND slot >='%u' AND slot <= '%u'",
_player->GetGUIDLow(),petnumber,PET_SAVE_FIRST_STABLE_SLOT,PET_SAVE_LAST_STABLE_SLOT);
if(result)
{
Field *fields = result->Fetch();
creature_id = fields[0].GetUInt32();
delete result;
}
}
if(!creature_id)
{
WorldPacket data(SMSG_STABLE_RESULT, 1);
data << uint8(0x06);
SendPacket(&data);
return;
}
CreatureInfo const* creatureInfo = objmgr.GetCreatureTemplate(creature_id);
if(!creatureInfo || !creatureInfo->isTameable(_player->CanTameExoticPets()))
{
WorldPacket data(SMSG_STABLE_RESULT, 1);
data << uint8(0x06);
SendPacket(&data);
return;
}
Pet* pet = _player->GetPet();
if(pet && pet->isAlive())
{
WorldPacket data(SMSG_STABLE_RESULT, 1);
data << uint8(0x06);
SendPacket(&data);
return;
@ -661,28 +690,19 @@ void WorldSession::HandleUnstablePet( WorldPacket & recv_data )
if(pet)
_player->RemovePet(pet,PET_SAVE_AS_DELETED);
Pet *newpet = NULL;
QueryResult *result = CharacterDatabase.PQuery("SELECT entry FROM character_pet WHERE owner = '%u' AND id = '%u' AND slot >='%u' AND slot <= '%u'",
_player->GetGUIDLow(),petnumber,PET_SAVE_FIRST_STABLE_SLOT,PET_SAVE_LAST_STABLE_SLOT);
if(result)
{
Field *fields = result->Fetch();
uint32 petentry = fields[0].GetUInt32();
newpet = new Pet(HUNTER_PET);
if(!newpet->LoadPetFromDB(_player,petentry,petnumber))
Pet *newpet = new Pet(HUNTER_PET);
if(!newpet->LoadPetFromDB(_player,creature_id,petnumber))
{
delete newpet;
newpet = NULL;
}
delete result;
WorldPacket data(SMSG_STABLE_RESULT, 1);
data << uint8(0x06);
SendPacket(&data);
return;
}
if(newpet)
WorldPacket data(SMSG_STABLE_RESULT, 1);
data << uint8(0x09);
else
data << uint8(0x06);
SendPacket(&data);
}
@ -768,15 +788,32 @@ void WorldSession::HandleStableSwapPet( WorldPacket & recv_data )
Field *fields = result->Fetch();
uint32 slot = fields[0].GetUInt32();
uint32 petentry = fields[1].GetUInt32();
uint32 creature_id = fields[1].GetUInt32();
delete result;
if(!creature_id)
{
WorldPacket data(SMSG_STABLE_RESULT, 1);
data << uint8(0x06);
SendPacket(&data);
return;
}
CreatureInfo const* creatureInfo = objmgr.GetCreatureTemplate(creature_id);
if(!creatureInfo || !creatureInfo->isTameable(_player->CanTameExoticPets()))
{
WorldPacket data(SMSG_STABLE_RESULT, 1);
data << uint8(0x06);
SendPacket(&data);
return;
}
// move alive pet to slot or delete dead pet
_player->RemovePet(pet,pet->isAlive() ? PetSaveMode(slot) : PET_SAVE_AS_DELETED);
// summon unstabled pet
Pet *newpet = new Pet;
if(!newpet->LoadPetFromDB(_player,petentry,pet_number))
if(!newpet->LoadPetFromDB(_player,creature_id,pet_number))
{
delete newpet;
data << uint8(0x06);

View file

@ -134,6 +134,17 @@ bool Pet::LoadPetFromDB( Player* owner, uint32 petentry, uint32 petnumber, bool
return false;
}
PetType pet_type = PetType(fields[18].GetUInt8());
if(pet_type==HUNTER_PET)
{
CreatureInfo const* creatureInfo = objmgr.GetCreatureTemplate(petentry);
if(!creatureInfo || !creatureInfo->isTameable(owner->CanTameExoticPets()))
{
delete result;
return false;
}
}
uint32 pet_number = fields[0].GetUInt32();
if (current && owner->IsPetNeedBeTemporaryUnsummoned())
@ -164,7 +175,7 @@ bool Pet::LoadPetFromDB( Player* owner, uint32 petentry, uint32 petnumber, bool
return false;
}
setPetType(PetType(fields[18].GetUInt8()));
setPetType(pet_type);
setFaction(owner->getFaction());
SetUInt32Value(UNIT_CREATED_BY_SPELL, summon_spell_id);

View file

@ -3480,6 +3480,14 @@ bool Player::resetTalents(bool no_cost)
//FIXME: remove pet before or after unlearn spells? for now after unlearn to allow removing of talent related, pet affecting auras
RemovePet(NULL,PET_SAVE_NOT_IN_SLOT, true);
/* when prev line will dropped use next line
if(Pet* pet = GetPet())
{
if(pet->getPetType()==HUNTER_PET && !pet->GetCreatureInfo()->isTameable(CanTameExoticPets()))
RemovePet(NULL,PET_SAVE_NOT_IN_SLOT, true);
}
*/
if(m_canTitanGrip)
{

View file

@ -1729,6 +1729,7 @@ class MANGOS_DLL_SPEC Player : public Unit
void SetCanDualWield(bool value) { m_canDualWield = value; }
bool CanTitanGrip() const { return m_canTitanGrip ; }
void SetCanTitanGrip(bool value) { m_canTitanGrip = value; }
bool CanTameExoticPets() const { return isGameMaster() || HasAuraType(SPELL_AURA_ALLOW_TAME_PET_TYPE); }
void SetRegularAttackTime();
void SetBaseModValue(BaseModGroup modGroup, BaseModType modType, float value) { m_auraBaseMod[modGroup][modType] = value; }

View file

@ -1818,10 +1818,11 @@ enum CreatureFamily
enum CreatureTypeFlags
{
CREATURE_TYPEFLAGS_TAMEABLE = 0x0001,
CREATURE_TYPEFLAGS_HERBLOOT = 0x0100,
CREATURE_TYPEFLAGS_MININGLOOT = 0x0200,
CREATURE_TYPEFLAGS_ENGINEERLOOT = 0x8000
CREATURE_TYPEFLAGS_TAMEABLE = 0x00001,
CREATURE_TYPEFLAGS_HERBLOOT = 0x00100,
CREATURE_TYPEFLAGS_MININGLOOT = 0x00200,
CREATURE_TYPEFLAGS_ENGINEERLOOT = 0x08000,
CREATURE_TYPEFLAGS_EXOTIC = 0x10000
};
enum CreatureEliteType

View file

@ -4111,14 +4111,19 @@ SpellCastResult Spell::CheckCast(bool strict)
}
case SPELL_EFFECT_TAMECREATURE:
{
if (m_caster->GetTypeId() != TYPEID_PLAYER)
return SPELL_FAILED_BAD_TARGETS;
if (!m_targets.getUnitTarget() || m_targets.getUnitTarget()->GetTypeId() == TYPEID_PLAYER)
return SPELL_FAILED_BAD_IMPLICIT_TARGETS;
if (m_targets.getUnitTarget()->getLevel() > m_caster->getLevel())
Creature* target = (Creature*)m_targets.getUnitTarget();
if (target->getLevel() > m_caster->getLevel())
return SPELL_FAILED_HIGHLEVEL;
// use SMSG_PET_TAME_FAILURE?
if (!((Creature*)m_targets.getUnitTarget())->GetCreatureInfo()->isTameable ())
if (!target->GetCreatureInfo()->isTameable (((Player*)m_caster)->CanTameExoticPets()))
return SPELL_FAILED_BAD_TARGETS;
if(m_caster->GetPetGUID())

View file

@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__
#define __REVISION_NR_H__
#define REVISION_NR "7970"
#define REVISION_NR "7971"
#endif // __REVISION_NR_H__