diff --git a/src/game/Level2.cpp b/src/game/Level2.cpp index ff13a0a0a..a9d25d812 100644 --- a/src/game/Level2.cpp +++ b/src/game/Level2.cpp @@ -2172,50 +2172,7 @@ bool ChatHandler::HandleNpcTameCommand(char* /*args*/) return false; } - CreatureInfo const* cInfo = creatureTarget->GetCreatureInfo(); - - if (!cInfo->isTameable(player->CanTameExoticPets())) - { - PSendSysMessage(LANG_CREATURE_NON_TAMEABLE,cInfo->Entry); - SetSentErrorMessage(true); - return false; - } - - // Everything looks OK, create new pet - Pet* pet = player->CreateTamedPetFrom (creatureTarget); - if (!pet) - { - PSendSysMessage (LANG_CREATURE_NON_TAMEABLE,cInfo->Entry); - SetSentErrorMessage (true); - return false; - } - - // place pet before player - float x,y,z; - player->GetClosePoint(x, y, z, creatureTarget->GetObjectBoundingRadius(), CONTACT_DISTANCE); - pet->Relocate (x,y,z,M_PI_F-player->GetOrientation ()); - - // set pet to defensive mode by default (some classes can't control controlled pets in fact). - pet->GetCharmInfo()->SetReactState(REACT_DEFENSIVE); - - // calculate proper level - uint32 level = (creatureTarget->getLevel() < (player->getLevel() - 5)) ? (player->getLevel() - 5) : creatureTarget->getLevel(); - - // prepare visual effect for levelup - pet->SetUInt32Value(UNIT_FIELD_LEVEL, level - 1); - - // add to world - pet->GetMap()->Add((Creature*)pet); - - // visual effect for levelup - pet->SetUInt32Value(UNIT_FIELD_LEVEL, level); - - // caster have pet now - player->SetPet(pet); - - pet->SavePetToDB(PET_SAVE_AS_CURRENT); - player->PetSpellInitialize(); - + player->CastSpell(creatureTarget, 13481, true); // Tame Beast, triggered effect return true; } //npc phasemask handling diff --git a/src/game/Spell.cpp b/src/game/Spell.cpp index a26f5255c..972bb93a3 100644 --- a/src/game/Spell.cpp +++ b/src/game/Spell.cpp @@ -43,6 +43,7 @@ #include "VMapFactory.h" #include "BattleGround.h" #include "Util.h" +#include "Chat.h" #define SPELL_CHANNEL_UPDATE_INTERVAL (1 * IN_MILLISECONDS) @@ -5003,7 +5004,15 @@ SpellCastResult Spell::CheckCast(bool strict) Player* plrCaster = (Player*)caster; - if(plrCaster->getClass() != CLASS_HUNTER) + bool gmmode = m_triggeredBySpellInfo == NULL; + + if (gmmode && !ChatHandler(plrCaster).FindCommand("npc tame")) + { + plrCaster->SendPetTameFailure(PETTAME_UNKNOWNERROR); + return SPELL_FAILED_DONT_REPORT; + } + + if(plrCaster->getClass() != CLASS_HUNTER && !gmmode) { plrCaster->SendPetTameFailure(PETTAME_UNITSCANTTAME); return SPELL_FAILED_DONT_REPORT; @@ -5017,13 +5026,13 @@ SpellCastResult Spell::CheckCast(bool strict) return SPELL_FAILED_DONT_REPORT; } - if (target->getLevel() > plrCaster->getLevel()) + if (target->getLevel() > plrCaster->getLevel() && !gmmode) { plrCaster->SendPetTameFailure(PETTAME_TOOHIGHLEVEL); return SPELL_FAILED_DONT_REPORT; } - if (target->GetCreatureInfo()->IsExotic() && !plrCaster->CanTameExoticPets()) + if (target->GetCreatureInfo()->IsExotic() && !plrCaster->CanTameExoticPets() && !gmmode) { plrCaster->SendPetTameFailure(PETTAME_CANTCONTROLEXOTIC); return SPELL_FAILED_DONT_REPORT; diff --git a/src/game/SpellEffects.cpp b/src/game/SpellEffects.cpp index 2e52e48ca..3e487079d 100644 --- a/src/game/SpellEffects.cpp +++ b/src/game/SpellEffects.cpp @@ -5312,15 +5312,47 @@ void Spell::EffectTameCreature(SpellEffectIndex /*eff_idx*/) //SendChannelUpdate(0); finish(); - Pet* pet = plr->CreateTamedPetFrom(creatureTarget, m_spellInfo->Id); - if(!pet) // in versy specific state like near world end/etc. + Pet* pet = new Pet(HUNTER_PET); + + if(!pet->CreateBaseAtCreature(creatureTarget)) + { + delete pet; return; + } + + pet->SetOwnerGuid(plr->GetObjectGuid()); + pet->SetCreatorGuid(plr->GetObjectGuid()); + pet->setFaction(plr->getFaction()); + pet->SetUInt32Value(UNIT_CREATED_BY_SPELL, m_spellInfo->Id); + pet->SetUInt32Value(UNIT_FIELD_FLAGS, UNIT_FLAG_PVP_ATTACKABLE); + + if (pet->IsPvP()) + pet->SetPvP(true); + + if (pet->IsFFAPvP()) + pet->SetFFAPvP(true); + + // level of hunter pet can't be less owner level at 5 levels + uint32 level = creatureTarget->getLevel() + 5 < plr->getLevel() ? (plr->getLevel() - 5) : creatureTarget->getLevel(); + + if (!pet->InitStatsForLevel(level)) + { + sLog.outError("Pet::InitStatsForLevel() failed for creature (Entry: %u)!", creatureTarget->GetEntry()); + delete pet; + return; + } + + pet->GetCharmInfo()->SetPetNumber(sObjectMgr.GeneratePetNumber(), true); + // this enables pet details window (Shift+P) + pet->AIM_Initialize(); + pet->InitPetCreateSpells(); + pet->InitLevelupSpellsForLevel(); + pet->InitTalentForLevel(); + pet->SetHealth(pet->GetMaxHealth()); // "kill" original creature creatureTarget->ForcedDespawn(); - uint32 level = (creatureTarget->getLevel() < (plr->getLevel() - 5)) ? (plr->getLevel() - 5) : creatureTarget->getLevel(); - // prepare visual effect for levelup pet->SetUInt32Value(UNIT_FIELD_LEVEL, level - 1); diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp index 62ea6050f..5fba51ac9 100644 --- a/src/game/Unit.cpp +++ b/src/game/Unit.cpp @@ -10397,51 +10397,6 @@ void Unit::RemovePetAura(PetAura const* petSpell) pet->RemoveAurasDueToSpell(petSpell->GetAura(pet->GetEntry())); } -Pet* Unit::CreateTamedPetFrom(Creature* creatureTarget,uint32 spell_id) -{ - Pet* pet = new Pet(HUNTER_PET); - - if(!pet->CreateBaseAtCreature(creatureTarget)) - { - delete pet; - return NULL; - } - - pet->SetOwnerGuid(GetObjectGuid()); - pet->SetCreatorGuid(GetObjectGuid()); - pet->setFaction(getFaction()); - pet->SetUInt32Value(UNIT_CREATED_BY_SPELL, spell_id); - - if(GetTypeId()==TYPEID_PLAYER) - pet->SetUInt32Value(UNIT_FIELD_FLAGS, UNIT_FLAG_PVP_ATTACKABLE); - - if(IsPvP()) - pet->SetPvP(true); - - if(IsFFAPvP()) - pet->SetFFAPvP(true); - - // level of hunter pet can't be less owner level at 5 levels - uint32 level = creatureTarget->getLevel() + 5 < getLevel() ? (getLevel() - 5) : creatureTarget->getLevel(); - - if(!pet->InitStatsForLevel(level)) - { - sLog.outError("Pet::InitStatsForLevel() failed for creature (Entry: %u)!",creatureTarget->GetEntry()); - delete pet; - return NULL; - } - - pet->GetCharmInfo()->SetPetNumber(sObjectMgr.GeneratePetNumber(), true); - // this enables pet details window (Shift+P) - pet->AIM_Initialize(); - pet->InitPetCreateSpells(); - pet->InitLevelupSpellsForLevel(); - pet->InitTalentForLevel(); - pet->SetHealth(pet->GetMaxHealth()); - - return pet; -} - void Unit::RemoveAurasAtMechanicImmunity(uint32 mechMask, uint32 exceptSpellId, bool non_positive /*= false*/) { Unit::SpellAuraHolderMap& auras = GetSpellAuraHolderMap(); diff --git a/src/game/Unit.h b/src/game/Unit.h index a0b14adcc..c52cda59c 100644 --- a/src/game/Unit.h +++ b/src/game/Unit.h @@ -1552,8 +1552,6 @@ class MANGOS_DLL_SPEC Unit : public WorldObject CharmInfo* GetCharmInfo() { return m_charmInfo; } CharmInfo* InitCharmInfo(Unit* charm); - Pet* CreateTamedPetFrom(Creature* creatureTarget,uint32 spell_id = 0); - uint64 const& GetTotemGUID(TotemSlot slot) const { return m_TotemSlot[slot]; } Totem* GetTotem(TotemSlot slot) const; bool IsAllTotemSlotsUsed() const; diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index c2f47855e..7b91ec5ac 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "11214" + #define REVISION_NR "11215" #endif // __REVISION_NR_H__