mirror of
https://github.com/mod-playerbots/mod-playerbots
synced 2025-11-29 15:58:20 +08:00
Update TeleportAction.cpp
Add alternative method for finding and using portals. Works with first boss of Sunwell Plateau, Kalecgos, using the Spectral Rifts.
This commit is contained in:
@@ -11,6 +11,54 @@
|
|||||||
|
|
||||||
bool TeleportAction::Execute(Event event)
|
bool TeleportAction::Execute(Event event)
|
||||||
{
|
{
|
||||||
|
// List of allowed portal entries (you can populate this dynamically)
|
||||||
|
std::vector<uint32> allowedPortals = {
|
||||||
|
187055, 195142, 195141, 201797, 202079, 194481, 195682, 191164, 176498, 182351,
|
||||||
|
178404, 176497, 181146, 184605, 176499, 195140, 193948, 193427, 193052, 193206,
|
||||||
|
192786, 184594, 183384, 182352, 184604, 189994, 193053, 193207, 193956, 195139,
|
||||||
|
176296, 194011, 194012, 189993, 176500, 176501, 193955, 193425, 193772, 193604,
|
||||||
|
191006, 191007, 191008, 191009, 191013, 191014, 191010, 190960, 191011, 191012,
|
||||||
|
183317, 183321, 183322, 187056, 183323, 183324, 183325, 183326, 183327, 190203,
|
||||||
|
190204, 190205, 190206
|
||||||
|
};
|
||||||
|
|
||||||
|
// Try teleporting using allowed portals
|
||||||
|
GuidVector closeObjects = *context->GetValue<GuidVector>("nearest game objects no los");
|
||||||
|
GameObject* closestPortal = nullptr;
|
||||||
|
float closestDistance = 100.0f;
|
||||||
|
|
||||||
|
for (ObjectGuid const& guid : closeObjects)
|
||||||
|
{
|
||||||
|
GameObject* go = botAI->GetGameObject(guid);
|
||||||
|
if (!go)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
// Check if the game object entry is in the allowed portals list
|
||||||
|
if (std::find(allowedPortals.begin(), allowedPortals.end(), go->GetEntry()) != allowedPortals.end())
|
||||||
|
{
|
||||||
|
float tempDist = bot->GetDistance(go);
|
||||||
|
|
||||||
|
if (tempDist < closestDistance)
|
||||||
|
{
|
||||||
|
closestDistance = tempDist;
|
||||||
|
closestPortal = go;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// If a nearby portal is found, use it
|
||||||
|
if (closestPortal && bot->IsWithinDistInMap(closestPortal, INTERACTION_DISTANCE))
|
||||||
|
{
|
||||||
|
std::ostringstream out;
|
||||||
|
out << "Using portal: " << closestPortal->GetName();
|
||||||
|
botAI->TellMasterNoFacing(out.str());
|
||||||
|
|
||||||
|
WorldPacket data(CMSG_GAMEOBJ_USE);
|
||||||
|
data << closestPortal->GetGUID();
|
||||||
|
bot->GetSession()->HandleGameObjectUseOpcode(data);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
// If no portal was found, fallback to spellcaster-type game objects
|
||||||
GuidVector gos = *context->GetValue<GuidVector>("nearest game objects");
|
GuidVector gos = *context->GetValue<GuidVector>("nearest game objects");
|
||||||
for (ObjectGuid const guid : gos)
|
for (ObjectGuid const guid : gos)
|
||||||
{
|
{
|
||||||
@@ -40,7 +88,8 @@ bool TeleportAction::Execute(Event event)
|
|||||||
spell->cast(true);
|
spell->cast(true);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If no game objects were found, try using the last area trigger
|
||||||
LastMovement& movement = context->GetValue<LastMovement&>("last area trigger")->Get();
|
LastMovement& movement = context->GetValue<LastMovement&>("last area trigger")->Get();
|
||||||
if (movement.lastAreaTrigger)
|
if (movement.lastAreaTrigger)
|
||||||
{
|
{
|
||||||
@@ -53,6 +102,7 @@ bool TeleportAction::Execute(Event event)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If no teleport option is found
|
||||||
botAI->TellError("Cannot find any portal to teleport");
|
botAI->TellError("Cannot find any portal to teleport");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user