diff --git a/src/game/CreatureAISelector.cpp b/src/game/CreatureAISelector.cpp index f9a76095f..41013b97f 100644 --- a/src/game/CreatureAISelector.cpp +++ b/src/game/CreatureAISelector.cpp @@ -45,25 +45,25 @@ namespace FactorySelector std::string ainame=cinfo->AIName; + // 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 + Unit *owner=NULL; + if(creature->isPet() && ((Pet*)creature)->isControlled() && (owner=creature->GetOwner()) && owner->GetTypeId()==TYPEID_PLAYER || creature->isCharmed()) + ai_factory = ai_registry.GetRegistryItem("PetAI"); + else if(creature->isTotem()) + ai_factory = ai_registry.GetRegistryItem("TotemAI"); + // select by script name - if( !ainame.empty()) + if( !ai_factory && !ainame.empty()) ai_factory = ai_registry.GetRegistryItem( ainame.c_str() ); - // select by NPC flags - if(!ai_factory) - { - if( creature->isGuard() ) - ai_factory = ai_registry.GetRegistryItem("GuardAI"); - else if(creature->isPet() || creature->isCharmed()) - ai_factory = ai_registry.GetRegistryItem("PetAI"); - else if(creature->isTotem()) - ai_factory = ai_registry.GetRegistryItem("TotemAI"); - } + if(!ai_factory && creature->isGuard() ) + ai_factory = ai_registry.GetRegistryItem("GuardAI"); // select by permit check if(!ai_factory) { - int best_val = -1; + int best_val = PERMIT_BASE_NO; typedef CreatureAIRegistry::RegistryMapType RMT; RMT const &l = ai_registry.GetRegisteredItems(); for( RMT::const_iterator iter = l.begin(); iter != l.end(); ++iter) diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index eabe09dab..8e3a54bd0 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 "7654" + #define REVISION_NR "7655" #endif // __REVISION_NR_H__