[11215] Replace direct code use in .npc tame by spell cast.

Only work different from old way: target creature despawned.
So if this not expected use .respawn to it in gm mode or area respawn.

Code simplification suggested originally by rsa.
This commit is contained in:
VladimirMangos 2011-03-03 21:31:02 +03:00
parent 9312ef7e78
commit 06fe777f82
6 changed files with 50 additions and 99 deletions

View file

@ -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;