Core/GuardAI: Guards don't evade if the target casts Vanish and also can detect players with Feign Death.

Core/Scripts: Moved scripts from ScriptedGuardAI to guards.cpp
Core/Creature: Removed custom npcflags UNIT_NPC_FLAG_GUARD (now moved to flag_extras) and UNIT_NPC_FLAG_OUTDOORPVP (not used)

Thanks to Kaelima, Xanadu, Shauren and linencloth.

Signed-off-by: Manuel Carrasco <[email protected]>
This commit is contained in:
Manuel Carrasco
2011-02-10 22:36:35 -03:00
parent 71849e0efe
commit 6b2ffc9039
16 changed files with 337 additions and 398 deletions
+20 -1
View File
@@ -1421,6 +1421,17 @@ bool Creature::isVisibleForInState(WorldObject const* seer) const
return false;
}
bool Creature::canSeeAlways(WorldObject const* obj) const
{
if (Unit::canSeeAlways(obj))
return true;
if (IsAIEnabled && AI()->CanSeeAlways(obj))
return true;
return false;
}
bool Creature::canStartAttack(Unit const* who, bool force) const
{
if (isCivilian())
@@ -1960,10 +1971,18 @@ bool Creature::_IsTargetAcceptable(const Unit *target) const
// if the target cannot be attacked, the target is not acceptable
if (IsFriendlyTo(target)
|| !target->isAttackableByAOE()
|| target->HasUnitState(UNIT_STAT_DIED)
|| (m_vehicle && (IsOnVehicle(target) || m_vehicle->GetBase()->IsOnVehicle(target))))
return false;
if (target->HasUnitState(UNIT_STAT_DIED))
{
// guards can detect fake death
if (isGuard() && target->HasFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_FEIGN_DEATH))
return true;
else
return false;
}
const Unit *myVictim = getAttackerForHelper();
const Unit *targetVictim = target->getAttackerForHelper();
+5 -2
View File
@@ -49,7 +49,7 @@ enum CreatureFlagsExtra
CREATURE_FLAG_EXTRA_TRIGGER = 0x00000080, // trigger creature
CREATURE_FLAG_EXTRA_NO_TAUNT = 0x00000100, // creature is immune to taunt auras and effect attack me
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_GUARD = 0x00008000, // Creature is guard
CREATURE_FLAG_EXTRA_NO_CRIT = 0x00020000, // creature can't do critical strikes
CREATURE_FLAG_EXTRA_NO_SKILLGAIN = 0x00040000, // creature won't increase weapon skills
CREATURE_FLAG_EXTRA_TAUNT_DIMINISH = 0x00080000, // Taunt is a subject to diminishing returns on this creautre
@@ -61,7 +61,8 @@ enum CreatureFlagsExtra
CREATURE_FLAG_EXTRA_NO_PARRY | CREATURE_FLAG_EXTRA_NO_PARRY_HASTEN | CREATURE_FLAG_EXTRA_NO_BLOCK | \
CREATURE_FLAG_EXTRA_NO_CRUSH | CREATURE_FLAG_EXTRA_NO_XP_AT_KILL | CREATURE_FLAG_EXTRA_TRIGGER | \
CREATURE_FLAG_EXTRA_NO_TAUNT | CREATURE_FLAG_EXTRA_WORLDEVENT | CREATURE_FLAG_EXTRA_NO_CRIT | \
CREATURE_FLAG_EXTRA_NO_SKILLGAIN | CREATURE_FLAG_EXTRA_TAUNT_DIMINISH | CREATURE_FLAG_EXTRA_ALL_DIMINISH)
CREATURE_FLAG_EXTRA_NO_SKILLGAIN | CREATURE_FLAG_EXTRA_TAUNT_DIMINISH | CREATURE_FLAG_EXTRA_ALL_DIMINISH | \
CREATURE_FLAG_EXTRA_GUARD)
// 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
#if defined(__GNUC__)
@@ -435,6 +436,7 @@ class Creature : public Unit, public GridObject<Creature>
bool isRacialLeader() const { return GetCreatureInfo()->RacialLeader; }
bool isCivilian() const { return GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_CIVILIAN; }
bool isTrigger() const { return GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_TRIGGER; }
bool isGuard() const { return GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_GUARD; }
bool canWalk() const { return GetCreatureInfo()->InhabitType & INHABIT_GROUND; }
bool canSwim() const { return GetCreatureInfo()->InhabitType & INHABIT_WATER; }
//bool canFly() const { return GetCreatureInfo()->InhabitType & INHABIT_AIR; }
@@ -729,6 +731,7 @@ class Creature : public Unit, public GridObject<Creature>
uint32 guid_transport;
bool isVisibleForInState(WorldObject const* seer) const;
bool canSeeAlways(WorldObject const* obj) const;
private:
//WaypointMovementGenerator vars
uint32 m_waypointID;