*Add creature extra flag "immune to taunt" and "charmed ai".

*Fix the bug that creature still use its ai when charmed. Only creature with charmed ai flag can use its ai when charmed.

--HG--
branch : trunk
This commit is contained in:
megamage
2009-01-27 15:23:26 -06:00
parent ed6337550e
commit beb293383c
2 changed files with 16 additions and 1 deletions

View File

@@ -375,6 +375,12 @@ bool Creature::UpdateEntry(uint32 Entry, uint32 team, const CreatureData *data )
else
SetReactState(REACT_AGGRESSIVE);
if(GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_NO_TAUNT)
{
ApplySpellImmune(0, IMMUNITY_STATE, SPELL_AURA_MOD_TAUNT, true);
ApplySpellImmune(0, IMMUNITY_EFFECT,SPELL_EFFECT_ATTACK_ME, true);
}
return true;
}
@@ -482,7 +488,7 @@ void Creature::Update(uint32 diff)
if(!isAlive())
break;
if(!IsInEvadeMode())
if(!IsInEvadeMode() && m_AI_enabled)
{
// do not allow the AI to be changed during update
m_AI_locked = true;
@@ -599,6 +605,7 @@ bool Creature::AIM_Initialize(CreatureAI* ai)
i_AI = ai ? ai : FactorySelector::selectAI(this);
if (oldAI)
delete oldAI;
m_AI_enabled = true;
return true;
}
@@ -611,6 +618,9 @@ void Creature::InitPossessedAI()
// Signal the old AI that it's been disabled
i_AI->OnPossess(true);
if(!(GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_CHARM_AI))
m_AI_enabled = false;
}
void Creature::DisablePossessedAI()
@@ -621,6 +631,8 @@ void Creature::DisablePossessedAI()
// Signal the old AI that it's been re-enabled
i_AI->OnPossess(false);
m_AI_enabled = true;
}
bool Creature::Create (uint32 guidlow, Map *map, uint32 Entry, uint32 team, const CreatureData *data)

View File

@@ -132,6 +132,8 @@ enum CreatureFlagsExtra
CREATURE_FLAG_EXTRA_NO_XP_AT_KILL = 0x00000040, // creature kill not provide XP
CREATURE_FLAG_EXTRA_TRIGGER = 0x00000080, // trigger creature
CREATURE_FLAG_EXTRA_WORLDEVENT = 0x00004000, // custom flag for world event creatures (left room for merging)
CREATURE_FLAG_EXTRA_CHARM_AI = 0x00008000, // use ai when charmed
CREATURE_FLAG_EXTRA_NO_TAUNT = 0x00010000, // cannot be taunted
};
// GCC have alternative #pragma pack(N) syntax and old gcc version not support pack(push,N), also any gcc version not support it at some platform
@@ -671,6 +673,7 @@ class TRINITY_DLL_SPEC Creature : public Unit
bool m_AlreadyCallAssistance;
bool m_regenHealth;
bool m_AI_locked;
bool m_AI_enabled;
bool m_isDeadByDefault;
SpellSchoolMask m_meleeDamageSchoolMask;