mirror of
https://github.com/liyunfan1223/mod-playerbots.git
synced 2026-06-20 15:39:25 +02:00
feat(Core/RPG): Reorder do-quest above attack-anything
This commit is contained in:
parent
3f5a558c13
commit
6a961bb46c
@ -5,11 +5,66 @@
|
|||||||
|
|
||||||
#include "NewRpgStrategy.h"
|
#include "NewRpgStrategy.h"
|
||||||
|
|
||||||
|
#include "Action.h"
|
||||||
|
#include "NewRpgInfo.h"
|
||||||
|
#include "Player.h"
|
||||||
|
#include "PlayerbotAI.h"
|
||||||
|
|
||||||
|
static bool IsGatherObjectiveForDoQuest(NewRpgInfo::DoQuest const* data)
|
||||||
|
{
|
||||||
|
if (!data || !data->quest)
|
||||||
|
return false;
|
||||||
|
Quest const* q = data->quest;
|
||||||
|
int32 obj = data->objectiveIdx;
|
||||||
|
if (obj < QUEST_OBJECTIVES_COUNT)
|
||||||
|
{
|
||||||
|
int32 entry = q->RequiredNpcOrGo[obj];
|
||||||
|
if (entry < 0) // GO objective
|
||||||
|
return true;
|
||||||
|
if (entry == 0 && obj < QUEST_ITEM_OBJECTIVES_COUNT && q->RequiredItemId[obj])
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else if (obj < QUEST_OBJECTIVES_COUNT + QUEST_ITEM_OBJECTIVES_COUNT)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
// source-item quest: need to find the right target to use it on
|
||||||
|
if (q->GetSrcItemId())
|
||||||
|
return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
float NewRpgDoQuestMultiplier::GetValue(Action* action)
|
||||||
|
{
|
||||||
|
if (!action || action->getName() != "attack anything")
|
||||||
|
return 1.0f;
|
||||||
|
|
||||||
|
NewRpgInfo& info = botAI->rpgInfo;
|
||||||
|
if (info.GetStatus() != RPG_DO_QUEST)
|
||||||
|
return 1.0f;
|
||||||
|
|
||||||
|
auto* data = std::get_if<NewRpgInfo::DoQuest>(&info.data);
|
||||||
|
if (!data)
|
||||||
|
return 1.0f;
|
||||||
|
|
||||||
|
// heading back to turn in, don't get sidetracked
|
||||||
|
if (data->questId && bot->GetQuestStatus(data->questId) == QUEST_STATUS_COMPLETE)
|
||||||
|
return 0.15f;
|
||||||
|
|
||||||
|
// at POI: gather stays low so mobs don't pull us off the cluster;
|
||||||
|
// kill runs full so attack-anything drives behavior
|
||||||
|
if (data->lastReachPOI)
|
||||||
|
return IsGatherObjectiveForDoQuest(data) ? 0.30f : 1.0f;
|
||||||
|
|
||||||
|
// traveling
|
||||||
|
return 0.20f;
|
||||||
|
}
|
||||||
|
|
||||||
NewRpgStrategy::NewRpgStrategy(PlayerbotAI* botAI) : Strategy(botAI) {}
|
NewRpgStrategy::NewRpgStrategy(PlayerbotAI* botAI) : Strategy(botAI) {}
|
||||||
|
|
||||||
std::vector<NextAction> NewRpgStrategy::getDefaultActions()
|
std::vector<NextAction> NewRpgStrategy::getDefaultActions()
|
||||||
{
|
{
|
||||||
// the releavance should be greater than grind
|
// must outrank grind
|
||||||
return {
|
return {
|
||||||
NextAction("new rpg status update", 11.0f)
|
NextAction("new rpg status update", 11.0f)
|
||||||
};
|
};
|
||||||
@ -53,7 +108,8 @@ void NewRpgStrategy::InitTriggers(std::vector<TriggerNode*>& triggers)
|
|||||||
new TriggerNode(
|
new TriggerNode(
|
||||||
"do quest status",
|
"do quest status",
|
||||||
{
|
{
|
||||||
NextAction("new rpg do quest", 3.0f)
|
// 4.5: above attack-anything (4.0), below loot (5.0+)
|
||||||
|
NextAction("new rpg do quest", 4.5f)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
@ -75,6 +131,7 @@ void NewRpgStrategy::InitTriggers(std::vector<TriggerNode*>& triggers)
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
void NewRpgStrategy::InitMultipliers(std::vector<Multiplier*>&)
|
void NewRpgStrategy::InitMultipliers(std::vector<Multiplier*>& multipliers)
|
||||||
{
|
{
|
||||||
|
multipliers.push_back(new NewRpgDoQuestMultiplier(botAI));
|
||||||
}
|
}
|
||||||
|
|||||||
@ -12,6 +12,13 @@
|
|||||||
|
|
||||||
class PlayerbotAI;
|
class PlayerbotAI;
|
||||||
|
|
||||||
|
class NewRpgDoQuestMultiplier : public Multiplier
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
NewRpgDoQuestMultiplier(PlayerbotAI* botAI) : Multiplier(botAI, "new rpg do quest") {}
|
||||||
|
float GetValue(Action* action) override;
|
||||||
|
};
|
||||||
|
|
||||||
class NewRpgStrategy : public Strategy
|
class NewRpgStrategy : public Strategy
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user