Fix bug that creatures which use FleeingMovementGenerator would not attack after respawning.

Bug was caused by improper react state

--HG--
branch : trunk
This commit is contained in:
Machiavelli
2010-06-27 03:47:18 +02:00
parent 0fd3e47edc
commit 26f4fae802
2 changed files with 15 additions and 7 deletions
@@ -410,13 +410,7 @@ bool Creature::UpdateEntry(uint32 Entry, uint32 team, const CreatureData *data)
if (isTrigger()) if (isTrigger())
SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
if (isTotem() || isTrigger() InitializeReactState();
|| GetCreatureType() == CREATURE_TYPE_CRITTER)
SetReactState(REACT_PASSIVE);
/*else if (isCivilian())
SetReactState(REACT_DEFENSIVE);*/
else
SetReactState(REACT_AGGRESSIVE);
if (cInfo->flags_extra & CREATURE_FLAG_EXTRA_NO_TAUNT) if (cInfo->flags_extra & CREATURE_FLAG_EXTRA_NO_TAUNT)
{ {
@@ -1602,6 +1596,9 @@ void Creature::Respawn(bool force)
uint16 poolid = GetDBTableGUIDLow() ? poolhandler.IsPartOfAPool<Creature>(GetDBTableGUIDLow()) : 0; uint16 poolid = GetDBTableGUIDLow() ? poolhandler.IsPartOfAPool<Creature>(GetDBTableGUIDLow()) : 0;
if (poolid) if (poolid)
poolhandler.UpdatePool<Creature>(poolid, GetDBTableGUIDLow()); poolhandler.UpdatePool<Creature>(poolid, GetDBTableGUIDLow());
//Re-initialize reactstate that could be altered by movementgenerators
InitializeReactState();
} }
UpdateObjectVisibility(); UpdateObjectVisibility();
@@ -428,9 +428,20 @@ class Creature : public Unit, public GridObject<Creature>
bool canWalk() const { return GetCreatureInfo()->InhabitType & INHABIT_GROUND; } bool canWalk() const { return GetCreatureInfo()->InhabitType & INHABIT_GROUND; }
bool canSwim() const { return GetCreatureInfo()->InhabitType & INHABIT_WATER; } bool canSwim() const { return GetCreatureInfo()->InhabitType & INHABIT_WATER; }
//bool canFly() const { return GetCreatureInfo()->InhabitType & INHABIT_AIR; } //bool canFly() const { return GetCreatureInfo()->InhabitType & INHABIT_AIR; }
void SetReactState(ReactStates st) { m_reactState = st; } void SetReactState(ReactStates st) { m_reactState = st; }
ReactStates GetReactState() { return m_reactState; } ReactStates GetReactState() { return m_reactState; }
bool HasReactState(ReactStates state) const { return (m_reactState == state); } bool HasReactState(ReactStates state) const { return (m_reactState == state); }
void InitializeReactState()
{
if (isTotem() || isTrigger() || GetCreatureType() == CREATURE_TYPE_CRITTER)
SetReactState(REACT_PASSIVE);
else
SetReactState(REACT_AGGRESSIVE);
/*else if (isCivilian())
SetReactState(REACT_DEFENSIVE);*/;
}
///// TODO RENAME THIS!!!!! ///// TODO RENAME THIS!!!!!
bool isCanTrainingOf(Player* player, bool msg) const; bool isCanTrainingOf(Player* player, bool msg) const;
bool isCanInteractWithBattleMaster(Player* player, bool msg) const; bool isCanInteractWithBattleMaster(Player* player, bool msg) const;