fix merge master conflict

This commit is contained in:
Atidot3
2024-08-12 09:35:31 +02:00
23 changed files with 1626 additions and 1200 deletions

View File

@@ -18,8 +18,6 @@ bool ChangeTalentsAction::Execute(Event event)
std::ostringstream out;
TalentSpec botSpec(bot);
if (!param.empty())
{
if (param.find("help") != std::string::npos)

View File

@@ -173,6 +173,7 @@ public:
creators["bwl chat shortcut"] = &ChatActionContext::bwl_chat_shortcut;
creators["tell expected dps"] = &ChatActionContext::tell_expected_dps;
creators["join"] = &ChatActionContext::join;
creators["calc"] = &ChatActionContext::calc;
}
private:
@@ -270,6 +271,7 @@ private:
static Action* bwl_chat_shortcut(PlayerbotAI* ai) { return new BwlChatShortcutAction(ai); }
static Action* tell_expected_dps(PlayerbotAI* ai) { return new TellExpectedDpsAction(ai); }
static Action* join(PlayerbotAI* ai) { return new JoinGroupAction(ai); }
static Action* calc(PlayerbotAI* ai) { return new TellCalculateItemAction(ai); }
};
#endif

View File

@@ -827,15 +827,21 @@ bool MovementAction::ReachCombatTo(Unit* target, float distance)
ty = target->GetPositionY();
tz = target->GetPositionZ();
}
// Prediction may cause this, which makes ShortenPathUntilDist fail
if (bot->GetExactDist(tx, ty, tz) <= distance)
{
tx = target->GetPositionX();
ty = target->GetPositionY();
tz = target->GetPositionZ();
}
}
if (bot->GetExactDist(tx, ty, tz) <= distance)
{
return false;
}
PathGenerator path(bot);
path.CalculatePath(tx, ty, tz, false);
PathType type = path.GetPathType();
if (type != PATHFIND_NORMAL && type != PATHFIND_INCOMPLETE)
int typeOk = PATHFIND_NORMAL | PATHFIND_INCOMPLETE;
if (!(type & typeOk))
return false;
path.ShortenPathUntilDist(G3D::Vector3(tx, ty, tz), distance);
G3D::Vector3 endPos = path.GetPath().back();
@@ -881,7 +887,7 @@ bool MovementAction::IsMovingAllowed(Unit* target)
bool MovementAction::IsMovingAllowed(uint32 mapId, float x, float y, float z)
{
// removed sqrt as means distance limit was effectively 22500 (ReactDistance²)
// removed sqrt as means distance limit was effectively 22500 (ReactDistance<EFBFBD>)
// leaving it commented incase we find ReactDistance limit causes problems
// float distance = sqrt(bot->GetDistance(x, y, z));
float distance = bot->GetDistance(x, y, z);
@@ -2351,10 +2357,15 @@ bool MoveRandomAction::Execute(Event event)
float angle = (float)rand_norm() * static_cast<float>(M_PI);
x += urand(0, distance) * cos(angle);
y += urand(0, distance) * sin(angle);
float ox = x;
float oy = y;
float oz = z;
if (!bot->GetMap()->CheckCollisionAndGetValidCoords(bot, bot->GetPositionX(), bot->GetPositionY(),
bot->GetPositionZ(), x, y, z))
{
continue;
x = ox;
y = oy;
z = oz;
}
if (map->IsInWater(bot->GetPhaseMask(), x, y, z, bot->GetCollisionHeight()))
continue;

View File

@@ -4,10 +4,16 @@
*/
#include "TellLosAction.h"
#include <istream>
#include <sstream>
#include "ChatHelper.h"
#include "DBCStores.h"
#include "Event.h"
#include "ItemTemplate.h"
#include "ObjectMgr.h"
#include "Playerbots.h"
#include "StatsWeightCalculator.h"
#include "World.h"
bool TellLosAction::Execute(Event event)
@@ -130,3 +136,21 @@ bool TellExpectedDpsAction::Execute(Event event)
botAI->TellMaster("Expected Group DPS: " + std::to_string(dps));
return true;
}
bool TellCalculateItemAction::Execute(Event event)
{
std::string const text = event.getParam();
ItemIds ids = chat->parseItems(text);
StatsWeightCalculator calculator(bot);
for (const uint32 &id : ids)
{
const ItemTemplate* proto = sObjectMgr->GetItemTemplate(id);
if (!proto)
continue;
float score = calculator.CalculateItem(id);
std::ostringstream out;
out << "Calculated score of " << chat->FormatItem(proto) << " : " << score;
botAI->TellMasterNoFacing(out.str());
}
return true;
}

View File

@@ -37,4 +37,13 @@ public:
virtual bool Execute(Event event);
};
class TellCalculateItemAction : public Action
{
public:
TellCalculateItemAction(PlayerbotAI* ai) : Action(ai, "calculate item") {}
virtual bool Execute(Event event);
};
#endif

View File

