mirror of
https://github.com/liyunfan1223/mod-playerbots.git
synced 2026-02-20 18:10:02 +01:00
Compare commits
No commits in common. "25800f54e8c0b40eee1933636d6aaf1d904da57d" and "610fdc16d7e24fccbc336509831879d4c08db600" have entirely different histories.
25800f54e8
...
610fdc16d7
@ -184,7 +184,7 @@ std::string ChangeTalentsAction::SpecApply(std::string param)
|
||||
// // }
|
||||
// // }
|
||||
|
||||
// return ret;
|
||||
// return std::move(ret);
|
||||
// }
|
||||
|
||||
// std::vector<TalentPath*> ChangeTalentsAction::getPremadePaths(TalentSpec* oldSpec)
|
||||
@ -201,7 +201,7 @@ std::string ChangeTalentsAction::SpecApply(std::string param)
|
||||
// // }
|
||||
// // }
|
||||
|
||||
// return ret;
|
||||
// return std::move(ret);
|
||||
// }
|
||||
|
||||
// TalentPath* ChangeTalentsAction::getPremadePath(uint32 id)
|
||||
|
||||
@ -55,6 +55,63 @@ MountData CollectMountData(const Player* bot)
|
||||
return data;
|
||||
}
|
||||
|
||||
bool CheckMountStateAction::isUseful()
|
||||
{
|
||||
// Not useful when:
|
||||
if (botAI->IsInVehicle() || bot->isDead() || bot->HasUnitState(UNIT_STATE_IN_FLIGHT) ||
|
||||
!bot->IsOutdoors() || bot->InArena())
|
||||
return false;
|
||||
|
||||
master = GetMaster();
|
||||
|
||||
// Get shapeshift states, only applicable when there's a master
|
||||
if (master)
|
||||
{
|
||||
botInShapeshiftForm = bot->GetShapeshiftForm();
|
||||
masterInShapeshiftForm = master->GetShapeshiftForm();
|
||||
}
|
||||
|
||||
// Not useful when in combat and not currently mounted / travel formed
|
||||
if ((bot->IsInCombat() || botAI->GetState() == BOT_STATE_COMBAT) &&
|
||||
!bot->IsMounted() && botInShapeshiftForm != FORM_TRAVEL && botInShapeshiftForm != FORM_FLIGHT && botInShapeshiftForm != FORM_FLIGHT_EPIC)
|
||||
return false;
|
||||
|
||||
// In addition to checking IsOutdoors, also check whether bot is clipping below floor slightly because that will
|
||||
// cause bot to falsly indicate they are outdoors. This fixes bug where bot tries to mount indoors (which seems
|
||||
// to mostly be an issue in tunnels of WSG and AV)
|
||||
float posZ = bot->GetPositionZ();
|
||||
float groundLevel = bot->GetMapWaterOrGroundLevel(bot->GetPositionX(), bot->GetPositionY(), posZ);
|
||||
if (!bot->IsMounted() && !bot->HasWaterWalkAura() && posZ < groundLevel)
|
||||
return false;
|
||||
|
||||
// Not useful when bot does not have mount strat and is not currently mounted
|
||||
if (!GET_PLAYERBOT_AI(bot)->HasStrategy("mount", BOT_STATE_NON_COMBAT) && !bot->IsMounted())
|
||||
return false;
|
||||
|
||||
// Not useful when level lower than minimum required
|
||||
if (bot->GetLevel() < sPlayerbotAIConfig.useGroundMountAtMinLevel)
|
||||
return false;
|
||||
|
||||
// Allow mounting while transformed only if the form allows it
|
||||
if (bot->HasAuraType(SPELL_AURA_TRANSFORM) && bot->IsInDisallowedMountForm())
|
||||
return false;
|
||||
|
||||
// BG Logic
|
||||
if (bot->InBattleground())
|
||||
{
|
||||
// Do not use when carrying BG Flags
|
||||
if (bot->HasAura(BG_WS_SPELL_WARSONG_FLAG) || bot->HasAura(BG_WS_SPELL_SILVERWING_FLAG) || bot->HasAura(BG_EY_NETHERSTORM_FLAG_SPELL))
|
||||
return false;
|
||||
|
||||
// Only mount if BG starts in less than 30 sec
|
||||
if (Battleground* bg = bot->GetBattleground())
|
||||
if (bg->GetStatus() == STATUS_WAIT_JOIN && bg->GetStartDelayTime() > BG_START_DELAY_30S)
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CheckMountStateAction::Execute(Event /*event*/)
|
||||
{
|
||||
// Determine if there are no attackers
|
||||
@ -125,63 +182,6 @@ bool CheckMountStateAction::Execute(Event /*event*/)
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CheckMountStateAction::isUseful()
|
||||
{
|
||||
// Not useful when:
|
||||
if (botAI->IsInVehicle() || bot->isDead() || bot->HasUnitState(UNIT_STATE_IN_FLIGHT) ||
|
||||
!bot->IsOutdoors() || bot->InArena())
|
||||
return false;
|
||||
|
||||
master = GetMaster();
|
||||
|
||||
// Get shapeshift states, only applicable when there's a master
|
||||
if (master)
|
||||
{
|
||||
botInShapeshiftForm = bot->GetShapeshiftForm();
|
||||
masterInShapeshiftForm = master->GetShapeshiftForm();
|
||||
}
|
||||
|
||||
// Not useful when in combat and not currently mounted / travel formed
|
||||
if ((bot->IsInCombat() || botAI->GetState() == BOT_STATE_COMBAT) &&
|
||||
!bot->IsMounted() && botInShapeshiftForm != FORM_TRAVEL && botInShapeshiftForm != FORM_FLIGHT && botInShapeshiftForm != FORM_FLIGHT_EPIC)
|
||||
return false;
|
||||
|
||||
// In addition to checking IsOutdoors, also check whether bot is clipping below floor slightly because that will
|
||||
// cause bot to falsly indicate they are outdoors. This fixes bug where bot tries to mount indoors (which seems
|
||||
// to mostly be an issue in tunnels of WSG and AV)
|
||||
float posZ = bot->GetPositionZ();
|
||||
float groundLevel = bot->GetMapWaterOrGroundLevel(bot->GetPositionX(), bot->GetPositionY(), posZ);
|
||||
if (!bot->IsMounted() && !bot->HasWaterWalkAura() && posZ < groundLevel)
|
||||
return false;
|
||||
|
||||
// Not useful when bot does not have mount strat and is not currently mounted
|
||||
if (!GET_PLAYERBOT_AI(bot)->HasStrategy("mount", BOT_STATE_NON_COMBAT) && !bot->IsMounted())
|
||||
return false;
|
||||
|
||||
// Not useful when level lower than minimum required
|
||||
if (bot->GetLevel() < sPlayerbotAIConfig.useGroundMountAtMinLevel)
|
||||
return false;
|
||||
|
||||
// Allow mounting while transformed only if the form allows it
|
||||
if (bot->HasAuraType(SPELL_AURA_TRANSFORM) && bot->IsInDisallowedMountForm())
|
||||
return false;
|
||||
|
||||
// BG Logic
|
||||
if (bot->InBattleground())
|
||||
{
|
||||
// Do not use when carrying BG Flags
|
||||
if (bot->HasAura(BG_WS_SPELL_WARSONG_FLAG) || bot->HasAura(BG_WS_SPELL_SILVERWING_FLAG) || bot->HasAura(BG_EY_NETHERSTORM_FLAG_SPELL))
|
||||
return false;
|
||||
|
||||
// Only mount if BG starts in less than 30 sec
|
||||
if (Battleground* bg = bot->GetBattleground())
|
||||
if (bg->GetStatus() == STATUS_WAIT_JOIN && bg->GetStartDelayTime() > BG_START_DELAY_30S)
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CheckMountStateAction::Mount()
|
||||
{
|
||||
// Remove current Shapeshift if need be
|
||||
|
||||
@ -320,7 +320,7 @@ bool ChooseRpgTargetAction::isFollowValid(Player* bot, WorldPosition pos)
|
||||
inDungeon = true;
|
||||
|
||||
if (realMaster && realMaster->IsInWorld() && realMaster->GetMap()->IsDungeon() &&
|
||||
(realMaster->GetMapId() != pos.GetMapId()))
|
||||
(realMaster->GetMapId() != pos.getMapId()))
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -334,7 +334,7 @@ bool ChooseRpgTargetAction::isFollowValid(Player* bot, WorldPosition pos)
|
||||
return false;
|
||||
|
||||
Formation* formation = AI_VALUE(Formation*, "formation");
|
||||
float distance = groupLeader->GetDistance2d(pos.GetPositionX(), pos.GetPositionY());
|
||||
float distance = groupLeader->GetDistance2d(pos.getX(), pos.getY());
|
||||
|
||||
if (!botAI->HasActivePlayerMaster() && distance < 50.0f)
|
||||
{
|
||||
|
||||
@ -30,6 +30,37 @@ bool AttackEnemyFlagCarrierAction::isUseful()
|
||||
PlayerHasFlag::IsCapturingFlag(bot);
|
||||
}
|
||||
|
||||
bool AttackAnythingAction::isUseful()
|
||||
{
|
||||
if (!bot || !botAI) // Prevents invalid accesses
|
||||
return false;
|
||||
|
||||
if (!botAI->AllowActivity(GRIND_ACTIVITY)) // Bot cannot be active
|
||||
return false;
|
||||
|
||||
if (botAI->HasStrategy("stay", BOT_STATE_NON_COMBAT))
|
||||
return false;
|
||||
|
||||
if (bot->IsInCombat())
|
||||
return false;
|
||||
|
||||
Unit* target = GetTarget();
|
||||
if (!target || !target->IsInWorld()) // Checks if the target is valid and in the world
|
||||
return false;
|
||||
|
||||
std::string const name = std::string(target->GetName());
|
||||
if (!name.empty() &&
|
||||
(name.find("Dummy") != std::string::npos ||
|
||||
name.find("Charge Target") != std::string::npos ||
|
||||
name.find("Melee Target") != std::string::npos ||
|
||||
name.find("Ranged Target") != std::string::npos))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool DropTargetAction::Execute(Event event)
|
||||
{
|
||||
Unit* target = context->GetValue<Unit*>("current target")->Get();
|
||||
@ -96,38 +127,7 @@ bool AttackAnythingAction::Execute(Event event)
|
||||
return result;
|
||||
}
|
||||
|
||||
bool AttackAnythingAction::isUseful()
|
||||
{
|
||||
if (!bot || !botAI) // Prevents invalid accesses
|
||||
return false;
|
||||
|
||||
if (!botAI->AllowActivity(GRIND_ACTIVITY)) // Bot cannot be active
|
||||
return false;
|
||||
|
||||
if (botAI->HasStrategy("stay", BOT_STATE_NON_COMBAT))
|
||||
return false;
|
||||
|
||||
if (bot->IsInCombat())
|
||||
return false;
|
||||
|
||||
Unit* target = GetTarget();
|
||||
if (!target || !target->IsInWorld()) // Checks if the target is valid and in the world
|
||||
return false;
|
||||
|
||||
std::string const name = std::string(target->GetName());
|
||||
if (!name.empty() &&
|
||||
(name.find("Dummy") != std::string::npos ||
|
||||
name.find("Charge Target") != std::string::npos ||
|
||||
name.find("Melee Target") != std::string::npos ||
|
||||
name.find("Ranged Target") != std::string::npos))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AttackAnythingAction::isPossible() { return GetTarget() && AttackAction::isPossible(); }
|
||||
bool AttackAnythingAction::isPossible() { return AttackAction::isPossible() && GetTarget(); }
|
||||
|
||||
bool DpsAssistAction::isUseful()
|
||||
{
|
||||
|
||||
@ -28,8 +28,8 @@ bool DebugAction::Execute(Event event)
|
||||
|
||||
uint32 areaId = 0;
|
||||
uint32 zoneId = 0;
|
||||
sMapMgr->GetZoneAndAreaId(PHASEMASK_NORMAL, zoneId, areaId, pos.GetMapId(), pos.GetPositionX(), pos.GetPositionY(),
|
||||
pos.GetPositionZ());
|
||||
sMapMgr->GetZoneAndAreaId(PHASEMASK_NORMAL, zoneId, areaId, pos.getMapId(), pos.getX(), pos.getY(),
|
||||
pos.getZ());
|
||||
|
||||
std::ostringstream out;
|
||||
out << zoneId << "," << areaId << "," << (pos.getAreaName().empty() ? "none" : pos.getAreaName()) << ",";
|
||||
@ -298,7 +298,7 @@ bool DebugAction::Execute(Event event)
|
||||
for (auto p : ppath)
|
||||
{
|
||||
Creature* wpCreature =
|
||||
bot->SummonCreature(1, p.GetPositionX(), p.GetPositionY(), p.GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN, 20000.0f);
|
||||
bot->SummonCreature(1, p.getX(), p.getY(), p.getZ(), 0, TEMPSUMMON_TIMED_DESPAWN, 20000.0f);
|
||||
// addAura(246, wpCreature);
|
||||
units.push_back(wpCreature->GetGUID());
|
||||
|
||||
@ -325,11 +325,11 @@ bool DebugAction::Execute(Event event)
|
||||
WorldPosition botPos(bot);
|
||||
WorldPosition botPos1 = botPos;
|
||||
|
||||
botPos.setX(botPos.GetPositionX() + cos(ang) * dist);
|
||||
botPos.setY(botPos.GetPositionY() + sin(ang) * dist);
|
||||
botPos.setX(botPos.getX() + cos(ang) * dist);
|
||||
botPos.setY(botPos.getY() + sin(ang) * dist);
|
||||
botPos.setZ(botPos.getHeight() + 2);
|
||||
|
||||
Creature* wpCreature = bot->SummonCreature(2334, botPos.GetPositionX(), botPos.GetPositionY(), botPos.GetPositionZ(), 0,
|
||||
Creature* wpCreature = bot->SummonCreature(2334, botPos.getX(), botPos.getY(), botPos.getZ(), 0,
|
||||
TEMPSUMMON_TIMED_DESPAWN, 10000.0f);
|
||||
|
||||
FakeSpell(spellEffect, wpCreature, wpCreature, prev->GetGUID(), {}, {}, botPos, botPos);
|
||||
@ -352,11 +352,11 @@ bool DebugAction::Execute(Event event)
|
||||
WorldPosition botPos(bot);
|
||||
WorldPosition botPos1 = botPos;
|
||||
|
||||
botPos.setX(botPos.GetPositionX() + cos(ang) * dist);
|
||||
botPos.setY(botPos.GetPositionY() + sin(ang) * dist);
|
||||
botPos.setX(botPos.getX() + cos(ang) * dist);
|
||||
botPos.setY(botPos.getY() + sin(ang) * dist);
|
||||
botPos.setZ(botPos.getHeight() + 2);
|
||||
|
||||
Creature* wpCreature = bot->SummonCreature(2334, botPos.GetPositionX(), botPos.GetPositionY(), botPos.GetPositionZ(), 0,
|
||||
Creature* wpCreature = bot->SummonCreature(2334, botPos.getX(), botPos.getY(), botPos.getZ(), 0,
|
||||
TEMPSUMMON_TIMED_DESPAWN, 10000.0f);
|
||||
|
||||
if (wpCreature)
|
||||
@ -383,11 +383,11 @@ bool DebugAction::Execute(Event event)
|
||||
WorldPosition botPos(bot);
|
||||
WorldPosition botPos1 = botPos;
|
||||
|
||||
botPos.setX(botPos.GetPositionX() + cos(ang) * dist);
|
||||
botPos.setY(botPos.GetPositionY() + sin(ang) * dist);
|
||||
botPos.setX(botPos.getX() + cos(ang) * dist);
|
||||
botPos.setY(botPos.getY() + sin(ang) * dist);
|
||||
botPos.setZ(botPos.getHeight() + 2);
|
||||
|
||||
Creature* wpCreature = bot->SummonCreature(2334, botPos.GetPositionX(), botPos.GetPositionY(), botPos.GetPositionZ(), 0,
|
||||
Creature* wpCreature = bot->SummonCreature(2334, botPos.getX(), botPos.getY(), botPos.getZ(), 0,
|
||||
TEMPSUMMON_TIMED_DESPAWN, 5000.0f + i * 100.0f);
|
||||
wpCreature->SetObjectScale(0.5f);
|
||||
|
||||
@ -411,11 +411,11 @@ bool DebugAction::Execute(Event event)
|
||||
|
||||
WorldPosition botPos(bot);
|
||||
|
||||
botPos.setX(botPos.GetPositionX() + cos(ang) * dist);
|
||||
botPos.setY(botPos.GetPositionY() + sin(ang) * dist);
|
||||
botPos.setX(botPos.getX() + cos(ang) * dist);
|
||||
botPos.setY(botPos.getY() + sin(ang) * dist);
|
||||
botPos.setZ(botPos.getHeight() + 2);
|
||||
|
||||
Creature* wpCreature = bot->SummonCreature(2334, botPos.GetPositionX(), botPos.GetPositionY(), botPos.GetPositionZ(), 0,
|
||||
Creature* wpCreature = bot->SummonCreature(2334, botPos.getX(), botPos.getY(), botPos.getZ(), 0,
|
||||
TEMPSUMMON_TIMED_DESPAWN, 10000.0f);
|
||||
|
||||
units.push_back(wpCreature->GetGUID());
|
||||
@ -480,13 +480,13 @@ bool DebugAction::Execute(Event event)
|
||||
uint32 effect = dx + dy * 10 + spellEffect * 100;
|
||||
WorldPosition botPos(bot);
|
||||
|
||||
botPos.setX(botPos.GetPositionX() + (dx - 5) * 5);
|
||||
botPos.setY(botPos.GetPositionY() + (dy - 5) * 5);
|
||||
botPos.setX(botPos.getX() + (dx - 5) * 5);
|
||||
botPos.setY(botPos.getY() + (dy - 5) * 5);
|
||||
botPos.setZ(botPos.getHeight());
|
||||
|
||||
Creature* wpCreature =
|
||||
bot->SummonCreature((dy == 0 && (dx == 0 || dx == 2)) ? 6 : 2, botPos.GetPositionX(), botPos.GetPositionY(),
|
||||
botPos.GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN, 10000.0f);
|
||||
bot->SummonCreature((dy == 0 && (dx == 0 || dx == 2)) ? 6 : 2, botPos.getX(), botPos.getY(),
|
||||
botPos.getZ(), 0, TEMPSUMMON_TIMED_DESPAWN, 10000.0f);
|
||||
|
||||
if (wpCreature)
|
||||
{
|
||||
@ -512,11 +512,11 @@ bool DebugAction::Execute(Event event)
|
||||
uint32 effect = dx + dy * 10 + spellEffect * 100;
|
||||
WorldPosition botPos(bot);
|
||||
|
||||
botPos.setX(botPos.GetPositionX() + (dx - 5) * 5);
|
||||
botPos.setY(botPos.GetPositionY() + (dy - 5) * 5);
|
||||
botPos.setX(botPos.getX() + (dx - 5) * 5);
|
||||
botPos.setY(botPos.getY() + (dy - 5) * 5);
|
||||
botPos.setZ(botPos.getHeight());
|
||||
|
||||
Creature* wpCreature = bot->SummonCreature(effect, botPos.GetPositionX(), botPos.GetPositionY(), botPos.GetPositionZ(), 0,
|
||||
Creature* wpCreature = bot->SummonCreature(effect, botPos.getX(), botPos.getY(), botPos.getZ(), 0,
|
||||
TEMPSUMMON_TIMED_DESPAWN, 10000.0f);
|
||||
}
|
||||
}
|
||||
@ -532,8 +532,8 @@ bool DebugAction::Execute(Event event)
|
||||
uint32 effect = dx + dy * 10 + spellEffect * 100;
|
||||
WorldPosition botPos(bot);
|
||||
|
||||
botPos.setX(botPos.GetPositionX() + (dx - 5) * 5);
|
||||
botPos.setY(botPos.GetPositionY() + (dy - 5) * 5);
|
||||
botPos.setX(botPos.getX() + (dx - 5) * 5);
|
||||
botPos.setY(botPos.getY() + (dy - 5) * 5);
|
||||
botPos.setZ(botPos.getHeight());
|
||||
|
||||
FakeSpell(effect, bot, nullptr, ObjectGuid::Empty, {}, {}, botPos, botPos, true);
|
||||
@ -552,11 +552,11 @@ bool DebugAction::Execute(Event event)
|
||||
uint32 effect = dx + dy * 10 + spellEffect * 100;
|
||||
WorldPosition botPos(bot);
|
||||
|
||||
botPos.setX(botPos.GetPositionX() + (dx - 5) * 5);
|
||||
botPos.setY(botPos.GetPositionY() + (dy - 5) * 5);
|
||||
botPos.setX(botPos.getX() + (dx - 5) * 5);
|
||||
botPos.setY(botPos.getY() + (dy - 5) * 5);
|
||||
botPos.setZ(botPos.getHeight());
|
||||
|
||||
Creature* wpCreature = bot->SummonCreature(2334, botPos.GetPositionX(), botPos.GetPositionY(), botPos.GetPositionZ(), 0,
|
||||
Creature* wpCreature = bot->SummonCreature(2334, botPos.getX(), botPos.getY(), botPos.getZ(), 0,
|
||||
TEMPSUMMON_TIMED_DESPAWN, 10000.0f);
|
||||
|
||||
if (wpCreature)
|
||||
@ -568,7 +568,7 @@ bool DebugAction::Execute(Event event)
|
||||
// wpCreature->SendMessageToSet(&data, true);
|
||||
datMap.push_back(data);
|
||||
|
||||
// wpCreature->MonsterMoveWithSpeed(botPos.GetPositionX(), botPos.GetPositionY() + 80, botPos.GetPositionZ(), 8.0f, true,
|
||||
// wpCreature->MonsterMoveWithSpeed(botPos.getX(), botPos.getY() + 80, botPos.getZ(), 8.0f, true,
|
||||
// true);
|
||||
}
|
||||
}
|
||||
@ -600,13 +600,13 @@ bool DebugAction::Execute(Event event)
|
||||
uint32 effect = dx + dy * 10 + spellEffect * 100;
|
||||
WorldPosition botPos(bot);
|
||||
|
||||
botPos.setX(botPos.GetPositionX() + (dx - 5) * 5);
|
||||
botPos.setY(botPos.GetPositionY() + (dy - 5) * 5);
|
||||
botPos.setX(botPos.getX() + (dx - 5) * 5);
|
||||
botPos.setY(botPos.getY() + (dy - 5) * 5);
|
||||
botPos.setZ(botPos.getHeight());
|
||||
|
||||
Creature* wpCreature =
|
||||
bot->SummonCreature((dy == 0 && (dx == 0 || dx == 2)) ? 6 : 2, botPos.GetPositionX(), botPos.GetPositionY(),
|
||||
botPos.GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN, 10000.0f);
|
||||
bot->SummonCreature((dy == 0 && (dx == 0 || dx == 2)) ? 6 : 2, botPos.getX(), botPos.getY(),
|
||||
botPos.getZ(), 0, TEMPSUMMON_TIMED_DESPAWN, 10000.0f);
|
||||
|
||||
if (wpCreature)
|
||||
{
|
||||
@ -646,12 +646,12 @@ bool DebugAction::Execute(Event event)
|
||||
uint32 effect = dx + dy * 10 + spellEffect * 100;
|
||||
WorldPosition botPos(bot);
|
||||
|
||||
botPos.setX(botPos.GetPositionX() + (dx - 5) * 5);
|
||||
botPos.setY(botPos.GetPositionY() + (dy - 5) * 5);
|
||||
botPos.setX(botPos.getX() + (dx - 5) * 5);
|
||||
botPos.setY(botPos.getY() + (dy - 5) * 5);
|
||||
botPos.setZ(botPos.getHeight());
|
||||
|
||||
wpCreature = bot->SummonCreature((dy == 0 && (dx == 0 || dx == 2)) ? 6 : 2, botPos.GetPositionX(),
|
||||
botPos.GetPositionY(), botPos.GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN, 10000.0f);
|
||||
wpCreature = bot->SummonCreature((dy == 0 && (dx == 0 || dx == 2)) ? 6 : 2, botPos.getX(),
|
||||
botPos.getY(), botPos.getZ(), 0, TEMPSUMMON_TIMED_DESPAWN, 10000.0f);
|
||||
|
||||
if (wpCreature && lCreature)
|
||||
{
|
||||
@ -675,11 +675,11 @@ bool DebugAction::Execute(Event event)
|
||||
uint32 effect = dx + dy * 10 + spellEffect * 100;
|
||||
WorldPosition botPos(bot);
|
||||
|
||||
botPos.setX(botPos.GetPositionX() + (dx - 5) * 5);
|
||||
botPos.setY(botPos.GetPositionY() + (dy - 5) * 5);
|
||||
botPos.setX(botPos.getX() + (dx - 5) * 5);
|
||||
botPos.setY(botPos.getY() + (dy - 5) * 5);
|
||||
botPos.setZ(botPos.getHeight());
|
||||
|
||||
wpCreature = bot->SummonCreature(2334, botPos.GetPositionX(), botPos.GetPositionY(), botPos.GetPositionZ(), 0,
|
||||
wpCreature = bot->SummonCreature(2334, botPos.getX(), botPos.getY(), botPos.getZ(), 0,
|
||||
TEMPSUMMON_TIMED_DESPAWN, 10000.0f);
|
||||
|
||||
if (wpCreature)
|
||||
@ -708,11 +708,11 @@ bool DebugAction::Execute(Event event)
|
||||
{
|
||||
WorldPosition botPos(bot);
|
||||
|
||||
botPos.setX(botPos.GetPositionX() + (dx - 5) * 5);
|
||||
botPos.setY(botPos.GetPositionY() + (dy - 5) * 5);
|
||||
botPos.setX(botPos.getX() + (dx - 5) * 5);
|
||||
botPos.setY(botPos.getY() + (dy - 5) * 5);
|
||||
botPos.setZ(botPos.getHeight());
|
||||
|
||||
Creature* wpCreature = bot->SummonCreature(2334, botPos.GetPositionX(), botPos.GetPositionY(), botPos.GetPositionZ(), 0,
|
||||
Creature* wpCreature = bot->SummonCreature(2334, botPos.getX(), botPos.getY(), botPos.getZ(), 0,
|
||||
TEMPSUMMON_TIMED_DESPAWN, 10000.0f);
|
||||
|
||||
all_targets.push_back(wpCreature->GetGUID());
|
||||
@ -788,11 +788,11 @@ bool DebugAction::Execute(Event event)
|
||||
{
|
||||
WorldPosition botPos(bot);
|
||||
|
||||
botPos.setX(botPos.GetPositionX() + (dx - 5) * 5);
|
||||
botPos.setY(botPos.GetPositionY() + (dy - 5) * 5);
|
||||
botPos.setX(botPos.getX() + (dx - 5) * 5);
|
||||
botPos.setY(botPos.getY() + (dy - 5) * 5);
|
||||
botPos.setZ(botPos.getHeight());
|
||||
|
||||
Creature* wpCreature = bot->SummonCreature(2334, botPos.GetPositionX(), botPos.GetPositionY(), botPos.GetPositionZ(), 0,
|
||||
Creature* wpCreature = bot->SummonCreature(2334, botPos.getX(), botPos.getY(), botPos.getZ(), 0,
|
||||
TEMPSUMMON_TIMED_DESPAWN, 10000.0f);
|
||||
|
||||
all_targets.push_back(wpCreature->GetGUID());
|
||||
@ -868,13 +868,13 @@ bool DebugAction::Execute(Event event)
|
||||
uint32 effect = dx + dy * 10 + soundEffects * 100;
|
||||
WorldPosition botPos(bot);
|
||||
|
||||
botPos.setX(botPos.GetPositionX() + (dx - 5) * 5);
|
||||
botPos.setY(botPos.GetPositionY() + (dy - 5) * 5);
|
||||
botPos.setX(botPos.getX() + (dx - 5) * 5);
|
||||
botPos.setY(botPos.getY() + (dy - 5) * 5);
|
||||
botPos.setZ(botPos.getHeight());
|
||||
|
||||
Creature* wpCreature =
|
||||
bot->SummonCreature((dy == 0 && (dx == 0 || dx == 2)) ? 6 : 2, botPos.GetPositionX(), botPos.GetPositionY(),
|
||||
botPos.GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN, 10000.0f);
|
||||
bot->SummonCreature((dy == 0 && (dx == 0 || dx == 2)) ? 6 : 2, botPos.getX(), botPos.getY(),
|
||||
botPos.getZ(), 0, TEMPSUMMON_TIMED_DESPAWN, 10000.0f);
|
||||
|
||||
wpCreature->PlayDistanceSound(effect);
|
||||
}
|
||||
@ -964,7 +964,7 @@ void DebugAction::FakeSpell(uint32 spellId, Unit* truecaster, Unit* caster, Obje
|
||||
m_targets.SetDst(dest);
|
||||
|
||||
if ((spellInfo && spellInfo->Targets & TARGET_FLAG_SOURCE_LOCATION) || forceDest)
|
||||
m_targets.SetSrc(source.GetPositionX(), source.GetPositionY(), source.GetPositionZ());
|
||||
m_targets.SetSrc(source.getX(), source.getY(), source.getZ());
|
||||
|
||||
if (!forceDest && target)
|
||||
if (!spellInfo ||
|
||||
|
||||
@ -7,24 +7,22 @@
|
||||
#define _PLAYERBOT_FISHINGACTION_H
|
||||
|
||||
#include "Action.h"
|
||||
#include "Event.h"
|
||||
#include "MovementActions.h"
|
||||
#include "Event.h"
|
||||
#include "Playerbots.h"
|
||||
|
||||
extern const uint32 FISHING_SPELL;
|
||||
extern const uint32 FISHING_POLE;
|
||||
extern const uint32 FISHING_BOBBER;
|
||||
|
||||
WorldPosition FindWaterRadial(Player* bot, float x, float y, float z, Map* map, uint32 phaseMask, float minDistance,
|
||||
float maxDistance, float increment, bool checkLOS = false, int numDirections = 16);
|
||||
WorldPosition FindWaterRadial(Player* bot, float x, float y, float z, Map* map, uint32 phaseMask, float minDistance, float maxDistance, float increment, bool checkLOS=false, int numDirections = 16);
|
||||
|
||||
class PlayerbotAI;
|
||||
|
||||
class FishingAction : public Action
|
||||
{
|
||||
public:
|
||||
FishingAction(PlayerbotAI* botAI) : Action(botAI, "go fishing") {}
|
||||
|
||||
FishingAction(PlayerbotAI* botAI) : Action(botAI, "go fishing"){}
|
||||
bool Execute(Event event) override;
|
||||
bool isUseful() override;
|
||||
};
|
||||
@ -33,10 +31,8 @@ class EquipFishingPoleAction : public Action
|
||||
{
|
||||
public:
|
||||
EquipFishingPoleAction(PlayerbotAI* botAI) : Action(botAI, "equip fishing pole") {}
|
||||
|
||||
bool Execute(Event event) override;
|
||||
bool isUseful() override;
|
||||
|
||||
private:
|
||||
Item* _pole = nullptr;
|
||||
};
|
||||
@ -44,8 +40,7 @@ private:
|
||||
class MoveNearWaterAction : public MovementAction
|
||||
{
|
||||
public:
|
||||
MoveNearWaterAction(PlayerbotAI* botAI) : MovementAction(botAI, "move near water") {}
|
||||
|
||||
MoveNearWaterAction(PlayerbotAI* botAI): MovementAction(botAI, "move near water") {}
|
||||
bool Execute(Event event) override;
|
||||
bool isUseful() override;
|
||||
bool isPossible() override;
|
||||
@ -55,7 +50,6 @@ class UseBobberAction : public Action
|
||||
{
|
||||
public:
|
||||
UseBobberAction(PlayerbotAI* botAI) : Action(botAI, "use fishing bobber") {}
|
||||
|
||||
bool Execute(Event event) override;
|
||||
bool isUseful() override;
|
||||
};
|
||||
@ -64,7 +58,6 @@ class EndMasterFishingAction : public Action
|
||||
{
|
||||
public:
|
||||
EndMasterFishingAction(PlayerbotAI* botAI) : Action(botAI, "end master fishing") {}
|
||||
|
||||
bool Execute(Event event) override;
|
||||
bool isUseful() override;
|
||||
};
|
||||
@ -73,8 +66,6 @@ class RemoveBobberStrategyAction : public Action
|
||||
{
|
||||
public:
|
||||
RemoveBobberStrategyAction(PlayerbotAI* botAI) : Action(botAI, "remove bobber strategy") {}
|
||||
|
||||
bool Execute(Event event) override;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@ -78,35 +78,6 @@ bool CastSpellAction::Execute(Event event)
|
||||
return botAI->CastSpell(spell, GetTarget());
|
||||
}
|
||||
|
||||
bool CastSpellAction::isUseful()
|
||||
{
|
||||
if (botAI->IsInVehicle() && !botAI->IsInVehicle(false, false, true))
|
||||
return false;
|
||||
|
||||
if (spell == "mount" && !bot->IsMounted() && !bot->IsInCombat())
|
||||
return true;
|
||||
|
||||
if (spell == "mount" && bot->IsInCombat())
|
||||
{
|
||||
bot->Dismount();
|
||||
return false;
|
||||
}
|
||||
|
||||
Unit* spellTarget = GetTarget();
|
||||
if (!spellTarget)
|
||||
return false;
|
||||
|
||||
if (!spellTarget->IsInWorld() || spellTarget->GetMapId() != bot->GetMapId())
|
||||
return false;
|
||||
|
||||
// float combatReach = bot->GetCombatReach() + target->GetCombatReach();
|
||||
// if (!botAI->IsRanged(bot))
|
||||
// combatReach += 4.0f / 3.0f;
|
||||
|
||||
return AI_VALUE2(bool, "spell cast useful", spell);
|
||||
// && ServerFacade::instance().GetDistance2d(bot, target) <= (range + combatReach);
|
||||
}
|
||||
|
||||
bool CastSpellAction::isPossible()
|
||||
{
|
||||
if (botAI->IsInVehicle() && !botAI->IsInVehicle(false, false, true))
|
||||
@ -135,6 +106,36 @@ bool CastSpellAction::isPossible()
|
||||
return botAI->CanCastSpell(spell, GetTarget());
|
||||
}
|
||||
|
||||
bool CastSpellAction::isUseful()
|
||||
{
|
||||
if (botAI->IsInVehicle() && !botAI->IsInVehicle(false, false, true))
|
||||
return false;
|
||||
|
||||
if (spell == "mount" && !bot->IsMounted() && !bot->IsInCombat())
|
||||
return true;
|
||||
|
||||
if (spell == "mount" && bot->IsInCombat())
|
||||
{
|
||||
bot->Dismount();
|
||||
return false;
|
||||
}
|
||||
|
||||
Unit* spellTarget = GetTarget();
|
||||
if (!spellTarget)
|
||||
return false;
|
||||
|
||||
if (!spellTarget->IsInWorld() || spellTarget->GetMapId() != bot->GetMapId())
|
||||
return false;
|
||||
|
||||
// float combatReach = bot->GetCombatReach() + spellTarget->GetCombatReach();
|
||||
// if (!botAI->IsRanged(bot))
|
||||
// combatReach += 4.0f / 3.0f;
|
||||
|
||||
return spellTarget &&
|
||||
AI_VALUE2(bool, "spell cast useful",
|
||||
spell); // && ServerFacade::instance().GetDistance2d(bot, spellTarget) <= (range + combatReach);
|
||||
}
|
||||
|
||||
CastMeleeSpellAction::CastMeleeSpellAction(PlayerbotAI* botAI, std::string const spell) : CastSpellAction(botAI, spell)
|
||||
{
|
||||
range = ATTACK_DISTANCE;
|
||||
|
||||
@ -23,8 +23,8 @@ public:
|
||||
|
||||
std::string const GetTargetName() override { return "current target"; };
|
||||
bool Execute(Event event) override;
|
||||
bool isUseful() override;
|
||||
bool isPossible() override;
|
||||
bool isUseful() override;
|
||||
ActionThreatType getThreatType() override { return ActionThreatType::Single; }
|
||||
|
||||
std::vector<NextAction> getPrerequisites() override
|
||||
|
||||
@ -370,7 +370,7 @@ bool MovementAction::MoveTo(uint32 mapId, float x, float y, float z, bool idle,
|
||||
// {
|
||||
// movePosition = endPosition;
|
||||
|
||||
// if (startPosition.GetMapId() != endPosition.GetMapId() || totalDistance > maxDist)
|
||||
// if (startPosition.getMapId() != endPosition.getMapId() || totalDistance > maxDist)
|
||||
// {
|
||||
// if (!TravelNodeMap::instance().getNodes().empty() && !bot->InBattleground())
|
||||
// {
|
||||
@ -421,7 +421,7 @@ bool MovementAction::MoveTo(uint32 mapId, float x, float y, float z, bool idle,
|
||||
// {
|
||||
// //Use standard PathGenerator to find a route.
|
||||
// PathGenerator path(mover);
|
||||
// path.CalculatePath(movePosition.GetPositionX(), movePosition.GetPositionY(), movePosition.GetPositionZ(), false);
|
||||
// path.CalculatePath(movePosition.getX(), movePosition.getY(), movePosition.getZ(), false);
|
||||
// PathType type = path.GetPathType();
|
||||
// Movement::PointsArray const& points = path.GetPath();
|
||||
// movePath.addPath(startPosition.fromPointsArray(points));
|
||||
@ -485,8 +485,8 @@ bool MovementAction::MoveTo(uint32 mapId, float x, float y, float z, bool idle,
|
||||
// else
|
||||
// {
|
||||
// LOG_DEBUG("playerbots", "!entry");
|
||||
// return bot->TeleportTo(movePosition.GetMapId(), movePosition.GetPositionX(), movePosition.GetPositionY(),
|
||||
// movePosition.GetPositionZ(), movePosition.GetOrientation(), 0);
|
||||
// return bot->TeleportTo(movePosition.getMapId(), movePosition.getX(), movePosition.getY(),
|
||||
// movePosition.getZ(), movePosition.getO(), 0);
|
||||
// }
|
||||
// }
|
||||
|
||||
@ -563,14 +563,14 @@ bool MovementAction::MoveTo(uint32 mapId, float x, float y, float z, bool idle,
|
||||
|
||||
// AI_VALUE(LastMovement&, "last movement").setPath(movePath);
|
||||
|
||||
// if (!movePosition || movePosition.GetMapId() != bot->GetMapId())
|
||||
// if (!movePosition || movePosition.getMapId() != bot->GetMapId())
|
||||
// {
|
||||
// movePath.clear();
|
||||
// AI_VALUE(LastMovement&, "last movement").setPath(movePath);
|
||||
|
||||
// if (botAI->HasStrategy("debug move", BOT_STATE_NON_COMBAT))
|
||||
// botAI->TellMasterNoFacing("No point. Rebuilding.");
|
||||
// LOG_DEBUG("playerbots", "!movePosition || movePosition.GetMapId() != bot->GetMapId()");
|
||||
// LOG_DEBUG("playerbots", "!movePosition || movePosition.getMapId() != bot->GetMapId()");
|
||||
// return false;
|
||||
// }
|
||||
|
||||
@ -609,15 +609,15 @@ bool MovementAction::MoveTo(uint32 mapId, float x, float y, float z, bool idle,
|
||||
// float cz = z;
|
||||
// for (auto i : movePath.getPath())
|
||||
// {
|
||||
// CreateWp(bot, i.point.GetPositionX(), i.point.GetPositionY(), i.point.GetPositionZ(), 0.f, 2334);
|
||||
// CreateWp(bot, i.point.getX(), i.point.getY(), i.point.getZ(), 0.f, 2334);
|
||||
|
||||
// cx = i.point.GetPositionX();
|
||||
// cy = i.point.GetPositionY();
|
||||
// cz = i.point.GetPositionZ();
|
||||
// cx = i.point.getX();
|
||||
// cy = i.point.getY();
|
||||
// cz = i.point.getZ();
|
||||
// }
|
||||
// }
|
||||
// else
|
||||
// CreateWp(bot, movePosition.GetPositionX(), movePosition.GetPositionY(), movePosition.GetPositionZ(), 0, 2334, true);
|
||||
// CreateWp(bot, movePosition.getX(), movePosition.getY(), movePosition.getZ(), 0, 2334, true);
|
||||
// }
|
||||
|
||||
// //Log bot movement
|
||||
@ -634,8 +634,8 @@ bool MovementAction::MoveTo(uint32 mapId, float x, float y, float z, bool idle,
|
||||
|
||||
// sPlayerbotAIConfig.log("bot_movement.csv", out.str().c_str());
|
||||
// }
|
||||
// // LOG_DEBUG("playerbots", "({}, {}) -> ({}, {})", startPosition.GetPositionX(), startPosition.GetPositionY(),
|
||||
// movePosition.GetPositionX(), movePosition.GetPositionY()); if (!react)
|
||||
// // LOG_DEBUG("playerbots", "({}, {}) -> ({}, {})", startPosition.getX(), startPosition.getY(),
|
||||
// movePosition.getX(), movePosition.getY()); if (!react)
|
||||
// if (totalDistance > maxDist)
|
||||
// WaitForReach(startPosition.distance(movePosition) - 10.0f);
|
||||
// else
|
||||
@ -671,7 +671,7 @@ bool MovementAction::MoveTo(uint32 mapId, float x, float y, float z, bool idle,
|
||||
// // else
|
||||
// // {
|
||||
// // mover->GetMotionMaster()->GetDestination(x, y, z);
|
||||
// // if (movePosition.distance(WorldPosition(movePosition.GetMapId(), x, y, z, 0)) > minDist)
|
||||
// // if (movePosition.distance(WorldPosition(movePosition.getMapId(), x, y, z, 0)) > minDist)
|
||||
// // {
|
||||
// // mover->StopMoving();
|
||||
// // mover->GetMotionMaster()->Clear();
|
||||
@ -685,8 +685,8 @@ bool MovementAction::MoveTo(uint32 mapId, float x, float y, float z, bool idle,
|
||||
|
||||
// AI_VALUE(LastMovement&, "last movement").nextTeleport = now +
|
||||
// (time_t)MoveDelay(startPosition.distance(movePosition)); LOG_DEBUG("playerbots", "totalDistance > maxDist &&
|
||||
// !detailedMove && !botAI->HasPlayerNearby(&movePosition)"); return bot->TeleportTo(movePosition.GetMapId(),
|
||||
// movePosition.GetPositionX(), movePosition.GetPositionY(), movePosition.GetPositionZ(), startPosition.getAngleTo(movePosition));
|
||||
// !detailedMove && !botAI->HasPlayerNearby(&movePosition)"); return bot->TeleportTo(movePosition.getMapId(),
|
||||
// movePosition.getX(), movePosition.getY(), movePosition.getZ(), startPosition.getAngleTo(movePosition));
|
||||
// }
|
||||
|
||||
// // walk if master walks and is close
|
||||
@ -708,9 +708,9 @@ bool MovementAction::MoveTo(uint32 mapId, float x, float y, float z, bool idle,
|
||||
// if (!bot->HasAuraType(SPELL_AURA_MOD_INCREASE_MOUNTED_FLIGHT_SPEED) && !bot->HasAuraType(SPELL_AURA_FLY))
|
||||
// {
|
||||
// bot->SetWalk(masterWalking);
|
||||
// bot->GetMotionMaster()->MovePoint(movePosition.GetMapId(), movePosition.GetPositionX(), movePosition.GetPositionY(),
|
||||
// movePosition.GetPositionZ(), generatePath); WaitForReach(startPosition.distance(movePosition));
|
||||
// // LOG_DEBUG("playerbots", "Movepoint to ({}, {})", movePosition.GetPositionX(), movePosition.GetPositionY());
|
||||
// bot->GetMotionMaster()->MovePoint(movePosition.getMapId(), movePosition.getX(), movePosition.getY(),
|
||||
// movePosition.getZ(), generatePath); WaitForReach(startPosition.distance(movePosition));
|
||||
// // LOG_DEBUG("playerbots", "Movepoint to ({}, {})", movePosition.getX(), movePosition.getY());
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
@ -756,9 +756,9 @@ bool MovementAction::MoveTo(uint32 mapId, float x, float y, float z, bool idle,
|
||||
// }
|
||||
// }
|
||||
|
||||
// bot->GetMotionMaster()->MovePoint(movePosition.GetMapId(), Position(movePosition.GetPositionX(), movePosition.GetPositionY(),
|
||||
// movePosition.GetPositionZ(), 0.f)); WaitForReach(startPosition.distance(movePosition)); LOG_DEBUG("playerbots",
|
||||
// "Movepoint to ({}, {})", movePosition.GetPositionX(), movePosition.GetPositionY());
|
||||
// bot->GetMotionMaster()->MovePoint(movePosition.getMapId(), Position(movePosition.getX(), movePosition.getY(),
|
||||
// movePosition.getZ(), 0.f)); WaitForReach(startPosition.distance(movePosition)); LOG_DEBUG("playerbots",
|
||||
// "Movepoint to ({}, {})", movePosition.getX(), movePosition.getY());
|
||||
// }
|
||||
|
||||
// AI_VALUE(LastMovement&, "last movement").setShort(movePosition);
|
||||
@ -1190,7 +1190,7 @@ bool MovementAction::Follow(Unit* target, float distance, float angle)
|
||||
WorldPosition cPos(corpse);
|
||||
|
||||
if (botPos.fDist(cPos) > sPlayerbotAIConfig.spellDistance)
|
||||
return MoveTo(cPos.GetMapId(), cPos.GetPositionX(), cPos.GetPositionY(), cPos.GetPositionZ());
|
||||
return MoveTo(cPos.getMapId(), cPos.getX(), cPos.getY(), cPos.getZ());
|
||||
}
|
||||
}
|
||||
|
||||
@ -1217,7 +1217,7 @@ bool MovementAction::Follow(Unit* target, float distance, float angle)
|
||||
if ((lDist * 1.5 < tDist && ang < static_cast<float>(M_PI) / 2) ||
|
||||
target->HasUnitState(UNIT_STATE_IN_FLIGHT))
|
||||
{
|
||||
return MoveTo(longMove.GetMapId(), longMove.GetPositionX(), longMove.GetPositionY(), longMove.GetPositionZ());
|
||||
return MoveTo(longMove.getMapId(), longMove.getX(), longMove.getY(), longMove.getZ());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -49,16 +49,18 @@ bool DrinkAction::Execute(Event event)
|
||||
|
||||
bool DrinkAction::isUseful()
|
||||
{
|
||||
return UseItemAction::isUseful() && AI_VALUE2(bool, "has mana", "self target") &&
|
||||
AI_VALUE2(uint8, "mana", "self target") < 100;
|
||||
return UseItemAction::isUseful() &&
|
||||
AI_VALUE2(bool, "has mana", "self target") &&
|
||||
AI_VALUE2(uint8, "mana", "self target") < 100;
|
||||
}
|
||||
|
||||
bool DrinkAction::isPossible()
|
||||
{
|
||||
return !bot->IsInCombat() && !bot->IsMounted() &&
|
||||
!botAI->HasAnyAuraOf(GetTarget(), "dire bear form", "bear form", "cat form", "travel form", "aquatic form",
|
||||
"flight form", "swift flight form", nullptr) &&
|
||||
(botAI->HasCheat(BotCheatMask::food) || UseItemAction::isPossible());
|
||||
return !bot->IsInCombat() &&
|
||||
!bot->IsMounted() &&
|
||||
!botAI->HasAnyAuraOf(GetTarget(), "dire bear form", "bear form", "cat form", "travel form",
|
||||
"aquatic form","flight form", "swift flight form", nullptr) &&
|
||||
(botAI->HasCheat(BotCheatMask::food) || UseItemAction::isPossible());
|
||||
}
|
||||
|
||||
bool EatAction::Execute(Event event)
|
||||
@ -100,12 +102,17 @@ bool EatAction::Execute(Event event)
|
||||
return UseItemAction::Execute(event);
|
||||
}
|
||||
|
||||
bool EatAction::isUseful() { return UseItemAction::isUseful() && AI_VALUE2(uint8, "health", "self target") < 100; }
|
||||
bool EatAction::isUseful()
|
||||
{
|
||||
return UseItemAction::isUseful() &&
|
||||
AI_VALUE2(uint8, "health", "self target") < 100;
|
||||
}
|
||||
|
||||
bool EatAction::isPossible()
|
||||
{
|
||||
return !bot->IsInCombat() && !bot->IsMounted() &&
|
||||
!botAI->HasAnyAuraOf(GetTarget(), "dire bear form", "bear form", "cat form", "travel form", "aquatic form",
|
||||
"flight form", "swift flight form", nullptr) &&
|
||||
(botAI->HasCheat(BotCheatMask::food) || UseItemAction::isPossible());
|
||||
return !bot->IsInCombat() &&
|
||||
!bot->IsMounted() &&
|
||||
!botAI->HasAnyAuraOf(GetTarget(), "dire bear form", "bear form", "cat form", "travel form",
|
||||
"aquatic form","flight form", "swift flight form", nullptr) &&
|
||||
(botAI->HasCheat(BotCheatMask::food) || UseItemAction::isPossible());
|
||||
}
|
||||
|
||||
@ -150,7 +150,7 @@ bool FindCorpseAction::Execute(Event event)
|
||||
{
|
||||
float rx, ry, rz;
|
||||
if (manager.CalculateDestination(&rx, &ry, &rz))
|
||||
moveToPos = WorldPosition(moveToPos.GetMapId(), rx, ry, rz, 0.0);
|
||||
moveToPos = WorldPosition(moveToPos.getMapId(), rx, ry, rz, 0.0);
|
||||
else if (!moveToPos.GetReachableRandomPointOnGround(bot, reclaimDist, urand(0, 1)))
|
||||
moveToPos = corpsePos;
|
||||
}
|
||||
@ -170,7 +170,7 @@ bool FindCorpseAction::Execute(Event event)
|
||||
{
|
||||
bot->GetMotionMaster()->Clear();
|
||||
bot->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_TELEPORTED | AURA_INTERRUPT_FLAG_CHANGE_MAP);
|
||||
bot->TeleportTo(moveToPos.GetMapId(), moveToPos.GetPositionX(), moveToPos.GetPositionY(), moveToPos.GetPositionZ(), 0);
|
||||
bot->TeleportTo(moveToPos.getMapId(), moveToPos.getX(), moveToPos.getY(), moveToPos.getZ(), 0);
|
||||
}
|
||||
|
||||
moved = true;
|
||||
@ -184,7 +184,7 @@ bool FindCorpseAction::Execute(Event event)
|
||||
if (deadTime < 10 * MINUTE && dCount < 5) // Look for corpse up to 30 minutes.
|
||||
{
|
||||
moved =
|
||||
MoveTo(moveToPos.GetMapId(), moveToPos.GetPositionX(), moveToPos.GetPositionY(), moveToPos.GetPositionZ(), false, false);
|
||||
MoveTo(moveToPos.getMapId(), moveToPos.getX(), moveToPos.getY(), moveToPos.getZ(), false, false);
|
||||
}
|
||||
|
||||
if (!moved)
|
||||
@ -237,10 +237,10 @@ GraveyardStruct const* SpiritHealerAction::GetGrave(bool startZone)
|
||||
{
|
||||
uint32 areaId = 0;
|
||||
uint32 zoneId = 0;
|
||||
sMapMgr->GetZoneAndAreaId(bot->GetPhaseMask(), zoneId, areaId, travelPos.GetMapId(), travelPos.GetPositionX(),
|
||||
travelPos.GetPositionY(), travelPos.GetPositionZ());
|
||||
ClosestGrave = sGraveyard->GetClosestGraveyard(travelPos.GetMapId(), travelPos.GetPositionX(), travelPos.GetPositionY(),
|
||||
travelPos.GetPositionZ(), bot->GetTeamId(), areaId, zoneId,
|
||||
sMapMgr->GetZoneAndAreaId(bot->GetPhaseMask(), zoneId, areaId, travelPos.getMapId(), travelPos.getX(),
|
||||
travelPos.getY(), travelPos.getZ());
|
||||
ClosestGrave = sGraveyard->GetClosestGraveyard(travelPos.getMapId(), travelPos.getX(), travelPos.getY(),
|
||||
travelPos.getZ(), bot->GetTeamId(), areaId, zoneId,
|
||||
bot->getClass() == CLASS_DEATH_KNIGHT);
|
||||
|
||||
if (ClosestGrave)
|
||||
|
||||
@ -85,7 +85,7 @@ bool RpgAction::SetNextRpgAction()
|
||||
isChecked = true;
|
||||
|
||||
Action* action = botAI->GetAiObjectContext()->GetAction(nextAction.getName());
|
||||
if (!dynamic_cast<RpgEnabled*>(action) || !action->isUseful() || !action->isPossible())
|
||||
if (!dynamic_cast<RpgEnabled*>(action) || !action->isPossible() || !action->isUseful())
|
||||
continue;
|
||||
|
||||
actions.push_back(action);
|
||||
|
||||
@ -150,7 +150,7 @@ bool RpgTaxiAction::Execute(Event event)
|
||||
bot->GetSession()->HandleCancelMountAuraOpcode(emptyPacket);
|
||||
|
||||
uint32 node =
|
||||
sObjectMgr->GetNearestTaxiNode(guidP.GetPositionX(), guidP.GetPositionY(), guidP.GetPositionZ(), guidP.GetMapId(), bot->GetTeamId());
|
||||
sObjectMgr->GetNearestTaxiNode(guidP.getX(), guidP.getY(), guidP.getZ(), guidP.getMapId(), bot->GetTeamId());
|
||||
|
||||
std::vector<uint32> nodes;
|
||||
for (uint32 i = 0; i < sTaxiPathStore.GetNumRows(); ++i)
|
||||
@ -208,7 +208,7 @@ bool RpgDiscoverAction::Execute(Event event)
|
||||
GuidPosition guidP = rpg->guidP();
|
||||
|
||||
uint32 node =
|
||||
sObjectMgr->GetNearestTaxiNode(guidP.GetPositionX(), guidP.GetPositionY(), guidP.GetPositionZ(), guidP.GetMapId(), bot->GetTeamId());
|
||||
sObjectMgr->GetNearestTaxiNode(guidP.getX(), guidP.getY(), guidP.getZ(), guidP.getMapId(), bot->GetTeamId());
|
||||
|
||||
if (!node)
|
||||
return false;
|
||||
|
||||
@ -80,9 +80,8 @@ bool RTSCAction::Execute(Event event)
|
||||
SET_AI_VALUE2(WorldPosition, "RTSC saved location", locationName, spellPosition);
|
||||
|
||||
Creature* wpCreature =
|
||||
bot->SummonCreature(15631, spellPosition.GetPositionX(), spellPosition.GetPositionY(),
|
||||
spellPosition.GetPositionZ(), spellPosition.GetOrientation(), TEMPSUMMON_TIMED_DESPAWN,
|
||||
2000.0f);
|
||||
bot->SummonCreature(15631, spellPosition.getX(), spellPosition.getY(), spellPosition.getZ(),
|
||||
spellPosition.getO(), TEMPSUMMON_TIMED_DESPAWN, 2000.0f);
|
||||
wpCreature->SetObjectScale(0.5f);
|
||||
|
||||
return true;
|
||||
@ -111,9 +110,8 @@ bool RTSCAction::Execute(Event event)
|
||||
if (spellPosition)
|
||||
{
|
||||
Creature* wpCreature =
|
||||
bot->SummonCreature(15631, spellPosition.GetPositionX(), spellPosition.GetPositionY(),
|
||||
spellPosition.GetPositionZ(), spellPosition.GetOrientation(),
|
||||
TEMPSUMMON_TIMED_DESPAWN, 2000.0f);
|
||||
bot->SummonCreature(15631, spellPosition.getX(), spellPosition.getY(), spellPosition.getZ(),
|
||||
spellPosition.getO(), TEMPSUMMON_TIMED_DESPAWN, 2000.0f);
|
||||
wpCreature->SetObjectScale(0.5f);
|
||||
}
|
||||
|
||||
|
||||
@ -134,8 +134,8 @@ bool SeeSpellAction::Execute(Event event)
|
||||
SET_AI_VALUE2(WorldPosition, "RTSC saved location", locationName, spellPosition);
|
||||
|
||||
Creature* wpCreature =
|
||||
bot->SummonCreature(15631, spellPosition.GetPositionX(), spellPosition.GetPositionY(), spellPosition.GetPositionZ(),
|
||||
spellPosition.GetOrientation(), TEMPSUMMON_TIMED_DESPAWN, 2000.0f);
|
||||
bot->SummonCreature(15631, spellPosition.getX(), spellPosition.getY(), spellPosition.getZ(),
|
||||
spellPosition.getO(), TEMPSUMMON_TIMED_DESPAWN, 2000.0f);
|
||||
wpCreature->SetObjectScale(0.5f);
|
||||
RESET_AI_VALUE(std::string, "RTSC next spell action");
|
||||
|
||||
@ -167,14 +167,14 @@ bool SeeSpellAction::MoveToSpell(WorldPosition& spellPosition, bool inFormation)
|
||||
PositionMap& posMap = AI_VALUE(PositionMap&, "position");
|
||||
PositionInfo stayPosition = posMap["stay"];
|
||||
|
||||
stayPosition.Set(spellPosition.GetPositionX(), spellPosition.GetPositionY(), spellPosition.GetPositionZ(), spellPosition.GetMapId());
|
||||
stayPosition.Set(spellPosition.getX(), spellPosition.getY(), spellPosition.getZ(), spellPosition.getMapId());
|
||||
posMap["stay"] = stayPosition;
|
||||
}
|
||||
|
||||
if (bot->IsWithinLOS(spellPosition.GetPositionX(), spellPosition.GetPositionY(), spellPosition.GetPositionZ()))
|
||||
return MoveNear(spellPosition.GetMapId(), spellPosition.GetPositionX(), spellPosition.GetPositionY(), spellPosition.GetPositionZ(), 0);
|
||||
if (bot->IsWithinLOS(spellPosition.getX(), spellPosition.getY(), spellPosition.getZ()))
|
||||
return MoveNear(spellPosition.getMapId(), spellPosition.getX(), spellPosition.getY(), spellPosition.getZ(), 0);
|
||||
|
||||
return MoveTo(spellPosition.GetMapId(), spellPosition.GetPositionX(), spellPosition.GetPositionY(), spellPosition.GetPositionZ(), false,
|
||||
return MoveTo(spellPosition.getMapId(), spellPosition.getX(), spellPosition.getY(), spellPosition.getZ(), false,
|
||||
false);
|
||||
}
|
||||
|
||||
|
||||
@ -7,9 +7,9 @@
|
||||
|
||||
#include "ChatHelper.h"
|
||||
#include "Event.h"
|
||||
#include "ItemPackets.h"
|
||||
#include "ItemUsageValue.h"
|
||||
#include "Playerbots.h"
|
||||
#include "ItemPackets.h"
|
||||
|
||||
bool UseItemAction::Execute(Event event)
|
||||
{
|
||||
@ -416,6 +416,13 @@ bool UseHearthStone::Execute(Event event)
|
||||
|
||||
bool UseHearthStone::isUseful() { return !bot->InBattleground(); }
|
||||
|
||||
bool UseRandomRecipe::isUseful()
|
||||
{
|
||||
return !bot->IsInCombat() && !botAI->HasActivePlayerMaster() && !bot->InBattleground();
|
||||
}
|
||||
|
||||
bool UseRandomRecipe::isPossible() { return AI_VALUE2(uint32, "item count", "recipe") > 0; }
|
||||
|
||||
bool UseRandomRecipe::Execute(Event event)
|
||||
{
|
||||
std::vector<Item*> recipes = AI_VALUE2(std::vector<Item*>, "inventory items", "recipe");
|
||||
@ -438,12 +445,12 @@ bool UseRandomRecipe::Execute(Event event)
|
||||
return used;
|
||||
}
|
||||
|
||||
bool UseRandomRecipe::isUseful()
|
||||
bool UseRandomQuestItem::isUseful()
|
||||
{
|
||||
return !bot->IsInCombat() && !botAI->HasActivePlayerMaster() && !bot->InBattleground();
|
||||
return !botAI->HasActivePlayerMaster() && !bot->InBattleground() && !bot->HasUnitState(UNIT_STATE_IN_FLIGHT);
|
||||
}
|
||||
|
||||
bool UseRandomRecipe::isPossible() { return AI_VALUE2(uint32, "item count", "recipe") > 0; }
|
||||
bool UseRandomQuestItem::isPossible() { return AI_VALUE2(uint32, "item count", "quest") > 0; }
|
||||
|
||||
bool UseRandomQuestItem::Execute(Event event)
|
||||
{
|
||||
@ -471,6 +478,7 @@ bool UseRandomQuestItem::Execute(Event event)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (!item)
|
||||
@ -482,10 +490,3 @@ bool UseRandomQuestItem::Execute(Event event)
|
||||
|
||||
return used;
|
||||
}
|
||||
|
||||
bool UseRandomQuestItem::isUseful()
|
||||
{
|
||||
return !botAI->HasActivePlayerMaster() && !bot->InBattleground() && !bot->HasUnitState(UNIT_STATE_IN_FLIGHT);
|
||||
}
|
||||
|
||||
bool UseRandomQuestItem::isPossible() { return AI_VALUE2(uint32, "item count", "quest") > 0; }
|
||||
|
||||
@ -69,8 +69,8 @@ class UseHearthStone : public UseItemAction
|
||||
public:
|
||||
UseHearthStone(PlayerbotAI* botAI) : UseItemAction(botAI, "hearthstone", true) {}
|
||||
|
||||
bool Execute(Event event) override;
|
||||
bool isUseful() override;
|
||||
bool Execute(Event event) override;
|
||||
};
|
||||
|
||||
class UseRandomRecipe : public UseItemAction
|
||||
@ -78,9 +78,9 @@ class UseRandomRecipe : public UseItemAction
|
||||
public:
|
||||
UseRandomRecipe(PlayerbotAI* botAI) : UseItemAction(botAI, "random recipe", true) {}
|
||||
|
||||
bool Execute(Event event) override;
|
||||
bool isUseful() override;
|
||||
bool isPossible() override;
|
||||
bool Execute(Event event) override;
|
||||
};
|
||||
|
||||
class UseRandomQuestItem : public UseItemAction
|
||||
@ -88,9 +88,9 @@ class UseRandomQuestItem : public UseItemAction
|
||||
public:
|
||||
UseRandomQuestItem(PlayerbotAI* botAI) : UseItemAction(botAI, "random quest item", true) {}
|
||||
|
||||
bool Execute(Event event) override;
|
||||
bool isUseful() override;
|
||||
bool isPossible() override;
|
||||
bool Execute(Event event) override;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@ -46,8 +46,7 @@ bool RpgTaxiTrigger::IsActive()
|
||||
return false;
|
||||
|
||||
uint32 node =
|
||||
sObjectMgr->GetNearestTaxiNode(guidP.GetPositionX(), guidP.GetPositionY(), guidP.GetPositionZ(),
|
||||
guidP.GetMapId(), bot->GetTeamId());
|
||||
sObjectMgr->GetNearestTaxiNode(guidP.getX(), guidP.getY(), guidP.getZ(), guidP.getMapId(), bot->GetTeamId());
|
||||
|
||||
if (!node)
|
||||
return false;
|
||||
@ -69,8 +68,7 @@ bool RpgDiscoverTrigger::IsActive()
|
||||
return false;
|
||||
|
||||
uint32 node =
|
||||
sObjectMgr->GetNearestTaxiNode(guidP.GetPositionX(), guidP.GetPositionY(), guidP.GetPositionZ(),
|
||||
guidP.GetMapId(), bot->GetTeamId());
|
||||
sObjectMgr->GetNearestTaxiNode(guidP.getX(), guidP.getY(), guidP.getZ(), guidP.getMapId(), bot->GetTeamId());
|
||||
|
||||
if (bot->m_taxi.IsTaximaskNodeKnown(node))
|
||||
return false;
|
||||
|
||||
@ -90,7 +90,7 @@ bool MoveLongStuckTrigger::IsActive()
|
||||
}
|
||||
|
||||
if (cell.GridX() > 0 && cell.GridY() > 0 &&
|
||||
!MMAP::MMapFactory::createOrGetMMapMgr()->loadMap(botPos.GetMapId(), cell.GridX(), cell.GridY()))
|
||||
!MMAP::MMapFactory::createOrGetMMapMgr()->loadMap(botPos.getMapId(), cell.GridX(), cell.GridY()))
|
||||
{
|
||||
// LOG_INFO("playerbots", "Bot {} {}:{} <{}> was in unloaded grid {},{} on map {}",
|
||||
// bot->GetGUID().ToString().c_str(), bot->GetTeamId() == TEAM_ALLIANCE ? "A" : "H", bot->GetLevel(),
|
||||
|
||||
@ -11,10 +11,6 @@
|
||||
|
||||
bool NearestEnemyPlayersValue::AcceptUnit(Unit* unit)
|
||||
{
|
||||
// Apply parent's filtering first (includes level difference checks)
|
||||
if (!PossibleTargetsValue::AcceptUnit(unit))
|
||||
return false;
|
||||
|
||||
bool inCannon = botAI->IsInVehicle(false, true);
|
||||
Player* enemy = dynamic_cast<Player*>(unit);
|
||||
if (enemy && botAI->IsOpposing(enemy) && enemy->IsPvP() &&
|
||||
@ -23,14 +19,7 @@ bool NearestEnemyPlayersValue::AcceptUnit(Unit* unit)
|
||||
((inCannon || !enemy->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE))) &&
|
||||
/*!enemy->HasStealthAura() && !enemy->HasInvisibilityAura()*/ enemy->CanSeeOrDetect(bot) &&
|
||||
!(enemy->HasSpiritOfRedemptionAura()))
|
||||
{
|
||||
// If with master, only attack if master is PvP flagged
|
||||
Player* master = botAI->GetMaster();
|
||||
if (master && !master->IsPvP() && !master->IsFFAPvP())
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -107,7 +107,7 @@ Unit* GrindTargetValue::FindTargetForGrinding(uint32 assistCount)
|
||||
continue;
|
||||
}
|
||||
|
||||
bool inactiveGrindStatus = botAI->rpgInfo.GetStatus() != RPG_WANDER_RANDOM && botAI->rpgInfo.GetStatus() != RPG_IDLE;
|
||||
bool inactiveGrindStatus = botAI->rpgInfo.status != RPG_WANDER_RANDOM && botAI->rpgInfo.status != RPG_IDLE;
|
||||
|
||||
float aggroRange = 30.0f;
|
||||
if (unit->ToCreature())
|
||||
|
||||
@ -16,20 +16,6 @@
|
||||
#include "SpellAuraEffects.h"
|
||||
#include "SpellMgr.h"
|
||||
#include "Unit.h"
|
||||
#include "AreaDefines.h"
|
||||
|
||||
// Level difference thresholds for attack probability
|
||||
constexpr int32 EXTREME_LEVEL_DIFF = 5; // Don't attack if enemy is this much higher
|
||||
constexpr int32 HIGH_LEVEL_DIFF = 4; // 25% chance at +/- this difference
|
||||
constexpr int32 MID_LEVEL_DIFF = 3; // 50% chance at +/- this difference
|
||||
constexpr int32 LOW_LEVEL_DIFF = 2; // 75% chance at +/- this difference
|
||||
|
||||
// Time window for deterministic attack decisions
|
||||
constexpr uint32 ATTACK_DECISION_TIME_WINDOW = 2 * MINUTE;
|
||||
|
||||
// 64 bit FNV-1a hash constants
|
||||
constexpr uint64_t FNV_OFFSET_BASIS = 14695981039346656037ULL;
|
||||
constexpr uint64_t FNV_PRIME = 1099511628211ULL;
|
||||
|
||||
void PossibleTargetsValue::FindUnits(std::list<Unit*>& targets)
|
||||
{
|
||||
@ -38,103 +24,7 @@ void PossibleTargetsValue::FindUnits(std::list<Unit*>& targets)
|
||||
Cell::VisitObjects(bot, searcher, range);
|
||||
}
|
||||
|
||||
bool PossibleTargetsValue::AcceptUnit(Unit* unit)
|
||||
{
|
||||
if (!AttackersValue::IsPossibleTarget(unit, bot, range))
|
||||
return false;
|
||||
|
||||
// Level-based PvP restrictions
|
||||
if (unit->IsPlayer())
|
||||
{
|
||||
// Self-defense - always allow fighting back
|
||||
if (bot->IsInCombat() && bot->GetVictim() == unit)
|
||||
return true; // Already fighting
|
||||
|
||||
Unit* botAttacker = bot->getAttackerForHelper();
|
||||
if (botAttacker)
|
||||
{
|
||||
if (botAttacker == unit)
|
||||
return true; // Enemy attacking
|
||||
|
||||
if (botAttacker->IsPet())
|
||||
{
|
||||
Unit* petOwner = botAttacker->GetOwner();
|
||||
if (petOwner && petOwner == unit)
|
||||
return true; // Enemy's pet attacking
|
||||
}
|
||||
}
|
||||
|
||||
// Skip restrictions in BG/Arena
|
||||
if (bot->InBattleground() || bot->InArena())
|
||||
return true;
|
||||
|
||||
// Skip restrictions if in duel with this player
|
||||
if (bot->duel && bot->duel->Opponent == unit)
|
||||
return true;
|
||||
|
||||
// Capital cities - no restrictions
|
||||
uint32 zoneId = bot->GetZoneId();
|
||||
bool inCapitalCity = (zoneId == AREA_STORMWIND_CITY ||
|
||||
zoneId == AREA_IRONFORGE ||
|
||||
zoneId == AREA_DARNASSUS ||
|
||||
zoneId == AREA_THE_EXODAR ||
|
||||
zoneId == AREA_ORGRIMMAR ||
|
||||
zoneId == AREA_THUNDER_BLUFF ||
|
||||
zoneId == AREA_UNDERCITY ||
|
||||
zoneId == AREA_SILVERMOON_CITY);
|
||||
|
||||
if (inCapitalCity)
|
||||
return true;
|
||||
|
||||
// Level difference check
|
||||
int32 levelDifference = unit->GetLevel() - bot->GetLevel();
|
||||
int32 absLevelDifference = std::abs(levelDifference);
|
||||
|
||||
// Extreme difference - do not attack
|
||||
if (levelDifference >= EXTREME_LEVEL_DIFF)
|
||||
return false;
|
||||
|
||||
// Calculate attack chance based on level difference
|
||||
uint32 attackChance = 100; // Default 100%: Bot and target's levels are very close
|
||||
|
||||
// There's a chance a bot might gank on an extremly low target
|
||||
if ((absLevelDifference < EXTREME_LEVEL_DIFF && absLevelDifference >= HIGH_LEVEL_DIFF) ||
|
||||
levelDifference <= -EXTREME_LEVEL_DIFF)
|
||||
attackChance = 25;
|
||||
|
||||
else if (absLevelDifference < HIGH_LEVEL_DIFF && absLevelDifference >= MID_LEVEL_DIFF)
|
||||
attackChance = 50;
|
||||
|
||||
else if (absLevelDifference < MID_LEVEL_DIFF && absLevelDifference >= LOW_LEVEL_DIFF)
|
||||
attackChance = 75;
|
||||
|
||||
// If probability check needed, use deterministic hash-based decision
|
||||
if (attackChance < 100)
|
||||
{
|
||||
// Decisions remain stable for ATTACK_DECISION_TIME_WINDOW.
|
||||
time_t timeWindow = time(nullptr) / ATTACK_DECISION_TIME_WINDOW;
|
||||
|
||||
// FNV-1a hash used to deterministically convert botGUID, targetGUID, and timeWindow
|
||||
// into a consistent percentage chance without needing to cache previous decisions.
|
||||
// See: http://www.isthe.com/chongo/tech/comp/fnv/
|
||||
uint64_t hash = FNV_OFFSET_BASIS;
|
||||
|
||||
// Diffuse bot GUID, target GUID, and time window into the hash
|
||||
hash ^= bot->GetGUID().GetRawValue();
|
||||
hash *= FNV_PRIME;
|
||||
hash ^= unit->GetGUID().GetRawValue();
|
||||
hash *= FNV_PRIME;
|
||||
hash ^= static_cast<uint64_t>(timeWindow);
|
||||
hash *= FNV_PRIME;
|
||||
|
||||
// Convert hash to 0-99 range and compare against attack chance percentage.
|
||||
// Ex: attackChance=75: hash 0-74 = attack (75%), hash 75-99 = don't attack (25%)
|
||||
return (hash % 100) < attackChance;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
bool PossibleTargetsValue::AcceptUnit(Unit* unit) { return AttackersValue::IsPossibleTarget(unit, bot, range); }
|
||||
|
||||
void PossibleTriggersValue::FindUnits(std::list<Unit*>& targets)
|
||||
{
|
||||
@ -146,8 +36,9 @@ void PossibleTriggersValue::FindUnits(std::list<Unit*>& targets)
|
||||
bool PossibleTriggersValue::AcceptUnit(Unit* unit)
|
||||
{
|
||||
if (!unit->HasUnitFlag(UNIT_FLAG_NOT_SELECTABLE))
|
||||
{
|
||||
return false;
|
||||
|
||||
}
|
||||
Unit::AuraEffectList const& aurasPeriodicTriggerSpell =
|
||||
unit->GetAuraEffectsByType(SPELL_AURA_PERIODIC_TRIGGER_SPELL);
|
||||
Unit::AuraEffectList const& aurasPeriodicTriggerWithValueSpell =
|
||||
@ -167,7 +58,9 @@ bool PossibleTriggersValue::AcceptUnit(Unit* unit)
|
||||
for (int j = 0; j < MAX_SPELL_EFFECTS; j++)
|
||||
{
|
||||
if (triggerSpellInfo->Effects[j].Effect == SPELL_EFFECT_SCHOOL_DAMAGE)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -7,19 +7,20 @@
|
||||
|
||||
#include "Playerbots.h"
|
||||
|
||||
bool CastBearFormAction::isUseful()
|
||||
{
|
||||
return CastBuffSpellAction::isUseful() && !botAI->HasAura("dire bear form", GetTarget());
|
||||
}
|
||||
|
||||
bool CastBearFormAction::isPossible()
|
||||
{
|
||||
return CastBuffSpellAction::isPossible() && !botAI->HasAura("dire bear form", GetTarget());
|
||||
}
|
||||
|
||||
bool CastBearFormAction::isUseful()
|
||||
{
|
||||
return CastBuffSpellAction::isUseful() && !botAI->HasAura("dire bear form", GetTarget());
|
||||
}
|
||||
|
||||
std::vector<NextAction> CastDireBearFormAction::getAlternatives()
|
||||
{
|
||||
return NextAction::merge({NextAction("bear form")}, CastSpellAction::getAlternatives());
|
||||
return NextAction::merge({ NextAction("bear form") },
|
||||
CastSpellAction::getAlternatives());
|
||||
}
|
||||
|
||||
bool CastTravelFormAction::isUseful()
|
||||
@ -31,17 +32,22 @@ bool CastTravelFormAction::isUseful()
|
||||
!botAI->HasAura("dash", bot);
|
||||
}
|
||||
|
||||
bool CastCasterFormAction::isUseful()
|
||||
{
|
||||
return botAI->HasAnyAuraOf(GetTarget(), "dire bear form", "bear form", "cat form", "travel form", "aquatic form",
|
||||
"flight form", "swift flight form", "moonkin form", nullptr) &&
|
||||
AI_VALUE2(uint8, "mana", "self target") > sPlayerbotAIConfig.mediumHealth;
|
||||
}
|
||||
|
||||
bool CastCasterFormAction::Execute(Event event)
|
||||
{
|
||||
botAI->RemoveShapeshift();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CastCasterFormAction::isUseful()
|
||||
bool CastCancelTreeFormAction::isUseful()
|
||||
{
|
||||
return botAI->HasAnyAuraOf(GetTarget(), "dire bear form", "bear form", "cat form", "travel form", "aquatic form",
|
||||
"flight form", "swift flight form", "moonkin form", nullptr) &&
|
||||
AI_VALUE2(uint8, "mana", "self target") > sPlayerbotAIConfig.mediumHealth;
|
||||
return botAI->HasAura(33891, bot);
|
||||
}
|
||||
|
||||
bool CastCancelTreeFormAction::Execute(Event event)
|
||||
@ -50,8 +56,6 @@ bool CastCancelTreeFormAction::Execute(Event event)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CastCancelTreeFormAction::isUseful() { return botAI->HasAura(33891, bot); }
|
||||
|
||||
bool CastTreeFormAction::isUseful()
|
||||
{
|
||||
return GetTarget() && CastSpellAction::isUseful() && !botAI->HasAura(33891, bot);
|
||||
|
||||
@ -15,8 +15,8 @@ class CastBearFormAction : public CastBuffSpellAction
|
||||
public:
|
||||
CastBearFormAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "bear form") {}
|
||||
|
||||
bool isUseful() override;
|
||||
bool isPossible() override;
|
||||
bool isUseful() override;
|
||||
};
|
||||
|
||||
class CastDireBearFormAction : public CastBuffSpellAction
|
||||
@ -37,7 +37,6 @@ class CastTreeFormAction : public CastBuffSpellAction
|
||||
{
|
||||
public:
|
||||
CastTreeFormAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "tree of life") {}
|
||||
|
||||
bool isUseful() override;
|
||||
};
|
||||
|
||||
@ -66,9 +65,9 @@ class CastCasterFormAction : public CastBuffSpellAction
|
||||
public:
|
||||
CastCasterFormAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "caster form") {}
|
||||
|
||||
bool Execute(Event event) override;
|
||||
bool isUseful() override;
|
||||
bool isPossible() override { return true; }
|
||||
bool Execute(Event event) override;
|
||||
};
|
||||
|
||||
class CastCancelTreeFormAction : public CastBuffSpellAction
|
||||
@ -76,9 +75,9 @@ class CastCancelTreeFormAction : public CastBuffSpellAction
|
||||
public:
|
||||
CastCancelTreeFormAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "cancel tree form") {}
|
||||
|
||||
bool Execute(Event event) override;
|
||||
bool isUseful() override;
|
||||
bool isPossible() override { return true; }
|
||||
bool Execute(Event event) override;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@ -8,14 +8,16 @@
|
||||
#include "Event.h"
|
||||
#include "Playerbots.h"
|
||||
|
||||
bool CastRemoveShadowformAction::isUseful() { return botAI->HasAura("shadowform", AI_VALUE(Unit*, "self target")); }
|
||||
|
||||
bool CastRemoveShadowformAction::isPossible() { return true; }
|
||||
|
||||
bool CastRemoveShadowformAction::Execute(Event event)
|
||||
{
|
||||
botAI->RemoveAura("shadowform");
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CastRemoveShadowformAction::isUseful() { return botAI->HasAura("shadowform", AI_VALUE(Unit*, "self target")); }
|
||||
|
||||
Unit* CastPowerWordShieldOnAlmostFullHealthBelowAction::GetTarget()
|
||||
{
|
||||
Group* group = bot->GetGroup();
|
||||
|
||||
@ -56,10 +56,7 @@ HEAL_PARTY_ACTION(CastRenewOnPartyAction, "renew", 15.0f, HealingManaEfficiency:
|
||||
class CastPrayerOfMendingAction : public HealPartyMemberAction
|
||||
{
|
||||
public:
|
||||
CastPrayerOfMendingAction(PlayerbotAI* botAI)
|
||||
: HealPartyMemberAction(botAI, "prayer of mending", 10.0f, HealingManaEfficiency::HIGH, false)
|
||||
{
|
||||
}
|
||||
CastPrayerOfMendingAction(PlayerbotAI* botAI) : HealPartyMemberAction(botAI, "prayer of mending", 10.0f, HealingManaEfficiency::HIGH, false) {}
|
||||
};
|
||||
|
||||
HEAL_PARTY_ACTION(CastBindingHealAction, "binding heal", 15.0f, HealingManaEfficiency::MEDIUM);
|
||||
@ -68,8 +65,7 @@ HEAL_PARTY_ACTION(CastPrayerOfHealingAction, "prayer of healing", 15.0f, Healing
|
||||
class CastCircleOfHealingAction : public HealPartyMemberAction
|
||||
{
|
||||
public:
|
||||
CastCircleOfHealingAction(PlayerbotAI* ai)
|
||||
: HealPartyMemberAction(ai, "circle of healing", 15.0f, HealingManaEfficiency::HIGH)
|
||||
CastCircleOfHealingAction(PlayerbotAI* ai) : HealPartyMemberAction(ai, "circle of healing", 15.0f, HealingManaEfficiency::HIGH)
|
||||
{
|
||||
}
|
||||
};
|
||||
@ -138,15 +134,15 @@ class CastRemoveShadowformAction : public Action
|
||||
public:
|
||||
CastRemoveShadowformAction(PlayerbotAI* botAI) : Action(botAI, "remove shadowform") {}
|
||||
|
||||
bool Execute(Event event) override;
|
||||
bool isUseful() override;
|
||||
bool isPossible() override;
|
||||
bool Execute(Event event) override;
|
||||
};
|
||||
|
||||
class CastDispersionAction : public CastSpellAction
|
||||
{
|
||||
public:
|
||||
CastDispersionAction(PlayerbotAI* ai) : CastSpellAction(ai, "dispersion") {}
|
||||
|
||||
virtual std::string const GetTargetName() { return "self target"; }
|
||||
};
|
||||
|
||||
@ -162,7 +158,6 @@ class CastHymnOfHopeAction : public CastSpellAction
|
||||
{
|
||||
public:
|
||||
CastHymnOfHopeAction(PlayerbotAI* ai) : CastSpellAction(ai, "hymn of hope") {}
|
||||
|
||||
virtual std::string const GetTargetName() { return "self target"; }
|
||||
};
|
||||
|
||||
@ -170,7 +165,6 @@ class CastDivineHymnAction : public CastSpellAction
|
||||
{
|
||||
public:
|
||||
CastDivineHymnAction(PlayerbotAI* ai) : CastSpellAction(ai, "divine hymn") {}
|
||||
|
||||
virtual std::string const GetTargetName() { return "self target"; }
|
||||
};
|
||||
|
||||
@ -178,7 +172,6 @@ class CastShadowfiendAction : public CastSpellAction
|
||||
{
|
||||
public:
|
||||
CastShadowfiendAction(PlayerbotAI* ai) : CastSpellAction(ai, "shadowfiend") {}
|
||||
|
||||
virtual std::string const GetTargetName() { return "current target"; }
|
||||
};
|
||||
|
||||
@ -189,7 +182,6 @@ public:
|
||||
: HealPartyMemberAction(ai, "power word: shield", 15.0f, HealingManaEfficiency::HIGH)
|
||||
{
|
||||
}
|
||||
|
||||
bool isUseful() override;
|
||||
Unit* GetTarget() override;
|
||||
};
|
||||
@ -201,7 +193,6 @@ public:
|
||||
: HealPartyMemberAction(ai, "power word: shield", 5.0f, HealingManaEfficiency::HIGH)
|
||||
{
|
||||
}
|
||||
|
||||
bool isUseful() override;
|
||||
Unit* GetTarget() override;
|
||||
};
|
||||
@ -210,17 +201,13 @@ class CastMindSearAction : public CastSpellAction
|
||||
{
|
||||
public:
|
||||
CastMindSearAction(PlayerbotAI* ai) : CastSpellAction(ai, "mind sear") {}
|
||||
|
||||
ActionThreatType getThreatType() override { return ActionThreatType::Aoe; }
|
||||
};
|
||||
|
||||
class CastGuardianSpiritOnPartyAction : public HealPartyMemberAction
|
||||
{
|
||||
public:
|
||||
CastGuardianSpiritOnPartyAction(PlayerbotAI* ai)
|
||||
: HealPartyMemberAction(ai, "guardian spirit", 40.0f, HealingManaEfficiency::MEDIUM)
|
||||
{
|
||||
}
|
||||
CastGuardianSpiritOnPartyAction(PlayerbotAI* ai) : HealPartyMemberAction(ai, "guardian spirit", 40.0f, HealingManaEfficiency::MEDIUM) {}
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@ -27,7 +27,6 @@ class CastHungerForBloodAction : public CastBuffSpellAction
|
||||
{
|
||||
public:
|
||||
CastHungerForBloodAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "hunger for blood") {}
|
||||
|
||||
std::string const GetTargetName() override { return "current target"; }
|
||||
};
|
||||
|
||||
@ -44,9 +43,9 @@ class CastStealthAction : public CastBuffSpellAction
|
||||
public:
|
||||
CastStealthAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "stealth") {}
|
||||
|
||||
std::string const GetTargetName() override { return "self target"; }
|
||||
bool isUseful() override;
|
||||
bool isPossible() override;
|
||||
std::string const GetTargetName() override { return "self target"; }
|
||||
};
|
||||
|
||||
class UnstealthAction : public Action
|
||||
@ -62,8 +61,8 @@ class CheckStealthAction : public Action
|
||||
public:
|
||||
CheckStealthAction(PlayerbotAI* botAI) : Action(botAI, "check stealth") {}
|
||||
|
||||
bool Execute(Event event) override;
|
||||
bool isPossible() override { return true; }
|
||||
bool Execute(Event event) override;
|
||||
};
|
||||
|
||||
class CastKickAction : public CastSpellAction
|
||||
@ -132,7 +131,6 @@ class CastEnvenomAction : public CastMeleeSpellAction
|
||||
{
|
||||
public:
|
||||
CastEnvenomAction(PlayerbotAI* ai) : CastMeleeSpellAction(ai, "envenom") {}
|
||||
|
||||
bool isUseful() override;
|
||||
bool isPossible() override;
|
||||
};
|
||||
@ -141,42 +139,37 @@ class CastTricksOfTheTradeOnMainTankAction : public BuffOnMainTankAction
|
||||
{
|
||||
public:
|
||||
CastTricksOfTheTradeOnMainTankAction(PlayerbotAI* ai) : BuffOnMainTankAction(ai, "tricks of the trade", true) {}
|
||||
|
||||
bool isUseful() override;
|
||||
virtual bool isUseful() override;
|
||||
};
|
||||
|
||||
class UseDeadlyPoisonAction : public UseItemAction
|
||||
{
|
||||
public:
|
||||
UseDeadlyPoisonAction(PlayerbotAI* ai) : UseItemAction(ai, "Deadly Poison") {}
|
||||
|
||||
bool Execute(Event event) override;
|
||||
bool isPossible() override;
|
||||
virtual bool Execute(Event event) override;
|
||||
virtual bool isPossible() override;
|
||||
};
|
||||
|
||||
class UseInstantPoisonAction : public UseItemAction
|
||||
{
|
||||
public:
|
||||
UseInstantPoisonAction(PlayerbotAI* ai) : UseItemAction(ai, "Instant Poison") {}
|
||||
|
||||
bool Execute(Event event) override;
|
||||
bool isPossible() override;
|
||||
virtual bool Execute(Event event) override;
|
||||
virtual bool isPossible() override;
|
||||
};
|
||||
|
||||
class UseInstantPoisonOffHandAction : public UseItemAction
|
||||
{
|
||||
public:
|
||||
UseInstantPoisonOffHandAction(PlayerbotAI* ai) : UseItemAction(ai, "Instant Poison Off Hand") {}
|
||||
|
||||
bool Execute(Event event) override;
|
||||
bool isPossible() override;
|
||||
virtual bool Execute(Event event) override;
|
||||
virtual bool isPossible() override;
|
||||
};
|
||||
|
||||
class FanOfKnivesAction : public CastMeleeSpellAction
|
||||
{
|
||||
public:
|
||||
FanOfKnivesAction(PlayerbotAI* ai) : CastMeleeSpellAction(ai, "fan of knives") {}
|
||||
|
||||
ActionThreatType getThreatType() override { return ActionThreatType::Aoe; }
|
||||
};
|
||||
|
||||
|
||||
@ -176,19 +176,20 @@ Unit* CastShatteringThrowAction::GetTarget()
|
||||
return nullptr; // No valid target
|
||||
}
|
||||
|
||||
bool CastShatteringThrowAction::Execute(Event event)
|
||||
{
|
||||
Unit* target = GetTarget();
|
||||
if (!target)
|
||||
return false;
|
||||
|
||||
return botAI->CastSpell("shattering throw", target);
|
||||
}
|
||||
|
||||
bool CastShatteringThrowAction::isUseful()
|
||||
{
|
||||
if (!bot->HasSpell(64382) || bot->HasSpellCooldown(64382))
|
||||
|
||||
// Spell cooldown check
|
||||
if (!bot->HasSpell(64382))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Spell cooldown check
|
||||
if (bot->HasSpellCooldown(64382))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
GuidVector enemies = AI_VALUE(GuidVector, "possible targets");
|
||||
|
||||
@ -219,12 +220,25 @@ bool CastShatteringThrowAction::isPossible()
|
||||
|
||||
// Range check: Shattering Throw is 30 yards
|
||||
if (!bot->IsWithinDistInMap(target, 30.0f))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check line of sight
|
||||
if (!bot->IsWithinLOSInMap(target))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// If the minimal checks above pass, simply return true.
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CastShatteringThrowAction::Execute(Event event)
|
||||
{
|
||||
Unit* target = GetTarget();
|
||||
if (!target)
|
||||
return false;
|
||||
|
||||
return botAI->CastSpell("shattering throw", target);
|
||||
}
|
||||
|
||||
@ -25,7 +25,8 @@ MELEE_ACTION_U(CastBattleShoutTauntAction, "battle shout", CastSpellAction::isUs
|
||||
class CastDemoralizingShoutAction : public CastMeleeDebuffSpellAction
|
||||
{
|
||||
public:
|
||||
CastDemoralizingShoutAction(PlayerbotAI* botAI) : CastMeleeDebuffSpellAction(botAI, "demoralizing shout") {}
|
||||
CastDemoralizingShoutAction(PlayerbotAI* botAI)
|
||||
: CastMeleeDebuffSpellAction(botAI, "demoralizing shout") {}
|
||||
};
|
||||
|
||||
class CastDemoralizingShoutWithoutLifeTimeCheckAction : public CastMeleeDebuffSpellAction
|
||||
@ -139,8 +140,8 @@ class CastVigilanceAction : public BuffOnPartyAction
|
||||
public:
|
||||
CastVigilanceAction(PlayerbotAI* botAI) : BuffOnPartyAction(botAI, "vigilance") {}
|
||||
|
||||
bool Execute(Event event) override;
|
||||
Unit* GetTarget() override;
|
||||
bool Execute(Event event) override;
|
||||
};
|
||||
|
||||
class CastRetaliationAction : public CastBuffSpellAction
|
||||
@ -156,10 +157,10 @@ class CastShatteringThrowAction : public CastSpellAction
|
||||
public:
|
||||
CastShatteringThrowAction(PlayerbotAI* botAI) : CastSpellAction(botAI, "shattering throw") {}
|
||||
|
||||
bool Execute(Event event) override;
|
||||
Unit* GetTarget() override;
|
||||
bool isUseful() override;
|
||||
bool isPossible() override;
|
||||
Unit* GetTarget() override;
|
||||
bool Execute(Event event) override;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@ -193,18 +193,17 @@ bool IckAndKrickAction::ExplosiveBarrage(bool explosiveBarrage, Unit* boss)
|
||||
{
|
||||
float angle = i * ANGLE_INCREMENT;
|
||||
Position potentialPos;
|
||||
potentialPos.Relocate(bot->GetPositionX() + SAFE_DISTANCE * cos(angle),
|
||||
bot->GetPositionY() + SAFE_DISTANCE * sin(angle),
|
||||
bot->GetPositionZ());
|
||||
potentialPos.m_positionX = bot->GetPositionX() + SAFE_DISTANCE * cos(angle);
|
||||
potentialPos.m_positionY = bot->GetPositionY() + SAFE_DISTANCE * sin(angle);
|
||||
potentialPos.m_positionZ = bot->GetPositionZ();
|
||||
|
||||
// Check if position is valid (not in a wall)
|
||||
if (!bot->IsWithinLOS(potentialPos.GetPositionX(), potentialPos.GetPositionY(),
|
||||
potentialPos.GetPositionZ()))
|
||||
if (!bot->IsWithinLOS(potentialPos.m_positionX, potentialPos.m_positionY, potentialPos.m_positionZ))
|
||||
continue;
|
||||
|
||||
// Check if position is within maximum allowed distance from boss
|
||||
if (boss && sqrt(pow(potentialPos.GetPositionX() - boss->GetPositionX(), 2) +
|
||||
pow(potentialPos.GetPositionY() - boss->GetPositionY(), 2)) > MAX_BOSS_DISTANCE)
|
||||
if (boss && sqrt(pow(potentialPos.m_positionX - boss->GetPositionX(), 2) +
|
||||
pow(potentialPos.m_positionY - boss->GetPositionY(), 2)) > MAX_BOSS_DISTANCE)
|
||||
continue;
|
||||
|
||||
// Score this position based on:
|
||||
@ -217,8 +216,8 @@ bool IckAndKrickAction::ExplosiveBarrage(bool explosiveBarrage, Unit* boss)
|
||||
float minOrbDist = std::numeric_limits<float>::max();
|
||||
for (Unit* orb : orbs)
|
||||
{
|
||||
float orbDist = sqrt(pow(potentialPos.GetPositionX() - orb->GetPositionX(), 2) +
|
||||
pow(potentialPos.GetPositionY() - orb->GetPositionY(), 2));
|
||||
float orbDist = sqrt(pow(potentialPos.m_positionX - orb->GetPositionX(), 2) +
|
||||
pow(potentialPos.m_positionY - orb->GetPositionY(), 2));
|
||||
minOrbDist = std::min(minOrbDist, orbDist);
|
||||
}
|
||||
score += minOrbDist * 2.0f; // Weight orb distance more heavily
|
||||
@ -226,16 +225,16 @@ bool IckAndKrickAction::ExplosiveBarrage(bool explosiveBarrage, Unit* boss)
|
||||
// Check distance from other players
|
||||
for (const Position& playerPos : playerPositions)
|
||||
{
|
||||
float playerDist = sqrt(pow(potentialPos.GetPositionX() - playerPos.GetPositionX(), 2) +
|
||||
pow(potentialPos.GetPositionY() - playerPos.GetPositionY(), 2));
|
||||
float playerDist = sqrt(pow(potentialPos.m_positionX - playerPos.m_positionX, 2) +
|
||||
pow(potentialPos.m_positionY - playerPos.m_positionY, 2));
|
||||
score += std::min(playerDist, 10.0f); // Cap player distance contribution
|
||||
}
|
||||
|
||||
// Factor in proximity to boss (closer is better, as long as we're safe from orbs)
|
||||
if (boss)
|
||||
{
|
||||
float bossDist = sqrt(pow(potentialPos.GetPositionX() - boss->GetPositionX(), 2) +
|
||||
pow(potentialPos.GetPositionY() - boss->GetPositionY(), 2));
|
||||
float bossDist = sqrt(pow(potentialPos.m_positionX - boss->GetPositionX(), 2) +
|
||||
pow(potentialPos.m_positionY - boss->GetPositionY(), 2));
|
||||
// Add points for being closer to boss (inverse relationship)
|
||||
// but only if we're safely away from orbs
|
||||
if (minOrbDist > SAFE_DISTANCE)
|
||||
@ -258,8 +257,7 @@ bool IckAndKrickAction::ExplosiveBarrage(bool explosiveBarrage, Unit* boss)
|
||||
{
|
||||
botAI->Reset();
|
||||
// Use MoveTo instead of FleePosition since we already calculated the exact position
|
||||
return MoveTo(bot->GetMapId(), bestPos.GetPositionX(), bestPos.GetPositionY(), bot->GetPositionZ(), false,
|
||||
false,
|
||||
return MoveTo(bot->GetMapId(), bestPos.m_positionX, bestPos.m_positionY, bot->GetPositionZ(), false, false,
|
||||
false, true, MovementPriority::MOVEMENT_COMBAT);
|
||||
}
|
||||
else
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
#ifndef _PLAYERBOT_RAIDEOEACTIONS_H
|
||||
#define _PLAYERBOT_RAIDEOEACTIONS_H
|
||||
|
||||
#include "MovementActions.h"
|
||||
#include "AttackAction.h"
|
||||
#include "GenericSpellActions.h"
|
||||
#include "MovementActions.h"
|
||||
#include "PlayerbotAI.h"
|
||||
#include "Playerbots.h"
|
||||
|
||||
@ -13,38 +13,34 @@ const std::pair<float, float> MALYGOS_STACK_POSITION = {755.0f, 1301.0f};
|
||||
class MalygosPositionAction : public MovementAction
|
||||
{
|
||||
public:
|
||||
MalygosPositionAction(PlayerbotAI* botAI, std::string const name = "malygos position") : MovementAction(botAI, name)
|
||||
{
|
||||
}
|
||||
|
||||
MalygosPositionAction(PlayerbotAI* botAI, std::string const name = "malygos position")
|
||||
: MovementAction(botAI, name) {}
|
||||
bool Execute(Event event) override;
|
||||
};
|
||||
|
||||
class MalygosTargetAction : public AttackAction
|
||||
{
|
||||
public:
|
||||
MalygosTargetAction(PlayerbotAI* botAI, std::string const name = "malygos target") : AttackAction(botAI, name) {}
|
||||
|
||||
MalygosTargetAction(PlayerbotAI* botAI, std::string const name = "malygos target")
|
||||
: AttackAction(botAI, name) {}
|
||||
bool Execute(Event event) override;
|
||||
};
|
||||
|
||||
//class PullPowerSparkAction : public CastSpellAction
|
||||
//{
|
||||
//public:
|
||||
// PullPowerSparkAction(PlayerbotAI* botAI, std::string const name = "pull power spark") : CastSpellAction(botAI, name)
|
||||
// {
|
||||
// }
|
||||
|
||||
// bool Execute(Event event) override;
|
||||
// bool isUseful() override;
|
||||
// bool isPossible() override;
|
||||
//};
|
||||
class PullPowerSparkAction : public CastSpellAction
|
||||
{
|
||||
public:
|
||||
PullPowerSparkAction(PlayerbotAI* botAI, std::string const name = "pull power spark")
|
||||
: CastSpellAction(botAI, name) {}
|
||||
bool Execute(Event event) override;
|
||||
bool isPossible() override;
|
||||
bool isUseful() override;
|
||||
};
|
||||
|
||||
class KillPowerSparkAction : public AttackAction
|
||||
{
|
||||
public:
|
||||
KillPowerSparkAction(PlayerbotAI* botAI, std::string const name = "kill power spark") : AttackAction(botAI, name) {}
|
||||
|
||||
KillPowerSparkAction(PlayerbotAI* botAI, std::string const name = "kill power spark")
|
||||
: AttackAction(botAI, name) {}
|
||||
bool Execute(Event event) override;
|
||||
};
|
||||
|
||||
@ -52,7 +48,6 @@ class EoEFlyDrakeAction : public MovementAction
|
||||
{
|
||||
public:
|
||||
EoEFlyDrakeAction(PlayerbotAI* ai) : MovementAction(ai, "eoe fly drake") {}
|
||||
|
||||
bool Execute(Event event) override;
|
||||
bool isPossible() override;
|
||||
};
|
||||
@ -61,7 +56,6 @@ class EoEDrakeAttackAction : public Action
|
||||
{
|
||||
public:
|
||||
EoEDrakeAttackAction(PlayerbotAI* botAI) : Action(botAI, "eoe drake attack") {}
|
||||
|
||||
bool Execute(Event event) override;
|
||||
bool isPossible() override;
|
||||
|
||||
|
||||
@ -164,21 +164,21 @@ namespace GruulsLairHelpers
|
||||
{
|
||||
float angle = 2 * M_PI * i / NUM_POSITIONS;
|
||||
Position candidatePos;
|
||||
candidatePos.Relocate(bot->GetPositionX() + SEARCH_RADIUS * cos(angle),
|
||||
bot->GetPositionY() + SEARCH_RADIUS * sin(angle),
|
||||
bot->GetPositionZ());
|
||||
candidatePos.m_positionX = bot->GetPositionX() + SEARCH_RADIUS * cos(angle);
|
||||
candidatePos.m_positionY = bot->GetPositionY() + SEARCH_RADIUS * sin(angle);
|
||||
candidatePos.m_positionZ = bot->GetPositionZ();
|
||||
|
||||
float destX = candidatePos.GetPositionX();
|
||||
float destY = candidatePos.GetPositionY();
|
||||
float destZ = candidatePos.GetPositionZ();
|
||||
float destX = candidatePos.m_positionX, destY = candidatePos.m_positionY, destZ = candidatePos.m_positionZ;
|
||||
if (!bot->GetMap()->CheckCollisionAndGetValidCoords(bot, bot->GetPositionX(), bot->GetPositionY(),
|
||||
bot->GetPositionZ(), destX, destY, destZ, true))
|
||||
continue;
|
||||
|
||||
if (destX != candidatePos.GetPositionX() || destY != candidatePos.GetPositionY())
|
||||
if (destX != candidatePos.m_positionX || destY != candidatePos.m_positionY)
|
||||
continue;
|
||||
|
||||
candidatePos.Relocate(destX, destY, destZ);
|
||||
candidatePos.m_positionX = destX;
|
||||
candidatePos.m_positionY = destY;
|
||||
candidatePos.m_positionZ = destZ;
|
||||
|
||||
if (IsPositionSafe(botAI, bot, candidatePos))
|
||||
{
|
||||
|
||||
@ -1551,10 +1551,8 @@ Position IccFestergutSporeAction::CalculateSpreadPosition()
|
||||
float angle = (bot->GetGUID().GetCounter() % 16) * (M_PI / 8);
|
||||
|
||||
Position spreadRangedPos = ICC_FESTERGUT_RANGED_SPORE;
|
||||
spreadRangedPos.Relocate(spreadRangedPos.GetPositionX() + cos(angle) * SPREAD_RADIUS,
|
||||
spreadRangedPos.GetPositionY() + sin(angle) * SPREAD_RADIUS,
|
||||
spreadRangedPos.GetPositionZ(),
|
||||
spreadRangedPos.GetOrientation());
|
||||
spreadRangedPos.m_positionX += cos(angle) * SPREAD_RADIUS;
|
||||
spreadRangedPos.m_positionY += sin(angle) * SPREAD_RADIUS;
|
||||
|
||||
return spreadRangedPos;
|
||||
}
|
||||
|
||||
@ -640,7 +640,7 @@ bool MagtheridonManageTimersAndAssignmentsAction::Execute(Event event)
|
||||
magtheridon->FindCurrentSpellBySpellId(SPELL_BLAST_NOVA);
|
||||
bool lastBlastNova = lastBlastNovaState[instanceId];
|
||||
|
||||
if (lastBlastNova && !blastNovaActive)
|
||||
if (lastBlastNova && !blastNovaActive && IsMechanicTrackerBot(botAI, bot, MAGTHERIDON_MAP_ID, nullptr))
|
||||
blastNovaTimer[instanceId] = now;
|
||||
|
||||
lastBlastNovaState[instanceId] = blastNovaActive;
|
||||
|
||||
@ -64,18 +64,17 @@ bool StartRpgDoQuestAction::Execute(Event event)
|
||||
bool NewRpgStatusUpdateAction::Execute(Event event)
|
||||
{
|
||||
NewRpgInfo& info = botAI->rpgInfo;
|
||||
NewRpgStatus status = info.GetStatus();
|
||||
switch (status)
|
||||
switch (info.status)
|
||||
{
|
||||
case RPG_IDLE:
|
||||
{
|
||||
return RandomChangeStatus({RPG_GO_CAMP, RPG_GO_GRIND, RPG_WANDER_RANDOM, RPG_WANDER_NPC, RPG_DO_QUEST,
|
||||
RPG_TRAVEL_FLIGHT, RPG_REST});
|
||||
|
||||
}
|
||||
case RPG_GO_GRIND:
|
||||
{
|
||||
auto& data = std::get<NewRpgInfo::GoGrind>(info.data);
|
||||
WorldPosition& originalPos = data.pos;
|
||||
assert(data.pos != WorldPosition());
|
||||
WorldPosition& originalPos = info.go_grind.pos;
|
||||
assert(info.go_grind.pos != WorldPosition());
|
||||
// GO_GRIND -> WANDER_RANDOM
|
||||
if (bot->GetExactDist(originalPos) < 10.0f)
|
||||
{
|
||||
@ -86,9 +85,8 @@ bool NewRpgStatusUpdateAction::Execute(Event event)
|
||||
}
|
||||
case RPG_GO_CAMP:
|
||||
{
|
||||
auto& data = std::get<NewRpgInfo::GoCamp>(info.data);
|
||||
WorldPosition& originalPos = data.pos;
|
||||
assert(data.pos != WorldPosition());
|
||||
WorldPosition& originalPos = info.go_camp.pos;
|
||||
assert(info.go_camp.pos != WorldPosition());
|
||||
// GO_CAMP -> WANDER_NPC
|
||||
if (bot->GetExactDist(originalPos) < 10.0f)
|
||||
{
|
||||
@ -128,8 +126,7 @@ bool NewRpgStatusUpdateAction::Execute(Event event)
|
||||
}
|
||||
case RPG_TRAVEL_FLIGHT:
|
||||
{
|
||||
auto& data = std::get<NewRpgInfo::TravelFlight>(info.data);
|
||||
if (data.inFlight && !bot->IsInFlight())
|
||||
if (info.flight.inFlight && !bot->IsInFlight())
|
||||
{
|
||||
// flight arrival
|
||||
info.ChangeToIdle();
|
||||
@ -157,10 +154,8 @@ bool NewRpgGoGrindAction::Execute(Event event)
|
||||
{
|
||||
if (SearchQuestGiverAndAcceptOrReward())
|
||||
return true;
|
||||
if (auto* data = std::get_if<NewRpgInfo::GoGrind>(&botAI->rpgInfo.data))
|
||||
return MoveFarTo(data->pos);
|
||||
|
||||
return false;
|
||||
return MoveFarTo(botAI->rpgInfo.go_grind.pos);
|
||||
}
|
||||
|
||||
bool NewRpgGoCampAction::Execute(Event event)
|
||||
@ -168,10 +163,7 @@ bool NewRpgGoCampAction::Execute(Event event)
|
||||
if (SearchQuestGiverAndAcceptOrReward())
|
||||
return true;
|
||||
|
||||
if (auto* data = std::get_if<NewRpgInfo::GoCamp>(&botAI->rpgInfo.data))
|
||||
return MoveFarTo(data->pos);
|
||||
|
||||
return false;
|
||||
return MoveFarTo(botAI->rpgInfo.go_camp.pos);
|
||||
}
|
||||
|
||||
bool NewRpgWanderRandomAction::Execute(Event event)
|
||||
@ -185,11 +177,7 @@ bool NewRpgWanderRandomAction::Execute(Event event)
|
||||
bool NewRpgWanderNpcAction::Execute(Event event)
|
||||
{
|
||||
NewRpgInfo& info = botAI->rpgInfo;
|
||||
auto* dataPtr = std::get_if<NewRpgInfo::WanderNpc>(&info.data);
|
||||
if (!dataPtr)
|
||||
return false;
|
||||
auto& data = *dataPtr;
|
||||
if (!data.npcOrGo)
|
||||
if (!info.wander_npc.npcOrGo)
|
||||
{
|
||||
// No npc can be found, switch to IDLE
|
||||
ObjectGuid npcOrGo = ChooseNpcOrGameObjectToInteract();
|
||||
@ -198,32 +186,33 @@ bool NewRpgWanderNpcAction::Execute(Event event)
|
||||
info.ChangeToIdle();
|
||||
return true;
|
||||
}
|
||||
data.npcOrGo = npcOrGo;
|
||||
data.lastReach = 0;
|
||||
info.wander_npc.npcOrGo = npcOrGo;
|
||||
info.wander_npc.lastReach = 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
WorldObject* object = ObjectAccessor::GetWorldObject(*bot, data.npcOrGo);
|
||||
WorldObject* object = ObjectAccessor::GetWorldObject(*bot, info.wander_npc.npcOrGo);
|
||||
if (object && IsWithinInteractionDist(object))
|
||||
{
|
||||
if (!data.lastReach)
|
||||
if (!info.wander_npc.lastReach)
|
||||
{
|
||||
data.lastReach = getMSTime();
|
||||
info.wander_npc.lastReach = getMSTime();
|
||||
if (bot->CanInteractWithQuestGiver(object))
|
||||
InteractWithNpcOrGameObjectForQuest(data.npcOrGo);
|
||||
InteractWithNpcOrGameObjectForQuest(info.wander_npc.npcOrGo);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (data.lastReach && GetMSTimeDiffToNow(data.lastReach) < npcStayTime)
|
||||
if (info.wander_npc.lastReach && GetMSTimeDiffToNow(info.wander_npc.lastReach) < npcStayTime)
|
||||
return false;
|
||||
|
||||
// has reached the npc for more than `npcStayTime`, select the next target
|
||||
data.npcOrGo = ObjectGuid();
|
||||
data.lastReach = 0;
|
||||
info.wander_npc.npcOrGo = ObjectGuid();
|
||||
info.wander_npc.lastReach = 0;
|
||||
}
|
||||
else
|
||||
return MoveWorldObjectTo(data.npcOrGo);
|
||||
|
||||
{
|
||||
return MoveWorldObjectTo(info.wander_npc.npcOrGo);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -233,33 +222,29 @@ bool NewRpgDoQuestAction::Execute(Event event)
|
||||
return true;
|
||||
|
||||
NewRpgInfo& info = botAI->rpgInfo;
|
||||
auto* dataPtr = std::get_if<NewRpgInfo::DoQuest>(&info.data);
|
||||
if (!dataPtr)
|
||||
return false;
|
||||
auto& data = *dataPtr;
|
||||
uint32 questId = data.questId;
|
||||
const Quest* quest = data.quest;
|
||||
uint32 questId = RPG_INFO(quest, questId);
|
||||
const Quest* quest = RPG_INFO(quest, quest);
|
||||
uint8 questStatus = bot->GetQuestStatus(questId);
|
||||
switch (questStatus)
|
||||
{
|
||||
case QUEST_STATUS_INCOMPLETE:
|
||||
return DoIncompleteQuest(data);
|
||||
return DoIncompleteQuest();
|
||||
case QUEST_STATUS_COMPLETE:
|
||||
return DoCompletedQuest(data);
|
||||
return DoCompletedQuest();
|
||||
default:
|
||||
break;
|
||||
}
|
||||
info.ChangeToIdle();
|
||||
botAI->rpgInfo.ChangeToIdle();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool NewRpgDoQuestAction::DoIncompleteQuest(NewRpgInfo::DoQuest& data)
|
||||
bool NewRpgDoQuestAction::DoIncompleteQuest()
|
||||
{
|
||||
uint32 questId = data.questId;
|
||||
if (data.pos != WorldPosition())
|
||||
uint32 questId = RPG_INFO(do_quest, questId);
|
||||
if (botAI->rpgInfo.do_quest.pos != WorldPosition())
|
||||
{
|
||||
/// @TODO: extract to a new function
|
||||
int32 currentObjective = data.objectiveIdx;
|
||||
int32 currentObjective = botAI->rpgInfo.do_quest.objectiveIdx;
|
||||
// check if the objective has completed
|
||||
Quest const* quest = sObjectMgr->GetQuestTemplate(questId);
|
||||
const QuestStatusData& q_status = bot->getQuestStatusMap().at(questId);
|
||||
@ -278,12 +263,12 @@ bool NewRpgDoQuestAction::DoIncompleteQuest(NewRpgInfo::DoQuest& data)
|
||||
// the current objective is completed, clear and find a new objective later
|
||||
if (completed)
|
||||
{
|
||||
data.lastReachPOI = 0;
|
||||
data.pos = WorldPosition();
|
||||
data.objectiveIdx = 0;
|
||||
botAI->rpgInfo.do_quest.lastReachPOI = 0;
|
||||
botAI->rpgInfo.do_quest.pos = WorldPosition();
|
||||
botAI->rpgInfo.do_quest.objectiveIdx = 0;
|
||||
}
|
||||
}
|
||||
if (data.pos == WorldPosition())
|
||||
if (botAI->rpgInfo.do_quest.pos == WorldPosition())
|
||||
{
|
||||
std::vector<POIInfo> poiInfo;
|
||||
if (!GetQuestPOIPosAndObjectiveIdx(questId, poiInfo))
|
||||
@ -306,28 +291,28 @@ bool NewRpgDoQuestAction::DoIncompleteQuest(NewRpgInfo::DoQuest& data)
|
||||
return false;
|
||||
|
||||
WorldPosition pos(bot->GetMapId(), dx, dy, dz);
|
||||
data.lastReachPOI = 0;
|
||||
data.pos = pos;
|
||||
data.objectiveIdx = objectiveIdx;
|
||||
botAI->rpgInfo.do_quest.lastReachPOI = 0;
|
||||
botAI->rpgInfo.do_quest.pos = pos;
|
||||
botAI->rpgInfo.do_quest.objectiveIdx = objectiveIdx;
|
||||
}
|
||||
|
||||
if (bot->GetDistance(data.pos) > 10.0f && !data.lastReachPOI)
|
||||
if (bot->GetDistance(botAI->rpgInfo.do_quest.pos) > 10.0f && !botAI->rpgInfo.do_quest.lastReachPOI)
|
||||
{
|
||||
return MoveFarTo(data.pos);
|
||||
return MoveFarTo(botAI->rpgInfo.do_quest.pos);
|
||||
}
|
||||
// Now we are near the quest objective
|
||||
// kill mobs and looting quest should be done automatically by grind strategy
|
||||
|
||||
if (!data.lastReachPOI)
|
||||
if (!botAI->rpgInfo.do_quest.lastReachPOI)
|
||||
{
|
||||
data.lastReachPOI = getMSTime();
|
||||
botAI->rpgInfo.do_quest.lastReachPOI = getMSTime();
|
||||
return true;
|
||||
}
|
||||
// stayed at this POI for more than 5 minutes
|
||||
if (GetMSTimeDiffToNow(data.lastReachPOI) >= poiStayTime)
|
||||
if (GetMSTimeDiffToNow(botAI->rpgInfo.do_quest.lastReachPOI) >= poiStayTime)
|
||||
{
|
||||
bool hasProgression = false;
|
||||
int32 currentObjective = data.objectiveIdx;
|
||||
int32 currentObjective = botAI->rpgInfo.do_quest.objectiveIdx;
|
||||
// check if the objective has progression
|
||||
Quest const* quest = sObjectMgr->GetQuestTemplate(questId);
|
||||
const QuestStatusData& q_status = bot->getQuestStatusMap().at(questId);
|
||||
@ -354,21 +339,21 @@ bool NewRpgDoQuestAction::DoIncompleteQuest(NewRpgInfo::DoQuest& data)
|
||||
return true;
|
||||
}
|
||||
// clear and select another poi later
|
||||
data.lastReachPOI = 0;
|
||||
data.pos = WorldPosition();
|
||||
data.objectiveIdx = 0;
|
||||
botAI->rpgInfo.do_quest.lastReachPOI = 0;
|
||||
botAI->rpgInfo.do_quest.pos = WorldPosition();
|
||||
botAI->rpgInfo.do_quest.objectiveIdx = 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
return MoveRandomNear(20.0f);
|
||||
}
|
||||
|
||||
bool NewRpgDoQuestAction::DoCompletedQuest(NewRpgInfo::DoQuest& data)
|
||||
bool NewRpgDoQuestAction::DoCompletedQuest()
|
||||
{
|
||||
uint32 questId = data.questId;
|
||||
const Quest* quest = data.quest;
|
||||
uint32 questId = RPG_INFO(quest, questId);
|
||||
const Quest* quest = RPG_INFO(quest, quest);
|
||||
|
||||
if (data.objectiveIdx != -1)
|
||||
if (RPG_INFO(quest, objectiveIdx) != -1)
|
||||
{
|
||||
// if quest is completed, back to poi with -1 idx to reward
|
||||
BroadcastHelper::BroadcastQuestUpdateComplete(botAI, bot, quest);
|
||||
@ -391,26 +376,26 @@ bool NewRpgDoQuestAction::DoCompletedQuest(NewRpgInfo::DoQuest& data)
|
||||
return false;
|
||||
|
||||
WorldPosition pos(bot->GetMapId(), dx, dy, dz);
|
||||
data.lastReachPOI = 0;
|
||||
data.pos = pos;
|
||||
data.objectiveIdx = -1;
|
||||
botAI->rpgInfo.do_quest.lastReachPOI = 0;
|
||||
botAI->rpgInfo.do_quest.pos = pos;
|
||||
botAI->rpgInfo.do_quest.objectiveIdx = -1;
|
||||
}
|
||||
|
||||
if (data.pos == WorldPosition())
|
||||
if (botAI->rpgInfo.do_quest.pos == WorldPosition())
|
||||
return false;
|
||||
|
||||
if (bot->GetDistance(data.pos) > 10.0f && !data.lastReachPOI)
|
||||
return MoveFarTo(data.pos);
|
||||
if (bot->GetDistance(botAI->rpgInfo.do_quest.pos) > 10.0f && !botAI->rpgInfo.do_quest.lastReachPOI)
|
||||
return MoveFarTo(botAI->rpgInfo.do_quest.pos);
|
||||
|
||||
// Now we are near the qoi of reward
|
||||
// the quest should be rewarded by SearchQuestGiverAndAcceptOrReward
|
||||
if (!data.lastReachPOI)
|
||||
if (!botAI->rpgInfo.do_quest.lastReachPOI)
|
||||
{
|
||||
data.lastReachPOI = getMSTime();
|
||||
botAI->rpgInfo.do_quest.lastReachPOI = getMSTime();
|
||||
return true;
|
||||
}
|
||||
// stayed at this POI for more than 5 minutes
|
||||
if (GetMSTimeDiffToNow(data.lastReachPOI) >= poiStayTime)
|
||||
if (GetMSTimeDiffToNow(botAI->rpgInfo.do_quest.lastReachPOI) >= poiStayTime)
|
||||
{
|
||||
// e.g. Can not reward quest to gameobjects
|
||||
/// @TODO: It may be better to make lowPriorityQuest a global set shared by all bots (or saved in db)
|
||||
@ -425,33 +410,29 @@ bool NewRpgDoQuestAction::DoCompletedQuest(NewRpgInfo::DoQuest& data)
|
||||
|
||||
bool NewRpgTravelFlightAction::Execute(Event event)
|
||||
{
|
||||
NewRpgInfo& info = botAI->rpgInfo;
|
||||
auto* dataPtr = std::get_if<NewRpgInfo::TravelFlight>(&info.data);
|
||||
if (!dataPtr)
|
||||
return false;
|
||||
|
||||
auto& data = *dataPtr;
|
||||
if (bot->IsInFlight())
|
||||
{
|
||||
data.inFlight = true;
|
||||
botAI->rpgInfo.flight.inFlight = true;
|
||||
return false;
|
||||
}
|
||||
Creature* flightMaster = ObjectAccessor::GetCreature(*bot, data.fromFlightMaster);
|
||||
Creature* flightMaster = ObjectAccessor::GetCreature(*bot, botAI->rpgInfo.flight.fromFlightMaster);
|
||||
if (!flightMaster || !flightMaster->IsAlive())
|
||||
{
|
||||
botAI->rpgInfo.ChangeToIdle();
|
||||
return true;
|
||||
}
|
||||
const TaxiNodesEntry* entry = sTaxiNodesStore.LookupEntry(data.toNode);
|
||||
const TaxiNodesEntry* entry = sTaxiNodesStore.LookupEntry(botAI->rpgInfo.flight.toNode);
|
||||
if (bot->GetDistance(flightMaster) > INTERACTION_DISTANCE)
|
||||
{
|
||||
return MoveFarTo(flightMaster);
|
||||
|
||||
std::vector<uint32> nodes = {data.fromNode, data.toNode};
|
||||
}
|
||||
std::vector<uint32> nodes = {botAI->rpgInfo.flight.fromNode, botAI->rpgInfo.flight.toNode};
|
||||
|
||||
botAI->RemoveShapeshift();
|
||||
if (bot->IsMounted())
|
||||
{
|
||||
bot->Dismount();
|
||||
|
||||
}
|
||||
if (!bot->ActivateTaxiPathTo(nodes, flightMaster, 0))
|
||||
{
|
||||
LOG_DEBUG("playerbots", "[New RPG] {} active taxi path {} (from {} to {}) failed", bot->GetName(),
|
||||
|
||||
@ -90,8 +90,8 @@ public:
|
||||
bool Execute(Event event) override;
|
||||
|
||||
protected:
|
||||
bool DoIncompleteQuest(NewRpgInfo::DoQuest& data);
|
||||
bool DoCompletedQuest(NewRpgInfo::DoQuest& data);
|
||||
bool DoIncompleteQuest();
|
||||
bool DoCompletedQuest();
|
||||
|
||||
const uint32 poiStayTime = 5 * 60 * 1000;
|
||||
};
|
||||
|
||||
@ -66,7 +66,7 @@ bool NewRpgBaseAction::MoveFarTo(WorldPosition dest)
|
||||
"playerbots",
|
||||
"[New RPG] Teleport {} from ({},{},{},{}) to ({},{},{},{}) as it stuck when moving far - Zone: {} ({})",
|
||||
bot->GetName(), bot->GetPositionX(), bot->GetPositionY(), bot->GetPositionZ(), bot->GetMapId(),
|
||||
dest.GetPositionX(), dest.GetPositionY(), dest.GetPositionZ(), dest.GetMapId(), bot->GetZoneId(),
|
||||
dest.GetPositionX(), dest.GetPositionY(), dest.GetPositionZ(), dest.getMapId(), bot->GetZoneId(),
|
||||
zone_name);
|
||||
bot->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_TELEPORTED | AURA_INTERRUPT_FLAG_CHANGE_MAP);
|
||||
return bot->TeleportTo(dest);
|
||||
@ -75,7 +75,7 @@ bool NewRpgBaseAction::MoveFarTo(WorldPosition dest)
|
||||
float dis = bot->GetExactDist(dest);
|
||||
if (dis < pathFinderDis)
|
||||
{
|
||||
return MoveTo(dest.GetMapId(), dest.GetPositionX(), dest.GetPositionY(), dest.GetPositionZ(), false, false,
|
||||
return MoveTo(dest.getMapId(), dest.GetPositionX(), dest.GetPositionY(), dest.GetPositionZ(), false, false,
|
||||
false, true);
|
||||
}
|
||||
|
||||
|
||||
@ -6,65 +6,71 @@
|
||||
|
||||
void NewRpgInfo::ChangeToGoGrind(WorldPosition pos)
|
||||
{
|
||||
startT = getMSTime();
|
||||
data = GoGrind{pos};
|
||||
Reset();
|
||||
status = RPG_GO_GRIND;
|
||||
go_grind = GoGrind();
|
||||
go_grind.pos = pos;
|
||||
}
|
||||
|
||||
void NewRpgInfo::ChangeToGoCamp(WorldPosition pos)
|
||||
{
|
||||
startT = getMSTime();
|
||||
data = GoCamp{pos};
|
||||
Reset();
|
||||
status = RPG_GO_CAMP;
|
||||
go_camp = GoCamp();
|
||||
go_camp.pos = pos;
|
||||
}
|
||||
|
||||
void NewRpgInfo::ChangeToWanderNpc()
|
||||
{
|
||||
startT = getMSTime();
|
||||
data = WanderNpc{};
|
||||
Reset();
|
||||
status = RPG_WANDER_NPC;
|
||||
wander_npc = WanderNpc();
|
||||
}
|
||||
|
||||
void NewRpgInfo::ChangeToWanderRandom()
|
||||
{
|
||||
startT = getMSTime();
|
||||
data = WanderRandom{};
|
||||
Reset();
|
||||
status = RPG_WANDER_RANDOM;
|
||||
WANDER_RANDOM = WanderRandom();
|
||||
}
|
||||
|
||||
void NewRpgInfo::ChangeToDoQuest(uint32 questId, const Quest* quest)
|
||||
{
|
||||
startT = getMSTime();
|
||||
DoQuest do_quest;
|
||||
Reset();
|
||||
status = RPG_DO_QUEST;
|
||||
do_quest = DoQuest();
|
||||
do_quest.questId = questId;
|
||||
do_quest.quest = quest;
|
||||
data = do_quest;
|
||||
}
|
||||
|
||||
void NewRpgInfo::ChangeToTravelFlight(ObjectGuid fromFlightMaster, uint32 fromNode, uint32 toNode)
|
||||
{
|
||||
startT = getMSTime();
|
||||
TravelFlight flight;
|
||||
Reset();
|
||||
status = RPG_TRAVEL_FLIGHT;
|
||||
flight = TravelFlight();
|
||||
flight.fromFlightMaster = fromFlightMaster;
|
||||
flight.fromNode = fromNode;
|
||||
flight.toNode = toNode;
|
||||
flight.inFlight = false;
|
||||
data = flight;
|
||||
}
|
||||
|
||||
void NewRpgInfo::ChangeToRest()
|
||||
{
|
||||
startT = getMSTime();
|
||||
data = Rest{};
|
||||
Reset();
|
||||
status = RPG_REST;
|
||||
rest = Rest();
|
||||
}
|
||||
|
||||
void NewRpgInfo::ChangeToIdle()
|
||||
{
|
||||
startT = getMSTime();
|
||||
data = Idle{};
|
||||
Reset();
|
||||
status = RPG_IDLE;
|
||||
}
|
||||
|
||||
bool NewRpgInfo::CanChangeTo(NewRpgStatus status) { return true; }
|
||||
|
||||
void NewRpgInfo::Reset()
|
||||
{
|
||||
data = Idle{};
|
||||
*this = NewRpgInfo();
|
||||
startT = getMSTime();
|
||||
}
|
||||
|
||||
@ -76,83 +82,58 @@ void NewRpgInfo::SetMoveFarTo(WorldPosition pos)
|
||||
moveFarPos = pos;
|
||||
}
|
||||
|
||||
NewRpgStatus NewRpgInfo::GetStatus()
|
||||
{
|
||||
return std::visit([](auto&& arg) -> NewRpgStatus {
|
||||
using T = std::decay_t<decltype(arg)>;
|
||||
if constexpr (std::is_same_v<T, Idle>) return RPG_IDLE;
|
||||
if constexpr (std::is_same_v<T, GoGrind>) return RPG_GO_GRIND;
|
||||
if constexpr (std::is_same_v<T, GoCamp>) return RPG_GO_CAMP;
|
||||
if constexpr (std::is_same_v<T, WanderNpc>) return RPG_WANDER_NPC;
|
||||
if constexpr (std::is_same_v<T, WanderRandom>) return RPG_WANDER_RANDOM;
|
||||
if constexpr (std::is_same_v<T, Rest>) return RPG_REST;
|
||||
if constexpr (std::is_same_v<T, DoQuest>) return RPG_DO_QUEST;
|
||||
if constexpr (std::is_same_v<T, TravelFlight>) return RPG_TRAVEL_FLIGHT;
|
||||
return RPG_IDLE;
|
||||
}, data);
|
||||
}
|
||||
|
||||
std::string NewRpgInfo::ToString()
|
||||
{
|
||||
std::stringstream out;
|
||||
out << "Status: ";
|
||||
std::visit([&out, this](auto&& arg)
|
||||
switch (status)
|
||||
{
|
||||
using T = std::decay_t<decltype(arg)>;
|
||||
if constexpr (std::is_same_v<T, GoGrind>)
|
||||
{
|
||||
case RPG_GO_GRIND:
|
||||
out << "GO_GRIND";
|
||||
out << "\nGrindPos: " << arg.pos.GetMapId() << " " << arg.pos.GetPositionX() << " "
|
||||
<< arg.pos.GetPositionY() << " " << arg.pos.GetPositionZ();
|
||||
out << "\nGrindPos: " << go_grind.pos.GetMapId() << " " << go_grind.pos.GetPositionX() << " "
|
||||
<< go_grind.pos.GetPositionY() << " " << go_grind.pos.GetPositionZ();
|
||||
out << "\nlastGoGrind: " << startT;
|
||||
}
|
||||
else if constexpr (std::is_same_v<T, GoCamp>)
|
||||
{
|
||||
break;
|
||||
case RPG_GO_CAMP:
|
||||
out << "GO_CAMP";
|
||||
out << "\nCampPos: " << arg.pos.GetMapId() << " " << arg.pos.GetPositionX() << " "
|
||||
<< arg.pos.GetPositionY() << " " << arg.pos.GetPositionZ();
|
||||
out << "\nCampPos: " << go_camp.pos.GetMapId() << " " << go_camp.pos.GetPositionX() << " "
|
||||
<< go_camp.pos.GetPositionY() << " " << go_camp.pos.GetPositionZ();
|
||||
out << "\nlastGoCamp: " << startT;
|
||||
}
|
||||
else if constexpr (std::is_same_v<T, WanderNpc>)
|
||||
{
|
||||
break;
|
||||
case RPG_WANDER_NPC:
|
||||
out << "WANDER_NPC";
|
||||
out << "\nnpcOrGoEntry: " << arg.npcOrGo.GetCounter();
|
||||
out << "\nnpcOrGoEntry: " << wander_npc.npcOrGo.GetCounter();
|
||||
out << "\nlastWanderNpc: " << startT;
|
||||
out << "\nlastReachNpcOrGo: " << arg.lastReach;
|
||||
}
|
||||
else if constexpr (std::is_same_v<T, WanderRandom>)
|
||||
{
|
||||
out << "\nlastReachNpcOrGo: " << wander_npc.lastReach;
|
||||
break;
|
||||
case RPG_WANDER_RANDOM:
|
||||
out << "WANDER_RANDOM";
|
||||
out << "\nlastWanderRandom: " << startT;
|
||||
}
|
||||
else if constexpr (std::is_same_v<T, Idle>)
|
||||
{
|
||||
break;
|
||||
case RPG_IDLE:
|
||||
out << "IDLE";
|
||||
}
|
||||
else if constexpr (std::is_same_v<T, Rest>)
|
||||
{
|
||||
break;
|
||||
case RPG_REST:
|
||||
out << "REST";
|
||||
out << "\nlastRest: " << startT;
|
||||
}
|
||||
else if constexpr (std::is_same_v<T, DoQuest>)
|
||||
{
|
||||
break;
|
||||
case RPG_DO_QUEST:
|
||||
out << "DO_QUEST";
|
||||
out << "\nquestId: " << arg.questId;
|
||||
out << "\nobjectiveIdx: " << arg.objectiveIdx;
|
||||
out << "\npoiPos: " << arg.pos.GetMapId() << " " << arg.pos.GetPositionX() << " "
|
||||
<< arg.pos.GetPositionY() << " " << arg.pos.GetPositionZ();
|
||||
out << "\nlastReachPOI: " << (arg.lastReachPOI ? GetMSTimeDiffToNow(arg.lastReachPOI) : 0);
|
||||
}
|
||||
else if constexpr (std::is_same_v<T, TravelFlight>)
|
||||
{
|
||||
out << "\nquestId: " << do_quest.questId;
|
||||
out << "\nobjectiveIdx: " << do_quest.objectiveIdx;
|
||||
out << "\npoiPos: " << do_quest.pos.GetMapId() << " " << do_quest.pos.GetPositionX() << " "
|
||||
<< do_quest.pos.GetPositionY() << " " << do_quest.pos.GetPositionZ();
|
||||
out << "\nlastReachPOI: " << do_quest.lastReachPOI ? GetMSTimeDiffToNow(do_quest.lastReachPOI) : 0;
|
||||
break;
|
||||
case RPG_TRAVEL_FLIGHT:
|
||||
out << "TRAVEL_FLIGHT";
|
||||
out << "\nfromFlightMaster: " << arg.fromFlightMaster.GetEntry();
|
||||
out << "\nfromNode: " << arg.fromNode;
|
||||
out << "\ntoNode: " << arg.toNode;
|
||||
out << "\ninFlight: " << arg.inFlight;
|
||||
}
|
||||
else
|
||||
out << "\nfromFlightMaster: " << flight.fromFlightMaster.GetEntry();
|
||||
out << "\nfromNode: " << flight.fromNode;
|
||||
out << "\ntoNode: " << flight.toNode;
|
||||
out << "\ninFlight: " << flight.inFlight;
|
||||
break;
|
||||
default:
|
||||
out << "UNKNOWN";
|
||||
}, data);
|
||||
}
|
||||
return out.str();
|
||||
}
|
||||
|
||||
@ -13,8 +13,7 @@ using NewRpgStatusTransitionProb = std::vector<std::vector<int>>;
|
||||
|
||||
struct NewRpgInfo
|
||||
{
|
||||
NewRpgInfo() : data(Idle{}) {}
|
||||
~NewRpgInfo() = default;
|
||||
NewRpgInfo() {}
|
||||
|
||||
// RPG_GO_GRIND
|
||||
struct GoGrind
|
||||
@ -62,6 +61,7 @@ struct NewRpgInfo
|
||||
struct Idle
|
||||
{
|
||||
};
|
||||
NewRpgStatus status{RPG_IDLE};
|
||||
|
||||
uint32 startT{0}; // start timestamp of the current status
|
||||
|
||||
@ -72,19 +72,18 @@ struct NewRpgInfo
|
||||
WorldPosition moveFarPos;
|
||||
// END MOVE_FAR
|
||||
|
||||
using RpgData = std::variant<
|
||||
Idle,
|
||||
GoGrind,
|
||||
GoCamp,
|
||||
WanderNpc,
|
||||
WanderRandom,
|
||||
DoQuest,
|
||||
Rest,
|
||||
TravelFlight
|
||||
>;
|
||||
RpgData data;
|
||||
union
|
||||
{
|
||||
GoGrind go_grind;
|
||||
GoCamp go_camp;
|
||||
WanderNpc wander_npc;
|
||||
WanderRandom WANDER_RANDOM;
|
||||
DoQuest do_quest;
|
||||
Rest rest;
|
||||
DoQuest quest;
|
||||
TravelFlight flight;
|
||||
};
|
||||
|
||||
NewRpgStatus GetStatus();
|
||||
bool HasStatusPersisted(uint32 maxDuration) { return GetMSTimeDiffToNow(startT) > maxDuration; }
|
||||
void ChangeToGoGrind(WorldPosition pos);
|
||||
void ChangeToGoCamp(WorldPosition pos);
|
||||
@ -128,4 +127,7 @@ struct NewRpgStatistic
|
||||
}
|
||||
};
|
||||
|
||||
// not sure is it necessary but keep it for now
|
||||
#define RPG_INFO(x, y) botAI->rpgInfo.x.y
|
||||
|
||||
#endif
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
#include "NewRpgTriggers.h"
|
||||
#include "PlayerbotAI.h"
|
||||
|
||||
bool NewRpgStatusTrigger::IsActive() { return status == botAI->rpgInfo.GetStatus(); }
|
||||
bool NewRpgStatusTrigger::IsActive() { return status == botAI->rpgInfo.status; }
|
||||
|
||||
@ -60,27 +60,8 @@ public:
|
||||
virtual ~Action(void) {}
|
||||
|
||||
virtual bool Execute([[maybe_unused]] Event event) { return true; }
|
||||
|
||||
/**
|
||||
* @brief First validation check - determines if this action is contextually useful
|
||||
*
|
||||
* Performs lightweight checks to evaluate whether the action makes sense
|
||||
* in the current situation. Called before isPossible() during action selection.
|
||||
*
|
||||
* @return true if the action is useful, false otherwise
|
||||
*/
|
||||
virtual bool isUseful() { return true; }
|
||||
|
||||
/**
|
||||
* @brief Second validation check - determines if this action can be executed
|
||||
*
|
||||
* Performs hard pre-execution validation against the event and game state.
|
||||
* Called after isUseful() passes, before Execute().
|
||||
*
|
||||
* @return true if the action is possible, false otherwise
|
||||
*/
|
||||
virtual bool isPossible() { return true; }
|
||||
|
||||
virtual bool isUseful() { return true; }
|
||||
virtual std::vector<NextAction> getPrerequisites() { return {}; }
|
||||
virtual std::vector<NextAction> getAlternatives() { return {}; }
|
||||
virtual std::vector<NextAction> getContinuers() { return {}; }
|
||||
|
||||
@ -323,18 +323,18 @@ ActionResult Engine::ExecuteAction(std::string const name, Event event, std::str
|
||||
q->Qualify(qualifier);
|
||||
}
|
||||
|
||||
if (!action->isUseful())
|
||||
{
|
||||
delete actionNode;
|
||||
return ACTION_RESULT_USELESS;
|
||||
}
|
||||
|
||||
if (!action->isPossible())
|
||||
{
|
||||
delete actionNode;
|
||||
return ACTION_RESULT_IMPOSSIBLE;
|
||||
}
|
||||
|
||||
if (!action->isUseful())
|
||||
{
|
||||
delete actionNode;
|
||||
return ACTION_RESULT_USELESS;
|
||||
}
|
||||
|
||||
action->MakeVerbose();
|
||||
|
||||
result = ListenAndExecute(action, event);
|
||||
|
||||
@ -277,7 +277,7 @@ std::string const RandomPlayerbotFactory::CreateRandomBotName(NameRaceAndGender
|
||||
botName.clear();
|
||||
continue;
|
||||
}
|
||||
return botName;
|
||||
return std::move(botName);
|
||||
}
|
||||
|
||||
// TRUE RANDOM NAME GENERATION
|
||||
@ -302,11 +302,11 @@ std::string const RandomPlayerbotFactory::CreateRandomBotName(NameRaceAndGender
|
||||
botName.clear();
|
||||
continue;
|
||||
}
|
||||
return botName;
|
||||
return std::move(botName);
|
||||
}
|
||||
LOG_ERROR("playerbots", "Random name generation failed.");
|
||||
botName.clear();
|
||||
return botName;
|
||||
return std::move(botName);
|
||||
}
|
||||
|
||||
// Calculates the total number of required accounts, either using the specified randomBotAccountCount
|
||||
@ -763,7 +763,7 @@ std::string const RandomPlayerbotFactory::CreateRandomGuildName()
|
||||
if (!result)
|
||||
{
|
||||
LOG_ERROR("playerbots", "No more names left for random guilds");
|
||||
return guildName;
|
||||
return std::move(guildName);
|
||||
}
|
||||
|
||||
Field* fields = result->Fetch();
|
||||
@ -777,13 +777,13 @@ std::string const RandomPlayerbotFactory::CreateRandomGuildName()
|
||||
if (!result)
|
||||
{
|
||||
LOG_ERROR("playerbots", "No more names left for random guilds");
|
||||
return guildName;
|
||||
return std::move(guildName);
|
||||
}
|
||||
|
||||
fields = result->Fetch();
|
||||
guildName = fields[0].Get<std::string>();
|
||||
|
||||
return guildName;
|
||||
return std::move(guildName);
|
||||
}
|
||||
|
||||
void RandomPlayerbotFactory::CreateRandomArenaTeams(ArenaType type, uint32 count)
|
||||
@ -905,7 +905,7 @@ std::string const RandomPlayerbotFactory::CreateRandomArenaTeamName()
|
||||
if (!result)
|
||||
{
|
||||
LOG_ERROR("playerbots", "No more names left for random arena teams");
|
||||
return arenaTeamName;
|
||||
return std::move(arenaTeamName);
|
||||
}
|
||||
|
||||
Field* fields = result->Fetch();
|
||||
@ -920,11 +920,11 @@ std::string const RandomPlayerbotFactory::CreateRandomArenaTeamName()
|
||||
if (!result)
|
||||
{
|
||||
LOG_ERROR("playerbots", "No more names left for random arena teams");
|
||||
return arenaTeamName;
|
||||
return std::move(arenaTeamName);
|
||||
}
|
||||
|
||||
fields = result->Fetch();
|
||||
arenaTeamName = fields[0].Get<std::string>();
|
||||
|
||||
return arenaTeamName;
|
||||
return std::move(arenaTeamName);
|
||||
}
|
||||
|
||||
@ -5192,9 +5192,8 @@ std::string const PlayerbotAI::HandleRemoteCommand(std::string const command)
|
||||
{
|
||||
LastMovement& data = *GetAiObjectContext()->GetValue<LastMovement&>("last movement");
|
||||
std::ostringstream out;
|
||||
out << data.lastMoveShort.GetPositionX() << " " << data.lastMoveShort.GetPositionY() << " "
|
||||
<< data.lastMoveShort.GetPositionZ() << " " << data.lastMoveShort.GetMapId() << " "
|
||||
<< data.lastMoveShort.GetOrientation();
|
||||
out << data.lastMoveShort.getX() << " " << data.lastMoveShort.getY() << " " << data.lastMoveShort.getZ() << " "
|
||||
<< data.lastMoveShort.getMapId() << " " << data.lastMoveShort.getO();
|
||||
return out.str();
|
||||
}
|
||||
else if (command == "target")
|
||||
|
||||
@ -1667,7 +1667,7 @@ void RandomPlayerbotMgr::RandomTeleport(Player* bot, std::vector<WorldLocation>&
|
||||
{
|
||||
std::vector<uint32>::iterator i =
|
||||
find(sPlayerbotAIConfig.randomBotMaps.begin(),
|
||||
sPlayerbotAIConfig.randomBotMaps.end(), l.GetMapId());
|
||||
sPlayerbotAIConfig.randomBotMaps.end(), l.getMapId());
|
||||
return i == sPlayerbotAIConfig.randomBotMaps.end();
|
||||
}),
|
||||
tlocs.end());
|
||||
@ -2680,7 +2680,7 @@ std::vector<uint32> RandomPlayerbotMgr::GetBgBots(uint32 bracket)
|
||||
} while (result->NextRow());
|
||||
}
|
||||
|
||||
return BgBots;
|
||||
return std::move(BgBots);
|
||||
}
|
||||
|
||||
CachedEvent* RandomPlayerbotMgr::FindEvent(uint32 bot, std::string const& event)
|
||||
@ -3073,7 +3073,7 @@ void RandomPlayerbotMgr::OnPlayerLogin(Player* player)
|
||||
FactionTemplateEntry const* factionEntry = sFactionTemplateStore.LookupEntry(cInfo->faction);
|
||||
ReputationRank reaction = Unit::GetFactionReactionTo(player->GetFactionTemplateEntry(), factionEntry);
|
||||
|
||||
if (reaction > REP_NEUTRAL && dest->nearestPoint(&botPos)->GetMapId() == player->GetMapId())
|
||||
if (reaction > REP_NEUTRAL && dest->nearestPoint(&botPos)->m_mapId == player->GetMapId())
|
||||
{
|
||||
botPos = *dest->nearestPoint(&botPos);
|
||||
break;
|
||||
@ -3252,7 +3252,7 @@ void RandomPlayerbotMgr::PrintStats()
|
||||
|
||||
if (sPlayerbotAIConfig.enableNewRpgStrategy)
|
||||
{
|
||||
rpgStatusCount[botAI->rpgInfo.GetStatus()]++;
|
||||
rpgStatusCount[botAI->rpgInfo.status]++;
|
||||
rpgStasticTotal += botAI->rpgStatistic;
|
||||
botAI->rpgStatistic = NewRpgStatistic();
|
||||
}
|
||||
|
||||
@ -1700,7 +1700,7 @@ std::vector<uint32> RandomItemMgr::GetQuestIdsForItem(uint32 itemId)
|
||||
}
|
||||
}
|
||||
|
||||
return questIds;
|
||||
return std::move(questIds);
|
||||
}
|
||||
|
||||
uint32 RandomItemMgr::GetUpgrade(Player* player, std::string spec, uint8 slot, uint32 quality, uint32 itemId)
|
||||
@ -1827,7 +1827,7 @@ std::vector<uint32> RandomItemMgr::GetUpgradeList(Player* player, std::string sp
|
||||
{
|
||||
std::vector<uint32> listItems;
|
||||
if (!player)
|
||||
return listItems;
|
||||
return std::move(listItems);
|
||||
|
||||
// get old item statWeight
|
||||
uint32 oldStatWeight = 0;
|
||||
@ -1848,7 +1848,7 @@ std::vector<uint32> RandomItemMgr::GetUpgradeList(Player* player, std::string sp
|
||||
}
|
||||
|
||||
if (!specId)
|
||||
return listItems;
|
||||
return std::move(listItems);
|
||||
|
||||
if (itemId && itemInfoCache.find(itemId) != itemInfoCache.end())
|
||||
{
|
||||
@ -1942,7 +1942,7 @@ std::vector<uint32> RandomItemMgr::GetUpgradeList(Player* player, std::string sp
|
||||
LOG_INFO("playerbots", "New Items: {}, Old item:%d, New items max: {}", listItems.size(), oldStatWeight,
|
||||
closestUpgradeWeight);
|
||||
|
||||
return listItems;
|
||||
return std::move(listItems);
|
||||
}
|
||||
|
||||
bool RandomItemMgr::HasStatWeight(uint32 itemId)
|
||||
|
||||
@ -62,9 +62,9 @@ void FleeManager::calculatePossibleDestinations(std::vector<FleePoint*>& points)
|
||||
}
|
||||
Unit* target = *botAI->GetAiObjectContext()->GetValue<Unit*>("current target");
|
||||
|
||||
float botPosX = startPosition.GetPositionX();
|
||||
float botPosY = startPosition.GetPositionY();
|
||||
float botPosZ = startPosition.GetPositionZ();
|
||||
float botPosX = startPosition.getX();
|
||||
float botPosY = startPosition.getY();
|
||||
float botPosZ = startPosition.getZ();
|
||||
|
||||
FleePoint start(botAI, botPosX, botPosY, botPosZ);
|
||||
calculateDistanceToCreatures(&start);
|
||||
|
||||
@ -317,7 +317,7 @@ std::vector<TalentSpec::TalentListEntry> TalentSpec::GetTalentTree(uint32 tabpag
|
||||
if (entry.tabPage() == tabpage)
|
||||
retList.push_back(entry);
|
||||
|
||||
return retList;
|
||||
return std::move(retList);
|
||||
}
|
||||
|
||||
uint32 TalentSpec::GetTalentPoints(int32 tabpage) { return GetTalentPoints(talents, tabpage); };
|
||||
@ -368,7 +368,7 @@ std::string const TalentSpec::GetTalentLink()
|
||||
if (treeLink[2] != "0")
|
||||
link = link + "-" + treeLink[2];
|
||||
|
||||
return link;
|
||||
return std::move(link);
|
||||
}
|
||||
|
||||
uint32 TalentSpec::highestTree()
|
||||
|
||||
@ -71,13 +71,13 @@ WorldPosition::WorldPosition(std::vector<WorldPosition*> list, WorldPositionCons
|
||||
set(*list[urand(0, size - 1)]);
|
||||
else if (conType == WP_CENTROID)
|
||||
{
|
||||
set(std::accumulate(list.begin(), list.end(), WorldLocation(list[0]->GetMapId(), 0, 0, 0, 0),
|
||||
set(std::accumulate(list.begin(), list.end(), WorldLocation(list[0]->getMapId(), 0, 0, 0, 0),
|
||||
[size](WorldLocation i, WorldPosition* j)
|
||||
{
|
||||
i.m_positionX += j->GetPositionX() / size;
|
||||
i.m_positionY += j->GetPositionY() / size;
|
||||
i.m_positionZ += j->GetPositionZ() / size;
|
||||
i.NormalizeOrientation(i.m_orientation += j->GetOrientation() / size);
|
||||
i.m_positionX += j->getX() / size;
|
||||
i.m_positionY += j->getY() / size;
|
||||
i.m_positionZ += j->getZ() / size;
|
||||
i.NormalizeOrientation(i.m_orientation += j->getO() / size);
|
||||
return i;
|
||||
}));
|
||||
}
|
||||
@ -100,13 +100,13 @@ WorldPosition::WorldPosition(std::vector<WorldPosition> list, WorldPositionConst
|
||||
set(list[urand(0, size - 1)]);
|
||||
else if (conType == WP_CENTROID)
|
||||
{
|
||||
set(std::accumulate(list.begin(), list.end(), WorldLocation(list[0].GetMapId(), 0, 0, 0, 0),
|
||||
set(std::accumulate(list.begin(), list.end(), WorldLocation(list[0].getMapId(), 0, 0, 0, 0),
|
||||
[size](WorldLocation i, WorldPosition& j)
|
||||
{
|
||||
i.m_positionX += j.GetPositionX() / size;
|
||||
i.m_positionY += j.GetPositionY() / size;
|
||||
i.m_positionZ += j.GetPositionZ() / size;
|
||||
i.NormalizeOrientation(i.m_orientation += j.GetOrientation() / size);
|
||||
i.m_positionX += j.getX() / size;
|
||||
i.m_positionY += j.getY() / size;
|
||||
i.m_positionZ += j.getZ() / size;
|
||||
i.NormalizeOrientation(i.m_orientation += j.getO() / size);
|
||||
return i;
|
||||
}));
|
||||
}
|
||||
@ -190,6 +190,16 @@ WorldPosition& WorldPosition::operator-=(WorldPosition const& p1)
|
||||
return *this;
|
||||
}
|
||||
|
||||
uint32 WorldPosition::getMapId() { return GetMapId(); }
|
||||
|
||||
float WorldPosition::getX() { return GetPositionX(); }
|
||||
|
||||
float WorldPosition::getY() { return GetPositionY(); }
|
||||
|
||||
float WorldPosition::getZ() { return GetPositionZ(); }
|
||||
|
||||
float WorldPosition::getO() { return GetOrientation(); }
|
||||
|
||||
bool WorldPosition::isOverworld()
|
||||
{
|
||||
return GetMapId() == 0 || GetMapId() == 1 || GetMapId() == 530 || GetMapId() == 571;
|
||||
@ -233,7 +243,7 @@ float WorldPosition::size()
|
||||
|
||||
float WorldPosition::distance(WorldPosition* center)
|
||||
{
|
||||
if (GetMapId() == center->GetMapId())
|
||||
if (GetMapId() == center->getMapId())
|
||||
return relPoint(center).size();
|
||||
|
||||
// this -> mapTransfer | mapTransfer -> center
|
||||
@ -242,7 +252,7 @@ float WorldPosition::distance(WorldPosition* center)
|
||||
|
||||
float WorldPosition::fDist(WorldPosition* center)
|
||||
{
|
||||
if (GetMapId() == center->GetMapId())
|
||||
if (GetMapId() == center->getMapId())
|
||||
return sqrt(sqDistance2d(center));
|
||||
|
||||
// this -> mapTransfer | mapTransfer -> center
|
||||
@ -318,7 +328,7 @@ WorldPosition WorldPosition::firstOutRange(std::vector<WorldPosition> list, floa
|
||||
// Returns true if (on the x-y plane) the position is inside the three points.
|
||||
bool WorldPosition::isInside(WorldPosition* p1, WorldPosition* p2, WorldPosition* p3)
|
||||
{
|
||||
if (GetMapId() != p1->GetMapId() != p2->GetMapId() != p3->GetMapId())
|
||||
if (getMapId() != p1->getMapId() != p2->getMapId() != p3->getMapId())
|
||||
return false;
|
||||
|
||||
float d1, d2, d3;
|
||||
@ -338,7 +348,7 @@ MapEntry const* WorldPosition::getMapEntry() { return sMapStore.LookupEntry(GetM
|
||||
|
||||
uint32 WorldPosition::getInstanceId()
|
||||
{
|
||||
if (Map* map = sMapMgr->FindBaseMap(GetMapId()))
|
||||
if (Map* map = sMapMgr->FindBaseMap(getMapId()))
|
||||
return map->GetInstanceId();
|
||||
|
||||
return 0;
|
||||
@ -351,7 +361,7 @@ Map* WorldPosition::getMap()
|
||||
|
||||
float WorldPosition::getHeight() // remove const - whipowill
|
||||
{
|
||||
return getMap()->GetHeight(GetPositionX(), GetPositionY(), GetPositionZ());
|
||||
return getMap()->GetHeight(getX(), getY(), getZ());
|
||||
}
|
||||
|
||||
G3D::Vector3 WorldPosition::getVector3() { return G3D::Vector3(GetPositionX(), GetPositionY(), GetPositionZ()); }
|
||||
@ -371,11 +381,11 @@ std::string const WorldPosition::print()
|
||||
std::string const WorldPosition::to_string()
|
||||
{
|
||||
std::stringstream out;
|
||||
out << GetMapId() << '|';
|
||||
out << GetPositionX() << '|';
|
||||
out << GetPositionY() << '|';
|
||||
out << GetPositionZ() << '|';
|
||||
out << GetOrientation();
|
||||
out << m_mapId << '|';
|
||||
out << m_positionX << '|';
|
||||
out << m_positionY << '|';
|
||||
out << m_positionZ << '|';
|
||||
out << m_orientation;
|
||||
return out.str();
|
||||
}
|
||||
|
||||
@ -419,14 +429,11 @@ void WorldPosition::printWKT(std::vector<WorldPosition> points, std::ostringstre
|
||||
|
||||
WorldPosition WorldPosition::getDisplayLocation()
|
||||
{
|
||||
WorldPosition pos = TravelNodeMap::instance().getMapOffset(GetMapId());
|
||||
WorldPosition pos = TravelNodeMap::instance().getMapOffset(getMapId());
|
||||
return offset(const_cast<WorldPosition*>(&pos));
|
||||
}
|
||||
|
||||
uint16 WorldPosition::getAreaId()
|
||||
{
|
||||
return sMapMgr->GetAreaId(PHASEMASK_NORMAL, GetMapId(), GetPositionX(), GetPositionY(), GetPositionZ());
|
||||
}
|
||||
uint16 WorldPosition::getAreaId() { return sMapMgr->GetAreaId(PHASEMASK_NORMAL, getMapId(), getX(), getY(), getZ()); }
|
||||
|
||||
AreaTableEntry const* WorldPosition::getArea()
|
||||
{
|
||||
@ -441,7 +448,7 @@ std::string const WorldPosition::getAreaName(bool fullName, bool zoneName)
|
||||
{
|
||||
if (!isOverworld())
|
||||
{
|
||||
MapEntry const* map = sMapStore.LookupEntry(GetMapId());
|
||||
MapEntry const* map = sMapStore.LookupEntry(getMapId());
|
||||
if (map)
|
||||
return map->name[0];
|
||||
}
|
||||
@ -473,7 +480,7 @@ std::string const WorldPosition::getAreaName(bool fullName, bool zoneName)
|
||||
}
|
||||
}
|
||||
|
||||
return areaName;
|
||||
return std::move(areaName);
|
||||
}
|
||||
|
||||
std::set<Transport*> WorldPosition::getTransports(uint32 entry)
|
||||
@ -538,7 +545,7 @@ std::vector<WorldPosition> WorldPosition::fromGridCoord(GridCoord gridCoord)
|
||||
if (d == 2 || d == 3)
|
||||
g.inc_y(1);
|
||||
|
||||
retVec.push_back(WorldPosition(GetMapId(), g));
|
||||
retVec.push_back(WorldPosition(getMapId(), g));
|
||||
}
|
||||
|
||||
return retVec;
|
||||
@ -559,7 +566,7 @@ std::vector<WorldPosition> WorldPosition::fromCellCoord(CellCoord cellcoord)
|
||||
if (d == 2 || d == 3)
|
||||
p.inc_y(1);
|
||||
|
||||
retVec.push_back(WorldPosition(GetMapId(), p));
|
||||
retVec.push_back(WorldPosition(getMapId(), p));
|
||||
}
|
||||
return retVec;
|
||||
}
|
||||
@ -611,7 +618,7 @@ std::vector<WorldPosition> WorldPosition::frommGridCoord(mGridCoord GridCoord)
|
||||
if (d == 2 || d == 3)
|
||||
g.first++;
|
||||
|
||||
retVec.push_back(WorldPosition(GetMapId(), g));
|
||||
retVec.push_back(WorldPosition(getMapId(), g));
|
||||
}
|
||||
|
||||
return retVec;
|
||||
@ -699,7 +706,7 @@ void WorldPosition::loadMapAndVMaps(WorldPosition secondPos)
|
||||
{
|
||||
for (auto& grid : getmGridCoords(secondPos))
|
||||
{
|
||||
loadMapAndVMap(GetMapId(), grid.first, grid.second);
|
||||
loadMapAndVMap(getMapId(), grid.first, grid.second);
|
||||
}
|
||||
}
|
||||
|
||||
@ -707,7 +714,7 @@ std::vector<WorldPosition> WorldPosition::fromPointsArray(std::vector<G3D::Vecto
|
||||
{
|
||||
std::vector<WorldPosition> retVec;
|
||||
for (auto p : path)
|
||||
retVec.push_back(WorldPosition(GetMapId(), p.x, p.y, p.z, GetOrientation()));
|
||||
retVec.push_back(WorldPosition(getMapId(), p.x, p.y, p.z, getO()));
|
||||
|
||||
return retVec;
|
||||
}
|
||||
@ -722,7 +729,7 @@ std::vector<WorldPosition> WorldPosition::getPathStepFrom(WorldPosition startPos
|
||||
loadMapAndVMaps(startPos);
|
||||
|
||||
PathGenerator path(bot);
|
||||
path.CalculatePath(startPos.GetPositionX(), startPos.GetPositionY(), startPos.GetPositionZ());
|
||||
path.CalculatePath(startPos.getX(), startPos.getY(), startPos.getZ());
|
||||
|
||||
Movement::PointsArray points = path.GetPath();
|
||||
PathType type = path.GetPathType();
|
||||
@ -778,7 +785,7 @@ std::vector<WorldPosition> WorldPosition::getPathFromPath(std::vector<WorldPosit
|
||||
WorldPosition currentPos = startPath.back();
|
||||
|
||||
// No pathfinding across maps.
|
||||
if (GetMapId() != currentPos.GetMapId())
|
||||
if (getMapId() != currentPos.getMapId())
|
||||
return {};
|
||||
|
||||
std::vector<WorldPosition> subPath, fullPath = startPath;
|
||||
@ -811,18 +818,10 @@ bool WorldPosition::GetReachableRandomPointOnGround(Player* bot, float radius, b
|
||||
{
|
||||
radius *= randomRange ? rand_norm() : 1.f;
|
||||
float angle = rand_norm() * static_cast<float>(2 * M_PI);
|
||||
setX(GetPositionX() + radius * cosf(angle));
|
||||
setY(GetPositionY() + radius * sinf(angle));
|
||||
m_positionX += radius * cosf(angle);
|
||||
m_positionY += radius * sinf(angle);
|
||||
|
||||
float x = GetPositionX();
|
||||
float y = GetPositionY();
|
||||
float z = GetPositionZ();
|
||||
bool canReach = getMap()->CanReachPositionAndGetValidCoords(bot, x, y, z);
|
||||
setX(x);
|
||||
setY(y);
|
||||
setZ(z);
|
||||
|
||||
return canReach;
|
||||
return getMap()->CanReachPositionAndGetValidCoords(bot, m_positionX, m_positionY, m_positionZ);
|
||||
}
|
||||
|
||||
uint32 WorldPosition::getUnitsAggro(GuidVector& units, Player* bot)
|
||||
@ -845,7 +844,7 @@ uint32 WorldPosition::getUnitsAggro(GuidVector& units, Player* bot)
|
||||
void FindPointCreatureData::operator()(CreatureData const& creatureData)
|
||||
{
|
||||
if (!entry || creatureData.id1 == entry)
|
||||
if ((!point || creatureData.mapid == point.GetMapId()) &&
|
||||
if ((!point || creatureData.mapid == point.getMapId()) &&
|
||||
(!radius || point.sqDistance(WorldPosition(creatureData.mapid, creatureData.posX, creatureData.posY,
|
||||
creatureData.posZ)) < radius * radius))
|
||||
{
|
||||
@ -856,7 +855,7 @@ void FindPointCreatureData::operator()(CreatureData const& creatureData)
|
||||
void FindPointGameObjectData::operator()(GameObjectData const& gameobjectData)
|
||||
{
|
||||
if (!entry || gameobjectData.id == entry)
|
||||
if ((!point || gameobjectData.mapid == point.GetMapId()) &&
|
||||
if ((!point || gameobjectData.mapid == point.getMapId()) &&
|
||||
(!radius || point.sqDistance(WorldPosition(gameobjectData.mapid, gameobjectData.posX, gameobjectData.posY,
|
||||
gameobjectData.posZ)) < radius * radius))
|
||||
{
|
||||
@ -3224,8 +3223,7 @@ void TravelMgr::LoadQuestTravelTable()
|
||||
if (loc.second.empty())
|
||||
continue;
|
||||
|
||||
if (!TravelNodeMap::instance().getMapOffset(loc.second.front().GetMapId()) &&
|
||||
loc.second.front().GetMapId() != 0)
|
||||
if (!TravelNodeMap::instance().getMapOffset(loc.second.front().getMapId()) && loc.second.front().getMapId() != 0)
|
||||
continue;
|
||||
|
||||
std::vector<WorldPosition> points = loc.second;
|
||||
@ -3237,7 +3235,7 @@ void TravelMgr::LoadQuestTravelTable()
|
||||
|
||||
out << "\"center\""
|
||||
<< ",";
|
||||
out << points.begin()->GetMapId() << ",";
|
||||
out << points.begin()->getMapId() << ",";
|
||||
out << points.begin()->getAreaName() << ",";
|
||||
out << points.begin()->getAreaName(true, true) << ",";
|
||||
|
||||
@ -3247,7 +3245,7 @@ void TravelMgr::LoadQuestTravelTable()
|
||||
|
||||
out << "\"area\""
|
||||
<< ",";
|
||||
out << points.begin()->GetMapId() << ",";
|
||||
out << points.begin()->getMapId() << ",";
|
||||
out << points.begin()->getAreaName() << ",";
|
||||
out << points.begin()->getAreaName(true, true) << ",";
|
||||
|
||||
@ -3615,18 +3613,17 @@ void TravelMgr::LoadQuestTravelTable()
|
||||
if (!pos->getMap())
|
||||
continue;
|
||||
|
||||
float nx = pos->GetPositionX() + (x * 5) - 5000.0f;
|
||||
float ny = pos->GetPositionY() + (y * 5) - 5000.0f;
|
||||
float nz = pos->GetPositionZ() + 100.0f;
|
||||
float nx = pos->getX() + (x*5)-5000.0f;
|
||||
float ny = pos->getY() + (y*5)-5000.0f;
|
||||
float nz = pos->getZ() + 100.0f;
|
||||
|
||||
//pos->getMap()->GetHitPosition(nx, ny, nz + 200.0f, nx, ny, nz, -0.5f);
|
||||
|
||||
if (!pos->getMap()->GetHeightInRange(nx, ny, nz, 5000.0f)) // GetHeight can fail
|
||||
continue;
|
||||
|
||||
WorldPosition npos = WorldPosition(pos->GetMapId(), nx, ny, nz, 0.0);
|
||||
uint32 area = path.getArea(npos.GetMapId(), npos.GetPositionX(), npos.GetPositionY(),
|
||||
npos.GetPositionZ());
|
||||
WorldPosition npos = WorldPosition(pos->getMapId(), nx, ny, nz, 0.0);
|
||||
uint32 area = path.getArea(npos.getMapId(), npos.getX(), npos.getY(), npos.getZ());
|
||||
|
||||
std::ostringstream out;
|
||||
out << std::fixed << area << "," << npos.getDisplayX() << "," << npos.getDisplayY();
|
||||
@ -3650,8 +3647,7 @@ void TravelMgr::LoadQuestTravelTable()
|
||||
std::string const name = i.second->getTitle();
|
||||
name.erase(remove(name.begin(), name.end(), '\"'), name.end());
|
||||
out << std::fixed << std::setprecision(2) << name.c_str() << "," << i.first << "," << j->getDisplayX() <<
|
||||
"," << j->getDisplayY() << "," << j->GetPositionX() << "," << j->GetPositionY() << "," << j->GetPositionZ();
|
||||
sPlayerbotAIConfig.log(5,
|
||||
"," << j->getDisplayY() << "," << j->getX() << "," << j->getY() << "," << j->getZ(); sPlayerbotAIConfig.log(5,
|
||||
out.str().c_str());
|
||||
}
|
||||
}
|
||||
@ -4026,7 +4022,7 @@ std::vector<TravelDestination*> TravelMgr::getRpgTravelDestinations(Player* bot,
|
||||
retTravelLocations.push_back(dest);
|
||||
}
|
||||
|
||||
return retTravelLocations;
|
||||
return std::move(retTravelLocations);
|
||||
}
|
||||
|
||||
std::vector<TravelDestination*> TravelMgr::getExploreTravelDestinations(Player* bot, bool ignoreFull,
|
||||
@ -4091,8 +4087,8 @@ void TravelMgr::setNullTravelTarget(Player* player)
|
||||
|
||||
void TravelMgr::addMapTransfer(WorldPosition start, WorldPosition end, float portalDistance, bool makeShortcuts)
|
||||
{
|
||||
uint32 sMap = start.GetMapId();
|
||||
uint32 eMap = end.GetMapId();
|
||||
uint32 sMap = start.getMapId();
|
||||
uint32 eMap = end.getMapId();
|
||||
|
||||
if (sMap == eMap)
|
||||
return;
|
||||
@ -4125,7 +4121,7 @@ void TravelMgr::addMapTransfer(WorldPosition start, WorldPosition end, float por
|
||||
}
|
||||
|
||||
// Add actual transfer.
|
||||
auto mapTransfers = mapTransfersMap.find(std::make_pair(start.GetMapId(), end.GetMapId()));
|
||||
auto mapTransfers = mapTransfersMap.find(std::make_pair(start.getMapId(), end.getMapId()));
|
||||
|
||||
if (mapTransfers == mapTransfersMap.end())
|
||||
mapTransfersMap.insert({{sMap, eMap}, {mapTransfer(start, end, portalDistance)}});
|
||||
@ -4146,8 +4142,8 @@ void TravelMgr::loadMapTransfers()
|
||||
|
||||
float TravelMgr::mapTransDistance(WorldPosition start, WorldPosition end)
|
||||
{
|
||||
uint32 sMap = start.GetMapId();
|
||||
uint32 eMap = end.GetMapId();
|
||||
uint32 sMap = start.getMapId();
|
||||
uint32 eMap = end.getMapId();
|
||||
|
||||
if (sMap == eMap)
|
||||
return start.distance(end);
|
||||
@ -4171,8 +4167,8 @@ float TravelMgr::mapTransDistance(WorldPosition start, WorldPosition end)
|
||||
|
||||
float TravelMgr::fastMapTransDistance(WorldPosition start, WorldPosition end)
|
||||
{
|
||||
uint32 sMap = start.GetMapId();
|
||||
uint32 eMap = end.GetMapId();
|
||||
uint32 sMap = start.getMapId();
|
||||
uint32 eMap = end.getMapId();
|
||||
|
||||
if (sMap == eMap)
|
||||
return start.fDist(end);
|
||||
|
||||
@ -120,6 +120,12 @@ public:
|
||||
WorldPosition& operator+=(WorldPosition const& p1);
|
||||
WorldPosition& operator-=(WorldPosition const& p1);
|
||||
|
||||
uint32 getMapId();
|
||||
float getX();
|
||||
float getY();
|
||||
float getZ();
|
||||
float getO();
|
||||
|
||||
G3D::Vector3 getVector3();
|
||||
std::string const print();
|
||||
|
||||
@ -179,29 +185,29 @@ public:
|
||||
// Quick square distance in 2d plane.
|
||||
float sqDistance2d(WorldPosition center)
|
||||
{
|
||||
return (GetPositionX() - center.GetPositionX()) * (GetPositionX() - center.GetPositionX()) +
|
||||
(GetPositionY() - center.GetPositionY()) * (GetPositionY() - center.GetPositionY());
|
||||
return (getX() - center.getX()) * (getX() - center.getX()) +
|
||||
(getY() - center.getY()) * (getY() - center.getY());
|
||||
}
|
||||
|
||||
// Quick square distance calculation without map check. Used for getting the minimum distant points.
|
||||
float sqDistance(WorldPosition center)
|
||||
{
|
||||
return (GetPositionX() - center.GetPositionX()) * (GetPositionX() - center.GetPositionX()) +
|
||||
(GetPositionY() - center.GetPositionY()) * (GetPositionY() - center.GetPositionY()) +
|
||||
(GetPositionZ() - center.GetPositionZ()) * (GetPositionZ() - center.GetPositionZ());
|
||||
return (getX() - center.getX()) * (getX() - center.getX()) +
|
||||
(getY() - center.getY()) * (getY() - center.getY()) +
|
||||
(getZ() - center.getZ()) * (getZ() - center.getZ());
|
||||
}
|
||||
|
||||
float sqDistance2d(WorldPosition* center)
|
||||
{
|
||||
return (GetPositionX() - center->GetPositionX()) * (GetPositionX() - center->GetPositionX()) +
|
||||
(GetPositionY() - center->GetPositionY()) * (GetPositionY() - center->GetPositionY());
|
||||
return (getX() - center->getX()) * (getX() - center->getX()) +
|
||||
(getY() - center->getY()) * (getY() - center->getY());
|
||||
}
|
||||
|
||||
float sqDistance(WorldPosition* center)
|
||||
{
|
||||
return (GetPositionX() - center->GetPositionX()) * (GetPositionX() - center->GetPositionX()) +
|
||||
(GetPositionY() - center->GetPositionY()) * (GetPositionY() - center->GetPositionY()) +
|
||||
(GetPositionZ() - center->GetPositionZ()) * (GetPositionZ() - center->GetPositionZ());
|
||||
return (getX() - center->getX()) * (getX() - center->getX()) +
|
||||
(getY() - center->getY()) * (getY() - center->getY()) +
|
||||
(getZ() - center->getZ()) * (getZ() - center->getZ());
|
||||
}
|
||||
|
||||
// Returns the closest point of the list. Fast but only works for the same map.
|
||||
@ -221,7 +227,7 @@ public:
|
||||
|
||||
float getAngleTo(WorldPosition endPos)
|
||||
{
|
||||
float ang = atan2(endPos.GetPositionY() - GetPositionY(), endPos.GetPositionX() - GetPositionX());
|
||||
float ang = atan2(endPos.getY() - getY(), endPos.getX() - getX());
|
||||
return (ang >= 0) ? ang : 2 * static_cast<float>(M_PI) + ang;
|
||||
}
|
||||
|
||||
@ -232,8 +238,7 @@ public:
|
||||
|
||||
float mSign(WorldPosition* p1, WorldPosition* p2)
|
||||
{
|
||||
return (GetPositionX() - p2->GetPositionX()) * (p1->GetPositionY() - p2->GetPositionY()) -
|
||||
(p1->GetPositionX() - p2->GetPositionX()) * (GetPositionY() - p2->GetPositionY());
|
||||
return (getX() - p2->getX()) * (p1->getY() - p2->getY()) - (p1->getX() - p2->getX()) * (getY() - p2->getY());
|
||||
}
|
||||
|
||||
bool isInside(WorldPosition* p1, WorldPosition* p2, WorldPosition* p3);
|
||||
@ -246,23 +251,18 @@ public:
|
||||
|
||||
std::set<Transport*> getTransports(uint32 entry = 0);
|
||||
|
||||
CellCoord getCellCoord() { return Acore::ComputeCellCoord(GetPositionX(), GetPositionY()); }
|
||||
GridCoord getGridCoord()
|
||||
{
|
||||
CellCoord cellCoord = getCellCoord();
|
||||
Cell cell(cellCoord);
|
||||
return GridCoord(cell.GridX(), cell.GridY());
|
||||
}
|
||||
GridCoord getGridCoord() { return Acore::ComputeGridCoord(getX(), getY()); };
|
||||
std::vector<GridCoord> getGridCoord(WorldPosition secondPos);
|
||||
std::vector<WorldPosition> fromGridCoord(GridCoord GridCoord);
|
||||
|
||||
CellCoord getCellCoord() { return Acore::ComputeCellCoord(getX(), getY()); }
|
||||
std::vector<WorldPosition> fromCellCoord(CellCoord cellCoord);
|
||||
std::vector<WorldPosition> gridFromCellCoord(CellCoord cellCoord);
|
||||
|
||||
mGridCoord getmGridCoord()
|
||||
{
|
||||
return std::make_pair((int32)(CENTER_GRID_ID - GetPositionX() / SIZE_OF_GRIDS),
|
||||
(int32)(CENTER_GRID_ID - GetPositionY() / SIZE_OF_GRIDS));
|
||||
return std::make_pair((int32)(CENTER_GRID_ID - getX() / SIZE_OF_GRIDS),
|
||||
(int32)(CENTER_GRID_ID - getY() / SIZE_OF_GRIDS));
|
||||
}
|
||||
|
||||
std::vector<mGridCoord> getmGridCoords(WorldPosition secondPos);
|
||||
@ -270,15 +270,15 @@ public:
|
||||
|
||||
void loadMapAndVMap(uint32 mapId, uint8 x, uint8 y);
|
||||
|
||||
void loadMapAndVMap() { loadMapAndVMap(GetMapId(), getmGridCoord().first, getmGridCoord().second); }
|
||||
void loadMapAndVMap() { loadMapAndVMap(getMapId(), getmGridCoord().first, getmGridCoord().second); }
|
||||
|
||||
void loadMapAndVMaps(WorldPosition secondPos);
|
||||
|
||||
// Display functions
|
||||
WorldPosition getDisplayLocation();
|
||||
float getDisplayX() { return getDisplayLocation().GetPositionY() * -1.0; }
|
||||
float getDisplayX() { return getDisplayLocation().getY() * -1.0; }
|
||||
|
||||
float getDisplayY() { return getDisplayLocation().GetPositionX(); }
|
||||
float getDisplayY() { return getDisplayLocation().getX(); }
|
||||
|
||||
uint16 getAreaId();
|
||||
AreaTableEntry const* getArea();
|
||||
@ -334,11 +334,11 @@ private:
|
||||
|
||||
inline ByteBuffer& operator<<(ByteBuffer& b, WorldPosition& guidP)
|
||||
{
|
||||
b << guidP.GetMapId();
|
||||
b << guidP.GetPositionX();
|
||||
b << guidP.GetPositionY();
|
||||
b << guidP.GetPositionZ();
|
||||
b << guidP.GetOrientation();
|
||||
b << guidP.getMapId();
|
||||
b << guidP.getX();
|
||||
b << guidP.getY();
|
||||
b << guidP.getZ();
|
||||
b << guidP.getO();
|
||||
b << guidP.getVisitors();
|
||||
return b;
|
||||
}
|
||||
@ -440,7 +440,7 @@ std::vector<std::pair<T, WorldPosition>> GetPosList(std::vector<T> oList)
|
||||
for (auto& obj : oList)
|
||||
retList.push_back(std::make_pair(obj, WorldPosition(obj)));
|
||||
|
||||
return retList;
|
||||
return std::move(retList);
|
||||
};
|
||||
|
||||
template <class T>
|
||||
@ -450,7 +450,7 @@ std::vector<std::pair<T, WorldPosition>> GetPosVector(std::vector<T> oList)
|
||||
for (auto& obj : oList)
|
||||
retList.push_back(make_pair(obj, WorldPosition(obj)));
|
||||
|
||||
return retList;
|
||||
return std::move(retList);
|
||||
};
|
||||
|
||||
class mapTransfer
|
||||
@ -461,9 +461,9 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
bool isFrom(WorldPosition point) { return point.GetMapId() == pointFrom.GetMapId(); }
|
||||
bool isFrom(WorldPosition point) { return point.getMapId() == pointFrom.getMapId(); }
|
||||
|
||||
bool isTo(WorldPosition point) { return point.GetMapId() == pointTo.GetMapId(); }
|
||||
bool isTo(WorldPosition point) { return point.getMapId() == pointTo.getMapId(); }
|
||||
|
||||
WorldPosition* getPointFrom() { return &pointFrom; }
|
||||
|
||||
@ -543,7 +543,7 @@ public:
|
||||
WorldPosition* nearestPoint(WorldPosition* pos);
|
||||
|
||||
float distanceTo(WorldPosition* pos) { return nearestPoint(pos)->distance(pos); }
|
||||
bool onMap(WorldPosition* pos) { return nearestPoint(pos)->GetMapId() == pos->GetMapId(); }
|
||||
bool onMap(WorldPosition* pos) { return nearestPoint(pos)->getMapId() == pos->getMapId(); }
|
||||
virtual bool isIn(WorldPosition* pos, float radius = 0.f)
|
||||
{
|
||||
return onMap(pos) && distanceTo(pos) <= (radius ? radius : radiusMin);
|
||||
|
||||
@ -81,7 +81,7 @@ void TravelNodePath::calculateCost(bool distanceOnly)
|
||||
}
|
||||
}
|
||||
|
||||
if (lastPoint && point.GetMapId() == lastPoint.GetMapId())
|
||||
if (lastPoint && point.getMapId() == lastPoint.getMapId())
|
||||
{
|
||||
if (!distanceOnly && (point.isInWater() || lastPoint.isInWater()))
|
||||
swimDistance += point.distance(lastPoint);
|
||||
@ -364,7 +364,7 @@ std::vector<TravelNode*> TravelNode::getNodeMap(bool importantOnly, std::vector<
|
||||
}
|
||||
}
|
||||
|
||||
return closeList;
|
||||
return std::move(closeList);
|
||||
}
|
||||
|
||||
bool TravelNode::isUselessLink(TravelNode* farNode)
|
||||
@ -687,7 +687,7 @@ bool TravelPath::makeShortCut(WorldPosition startPos, float maxDist)
|
||||
// if (p.point.getMapId() != startPos.getMapId())
|
||||
// continue;
|
||||
|
||||
if (p.point.GetMapId() == startPos.GetMapId())
|
||||
if (p.point.getMapId() == startPos.getMapId())
|
||||
{
|
||||
float curDist = p.point.sqDistance(startPos);
|
||||
|
||||
@ -722,7 +722,7 @@ bool TravelPath::makeShortCut(WorldPosition startPos, float maxDist)
|
||||
newPath.push_back(p);
|
||||
}
|
||||
|
||||
if (newPath.empty() || minDist > maxDistSq || newPath.front().point.GetMapId() != startPos.GetMapId())
|
||||
if (newPath.empty() || minDist > maxDistSq || newPath.front().point.getMapId() != startPos.getMapId())
|
||||
{
|
||||
clear();
|
||||
return false;
|
||||
@ -800,7 +800,7 @@ bool TravelPath::shouldMoveToNextPoint(WorldPosition startPos, std::vector<PathN
|
||||
|
||||
float nextMove = p->point.distance(nextP->point);
|
||||
|
||||
if (p->point.GetMapId() != startPos.GetMapId() ||
|
||||
if (p->point.getMapId() != startPos.getMapId() ||
|
||||
((moveDist + nextMove > maxDist || startPos.distance(nextP->point) > maxDist) && moveDist > 0))
|
||||
{
|
||||
return false;
|
||||
@ -827,7 +827,7 @@ WorldPosition TravelPath::getNextPoint(WorldPosition startPos, float maxDist, Tr
|
||||
// Get the closest point on the path to start from.
|
||||
for (auto p = startP; p != ed; p++)
|
||||
{
|
||||
if (p->point.GetMapId() != startPos.GetMapId())
|
||||
if (p->point.getMapId() != startPos.getMapId())
|
||||
continue;
|
||||
|
||||
float curDist = p->point.distance(startPos);
|
||||
@ -1126,7 +1126,7 @@ std::vector<TravelNode*> TravelNodeMap::getNodes(WorldPosition pos, float range)
|
||||
|
||||
for (auto& node : m_nodes)
|
||||
{
|
||||
if (node->getMapId() == pos.GetMapId())
|
||||
if (node->getMapId() == pos.getMapId())
|
||||
if (range == -1 || node->getDistance(pos) <= range)
|
||||
retVec.push_back(node);
|
||||
}
|
||||
@ -1135,7 +1135,7 @@ std::vector<TravelNode*> TravelNodeMap::getNodes(WorldPosition pos, float range)
|
||||
[pos](TravelNode* i, TravelNode* j)
|
||||
{ return i->getPosition()->distance(pos) < j->getPosition()->distance(pos); });
|
||||
|
||||
return retVec;
|
||||
return std::move(retVec);
|
||||
}
|
||||
|
||||
TravelNode* TravelNodeMap::getNode(WorldPosition pos, [[maybe_unused]] std::vector<WorldPosition>& ppath, Unit* bot,
|
||||
@ -1787,9 +1787,8 @@ void TravelNodeMap::generateTransportNodes()
|
||||
float dy = -1 * p.second->Y;
|
||||
|
||||
WorldPosition pos =
|
||||
WorldPosition(basePos.GetMapId(), basePos.GetPositionX() + dx,
|
||||
basePos.GetPositionY() + dy, basePos.GetPositionZ() + p.second->Z,
|
||||
basePos.GetOrientation());
|
||||
WorldPosition(basePos.getMapId(), basePos.getX() + dx, basePos.getY() + dy,
|
||||
basePos.getZ() + p.second->Z, basePos.getO());
|
||||
|
||||
if (prevNode)
|
||||
{
|
||||
@ -1831,9 +1830,8 @@ void TravelNodeMap::generateTransportNodes()
|
||||
float dx = -1 * p.second->X;
|
||||
float dy = -1 * p.second->Y;
|
||||
WorldPosition pos =
|
||||
WorldPosition(basePos.GetMapId(), basePos.GetPositionX() + dx,
|
||||
basePos.GetPositionY() + dy, basePos.GetPositionZ() + p.second->Z,
|
||||
basePos.GetOrientation());
|
||||
WorldPosition(basePos.getMapId(), basePos.getX() + dx, basePos.getY() + dy,
|
||||
basePos.getZ() + p.second->Z, basePos.getO());
|
||||
|
||||
ppath.push_back(pos);
|
||||
|
||||
@ -2358,10 +2356,10 @@ void TravelNodeMap::saveNodeStore()
|
||||
stmt->SetData(0, i);
|
||||
stmt->SetData(1, saveNodes.find(link.first)->second);
|
||||
stmt->SetData(2, j);
|
||||
stmt->SetData(3, point.GetMapId());
|
||||
stmt->SetData(4, point.GetPositionX());
|
||||
stmt->SetData(5, point.GetPositionY());
|
||||
stmt->SetData(6, point.GetPositionZ());
|
||||
stmt->SetData(3, point.getMapId());
|
||||
stmt->SetData(4, point.getX());
|
||||
stmt->SetData(5, point.getY());
|
||||
stmt->SetData(6, point.getZ());
|
||||
trans->Append(stmt);
|
||||
|
||||
points++;
|
||||
@ -2518,10 +2516,10 @@ void TravelNodeMap::calcMapOffset()
|
||||
}
|
||||
else
|
||||
{
|
||||
min.back().setX(std::min(min.back().GetPositionX(), node->getX()));
|
||||
min.back().setY(std::min(min.back().GetPositionY(), node->getY()));
|
||||
max.back().setX(std::max(max.back().GetPositionX(), node->getX()));
|
||||
max.back().setY(std::max(max.back().GetPositionY(), node->getY()));
|
||||
min.back().setX(std::min(min.back().getX(), node->getX()));
|
||||
min.back().setY(std::min(min.back().getY(), node->getY()));
|
||||
max.back().setX(std::max(max.back().getX(), node->getX()));
|
||||
max.back().setY(std::max(max.back().getY(), node->getY()));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2535,15 +2533,14 @@ void TravelNodeMap::calcMapOffset()
|
||||
for (auto& mapId : mapIds)
|
||||
{
|
||||
mapOffsets.push_back(std::make_pair(
|
||||
mapId, WorldPosition(mapId, curPos.GetPositionX() - min[i].GetPositionX(),
|
||||
curPos.GetPositionY() - max[i].GetPositionY(), 0, 0)));
|
||||
mapId, WorldPosition(mapId, curPos.getX() - min[i].getX(), curPos.getY() - max[i].getY(), 0, 0)));
|
||||
|
||||
maxY = std::max(maxY, (max[i].GetPositionY() - min[i].GetPositionY() + 500));
|
||||
curPos.setX(curPos.GetPositionX() + (max[i].GetPositionX() - min[i].GetPositionX() + 500));
|
||||
maxY = std::max(maxY, (max[i].getY() - min[i].getY() + 500));
|
||||
curPos.setX(curPos.getX() + (max[i].getX() - min[i].getX() + 500));
|
||||
|
||||
if (curPos.GetPositionX() > endPos.GetPositionX())
|
||||
if (curPos.getX() > endPos.getX())
|
||||
{
|
||||
curPos.setY(curPos.GetPositionY() - maxY);
|
||||
curPos.setY(curPos.getY() - maxY);
|
||||
curPos.setX(-13000);
|
||||
}
|
||||
|
||||
|
||||
@ -251,11 +251,11 @@ public:
|
||||
}
|
||||
|
||||
// WorldLocation shortcuts
|
||||
uint32 getMapId() { return point.GetMapId(); }
|
||||
float getX() { return point.GetPositionX(); }
|
||||
float getY() { return point.GetPositionY(); }
|
||||
float getZ() { return point.GetPositionZ(); }
|
||||
float getO() { return point.GetOrientation(); }
|
||||
uint32 getMapId() { return point.getMapId(); }
|
||||
float getX() { return point.getX(); }
|
||||
float getY() { return point.getY(); }
|
||||
float getZ() { return point.getZ(); }
|
||||
float getO() { return point.getO(); }
|
||||
float getDistance(WorldPosition pos) { return point.distance(pos); }
|
||||
float getDistance(TravelNode* node) { return point.distance(node->getPosition()); }
|
||||
float fDist(TravelNode* node) { return point.fDist(node->getPosition()); }
|
||||
|
||||
@ -42,20 +42,21 @@ enum class HealingManaEfficiency : uint8
|
||||
|
||||
enum NewRpgStatus : int
|
||||
{
|
||||
//Initial Status
|
||||
RPG_IDLE = 0,
|
||||
RPG_GO_GRIND = 1,
|
||||
RPG_GO_CAMP = 2,
|
||||
RPG_STATUS_START = 0,
|
||||
// Going to far away place
|
||||
RPG_GO_GRIND = 0,
|
||||
RPG_GO_CAMP = 1,
|
||||
// Exploring nearby
|
||||
RPG_WANDER_RANDOM = 3,
|
||||
RPG_WANDER_NPC = 4,
|
||||
RPG_WANDER_RANDOM = 2,
|
||||
RPG_WANDER_NPC = 3,
|
||||
// Do Quest (based on quest status)
|
||||
RPG_DO_QUEST = 5,
|
||||
RPG_DO_QUEST = 4,
|
||||
// Travel
|
||||
|
||||
RPG_TRAVEL_FLIGHT = 6,
|
||||
RPG_TRAVEL_FLIGHT = 5,
|
||||
// Taking a break
|
||||
RPG_REST = 7,
|
||||
RPG_REST = 6,
|
||||
// Initial status
|
||||
RPG_IDLE = 7,
|
||||
RPG_STATUS_END = 8
|
||||
};
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user