miscs(raid strategy, distance triggers, etc)

This commit is contained in:
Yunfan Li
2023-06-06 00:11:35 +08:00
parent 516366a74d
commit 98e46a3d02
32 changed files with 2711 additions and 76 deletions

View File

@@ -57,6 +57,7 @@
#include "XpGainAction.h"
#include "VehicleActions.h"
#include "WorldBuffAction.h"
#include "RaidNaxxAction.h"
class PlayerbotAI;
@@ -221,6 +222,42 @@ class ActionContext : public NamedObjectContext<Action>
creators["rpg mount anim"] = &ActionContext::rpg_mount_anim;
creators["toggle pet spell"] = &ActionContext::toggle_pet_spell;
// creators["rotate grobbulus"] = &ActionContext::rotate_grobbulus;
// creators["grobbulus move center"] = &ActionContext::grobbulus_move_center;
creators["heigan dance melee"] = &ActionContext::heigan_dance_melee;
creators["heigan dance ranged"] = &ActionContext::heigan_dance_ranged;
// creators["thaddius attack nearest pet"] = &ActionContext::thaddius_attack_nearest_pet;
// creators["thaddius melee to place"] = &ActionContext::thaddius_tank_to_place;
// creators["thaddius ranged to place"] = &ActionContext::thaddius_ranged_to_place;
// creators["thaddius move to platform"] = &ActionContext::thaddius_move_to_platform;
// creators["thaddius move polarity"] = &ActionContext::thaddius_move_polarity;
// creators["razuvious use obedience crystal"] = &ActionContext::razuvious_use_obedience_crystal;
// creators["razuvious target"] = &ActionContext::razuvious_target;
// creators["horseman attract alternatively"] = &ActionContext::horseman_attract_alternatively;
// creators["horseman attack in order"] = &ActionContext::horseman_attack_in_order;
// creators["sapphiron ground main tank position"] = &ActionContext::sapphiron_ground_main_tank_position;
// creators["sapphiron ground position"] = &ActionContext::sapphiron_ground_position;
// creators["sapphiron flight position"] = &ActionContext::sapphiron_flight_position;
// creators["sapphiron avoid chill"] = &ActionContext::sapphiron_avoid_chill;
// creators["kel'thuzad choose target"] = &ActionContext::kelthuzad_choose_target;
// creators["kel'thuzad position"] = &ActionContext::kelthuzad_position;
// creators["anub'rekhan choose target"] = &ActionContext::anubrekhan_choose_target;
// creators["anub'rekhan position"] = &ActionContext::anubrekhan_position;
// creators["gluth choose target"] = &ActionContext::gluth_choose_target;
// creators["gluth position"] = &ActionContext::gluth_position;
// creators["gluth slowdown"] = &ActionContext::gluth_slowdown;
// creators["loatheb position"] = &ActionContext::loatheb_position;
// creators["loatheb choose target"] = &ActionContext::loatheb_choose_target;
}
private:
@@ -382,6 +419,33 @@ class ActionContext : public NamedObjectContext<Action>
static Action* rpg_mount_anim(PlayerbotAI* botAI) { return new RpgMountAnimAction(botAI); }
static Action* toggle_pet_spell(PlayerbotAI* ai) { return new TogglePetSpellAutoCastAction(ai); }
// static Action* rotate_grobbulus(PlayerbotAI* ai) { return new RotateGrobbulusAction(ai); }
// static Action* grobbulus_move_center(PlayerbotAI* ai) { return new GrobblulusMoveCenterAction(ai); }
static Action* heigan_dance_melee(PlayerbotAI* ai) { return new HeiganDanceMeleeAction(ai); }
static Action* heigan_dance_ranged(PlayerbotAI* ai) { return new HeiganDanceRangedAction(ai); }
// static Action* thaddius_attack_nearest_pet(PlayerbotAI* ai) { return new ThaddiusAttackNearestPetAction(ai); }
// static Action* thaddius_tank_to_place(PlayerbotAI* ai) { return new ThaddiusMeleeToPlaceAction(ai); }
// static Action* thaddius_ranged_to_place(PlayerbotAI* ai) { return new ThaddiusRangedToPlaceAction(ai); }
// static Action* thaddius_move_to_platform(PlayerbotAI* ai) { return new ThaddiusMoveToPlatformAction(ai); }
// static Action* thaddius_move_polarity(PlayerbotAI* ai) { return new ThaddiusMovePolarityAction(ai); }
// static Action* razuvious_target(PlayerbotAI* ai) { return new RazuviousTargetAction(ai); }
// static Action* razuvious_use_obedience_crystal(PlayerbotAI* ai) { return new RazuviousUseObedienceCrystalAction(ai); }
// static Action* horseman_attract_alternatively(PlayerbotAI* ai) { return new HorsemanAttractAlternativelyAction(ai); }
// static Action* horseman_attack_in_order(PlayerbotAI* ai) { return new HorsemanAttactInOrderAction(ai); }
// static Action* sapphiron_ground_main_tank_position(PlayerbotAI* ai) { return new SapphironGroundMainTankPositionAction(ai); }
// static Action* sapphiron_ground_position(PlayerbotAI* ai) { return new SapphironGroundPositionAction(ai); }
// static Action* sapphiron_flight_position(PlayerbotAI* ai) { return new SapphironFlightPositionAction(ai); }
// static Action* sapphiron_avoid_chill(PlayerbotAI* ai) { return new SapphironAvoidChillAction(ai); }
// static Action* kelthuzad_choose_target(PlayerbotAI* ai) { return new KelthuzadChooseTargetAction(ai); }
// static Action* kelthuzad_position(PlayerbotAI* ai) { return new KelthuzadPositionAction(ai); }
// static Action* anubrekhan_choose_target(PlayerbotAI* ai) { return new AnubrekhanChooseTargetAction(ai); }
// static Action* anubrekhan_position(PlayerbotAI* ai) { return new AnubrekhanPositionAction(ai); }
// static Action* gluth_choose_target(PlayerbotAI* ai) { return new GluthChooseTargetAction(ai); }
// static Action* gluth_position(PlayerbotAI* ai) { return new GluthPositionAction(ai); }
// static Action* gluth_slowdown(PlayerbotAI* ai) { return new GluthSlowdownAction(ai); }
// static Action* loatheb_position(PlayerbotAI* ai) { return new LoathebPositionAction(ai); }
// static Action* loatheb_choose_target(PlayerbotAI* ai) { return new LoathebChooseTargetAction(ai); }
};
#endif