@@ -10,8 +10,10 @@
#include "GuildTaskMgr.h"
#include "ItemUsageValue.h"
#include "ItemVisitors.h"
#include "PlayerbotMgr.h"
#include "PlayerbotSecurity.h"
#include "Playerbots.h"
#include "RandomPlayerbotMgr.h"
#include "SetCraftAction.h"
bool TradeStatusAction::Execute(Event event)
@@ -180,8 +182,12 @@ bool TradeStatusAction::CheckTrade()
}
return isGettingItem;
}
if (!sRandomPlayerbotMgr->IsRandomBot(bot))
if (!bot->GetSession())
{
return false;
}
uint32 accountId = bot->GetSession()->GetAccountId();
if (!sPlayerbotAIConfig->IsInRandomAccountList(accountId))
{
int32 botItemsMoney = CalculateCost(bot, true);
int32 botMoney = bot->GetTradeData()->GetMoney() + botItemsMoney;

View File

@@ -157,4 +157,5 @@ ChatCommandHandlerStrategy::ChatCommandHandlerStrategy(PlayerbotAI* botAI) : Pas
supported.push_back("guild leave");
supported.push_back("rtsc");
supported.push_back("drink");
supported.push_back("calc");
}

View File

@@ -121,6 +121,7 @@ public:
creators["bwl"] = &ChatTriggerContext::bwl;
creators["dps"] = &ChatTriggerContext::dps;
creators["disperse"] = &ChatTriggerContext::disperse;
creators["calc"] = &ChatTriggerContext::calc;
}
private:
@@ -221,6 +222,7 @@ private:
static Trigger* bwl(PlayerbotAI* ai) { return new ChatCommandTrigger(ai, "bwl"); }
static Trigger* dps(PlayerbotAI* ai) { return new ChatCommandTrigger(ai, "dps"); }
static Trigger* disperse(PlayerbotAI* ai) { return new ChatCommandTrigger(ai, "disperse"); }
static Trigger* calc(PlayerbotAI* ai) { return new ChatCommandTrigger(ai, "calc"); }
};
#endif

View File

@@ -47,11 +47,14 @@ WorldLocation ArrowFormation::GetLocationInternal()
float x = master->GetPositionX() - masterUnit->GetX() + botUnit->GetX();
float y = master->GetPositionY() - masterUnit->GetY() + botUnit->GetY();
float z = master->GetPositionZ();
if (!master->GetMap()->CheckCollisionAndGetValidCoords(master, master->GetPositionX(), master->GetPositionY(),
master->GetPositionZ(), x, y, z))
return Formation::NullLocation;
// master->UpdateGroundPositionZ(x, y, z);
{
x = master->GetPositionX() - masterUnit->GetX() + botUnit->GetX();
y = master->GetPositionY() - masterUnit->GetY() + botUnit->GetY();
z = master->GetPositionZ() + master->GetHoverHeight();
z = master->GetMapHeight(x, y, z);
}
return WorldLocation(master->GetMapId(), x, y, z);
}

View File

