Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Noscopezz committed Jan 4, 2025
2 parents e222d86 + 41e9851 commit ec0a920
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 30 deletions.
8 changes: 3 additions & 5 deletions src/PlayerbotAI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ void PlayerbotAI::UpdateAI(uint32 elapsed, bool minimal)
}
}

if (!bot->InBattleground() && !bot->inRandomLfgDungeon() && bot->GetGroup())
if (!bot->InBattleground() && !bot->inRandomLfgDungeon() && bot->GetGroup() && !bot->GetGroup()->isLFGGroup())
{
Player* leader = bot->GetGroup()->GetLeader();
if (leader && leader != bot) // Checks if the leader is valid and is not the bot itself
Expand Down Expand Up @@ -1312,11 +1312,9 @@ void PlayerbotAI::DoNextAction(bool min)
// if in combat but stick with old data - clear targets
if (currentEngine == engines[BOT_STATE_NON_COMBAT] && bot->IsInCombat())
{
if (aiObjectContext->GetValue<Unit*>("current target")->Get() != nullptr ||
aiObjectContext->GetValue<ObjectGuid>("pull target")->Get() != ObjectGuid::Empty ||
aiObjectContext->GetValue<Unit*>("dps target")->Get() != nullptr)
if (aiObjectContext->GetValue<Unit*>("current target")->Get() != nullptr)
{
Reset();
aiObjectContext->GetValue<Unit*>("current target")->Set(nullptr);
}
}

Expand Down
26 changes: 15 additions & 11 deletions src/strategy/actions/ChooseTargetActions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include "ChooseRpgTargetAction.h"
#include "Event.h"
#include "LootObjectStack.h"
#include "NewRpgStrategy.h"
#include "Playerbots.h"
#include "PossibleRpgTargetsValue.h"
#include "PvpTriggers.h"
Expand Down Expand Up @@ -35,19 +36,26 @@ 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
return false;
// if (bot->IsInCombat()) {


// if (context->GetValue<TravelTarget*>("travel target")->Get()->isTraveling() &&
// ChooseRpgTargetAction::isFollowValid(
// bot, *context->GetValue<TravelTarget*>("travel target")->Get()->getPosition())) // Bot is traveling
// return false;
// }

Unit* target = GetTarget();

if (!target)
return false;

bool inactiveGrindStatus = botAI->rpgInfo.status == NewRpgStatus::GO_GRIND ||
botAI->rpgInfo.status == NewRpgStatus::NEAR_NPC ||
botAI->rpgInfo.status == NewRpgStatus::REST ||
botAI->rpgInfo.status == NewRpgStatus::GO_INNKEEPER;

if (inactiveGrindStatus && bot->GetDistance(target) > 25.0f)
return false;

std::string const name = std::string(target->GetName());
// Check for invalid targets: Dummy, Charge Target, Melee Target, Ranged Target
if (!name.empty() &&
Expand All @@ -59,10 +67,6 @@ bool AttackAnythingAction::isUseful()
return false; // Target is one of the disallowed types
}

// if (!ChooseRpgTargetAction::isFollowValid(bot, target)) //Do not grind mobs far
// away from master.
// return false;

return true;
}

Expand Down
20 changes: 10 additions & 10 deletions src/strategy/actions/MovementActions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -236,11 +236,11 @@ bool MovementAction::MoveTo(uint32 mapId, float x, float y, float z, bool idle,
if (bot->IsSitState())
bot->SetStandState(UNIT_STAND_STATE_STAND);

if (bot->IsNonMeleeSpellCast(true))
{
bot->CastStop();
botAI->InterruptSpell();
}
// if (bot->IsNonMeleeSpellCast(true))
// {
// bot->CastStop();
// botAI->InterruptSpell();
// }
MotionMaster& mm = *bot->GetMotionMaster();
mm.Clear();
if (!backwards)
Expand Down Expand Up @@ -277,11 +277,11 @@ bool MovementAction::MoveTo(uint32 mapId, float x, float y, float z, bool idle,
if (bot->IsSitState())
bot->SetStandState(UNIT_STAND_STATE_STAND);

if (bot->IsNonMeleeSpellCast(true))
{
bot->CastStop();
botAI->InterruptSpell();
}
// if (bot->IsNonMeleeSpellCast(true))
// {
// bot->CastStop();
// botAI->InterruptSpell();
// }
MotionMaster& mm = *bot->GetMotionMaster();
G3D::Vector3 endP = path.back();
mm.Clear();
Expand Down
4 changes: 2 additions & 2 deletions src/strategy/rpg/NewRpgAction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ bool NewRpgStatusUpdateAction::Execute(Event event)
}
}
// IDLE -> GO_INNKEEPER
else if (bot->GetLevel() >= 6 && roll <= 45)
else if (roll <= 45)
{
WorldPosition pos = SelectRandomInnKeeperPos();
if (pos != WorldPosition() && bot->GetExactDist(pos) > 50.0f)
Expand Down Expand Up @@ -245,7 +245,7 @@ bool NewRpgGoFarAwayPosAction::MoveFarTo(WorldPosition dest)
while (--attempt)
{
float angle = bot->GetAngle(&dest);
float delta = (rand_norm() - 0.5) * M_PI * 2;
float delta = urand(1, 100) <= 75 ? (rand_norm() - 0.5) * M_PI * 0.5 : (rand_norm() - 0.5) * M_PI * 2;
angle += delta;
float dis = rand_norm() * pathFinderDis;
float dx = x + cos(angle) * dis;
Expand Down
2 changes: 1 addition & 1 deletion src/strategy/rpg/NewRpgAction.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class NewRpgStatusUpdateAction : public Action
protected:
// const int32 setGrindInterval = 5 * 60 * 1000;
// const int32 setNpcInterval = 1 * 60 * 1000;
const int32 statusNearNpcDuration = 2 * 60 * 1000;
const int32 statusNearNpcDuration = 5 * 60 * 1000;
const int32 statusNearRandomDuration = 2 * 60 * 1000;
const int32 statusRestDuration = 30 * 1000;
WorldPosition SelectRandomGrindPos();
Expand Down
2 changes: 1 addition & 1 deletion src/strategy/shaman/ShamanActions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

bool CastTotemAction::isUseful()
{
if (needLifeTime > 0.1f)
if (needLifeTime > 0.1f && AI_VALUE(uint8, "attacker count") < 3)
{
Unit* target = AI_VALUE(Unit*, "current target");
if (!target)
Expand Down

0 comments on commit ec0a920

Please sign in to comment.