Skip to content

Commit

Permalink
Core/AI: Fully move react state check from CreatureUnitRelocationWork…
Browse files Browse the repository at this point in the history
…er to CreatureAI::MoveInLineOfSight. This means that AI for passive/defensive creatures can now once again use MoveInLineOfSight (and fixes that weird thing where triggers decided it would be funny to attack players).
  • Loading branch information
Treeston committed Feb 11, 2016
1 parent 47493fd commit 8e6fb3b
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/server/game/AI/CreatureAI.cpp
Expand Up @@ -133,7 +133,7 @@ void CreatureAI::MoveInLineOfSight(Unit* who)
if (me->GetCreatureType() == CREATURE_TYPE_NON_COMBAT_PET) // non-combat pets should just stand there and look good;)
return;

if (me->CanStartAttack(who, false))
if (me->HasReactState(REACT_AGGRESSIVE) && me->CanStartAttack(who, false))
AttackStart(who);
//else if (who->GetVictim() && me->IsFriendlyTo(who)
// && me->IsWithinDistInMap(who, sWorld->getIntConfig(CONFIG_CREATURE_FAMILY_ASSISTANCE_RADIUS))
Expand Down
2 changes: 1 addition & 1 deletion src/server/game/Grids/Notifiers/GridNotifiers.cpp
Expand Up @@ -131,7 +131,7 @@ inline void CreatureUnitRelocationWorker(Creature* c, Unit* u)
if (!u->IsAlive() || !c->IsAlive() || c == u || u->IsInFlight())
return;

if ((c->HasReactState(REACT_AGGRESSIVE) || c->IsTrigger()) && !c->HasUnitState(UNIT_STATE_SIGHTLESS))
if (!c->HasUnitState(UNIT_STATE_SIGHTLESS))
{
if (c->IsAIEnabled && c->CanSeeOrDetect(u, false, true))
c->AI()->MoveInLineOfSight_Safe(u);
Expand Down

2 comments on commit 8e6fb3b

@Trisjdc
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could be all put inside Creature::CanStartAttack, including the UNIT_STATE_SIGHTLESS check. Creature::CanStartAttack is only supposed to be used for the MoveInLoS attack checks.

@Treeston
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, but arguably, if the creature is sightless, then MoveInLineOfSight shouldn't be called, ever.

While CanStartAttack is used that way now, it's hard to tell what might happen in the future, so I'd prefer to keep it as is.

Please sign in to comment.