mirror of
https://github.com/liyunfan1223/mod-playerbots.git
synced 2026-02-20 18:10:02 +01:00
Compare commits
No commits in common. "b0f3de65f55cfd3f817a51c3c2fc23143321a89b" and "23d9931f65418619ae450e37539f0414b5a13c4e" have entirely different histories.
b0f3de65f5
...
23d9931f65
@ -101,22 +101,6 @@ std::string PlayerbotTextMgr::GetBotText(std::string name, std::map<std::string,
|
|||||||
return botText;
|
return botText;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string PlayerbotTextMgr::GetBotTextOrDefault(std::string name, std::string defaultText,
|
|
||||||
std::map<std::string, std::string> placeholders)
|
|
||||||
{
|
|
||||||
std::string botText = GetBotText(name, placeholders);
|
|
||||||
if (botText.empty())
|
|
||||||
{
|
|
||||||
for (std::map<std::string, std::string>::iterator i = placeholders.begin(); i != placeholders.end(); ++i)
|
|
||||||
{
|
|
||||||
replaceAll(defaultText, i->first, i->second);
|
|
||||||
}
|
|
||||||
return defaultText;
|
|
||||||
}
|
|
||||||
|
|
||||||
return botText;
|
|
||||||
}
|
|
||||||
|
|
||||||
// chat replies
|
// chat replies
|
||||||
|
|
||||||
std::string PlayerbotTextMgr::GetBotText(ChatReplyType replyType, std::map<std::string, std::string> placeholders)
|
std::string PlayerbotTextMgr::GetBotText(ChatReplyType replyType, std::map<std::string, std::string> placeholders)
|
||||||
|
|||||||
@ -83,8 +83,6 @@ public:
|
|||||||
std::string GetBotText(ChatReplyType replyType, std::string name);
|
std::string GetBotText(ChatReplyType replyType, std::string name);
|
||||||
bool GetBotText(std::string name, std::string& text);
|
bool GetBotText(std::string name, std::string& text);
|
||||||
bool GetBotText(std::string name, std::string& text, std::map<std::string, std::string> placeholders);
|
bool GetBotText(std::string name, std::string& text, std::map<std::string, std::string> placeholders);
|
||||||
std::string GetBotTextOrDefault(std::string name, std::string defaultText,
|
|
||||||
std::map<std::string, std::string> placeholders);
|
|
||||||
void LoadBotTexts();
|
void LoadBotTexts();
|
||||||
void LoadBotTextChance();
|
void LoadBotTextChance();
|
||||||
static void replaceAll(std::string& str, const std::string& from, const std::string& to);
|
static void replaceAll(std::string& str, const std::string& from, const std::string& to);
|
||||||
|
|||||||
@ -47,8 +47,6 @@ public:
|
|||||||
std::unordered_map<std::string, ObjectCreator> creators;
|
std::unordered_map<std::string, ObjectCreator> creators;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual ~NamedObjectFactory() = default;
|
|
||||||
|
|
||||||
virtual T* create(std::string name, PlayerbotAI* botAI)
|
virtual T* create(std::string name, PlayerbotAI* botAI)
|
||||||
{
|
{
|
||||||
size_t found = name.find("::");
|
size_t found = name.find("::");
|
||||||
@ -149,7 +147,9 @@ public:
|
|||||||
{
|
{
|
||||||
contexts.push_back(context);
|
contexts.push_back(context);
|
||||||
for (const auto& iter : context->creators)
|
for (const auto& iter : context->creators)
|
||||||
|
{
|
||||||
creators[iter.first] = iter.second;
|
creators[iter.first] = iter.second;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -208,7 +208,6 @@ public:
|
|||||||
if (T* object = create(name, botAI))
|
if (T* object = create(name, botAI))
|
||||||
return created[name] = object;
|
return created[name] = object;
|
||||||
}
|
}
|
||||||
|
|
||||||
return created[name];
|
return created[name];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -237,6 +236,7 @@ public:
|
|||||||
for (auto i = contexts.begin(); i != contexts.end(); i++)
|
for (auto i = contexts.begin(); i != contexts.end(); i++)
|
||||||
{
|
{
|
||||||
std::set<std::string> supported = (*i)->supports();
|
std::set<std::string> supported = (*i)->supports();
|
||||||
|
|
||||||
for (std::set<std::string>::const_iterator j = supported.begin(); j != supported.end(); ++j)
|
for (std::set<std::string>::const_iterator j = supported.begin(); j != supported.end(); ++j)
|
||||||
result.insert(*j);
|
result.insert(*j);
|
||||||
}
|
}
|
||||||
@ -248,7 +248,9 @@ public:
|
|||||||
{
|
{
|
||||||
std::set<std::string> result;
|
std::set<std::string> result;
|
||||||
for (typename std::unordered_map<std::string, T*>::const_iterator i = created.begin(); i != created.end(); i++)
|
for (typename std::unordered_map<std::string, T*>::const_iterator i = created.begin(); i != created.end(); i++)
|
||||||
|
{
|
||||||
result.insert(i->first);
|
result.insert(i->first);
|
||||||
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -295,14 +297,15 @@ public:
|
|||||||
{
|
{
|
||||||
factories.push_back(context);
|
factories.push_back(context);
|
||||||
for (const auto& iter : context->creators)
|
for (const auto& iter : context->creators)
|
||||||
|
{
|
||||||
creators[iter.first] = iter.second;
|
creators[iter.first] = iter.second;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
T* GetContextObject(const std::string& name, PlayerbotAI* botAI)
|
T* GetContextObject(const std::string& name, PlayerbotAI* botAI)
|
||||||
{
|
{
|
||||||
if (T* object = create(name, botAI))
|
if (T* object = create(name, botAI))
|
||||||
return object;
|
return object;
|
||||||
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@ -184,8 +184,8 @@ private:
|
|||||||
static Strategy* grind(PlayerbotAI* botAI) { return new GrindingStrategy(botAI); }
|
static Strategy* grind(PlayerbotAI* botAI) { return new GrindingStrategy(botAI); }
|
||||||
static Strategy* avoid_aoe(PlayerbotAI* botAI) { return new AvoidAoeStrategy(botAI); }
|
static Strategy* avoid_aoe(PlayerbotAI* botAI) { return new AvoidAoeStrategy(botAI); }
|
||||||
static Strategy* tank_face(PlayerbotAI* botAI) { return new TankFaceStrategy(botAI); }
|
static Strategy* tank_face(PlayerbotAI* botAI) { return new TankFaceStrategy(botAI); }
|
||||||
static Strategy* move_random(PlayerbotAI* botAI) { return new MoveRandomStrategy(botAI); }
|
static Strategy* move_random(PlayerbotAI* ai) { return new MoveRandomStrategy(ai); }
|
||||||
static Strategy* combat_formation(PlayerbotAI* botAI) { return new CombatFormationStrategy(botAI); }
|
static Strategy* combat_formation(PlayerbotAI* ai) { return new CombatFormationStrategy(ai); }
|
||||||
static Strategy* move_from_group(PlayerbotAI* botAI) { return new MoveFromGroupStrategy(botAI); }
|
static Strategy* move_from_group(PlayerbotAI* botAI) { return new MoveFromGroupStrategy(botAI); }
|
||||||
static Strategy* world_buff(PlayerbotAI* botAI) { return new WorldBuffStrategy(botAI); }
|
static Strategy* world_buff(PlayerbotAI* botAI) { return new WorldBuffStrategy(botAI); }
|
||||||
};
|
};
|
||||||
|
|||||||
@ -125,15 +125,26 @@ namespace ai::buff
|
|||||||
key = "rp_missing_reagent_generic";
|
key = "rp_missing_reagent_generic";
|
||||||
|
|
||||||
// Placeholders
|
// Placeholders
|
||||||
std::map<std::string, std::string> placeholders;
|
std::map<std::string, std::string> ph;
|
||||||
placeholders["%group_spell"] = groupName;
|
ph["%group_spell"] = groupName;
|
||||||
placeholders["%base_spell"] = baseName;
|
ph["%base_spell"] = baseName;
|
||||||
|
|
||||||
std::string announceText = sPlayerbotTextMgr->GetBotTextOrDefault(key,
|
// Respecte ai_playerbot_texts_chance if present
|
||||||
"Out of components for %group_spell. Using %base_spell!", placeholders);
|
std::string rp;
|
||||||
|
bool got = sPlayerbotTextMgr->GetBotText(key, rp, ph);
|
||||||
announce(announceText);
|
if (got && !rp.empty())
|
||||||
last = now;
|
{
|
||||||
|
announce(rp);
|
||||||
|
last = now;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Minimal Fallback
|
||||||
|
std::ostringstream oss;
|
||||||
|
oss << "Out of components for " << groupName << ". Using " << baseName << "!";
|
||||||
|
announce(oss.str());
|
||||||
|
last = now;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -20,7 +20,7 @@ public:
|
|||||||
class AutoShareQuestAction : public ShareQuestAction
|
class AutoShareQuestAction : public ShareQuestAction
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
AutoShareQuestAction(PlayerbotAI* botAI) : ShareQuestAction(botAI, "auto share quest") {}
|
AutoShareQuestAction(PlayerbotAI* ai) : ShareQuestAction(botAI, "auto share quest") {}
|
||||||
bool Execute(Event event) override;
|
bool Execute(Event event) override;
|
||||||
|
|
||||||
bool isUseful() override;
|
bool isUseful() override;
|
||||||
|
|||||||
@ -24,7 +24,7 @@ public:
|
|||||||
class MoveRandomStrategy : public NonCombatStrategy
|
class MoveRandomStrategy : public NonCombatStrategy
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
MoveRandomStrategy(PlayerbotAI* botAI) : NonCombatStrategy(botAI) {}
|
MoveRandomStrategy(PlayerbotAI* ai) : NonCombatStrategy(botAI) {}
|
||||||
std::string const getName() override { return "move random"; }
|
std::string const getName() override { return "move random"; }
|
||||||
void InitTriggers(std::vector<TriggerNode*>& triggers) override;
|
void InitTriggers(std::vector<TriggerNode*>& triggers) override;
|
||||||
};
|
};
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user