View File

@@ -108,11 +108,11 @@ bool CastSpellAction::isUseful()
if (!spellTarget->IsInWorld() || spellTarget->GetMapId() != bot->GetMapId())
return false;
float combatReach = bot->GetCombatReach() + spellTarget->GetCombatReach();
if (!botAI->IsRanged(bot))
combatReach += 4.0f / 3.0f;
// float combatReach = bot->GetCombatReach() + spellTarget->GetCombatReach();
// if (!botAI->IsRanged(bot))
// combatReach += 4.0f / 3.0f;
return spellTarget && AI_VALUE2(bool, "spell cast useful", spell) && sServerFacade->GetDistance2d(bot, spellTarget) <= (range + combatReach);
return spellTarget && AI_VALUE2(bool, "spell cast useful", spell); // && sServerFacade->GetDistance2d(bot, spellTarget) <= (range + combatReach);
}
CastMeleeSpellAction::CastMeleeSpellAction(PlayerbotAI* botAI, std::string const spell) : CastSpellAction(botAI, spell)

View File

@@ -128,6 +128,43 @@ bool MovementAction::MoveToLOS(WorldObject* target, bool ranged)
bool MovementAction::MoveTo(uint32 mapId, float x, float y, float z, bool idle, bool react)
{
// if (!IsMovingAllowed(mapId, x, y, z))
// return false;
// bot->UpdateGroundPositionZ(x, y, z);
// float distance = bot->GetDistance2d(x, y);
// if (distance > sPlayerbotAIConfig->contactDistance)
// {
// WaitForReach(distance);
// if (bot->IsSitState())
// bot->SetStandState(UNIT_STAND_STATE_STAND);
// if (bot->IsNonMeleeSpellCast(true))
// {
// bot->CastStop();
// botAI->InterruptSpell();
// }
// bool generatePath = !bot->HasAuraType(SPELL_AURA_MOD_INCREASE_MOUNTED_FLIGHT_SPEED) &&
// !bot->IsFlying() && !bot->IsUnderWater();
// MotionMaster &mm = *bot->GetMotionMaster();
// mm.Clear();
// // float botZ = bot->GetPositionZ();
// // if (!bot->InBattleground() && z - botZ > 0.5f && bot->GetDistance2d(x, y) <= 5.0f)
// // {
// // float speed = bot->GetSpeed(MOVE_RUN);
// // mm.MoveJump(x, y, botZ + 0.5f, speed, speed, 1);
// // }
// // else
// mm.MovePoint(mapId, x, y, z, generatePath);
// AI_VALUE(LastMovement&, "last movement").Set(mapId, x, y, z, bot->GetOrientation());
// return true;
// }
// return false;
UpdateMovementState();
// LOG_DEBUG("playerbots", "IsMovingAllowed {}", IsMovingAllowed());
if (!IsMovingAllowed())
@@ -507,20 +544,20 @@ bool MovementAction::MoveTo(uint32 mapId, float x, float y, float z, bool idle,
*/
// Clean movement if not already moving the same way.
if (mover->GetMotionMaster()->GetCurrentMovementGeneratorType() != POINT_MOTION_TYPE)
{
mover->StopMoving();
mover->GetMotionMaster()->Clear();
}
else
{
mover->GetMotionMaster()->GetDestination(x, y, z);
if (movePosition.distance(WorldPosition(movePosition.getMapId(), x, y, z, 0)) > minDist)
{
mover->StopMoving();
mover->GetMotionMaster()->Clear();
}
}
// if (mover->GetMotionMaster()->GetCurrentMovementGeneratorType() != POINT_MOTION_TYPE)
// {
// mover->StopMoving();
// mover->GetMotionMaster()->Clear();
// }
// else
// {
// mover->GetMotionMaster()->GetDestination(x, y, z);
// if (movePosition.distance(WorldPosition(movePosition.getMapId(), x, y, z, 0)) > minDist)
// {
// mover->StopMoving();
// mover->GetMotionMaster()->Clear();
// }
// }
if (totalDistance > maxDist && !detailedMove && !botAI->HasPlayerNearby(&movePosition)) // Why walk if you can fly?
{
@@ -549,6 +586,7 @@ bool MovementAction::MoveTo(uint32 mapId, float x, float y, float z, bool idle,
{
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());
}
else
@@ -595,6 +633,7 @@ 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());
}
@@ -1221,6 +1260,14 @@ bool MovementAction::MoveAway(Unit* target)
return MoveTo(target->GetMapId(), dx, dy, dz);
}
bool MovementAction::MoveInside(uint32 mapId, float x, float y, float z, float distance)
{
if (bot->GetDistance2d(x, y) <= distance) {
return false;
}
return MoveNear(mapId, x, y, z, distance);
}
bool FleeAction::Execute(Event event)
{
// return Flee(AI_VALUE(Unit*, "current target"));

View File

@@ -37,6 +37,7 @@ class MovementAction : public Action
void ClearIdleState();
void UpdateMovementState();
bool MoveAway(Unit* target);
bool MoveInside(uint32 mapId, float x, float y, float z, float distance = sPlayerbotAIConfig->followDistance);
void CreateWp(Player* wpOwner, float x, float y, float z, float o, uint32 entry, bool important = false);
};

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,318 @@
#ifndef _PLAYERBOT_RAIDNAXXACTION_H
#define _PLAYERBOT_RAIDNAXXACTION_H
#include "Action.h"
#include "MovementActions.h"
#include "AttackAction.h"
#include "GenericActions.h"
// just for test
// class TryToGetBossAIAction : public Action
// {
// public:
// TryToGetBossAIAction(PlayerbotAI* ai) : Action(ai, "try to get boss ai") {}
// public:
// virtual bool Execute(Event event);
// };
// class GoBehindTheBossAction : public MovementAction
// {
// public:
// GoBehindTheBossAction(PlayerbotAI* ai, float distance = 24.0f, float delta_angle = M_PI / 8) : MovementAction(ai, "grobbulus go behind the boss") {
// this->distance = distance;
// this->delta_angle = delta_angle;
// }
// virtual bool Execute(Event event);
// protected:
// float distance, delta_angle;
// };
// class MoveToPointForceAction : public MovementAction
// {
// public:
// MoveToPointForceAction(PlayerbotAI* ai, float x, float y) : MovementAction(ai, "move to point force") {
// this->x = x;
// this->y = y;
// }
// virtual bool Execute(Event event);
// protected:
// float x, y;
// };
// class MoveInsideAction : public MovementAction
// {
// public:
// MoveInsideAction(PlayerbotAI* ai, float x, float y, float distance = 5.0f) : MovementAction(ai, "move inside") {
// this->x = x;
// this->y = y;
// this->distance = distance;
// }
// virtual bool Execute(Event event);
// protected:
// float x, y, distance;
// };
// class RotateAroundTheCenterPointAction : public MovementAction
// {
// public:
// RotateAroundTheCenterPointAction(PlayerbotAI* ai, string name,
// float center_x, float center_y, float radius = 40.0f,
// uint32 intervals = 16, bool clockwise = true, float start_angle = 0) : MovementAction(ai, name) {
// this->center_x = center_x;
// this->center_y = center_y;
// this->radius = radius;
// this->intervals = intervals;
// this->clockwise = clockwise;
// this->call_counters = 0;
// for (int i = 0; i < intervals; i++) {
// float angle = start_angle + 2 * M_PI * i / intervals;
// waypoints.push_back(std::make_pair(center_x + cos(angle) * radius, center_y + sin(angle) * radius));
// }
// }
// virtual bool Execute(Event event);
// protected:
// virtual uint32 GetCurrWaypoint() { return 0; }
// uint32 FindNearestWaypoint();
// float center_x, center_y, radius;
// uint32 intervals, call_counters;
// bool clockwise;
// std::vector<std::pair<float, float>> waypoints;
// };
// class RotateGrobbulusAction : public RotateAroundTheCenterPointAction
// {
// public:
// RotateGrobbulusAction(PlayerbotAI* ai): RotateAroundTheCenterPointAction(ai, "rotate grobbulus", 3281.23f, -3310.38f, 35.0f, 8, true, M_PI) {}
// virtual bool isUseful() {
// return RotateAroundTheCenterPointAction::isUseful() && ai->IsMainTank(bot) && AI_VALUE2(bool, "has aggro", "boss target");
// }
// virtual uint32 GetCurrWaypoint();
// protected:
// };
// class GrobblulusMoveCenterAction : public MoveInsideAction
// {
// public:
// GrobblulusMoveCenterAction(PlayerbotAI* ai) : MoveInsideAction(ai, 3281.23f, -3310.38f, 5.0f) {}
// };
class HeiganDanceAction : public MovementAction
{
public:
HeiganDanceAction(PlayerbotAI* ai) : MovementAction(ai, "heigan dance") {
this->prev_phase = 0;
this->prev_erupt = 0;
this->prev_timer = 0;
waypoints.push_back(std::make_pair(2793.58f, -3665.93f));
waypoints.push_back(std::make_pair(2775.49f, -3674.43f));
waypoints.push_back(std::make_pair(2762.30f, -3684.59f));
waypoints.push_back(std::make_pair(2755.99f, -3703.96f));
}
protected:
bool CalculateSafe();
void ResetSafe() { curr_safe = 0; curr_dir = 1; }
void NextSafe() { curr_safe += curr_dir; if (curr_safe == 3 || curr_safe == 0) { curr_dir = -curr_dir; } }
uint32 prev_phase, prev_erupt, prev_timer;
uint32 curr_safe, curr_dir;
std::vector<std::pair<float, float>> waypoints;
};
class HeiganDanceMeleeAction : public HeiganDanceAction
{
public:
HeiganDanceMeleeAction(PlayerbotAI* ai) : HeiganDanceAction(ai) {}
virtual bool Execute(Event event);
};
class HeiganDanceRangedAction : public HeiganDanceAction
{
public:
HeiganDanceRangedAction(PlayerbotAI* ai) : HeiganDanceAction(ai) {
platform = std::make_pair(2794.26f, -3706.67f);
}
virtual bool Execute(Event event);
protected:
std::pair<float, float> platform;
};
// class ThaddiusAttackNearestPetAction : public AttackAction
// {
// public:
// ThaddiusAttackNearestPetAction(PlayerbotAI* ai) : AttackAction(ai, "thaddius attack nearest pet") {}
// virtual bool Execute(Event event);
// virtual bool isUseful();
// };
// class ThaddiusMeleeToPlaceAction : public MovementAction
// {
// public:
// ThaddiusMeleeToPlaceAction(PlayerbotAI* ai) : MovementAction(ai, "thaddius melee to place") {}
// virtual bool Execute(Event event);
// virtual bool isUseful();
// };
// class ThaddiusRangedToPlaceAction : public MovementAction
// {
// public:
// ThaddiusRangedToPlaceAction(PlayerbotAI* ai) : MovementAction(ai, "thaddius ranged to place") {}
// virtual bool Execute(Event event);
// virtual bool isUseful();
// };
// class ThaddiusMoveToPlatformAction : public MovementAction
// {
// public:
// ThaddiusMoveToPlatformAction(PlayerbotAI* ai) : MovementAction(ai, "thaddius move to platform") {}
// virtual bool Execute(Event event);
// virtual bool isUseful();
// };
// class ThaddiusMovePolarityAction : public MovementAction
// {
// public:
// ThaddiusMovePolarityAction(PlayerbotAI* ai) : MovementAction(ai, "thaddius move polarity") {}
// virtual bool Execute(Event event);
// virtual bool isUseful();
// };
// class RazuviousUseObedienceCrystalAction : public MovementAction
// {
// public:
// RazuviousUseObedienceCrystalAction(PlayerbotAI* ai) : MovementAction(ai, "razuvious use obedience crystal") {}
// virtual bool Execute(Event event);
// };
// class RazuviousTargetAction : public AttackAction
// {
// public:
// RazuviousTargetAction(PlayerbotAI* ai) : AttackAction(ai, "razuvious target") {}
// virtual bool Execute(Event event);
// };
// class HorsemanAttractAlternativelyAction : public AttackAction
// {
// public:
// HorsemanAttractAlternativelyAction(PlayerbotAI* ai) : AttackAction(ai, "horseman attract alternatively") {
// this->last_voidzone = 0;
// this->voidzone_counter = 0;
// }
// virtual bool Execute(Event event);
// protected:
// uint32 last_voidzone, voidzone_counter;
// };
// class HorsemanAttactInOrderAction : public AttackAction
// {
// public:
// HorsemanAttactInOrderAction(PlayerbotAI* ai) : AttackAction(ai, "horseman attact in order") {}
// virtual bool Execute(Event event);
// };
// class SapphironGroundMainTankPositionAction : public MovementAction
// {
// public:
// SapphironGroundMainTankPositionAction(PlayerbotAI* ai) : MovementAction(ai, "sapphiron ground main tank position") {}
// virtual bool Execute(Event event);
// };
// class SapphironGroundPositionAction : public MovementAction
// {
// public:
// SapphironGroundPositionAction(PlayerbotAI* ai) : MovementAction(ai, "sapphiron ground position") {
// this->reset = 1;
// this->last_flight = 0;
// this->reset_timer = 0;
// }
// virtual bool Execute(Event event);
// protected:
// bool reset;
// uint32 last_flight, reset_timer;
// };
// class SapphironFlightPositionAction : public MovementAction
// {
// public:
// SapphironFlightPositionAction(PlayerbotAI* ai) : MovementAction(ai, "sapphiron flight position") {
// this->last_explosion = 0;
// this->move_ice_bolt = 0;
// }
// virtual bool Execute(Event event);
// protected:
// uint32 last_explosion;
// bool move_ice_bolt;
// bool MoveToNearestIcebolt();
// };
// class SapphironAvoidChillAction : public MovementAction
// {
// public:
// SapphironAvoidChillAction(PlayerbotAI* ai) : MovementAction(ai, "sapphiron avoid chill") {}
// virtual bool Execute(Event event);
// };
// class KelthuzadChooseTargetAction : public AttackAction
// {
// public:
// KelthuzadChooseTargetAction(PlayerbotAI* ai) : AttackAction(ai, "kel'thuzad choose target") {}
// virtual bool Execute(Event event);
// };
// class KelthuzadPositionAction : public MovementAction
// {
// public:
// KelthuzadPositionAction(PlayerbotAI* ai) : MovementAction(ai, "kel'thuzad position") {}
// virtual bool Execute(Event event);
// };
// class AnubrekhanChooseTargetAction : public AttackAction
// {
// public:
// AnubrekhanChooseTargetAction(PlayerbotAI* ai) : AttackAction(ai, "anub'rekhan choose target") {}
// virtual bool Execute(Event event);
// };
// class AnubrekhanPositionAction : public RotateAroundTheCenterPointAction
// {
// public:
// AnubrekhanPositionAction(PlayerbotAI* ai) : RotateAroundTheCenterPointAction(ai, "anub'rekhan position", 3272.49f, -3476.27f, 45.0f, 16) {}
// virtual bool Execute(Event event);
// };
// class GluthChooseTargetAction : public AttackAction
// {
// public:
// GluthChooseTargetAction(PlayerbotAI* ai) : AttackAction(ai, "gluth choose target") {}
// virtual bool Execute(Event event);
// };
// class GluthPositionAction : public RotateAroundTheCenterPointAction
// {
// public:
// GluthPositionAction(PlayerbotAI* ai) : RotateAroundTheCenterPointAction(ai, "gluth position", 3293.61f, -3149.01f, 12.0f, 12) {}
// virtual bool Execute(Event event);
// };
// class GluthSlowdownAction : public Action
// {
// public:
// GluthSlowdownAction(PlayerbotAI* ai) : Action(ai, "slowdown") {}
// virtual bool Execute(Event event);
// };
// class LoathebPositionAction : public MovementAction
// {
// public:
// LoathebPositionAction(PlayerbotAI* ai) : MovementAction(ai, "loatheb position") {}
// virtual bool Execute(Event event);
// };
// class LoathebChooseTargetAction : public AttackAction
// {
// public:
// LoathebChooseTargetAction(PlayerbotAI* ai) : AttackAction(ai, "loatheb choose target") {}
// virtual bool Execute(Event event);
// };
#endif

View File

@@ -36,7 +36,7 @@ ReachSpellAction::ReachSpellAction(PlayerbotAI* botAI) : ReachTargetAction(botAI
{
}
ReachPartyMemberToHealAction::ReachPartyMemberToHealAction(PlayerbotAI* botAI) : ReachTargetAction(botAI, "reach party member to heal", botAI->GetRange("spell"))
ReachPartyMemberToHealAction::ReachPartyMemberToHealAction(PlayerbotAI* botAI) : ReachTargetAction(botAI, "reach party member to heal", botAI->GetRange("heal"))
{
}