mirror of
https://github.com/liyunfan1223/mod-playerbots.git
synced 2026-06-20 15:39:25 +02:00
Focus heal targets strategy migration (#2254)
<!--
Thank you for contributing to mod-playerbots, please make sure that
you...
1. Submit your PR to the test-staging branch, not master.
2. Read the guidelines below before submitting.
3. Don't delete parts of this template.
DESIGN PHILOSOPHY: We prioritize STABILITY, PERFORMANCE, AND
PREDICTABILITY over behavioral realism.
Every action and decision executes PER BOT AND PER TRIGGER. Small
increases in logic complexity scale
poorly across thousands of bots and negatively affect all. We prioritize
a stable system over a smarter
one. Bots don't need to behave perfectly; believable behavior is the
goal, not human simulation.
Default behavior must be cheap in processing; expensive behavior must be
opt-in.
Before submitting, make sure your changes aligns with these principles.
-->
## Pull Request Description
<!-- Describe what this change does and why it is needed -->
Migration for "focus heal targets" strategy which order healer to focus
only on specified targets
Commands:
`nc +focus heal targets`
`co +focus heal targets`
`focus heal +botName`
`focus heal -botName`
`focus heal ?`
## How to Test the Changes
<!--
- Step-by-step instructions to test the change.
- Any required setup (e.g. multiple players, number of bots, specific
configuration).
- Expected behavior and how to verify it.
-->
- create bots party with at least one healer
- apply to healer strategy
- order healer focus on single bot
- start fight (for example with dummy)
- use `.damage 10000` to bots a watch which are healed directly and
which one only via aoe healing
## Impact Assessment
<!-- As a generic test, before and after measure of pmon (playerbot pmon
tick) can help you here. -->
- Does this change increase per-bot/per-tick processing or risk scaling
poorly with thousands of bots?
- - [x] No, not at all
- - [ ] Minimal impact (**explain below**)
- - [ ] Moderate impact (**explain below**)
- Does this change modify default bot behavior?
- - [x] No
- - [ ] Yes (**explain why**)
- Does this change add new decision branches or increase maintenance
complexity?
- - [x] No
- - [ ] Yes (**explain below**)
## Messages to Translate
<!--
Bot messages have to be translatable, but you don't need to do the
translations here. You only need to make sure
the message is in a translatable format, and list in the table the
message_key and the default English message.
Search for GetBotTextOrDefault in the codebase for examples.
-->
- Does this change add bot messages to translate?
- - [ ] No
- - [x] Yes (**list messages in the table**)
| Message key | Default message |
| --------------- | ------------------ |
focus_heal_not_healer | I''m not a healer or offhealer (please change my
strats to heal or offheal)
focus_heal_provide_names | Please provide one or more player names
focus_heal_no_targets | I don''t have any focus heal targets
focus_heal_current_targets | My focus heal targets are %targets
focus_heal_cleared | Removed focus heal targets
focus_heal_add_remove_syntax | Please specify a + for add or - to remove
a target
focus_heal_not_in_group | I''m not in a group
focus_heal_not_in_group_with | I''m not in a group with %player_name
focus_heal_added | Added %player_name to focus heal targets
focus_heal_removed | Removed %player_name from focus heal targets
## AI Assistance
<!--
AI assistance is allowed, but all submitted code must be fully
understood, reviewed, and owned by the contributor.
We expect contributors to be honest about what they do and do not
understand.
-->
- Was AI assistance used while working on this change?
- - [ ] No
- - [x] Yes (**explain below**)
<!--
If yes, please specify:
- Purpose of usage (e.g. brainstorming, refactoring, documentation, code
generation).
- Which parts of the change were influenced or generated, and whether it
was thoroughly reviewed.
-->
OpenCode, to help migrate strategy
## Final Checklist
- - [x] Stability is not compromised.
- - [x] Performance impact is understood, tested, and acceptable.
- - [x] Added logic complexity is justified and explained.
- - [ ] Documentation updated if needed (Conf comments, WiKi commands).
## Notes for Reviewers
<!-- Anything else that's helpful to review or test your pull request.
-->
From tests:
<img width="515" height="471" alt="obraz"
src="https://github.com/user-attachments/assets/ed6a2bce-e3b1-4fce-ba6f-1a2b10673c61"
/>
Its optional strategy mostly for raiders then performance is not a
issue.
---------
Co-authored-by: Keleborn <22352763+Celandriel@users.noreply.github.com>
Co-authored-by: bash <hermensb@gmail.com>
Co-authored-by: Revision <tkn963@gmail.com>
This commit is contained in:
parent
51a0d643b6
commit
7cc00e6283
@ -0,0 +1,240 @@
|
||||
-- #########################################################
|
||||
-- Playerbots - Add focus heal command texts
|
||||
-- Localized for all WotLK locales (koKR, frFR, deDE, zhCN,
|
||||
-- zhTW, esES, esMX, ruRU)
|
||||
-- #########################################################
|
||||
|
||||
DELETE FROM ai_playerbot_texts WHERE name IN (
|
||||
'focus_heal_not_healer',
|
||||
'focus_heal_provide_names',
|
||||
'focus_heal_no_targets',
|
||||
'focus_heal_current_targets',
|
||||
'focus_heal_cleared',
|
||||
'focus_heal_add_remove_syntax',
|
||||
'focus_heal_not_in_group',
|
||||
'focus_heal_not_in_group_with',
|
||||
'focus_heal_added',
|
||||
'focus_heal_removed'
|
||||
);
|
||||
DELETE FROM ai_playerbot_texts_chance WHERE name IN (
|
||||
'focus_heal_not_healer',
|
||||
'focus_heal_provide_names',
|
||||
'focus_heal_no_targets',
|
||||
'focus_heal_current_targets',
|
||||
'focus_heal_cleared',
|
||||
'focus_heal_add_remove_syntax',
|
||||
'focus_heal_not_in_group',
|
||||
'focus_heal_not_in_group_with',
|
||||
'focus_heal_added',
|
||||
'focus_heal_removed'
|
||||
);
|
||||
|
||||
-- focus_heal_not_healer
|
||||
INSERT INTO `ai_playerbot_texts`
|
||||
(`id`, `name`, `text`, `say_type`, `reply_type`,
|
||||
`text_loc1`, `text_loc2`, `text_loc3`, `text_loc4`,
|
||||
`text_loc5`, `text_loc6`, `text_loc7`, `text_loc8`)
|
||||
VALUES (
|
||||
1745,
|
||||
'focus_heal_not_healer',
|
||||
'I''m not a healer or offhealer (please change my strats to heal or offheal)',
|
||||
0, 0,
|
||||
'저는 힐러나 오프힐러가 아닙니다 (전략을 heal 또는 offheal로 변경해주세요)',
|
||||
'Je ne suis pas un soigneur ou un soigneur secondaire (veuillez changer mes strats en heal ou offheal)',
|
||||
'Ich bin kein Heiler oder Nebenheiler (bitte ändere meine Strategien auf heal oder offheal)',
|
||||
'我不是治疗者或副治疗者(请将我的策略更改为 heal 或 offheal)',
|
||||
'我不是治療者或副治療者(請將我的策略更改為 heal 或 offheal)',
|
||||
'No soy un sanador ni un sanador secundario (por favor cambia mis estrategias a heal o offheal)',
|
||||
'No soy un sanador ni un sanador secundario (por favor cambia mis estrategias a heal o offheal)',
|
||||
'Я не лекарь и не побочный лекарь (пожалуйста, измените мои стратегии на heal или offheal)');
|
||||
|
||||
INSERT INTO ai_playerbot_texts_chance (name, probability) VALUES ('focus_heal_not_healer', 100);
|
||||
|
||||
-- focus_heal_provide_names
|
||||
INSERT INTO `ai_playerbot_texts`
|
||||
(`id`, `name`, `text`, `say_type`, `reply_type`,
|
||||
`text_loc1`, `text_loc2`, `text_loc3`, `text_loc4`,
|
||||
`text_loc5`, `text_loc6`, `text_loc7`, `text_loc8`)
|
||||
VALUES (
|
||||
1746,
|
||||
'focus_heal_provide_names',
|
||||
'Please provide one or more player names',
|
||||
0, 0,
|
||||
'하나 이상의 플레이어 이름을 제공해주세요',
|
||||
'Veuillez fournir un ou plusieurs noms de joueurs',
|
||||
'Bitte geben Sie einen oder mehrere Spielernamen an',
|
||||
'请提供一个或多个玩家名称',
|
||||
'請提供一個或多個玩家名稱',
|
||||
'Por favor proporciona uno o más nombres de jugadores',
|
||||
'Por favor proporciona uno o más nombres de jugadores',
|
||||
'Пожалуйста, укажите одно или несколько имён игроков');
|
||||
|
||||
INSERT INTO ai_playerbot_texts_chance (name, probability) VALUES ('focus_heal_provide_names', 100);
|
||||
|
||||
-- focus_heal_no_targets
|
||||
INSERT INTO `ai_playerbot_texts`
|
||||
(`id`, `name`, `text`, `say_type`, `reply_type`,
|
||||
`text_loc1`, `text_loc2`, `text_loc3`, `text_loc4`,
|
||||
`text_loc5`, `text_loc6`, `text_loc7`, `text_loc8`)
|
||||
VALUES (
|
||||
1747,
|
||||
'focus_heal_no_targets',
|
||||
'I don''t have any focus heal targets',
|
||||
0, 0,
|
||||
'지정된 집중 치유 대상이 없습니다',
|
||||
'Je n''ai aucune cible de soin prioritaire',
|
||||
'Ich habe keine fokussierten Heilziele',
|
||||
'我没有任何集中治疗目标',
|
||||
'我沒有任何集中治療目標',
|
||||
'No tengo ningún objetivo de sanación prioritario',
|
||||
'No tengo ningún objetivo de sanación prioritario',
|
||||
'У меня нет целей приоритетного лечения');
|
||||
|
||||
INSERT INTO ai_playerbot_texts_chance (name, probability) VALUES ('focus_heal_no_targets', 100);
|
||||
|
||||
-- focus_heal_current_targets: %targets is replaced with comma-separated player names
|
||||
INSERT INTO `ai_playerbot_texts`
|
||||
(`id`, `name`, `text`, `say_type`, `reply_type`,
|
||||
`text_loc1`, `text_loc2`, `text_loc3`, `text_loc4`,
|
||||
`text_loc5`, `text_loc6`, `text_loc7`, `text_loc8`)
|
||||
VALUES (
|
||||
1748,
|
||||
'focus_heal_current_targets',
|
||||
'My focus heal targets are %targets',
|
||||
0, 0,
|
||||
'나의 집중 치유 대상: %targets',
|
||||
'Mes cibles de soin prioritaire sont %targets',
|
||||
'Meine fokussierten Heilziele sind %targets',
|
||||
'我的集中治疗目标是 %targets',
|
||||
'我的集中治療目標是 %targets',
|
||||
'Mis objetivos de sanación prioritarios son %targets',
|
||||
'Mis objetivos de sanación prioritarios son %targets',
|
||||
'Мои цели приоритетного лечения: %targets');
|
||||
|
||||
INSERT INTO ai_playerbot_texts_chance (name, probability) VALUES ('focus_heal_current_targets', 100);
|
||||
|
||||
-- focus_heal_cleared
|
||||
INSERT INTO `ai_playerbot_texts`
|
||||
(`id`, `name`, `text`, `say_type`, `reply_type`,
|
||||
`text_loc1`, `text_loc2`, `text_loc3`, `text_loc4`,
|
||||
`text_loc5`, `text_loc6`, `text_loc7`, `text_loc8`)
|
||||
VALUES (
|
||||
1749,
|
||||
'focus_heal_cleared',
|
||||
'Removed focus heal targets',
|
||||
0, 0,
|
||||
'집중 치유 대상을 제거했습니다',
|
||||
'Cibles de soin prioritaire supprimées',
|
||||
'Fokussierte Heilziele entfernt',
|
||||
'已移除集中治疗目标',
|
||||
'已移除集中治療目標',
|
||||
'Objetivos de sanación prioritarios eliminados',
|
||||
'Objetivos de sanación prioritarios eliminados',
|
||||
'Цели приоритетного лечения удалены');
|
||||
|
||||
INSERT INTO ai_playerbot_texts_chance (name, probability) VALUES ('focus_heal_cleared', 100);
|
||||
|
||||
-- focus_heal_add_remove_syntax
|
||||
INSERT INTO `ai_playerbot_texts`
|
||||
(`id`, `name`, `text`, `say_type`, `reply_type`,
|
||||
`text_loc1`, `text_loc2`, `text_loc3`, `text_loc4`,
|
||||
`text_loc5`, `text_loc6`, `text_loc7`, `text_loc8`)
|
||||
VALUES (
|
||||
1750,
|
||||
'focus_heal_add_remove_syntax',
|
||||
'Please specify a + for add or - to remove a target',
|
||||
0, 0,
|
||||
'대상을 추가하려면 +, 제거하려면 -를 지정해주세요',
|
||||
'Veuillez spécifier + pour ajouter ou - pour retirer une cible',
|
||||
'Bitte geben Sie + zum Hinzufügen oder - zum Entfernen eines Ziels an',
|
||||
'请指定 + 添加或 - 移除目标',
|
||||
'請指定 + 添加或 - 移除目標',
|
||||
'Por favor especifica + para agregar o - para eliminar un objetivo',
|
||||
'Por favor especifica + para agregar o - para eliminar un objetivo',
|
||||
'Пожалуйста, укажите + для добавления или - для удаления цели');
|
||||
|
||||
INSERT INTO ai_playerbot_texts_chance (name, probability) VALUES ('focus_heal_add_remove_syntax', 100);
|
||||
|
||||
-- focus_heal_not_in_group
|
||||
INSERT INTO `ai_playerbot_texts`
|
||||
(`id`, `name`, `text`, `say_type`, `reply_type`,
|
||||
`text_loc1`, `text_loc2`, `text_loc3`, `text_loc4`,
|
||||
`text_loc5`, `text_loc6`, `text_loc7`, `text_loc8`)
|
||||
VALUES (
|
||||
1751,
|
||||
'focus_heal_not_in_group',
|
||||
'I''m not in a group',
|
||||
0, 0,
|
||||
'저는 파티에 속해있지 않습니다',
|
||||
'Je ne suis pas dans un groupe',
|
||||
'Ich bin in keiner Gruppe',
|
||||
'我不在队伍中',
|
||||
'我不在隊伍中',
|
||||
'No estoy en un grupo',
|
||||
'No estoy en un grupo',
|
||||
'Я не в группе');
|
||||
|
||||
INSERT INTO ai_playerbot_texts_chance (name, probability) VALUES ('focus_heal_not_in_group', 100);
|
||||
|
||||
-- focus_heal_not_in_group_with: %player_name is replaced with the target player's name
|
||||
INSERT INTO `ai_playerbot_texts`
|
||||
(`id`, `name`, `text`, `say_type`, `reply_type`,
|
||||
`text_loc1`, `text_loc2`, `text_loc3`, `text_loc4`,
|
||||
`text_loc5`, `text_loc6`, `text_loc7`, `text_loc8`)
|
||||
VALUES (
|
||||
1752,
|
||||
'focus_heal_not_in_group_with',
|
||||
'I''m not in a group with %player_name',
|
||||
0, 0,
|
||||
'%player_name 와(과) 같은 파티에 없습니다',
|
||||
'Je ne suis pas dans un groupe avec %player_name',
|
||||
'Ich bin nicht in einer Gruppe mit %player_name',
|
||||
'我与 %player_name 不在同一队伍中',
|
||||
'我與 %player_name 不在同一隊伍中',
|
||||
'No estoy en un grupo con %player_name',
|
||||
'No estoy en un grupo con %player_name',
|
||||
'Я не в группе с %player_name');
|
||||
|
||||
INSERT INTO ai_playerbot_texts_chance (name, probability) VALUES ('focus_heal_not_in_group_with', 100);
|
||||
|
||||
-- focus_heal_added: %player_name is replaced with the added player's name
|
||||
INSERT INTO `ai_playerbot_texts`
|
||||
(`id`, `name`, `text`, `say_type`, `reply_type`,
|
||||
`text_loc1`, `text_loc2`, `text_loc3`, `text_loc4`,
|
||||
`text_loc5`, `text_loc6`, `text_loc7`, `text_loc8`)
|
||||
VALUES (
|
||||
1753,
|
||||
'focus_heal_added',
|
||||
'Added %player_name to focus heal targets',
|
||||
0, 0,
|
||||
'%player_name 을(를) 집중 치유 대상에 추가했습니다',
|
||||
'%player_name ajouté aux cibles de soin prioritaire',
|
||||
'%player_name zu den fokussierten Heilzielen hinzugefügt',
|
||||
'已将 %player_name 添加到集中治疗目标',
|
||||
'已將 %player_name 添加到集中治療目標',
|
||||
'%player_name agregado a los objetivos de sanación prioritarios',
|
||||
'%player_name agregado a los objetivos de sanación prioritarios',
|
||||
'%player_name добавлен в цели приоритетного лечения');
|
||||
|
||||
INSERT INTO ai_playerbot_texts_chance (name, probability) VALUES ('focus_heal_added', 100);
|
||||
|
||||
-- focus_heal_removed: %player_name is replaced with the removed player's name
|
||||
INSERT INTO `ai_playerbot_texts`
|
||||
(`id`, `name`, `text`, `say_type`, `reply_type`,
|
||||
`text_loc1`, `text_loc2`, `text_loc3`, `text_loc4`,
|
||||
`text_loc5`, `text_loc6`, `text_loc7`, `text_loc8`)
|
||||
VALUES (
|
||||
1754,
|
||||
'focus_heal_removed',
|
||||
'Removed %player_name from focus heal targets',
|
||||
0, 0,
|
||||
'%player_name 을(를) 집중 치유 대상에서 제거했습니다',
|
||||
'%player_name retiré des cibles de soin prioritaire',
|
||||
'%player_name aus den fokussierten Heilzielen entfernt',
|
||||
'已将 %player_name 从集中治疗目标中移除',
|
||||
'已將 %player_name 從集中治療目標中移除',
|
||||
'%player_name eliminado de los objetivos de sanación prioritarios',
|
||||
'%player_name eliminado de los objetivos de sanación prioritarios',
|
||||
'%player_name удалён из целей приоритетного лечения');
|
||||
|
||||
INSERT INTO ai_playerbot_texts_chance (name, probability) VALUES ('focus_heal_removed', 100);
|
||||
219
src/Ai/Base/Actions/SetFocusHealTargetsAction.cpp
Normal file
219
src/Ai/Base/Actions/SetFocusHealTargetsAction.cpp
Normal file
@ -0,0 +1,219 @@
|
||||
/*
|
||||
* Copyright (C) 2016+ AzerothCore <www.azerothcore.org>, released under GNU AGPL v3 license, you may redistribute it
|
||||
* and/or modify it under version 3 of the License, or (at your option), any later version.
|
||||
*/
|
||||
|
||||
#include "SetFocusHealTargetsAction.h"
|
||||
|
||||
#include "ObjectAccessor.h"
|
||||
#include "Playerbots.h"
|
||||
#include "PlayerbotTextMgr.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <cctype>
|
||||
|
||||
static std::string LowercaseString(std::string const& str)
|
||||
{
|
||||
std::string result = str;
|
||||
std::transform(result.begin(), result.end(), result.begin(),
|
||||
[](unsigned char c) { return std::tolower(c); });
|
||||
return result;
|
||||
}
|
||||
|
||||
static Player* FindGroupPlayerByName(Player* player, std::string const& playerName)
|
||||
{
|
||||
if (!player)
|
||||
return nullptr;
|
||||
|
||||
Group* group = player->GetGroup();
|
||||
if (!group)
|
||||
return nullptr;
|
||||
|
||||
for (GroupReference* gref = group->GetFirstMember(); gref; gref = gref->next())
|
||||
{
|
||||
Player* member = gref->GetSource();
|
||||
if (member)
|
||||
{
|
||||
std::string memberName = member->GetName();
|
||||
if (LowercaseString(memberName) == playerName)
|
||||
return member;
|
||||
}
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool SetFocusHealTargetsAction::Execute(Event event)
|
||||
{
|
||||
if (!botAI->IsHeal(bot) && !botAI->HasStrategy("offheal", BOT_STATE_COMBAT))
|
||||
{
|
||||
std::string text = PlayerbotTextMgr::instance().GetBotTextOrDefault(
|
||||
"focus_heal_not_healer",
|
||||
"I'm not a healer or offhealer (please change my strats to heal or offheal)",
|
||||
{});
|
||||
botAI->TellMasterNoFacing(text);
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string const param = LowercaseString(event.getParam());
|
||||
if (param.empty())
|
||||
{
|
||||
std::string text = PlayerbotTextMgr::instance().GetBotTextOrDefault(
|
||||
"focus_heal_provide_names",
|
||||
"Please provide one or more player names",
|
||||
{});
|
||||
botAI->TellMasterNoFacing(text);
|
||||
return false;
|
||||
}
|
||||
|
||||
std::list<ObjectGuid> focusHealTargets =
|
||||
AI_VALUE(std::list<ObjectGuid>, "focus heal targets");
|
||||
|
||||
// Query current focus targets
|
||||
if (param.find('?') != std::string::npos)
|
||||
{
|
||||
if (focusHealTargets.empty())
|
||||
{
|
||||
std::string text = PlayerbotTextMgr::instance().GetBotTextOrDefault(
|
||||
"focus_heal_no_targets",
|
||||
"I don't have any focus heal targets",
|
||||
{});
|
||||
botAI->TellMasterNoFacing(text);
|
||||
}
|
||||
else
|
||||
{
|
||||
std::stringstream targetNames;
|
||||
for (auto it = focusHealTargets.begin(); it != focusHealTargets.end(); ++it)
|
||||
{
|
||||
Unit* target = botAI->GetUnit(*it);
|
||||
if (target)
|
||||
{
|
||||
if (it != focusHealTargets.begin())
|
||||
targetNames << ", ";
|
||||
targetNames << target->GetName();
|
||||
}
|
||||
}
|
||||
|
||||
std::map<std::string, std::string> placeholders;
|
||||
placeholders["%targets"] = targetNames.str();
|
||||
std::string text = PlayerbotTextMgr::instance().GetBotTextOrDefault(
|
||||
"focus_heal_current_targets",
|
||||
"My focus heal targets are %targets",
|
||||
placeholders);
|
||||
botAI->TellMasterNoFacing(text);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// Clear all targets
|
||||
if (param == "none" || param == "unset" || param == "clear")
|
||||
{
|
||||
focusHealTargets.clear();
|
||||
SET_AI_VALUE(std::list<ObjectGuid>, "focus heal targets", focusHealTargets);
|
||||
botAI->ChangeStrategy("-focus heal targets", BOT_STATE_COMBAT);
|
||||
std::string text = PlayerbotTextMgr::instance().GetBotTextOrDefault(
|
||||
"focus_heal_cleared",
|
||||
"Removed focus heal targets",
|
||||
{});
|
||||
botAI->TellMasterNoFacing(text);
|
||||
return true;
|
||||
}
|
||||
|
||||
// Parse multiple targets separated by commas
|
||||
std::vector<std::string> targetNames;
|
||||
if (param.find(',') != std::string::npos)
|
||||
{
|
||||
std::string targetName;
|
||||
std::stringstream ss(param);
|
||||
while (std::getline(ss, targetName, ','))
|
||||
targetNames.push_back(targetName);
|
||||
}
|
||||
else
|
||||
targetNames.push_back(param);
|
||||
|
||||
if (targetNames.empty())
|
||||
{
|
||||
std::string text = PlayerbotTextMgr::instance().GetBotTextOrDefault(
|
||||
"focus_heal_provide_names",
|
||||
"Please provide one or more player names",
|
||||
{});
|
||||
botAI->TellMasterNoFacing(text);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!bot->GetGroup())
|
||||
{
|
||||
std::string text = PlayerbotTextMgr::instance().GetBotTextOrDefault(
|
||||
"focus_heal_not_in_group",
|
||||
"I'm not in a group",
|
||||
{});
|
||||
botAI->TellMasterNoFacing(text);
|
||||
return false;
|
||||
}
|
||||
|
||||
for (std::string const& targetName : targetNames)
|
||||
{
|
||||
bool const add = targetName.find("+") != std::string::npos;
|
||||
bool const remove = targetName.find("-") != std::string::npos;
|
||||
if (!add && !remove)
|
||||
{
|
||||
std::string text = PlayerbotTextMgr::instance().GetBotTextOrDefault(
|
||||
"focus_heal_add_remove_syntax",
|
||||
"Please specify a + for add or - to remove a target",
|
||||
{});
|
||||
botAI->TellMasterNoFacing(text);
|
||||
continue;
|
||||
}
|
||||
|
||||
std::string const playerName = targetName.substr(1);
|
||||
Player* target = FindGroupPlayerByName(bot, playerName);
|
||||
if (!target)
|
||||
{
|
||||
std::map<std::string, std::string> placeholders;
|
||||
placeholders["%player_name"] = playerName;
|
||||
std::string text = PlayerbotTextMgr::instance().GetBotTextOrDefault(
|
||||
"focus_heal_not_in_group_with",
|
||||
"I'm not in a group with %player_name",
|
||||
placeholders);
|
||||
botAI->TellMasterNoFacing(text);
|
||||
continue;
|
||||
}
|
||||
|
||||
ObjectGuid const& targetGuid = target->GetGUID();
|
||||
if (add)
|
||||
{
|
||||
if (std::find(focusHealTargets.begin(), focusHealTargets.end(), targetGuid) ==
|
||||
focusHealTargets.end())
|
||||
focusHealTargets.push_back(targetGuid);
|
||||
|
||||
std::map<std::string, std::string> placeholders;
|
||||
placeholders["%player_name"] = playerName;
|
||||
std::string text = PlayerbotTextMgr::instance().GetBotTextOrDefault(
|
||||
"focus_heal_added",
|
||||
"Added %player_name to focus heal targets",
|
||||
placeholders);
|
||||
botAI->TellMasterNoFacing(text);
|
||||
}
|
||||
else
|
||||
{
|
||||
focusHealTargets.remove(targetGuid);
|
||||
std::map<std::string, std::string> placeholders;
|
||||
placeholders["%player_name"] = playerName;
|
||||
std::string text = PlayerbotTextMgr::instance().GetBotTextOrDefault(
|
||||
"focus_heal_removed",
|
||||
"Removed %player_name from focus heal targets",
|
||||
placeholders);
|
||||
botAI->TellMasterNoFacing(text);
|
||||
}
|
||||
}
|
||||
|
||||
SET_AI_VALUE(std::list<ObjectGuid>, "focus heal targets", focusHealTargets);
|
||||
|
||||
if (focusHealTargets.empty())
|
||||
botAI->ChangeStrategy("-focus heal targets", BOT_STATE_COMBAT);
|
||||
else
|
||||
botAI->ChangeStrategy("+focus heal targets", BOT_STATE_COMBAT);
|
||||
|
||||
return true;
|
||||
}
|
||||
21
src/Ai/Base/Actions/SetFocusHealTargetsAction.h
Normal file
21
src/Ai/Base/Actions/SetFocusHealTargetsAction.h
Normal file
@ -0,0 +1,21 @@
|
||||
/*
|
||||
* Copyright (C) 2016+ AzerothCore <www.azerothcore.org>, released under GNU AGPL v3 license, you may redistribute it
|
||||
* and/or modify it under version 3 of the License, or (at your option), any later version.
|
||||
*/
|
||||
|
||||
#ifndef _PLAYERBOT_SETFOCUSHEALTARGETSACTION_H
|
||||
#define _PLAYERBOT_SETFOCUSHEALTARGETSACTION_H
|
||||
|
||||
#include "Action.h"
|
||||
|
||||
class PlayerbotAI;
|
||||
|
||||
class SetFocusHealTargetsAction : public Action
|
||||
{
|
||||
public:
|
||||
SetFocusHealTargetsAction(PlayerbotAI* botAI) : Action(botAI, "focus heal targets") {}
|
||||
|
||||
bool Execute(Event event) override;
|
||||
};
|
||||
|
||||
#endif
|
||||
@ -37,6 +37,7 @@
|
||||
#include "LogLevelAction.h"
|
||||
#include "LootStrategyAction.h"
|
||||
#include "LootRollAction.h"
|
||||
#include "SetFocusHealTargetsAction.h"
|
||||
#include "MailAction.h"
|
||||
#include "NamedObjectContext.h"
|
||||
#include "NewRpgAction.h"
|
||||
@ -201,6 +202,7 @@ public:
|
||||
creators["pet attack"] = &ChatActionContext::pet_attack;
|
||||
creators["roll"] = &ChatActionContext::roll_action;
|
||||
creators["wait for attack time"] = &ChatActionContext::wait_for_attack_time;
|
||||
creators["focus heal targets"] = &ChatActionContext::focus_heal_targets;
|
||||
}
|
||||
|
||||
private:
|
||||
@ -314,6 +316,7 @@ private:
|
||||
static Action* pet_attack(PlayerbotAI* botAI) { return new PetsAction(botAI, "attack"); }
|
||||
static Action* roll_action(PlayerbotAI* botAI) { return new RollAction(botAI); }
|
||||
static Action* wait_for_attack_time(PlayerbotAI* botAI) { return new SetWaitForAttackTimeAction(botAI); }
|
||||
static Action* focus_heal_targets(PlayerbotAI* botAI) { return new SetFocusHealTargetsAction(botAI); }
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@ -146,6 +146,7 @@ public:
|
||||
creators["pet attack"] = &ChatTriggerContext::pet_attack;
|
||||
creators["roll"] = &ChatTriggerContext::roll_action;
|
||||
creators["wait for attack time"] = &ChatTriggerContext::wait_for_attack_time;
|
||||
creators["focus heal"] = &ChatTriggerContext::focus_heal;
|
||||
}
|
||||
|
||||
private:
|
||||
@ -271,6 +272,7 @@ private:
|
||||
static Trigger* pet_attack(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "pet attack"); }
|
||||
static Trigger* roll_action(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "roll"); }
|
||||
static Trigger* wait_for_attack_time(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "wait for attack time"); }
|
||||
static Trigger* focus_heal(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "focus heal"); }
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@ -107,6 +107,7 @@ void ChatCommandHandlerStrategy::InitTriggers(std::vector<TriggerNode*>& trigger
|
||||
triggers.push_back(new TriggerNode("pet", { NextAction("pet", relevance) }));
|
||||
triggers.push_back(new TriggerNode("pet attack", { NextAction("pet attack", relevance) }));
|
||||
triggers.push_back(new TriggerNode("roll", { NextAction("roll", relevance) }));
|
||||
triggers.push_back(new TriggerNode("focus heal", { NextAction("focus heal targets", relevance) }));
|
||||
}
|
||||
|
||||
ChatCommandHandlerStrategy::ChatCommandHandlerStrategy(PlayerbotAI* botAI) : PassTroughStrategy(botAI)
|
||||
@ -200,4 +201,5 @@ ChatCommandHandlerStrategy::ChatCommandHandlerStrategy(PlayerbotAI* botAI) : Pas
|
||||
supported.push_back("pet");
|
||||
supported.push_back("pet attack");
|
||||
supported.push_back("wait for attack time");
|
||||
supported.push_back("focus heal");
|
||||
}
|
||||
|
||||
20
src/Ai/Base/Strategy/FocusTargetStrategy.h
Normal file
20
src/Ai/Base/Strategy/FocusTargetStrategy.h
Normal file
@ -0,0 +1,20 @@
|
||||
/*
|
||||
* Copyright (C) 2016+ AzerothCore <www.azerothcore.org>, released under GNU AGPL v3 license, you may redistribute it
|
||||
* and/or modify it under version 3 of the License, or (at your option), any later version.
|
||||
*/
|
||||
|
||||
#ifndef _PLAYERBOT_FOCUSTARGETSTRATEGY_H
|
||||
#define _PLAYERBOT_FOCUSTARGETSTRATEGY_H
|
||||
|
||||
#include "Strategy.h"
|
||||
|
||||
class PlayerbotAI;
|
||||
|
||||
class FocusHealTargetsStrategy : public Strategy
|
||||
{
|
||||
public:
|
||||
FocusHealTargetsStrategy(PlayerbotAI* botAI) : Strategy(botAI) {}
|
||||
std::string const getName() override { return "focus heal targets"; }
|
||||
};
|
||||
|
||||
#endif
|
||||
@ -19,6 +19,7 @@
|
||||
#include "DuelStrategy.h"
|
||||
#include "EmoteStrategy.h"
|
||||
#include "FleeStrategy.h"
|
||||
#include "FocusTargetStrategy.h"
|
||||
#include "FollowMasterStrategy.h"
|
||||
#include "GrindingStrategy.h"
|
||||
#include "GroupStrategy.h"
|
||||
@ -126,6 +127,7 @@ public:
|
||||
creators["use bobber"] = &StrategyContext::bobber_strategy;
|
||||
creators["master fishing"] = &StrategyContext::master_fishing;
|
||||
creators["wait for attack"] = &StrategyContext::wait_for_attack;
|
||||
creators["focus heal targets"] = &StrategyContext::focus_heal_targets;
|
||||
}
|
||||
|
||||
private:
|
||||
@ -198,6 +200,7 @@ private:
|
||||
static Strategy* bobber_strategy(PlayerbotAI* botAI) { return new UseBobberStrategy(botAI); }
|
||||
static Strategy* master_fishing(PlayerbotAI* botAI) { return new MasterFishingStrategy(botAI); }
|
||||
static Strategy* wait_for_attack(PlayerbotAI* botAI) { return new WaitForAttackStrategy(botAI); }
|
||||
static Strategy* focus_heal_targets(PlayerbotAI* botAI) { return new FocusHealTargetsStrategy(botAI); }
|
||||
};
|
||||
|
||||
class MovementStrategyContext : public NamedObjectContext<Strategy>
|
||||
|
||||
@ -38,6 +38,36 @@ Unit* PartyMemberToHeal::Calculate()
|
||||
bool isRaid = bot->GetGroup()->isRaidGroup();
|
||||
MinValueCalculator calc(100);
|
||||
|
||||
// If focus heal targets strategy is active, only heal those targets
|
||||
if (botAI->HasStrategy("focus heal targets", BOT_STATE_COMBAT))
|
||||
{
|
||||
std::list<ObjectGuid> const focusHealTargets =
|
||||
AI_VALUE(std::list<ObjectGuid>, "focus heal targets");
|
||||
|
||||
for (ObjectGuid const& focusHealTarget : focusHealTargets)
|
||||
{
|
||||
Player* player = ObjectAccessor::FindPlayer(focusHealTarget);
|
||||
if (!player || !player->IsInWorld() || !player->IsAlive() || !player->IsInSameGroupWith(bot))
|
||||
continue;
|
||||
|
||||
float health = player->GetHealthPct();
|
||||
if (isRaid || health < sPlayerbotAIConfig.mediumHealth ||
|
||||
!IsTargetOfSpellCast(player, predicate))
|
||||
{
|
||||
float probeValue = 100.0f;
|
||||
if (player->GetDistance2d(bot) > sPlayerbotAIConfig.healDistance)
|
||||
probeValue = health + 30.0f;
|
||||
else
|
||||
probeValue = health + player->GetDistance2d(bot) / 10.0f;
|
||||
|
||||
if (probeValue < calc.minValue && Check(player))
|
||||
calc.probe(probeValue, player);
|
||||
}
|
||||
}
|
||||
|
||||
return (Unit*)calc.param;
|
||||
}
|
||||
|
||||
for (GroupReference* gref = group->GetFirstMember(); gref; gref = gref->next())
|
||||
{
|
||||
Player* player = gref->GetSource();
|
||||
@ -45,17 +75,17 @@ Unit* PartyMemberToHeal::Calculate()
|
||||
continue;
|
||||
if (player && player->IsAlive())
|
||||
{
|
||||
uint8 health = player->GetHealthPct();
|
||||
float health = player->GetHealthPct();
|
||||
if (isRaid || health < sPlayerbotAIConfig.mediumHealth || !IsTargetOfSpellCast(player, predicate))
|
||||
{
|
||||
uint32 probeValue = 100;
|
||||
float probeValue = 100.0f;
|
||||
if (player->GetDistance2d(bot) > sPlayerbotAIConfig.healDistance)
|
||||
{
|
||||
probeValue = health + 30;
|
||||
probeValue = health + 30.0f;
|
||||
}
|
||||
else
|
||||
{
|
||||
probeValue = health + player->GetDistance2d(bot) / 10;
|
||||
probeValue = health + player->GetDistance2d(bot) / 10.0f;
|
||||
}
|
||||
// delay Check player to here for better performance
|
||||
if (probeValue < calc.minValue && Check(player))
|
||||
@ -68,10 +98,10 @@ Unit* PartyMemberToHeal::Calculate()
|
||||
Pet* pet = player->GetPet();
|
||||
if (pet && pet->IsAlive())
|
||||
{
|
||||
uint8 health = ((Unit*)pet)->GetHealthPct();
|
||||
uint32 probeValue = 100;
|
||||
float health = ((Unit*)pet)->GetHealthPct();
|
||||
float probeValue = 100.0f;
|
||||
if (isRaid || health < sPlayerbotAIConfig.mediumHealth)
|
||||
probeValue = health + 30;
|
||||
probeValue = health + 30.0f;
|
||||
// delay Check pet to here for better performance
|
||||
if (probeValue < calc.minValue && Check(pet))
|
||||
{
|
||||
@ -82,10 +112,10 @@ Unit* PartyMemberToHeal::Calculate()
|
||||
Unit* charm = player->GetCharm();
|
||||
if (charm && charm->IsAlive())
|
||||
{
|
||||
uint8 health = charm->GetHealthPct();
|
||||
uint32 probeValue = 100;
|
||||
float health = charm->GetHealthPct();
|
||||
float probeValue = 100.0f;
|
||||
if (isRaid || health < sPlayerbotAIConfig.mediumHealth)
|
||||
probeValue = health + 30;
|
||||
probeValue = health + 30.0f;
|
||||
// delay Check charm to here for better performance
|
||||
if (probeValue < calc.minValue && Check(charm))
|
||||
{
|
||||
|
||||
@ -140,4 +140,11 @@ public:
|
||||
public:
|
||||
Unit* Calculate();
|
||||
};
|
||||
|
||||
class FocusHealTargetValue : public ManualSetValue<std::list<ObjectGuid>>
|
||||
{
|
||||
public:
|
||||
FocusHealTargetValue(PlayerbotAI* botAI) : ManualSetValue<std::list<ObjectGuid>>(botAI, {}, "focus heal targets") {}
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@ -241,6 +241,7 @@ public:
|
||||
creators["travel target"] = &ValueContext::travel_target;
|
||||
creators["talk target"] = &ValueContext::talk_target;
|
||||
creators["pull target"] = &ValueContext::pull_target;
|
||||
creators["focus heal targets"] = &ValueContext::focus_heal_targets;
|
||||
creators["group"] = &ValueContext::group;
|
||||
creators["range"] = &ValueContext::range;
|
||||
creators["inside target"] = &ValueContext::inside_target;
|
||||
@ -497,6 +498,7 @@ private:
|
||||
static UntypedValue* next_rpg_action(PlayerbotAI* botAI) { return new NextRpgActionValue(botAI); }
|
||||
static UntypedValue* travel_target(PlayerbotAI* botAI) { return new TravelTargetValue(botAI); }
|
||||
static UntypedValue* pull_target(PlayerbotAI* botAI) { return new PullTargetValue(botAI); }
|
||||
static UntypedValue* focus_heal_targets(PlayerbotAI* botAI) { return new FocusHealTargetValue(botAI); }
|
||||
|
||||
static UntypedValue* bg_master(PlayerbotAI* botAI) { return new BgMasterValue(botAI); }
|
||||
static UntypedValue* bg_role(PlayerbotAI* botAI) { return new BgRoleValue(botAI); }
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user