mirror of
https://github.com/mod-playerbots/mod-playerbots.git
synced 2026-02-15 16:16:11 +00:00
Stage1 refactor world position method names (#2126)
# Pull Request This change replaces the non‑standard WorldPosition::getX/getY/getZ/getO/getMapId wrappers with the core getters (GetPositionX/Y/Z, GetOrientation, GetMapId) and removes the redundant wrappers. Goal: align the module with AzerothCore conventions, reduce local adapters, and improve long‑term maintainability. --- ## Design Philosophy This is a structural cleanup only (coordinate access) and does not alter any AI behavior or decision logic. It follows the stability/performance-first philosophy and does not add branches or extra runtime work. Before submitting: yes, this change aligns with the principles of stability, performance, and predictability. Principles: - **Stability before intelligence** A stable system is always preferred over a smarter one. - **Performance is a shared resource** Any increase in bot cost affects all players and all bots. - **Simple logic scales better than smart logic** Predictable behavior under load is more valuable than perfect decisions. - **Complexity must justify itself** If a feature cannot clearly explain its cost, it should not exist. - **Defaults must be cheap** Expensive behavior must always be optional and clearly communicated. - **Bots should look reasonable, not perfect** The goal is believable behavior, not human simulation. Before submitting, confirm that this change aligns with those principles. --- ## Feature Evaluation Please answer the following: - Minimum logic required: use core getters (GetPositionX/Y/Z, GetMapId, GetOrientation) wherever coordinates are needed. - Cheapest implementation: direct call replacement and removal of redundant wrappers. - Runtime cost: negligible (same data access, no additional logic). --- ## How to Test the Changes - No functional testing required (behavior‑neutral refactor). - Recommended: compile the module and run a normal server startup as validation. ## Complexity & Impact Does this change add new decision branches? - - [x] No - - [x] Yes (**explain below**) Does this change increase per-bot or per-tick processing? - - [x] No - - [ ] Yes (**describe and justify impact**) Could this logic scale poorly under load? - - [x] No - - [ ] Yes (**explain why**) --- ## Defaults & Configuration Does this change modify default bot behavior? - - [x] No - - [ ] Yes (**explain why**) If this introduces more advanced or AI-heavy logic: - - [x] Lightweight mode remains the default - - [x] More complex behavior is optional and thereby configurable --- ## AI Assistance Was AI assistance (e.g. ChatGPT or similar tools) used while working on this change? - - [ ] No - - [x] Yes (**explain below**) If yes, please specify: - AI tool or model used: Copilot - Purpose of usage: Translate this PR text from french to English --- ## Final Checklist - - [x] Stability is not compromised - - [x] Performance impact is understood, tested, and acceptable - - [x] Added logic complexity is justified and explained - - [x] Documentation updated if needed --- ## Notes for Reviewers This is a core-friendly cleanup only, with no behavioral change. No additional logic or CPU cost is introduced.
This commit is contained in:
@@ -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.getX(), pos.getY());
|
||||
float distance = groupLeader->GetDistance2d(pos.GetPositionX(), pos.GetPositionY());
|
||||
|
||||
if (!botAI->HasActivePlayerMaster() && distance < 50.0f)
|
||||
{
|
||||
|
||||
@@ -28,8 +28,8 @@ bool DebugAction::Execute(Event event)
|
||||
|
||||
uint32 areaId = 0;
|
||||
uint32 zoneId = 0;
|
||||
sMapMgr->GetZoneAndAreaId(PHASEMASK_NORMAL, zoneId, areaId, pos.getMapId(), pos.getX(), pos.getY(),
|
||||
pos.getZ());
|
||||
sMapMgr->GetZoneAndAreaId(PHASEMASK_NORMAL, zoneId, areaId, pos.GetMapId(), pos.GetPositionX(), pos.GetPositionY(),
|
||||
pos.GetPositionZ());
|
||||
|
||||
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.getX(), p.getY(), p.getZ(), 0, TEMPSUMMON_TIMED_DESPAWN, 20000.0f);
|
||||
bot->SummonCreature(1, p.GetPositionX(), p.GetPositionY(), p.GetPositionZ(), 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.getX() + cos(ang) * dist);
|
||||
botPos.setY(botPos.getY() + sin(ang) * dist);
|
||||
botPos.setX(botPos.GetPositionX() + cos(ang) * dist);
|
||||
botPos.setY(botPos.GetPositionY() + sin(ang) * dist);
|
||||
botPos.setZ(botPos.getHeight() + 2);
|
||||
|
||||
Creature* wpCreature = bot->SummonCreature(2334, botPos.getX(), botPos.getY(), botPos.getZ(), 0,
|
||||
Creature* wpCreature = bot->SummonCreature(2334, botPos.GetPositionX(), botPos.GetPositionY(), botPos.GetPositionZ(), 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.getX() + cos(ang) * dist);
|
||||
botPos.setY(botPos.getY() + sin(ang) * dist);
|
||||
botPos.setX(botPos.GetPositionX() + cos(ang) * dist);
|
||||
botPos.setY(botPos.GetPositionY() + sin(ang) * dist);
|
||||
botPos.setZ(botPos.getHeight() + 2);
|
||||
|
||||
Creature* wpCreature = bot->SummonCreature(2334, botPos.getX(), botPos.getY(), botPos.getZ(), 0,
|
||||
Creature* wpCreature = bot->SummonCreature(2334, botPos.GetPositionX(), botPos.GetPositionY(), botPos.GetPositionZ(), 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.getX() + cos(ang) * dist);
|
||||
botPos.setY(botPos.getY() + sin(ang) * dist);
|
||||
botPos.setX(botPos.GetPositionX() + cos(ang) * dist);
|
||||
botPos.setY(botPos.GetPositionY() + sin(ang) * dist);
|
||||
botPos.setZ(botPos.getHeight() + 2);
|
||||
|
||||
Creature* wpCreature = bot->SummonCreature(2334, botPos.getX(), botPos.getY(), botPos.getZ(), 0,
|
||||
Creature* wpCreature = bot->SummonCreature(2334, botPos.GetPositionX(), botPos.GetPositionY(), botPos.GetPositionZ(), 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.getX() + cos(ang) * dist);
|
||||
botPos.setY(botPos.getY() + sin(ang) * dist);
|
||||
botPos.setX(botPos.GetPositionX() + cos(ang) * dist);
|
||||
botPos.setY(botPos.GetPositionY() + sin(ang) * dist);
|
||||
botPos.setZ(botPos.getHeight() + 2);
|
||||
|
||||
Creature* wpCreature = bot->SummonCreature(2334, botPos.getX(), botPos.getY(), botPos.getZ(), 0,
|
||||
Creature* wpCreature = bot->SummonCreature(2334, botPos.GetPositionX(), botPos.GetPositionY(), botPos.GetPositionZ(), 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.getX() + (dx - 5) * 5);
|
||||
botPos.setY(botPos.getY() + (dy - 5) * 5);
|
||||
botPos.setX(botPos.GetPositionX() + (dx - 5) * 5);
|
||||
botPos.setY(botPos.GetPositionY() + (dy - 5) * 5);
|
||||
botPos.setZ(botPos.getHeight());
|
||||
|
||||
Creature* wpCreature =
|
||||
bot->SummonCreature((dy == 0 && (dx == 0 || dx == 2)) ? 6 : 2, botPos.getX(), botPos.getY(),
|
||||
botPos.getZ(), 0, TEMPSUMMON_TIMED_DESPAWN, 10000.0f);
|
||||
bot->SummonCreature((dy == 0 && (dx == 0 || dx == 2)) ? 6 : 2, botPos.GetPositionX(), botPos.GetPositionY(),
|
||||
botPos.GetPositionZ(), 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.getX() + (dx - 5) * 5);
|
||||
botPos.setY(botPos.getY() + (dy - 5) * 5);
|
||||
botPos.setX(botPos.GetPositionX() + (dx - 5) * 5);
|
||||
botPos.setY(botPos.GetPositionY() + (dy - 5) * 5);
|
||||
botPos.setZ(botPos.getHeight());
|
||||
|
||||
Creature* wpCreature = bot->SummonCreature(effect, botPos.getX(), botPos.getY(), botPos.getZ(), 0,
|
||||
Creature* wpCreature = bot->SummonCreature(effect, botPos.GetPositionX(), botPos.GetPositionY(), botPos.GetPositionZ(), 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.getX() + (dx - 5) * 5);
|
||||
botPos.setY(botPos.getY() + (dy - 5) * 5);
|
||||
botPos.setX(botPos.GetPositionX() + (dx - 5) * 5);
|
||||
botPos.setY(botPos.GetPositionY() + (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.getX() + (dx - 5) * 5);
|
||||
botPos.setY(botPos.getY() + (dy - 5) * 5);
|
||||
botPos.setX(botPos.GetPositionX() + (dx - 5) * 5);
|
||||
botPos.setY(botPos.GetPositionY() + (dy - 5) * 5);
|
||||
botPos.setZ(botPos.getHeight());
|
||||
|
||||
Creature* wpCreature = bot->SummonCreature(2334, botPos.getX(), botPos.getY(), botPos.getZ(), 0,
|
||||
Creature* wpCreature = bot->SummonCreature(2334, botPos.GetPositionX(), botPos.GetPositionY(), botPos.GetPositionZ(), 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.getX(), botPos.getY() + 80, botPos.getZ(), 8.0f, true,
|
||||
// wpCreature->MonsterMoveWithSpeed(botPos.GetPositionX(), botPos.GetPositionY() + 80, botPos.GetPositionZ(), 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.getX() + (dx - 5) * 5);
|
||||
botPos.setY(botPos.getY() + (dy - 5) * 5);
|
||||
botPos.setX(botPos.GetPositionX() + (dx - 5) * 5);
|
||||
botPos.setY(botPos.GetPositionY() + (dy - 5) * 5);
|
||||
botPos.setZ(botPos.getHeight());
|
||||
|
||||
Creature* wpCreature =
|
||||
bot->SummonCreature((dy == 0 && (dx == 0 || dx == 2)) ? 6 : 2, botPos.getX(), botPos.getY(),
|
||||
botPos.getZ(), 0, TEMPSUMMON_TIMED_DESPAWN, 10000.0f);
|
||||
bot->SummonCreature((dy == 0 && (dx == 0 || dx == 2)) ? 6 : 2, botPos.GetPositionX(), botPos.GetPositionY(),
|
||||
botPos.GetPositionZ(), 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.getX() + (dx - 5) * 5);
|
||||
botPos.setY(botPos.getY() + (dy - 5) * 5);
|
||||
botPos.setX(botPos.GetPositionX() + (dx - 5) * 5);
|
||||
botPos.setY(botPos.GetPositionY() + (dy - 5) * 5);
|
||||
botPos.setZ(botPos.getHeight());
|
||||
|
||||
wpCreature = bot->SummonCreature((dy == 0 && (dx == 0 || dx == 2)) ? 6 : 2, botPos.getX(),
|
||||
botPos.getY(), botPos.getZ(), 0, TEMPSUMMON_TIMED_DESPAWN, 10000.0f);
|
||||
wpCreature = bot->SummonCreature((dy == 0 && (dx == 0 || dx == 2)) ? 6 : 2, botPos.GetPositionX(),
|
||||
botPos.GetPositionY(), botPos.GetPositionZ(), 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.getX() + (dx - 5) * 5);
|
||||
botPos.setY(botPos.getY() + (dy - 5) * 5);
|
||||
botPos.setX(botPos.GetPositionX() + (dx - 5) * 5);
|
||||
botPos.setY(botPos.GetPositionY() + (dy - 5) * 5);
|
||||
botPos.setZ(botPos.getHeight());
|
||||
|
||||
wpCreature = bot->SummonCreature(2334, botPos.getX(), botPos.getY(), botPos.getZ(), 0,
|
||||
wpCreature = bot->SummonCreature(2334, botPos.GetPositionX(), botPos.GetPositionY(), botPos.GetPositionZ(), 0,
|
||||
TEMPSUMMON_TIMED_DESPAWN, 10000.0f);
|
||||
|
||||
if (wpCreature)
|
||||
@@ -708,11 +708,11 @@ bool DebugAction::Execute(Event event)
|
||||
{
|
||||
WorldPosition botPos(bot);
|
||||
|
||||
botPos.setX(botPos.getX() + (dx - 5) * 5);
|
||||
botPos.setY(botPos.getY() + (dy - 5) * 5);
|
||||
botPos.setX(botPos.GetPositionX() + (dx - 5) * 5);
|
||||
botPos.setY(botPos.GetPositionY() + (dy - 5) * 5);
|
||||
botPos.setZ(botPos.getHeight());
|
||||
|
||||
Creature* wpCreature = bot->SummonCreature(2334, botPos.getX(), botPos.getY(), botPos.getZ(), 0,
|
||||
Creature* wpCreature = bot->SummonCreature(2334, botPos.GetPositionX(), botPos.GetPositionY(), botPos.GetPositionZ(), 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.getX() + (dx - 5) * 5);
|
||||
botPos.setY(botPos.getY() + (dy - 5) * 5);
|
||||
botPos.setX(botPos.GetPositionX() + (dx - 5) * 5);
|
||||
botPos.setY(botPos.GetPositionY() + (dy - 5) * 5);
|
||||
botPos.setZ(botPos.getHeight());
|
||||
|
||||
Creature* wpCreature = bot->SummonCreature(2334, botPos.getX(), botPos.getY(), botPos.getZ(), 0,
|
||||
Creature* wpCreature = bot->SummonCreature(2334, botPos.GetPositionX(), botPos.GetPositionY(), botPos.GetPositionZ(), 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.getX() + (dx - 5) * 5);
|
||||
botPos.setY(botPos.getY() + (dy - 5) * 5);
|
||||
botPos.setX(botPos.GetPositionX() + (dx - 5) * 5);
|
||||
botPos.setY(botPos.GetPositionY() + (dy - 5) * 5);
|
||||
botPos.setZ(botPos.getHeight());
|
||||
|
||||
Creature* wpCreature =
|
||||
bot->SummonCreature((dy == 0 && (dx == 0 || dx == 2)) ? 6 : 2, botPos.getX(), botPos.getY(),
|
||||
botPos.getZ(), 0, TEMPSUMMON_TIMED_DESPAWN, 10000.0f);
|
||||
bot->SummonCreature((dy == 0 && (dx == 0 || dx == 2)) ? 6 : 2, botPos.GetPositionX(), botPos.GetPositionY(),
|
||||
botPos.GetPositionZ(), 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.getX(), source.getY(), source.getZ());
|
||||
m_targets.SetSrc(source.GetPositionX(), source.GetPositionY(), source.GetPositionZ());
|
||||
|
||||
if (!forceDest && target)
|
||||
if (!spellInfo ||
|
||||
|
||||
@@ -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.getX(), movePosition.getY(), movePosition.getZ(), false);
|
||||
// path.CalculatePath(movePosition.GetPositionX(), movePosition.GetPositionY(), movePosition.GetPositionZ(), 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.getX(), movePosition.getY(),
|
||||
// movePosition.getZ(), movePosition.getO(), 0);
|
||||
// return bot->TeleportTo(movePosition.GetMapId(), movePosition.GetPositionX(), movePosition.GetPositionY(),
|
||||
// movePosition.GetPositionZ(), movePosition.GetOrientation(), 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.getX(), i.point.getY(), i.point.getZ(), 0.f, 2334);
|
||||
// CreateWp(bot, i.point.GetPositionX(), i.point.GetPositionY(), i.point.GetPositionZ(), 0.f, 2334);
|
||||
|
||||
// cx = i.point.getX();
|
||||
// cy = i.point.getY();
|
||||
// cz = i.point.getZ();
|
||||
// cx = i.point.GetPositionX();
|
||||
// cy = i.point.GetPositionY();
|
||||
// cz = i.point.GetPositionZ();
|
||||
// }
|
||||
// }
|
||||
// else
|
||||
// CreateWp(bot, movePosition.getX(), movePosition.getY(), movePosition.getZ(), 0, 2334, true);
|
||||
// CreateWp(bot, movePosition.GetPositionX(), movePosition.GetPositionY(), movePosition.GetPositionZ(), 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.getX(), startPosition.getY(),
|
||||
// movePosition.getX(), movePosition.getY()); if (!react)
|
||||
// // LOG_DEBUG("playerbots", "({}, {}) -> ({}, {})", startPosition.GetPositionX(), startPosition.GetPositionY(),
|
||||
// movePosition.GetPositionX(), movePosition.GetPositionY()); 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.getX(), movePosition.getY(), movePosition.getZ(), startPosition.getAngleTo(movePosition));
|
||||
// !detailedMove && !botAI->HasPlayerNearby(&movePosition)"); return bot->TeleportTo(movePosition.GetMapId(),
|
||||
// movePosition.GetPositionX(), movePosition.GetPositionY(), movePosition.GetPositionZ(), 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.getX(), movePosition.getY(),
|
||||
// movePosition.getZ(), generatePath); WaitForReach(startPosition.distance(movePosition));
|
||||
// // LOG_DEBUG("playerbots", "Movepoint to ({}, {})", movePosition.getX(), movePosition.getY());
|
||||
// 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());
|
||||
// }
|
||||
// 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.getX(), movePosition.getY(),
|
||||
// movePosition.getZ(), 0.f)); WaitForReach(startPosition.distance(movePosition)); LOG_DEBUG("playerbots",
|
||||
// "Movepoint to ({}, {})", movePosition.getX(), movePosition.getY());
|
||||
// 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());
|
||||
// }
|
||||
|
||||
// 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.getX(), cPos.getY(), cPos.getZ());
|
||||
return MoveTo(cPos.GetMapId(), cPos.GetPositionX(), cPos.GetPositionY(), cPos.GetPositionZ());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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.getX(), longMove.getY(), longMove.getZ());
|
||||
return MoveTo(longMove.GetMapId(), longMove.GetPositionX(), longMove.GetPositionY(), longMove.GetPositionZ());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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.getX(), moveToPos.getY(), moveToPos.getZ(), 0);
|
||||
bot->TeleportTo(moveToPos.GetMapId(), moveToPos.GetPositionX(), moveToPos.GetPositionY(), moveToPos.GetPositionZ(), 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.getX(), moveToPos.getY(), moveToPos.getZ(), false, false);
|
||||
MoveTo(moveToPos.GetMapId(), moveToPos.GetPositionX(), moveToPos.GetPositionY(), moveToPos.GetPositionZ(), 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.getX(),
|
||||
travelPos.getY(), travelPos.getZ());
|
||||
ClosestGrave = sGraveyard->GetClosestGraveyard(travelPos.getMapId(), travelPos.getX(), travelPos.getY(),
|
||||
travelPos.getZ(), bot->GetTeamId(), areaId, zoneId,
|
||||
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,
|
||||
bot->getClass() == CLASS_DEATH_KNIGHT);
|
||||
|
||||
if (ClosestGrave)
|
||||
|
||||
@@ -150,7 +150,7 @@ bool RpgTaxiAction::Execute(Event event)
|
||||
bot->GetSession()->HandleCancelMountAuraOpcode(emptyPacket);
|
||||
|
||||
uint32 node =
|
||||
sObjectMgr->GetNearestTaxiNode(guidP.getX(), guidP.getY(), guidP.getZ(), guidP.getMapId(), bot->GetTeamId());
|
||||
sObjectMgr->GetNearestTaxiNode(guidP.GetPositionX(), guidP.GetPositionY(), guidP.GetPositionZ(), 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.getX(), guidP.getY(), guidP.getZ(), guidP.getMapId(), bot->GetTeamId());
|
||||
sObjectMgr->GetNearestTaxiNode(guidP.GetPositionX(), guidP.GetPositionY(), guidP.GetPositionZ(), guidP.GetMapId(), bot->GetTeamId());
|
||||
|
||||
if (!node)
|
||||
return false;
|
||||
|
||||
@@ -80,8 +80,9 @@ bool RTSCAction::Execute(Event event)
|
||||
SET_AI_VALUE2(WorldPosition, "RTSC saved location", locationName, spellPosition);
|
||||
|
||||
Creature* wpCreature =
|
||||
bot->SummonCreature(15631, spellPosition.getX(), spellPosition.getY(), spellPosition.getZ(),
|
||||
spellPosition.getO(), TEMPSUMMON_TIMED_DESPAWN, 2000.0f);
|
||||
bot->SummonCreature(15631, spellPosition.GetPositionX(), spellPosition.GetPositionY(),
|
||||
spellPosition.GetPositionZ(), spellPosition.GetOrientation(), TEMPSUMMON_TIMED_DESPAWN,
|
||||
2000.0f);
|
||||
wpCreature->SetObjectScale(0.5f);
|
||||
|
||||
return true;
|
||||
@@ -110,8 +111,9 @@ bool RTSCAction::Execute(Event event)
|
||||
if (spellPosition)
|
||||
{
|
||||
Creature* wpCreature =
|
||||
bot->SummonCreature(15631, spellPosition.getX(), spellPosition.getY(), spellPosition.getZ(),
|
||||
spellPosition.getO(), TEMPSUMMON_TIMED_DESPAWN, 2000.0f);
|
||||
bot->SummonCreature(15631, spellPosition.GetPositionX(), spellPosition.GetPositionY(),
|
||||
spellPosition.GetPositionZ(), spellPosition.GetOrientation(),
|
||||
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.getX(), spellPosition.getY(), spellPosition.getZ(),
|
||||
spellPosition.getO(), TEMPSUMMON_TIMED_DESPAWN, 2000.0f);
|
||||
bot->SummonCreature(15631, spellPosition.GetPositionX(), spellPosition.GetPositionY(), spellPosition.GetPositionZ(),
|
||||
spellPosition.GetOrientation(), 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.getX(), spellPosition.getY(), spellPosition.getZ(), spellPosition.getMapId());
|
||||
stayPosition.Set(spellPosition.GetPositionX(), spellPosition.GetPositionY(), spellPosition.GetPositionZ(), spellPosition.GetMapId());
|
||||
posMap["stay"] = stayPosition;
|
||||
}
|
||||
|
||||
if (bot->IsWithinLOS(spellPosition.getX(), spellPosition.getY(), spellPosition.getZ()))
|
||||
return MoveNear(spellPosition.getMapId(), spellPosition.getX(), spellPosition.getY(), spellPosition.getZ(), 0);
|
||||
if (bot->IsWithinLOS(spellPosition.GetPositionX(), spellPosition.GetPositionY(), spellPosition.GetPositionZ()))
|
||||
return MoveNear(spellPosition.GetMapId(), spellPosition.GetPositionX(), spellPosition.GetPositionY(), spellPosition.GetPositionZ(), 0);
|
||||
|
||||
return MoveTo(spellPosition.getMapId(), spellPosition.getX(), spellPosition.getY(), spellPosition.getZ(), false,
|
||||
return MoveTo(spellPosition.GetMapId(), spellPosition.GetPositionX(), spellPosition.GetPositionY(), spellPosition.GetPositionZ(), false,
|
||||
false);
|
||||
}
|
||||
|
||||
|
||||
@@ -46,7 +46,8 @@ bool RpgTaxiTrigger::IsActive()
|
||||
return false;
|
||||
|
||||
uint32 node =
|
||||
sObjectMgr->GetNearestTaxiNode(guidP.getX(), guidP.getY(), guidP.getZ(), guidP.getMapId(), bot->GetTeamId());
|
||||
sObjectMgr->GetNearestTaxiNode(guidP.GetPositionX(), guidP.GetPositionY(), guidP.GetPositionZ(),
|
||||
guidP.GetMapId(), bot->GetTeamId());
|
||||
|
||||
if (!node)
|
||||
return false;
|
||||
@@ -68,7 +69,8 @@ bool RpgDiscoverTrigger::IsActive()
|
||||
return false;
|
||||
|
||||
uint32 node =
|
||||
sObjectMgr->GetNearestTaxiNode(guidP.getX(), guidP.getY(), guidP.getZ(), guidP.getMapId(), bot->GetTeamId());
|
||||
sObjectMgr->GetNearestTaxiNode(guidP.GetPositionX(), guidP.GetPositionY(), guidP.GetPositionZ(),
|
||||
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(),
|
||||
|
||||
@@ -193,17 +193,18 @@ bool IckAndKrickAction::ExplosiveBarrage(bool explosiveBarrage, Unit* boss)
|
||||
{
|
||||
float angle = i * ANGLE_INCREMENT;
|
||||
Position potentialPos;
|
||||
potentialPos.m_positionX = bot->GetPositionX() + SAFE_DISTANCE * cos(angle);
|
||||
potentialPos.m_positionY = bot->GetPositionY() + SAFE_DISTANCE * sin(angle);
|
||||
potentialPos.m_positionZ = bot->GetPositionZ();
|
||||
potentialPos.Relocate(bot->GetPositionX() + SAFE_DISTANCE * cos(angle),
|
||||
bot->GetPositionY() + SAFE_DISTANCE * sin(angle),
|
||||
bot->GetPositionZ());
|
||||
|
||||
// Check if position is valid (not in a wall)
|
||||
if (!bot->IsWithinLOS(potentialPos.m_positionX, potentialPos.m_positionY, potentialPos.m_positionZ))
|
||||
if (!bot->IsWithinLOS(potentialPos.GetPositionX(), potentialPos.GetPositionY(),
|
||||
potentialPos.GetPositionZ()))
|
||||
continue;
|
||||
|
||||
// Check if position is within maximum allowed distance from boss
|
||||
if (boss && sqrt(pow(potentialPos.m_positionX - boss->GetPositionX(), 2) +
|
||||
pow(potentialPos.m_positionY - boss->GetPositionY(), 2)) > MAX_BOSS_DISTANCE)
|
||||
if (boss && sqrt(pow(potentialPos.GetPositionX() - boss->GetPositionX(), 2) +
|
||||
pow(potentialPos.GetPositionY() - boss->GetPositionY(), 2)) > MAX_BOSS_DISTANCE)
|
||||
continue;
|
||||
|
||||
// Score this position based on:
|
||||
@@ -216,8 +217,8 @@ bool IckAndKrickAction::ExplosiveBarrage(bool explosiveBarrage, Unit* boss)
|
||||
float minOrbDist = std::numeric_limits<float>::max();
|
||||
for (Unit* orb : orbs)
|
||||
{
|
||||
float orbDist = sqrt(pow(potentialPos.m_positionX - orb->GetPositionX(), 2) +
|
||||
pow(potentialPos.m_positionY - orb->GetPositionY(), 2));
|
||||
float orbDist = sqrt(pow(potentialPos.GetPositionX() - orb->GetPositionX(), 2) +
|
||||
pow(potentialPos.GetPositionY() - orb->GetPositionY(), 2));
|
||||
minOrbDist = std::min(minOrbDist, orbDist);
|
||||
}
|
||||
score += minOrbDist * 2.0f; // Weight orb distance more heavily
|
||||
@@ -225,16 +226,16 @@ bool IckAndKrickAction::ExplosiveBarrage(bool explosiveBarrage, Unit* boss)
|
||||
// Check distance from other players
|
||||
for (const Position& playerPos : playerPositions)
|
||||
{
|
||||
float playerDist = sqrt(pow(potentialPos.m_positionX - playerPos.m_positionX, 2) +
|
||||
pow(potentialPos.m_positionY - playerPos.m_positionY, 2));
|
||||
float playerDist = sqrt(pow(potentialPos.GetPositionX() - playerPos.GetPositionX(), 2) +
|
||||
pow(potentialPos.GetPositionY() - playerPos.GetPositionY(), 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.m_positionX - boss->GetPositionX(), 2) +
|
||||
pow(potentialPos.m_positionY - boss->GetPositionY(), 2));
|
||||
float bossDist = sqrt(pow(potentialPos.GetPositionX() - boss->GetPositionX(), 2) +
|
||||
pow(potentialPos.GetPositionY() - 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)
|
||||
@@ -257,7 +258,8 @@ 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.m_positionX, bestPos.m_positionY, bot->GetPositionZ(), false, false,
|
||||
return MoveTo(bot->GetMapId(), bestPos.GetPositionX(), bestPos.GetPositionY(), bot->GetPositionZ(), false,
|
||||
false,
|
||||
false, true, MovementPriority::MOVEMENT_COMBAT);
|
||||
}
|
||||
else
|
||||
|
||||
@@ -164,21 +164,21 @@ namespace GruulsLairHelpers
|
||||
{
|
||||
float angle = 2 * M_PI * i / NUM_POSITIONS;
|
||||
Position candidatePos;
|
||||
candidatePos.m_positionX = bot->GetPositionX() + SEARCH_RADIUS * cos(angle);
|
||||
candidatePos.m_positionY = bot->GetPositionY() + SEARCH_RADIUS * sin(angle);
|
||||
candidatePos.m_positionZ = bot->GetPositionZ();
|
||||
candidatePos.Relocate(bot->GetPositionX() + SEARCH_RADIUS * cos(angle),
|
||||
bot->GetPositionY() + SEARCH_RADIUS * sin(angle),
|
||||
bot->GetPositionZ());
|
||||
|
||||
float destX = candidatePos.m_positionX, destY = candidatePos.m_positionY, destZ = candidatePos.m_positionZ;
|
||||
float destX = candidatePos.GetPositionX();
|
||||
float destY = candidatePos.GetPositionY();
|
||||
float destZ = candidatePos.GetPositionZ();
|
||||
if (!bot->GetMap()->CheckCollisionAndGetValidCoords(bot, bot->GetPositionX(), bot->GetPositionY(),
|
||||
bot->GetPositionZ(), destX, destY, destZ, true))
|
||||
continue;
|
||||
|
||||
if (destX != candidatePos.m_positionX || destY != candidatePos.m_positionY)
|
||||
if (destX != candidatePos.GetPositionX() || destY != candidatePos.GetPositionY())
|
||||
continue;
|
||||
|
||||
candidatePos.m_positionX = destX;
|
||||
candidatePos.m_positionY = destY;
|
||||
candidatePos.m_positionZ = destZ;
|
||||
candidatePos.Relocate(destX, destY, destZ);
|
||||
|
||||
if (IsPositionSafe(botAI, bot, candidatePos))
|
||||
{
|
||||
|
||||
@@ -1551,8 +1551,10 @@ Position IccFestergutSporeAction::CalculateSpreadPosition()
|
||||
float angle = (bot->GetGUID().GetCounter() % 16) * (M_PI / 8);
|
||||
|
||||
Position spreadRangedPos = ICC_FESTERGUT_RANGED_SPORE;
|
||||
spreadRangedPos.m_positionX += cos(angle) * SPREAD_RADIUS;
|
||||
spreadRangedPos.m_positionY += sin(angle) * SPREAD_RADIUS;
|
||||
spreadRangedPos.Relocate(spreadRangedPos.GetPositionX() + cos(angle) * SPREAD_RADIUS,
|
||||
spreadRangedPos.GetPositionY() + sin(angle) * SPREAD_RADIUS,
|
||||
spreadRangedPos.GetPositionZ(),
|
||||
spreadRangedPos.GetOrientation());
|
||||
|
||||
return spreadRangedPos;
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -5192,8 +5192,9 @@ std::string const PlayerbotAI::HandleRemoteCommand(std::string const command)
|
||||
{
|
||||
LastMovement& data = *GetAiObjectContext()->GetValue<LastMovement&>("last movement");
|
||||
std::ostringstream out;
|
||||
out << data.lastMoveShort.getX() << " " << data.lastMoveShort.getY() << " " << data.lastMoveShort.getZ() << " "
|
||||
<< data.lastMoveShort.getMapId() << " " << data.lastMoveShort.getO();
|
||||
out << data.lastMoveShort.GetPositionX() << " " << data.lastMoveShort.GetPositionY() << " "
|
||||
<< data.lastMoveShort.GetPositionZ() << " " << data.lastMoveShort.GetMapId() << " "
|
||||
<< data.lastMoveShort.GetOrientation();
|
||||
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());
|
||||
@@ -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)->m_mapId == player->GetMapId())
|
||||
if (reaction > REP_NEUTRAL && dest->nearestPoint(&botPos)->GetMapId() == player->GetMapId())
|
||||
{
|
||||
botPos = *dest->nearestPoint(&botPos);
|
||||
break;
|
||||
|
||||
@@ -62,9 +62,9 @@ void FleeManager::calculatePossibleDestinations(std::vector<FleePoint*>& points)
|
||||
}
|
||||
Unit* target = *botAI->GetAiObjectContext()->GetValue<Unit*>("current target");
|
||||
|
||||
float botPosX = startPosition.getX();
|
||||
float botPosY = startPosition.getY();
|
||||
float botPosZ = startPosition.getZ();
|
||||
float botPosX = startPosition.GetPositionX();
|
||||
float botPosY = startPosition.GetPositionY();
|
||||
float botPosZ = startPosition.GetPositionZ();
|
||||
|
||||
FleePoint start(botAI, botPosX, botPosY, botPosZ);
|
||||
calculateDistanceToCreatures(&start);
|
||||
|
||||
@@ -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->getX() / size;
|
||||
i.m_positionY += j->getY() / size;
|
||||
i.m_positionZ += j->getZ() / size;
|
||||
i.NormalizeOrientation(i.m_orientation += j->getO() / size);
|
||||
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);
|
||||
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.getX() / size;
|
||||
i.m_positionY += j.getY() / size;
|
||||
i.m_positionZ += j.getZ() / size;
|
||||
i.NormalizeOrientation(i.m_orientation += j.getO() / size);
|
||||
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);
|
||||
return i;
|
||||
}));
|
||||
}
|
||||
@@ -190,16 +190,6 @@ 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;
|
||||
@@ -243,7 +233,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
|
||||
@@ -252,7 +242,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
|
||||
@@ -328,7 +318,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;
|
||||
@@ -348,7 +338,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;
|
||||
@@ -361,7 +351,7 @@ Map* WorldPosition::getMap()
|
||||
|
||||
float WorldPosition::getHeight() // remove const - whipowill
|
||||
{
|
||||
return getMap()->GetHeight(getX(), getY(), getZ());
|
||||
return getMap()->GetHeight(GetPositionX(), GetPositionY(), GetPositionZ());
|
||||
}
|
||||
|
||||
G3D::Vector3 WorldPosition::getVector3() { return G3D::Vector3(GetPositionX(), GetPositionY(), GetPositionZ()); }
|
||||
@@ -381,11 +371,11 @@ std::string const WorldPosition::print()
|
||||
std::string const WorldPosition::to_string()
|
||||
{
|
||||
std::stringstream out;
|
||||
out << m_mapId << '|';
|
||||
out << m_positionX << '|';
|
||||
out << m_positionY << '|';
|
||||
out << m_positionZ << '|';
|
||||
out << m_orientation;
|
||||
out << GetMapId() << '|';
|
||||
out << GetPositionX() << '|';
|
||||
out << GetPositionY() << '|';
|
||||
out << GetPositionZ() << '|';
|
||||
out << GetOrientation();
|
||||
return out.str();
|
||||
}
|
||||
|
||||
@@ -429,11 +419,14 @@ 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(), getX(), getY(), getZ()); }
|
||||
uint16 WorldPosition::getAreaId()
|
||||
{
|
||||
return sMapMgr->GetAreaId(PHASEMASK_NORMAL, GetMapId(), GetPositionX(), GetPositionY(), GetPositionZ());
|
||||
}
|
||||
|
||||
AreaTableEntry const* WorldPosition::getArea()
|
||||
{
|
||||
@@ -448,7 +441,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];
|
||||
}
|
||||
@@ -545,7 +538,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;
|
||||
@@ -566,7 +559,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;
|
||||
}
|
||||
@@ -618,7 +611,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;
|
||||
@@ -706,7 +699,7 @@ void WorldPosition::loadMapAndVMaps(WorldPosition secondPos)
|
||||
{
|
||||
for (auto& grid : getmGridCoords(secondPos))
|
||||
{
|
||||
loadMapAndVMap(getMapId(), grid.first, grid.second);
|
||||
loadMapAndVMap(GetMapId(), grid.first, grid.second);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -714,7 +707,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, getO()));
|
||||
retVec.push_back(WorldPosition(GetMapId(), p.x, p.y, p.z, GetOrientation()));
|
||||
|
||||
return retVec;
|
||||
}
|
||||
@@ -729,7 +722,7 @@ std::vector<WorldPosition> WorldPosition::getPathStepFrom(WorldPosition startPos
|
||||
loadMapAndVMaps(startPos);
|
||||
|
||||
PathGenerator path(bot);
|
||||
path.CalculatePath(startPos.getX(), startPos.getY(), startPos.getZ());
|
||||
path.CalculatePath(startPos.GetPositionX(), startPos.GetPositionY(), startPos.GetPositionZ());
|
||||
|
||||
Movement::PointsArray points = path.GetPath();
|
||||
PathType type = path.GetPathType();
|
||||
@@ -785,7 +778,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;
|
||||
@@ -818,10 +811,18 @@ bool WorldPosition::GetReachableRandomPointOnGround(Player* bot, float radius, b
|
||||
{
|
||||
radius *= randomRange ? rand_norm() : 1.f;
|
||||
float angle = rand_norm() * static_cast<float>(2 * M_PI);
|
||||
m_positionX += radius * cosf(angle);
|
||||
m_positionY += radius * sinf(angle);
|
||||
setX(GetPositionX() + radius * cosf(angle));
|
||||
setY(GetPositionY() + radius * sinf(angle));
|
||||
|
||||
return getMap()->CanReachPositionAndGetValidCoords(bot, m_positionX, m_positionY, m_positionZ);
|
||||
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;
|
||||
}
|
||||
|
||||
uint32 WorldPosition::getUnitsAggro(GuidVector& units, Player* bot)
|
||||
@@ -844,7 +845,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))
|
||||
{
|
||||
@@ -855,7 +856,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))
|
||||
{
|
||||
@@ -3223,7 +3224,8 @@ 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;
|
||||
@@ -3235,7 +3237,7 @@ void TravelMgr::LoadQuestTravelTable()
|
||||
|
||||
out << "\"center\""
|
||||
<< ",";
|
||||
out << points.begin()->getMapId() << ",";
|
||||
out << points.begin()->GetMapId() << ",";
|
||||
out << points.begin()->getAreaName() << ",";
|
||||
out << points.begin()->getAreaName(true, true) << ",";
|
||||
|
||||
@@ -3245,7 +3247,7 @@ void TravelMgr::LoadQuestTravelTable()
|
||||
|
||||
out << "\"area\""
|
||||
<< ",";
|
||||
out << points.begin()->getMapId() << ",";
|
||||
out << points.begin()->GetMapId() << ",";
|
||||
out << points.begin()->getAreaName() << ",";
|
||||
out << points.begin()->getAreaName(true, true) << ",";
|
||||
|
||||
@@ -3613,17 +3615,18 @@ void TravelMgr::LoadQuestTravelTable()
|
||||
if (!pos->getMap())
|
||||
continue;
|
||||
|
||||
float nx = pos->getX() + (x*5)-5000.0f;
|
||||
float ny = pos->getY() + (y*5)-5000.0f;
|
||||
float nz = pos->getZ() + 100.0f;
|
||||
float nx = pos->GetPositionX() + (x * 5) - 5000.0f;
|
||||
float ny = pos->GetPositionY() + (y * 5) - 5000.0f;
|
||||
float nz = pos->GetPositionZ() + 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.getX(), npos.getY(), npos.getZ());
|
||||
WorldPosition npos = WorldPosition(pos->GetMapId(), nx, ny, nz, 0.0);
|
||||
uint32 area = path.getArea(npos.GetMapId(), npos.GetPositionX(), npos.GetPositionY(),
|
||||
npos.GetPositionZ());
|
||||
|
||||
std::ostringstream out;
|
||||
out << std::fixed << area << "," << npos.getDisplayX() << "," << npos.getDisplayY();
|
||||
@@ -3647,7 +3650,8 @@ 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->getX() << "," << j->getY() << "," << j->getZ(); sPlayerbotAIConfig.log(5,
|
||||
"," << j->getDisplayY() << "," << j->GetPositionX() << "," << j->GetPositionY() << "," << j->GetPositionZ();
|
||||
sPlayerbotAIConfig.log(5,
|
||||
out.str().c_str());
|
||||
}
|
||||
}
|
||||
@@ -4087,8 +4091,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;
|
||||
@@ -4121,7 +4125,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)}});
|
||||
@@ -4142,8 +4146,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);
|
||||
@@ -4167,8 +4171,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,12 +120,6 @@ 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();
|
||||
|
||||
@@ -185,29 +179,29 @@ public:
|
||||
// Quick square distance in 2d plane.
|
||||
float sqDistance2d(WorldPosition center)
|
||||
{
|
||||
return (getX() - center.getX()) * (getX() - center.getX()) +
|
||||
(getY() - center.getY()) * (getY() - center.getY());
|
||||
return (GetPositionX() - center.GetPositionX()) * (GetPositionX() - center.GetPositionX()) +
|
||||
(GetPositionY() - center.GetPositionY()) * (GetPositionY() - center.GetPositionY());
|
||||
}
|
||||
|
||||
// Quick square distance calculation without map check. Used for getting the minimum distant points.
|
||||
float sqDistance(WorldPosition center)
|
||||
{
|
||||
return (getX() - center.getX()) * (getX() - center.getX()) +
|
||||
(getY() - center.getY()) * (getY() - center.getY()) +
|
||||
(getZ() - center.getZ()) * (getZ() - center.getZ());
|
||||
return (GetPositionX() - center.GetPositionX()) * (GetPositionX() - center.GetPositionX()) +
|
||||
(GetPositionY() - center.GetPositionY()) * (GetPositionY() - center.GetPositionY()) +
|
||||
(GetPositionZ() - center.GetPositionZ()) * (GetPositionZ() - center.GetPositionZ());
|
||||
}
|
||||
|
||||
float sqDistance2d(WorldPosition* center)
|
||||
{
|
||||
return (getX() - center->getX()) * (getX() - center->getX()) +
|
||||
(getY() - center->getY()) * (getY() - center->getY());
|
||||
return (GetPositionX() - center->GetPositionX()) * (GetPositionX() - center->GetPositionX()) +
|
||||
(GetPositionY() - center->GetPositionY()) * (GetPositionY() - center->GetPositionY());
|
||||
}
|
||||
|
||||
float sqDistance(WorldPosition* center)
|
||||
{
|
||||
return (getX() - center->getX()) * (getX() - center->getX()) +
|
||||
(getY() - center->getY()) * (getY() - center->getY()) +
|
||||
(getZ() - center->getZ()) * (getZ() - center->getZ());
|
||||
return (GetPositionX() - center->GetPositionX()) * (GetPositionX() - center->GetPositionX()) +
|
||||
(GetPositionY() - center->GetPositionY()) * (GetPositionY() - center->GetPositionY()) +
|
||||
(GetPositionZ() - center->GetPositionZ()) * (GetPositionZ() - center->GetPositionZ());
|
||||
}
|
||||
|
||||
// Returns the closest point of the list. Fast but only works for the same map.
|
||||
@@ -227,7 +221,7 @@ public:
|
||||
|
||||
float getAngleTo(WorldPosition endPos)
|
||||
{
|
||||
float ang = atan2(endPos.getY() - getY(), endPos.getX() - getX());
|
||||
float ang = atan2(endPos.GetPositionY() - GetPositionY(), endPos.GetPositionX() - GetPositionX());
|
||||
return (ang >= 0) ? ang : 2 * static_cast<float>(M_PI) + ang;
|
||||
}
|
||||
|
||||
@@ -238,7 +232,8 @@ public:
|
||||
|
||||
float mSign(WorldPosition* p1, WorldPosition* p2)
|
||||
{
|
||||
return (getX() - p2->getX()) * (p1->getY() - p2->getY()) - (p1->getX() - p2->getX()) * (getY() - p2->getY());
|
||||
return (GetPositionX() - p2->GetPositionX()) * (p1->GetPositionY() - p2->GetPositionY()) -
|
||||
(p1->GetPositionX() - p2->GetPositionX()) * (GetPositionY() - p2->GetPositionY());
|
||||
}
|
||||
|
||||
bool isInside(WorldPosition* p1, WorldPosition* p2, WorldPosition* p3);
|
||||
@@ -251,18 +246,23 @@ public:
|
||||
|
||||
std::set<Transport*> getTransports(uint32 entry = 0);
|
||||
|
||||
GridCoord getGridCoord() { return Acore::ComputeGridCoord(getX(), getY()); };
|
||||
CellCoord getCellCoord() { return Acore::ComputeCellCoord(GetPositionX(), GetPositionY()); }
|
||||
GridCoord getGridCoord()
|
||||
{
|
||||
CellCoord cellCoord = getCellCoord();
|
||||
Cell cell(cellCoord);
|
||||
return GridCoord(cell.GridX(), cell.GridY());
|
||||
}
|
||||
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 - getX() / SIZE_OF_GRIDS),
|
||||
(int32)(CENTER_GRID_ID - getY() / SIZE_OF_GRIDS));
|
||||
return std::make_pair((int32)(CENTER_GRID_ID - GetPositionX() / SIZE_OF_GRIDS),
|
||||
(int32)(CENTER_GRID_ID - GetPositionY() / 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().getY() * -1.0; }
|
||||
float getDisplayX() { return getDisplayLocation().GetPositionY() * -1.0; }
|
||||
|
||||
float getDisplayY() { return getDisplayLocation().getX(); }
|
||||
float getDisplayY() { return getDisplayLocation().GetPositionX(); }
|
||||
|
||||
uint16 getAreaId();
|
||||
AreaTableEntry const* getArea();
|
||||
@@ -334,11 +334,11 @@ private:
|
||||
|
||||
inline ByteBuffer& operator<<(ByteBuffer& b, WorldPosition& guidP)
|
||||
{
|
||||
b << guidP.getMapId();
|
||||
b << guidP.getX();
|
||||
b << guidP.getY();
|
||||
b << guidP.getZ();
|
||||
b << guidP.getO();
|
||||
b << guidP.GetMapId();
|
||||
b << guidP.GetPositionX();
|
||||
b << guidP.GetPositionY();
|
||||
b << guidP.GetPositionZ();
|
||||
b << guidP.GetOrientation();
|
||||
b << guidP.getVisitors();
|
||||
return b;
|
||||
}
|
||||
@@ -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);
|
||||
@@ -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);
|
||||
}
|
||||
@@ -1787,8 +1787,9 @@ void TravelNodeMap::generateTransportNodes()
|
||||
float dy = -1 * p.second->Y;
|
||||
|
||||
WorldPosition pos =
|
||||
WorldPosition(basePos.getMapId(), basePos.getX() + dx, basePos.getY() + dy,
|
||||
basePos.getZ() + p.second->Z, basePos.getO());
|
||||
WorldPosition(basePos.GetMapId(), basePos.GetPositionX() + dx,
|
||||
basePos.GetPositionY() + dy, basePos.GetPositionZ() + p.second->Z,
|
||||
basePos.GetOrientation());
|
||||
|
||||
if (prevNode)
|
||||
{
|
||||
@@ -1830,8 +1831,9 @@ void TravelNodeMap::generateTransportNodes()
|
||||
float dx = -1 * p.second->X;
|
||||
float dy = -1 * p.second->Y;
|
||||
WorldPosition pos =
|
||||
WorldPosition(basePos.getMapId(), basePos.getX() + dx, basePos.getY() + dy,
|
||||
basePos.getZ() + p.second->Z, basePos.getO());
|
||||
WorldPosition(basePos.GetMapId(), basePos.GetPositionX() + dx,
|
||||
basePos.GetPositionY() + dy, basePos.GetPositionZ() + p.second->Z,
|
||||
basePos.GetOrientation());
|
||||
|
||||
ppath.push_back(pos);
|
||||
|
||||
@@ -2356,10 +2358,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.getX());
|
||||
stmt->SetData(5, point.getY());
|
||||
stmt->SetData(6, point.getZ());
|
||||
stmt->SetData(3, point.GetMapId());
|
||||
stmt->SetData(4, point.GetPositionX());
|
||||
stmt->SetData(5, point.GetPositionY());
|
||||
stmt->SetData(6, point.GetPositionZ());
|
||||
trans->Append(stmt);
|
||||
|
||||
points++;
|
||||
@@ -2516,10 +2518,10 @@ void TravelNodeMap::calcMapOffset()
|
||||
}
|
||||
else
|
||||
{
|
||||
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()));
|
||||
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()));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2533,14 +2535,15 @@ void TravelNodeMap::calcMapOffset()
|
||||
for (auto& mapId : mapIds)
|
||||
{
|
||||
mapOffsets.push_back(std::make_pair(
|
||||
mapId, WorldPosition(mapId, curPos.getX() - min[i].getX(), curPos.getY() - max[i].getY(), 0, 0)));
|
||||
mapId, WorldPosition(mapId, curPos.GetPositionX() - min[i].GetPositionX(),
|
||||
curPos.GetPositionY() - max[i].GetPositionY(), 0, 0)));
|
||||
|
||||
maxY = std::max(maxY, (max[i].getY() - min[i].getY() + 500));
|
||||
curPos.setX(curPos.getX() + (max[i].getX() - min[i].getX() + 500));
|
||||
maxY = std::max(maxY, (max[i].GetPositionY() - min[i].GetPositionY() + 500));
|
||||
curPos.setX(curPos.GetPositionX() + (max[i].GetPositionX() - min[i].GetPositionX() + 500));
|
||||
|
||||
if (curPos.getX() > endPos.getX())
|
||||
if (curPos.GetPositionX() > endPos.GetPositionX())
|
||||
{
|
||||
curPos.setY(curPos.getY() - maxY);
|
||||
curPos.setY(curPos.GetPositionY() - maxY);
|
||||
curPos.setX(-13000);
|
||||
}
|
||||
|
||||
|
||||
@@ -251,11 +251,11 @@ public:
|
||||
}
|
||||
|
||||
// WorldLocation shortcuts
|
||||
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(); }
|
||||
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(); }
|
||||
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()); }
|
||||
|
||||
Reference in New Issue
Block a user