mirror of
https://github.com/mod-playerbots/mod-playerbots.git
synced 2026-01-13 09:07:19 +00:00
Auto do quest feature (new rpg strategy) (#1034)
* New rpg startup speed up and refactor * New rpg do quest * Fix invalid height in quest poi * Add quest accept and reward limitation * New rpg quest improvement * Organize quest log, reward quests and fix grind target * Quest dropped statistic and remove redundant code * Decrease grind relevance lower than loot * Fix new rpg drop quest * Go to reward quest instead of innkeeper when quest completed * Fix incorrect logic in do quest reward * Fix reset quests in factory * Fix crash on grind target value Co-authored-by: SaW <swerkhoven@outlook.com> * Fix a minor error in DoCompletedQuest * Let bots get rid of impossible quests faster * Increase loot fluency (especially for caster) * Remove seasonal quests from auto accept * Enhance quest accept condition check * Add questgiver check (limit acceptation of quest 7946) * Questgiver check and localization * Near npc fix * Fix quest item report * Add lowPriorityQuest set for quests can not be done * Improve gameobjects loot * Do complete quest * FIx move far to teleport check * Accept or reward quest from game objects * Fix possible crash in rpg game objects * Fix ChooseNpcOrGameObjectToInteract crash --------- Co-authored-by: SaW <swerkhoven@outlook.com>
This commit is contained in:
@@ -8,8 +8,11 @@
|
||||
#include "CellImpl.h"
|
||||
#include "GridNotifiers.h"
|
||||
#include "GridNotifiersImpl.h"
|
||||
#include "ObjectGuid.h"
|
||||
#include "Playerbots.h"
|
||||
#include "ServerFacade.h"
|
||||
#include "SharedDefines.h"
|
||||
#include "NearestGameObjects.h"
|
||||
|
||||
std::vector<uint32> PossibleRpgTargetsValue::allowedNpcFlags;
|
||||
|
||||
@@ -78,3 +81,125 @@ bool PossibleRpgTargetsValue::AcceptUnit(Unit* unit)
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
std::vector<uint32> PossibleNewRpgTargetsValue::allowedNpcFlags;
|
||||
|
||||
PossibleNewRpgTargetsValue::PossibleNewRpgTargetsValue(PlayerbotAI* botAI, float range)
|
||||
: NearestUnitsValue(botAI, "possible new rpg targets", range, true)
|
||||
{
|
||||
if (allowedNpcFlags.empty())
|
||||
{
|
||||
allowedNpcFlags.push_back(UNIT_NPC_FLAG_INNKEEPER);
|
||||
allowedNpcFlags.push_back(UNIT_NPC_FLAG_GOSSIP);
|
||||
allowedNpcFlags.push_back(UNIT_NPC_FLAG_QUESTGIVER);
|
||||
allowedNpcFlags.push_back(UNIT_NPC_FLAG_FLIGHTMASTER);
|
||||
allowedNpcFlags.push_back(UNIT_NPC_FLAG_BANKER);
|
||||
allowedNpcFlags.push_back(UNIT_NPC_FLAG_GUILD_BANKER);
|
||||
allowedNpcFlags.push_back(UNIT_NPC_FLAG_TRAINER_CLASS);
|
||||
allowedNpcFlags.push_back(UNIT_NPC_FLAG_TRAINER_PROFESSION);
|
||||
allowedNpcFlags.push_back(UNIT_NPC_FLAG_VENDOR_AMMO);
|
||||
allowedNpcFlags.push_back(UNIT_NPC_FLAG_VENDOR_FOOD);
|
||||
allowedNpcFlags.push_back(UNIT_NPC_FLAG_VENDOR_POISON);
|
||||
allowedNpcFlags.push_back(UNIT_NPC_FLAG_VENDOR_REAGENT);
|
||||
allowedNpcFlags.push_back(UNIT_NPC_FLAG_AUCTIONEER);
|
||||
allowedNpcFlags.push_back(UNIT_NPC_FLAG_STABLEMASTER);
|
||||
allowedNpcFlags.push_back(UNIT_NPC_FLAG_PETITIONER);
|
||||
allowedNpcFlags.push_back(UNIT_NPC_FLAG_TABARDDESIGNER);
|
||||
allowedNpcFlags.push_back(UNIT_NPC_FLAG_BATTLEMASTER);
|
||||
|
||||
allowedNpcFlags.push_back(UNIT_NPC_FLAG_TRAINER);
|
||||
allowedNpcFlags.push_back(UNIT_NPC_FLAG_VENDOR);
|
||||
allowedNpcFlags.push_back(UNIT_NPC_FLAG_REPAIR);
|
||||
}
|
||||
}
|
||||
|
||||
GuidVector PossibleNewRpgTargetsValue::Calculate()
|
||||
{
|
||||
std::list<Unit*> targets;
|
||||
FindUnits(targets);
|
||||
|
||||
GuidVector results;
|
||||
std::vector<std::pair<ObjectGuid, float>> guidDistancePairs;
|
||||
for (Unit* unit : targets)
|
||||
{
|
||||
if (AcceptUnit(unit) && (ignoreLos || bot->IsWithinLOSInMap(unit)))
|
||||
guidDistancePairs.push_back({unit->GetGUID(), bot->GetExactDist(unit)});
|
||||
}
|
||||
// Override to sort by distance
|
||||
std::sort(guidDistancePairs.begin(), guidDistancePairs.end(), [](const auto& a, const auto& b) {
|
||||
return a.second < b.second;
|
||||
});
|
||||
|
||||
for (const auto& pair : guidDistancePairs) {
|
||||
results.push_back(pair.first);
|
||||
}
|
||||
return results;
|
||||
}
|
||||
|
||||
void PossibleNewRpgTargetsValue::FindUnits(std::list<Unit*>& targets)
|
||||
{
|
||||
Acore::AnyUnitInObjectRangeCheck u_check(bot, range);
|
||||
Acore::UnitListSearcher<Acore::AnyUnitInObjectRangeCheck> searcher(bot, targets, u_check);
|
||||
Cell::VisitAllObjects(bot, searcher, range);
|
||||
}
|
||||
|
||||
bool PossibleNewRpgTargetsValue::AcceptUnit(Unit* unit)
|
||||
{
|
||||
if (unit->IsHostileTo(bot) || unit->GetTypeId() == TYPEID_PLAYER)
|
||||
return false;
|
||||
|
||||
if (unit->HasFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_SPIRITHEALER))
|
||||
return false;
|
||||
|
||||
for (uint32 npcFlag : allowedNpcFlags)
|
||||
{
|
||||
if (unit->HasFlag(UNIT_NPC_FLAGS, npcFlag))
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
std::vector<GameobjectTypes> PossibleNewRpgGameObjectsValue::allowedGOFlags;
|
||||
|
||||
GuidVector PossibleNewRpgGameObjectsValue::Calculate()
|
||||
{
|
||||
std::list<GameObject*> targets;
|
||||
AnyGameObjectInObjectRangeCheck u_check(bot, range);
|
||||
Acore::GameObjectListSearcher<AnyGameObjectInObjectRangeCheck> searcher(bot, targets, u_check);
|
||||
Cell::VisitAllObjects(bot, searcher, range);
|
||||
|
||||
|
||||
std::vector<std::pair<ObjectGuid, float>> guidDistancePairs;
|
||||
for (GameObject* go : targets)
|
||||
{
|
||||
bool flagCheck = false;
|
||||
for (uint32 goFlag : allowedGOFlags)
|
||||
{
|
||||
if (go->GetGoType() == goFlag)
|
||||
{
|
||||
flagCheck = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!flagCheck)
|
||||
continue;
|
||||
|
||||
if (!ignoreLos && !bot->IsWithinLOSInMap(go))
|
||||
continue;
|
||||
|
||||
guidDistancePairs.push_back({go->GetGUID(), bot->GetExactDist(go)});
|
||||
}
|
||||
GuidVector results;
|
||||
|
||||
// Sort by distance
|
||||
std::sort(guidDistancePairs.begin(), guidDistancePairs.end(), [](const auto& a, const auto& b) {
|
||||
return a.second < b.second;
|
||||
});
|
||||
|
||||
for (const auto& pair : guidDistancePairs) {
|
||||
results.push_back(pair.first);
|
||||
}
|
||||
return results;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user