aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/bindings/scripts/scripts/creature/mob_event_ai.cpp2
-rw-r--r--src/bindings/scripts/scripts/npc/npcs_special.cpp6
-rw-r--r--src/game/Creature.cpp13
-rw-r--r--src/game/Creature.h7
-rw-r--r--src/game/GridNotifiersImpl.h6
-rw-r--r--src/game/OutdoorPvPObjectiveAI.cpp2
-rw-r--r--src/game/Totem.cpp2
-rw-r--r--src/game/Unit.cpp2
8 files changed, 22 insertions, 18 deletions
diff --git a/src/bindings/scripts/scripts/creature/mob_event_ai.cpp b/src/bindings/scripts/scripts/creature/mob_event_ai.cpp
index c5ec311d310..07307a4f9a2 100644
--- a/src/bindings/scripts/scripts/creature/mob_event_ai.cpp
+++ b/src/bindings/scripts/scripts/creature/mob_event_ai.cpp
@@ -971,7 +971,7 @@ struct TRINITY_DLL_DECL Mob_EventAI : public ScriptedAI
m_creature->setActive(param1 ? true : false);
break;
case ACTION_T_SET_AGGRESSIVE:
- m_creature->SetAggressive(param1 ? true : false);
+ m_creature->SetReactState(param1);
break;
case ACTION_T_ATTACK_START_PULSE:
AttackStart(m_creature->SelectNearestTarget((float)param1));
diff --git a/src/bindings/scripts/scripts/npc/npcs_special.cpp b/src/bindings/scripts/scripts/npc/npcs_special.cpp
index d762c8803e6..5fc234b7e7a 100644
--- a/src/bindings/scripts/scripts/npc/npcs_special.cpp
+++ b/src/bindings/scripts/scripts/npc/npcs_special.cpp
@@ -840,10 +840,10 @@ struct TRINITY_DLL_DECL npc_steam_tonkAI : public ScriptedAI
m_creature->InitCharmInfo(m_creature);
m_creature->GetCharmInfo()->InitEmptyActionBar(false);
- m_creature->SetAggressive(false);
+ m_creature->SetReactState(REACT_PASSIVE);
}
else
- m_creature->SetAggressive(true);
+ m_creature->SetReactState(REACT_AGGRESSIVE);
}
};
@@ -859,7 +859,7 @@ struct TRINITY_DLL_DECL npc_tonk_mineAI : public ScriptedAI
{
npc_tonk_mineAI(Creature *c) : ScriptedAI(c)
{
- m_creature->SetAggressive(false);
+ m_creature->SetReactState(REACT_PASSIVE);
Reset();
}
diff --git a/src/game/Creature.cpp b/src/game/Creature.cpp
index f59acb0739b..460a6333dfa 100644
--- a/src/game/Creature.cpp
+++ b/src/game/Creature.cpp
@@ -144,7 +144,7 @@ Unit(), i_AI(NULL), i_AI_possessed(NULL),
lootForPickPocketed(false), lootForBody(false), m_groupLootTimer(0), lootingGroupLeaderGUID(0),
m_lootMoney(0), m_lootRecipient(0),
m_deathTimer(0), m_respawnTime(0), m_respawnDelay(25), m_corpseDelay(60), m_respawnradius(0.0f),
-m_gossipOptionLoaded(false), m_emoteState(0), m_isPet(false), m_isTotem(false), m_isAggressive(true),
+m_gossipOptionLoaded(false), m_emoteState(0), m_isPet(false), m_isTotem(false), m_reactState(REACT_AGGRESSIVE),
m_regenTimer(2000), m_defaultMovementType(IDLE_MOTION_TYPE), m_equipmentId(0),
m_AlreadyCallAssistance(false), m_regenHealth(true), m_AI_locked(false), m_isDeadByDefault(false),
m_meleeDamageSchoolMask(SPELL_SCHOOL_MASK_NORMAL),m_creatureInfo(NULL), m_DBTableGuid(0)
@@ -350,11 +350,13 @@ bool Creature::UpdateEntry(uint32 Entry, uint32 team, const CreatureData *data )
if(GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_TRIGGER)
SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
- if(isTotem() || isCivilian() || GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_TRIGGER
+ if(isTotem() || GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_TRIGGER
|| GetCreatureType() == CREATURE_TYPE_CRITTER)
- m_isAggressive = false;
+ SetReactState(REACT_PASSIVE);
+ else if(isCivilian())
+ SetReactState(REACT_DEFENSIVE);
else
- m_isAggressive = true;
+ SetReactState(REACT_AGGRESSIVE);
return true;
}
@@ -1928,7 +1930,8 @@ void Creature::CallAssistance()
bool Creature::CanAssistTo(const Unit* u, const Unit* enemy) const
{
- if(!isAggressive())
+ // is it true?
+ if(!HasReactState(REACT_AGGRESSIVE))
return false;
// we don't need help from zombies :)
diff --git a/src/game/Creature.h b/src/game/Creature.h
index d7d63574554..862e23c0ae1 100644
--- a/src/game/Creature.h
+++ b/src/game/Creature.h
@@ -428,8 +428,9 @@ class TRINITY_DLL_SPEC Creature : public Unit
bool canWalk() const { return GetCreatureInfo()->InhabitType & INHABIT_GROUND; }
bool canSwim() const { return GetCreatureInfo()->InhabitType & INHABIT_WATER; }
bool canFly() const { return GetCreatureInfo()->InhabitType & INHABIT_AIR; }
- bool isAggressive() const { return m_isAggressive; }
- void SetAggressive(bool agg) { m_isAggressive = agg; }
+ void SetReactState(ReactStates st) { m_reactState = st; }
+ ReactStates GetReactState() { return m_reactState; }
+ bool HasReactState(ReactStates state) const { return (m_reactState == state); }
///// TODO RENAME THIS!!!!!
bool isCanTrainingOf(Player* player, bool msg) const;
bool isCanIneractWithBattleMaster(Player* player, bool msg) const;
@@ -642,7 +643,7 @@ class TRINITY_DLL_SPEC Creature : public Unit
uint8 m_emoteState;
bool m_isPet; // set only in Pet::Pet
bool m_isTotem; // set only in Totem::Totem
- bool m_isAggressive;
+ ReactStates m_reactState; // for AI, not charmInfo
void RegenerateMana();
void RegenerateHealth();
uint32 m_regenTimer;
diff --git a/src/game/GridNotifiersImpl.h b/src/game/GridNotifiersImpl.h
index a4ad5a51bf7..970df635f50 100644
--- a/src/game/GridNotifiersImpl.h
+++ b/src/game/GridNotifiersImpl.h
@@ -72,7 +72,7 @@ inline void PlayerCreatureRelocationWorker(Player* pl, Creature* c)
pl->UpdateVisibilityOf(c);
// Creature AI reaction
- if(c->isAggressive() && !c->hasUnitState(UNIT_STAT_CHASE | UNIT_STAT_SEARCHING | UNIT_STAT_FLEEING))
+ if(c->HasReactState(REACT_AGGRESSIVE) && !c->hasUnitState(UNIT_STAT_CHASE | UNIT_STAT_SEARCHING | UNIT_STAT_FLEEING))
{
if( c->AI() && c->IsWithinSightDist(pl) /*c->AI()->IsVisible(pl)*/ && !c->IsInEvadeMode() )
c->AI()->MoveInLineOfSight(pl);
@@ -81,13 +81,13 @@ inline void PlayerCreatureRelocationWorker(Player* pl, Creature* c)
inline void CreatureCreatureRelocationWorker(Creature* c1, Creature* c2)
{
- if(c1->isAggressive() && !c1->hasUnitState(UNIT_STAT_CHASE | UNIT_STAT_SEARCHING | UNIT_STAT_FLEEING))
+ if(c1->HasReactState(REACT_AGGRESSIVE) && !c1->hasUnitState(UNIT_STAT_CHASE | UNIT_STAT_SEARCHING | UNIT_STAT_FLEEING))
{
if( c1->AI() && c1->IsWithinSightDist(c2) /*c1->AI()->IsVisible(c2)*/ && !c1->IsInEvadeMode() )
c1->AI()->MoveInLineOfSight(c2);
}
- if(c2->isAggressive() && !c2->hasUnitState(UNIT_STAT_CHASE | UNIT_STAT_SEARCHING | UNIT_STAT_FLEEING))
+ if(c2->HasReactState(REACT_AGGRESSIVE) && !c2->hasUnitState(UNIT_STAT_CHASE | UNIT_STAT_SEARCHING | UNIT_STAT_FLEEING))
{
if( c2->AI() && c1->IsWithinSightDist(c2) /*c2->AI()->IsVisible(c1)*/ && !c2->IsInEvadeMode() )
c2->AI()->MoveInLineOfSight(c1);
diff --git a/src/game/OutdoorPvPObjectiveAI.cpp b/src/game/OutdoorPvPObjectiveAI.cpp
index e8595e791f7..e27c583eb25 100644
--- a/src/game/OutdoorPvPObjectiveAI.cpp
+++ b/src/game/OutdoorPvPObjectiveAI.cpp
@@ -28,7 +28,7 @@
OutdoorPvPObjectiveAI::OutdoorPvPObjectiveAI(Creature &c) : i_creature(c)
{
sLog.outDebug("OutdoorPvP objective AI assigned to creature guid %u", c.GetGUIDLow());
- c.SetAggressive(true);
+ c.SetReactState(REACT_AGGRESSIVE);
}
void OutdoorPvPObjectiveAI::MoveInLineOfSight(Unit *u)
diff --git a/src/game/Totem.cpp b/src/game/Totem.cpp
index 26c471d441a..aa7094cd986 100644
--- a/src/game/Totem.cpp
+++ b/src/game/Totem.cpp
@@ -99,7 +99,7 @@ void Totem::Summon(Unit* owner)
}
if(GetEntry() == SENTRY_TOTEM_ENTRY)
- SetAggressive(true);
+ SetReactState(REACT_AGGRESSIVE);
}
void Totem::UnSummon()
diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp
index e397b767adf..c6a1f17df35 100644
--- a/src/game/Unit.cpp
+++ b/src/game/Unit.cpp
@@ -9592,7 +9592,7 @@ void Unit::CombatStart(Unit* target)
target->SetStandState(PLAYER_STATE_NONE);
if(!target->isInCombat() && target->GetTypeId() != TYPEID_PLAYER
- && ((Creature*)target)->isAggressive() && ((Creature*)target)->AI())
+ && !((Creature*)target)->HasReactState(REACT_PASSIVE) && ((Creature*)target)->AI())
{
SetInCombatWith(target);
target->SetInCombatWith(this);