mirror of
https://github.com/mod-playerbots/mod-playerbots.git
synced 2026-01-15 09:50:27 +00:00
feat: rndbot teleport, grind, stuck problem etc.
This commit is contained in:
@@ -33,9 +33,12 @@ bool AttackAnythingAction::isUseful()
|
||||
if (!AI_VALUE(bool, "can move around"))
|
||||
return false;
|
||||
|
||||
if (context->GetValue<TravelTarget*>("travel target")->Get()->isTraveling() && ChooseRpgTargetAction::isFollowValid(bot, *context->GetValue<TravelTarget*>("travel target")->Get()->getPosition())) //Bot is traveling
|
||||
if (context->GetValue<TravelTarget*>("travel target")->Get()->isTraveling() &&
|
||||
ChooseRpgTargetAction::isFollowValid(bot, *context->GetValue<TravelTarget*>("travel target")->Get()->getPosition())) //Bot is traveling
|
||||
return false;
|
||||
|
||||
if (bot->IsInCombat()) {
|
||||
return false;
|
||||
}
|
||||
Unit* target = GetTarget();
|
||||
|
||||
if (!target)
|
||||
|
||||
@@ -25,7 +25,7 @@ bool FollowAction::Execute(Event event)
|
||||
if (Formation::IsNullLocation(loc) || loc.GetMapId() == -1)
|
||||
return false;
|
||||
|
||||
moved = MoveTo(loc.GetMapId(), loc.GetPositionX(), loc.GetPositionY(), loc.GetPositionZ() + 2.0f);
|
||||
moved = MoveTo(loc.GetMapId(), loc.GetPositionX(), loc.GetPositionY(), loc.GetPositionZ());
|
||||
}
|
||||
|
||||
if (Pet* pet = bot->GetPet())
|
||||
@@ -33,11 +33,14 @@ bool FollowAction::Execute(Event event)
|
||||
if (CreatureAI* creatureAI = ((Creature*)pet)->AI())
|
||||
{
|
||||
pet->SetReactState(REACT_PASSIVE);
|
||||
pet->GetCharmInfo()->SetCommandState(COMMAND_FOLLOW);
|
||||
pet->GetCharmInfo()->SetIsFollowing(true);
|
||||
pet->AttackStop();
|
||||
pet->GetCharmInfo()->SetIsCommandFollow(true);
|
||||
pet->GetCharmInfo()->IsReturning();
|
||||
pet->GetMotionMaster()->MoveFollow(bot, PET_FOLLOW_DIST, pet->GetFollowAngle());
|
||||
// pet->GetCharmInfo()->SetCommandState(COMMAND_FOLLOW);
|
||||
// pet->GetCharmInfo()->SetIsFollowing(true);
|
||||
// pet->AttackStop();
|
||||
// pet->GetCharmInfo()->IsReturning();
|
||||
// pet->GetMotionMaster()->MoveFollow(bot, PET_FOLLOW_DIST, pet->GetFollowAngle());
|
||||
}
|
||||
}
|
||||
//if (moved)
|
||||
|
||||
@@ -4,7 +4,9 @@
|
||||
|
||||
#include "MovementActions.h"
|
||||
#include "MovementGenerator.h"
|
||||
#include "ObjectGuid.h"
|
||||
#include "PlayerbotAIConfig.h"
|
||||
#include "SharedDefines.h"
|
||||
#include "TargetedMovementGenerator.h"
|
||||
#include "Event.h"
|
||||
#include "LastMovementValue.h"
|
||||
@@ -15,6 +17,7 @@
|
||||
#include "Playerbots.h"
|
||||
#include "ServerFacade.h"
|
||||
#include "Transport.h"
|
||||
#include "Unit.h"
|
||||
#include "Vehicle.h"
|
||||
#include "WaypointMovementGenerator.h"
|
||||
|
||||
@@ -128,10 +131,17 @@ 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))
|
||||
if (!IsMovingAllowed(mapId, x, y, z)) {
|
||||
return false;
|
||||
bot->UpdateGroundPositionZ(x, y, z);
|
||||
|
||||
}
|
||||
// if (bot->HasUnitMovementFlag(MOVEMENTFLAG_FALLING | MOVEMENTFLAG_FALLING_FAR)) {
|
||||
// bot->Yell("I'm falling!", LANG_UNIVERSAL);
|
||||
// return false;
|
||||
// }
|
||||
// bot->UpdateGroundPositionZ(x, y, z);
|
||||
z += 15.0f;
|
||||
bot->UpdateAllowedPositionZ(x, y, z);
|
||||
z += 0.5f;
|
||||
float distance = bot->GetDistance2d(x, y);
|
||||
if (distance > sPlayerbotAIConfig->contactDistance)
|
||||
{
|
||||
@@ -159,8 +169,8 @@ bool MovementAction::MoveTo(uint32 mapId, float x, float y, float z, bool idle,
|
||||
return false;
|
||||
// UpdateMovementState();
|
||||
// // LOG_DEBUG("playerbots", "IsMovingAllowed {}", IsMovingAllowed());
|
||||
// if (!IsMovingAllowed())
|
||||
// return false;
|
||||
// bot->AddUnitMovementFlag()
|
||||
|
||||
|
||||
// bool isVehicle = false;
|
||||
// Unit* mover = bot;
|
||||
@@ -663,7 +673,7 @@ bool MovementAction::MoveTo(Unit* target, float distance)
|
||||
|
||||
float dx = cos(angle) * needToGo + bx;
|
||||
float dy = sin(angle) * needToGo + by;
|
||||
|
||||
float dz = bz + (tz - bz) * (needToGo / distanceToTarget); // calc accurate z postion to avoid stuck
|
||||
return MoveTo(target->GetMapId(), dx, dy, tz);
|
||||
}
|
||||
|
||||
@@ -1265,9 +1275,7 @@ bool FleeWithPetAction::Execute(Event event)
|
||||
if (CreatureAI* creatureAI = ((Creature*)pet)->AI())
|
||||
{
|
||||
pet->SetReactState(REACT_PASSIVE);
|
||||
pet->GetCharmInfo()->SetCommandState(COMMAND_FOLLOW);
|
||||
pet->GetCharmInfo()->SetIsFollowing(true);
|
||||
pet->AttackStop();
|
||||
pet->GetCharmInfo()->SetIsCommandFollow(true);
|
||||
pet->GetCharmInfo()->IsReturning();
|
||||
pet->GetMotionMaster()->MoveFollow(bot, PET_FOLLOW_DIST, pet->GetFollowAngle());
|
||||
}
|
||||
@@ -1384,17 +1392,27 @@ bool MoveOutOfCollisionAction::isUseful()
|
||||
|
||||
bool MoveRandomAction::Execute(Event event)
|
||||
{
|
||||
//uint32 randnum = bot->GetGUID().GetCounter(); // Semi-random but fixed number for each bot.
|
||||
//uint32 cycle = floor(getMSTime() / (1000 * 60)); // Semi-random number adds 1 each minute.
|
||||
float distance = sPlayerbotAIConfig->tooCloseDistance + sPlayerbotAIConfig->grindDistance * urand(3, 10) / 10.0f;
|
||||
|
||||
//randnum = ((randnum + cycle) % 1000) + 1;
|
||||
Map* map = bot->GetMap();
|
||||
for (int i = 0; i < 10; ++i)
|
||||
{
|
||||
float x = bot->GetPositionX();
|
||||
float y = bot->GetPositionY();
|
||||
float z = bot->GetPositionZ();
|
||||
x += urand(0, distance) - distance / 2;
|
||||
y += urand(0, distance) - distance / 2;
|
||||
bot->UpdateGroundPositionZ(x, y, z);
|
||||
|
||||
uint32 randnum = urand(1, 2000);
|
||||
if (map->IsInWater(bot->GetPhaseMask(), x, y, z, bot->GetCollisionHeight()))
|
||||
continue;
|
||||
|
||||
float angle = M_PI * (float)randnum / 1000; //urand(1, 1000);
|
||||
float distance = urand(20, 200);
|
||||
bool moved = MoveTo(bot->GetMapId(), x, y, z);
|
||||
if (moved)
|
||||
return true;
|
||||
}
|
||||
|
||||
return MoveTo(bot->GetMapId(), bot->GetPositionX() + cos(angle) * distance, bot->GetPositionY() + sin(angle) * distance, bot->GetPositionZ());
|
||||
return false;
|
||||
}
|
||||
|
||||
bool MoveRandomAction::isUseful()
|
||||
|
||||
@@ -18,8 +18,8 @@ bool DrinkAction::Execute(Event event)
|
||||
if (sPlayerbotAIConfig->freeFood)
|
||||
{
|
||||
|
||||
if (bot->IsNonMeleeSpellCast(true))
|
||||
return false;
|
||||
// if (bot->IsNonMeleeSpellCast(true))
|
||||
// return false;
|
||||
|
||||
bot->ClearUnitState(UNIT_STATE_CHASE);
|
||||
bot->ClearUnitState(UNIT_STATE_FOLLOW);
|
||||
@@ -70,8 +70,8 @@ bool EatAction::Execute(Event event)
|
||||
|
||||
if (sPlayerbotAIConfig->freeFood)
|
||||
{
|
||||
if (bot->IsNonMeleeSpellCast(true))
|
||||
return false;
|
||||
// if (bot->IsNonMeleeSpellCast(true))
|
||||
// return false;
|
||||
|
||||
bot->ClearUnitState(UNIT_STATE_CHASE);
|
||||
bot->ClearUnitState(UNIT_STATE_FOLLOW);
|
||||
@@ -106,8 +106,8 @@ bool EatAction::Execute(Event event)
|
||||
}
|
||||
|
||||
bool EatAction::isUseful()
|
||||
{
|
||||
return UseItemAction::isUseful() && AI_VALUE2(uint8, "health", "self target") < sPlayerbotAIConfig->lowHealth;
|
||||
{
|
||||
return UseItemAction::isUseful() && AI_VALUE2(uint8, "health", "self target") < 85;
|
||||
}
|
||||
|
||||
bool EatAction::isPossible()
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include "MapMgr.h"
|
||||
#include "Playerbots.h"
|
||||
#include "PlayerbotFactory.h"
|
||||
#include "RandomPlayerbotMgr.h"
|
||||
#include "ServerFacade.h"
|
||||
|
||||
bool ReviveFromCorpseAction::Execute(Event event)
|
||||
@@ -89,10 +90,11 @@ bool FindCorpseAction::Execute(Event event)
|
||||
{
|
||||
if (dCount >= 5)
|
||||
{
|
||||
LOG_DEBUG("playerbots", "Bot {} {}:{} <{}>: died too many times and was sent to an inn",
|
||||
LOG_INFO("playerbots", "Bot {} {}:{} <{}>: died too many times, was revived and teleported",
|
||||
bot->GetGUID().ToString().c_str(), bot->GetTeamId() == TEAM_ALLIANCE ? "A" : "H", bot->getLevel(), bot->GetName().c_str());
|
||||
context->GetValue<uint32>("death count")->Set(0);
|
||||
sRandomPlayerbotMgr->RandomTeleportForLevel(bot);
|
||||
// sRandomPlayerbotMgr->RandomTeleportForLevel(bot);
|
||||
sRandomPlayerbotMgr->Revive(bot);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,6 +12,8 @@ NextAction** GrindingStrategy::getDefaultActions()
|
||||
|
||||
void GrindingStrategy::InitTriggers(std::vector<TriggerNode*>& triggers)
|
||||
{
|
||||
triggers.push_back(new TriggerNode("medium mana", NextAction::array(0, new NextAction("drink", 7.0f), nullptr)));
|
||||
triggers.push_back(new TriggerNode("medium health", NextAction::array(0, new NextAction("food", 6.0f), nullptr)));
|
||||
triggers.push_back(new TriggerNode("no target", NextAction::array(0, new NextAction("attack anything", 5.0f), nullptr)));
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
*/
|
||||
|
||||
#include "Arrow.h"
|
||||
#include "Map.h"
|
||||
#include "Playerbots.h"
|
||||
|
||||
WorldLocation ArrowFormation::GetLocationInternal()
|
||||
@@ -47,8 +48,8 @@ WorldLocation ArrowFormation::GetLocationInternal()
|
||||
float ground = master->GetMap()->GetHeight(x, y, z + 0.5f);
|
||||
if (ground <= INVALID_HEIGHT)
|
||||
return Formation::NullLocation;
|
||||
|
||||
return WorldLocation(master->GetMapId(), x, y, 0.05f + ground);
|
||||
// master->UpdateGroundPositionZ(x, y, z);
|
||||
return WorldLocation(master->GetMapId(), x, y, z);
|
||||
}
|
||||
|
||||
void ArrowFormation::Build()
|
||||
|
||||
Reference in New Issue
Block a user