Skip to content

Commit

Permalink
Merge pull request liyunfan1223#343 from Jgoodwin64/stay-bug-fix
Browse files Browse the repository at this point in the history
Fixed bug in StayActions.cpp
  • Loading branch information
fuzzdeveloper authored Jul 16, 2024
2 parents cabc09f + 159980f commit 9ef0f64
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions src/strategy/actions/StayActions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ bool StayActionBase::Stay()

//if (!urand(0, 10))
//botAI->PlaySound(TEXT_EMOTE_YAWN);

if (bot->GetMotionMaster()->GetCurrentMovementGeneratorType() == FLIGHT_MOTION_TYPE)
return false;

Expand All @@ -26,12 +25,13 @@ bool StayActionBase::Stay()
context->GetValue<time_t>("stay time")->Set(stayTime);
}

if (!bot->isMoving())
return false;

bot->StopMoving();
bot->ClearUnitState(UNIT_STATE_CHASE);
bot->ClearUnitState(UNIT_STATE_FOLLOW);
// Stop the bot from moving immediately when action is called
if (bot->isMoving())
{
bot->StopMoving();
bot->ClearUnitState(UNIT_STATE_CHASE);
bot->ClearUnitState(UNIT_STATE_FOLLOW);
}

return true;
}
Expand All @@ -43,7 +43,8 @@ bool StayAction::Execute(Event event)

bool StayAction::isUseful()
{
return !AI_VALUE2(bool, "moving", "self target");
// Only useful if the bot is currently moving
return AI_VALUE2(bool, "moving", "self target");
}

bool SitAction::Execute(Event event)
Expand Down

0 comments on commit 9ef0f64

Please sign in to comment.