Skip to content

Commit

Permalink
NPCBots: never interrupt movement to cast non-instant spells during `…
Browse files Browse the repository at this point in the history
….npcbot sendto` movement, do not `sendto` bots in fullstop state (send position can be marked still)

(cherry picked from commit 33b73b03c19e2247d3838f6e26c586a4928bdd92)
  • Loading branch information
trickerer committed Jan 22, 2023
1 parent 425827f commit 9e8c167
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 17 deletions.
23 changes: 12 additions & 11 deletions src/server/game/AI/NpcBots/bot_ai.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -769,25 +769,26 @@ bool bot_ai::doCast(Unit* victim, uint32 spellId, TriggerCastFlags flags)
}

//spells with cast time
if (me->isMoving() && !HasBotCommandState(BOT_COMMAND_ISSUED_ORDER) && !HasBotCommandState(BOT_COMMAND_STAY) &&
if (me->isMoving() && !(flags & TRIGGERED_CAST_DIRECTLY) && !(m_botSpellInfo->Attributes & SPELL_ATTR0_ON_NEXT_SWING) &&
!m_botSpellInfo->IsAutoRepeatRangedSpell() &&
((m_botSpellInfo->InterruptFlags & SPELL_INTERRUPT_FLAG_MOVEMENT)
//autorepeat spells missing SPELL_INTERRUPT_FLAG_MOVEMENT
|| spellId == SHOOT_WAND
//channeled spells missing SPELL_INTERRUPT_FLAG_MOVEMENT
//Mind Flay (Rank 8)
|| spellId == 48155) &&
!(m_botSpellInfo->Attributes & SPELL_ATTR0_ON_NEXT_SWING) && !m_botSpellInfo->IsAutoRepeatRangedSpell() &&
!(flags & TRIGGERED_CAST_DIRECTLY) && (m_botSpellInfo->IsChanneled() || m_botSpellInfo->CalcCastTime()))
(m_botSpellInfo->IsChanneled() || m_botSpellInfo->CalcCastTime()))
{
if (JumpingOrFalling())
return false;
if (!me->GetVictim() && me->IsInWorld() && (me->GetMap()->IsRaid() || me->GetMap()->IsHeroic()))
return false;
if (!m_botSpellInfo->HasEffect(SPELL_EFFECT_HEAL) && Rand() > (IAmFree() ? 80 : 50))
return false;
if (!HasBotCommandState(BOT_COMMAND_ISSUED_ORDER))
{
if (JumpingOrFalling() || HasBotCommandState(BOT_COMMAND_STAY))
return false;
if (!me->GetVictim() && me->IsInWorld() && (me->GetMap()->IsRaid() || me->GetMap()->IsHeroic()))
return false;
if (!m_botSpellInfo->HasEffect(SPELL_EFFECT_HEAL) && Rand() > (IAmFree() ? 80 : 50))
return false;
}

//if (m_botSpellInfo->IsChanneled())
// TC_LOG_ERROR("entities.player", "bot_ai::doCast(): spell %u interrupts movement", spellId);
me->BotStopMovement();
}

Expand Down
12 changes: 6 additions & 6 deletions src/server/game/AI/NpcBots/botcommands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1098,7 +1098,7 @@ class script_bot_commands : public CommandScript
{
Unit const* target = handler->getSelectedCreature();
Creature const* bot = target ? owner->GetBotMgr()->GetBot(target->GetGUID()) : nullptr;
if (bot && bot->IsAlive())
if (bot && bot->IsAlive() && !bot->GetBotAI()->HasBotCommandState(BOT_COMMAND_FULLSTOP))
{
bot->GetBotAI()->SetBotAwaitState(BOT_AWAIT_SEND);
return return_success(handler, { bot->GetName() });
Expand All @@ -1110,7 +1110,7 @@ class script_bot_commands : public CommandScript
for (decltype(names)::value_type::value_type name : *names)
{
Creature const* bot = owner->GetBotMgr()->GetBotByName(name);
if (bot && bot->IsAlive())
if (bot && bot->IsAlive() && !bot->GetBotAI()->HasBotCommandState(BOT_COMMAND_FULLSTOP))
{
++count;
bot->GetBotAI()->SetBotAwaitState(BOT_AWAIT_SEND);
Expand Down Expand Up @@ -1155,7 +1155,7 @@ class script_bot_commands : public CommandScript
{
Unit const* target = handler->getSelectedCreature();
Creature const* bot = target ? owner->GetBotMgr()->GetBot(target->GetGUID()) : nullptr;
if (bot && bot->IsAlive())
if (bot && bot->IsAlive() && !bot->GetBotAI()->HasBotCommandState(BOT_COMMAND_FULLSTOP))
{
bot->GetBotAI()->MoveToLastSendPosition();
return return_success(handler, { bot->GetName() });
Expand All @@ -1167,7 +1167,7 @@ class script_bot_commands : public CommandScript
for (decltype(names)::value_type::value_type name : *names)
{
Creature const* bot = owner->GetBotMgr()->GetBotByName(name);
if (bot && bot->IsAlive())
if (bot && bot->IsAlive() && !bot->GetBotAI()->HasBotCommandState(BOT_COMMAND_FULLSTOP))
{
++count;
bot->GetBotAI()->MoveToLastSendPosition();
Expand Down Expand Up @@ -1268,7 +1268,7 @@ class script_bot_commands : public CommandScript
{
Unit const* target = handler->getSelectedCreature();
Creature const* bot = target ? owner->GetBotMgr()->GetBot(target->GetGUID()) : nullptr;
if (bot && bot->IsAlive())
if (bot && bot->IsAlive() && !bot->GetBotAI()->HasBotCommandState(BOT_COMMAND_FULLSTOP))
{
bot->GetBotAI()->MoveToSendPosition(*point_id - 1);
return return_success(handler, { bot->GetName() });
Expand All @@ -1280,7 +1280,7 @@ class script_bot_commands : public CommandScript
for (decltype(names)::value_type::value_type name : *names)
{
Creature const* bot = owner->GetBotMgr()->GetBotByName(name);
if (bot && bot->IsAlive())
if (bot && bot->IsAlive() && !bot->GetBotAI()->HasBotCommandState(BOT_COMMAND_FULLSTOP))
{
++count;
bot->GetBotAI()->MoveToSendPosition(*point_id - 1);
Expand Down

0 comments on commit 9e8c167

Please sign in to comment.