From 9be885c99bf16abe55699d95d73c4ad35e1452e3 Mon Sep 17 00:00:00 2001 From: VladimirMangos Date: Tue, 14 Apr 2009 02:10:32 +0400 Subject: [PATCH] [7666] For heroic mode creature use AIName from normal mode version in same way as done for ScriptName. Also at creature templates loading check that AIName/ScriptName not set for heroic mode creature versions. --- src/game/Creature.cpp | 9 +++++++-- src/game/Creature.h | 5 +++-- src/game/CreatureAISelector.cpp | 4 +--- src/game/CreatureEventAI.cpp | 2 +- src/game/ObjectMgr.cpp | 12 ++++++++++++ src/shared/revision_nr.h | 2 +- 6 files changed, 25 insertions(+), 9 deletions(-) diff --git a/src/game/Creature.cpp b/src/game/Creature.cpp index 392f938f..ca5fb4a1 100644 --- a/src/game/Creature.cpp +++ b/src/game/Creature.cpp @@ -1993,12 +1993,17 @@ uint32 Creature::getLevelForTarget( Unit const* target ) const return level; } -std::string Creature::GetScriptName() +std::string Creature::GetAIName() const +{ + return ObjectMgr::GetCreatureTemplate(GetEntry())->AIName; +} + +std::string Creature::GetScriptName() const { return objmgr.GetScriptName(GetScriptId()); } -uint32 Creature::GetScriptId() +uint32 Creature::GetScriptId() const { return ObjectMgr::GetCreatureTemplate(GetEntry())->ScriptID; } diff --git a/src/game/Creature.h b/src/game/Creature.h index 1d785615..4536aaf4 100644 --- a/src/game/Creature.h +++ b/src/game/Creature.h @@ -532,8 +532,9 @@ class MANGOS_DLL_SPEC Creature : public Unit CreatureInfo const *GetCreatureInfo() const { return m_creatureInfo; } CreatureDataAddon const* GetCreatureAddon() const; - std::string GetScriptName(); - uint32 GetScriptId(); + std::string GetAIName() const; + std::string GetScriptName() const; + uint32 GetScriptId() const; void prepareGossipMenu( Player *pPlayer, uint32 gossipid = 0 ); void sendPreparedGossip( Player* player ); diff --git a/src/game/CreatureAISelector.cpp b/src/game/CreatureAISelector.cpp index 41013b97..a3f4e517 100644 --- a/src/game/CreatureAISelector.cpp +++ b/src/game/CreatureAISelector.cpp @@ -38,12 +38,10 @@ namespace FactorySelector return scriptedAI; CreatureAIRegistry &ai_registry(CreatureAIRepository::Instance()); - assert( creature->GetCreatureInfo() != NULL ); - CreatureInfo const *cinfo=creature->GetCreatureInfo(); const CreatureAICreator *ai_factory = NULL; - std::string ainame=cinfo->AIName; + std::string ainame=creature->GetAIName(); // select by NPC flags _first_ - otherwise EventAI might be choosen for pets/totems // excplicit check for isControlled() and owner type to allow guardian, mini-pets and pets controlled by NPCs to be scripted by EventAI diff --git a/src/game/CreatureEventAI.cpp b/src/game/CreatureEventAI.cpp index 00b32acf..3d08eab8 100644 --- a/src/game/CreatureEventAI.cpp +++ b/src/game/CreatureEventAI.cpp @@ -32,7 +32,7 @@ int CreatureEventAI::Permissible(const Creature *creature) { - if( creature->GetCreatureInfo()->AIName == "EventAI" ) + if( creature->GetAIName() == "EventAI" ) return PERMIT_BASE_SPECIAL; return PERMIT_BASE_NO; } diff --git a/src/game/ObjectMgr.cpp b/src/game/ObjectMgr.cpp index 9c1d2fc2..90ef2211 100644 --- a/src/game/ObjectMgr.cpp +++ b/src/game/ObjectMgr.cpp @@ -528,6 +528,18 @@ void ObjectMgr::LoadCreatureTemplates() continue; } + if(heroicInfo->AIName && *heroicInfo->AIName) + { + sLog.outErrorDb("Heroic mode creature (Entry: %u) has `AIName`, but in any case will used normal mode creature (Entry: %u) AIName.",cInfo->HeroicEntry,i); + continue; + } + + if(heroicInfo->ScriptID) + { + sLog.outErrorDb("Heroic mode creature (Entry: %u) has `ScriptName`, but in any case will used normal mode creature (Entry: %u) ScriptName.",cInfo->HeroicEntry,i); + continue; + } + hasHeroicEntries.insert(i); heroicEntries.insert(cInfo->HeroicEntry); } diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 94702615..f6f1bce2 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 "7665" + #define REVISION_NR "7666" #endif // __REVISION_NR_H__ -- 2.11.4.GIT