Skip to content

Commit

Permalink
Fix unmount aura opcode build error
Browse files Browse the repository at this point in the history
  • Loading branch information
davidonete committed Apr 5, 2024
1 parent 5dd5a92 commit 0c8c10b
Show file tree
Hide file tree
Showing 11 changed files with 39 additions and 77 deletions.
17 changes: 17 additions & 0 deletions playerbot/PlayerbotAI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -815,6 +815,23 @@ bool PlayerbotAI::CanEnterArea(const AreaTrigger* area)
return false;
}

void PlayerbotAI::Unmount()
{
if (bot->IsMounted())
{
bot->RemoveSpellsCausingAura(SPELL_AURA_MOUNTED);
bot->Unmount();

bot->UpdateSpeed(MOVE_RUN, true);
bot->UpdateSpeed(MOVE_RUN, false);

if (bot->IsFlying())
{
bot->GetMotionMaster()->MoveFall();
}
}
}

bool PlayerbotAI::IsStateActive(BotState state) const
{
return currentEngine == engines[(uint8)state];
Expand Down
3 changes: 1 addition & 2 deletions playerbot/PlayerbotAI.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
#pragma once


#include "PlayerbotMgr.h"
#include "PlayerbotAIBase.h"
#include "strategy/AiObjectContext.h"
Expand Down Expand Up @@ -537,6 +535,7 @@ class PlayerbotAI : public PlayerbotAIBase
void UpdateTalentSpec(PlayerTalentSpec spec = PlayerTalentSpec::TALENT_SPEC_INVALID);

bool CanEnterArea(const AreaTrigger* area);
void Unmount();

private:
bool UpdateAIReaction(uint32 elapsed, bool minimal, bool isStunned);
Expand Down
6 changes: 1 addition & 5 deletions playerbot/strategy/actions/AttackAction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,14 +100,10 @@ bool AttackAction::Attack(Player* requester, Unit* target)
{
if (bot->IsMounted() && (sServerFacade.GetDistance2d(bot, target) < 40.0f || bot->IsFlying()))
{
WorldPacket emptyPacket;
bot->GetSession()->HandleCancelMountAuraOpcode(emptyPacket);
bot->UpdateSpeed(MOVE_RUN, true);
bot->UpdateSpeed(MOVE_RUN, false);
ai->Unmount();

if (bot->IsFlying())
{
bot->GetMotionMaster()->MoveFall();
return true;
}
}
Expand Down
21 changes: 7 additions & 14 deletions playerbot/strategy/actions/BattleGroundJoinAction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1312,8 +1312,9 @@ bool BGStatusAction::Execute(Event& event)
#endif
#endif
sLog.outBasic("Bot #%u %s:%d <%s>: Force join %s %s", bot->GetGUIDLow(), bot->GetTeam() == ALLIANCE ? "A" : "H", bot->GetLevel(), bot->GetName(), isArena ? "Arena" : "BG", _bgType.c_str());
WorldPacket emptyPacket;
bot->GetSession()->HandleCancelMountAuraOpcode(emptyPacket);

ai->Unmount();

action = 0x1;
// bg started so players should get invites by now
sRandomPlayerbotMgr.NeedBots[queueTypeId][bracketId][isArena ? isRated : GetTeamIndexByTeamId(bot->GetTeam())] = false;
Expand All @@ -1324,12 +1325,7 @@ bool BGStatusAction::Execute(Event& event)
#else
packet << type << unk2 << (uint32)_bgTypeId << unk << action;
#endif
#ifdef MANGOS
bot->GetSession()->HandleBattleFieldPortOpcode(packet);
#endif
#ifdef CMANGOS
bot->GetSession()->HandleBattlefieldPortOpcode(packet);
#endif

ai->ResetStrategies(false);
context->GetValue<uint32>("bg role")->Set(urand(0, 9));
Expand Down Expand Up @@ -1437,8 +1433,9 @@ bool BGStatusAction::Execute(Event& event)
#else
sLog.outBasic("Bot #%d %s:%d <%s> joined %s - %s", bot->GetGUIDLow(), bot->GetTeam() == ALLIANCE ? "A" : "H", bot->GetLevel(), bot->GetName(), isArena ? "Arena" : "BG", _bgType.c_str());
#endif
WorldPacket emptyPacket;
bot->GetSession()->HandleCancelMountAuraOpcode(emptyPacket);

ai->Unmount();

action = 0x1;
// bg started so players should get invites by now
sRandomPlayerbotMgr.NeedBots[queueTypeId][bracketId][isArena ? isRated : GetTeamIndexByTeamId(bot->GetTeam())] = false;
Expand All @@ -1449,12 +1446,8 @@ bool BGStatusAction::Execute(Event& event)
#else
packet << type << unk2 << (uint32)_bgTypeId << unk << action;
#endif
#ifdef MANGOS
bot->GetSession()->HandleBattleFieldPortOpcode(packet);
#endif
#ifdef CMANGOS

bot->GetSession()->HandleBattlefieldPortOpcode(packet);
#endif

ai->ResetStrategies(false);
context->GetValue<uint32>("bg role")->Set(urand(0, 9));
Expand Down
11 changes: 1 addition & 10 deletions playerbot/strategy/actions/CastCustomSpellAction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,16 +159,7 @@ bool CastCustomSpellAction::Execute(Event& event)
if (bot->IsFlying() && WorldPosition(bot).currentHeight() > 10.0f)
return false;

if (bot->IsMounted())
{
WorldPacket emptyPacket;
bot->GetSession()->HandleCancelMountAuraOpcode(emptyPacket);
bot->UpdateSpeed(MOVE_RUN, true);
bot->UpdateSpeed(MOVE_RUN, false);

if (bot->IsFlying())
bot->GetMotionMaster()->MoveFall();
}
ai->Unmount();
}

ai->RemoveShapeshift();
Expand Down
15 changes: 6 additions & 9 deletions playerbot/strategy/actions/CheckMountStateAction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -490,19 +490,16 @@ bool CheckMountStateAction::UnMount() const
return false;

if (bot->IsFlying() && WorldPosition(bot).currentHeight() > 10.0f)
{
return false;
}

if (bot->IsMounted())
{
WorldPacket emptyPacket;
bot->GetSession()->HandleCancelMountAuraOpcode(emptyPacket);
bot->UpdateSpeed(MOVE_RUN, true);
bot->UpdateSpeed(MOVE_RUN, false);

if (bot->IsFlying())
bot->GetMotionMaster()->MoveFall();
ai->Unmount();
}
else
ai->RemoveShapeshift();

ai->RemoveShapeshift();

return true;
}
8 changes: 1 addition & 7 deletions playerbot/strategy/actions/MovementActions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -504,13 +504,7 @@ bool MovementAction::MoveTo(uint32 mapId, float x, float y, float z, bool idle,
if (bot->IsFlying() && WorldPosition(bot).currentHeight() > 10.0f)
return false;

WorldPacket emptyPacket;
bot->GetSession()->HandleCancelMountAuraOpcode(emptyPacket);
bot->UpdateSpeed(MOVE_RUN, true);
bot->UpdateSpeed(MOVE_RUN, false);

if (bot->IsFlying())
bot->GetMotionMaster()->MoveFall();
ai->Unmount();
}