@@ -7,6 +7,7 @@
#include "Arrow.h"
#include "Event.h"
#include "Map.h"
#include "Playerbots.h"
#include "ServerFacade.h"
@@ -88,10 +89,14 @@ public:
float x = master->GetPositionX() + cos(angle) * range;
float y = master->GetPositionY() + sin(angle) * range;
float z = master->GetPositionZ();
if (!master->GetMap()->CheckCollisionAndGetValidCoords(master, master->GetPositionX(), master->GetPositionY(),
master->GetPositionZ(), x, y, z))
return Formation::NullLocation;
master->GetPositionZ(), x, y, z))
{
x = master->GetPositionX() + cos(angle) * range;
y = master->GetPositionY() + sin(angle) * range;
z = master->GetPositionZ() + master->GetHoverHeight();
master->UpdateAllowedPositionZ(x, y, z);
}
return WorldLocation(master->GetMapId(), x, y, z);
}
@@ -134,9 +139,15 @@ public:
float x = master->GetPositionX() + cos(angle) * range + dx;
float y = master->GetPositionY() + sin(angle) * range + dy;
float z = master->GetPositionZ();
if (!master->GetMap()->CheckCollisionAndGetValidCoords(
master, master->GetPositionX(), master->GetPositionY(), master->GetPositionZ(), x, y, z))
return Formation::NullLocation;
z = bot->GetMapHeight(x, y, z + 5.0f);
if (!master->GetMap()->CheckCollisionAndGetValidCoords(master, master->GetPositionX(), master->GetPositionY(),
master->GetPositionZ(), x, y, z))
{
x = master->GetPositionX() + cos(angle) * range + dx;
y = master->GetPositionY() + sin(angle) * range + dy;
z = master->GetPositionZ() + master->GetHoverHeight();
z = master->GetMapHeight(x, y, z);
}
// bot->GetMap()->CheckCollisionAndGetValidCoords(bot, bot->GetPositionX(), bot->GetPositionY(),
// bot->GetPositionZ(), x, y, z);
return WorldLocation(master->GetMapId(), x, y, z);
@@ -145,9 +156,15 @@ public:
float x = master->GetPositionX() + cos(angle) * range + dx;
float y = master->GetPositionY() + sin(angle) * range + dy;
float z = master->GetPositionZ();
z = bot->GetMapHeight(x, y, z + 5.0f);
if (!master->GetMap()->CheckCollisionAndGetValidCoords(master, master->GetPositionX(), master->GetPositionY(),
master->GetPositionZ(), x, y, z))
return Formation::NullLocation;
master->GetPositionZ(), x, y, z))
{
x = master->GetPositionX() + cos(angle) * range + dx;
y = master->GetPositionY() + sin(angle) * range + dy;
z = master->GetPositionZ() + master->GetHoverHeight();
z = master->GetMapHeight(x, y, z);
}
return WorldLocation(master->GetMapId(), x, y, z);
}
@@ -200,9 +217,13 @@ public:
float y = target->GetPositionY() + sin(angle) * range;
float z = target->GetPositionZ();
if (!master->GetMap()->CheckCollisionAndGetValidCoords(master, master->GetPositionX(), master->GetPositionY(),
master->GetPositionZ(), x, y, z))
return Formation::NullLocation;
master->GetPositionZ(), x, y, z))
{
x = target->GetPositionX() + cos(angle) * range;
y = target->GetPositionY() + sin(angle) * range;
z = target->GetPositionZ() + target->GetHoverHeight();
z = master->GetMapHeight(x, y, z);
}
return WorldLocation(bot->GetMapId(), x, y, z);
}
};
@@ -362,9 +383,14 @@ public:
if (minDist)
{
if (!master->GetMap()->CheckCollisionAndGetValidCoords(
master, master->GetPositionX(), master->GetPositionY(), master->GetPositionZ(), x, y, z))
return Formation::NullLocation;
if (!master->GetMap()->CheckCollisionAndGetValidCoords(master, master->GetPositionX(), master->GetPositionY(),
master->GetPositionZ(), x, y, z))
{
x = master->GetPositionX() + cos(angle) * range + cos(followAngle) * followRange;
y = master->GetPositionY() + sin(angle) * range + sin(followAngle) * followRange;
z = master->GetPositionZ() + master->GetHoverHeight();
z = master->GetMapHeight(x, y, z);
}
return WorldLocation(bot->GetMapId(), minX, minY, z);
}
@@ -372,8 +398,13 @@ public:
}
if (!master->GetMap()->CheckCollisionAndGetValidCoords(master, master->GetPositionX(), master->GetPositionY(),
master->GetPositionZ(), x, y, z))
return Formation::NullLocation;
master->GetPositionZ(), x, y, z))
{
x = master->GetPositionX() + cos(angle) * range + cos(followAngle) * followRange;
y = master->GetPositionY() + sin(angle) * range + sin(followAngle) * followRange;
z = master->GetPositionZ() + master->GetHoverHeight();
z = master->GetMapHeight(x, y, z);
}
return WorldLocation(bot->GetMapId(), x, y, z);
}
};
@@ -636,7 +667,11 @@ WorldLocation MoveFormation::MoveSingleLine(std::vector<Player*> line, float dif
Player* master = botAI->GetMaster();
if (!master->GetMap()->CheckCollisionAndGetValidCoords(
master, master->GetPositionX(), master->GetPositionY(), master->GetPositionZ(), lx, ly, lz))
return Formation::NullLocation;
{
lx = x + cos(angle) * radius;
ly = y + sin(angle) * radius;
lz = cz;
}
return WorldLocation(bot->GetMapId(), lx, ly, lz);
}

View File

@@ -13,6 +13,7 @@
#include "Playerbots.h"
#include "RandomItemMgr.h"
#include "ServerFacade.h"
#include "StatsWeightCalculator.h"
ItemUsage ItemUsageValue::Calculate()
{
@@ -190,7 +191,8 @@ ItemUsage ItemUsageValue::QueryItemUsageForEquip(ItemTemplate const* itemProto)
bool shouldEquip = false;
// uint32 statWeight = sRandomItemMgr->GetLiveStatWeight(bot, itemProto->ItemId);
float itemScore = PlayerbotFactory::CalculateItemScore(itemProto->ItemId, bot);
StatsWeightCalculator calculator(bot);
float itemScore = calculator.CalculateItem(itemProto->ItemId);
if (itemScore)
shouldEquip = true;
@@ -214,7 +216,7 @@ ItemUsage ItemUsageValue::QueryItemUsageForEquip(ItemTemplate const* itemProto)
}
ItemTemplate const* oldItemProto = oldItem->GetTemplate();
float oldScore = PlayerbotFactory::CalculateItemScore(oldItemProto->ItemId, bot);
float oldScore = calculator.CalculateItem(oldItemProto->ItemId);
if (oldItem)
{
// uint32 oldStatWeight = sRandomItemMgr->GetLiveStatWeight(bot, oldItemProto->ItemId);