*Use react state instead of isaggressive. Allow civilian to fight back.
--HG-- branch : trunk
This commit is contained in:
@@ -971,7 +971,7 @@ struct TRINITY_DLL_DECL Mob_EventAI : public ScriptedAI
|
|||||||
m_creature->setActive(param1 ? true : false);
|
m_creature->setActive(param1 ? true : false);
|
||||||
break;
|
break;
|
||||||
case ACTION_T_SET_AGGRESSIVE:
|
case ACTION_T_SET_AGGRESSIVE:
|
||||||
m_creature->SetAggressive(param1 ? true : false);
|
m_creature->SetReactState(param1);
|
||||||
break;
|
break;
|
||||||
case ACTION_T_ATTACK_START_PULSE:
|
case ACTION_T_ATTACK_START_PULSE:
|
||||||
AttackStart(m_creature->SelectNearestTarget((float)param1));
|
AttackStart(m_creature->SelectNearestTarget((float)param1));
|
||||||
|
|||||||
@@ -840,10 +840,10 @@ struct TRINITY_DLL_DECL npc_steam_tonkAI : public ScriptedAI
|
|||||||
m_creature->InitCharmInfo(m_creature);
|
m_creature->InitCharmInfo(m_creature);
|
||||||
m_creature->GetCharmInfo()->InitEmptyActionBar(false);
|
m_creature->GetCharmInfo()->InitEmptyActionBar(false);
|
||||||
|
|
||||||
m_creature->SetAggressive(false);
|
m_creature->SetReactState(REACT_PASSIVE);
|
||||||
}
|
}
|
||||||
else
|
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)
|
npc_tonk_mineAI(Creature *c) : ScriptedAI(c)
|
||||||
{
|
{
|
||||||
m_creature->SetAggressive(false);
|
m_creature->SetReactState(REACT_PASSIVE);
|
||||||
Reset();
|
Reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -144,7 +144,7 @@ Unit(), i_AI(NULL), i_AI_possessed(NULL),
|
|||||||
lootForPickPocketed(false), lootForBody(false), m_groupLootTimer(0), lootingGroupLeaderGUID(0),
|
lootForPickPocketed(false), lootForBody(false), m_groupLootTimer(0), lootingGroupLeaderGUID(0),
|
||||||
m_lootMoney(0), m_lootRecipient(0),
|
m_lootMoney(0), m_lootRecipient(0),
|
||||||
m_deathTimer(0), m_respawnTime(0), m_respawnDelay(25), m_corpseDelay(60), m_respawnradius(0.0f),
|
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_regenTimer(2000), m_defaultMovementType(IDLE_MOTION_TYPE), m_equipmentId(0),
|
||||||
m_AlreadyCallAssistance(false), m_regenHealth(true), m_AI_locked(false), m_isDeadByDefault(false),
|
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)
|
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)
|
if(GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_TRIGGER)
|
||||||
SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
|
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)
|
|| GetCreatureType() == CREATURE_TYPE_CRITTER)
|
||||||
m_isAggressive = false;
|
SetReactState(REACT_PASSIVE);
|
||||||
|
else if(isCivilian())
|
||||||
|
SetReactState(REACT_DEFENSIVE);
|
||||||
else
|
else
|
||||||
m_isAggressive = true;
|
SetReactState(REACT_AGGRESSIVE);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -1928,7 +1930,8 @@ void Creature::CallAssistance()
|
|||||||
|
|
||||||
bool Creature::CanAssistTo(const Unit* u, const Unit* enemy) const
|
bool Creature::CanAssistTo(const Unit* u, const Unit* enemy) const
|
||||||
{
|
{
|
||||||
if(!isAggressive())
|
// is it true?
|
||||||
|
if(!HasReactState(REACT_AGGRESSIVE))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// we don't need help from zombies :)
|
// we don't need help from zombies :)
|
||||||
|
|||||||
+4
-3
@@ -428,8 +428,9 @@ class TRINITY_DLL_SPEC Creature : public Unit
|
|||||||
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; }
|
||||||
bool isAggressive() const { return m_isAggressive; }
|
void SetReactState(ReactStates st) { m_reactState = st; }
|
||||||
void SetAggressive(bool agg) { m_isAggressive = agg; }
|
ReactStates GetReactState() { return m_reactState; }
|
||||||
|
bool HasReactState(ReactStates state) const { return (m_reactState == state); }
|
||||||
///// TODO RENAME THIS!!!!!
|
///// TODO RENAME THIS!!!!!
|
||||||
bool isCanTrainingOf(Player* player, bool msg) const;
|
bool isCanTrainingOf(Player* player, bool msg) const;
|
||||||
bool isCanIneractWithBattleMaster(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;
|
uint8 m_emoteState;
|
||||||
bool m_isPet; // set only in Pet::Pet
|
bool m_isPet; // set only in Pet::Pet
|
||||||
bool m_isTotem; // set only in Totem::Totem
|
bool m_isTotem; // set only in Totem::Totem
|
||||||
bool m_isAggressive;
|
ReactStates m_reactState; // for AI, not charmInfo
|
||||||
void RegenerateMana();
|
void RegenerateMana();
|
||||||
void RegenerateHealth();
|
void RegenerateHealth();
|
||||||
uint32 m_regenTimer;
|
uint32 m_regenTimer;
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ inline void PlayerCreatureRelocationWorker(Player* pl, Creature* c)
|
|||||||
pl->UpdateVisibilityOf(c);
|
pl->UpdateVisibilityOf(c);
|
||||||
|
|
||||||
// Creature AI reaction
|
// 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() )
|
if( c->AI() && c->IsWithinSightDist(pl) /*c->AI()->IsVisible(pl)*/ && !c->IsInEvadeMode() )
|
||||||
c->AI()->MoveInLineOfSight(pl);
|
c->AI()->MoveInLineOfSight(pl);
|
||||||
@@ -81,13 +81,13 @@ inline void PlayerCreatureRelocationWorker(Player* pl, Creature* c)
|
|||||||
|
|
||||||
inline void CreatureCreatureRelocationWorker(Creature* c1, Creature* c2)
|
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() )
|
if( c1->AI() && c1->IsWithinSightDist(c2) /*c1->AI()->IsVisible(c2)*/ && !c1->IsInEvadeMode() )
|
||||||
c1->AI()->MoveInLineOfSight(c2);
|
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() )
|
if( c2->AI() && c1->IsWithinSightDist(c2) /*c2->AI()->IsVisible(c1)*/ && !c2->IsInEvadeMode() )
|
||||||
c2->AI()->MoveInLineOfSight(c1);
|
c2->AI()->MoveInLineOfSight(c1);
|
||||||
|
|||||||
@@ -28,7 +28,7 @@
|
|||||||
OutdoorPvPObjectiveAI::OutdoorPvPObjectiveAI(Creature &c) : i_creature(c)
|
OutdoorPvPObjectiveAI::OutdoorPvPObjectiveAI(Creature &c) : i_creature(c)
|
||||||
{
|
{
|
||||||
sLog.outDebug("OutdoorPvP objective AI assigned to creature guid %u", c.GetGUIDLow());
|
sLog.outDebug("OutdoorPvP objective AI assigned to creature guid %u", c.GetGUIDLow());
|
||||||
c.SetAggressive(true);
|
c.SetReactState(REACT_AGGRESSIVE);
|
||||||
}
|
}
|
||||||
|
|
||||||
void OutdoorPvPObjectiveAI::MoveInLineOfSight(Unit *u)
|
void OutdoorPvPObjectiveAI::MoveInLineOfSight(Unit *u)
|
||||||
|
|||||||
+1
-1
@@ -99,7 +99,7 @@ void Totem::Summon(Unit* owner)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(GetEntry() == SENTRY_TOTEM_ENTRY)
|
if(GetEntry() == SENTRY_TOTEM_ENTRY)
|
||||||
SetAggressive(true);
|
SetReactState(REACT_AGGRESSIVE);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Totem::UnSummon()
|
void Totem::UnSummon()
|
||||||
|
|||||||
+1
-1
@@ -9592,7 +9592,7 @@ void Unit::CombatStart(Unit* target)
|
|||||||
target->SetStandState(PLAYER_STATE_NONE);
|
target->SetStandState(PLAYER_STATE_NONE);
|
||||||
|
|
||||||
if(!target->isInCombat() && target->GetTypeId() != TYPEID_PLAYER
|
if(!target->isInCombat() && target->GetTypeId() != TYPEID_PLAYER
|
||||||
&& ((Creature*)target)->isAggressive() && ((Creature*)target)->AI())
|
&& !((Creature*)target)->HasReactState(REACT_PASSIVE) && ((Creature*)target)->AI())
|
||||||
{
|
{
|
||||||
SetInCombatWith(target);
|
SetInCombatWith(target);
|
||||||
target->SetInCombatWith(this);
|
target->SetInCombatWith(this);
|
||||||
|
|||||||
Reference in New Issue
Block a user