Spell* spell = new Spell(bot, pSpellInfo, false);
Expand Down
16 changes: 2 additions & 14 deletions playerbot/strategy/actions/NonCombatActions.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,7 @@ namespace ai
if (!pSpellInfo)
return false;

if (bot->IsMounted())
{
WorldPacket emptyPacket;
bot->GetSession()->HandleCancelMountAuraOpcode(emptyPacket);
bot->UpdateSpeed(MOVE_RUN, true);
bot->UpdateSpeed(MOVE_RUN, false);
}
ai->Unmount();

ai->CastSpell(24355, bot);
SetDuration(drinkDuration);
Expand Down Expand Up @@ -132,13 +126,7 @@ namespace ai
if (!pSpellInfo)
return false;

if (bot->IsMounted())
{
WorldPacket emptyPacket;
bot->GetSession()->HandleCancelMountAuraOpcode(emptyPacket);
bot->UpdateSpeed(MOVE_RUN, true);
bot->UpdateSpeed(MOVE_RUN, false);
}
ai->Unmount();

ai->CastSpell(24005, bot);
SetDuration(eatDuration);
Expand Down
5 changes: 1 addition & 4 deletions playerbot/strategy/actions/RpgSubActions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,10 +139,7 @@ bool RpgTaxiAction::Execute(Event& event)

GuidPosition guidP = rpg->guidP();

WorldPacket emptyPacket;
bot->GetSession()->HandleCancelMountAuraOpcode(emptyPacket);
bot->UpdateSpeed(MOVE_RUN, true);
bot->UpdateSpeed(MOVE_RUN, false);
ai->Unmount();

uint32 node = sObjectMgr.GetNearestTaxiNode(guidP.getX(), guidP.getY(), guidP.getZ(), guidP.getMapId(), bot->GetTeam());

Expand Down
11 changes: 1 addition & 10 deletions playerbot/strategy/actions/UseItemAction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1213,16 +1213,7 @@ bool UseHearthStoneAction::Execute(Event& event)
if (bot->IsFlying() && WorldPosition(bot).currentHeight() > 10.0f)
return false;

if (bot->IsMounted())
{
WorldPacket emptyPacket;
bot->GetSession()->HandleCancelMountAuraOpcode(emptyPacket);
bot->UpdateSpeed(MOVE_RUN, true);
bot->UpdateSpeed(MOVE_RUN, false);

if (bot->IsFlying())
bot->GetMotionMaster()->MoveFall();
}
ai->Unmount();
}

ai->RemoveShapeshift();
Expand Down
3 changes: 1 addition & 2 deletions playerbot/strategy/actions/VehicleActions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,7 @@ bool EnterVehicleAction::Execute(Event& event)
{
seat = transportCheck->GetTransportSeat();
// dismount because bots can enter vehicle on mount
WorldPacket emptyPacket;
bot->GetSession()->HandleCancelMountAuraOpcode(emptyPacket);
ai->Unmount();
return true;
}

Expand Down

0 comments on commit 0c8c10b

Please sign in to comment.