[7655] Fixed choosing AI for pets

This commit is contained in:
arrai 2009-04-12 11:00:20 +02:00
parent db429d2a20
commit db7da450cd
2 changed files with 13 additions and 13 deletions

View file

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

View file

@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__
#define __REVISION_NR_H__
#define REVISION_NR "7654"
#define REVISION_NR "7655"
#endif // __REVISION_NR_H__