mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-11 21:01:29 +00:00
* Implement spell AI pulling, fix throw stone * more pull tweaks * holding check at start of ai process * fully implement ^pull logic to always return, can still be overidden by ^attack * Rewrite ^pull logic and handling. **MORE** Add ^setassistee command to set who your bots will assist. Bots will always assist you first before anyone else. If the rule Bots, AllowCrossGroupRaidAssist is enabled bots will assist the group or raid main assists. Rewrites logic in handling of pull and returning to ensure bots make it back to their location. * Move HateLine to a better ID * cleanup ST_Self logic in CastChecks * Removed unused BotSpellTypeRequiresLoS * Move fizzle message to define * add timer checks to Idle/Engaged/Pursue CastCheck to early terminate * Add back !IsBotNonSpellFighter() check to the different CastCheck * Correct IsValidSpellRange * Implement AAs and harmtouch/layonhands to ^cast --- fix IsValidSpellRange * Add PetDamageShields and PetResistBuffs to IsPetBotSpellType() * Add priorities to HateLine inserts for db update * Remove SpellTypeRequiresCastChecks * Add bot check to DetermineSpellTargets for IsIllusionSpell * merge with previous * Correct bot checks for ST_GroupClientAndPet * Remove misc target_type checks * Add lull/aelull to ^cast * Add more checks for CommandedSubTypes::AETarget * remove unneeded checks on IsValidSpellTypeBySpellID * add to aelull * rewrite GetCorrectSpellType * Add IsBlockedBuff to CastChecks * Add spellid option to ^cast to allow casting of a specific spell by ID * ^cast adjustments for spellid casts * Add missing alert round for ranged attacks * More castcheck improvements * CanUseBotSpell for ^cast * remove ht/loh from attack ai * remove SetCombatRoundForAlerts that triggered every engagement * Add RangedAttackImmunity checks before trying to ranged attack * move bot backstab to mob * fix MinStatusToBypassCreateLimit * more backstab to mob cleanup * add bot checks to tryheadshot / tryassassinate * adjust version number for bots * add back m_mob_check_moving_timer, necessary? * add sanity checks for classattacks * Get rid of Bots:BotGroupXP and change logic to support Bots:SameRaidGroupForXP Bots won't do anything if not in the same group so this should more accurately control only when in the same raid group. * add "confirm" check to ^delete * Update bot.cpp * Remove `id` from bot_settings, correct types * Implement blocked_buffs and blocked_pet_buffs * more blocked buff tweaks * add beneficial check to ^blockedbuffs * command grammar * missing ) * Move getnames for categories and settings to mob, rename hptomed/manatomed * add GetBotSpellCategoryIDByShortName and CopyBotBlockedPetBuffs, update ^defaultsettings command * cls cleanup * Allow bots to clear HasProjectIllusion flag * Add PercentChanceToCastGroupCure * Implmenet PetCures, add some missing types for defaults/chance to cast * Change GetRaidByBotName to GetRaidByBot * Typo on PetBuffs implement * Change GetSpellListSpellType to GetParentSpellType * missing from GetChanceToCastBySpellType * Fix performance in IsValidSpellRange by flipping HasProjectIllusion * merge with prev * merge with cls cleanup * Reorder IsTargetAlreadyReceivingSpell/CheckSpellLevelRestriction/IsBlockedBuff * Combine GatherGroupSpellTargets and GatherSpellTargets * Cleanup IsTargetAlreadyReceivingSpell * Fix ^petsettype to account for usable levels of spells and remove hardcoded level limits. * Remove Bot_AICheckCloseBeneficialSpells and use AttemptCloseBeneficialSpells for better performance * remove default hold for resist buffa * move IsValidSpellRange further down castchecks * raid optimizations * correct name checking to match players * more name checks and add proper soft deletes to bots * organize some checks in IsImmuneToBotSpell * Fix GetRaidByBotName and GetRaidByBot checks to not loop unnecessarily * Move GatherSpellTargets to mob * Change GetPrioritizedBotSpellsBySpellType to vector Some slipped through in "organize some checks in IsImmuneToBotSpell" * Move GatherSpellTargets and Raid to stored variables. Missing some in "organize some checks in IsImmuneToBotSpell" * comment out precheck, delays, thresholds, etc logging missed some in "organize some checks in IsImmuneToBotSpell" * Missing IsInGroupOrRaid cleanup * Implement AIBot_spells_by_type to reduce looping when searching for spells * Add _tempSpellType as placeholder for any future passthru * todo * Move bot_list from std::list to std::unordered_map like other entities * Fix missing raid assignment for GetStoredRaid in IsInGroupOrRaid * TempPet owned by bots that get the kill will now give exp like a client would * Remove unnecessary checks in bot process (closescanmoving timer, verify raid, send hp/mana/end packet * Fix client spell commands from saving the wrong setting * Cleanup ^copysettings command and add new commands * Add pet option to ^taunt No longer has toggle, required on/off option and an optional "pet" option to control pets' taunting state * Allow pet types to ^cast, prevent failure spam, add cure check * more raid optimizations, should be final. 10 clients, 710 bots, 10 raids, ~250 pets sits around 3.5% CPU idle * Move spell range check to proper location * Implement ^discipline * remove ^aggressive/^defensive * remove this for a separate PR * cleanup * Add BotGroupSay method * todo list * Add missing bot_blocked_buffs to schema * Remove plural on ^spelltypeidsand ^spelltypenames * Move spelltype names, spell subtypes, category names and setting names to maps. * move los checks to mob.cpp * Bot CampAll fix * Bots special_attacks.cpp fix * Add zero check for bot spawn limits If the spawn limit rule is set to 0 and spawn limit is set by bucket, if no class buckets are set, it defaults to the rule of 0 and renders the player unable to spawn bots. This adds a check where if the rule and class bucket are 0, it will check for the spawn limit bucket * Add HasSkill checks to bot special abilities (kick/bash/etc) * code cleanup 1 * code cleanup 2 * code cleanup 3 * code cleanup 4 * fix ^cast wirh commanded types * Remove bcspells, fix helper_send_usage_required_bots * linux build fix * remove completed todo * Allow inventory give to specific ID slots * Update TODO * Correct slot ranges for inventorygive * Add zone specific spawn limits and zone specific forced spawn limits * remove bd. from update queries where it doesn't exist * Rename _spellSettings to m_bot_spell_settings * Add IsPetOwnerOfClientBot(), add Lua and Perl methods * Make botOwnerCharacterID snakecase * Throw bot_camp_timer behind Bots:Enabled rule * Move various Bot<>Checks logging to BotSpellChecks * Remove from LogCategoryName * Consolidate IsInGroupOrRaid * Consolidate GatherSpellTargets * Add missing Bot Spell Type Checks to log * Add GetParentSpellType when checking spelltypes for idle, engaged, pursue CastChecks. * Consolidate AttemptForcedCastSpell * Consolidate SetBotBlockedBuff/SetBotBlockedPetBuff * Add list option to ^spellpriority commands. * Move client functions to client_bot * Move mob functions to mob_bot * Move bot spdat functions to spdat_bot * Move SendCommandHelpWindow to SendBotCommandHelpWindow and simplify * Change char_id to character_id for bot_settings * update todo * Fix typo on merge conflict * Cleanup command format changes, remove hardcoded class IDs in examples. * Set #illusionblock for players to guide access * Move client commands for bot spells from gm commands to existing bot commands * Fix alignment issues * More alignment fixes * More cleanup 1 * More cleanup 2 * Fix BotMeditate to med at proper percentages * Correct GetStopMeleeLevel checks for some buff checks * Add back hpmanaend update to bot raid, force timer update to prevent spamming * Remove log * Cleanup ranged and ammo calculations - Adds throwing check for match * Add check in distance calculations to stay at range if set even if no ammo or ranged * Move melee distance calculations to better function * Add GetBuffTargets helper * Missing p_item, s_item in CombatRangeInput * Linux test? * Reduce GetCorrectBotSpellType branching slightly This is still an ugly ass function but my brain is melted * Line fixes * Make bot pets only do half damage in pvp * Add bot pet pvp damage to tune * Add bot pet check for AIYellForHelp * Add bots to UseSpellImpliedTargeting * Move toggleranged, togglehelm and illusionblock to new help window. Add actionable support * Add bot and bot pet checks to various spells, auras and targeting checks that were missing. * update todo * New lines * Correct DoLosChecks * Remove Log TestDebug * Remove _Struct from struct declarations * Add bot check to IsAttackAllowed for GetUltimateOwner to skip entity list where possible * Wrap SaveBotSettings in Bots Enabled check * Remove comment * Wrap bot setting loading for clients in bots enabled rule * Cleanup BlockedBuffs logic in SpellOnTarget * Rename BotSpells_Struct/BotSpells_Struct_wIndex * Rename spawn/create status bypass rules, fix return for spawn limit * Remove unnecessary return in CanBuffStack, cleanup * Enable recastdelay support for clients * Remove unused variables * Rename _assistee to bot_assistee * hardcode BotCommandHelpWindow colors * todo * Fix ^cast summoncorpse * todo * Reimplement secondary colors to BotSendCommandHelpWindow * Give ^copysettings/^defaultsettings more options, cleanup. * Cleanup some commands * Add comment to CheckLosCheat/CheckLosCheatExempt * Make struct BotSpellSettings snake case * Allow duplicate casts of same spell on target for heals and cures * Add default delay to cures * Remove unused methods * Implement missing ^spellresistlimits/^resistlimits command * Move functions out of mob.h and cleanup * Return for GetRawBotList This checks offline bots too * Rename BotGroupSay to RaidGroupSay * Prevent bots from forming their own group if a bot that is a group leader is removed from the raid * Linux fix? * IsPetOwner fixes * Add remove option to list for ^blockedbuffs / ^blockedpetbuffs * Implement ^spellannouncecasts to toggle announcing casts of spell types * Remove rule Bots:BardsAnnounceCasts * Update bot.h * Remove unused no_pets option from GatherSpellTargets * Move ^attack response back to normal chat window (other) * Set lower limit of spell delays to 100 rather than 1 * Correct pet checks on GetUltimateSpell functions * Add rules (Bots, AICastSpellTypeDelay, Bots, AICastSpellTypeHeldDelay) to prevent spamming of failed spell type AI casts * Correct pet buff type logic to catch DS/Resists with other spell effects in them * Fix defaults for clients * Add more logic for necros/shaman for default heal thresholds due to lich and canni * Rename SpellHold, SpellDelay, SpellMinThreshold, SpellMaxThreshold, SpellRecastDelay to fit SpellType style naming * Use GetTempSpellType() for announce check in RaidGroupSay * Make all spell shortnames plural where applicable * Update bot.cpp * Bots:BotsUseLiveBlockedMessage filter to spell failure * Move GetSpellTargetList to only get called when necessary to reduce overhead * formatting * Formatting * Simplify case SE_Illusion and SE_IllusionCopy for GetIllusionBlock * Clean up InterruptSpell * Cleanup IsBot() checks for DetermineSpellTargets->ST_GroupClientAndPet * Cleanup range/aoe_range check in SpellFinished * Cleanup DetermineSpellTargets->ST_GroupNoPets * Cleanup DetermineSpellTargets->ST_Self for bot summon corpse * Cleanup DetermineSpellTargets->ST_Pet * Cleanup bot logic in TryBackstab * Cleanup IsAttackAllowed checks for bots and their pets * Cleanup StopMoving for bots * Cleanup CanThisClassTripleAttack * Fix casting for GetIllusionBlock checks * Formatting * Fix DetermineSpellTargets for group spells (this also wasn't properly checking the rule Character:EnableTGB in master) * Cleanup spelltarget grabbing logic, consolidate group heals in to GetNumberNeedingHealedInGroup * Throw added client los pet checks behind LoS cheat rule for bots * CLeanup give_exp on npc death logic and ensure client pets always pass. * Undo unintended rename from previous refactor * Remove pointless Bots, SameRaidGroupForXP rule * Revision to 0690783a9d1e99005d6bee0824597ea920e26df9 --------- Co-authored-by: Akkadius <akkadius1@gmail.com>
1194 lines
36 KiB
C++
1194 lines
36 KiB
C++
/* EQEMu: Everquest Server Emulator
|
|
Copyright (C) 2001-2016 EQEMu Development Team (http://eqemulator.org)
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
it under the terms of the GNU General Public License as published by
|
|
the Free Software Foundation; version 2 of the License.
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY except by those people which sell it, which
|
|
are required to give you total support for your newly bought product;
|
|
without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
|
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with this program; if not, write to the Free Software
|
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
*/
|
|
|
|
|
|
#ifndef BOT_COMMAND_H
|
|
#define BOT_COMMAND_H
|
|
|
|
class Client;
|
|
class Seperator;
|
|
|
|
#include "../common/types.h"
|
|
#include "bot.h"
|
|
#include "dialogue_window.h"
|
|
|
|
namespace
|
|
{
|
|
#define HP_RATIO_DELTA 5.0f
|
|
|
|
enum { EffectIDFirst = 1, EffectIDLast = 12 };
|
|
|
|
#define VALIDATECLASSID(x) ((x >= Class::Warrior && x <= Class::Berserker) ? (x) : (0))
|
|
|
|
// ActionableTarget action_type
|
|
#define FRIENDLY true
|
|
#define ENEMY false
|
|
|
|
enum {
|
|
AFT_None = 0,
|
|
AFT_Value,
|
|
AFT_GenderRace,
|
|
AFT_Race
|
|
};
|
|
}
|
|
|
|
namespace MyBots
|
|
{
|
|
static bool IsMyBot(Client *bot_owner, Mob *my_bot) {
|
|
if (!bot_owner || !my_bot || !my_bot->IsBot()) {
|
|
return false;
|
|
}
|
|
|
|
auto test_bot = my_bot->CastToBot();
|
|
if (!test_bot->GetOwner() || !test_bot->GetOwner()->IsClient() || test_bot->GetOwner()->CastToClient() != bot_owner) {
|
|
return false;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
static bool IsMyBotInTargetsGroup(Client *bot_owner, Mob *grouped_bot) {
|
|
if (!bot_owner || !grouped_bot || !grouped_bot->GetGroup() || !IsMyBot(bot_owner, grouped_bot)) {
|
|
return false;
|
|
}
|
|
|
|
auto target_mob = bot_owner->GetTarget();
|
|
if (!target_mob) {
|
|
return false;
|
|
}
|
|
|
|
if (!target_mob->GetGroup() || (!target_mob->IsClient() && !target_mob->IsBot())) {
|
|
return false;
|
|
}
|
|
|
|
return (grouped_bot->GetGroup() == target_mob->GetGroup());
|
|
}
|
|
|
|
static bool IsMyBotInPlayerGroup(Client *bot_owner, Mob *grouped_bot, Client *grouped_player) {
|
|
if (!bot_owner || !grouped_player || !grouped_player->GetGroup() || !grouped_bot || !grouped_bot->GetGroup() || !IsMyBot(bot_owner, grouped_bot)) {
|
|
return false;
|
|
}
|
|
|
|
return (grouped_player->GetGroup() == grouped_bot->GetGroup());
|
|
}
|
|
|
|
static void UniquifySBL(std::vector<Bot*> &sbl) {
|
|
sbl.erase(std::remove(sbl.begin(), sbl.end(), nullptr), sbl.end());
|
|
std::sort(sbl.begin(), sbl.end());
|
|
sbl.erase(std::unique(sbl.begin(), sbl.end()), sbl.end());
|
|
}
|
|
|
|
static void PopulateSBL_ByTargetedBot(Client *bot_owner, std::vector<Bot*> &sbl, bool clear_list = true) {
|
|
if (clear_list) {
|
|
sbl.clear();
|
|
}
|
|
|
|
if (IsMyBot(bot_owner, bot_owner->GetTarget())) {
|
|
sbl.push_back(bot_owner->GetTarget()->CastToBot());
|
|
}
|
|
|
|
if (!clear_list) {
|
|
UniquifySBL(sbl);
|
|
}
|
|
}
|
|
|
|
static void PopulateSBL_ByNamedBot(Client *bot_owner, std::vector<Bot*> &sbl, const char* name, bool clear_list = true) {
|
|
if (clear_list) {
|
|
sbl.clear();
|
|
}
|
|
|
|
if (!bot_owner || !name) {
|
|
return;
|
|
}
|
|
|
|
auto selectable_bot_list = entity_list.GetBotsByBotOwnerCharacterID(bot_owner->CharacterID());
|
|
for (auto bot_iter : selectable_bot_list) {
|
|
if (!strcasecmp(bot_iter->GetCleanName(), name)) {
|
|
sbl.push_back(bot_iter);
|
|
return;
|
|
}
|
|
}
|
|
|
|
if (!clear_list) {
|
|
UniquifySBL(sbl);
|
|
}
|
|
}
|
|
|
|
static void PopulateSBL_ByMyGroupedBots(Client *bot_owner, std::vector<Bot*> &sbl, bool clear_list = true) {
|
|
if (clear_list) {
|
|
sbl.clear();
|
|
}
|
|
|
|
if (!bot_owner) {
|
|
return;
|
|
}
|
|
|
|
if (!bot_owner->GetGroup() && !bot_owner->GetRaid()) {
|
|
return;
|
|
}
|
|
|
|
if (bot_owner->IsRaidGrouped()) {
|
|
Raid* raid = bot_owner->GetRaid();
|
|
if (!raid) {
|
|
return;
|
|
}
|
|
|
|
uint32 raid_group = raid->GetGroup(bot_owner);
|
|
if (raid_group >= MAX_RAID_GROUPS) {
|
|
return;
|
|
}
|
|
|
|
for (const auto& m : raid->members) {
|
|
if (m.member && m.group_number == raid_group) {
|
|
if (!MyBots::IsMyBot(bot_owner, m.member->CastToBot())) {
|
|
continue;
|
|
}
|
|
|
|
sbl.push_back(m.member->CastToBot());
|
|
}
|
|
}
|
|
}
|
|
else {
|
|
std::list<Bot*> group_list;
|
|
bot_owner->GetGroup()->GetBotList(group_list);
|
|
for (auto member_iter : group_list) {
|
|
if (IsMyBot(bot_owner, member_iter)) {
|
|
sbl.push_back(member_iter);
|
|
}
|
|
}
|
|
}
|
|
|
|
if (!clear_list) {
|
|
UniquifySBL(sbl);
|
|
}
|
|
}
|
|
|
|
static void PopulateSBL_ByMyRaidBots(Client* bot_owner, std::vector<Bot*>& sbl, bool clear_list = true) {
|
|
if (clear_list) {
|
|
sbl.clear();
|
|
}
|
|
|
|
if (!bot_owner) {
|
|
return;
|
|
}
|
|
|
|
if (!bot_owner->GetRaid()) {
|
|
return;
|
|
}
|
|
|
|
Raid* raid = bot_owner->GetRaid();
|
|
if (!raid) {
|
|
return;
|
|
}
|
|
|
|
for (const auto& m : raid->members) {
|
|
if (m.member) {
|
|
if (!MyBots::IsMyBot(bot_owner, m.member->CastToBot())) {
|
|
continue;
|
|
}
|
|
|
|
sbl.push_back(m.member->CastToBot());
|
|
}
|
|
}
|
|
|
|
if (!clear_list) {
|
|
UniquifySBL(sbl);
|
|
}
|
|
}
|
|
|
|
static void PopulateSBL_ByTargetsGroupedBots(Client *bot_owner, std::vector<Bot*> &sbl, bool clear_list = true) {
|
|
if (clear_list) {
|
|
sbl.clear();
|
|
}
|
|
|
|
if (!bot_owner) {
|
|
return;
|
|
}
|
|
|
|
auto target_mob = bot_owner->GetTarget();
|
|
if (!target_mob || (!target_mob->GetGroup() && !target_mob->GetRaid()) || (!target_mob->IsClient() && !target_mob->IsBot())) {
|
|
return;
|
|
}
|
|
|
|
if (bot_owner->IsRaidGrouped()) {
|
|
Raid* raid = bot_owner->GetRaid();
|
|
if (!raid) {
|
|
return;
|
|
}
|
|
|
|
if (MyBots::IsMyBot(bot_owner, target_mob)) {
|
|
uint32 raid_group = raid->GetGroup(target_mob->CastToClient());
|
|
if (raid_group >= MAX_RAID_GROUPS) {
|
|
return;
|
|
}
|
|
|
|
for (const auto& m : raid->members) {
|
|
if (m.member && m.group_number == raid_group) {
|
|
if (!MyBots::IsMyBot(bot_owner, m.member->CastToBot())) {
|
|
continue;
|
|
}
|
|
|
|
sbl.push_back(m.member->CastToBot());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
else {
|
|
std::list<Bot*> group_list;
|
|
bot_owner->GetGroup()->GetBotList(group_list);
|
|
for (auto member_iter : group_list) {
|
|
if (IsMyBot(bot_owner, member_iter)) {
|
|
sbl.push_back(member_iter);
|
|
}
|
|
}
|
|
}
|
|
|
|
if (!clear_list) {
|
|
UniquifySBL(sbl);
|
|
}
|
|
}
|
|
|
|
static void PopulateSBL_ByNamesGroupedBots(Client *bot_owner, std::vector<Bot*> &sbl, const char* name, bool clear_list = true) {
|
|
if (clear_list) {
|
|
sbl.clear();
|
|
}
|
|
|
|
if (!bot_owner || !name) {
|
|
return;
|
|
}
|
|
|
|
Mob* named_mob = nullptr;
|
|
std::list<Mob*> l_mob_list;
|
|
entity_list.GetMobList(l_mob_list);
|
|
for (auto mob_iter : l_mob_list) {
|
|
if (!strcasecmp(mob_iter->GetCleanName(), name)) {
|
|
named_mob = mob_iter;
|
|
break;
|
|
}
|
|
}
|
|
|
|
if (!named_mob || !MyBots::IsMyBot(bot_owner, named_mob) || (!named_mob->GetGroup() && !named_mob->GetRaid()) || (!named_mob->IsClient() && !named_mob->IsBot())) {
|
|
return;
|
|
}
|
|
|
|
if (bot_owner->IsRaidGrouped()) {
|
|
Raid* raid = bot_owner->GetRaid();
|
|
if (!raid) {
|
|
return;
|
|
}
|
|
|
|
uint32 raid_group = raid->GetGroup(named_mob->CastToClient());
|
|
if (raid_group >= MAX_RAID_GROUPS) {
|
|
return;
|
|
}
|
|
|
|
for (const auto& m : raid->members) {
|
|
if (m.member && m.group_number == raid_group) {
|
|
if (!MyBots::IsMyBot(bot_owner, m.member->CastToBot())) {
|
|
continue;
|
|
}
|
|
|
|
sbl.push_back(m.member->CastToBot());
|
|
}
|
|
}
|
|
}
|
|
else {
|
|
std::list<Bot*> group_list;
|
|
bot_owner->GetGroup()->GetBotList(group_list);
|
|
for (auto member_iter : group_list) {
|
|
if (IsMyBot(bot_owner, member_iter)) {
|
|
sbl.push_back(member_iter);
|
|
}
|
|
}
|
|
}
|
|
|
|
if (!clear_list) {
|
|
UniquifySBL(sbl);
|
|
}
|
|
}
|
|
|
|
static void PopulateSBL_ByHealRotation(Client *bot_owner, std::vector<Bot*> &sbl, const char* name, bool clear_list = true) {
|
|
if (clear_list) {
|
|
sbl.clear();
|
|
}
|
|
|
|
if (!bot_owner || (!name && !bot_owner->GetTarget())) {
|
|
return;
|
|
}
|
|
|
|
std::vector<Bot*> selectable_bot_list;
|
|
if (name) {
|
|
PopulateSBL_ByNamedBot(bot_owner, selectable_bot_list, name);
|
|
}
|
|
else {
|
|
PopulateSBL_ByTargetedBot(bot_owner, selectable_bot_list);
|
|
}
|
|
|
|
if (selectable_bot_list.empty() || !selectable_bot_list.front()->IsHealRotationMember()) {
|
|
return;
|
|
}
|
|
|
|
auto hrm = (*selectable_bot_list.front()->MemberOfHealRotation())->MemberList();
|
|
for (auto hrm_iter : *hrm) {
|
|
if (IsMyBot(bot_owner, hrm_iter)) {
|
|
sbl.push_back(hrm_iter);
|
|
}
|
|
}
|
|
|
|
auto hrt = (*selectable_bot_list.front()->MemberOfHealRotation())->TargetList();
|
|
for (auto hrt_iter : *hrt) {
|
|
if (IsMyBot(bot_owner, hrt_iter)) {
|
|
sbl.push_back(hrt_iter->CastToBot());
|
|
}
|
|
}
|
|
|
|
UniquifySBL(sbl);
|
|
}
|
|
|
|
static void PopulateSBL_ByHealRotationMembers(Client *bot_owner, std::vector<Bot*> &sbl, const char* name, bool clear_list = true) {
|
|
if (clear_list) {
|
|
sbl.clear();
|
|
}
|
|
|
|
if (!bot_owner || (!name && !bot_owner->GetTarget())) {
|
|
return;
|
|
}
|
|
|
|
std::vector<Bot*> selectable_bot_list;
|
|
if (name) {
|
|
PopulateSBL_ByNamedBot(bot_owner, selectable_bot_list, name);
|
|
}
|
|
else {
|
|
PopulateSBL_ByTargetedBot(bot_owner, selectable_bot_list);
|
|
}
|
|
|
|
if (selectable_bot_list.empty() || !selectable_bot_list.front()->IsHealRotationMember()) {
|
|
return;
|
|
}
|
|
|
|
auto hrm = (*selectable_bot_list.front()->MemberOfHealRotation())->MemberList();
|
|
for (auto hrm_iter : *hrm) {
|
|
if (IsMyBot(bot_owner, hrm_iter)) {
|
|
sbl.push_back(hrm_iter);
|
|
}
|
|
}
|
|
|
|
if (!clear_list) {
|
|
UniquifySBL(sbl);
|
|
}
|
|
}
|
|
|
|
static void PopulateSBL_ByHealRotationTargets(Client *bot_owner, std::vector<Bot*> &sbl, const char* name, bool clear_list = true) {
|
|
if (clear_list) {
|
|
sbl.clear();
|
|
}
|
|
|
|
if (!bot_owner || (!name && !bot_owner->GetTarget())) {
|
|
return;
|
|
}
|
|
|
|
std::vector<Bot*> selectable_bot_list;
|
|
if (name) {
|
|
PopulateSBL_ByNamedBot(bot_owner, selectable_bot_list, name);
|
|
}
|
|
else {
|
|
PopulateSBL_ByTargetedBot(bot_owner, selectable_bot_list);
|
|
}
|
|
|
|
if (selectable_bot_list.empty() || !selectable_bot_list.front()->IsHealRotationMember()) {
|
|
return;
|
|
}
|
|
|
|
auto hrm = (*selectable_bot_list.front()->MemberOfHealRotation())->TargetList();
|
|
for (auto hrm_iter : *hrm) {
|
|
if (IsMyBot(bot_owner, hrm_iter)) {
|
|
sbl.push_back(static_cast<Bot*>(hrm_iter));
|
|
}
|
|
}
|
|
|
|
if (!clear_list) {
|
|
UniquifySBL(sbl);
|
|
}
|
|
}
|
|
|
|
static void PopulateSBL_BySpawnedBots(Client *bot_owner, std::vector<Bot*> &sbl) { // should be used for most spell casting commands
|
|
sbl.clear();
|
|
if (!bot_owner) {
|
|
return;
|
|
}
|
|
|
|
sbl = entity_list.GetBotsByBotOwnerCharacterID(bot_owner->CharacterID());
|
|
sbl.erase(std::remove(sbl.begin(), sbl.end(), nullptr), sbl.end());
|
|
}
|
|
|
|
static void PopulateSBL_BySpawnedBotsClass(Client * bot_owner, std::vector<Bot*> &sbl, uint16 cls, bool clear_list = true) {
|
|
if (clear_list) {
|
|
sbl.clear();
|
|
}
|
|
|
|
if (!bot_owner || !cls) {
|
|
return;
|
|
}
|
|
|
|
auto selectable_bot_list = entity_list.GetBotsByBotOwnerCharacterID(bot_owner->CharacterID());
|
|
for (auto bot_iter : selectable_bot_list) {
|
|
if (bot_iter->GetClass() != cls) {
|
|
continue;
|
|
}
|
|
|
|
sbl.push_back(bot_iter);
|
|
}
|
|
|
|
if (!clear_list) {
|
|
UniquifySBL(sbl);
|
|
}
|
|
}
|
|
|
|
static void PopulateSBL_BySpawnedBotsRace(Client* bot_owner, std::vector<Bot*>& sbl, uint16 race, bool clear_list = true) {
|
|
if (clear_list) {
|
|
sbl.clear();
|
|
}
|
|
|
|
if (!bot_owner || !race) {
|
|
return;
|
|
}
|
|
|
|
auto selectable_bot_list = entity_list.GetBotsByBotOwnerCharacterID(bot_owner->CharacterID());
|
|
for (auto bot_iter : selectable_bot_list) {
|
|
if (bot_iter->GetBaseRace() != race) {
|
|
continue;
|
|
}
|
|
|
|
sbl.push_back(bot_iter);
|
|
}
|
|
|
|
if (!clear_list) {
|
|
UniquifySBL(sbl);
|
|
}
|
|
}
|
|
|
|
static void PopulateSBL_ByAtMMR(Client* bot_owner, std::vector<Bot*>& sbl, bool clear_list = true) {
|
|
if (clear_list) {
|
|
sbl.clear();
|
|
}
|
|
|
|
if (!bot_owner) {
|
|
return;
|
|
}
|
|
|
|
auto selectable_bot_list = entity_list.GetBotsByBotOwnerCharacterID(bot_owner->CharacterID());
|
|
for (auto bot_iter : selectable_bot_list) {
|
|
if (!bot_iter->GetMaxMeleeRange()) {
|
|
continue;
|
|
}
|
|
sbl.push_back(bot_iter);
|
|
}
|
|
if (!clear_list) {
|
|
UniquifySBL(sbl);
|
|
}
|
|
}
|
|
};
|
|
|
|
namespace ActionableTarget
|
|
{
|
|
static bool AmIInPlayerGroup(Client *bot_owner, Client *grouped_player) {
|
|
if (!bot_owner || !grouped_player || !bot_owner->GetGroup() || !grouped_player->GetGroup())
|
|
return false;
|
|
|
|
return (bot_owner->GetGroup() == grouped_player->GetGroup());
|
|
}
|
|
|
|
static bool IsAttackable(Client *bot_owner, Mob* target_mob) {
|
|
if (!bot_owner || !target_mob || bot_owner == target_mob)
|
|
return false;
|
|
|
|
return bot_owner->IsAttackAllowed(target_mob);
|
|
}
|
|
|
|
static Client* AsSingle_ByPlayer(Client *bot_owner, bool return_me_on_null_target = true) {
|
|
if (!bot_owner)
|
|
return nullptr;
|
|
|
|
if (!bot_owner->GetTarget()) {
|
|
if (return_me_on_null_target)
|
|
return bot_owner;
|
|
else
|
|
return nullptr;
|
|
}
|
|
|
|
if (!bot_owner->GetTarget()->IsClient())
|
|
return nullptr;
|
|
|
|
return bot_owner->GetTarget()->CastToClient();
|
|
}
|
|
|
|
static Client* AsGroupMember_ByPlayer(Client *bot_owner, bool return_me_on_null_target = true) {
|
|
if (!bot_owner)
|
|
return nullptr;
|
|
|
|
if (!bot_owner->GetTarget()) {
|
|
if (return_me_on_null_target)
|
|
return bot_owner;
|
|
else
|
|
return nullptr;
|
|
}
|
|
|
|
if (!bot_owner->GetTarget()->IsClient() || !AmIInPlayerGroup(bot_owner, bot_owner->GetTarget()->CastToClient()))
|
|
return nullptr;
|
|
|
|
return bot_owner->GetTarget()->CastToClient();
|
|
}
|
|
|
|
static Corpse* AsCorpse_ByPlayer(Client *bot_owner) {
|
|
if (!bot_owner || !bot_owner->GetTarget() || !bot_owner->GetTarget()->IsPlayerCorpse())
|
|
return nullptr;
|
|
|
|
return bot_owner->GetTarget()->CastToCorpse();
|
|
}
|
|
|
|
static Mob* AsSingle_ByAttackable(Client *bot_owner) {
|
|
if (!IsAttackable(bot_owner, bot_owner->GetTarget()))
|
|
return nullptr;
|
|
|
|
return bot_owner->GetTarget();
|
|
}
|
|
|
|
static bool IsFriendlyAllowed(Mob* target_mob) {
|
|
if (!target_mob || target_mob->IsClient() || target_mob->IsBot() || (target_mob->IsPet() && target_mob->GetOwner() && (target_mob->GetOwner()->IsClient() || target_mob->GetOwner()->IsBot())) || target_mob->IsPlayerCorpse())
|
|
return true;
|
|
|
|
return false;
|
|
}
|
|
}
|
|
|
|
namespace ActionableBots
|
|
{
|
|
enum ABType {
|
|
ABT_None = 0,
|
|
ABT_Target,
|
|
ABT_ByName,
|
|
ABT_OwnerGroup,
|
|
ABT_OwnerRaid,
|
|
ABT_TargetGroup,
|
|
ABT_NamesGroup,
|
|
ABT_HealRotation,
|
|
ABT_HealRotationMembers,
|
|
ABT_HealRotationTargets,
|
|
ABT_MMR,
|
|
ABT_Class,
|
|
ABT_Race,
|
|
ABT_Spawned,
|
|
ABT_All
|
|
};
|
|
|
|
enum ABMask {
|
|
ABM_None = 0,
|
|
ABM_Target = (1 << (ABT_Target - 1)),
|
|
ABM_ByName = (1 << (ABT_ByName - 1)),
|
|
ABM_OwnerGroup = (1 << (ABT_OwnerGroup - 1)),
|
|
ABM_OwnerRaid = (1 << (ABT_OwnerRaid - 1)),
|
|
ABM_TargetGroup = (1 << (ABT_TargetGroup - 1)),
|
|
ABM_NamesGroup = (1 << (ABT_NamesGroup - 1)),
|
|
ABM_HealRotation = (1 << (ABT_HealRotation - 1)),
|
|
ABM_HealRotationMembers = (1 << (ABT_HealRotationMembers - 1)),
|
|
ABM_HealRotationTargets = (1 << (ABT_HealRotationTargets - 1)),
|
|
ABM_MMR = (1 << (ABT_MMR - 1)),
|
|
ABM_Class = (1 << (ABT_Class - 1)),
|
|
ABM_Race = (1 << (ABT_Race - 1)),
|
|
ABM_Spawned = (1 << (ABT_Spawned - 1)),
|
|
ABM_All = (1 << (ABT_All - 1)),
|
|
ABM_Spawned_All = (3 << (ABT_Spawned - 1)),
|
|
ABM_NoFilter = ~0,
|
|
// grouped values
|
|
ABM_Type1 = (ABM_Target | ABM_ByName | ABM_OwnerGroup | ABM_OwnerRaid | ABM_TargetGroup | ABM_NamesGroup | ABM_HealRotationTargets | ABM_Spawned | ABM_MMR | ABM_Class | ABM_Race),
|
|
ABM_Type2 = (ABM_ByName | ABM_OwnerGroup | ABM_OwnerRaid | ABM_NamesGroup | ABM_HealRotation | ABM_Spawned | ABM_MMR | ABM_Class | ABM_Race)
|
|
};
|
|
|
|
// Populates 'sbl'
|
|
static ABType PopulateSBL(Client* bot_owner, std::string ab_type_arg, std::vector<Bot*> &sbl, int ab_mask, const char* name = nullptr, uint16 classrace = 0, bool clear_list = true, bool suppress_message = false) {
|
|
if (clear_list) {
|
|
sbl.clear();
|
|
}
|
|
|
|
if (!bot_owner) {
|
|
return ABT_None;
|
|
}
|
|
|
|
auto ab_type = ABT_None;
|
|
if (!ab_type_arg.compare("target") || ab_type_arg.empty()) {
|
|
ab_type = ABT_Target;
|
|
}
|
|
else if (!ab_type_arg.compare("byname")) {
|
|
ab_type = ABT_ByName;
|
|
}
|
|
else if (!ab_type_arg.compare("ownergroup")) {
|
|
ab_type = ABT_OwnerGroup;
|
|
}
|
|
else if (!ab_type_arg.compare("ownerraid")) {
|
|
ab_type = ABT_OwnerRaid;
|
|
}
|
|
else if (!ab_type_arg.compare("targetgroup")) {
|
|
ab_type = ABT_TargetGroup;
|
|
}
|
|
else if (!ab_type_arg.compare("namesgroup")) {
|
|
ab_type = ABT_NamesGroup;
|
|
}
|
|
else if (!ab_type_arg.compare("healrotation")) {
|
|
ab_type = ABT_HealRotation;
|
|
}
|
|
else if (!ab_type_arg.compare("healrotationmembers")) {
|
|
ab_type = ABT_HealRotationMembers;
|
|
}
|
|
else if (!ab_type_arg.compare("healrotationtargets")) {
|
|
ab_type = ABT_HealRotationTargets;
|
|
}
|
|
else if (!ab_type_arg.compare("mmr")) {
|
|
ab_type = ABT_MMR;
|
|
}
|
|
else if (!ab_type_arg.compare("byclass")) {
|
|
ab_type = ABT_Class;
|
|
}
|
|
else if (!ab_type_arg.compare("byrace")) {
|
|
ab_type = ABT_Race;
|
|
}
|
|
else if (!ab_type_arg.compare("spawned")) {
|
|
ab_type = ABT_Spawned;
|
|
}
|
|
else if (!ab_type_arg.compare("all")) {
|
|
ab_type = ABT_All;
|
|
}
|
|
|
|
if (ab_type_arg.empty()) {
|
|
ab_type_arg = "target";
|
|
}
|
|
|
|
switch (ab_type) {
|
|
case ABT_Target:
|
|
if (ab_mask & ABM_Target) {
|
|
MyBots::PopulateSBL_ByTargetedBot(bot_owner, sbl, clear_list);
|
|
}
|
|
break;
|
|
case ABT_ByName:
|
|
if (ab_mask & ABM_ByName) {
|
|
MyBots::PopulateSBL_ByNamedBot(bot_owner, sbl, name, clear_list);
|
|
}
|
|
break;
|
|
case ABT_OwnerGroup:
|
|
if (ab_mask & ABM_OwnerGroup) {
|
|
MyBots::PopulateSBL_ByMyGroupedBots(bot_owner, sbl, clear_list);
|
|
}
|
|
break;
|
|
case ABT_OwnerRaid:
|
|
if (ab_mask & ABM_OwnerRaid) {
|
|
MyBots::PopulateSBL_ByMyRaidBots(bot_owner, sbl, clear_list);
|
|
}
|
|
break;
|
|
case ABT_TargetGroup:
|
|
if (ab_mask & ABM_TargetGroup) {
|
|
MyBots::PopulateSBL_ByTargetsGroupedBots(bot_owner, sbl, clear_list);
|
|
}
|
|
break;
|
|
case ABT_NamesGroup:
|
|
if (ab_mask & ABM_NamesGroup) {
|
|
MyBots::PopulateSBL_ByNamesGroupedBots(bot_owner, sbl, name, clear_list);
|
|
}
|
|
break;
|
|
case ABT_HealRotation:
|
|
if (ab_mask & ABM_HealRotation) {
|
|
MyBots::PopulateSBL_ByHealRotation(bot_owner, sbl, name, clear_list);
|
|
}
|
|
break;
|
|
case ABT_HealRotationMembers:
|
|
if (ab_mask & ABM_HealRotationMembers) {
|
|
MyBots::PopulateSBL_ByHealRotationMembers(bot_owner, sbl, name, clear_list);
|
|
}
|
|
break;
|
|
case ABT_HealRotationTargets:
|
|
if (ab_mask & ABM_HealRotationTargets) {
|
|
MyBots::PopulateSBL_ByHealRotationTargets(bot_owner, sbl, name, clear_list);
|
|
}
|
|
break;
|
|
case ABT_MMR:
|
|
if (ab_mask & ABM_MMR) {
|
|
MyBots::PopulateSBL_ByAtMMR(bot_owner, sbl, clear_list);
|
|
}
|
|
break;
|
|
case ABT_Class:
|
|
if (ab_mask & ABM_Class) {
|
|
MyBots::PopulateSBL_BySpawnedBotsClass(bot_owner, sbl, classrace, clear_list);
|
|
}
|
|
break;
|
|
case ABT_Race:
|
|
if (ab_mask & ABM_Race) {
|
|
MyBots::PopulateSBL_BySpawnedBotsRace(bot_owner, sbl, classrace, clear_list);
|
|
}
|
|
break;
|
|
case ABT_Spawned:
|
|
case ABT_All:
|
|
if (ab_mask & ABM_Spawned_All) {
|
|
MyBots::PopulateSBL_BySpawnedBots(bot_owner, sbl);
|
|
}
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
if (sbl.empty() && ab_type != ABT_All) {
|
|
if (suppress_message) {
|
|
return ABT_None;
|
|
}
|
|
|
|
if (!ab_mask) {
|
|
bot_owner->Message(Chat::White, "Command passed null 'ActionableBot' criteria");
|
|
}
|
|
else if (ab_mask & ab_type) {
|
|
if (classrace) {
|
|
bot_owner->Message(Chat::White, "You have no spawned bots meeting this criteria - type: '%s', %s: '%i'", ab_type_arg.c_str(), ab_mask & ABM_Class ? "class" : ab_mask & ABM_Race ? "race" : "", classrace);
|
|
}
|
|
else {
|
|
bot_owner->Message(Chat::White, "You have no spawned bots meeting this criteria - type: '%s', name: '%s'", ab_type_arg.c_str(), ((name) ? (name) : ("")));
|
|
}
|
|
}
|
|
else {
|
|
bot_owner->Message(Chat::White, "This command does not allow 'ActionableBot' criteria '%s'", ab_type_arg.c_str());
|
|
}
|
|
|
|
return ABT_None;
|
|
}
|
|
|
|
return ab_type;
|
|
}
|
|
|
|
static Bot* AsGroupMember_ByClass(Client *bot_owner, Client *bot_grouped_player, uint8 cls, bool petless = false) {
|
|
if (!bot_owner || !bot_grouped_player) {
|
|
return nullptr;
|
|
}
|
|
|
|
if (!bot_grouped_player->GetGroup() && !bot_grouped_player->GetRaid()) {
|
|
return nullptr;
|
|
}
|
|
|
|
if (bot_owner->IsRaidGrouped()) {
|
|
Raid* raid = bot_grouped_player->GetRaid();
|
|
if (!raid) {
|
|
return nullptr;
|
|
}
|
|
|
|
uint32 raid_group = raid->GetGroup(bot_grouped_player);
|
|
if (raid_group >= MAX_RAID_GROUPS) {
|
|
return nullptr;
|
|
}
|
|
|
|
for (const auto& m : raid->members) {
|
|
if (m.member && m.group_number == raid_group) {
|
|
if (!MyBots::IsMyBot(bot_owner, m.member->CastToBot())) {
|
|
continue;
|
|
}
|
|
|
|
if (m.member->GetClass() != cls) {
|
|
continue;
|
|
}
|
|
|
|
if (petless && m.member->GetPet()) {
|
|
continue;
|
|
}
|
|
|
|
return static_cast<Bot*>(m.member->CastToBot());
|
|
}
|
|
}
|
|
}
|
|
else {
|
|
std::list<Mob*> group_list;
|
|
bot_grouped_player->GetGroup()->GetMemberList(group_list);
|
|
for (auto member_iter : group_list) {
|
|
if (!MyBots::IsMyBot(bot_owner, member_iter)) {
|
|
continue;
|
|
}
|
|
|
|
if (member_iter->GetClass() != cls) {
|
|
continue;
|
|
}
|
|
|
|
if (petless && member_iter->GetPet()) {
|
|
continue;
|
|
}
|
|
|
|
return static_cast<Bot*>(member_iter);
|
|
}
|
|
}
|
|
|
|
return nullptr;
|
|
}
|
|
|
|
static Bot* AsGroupMember_ByMinLevelAndClass(Client *bot_owner, Client *bot_grouped_player, uint8 minlvl, uint8 cls, bool petless = false) {
|
|
// This function can be nixed if we can enforce bot level as owner level..and the level check can then be moved to the spell loop in the command function
|
|
if (!bot_owner || !bot_grouped_player)
|
|
return nullptr;
|
|
if (!bot_grouped_player->GetGroup())
|
|
return nullptr;
|
|
|
|
std::list<Mob*> group_list;
|
|
bot_grouped_player->GetGroup()->GetMemberList(group_list);
|
|
for (auto member_iter : group_list) {
|
|
if (!MyBots::IsMyBot(bot_owner, member_iter))
|
|
continue;
|
|
if (member_iter->GetLevel() < minlvl || member_iter->GetClass() != cls)
|
|
continue;
|
|
if (petless && member_iter->GetPet())
|
|
continue;
|
|
|
|
return static_cast<Bot*>(member_iter);
|
|
}
|
|
|
|
return nullptr;
|
|
}
|
|
|
|
static Bot* AsSpawned_ByClass(Client *bot_owner, std::vector<Bot*> &sbl, uint8 cls, bool petless = false) {
|
|
if (!bot_owner) {
|
|
return nullptr;
|
|
}
|
|
|
|
for (auto bot_iter : sbl) {
|
|
if (!MyBots::IsMyBot(bot_owner, bot_iter)) {
|
|
continue;
|
|
}
|
|
|
|
if (bot_iter->GetClass() != cls) {
|
|
continue;
|
|
}
|
|
|
|
if (petless && bot_iter->GetPet()) {
|
|
continue;
|
|
}
|
|
|
|
return bot_iter;
|
|
}
|
|
|
|
return nullptr;
|
|
}
|
|
|
|
static Bot* AsSpawned_ByMinLevelAndClass(Client *bot_owner, std::vector<Bot*> &sbl, uint8 minlvl, uint8 cls, bool petless = false) {
|
|
// This function can be nixed if we can enforce bot level as owner level..and the level check can then be moved to the spell loop in the command function
|
|
if (!bot_owner)
|
|
return nullptr;
|
|
|
|
for (auto bot_iter : sbl) {
|
|
if (!MyBots::IsMyBot(bot_owner, bot_iter))
|
|
continue;
|
|
if (bot_iter->GetLevel() < minlvl || bot_iter->GetClass() != cls)
|
|
continue;
|
|
if (petless && bot_iter->GetPet())
|
|
continue;
|
|
|
|
return bot_iter;
|
|
}
|
|
|
|
return nullptr;
|
|
}
|
|
|
|
static Bot* AsTarget_ByBot(Client *bot_owner) {
|
|
if (!bot_owner || !MyBots::IsMyBot(bot_owner, bot_owner->GetTarget()))
|
|
return nullptr;
|
|
|
|
return bot_owner->GetTarget()->CastToBot();
|
|
}
|
|
|
|
static Bot* AsNamed_ByBot(Client *bot_owner, std::string bot_name) {
|
|
if (!bot_owner || bot_name.empty())
|
|
return nullptr;
|
|
|
|
std::vector<Bot*> selectable_bot_list;
|
|
MyBots::PopulateSBL_BySpawnedBots(bot_owner, selectable_bot_list);
|
|
for (auto bot_iter : selectable_bot_list) {
|
|
if (!bot_name.compare(bot_iter->GetCleanName()))
|
|
return bot_iter;
|
|
}
|
|
|
|
return nullptr;
|
|
}
|
|
|
|
static Bot* Select_ByClass(Client* bot_owner, int target_type, std::vector<Bot*>& sbl, uint8 cls, Mob* target_mob = nullptr, bool petless = false) {
|
|
if (!bot_owner || sbl.empty())
|
|
return nullptr;
|
|
|
|
for (auto bot_iter : sbl) {
|
|
if (!MyBots::IsMyBot(bot_owner, bot_iter))
|
|
continue;
|
|
if (bot_iter->GetClass() != cls)
|
|
continue;
|
|
if (petless && bot_iter->GetPet())
|
|
continue;
|
|
if (target_type == ST_GroupTeleport) {
|
|
if (!target_mob)
|
|
return nullptr;
|
|
else if (bot_iter->GetGroup() != target_mob->GetGroup())
|
|
continue;
|
|
}
|
|
|
|
return bot_iter;
|
|
}
|
|
|
|
return nullptr;
|
|
}
|
|
|
|
static Bot* Select_ByMinLevelAndClass(Client* bot_owner, int target_type, std::vector<Bot*>& sbl, uint8 minlvl, uint8 cls, Mob* target_mob = nullptr, bool petless = false) {
|
|
if (!bot_owner || sbl.empty())
|
|
return nullptr;
|
|
|
|
for (auto bot_iter : sbl) {
|
|
if (!MyBots::IsMyBot(bot_owner, bot_iter))
|
|
continue;
|
|
if (bot_iter->GetLevel() < minlvl || bot_iter->GetClass() != cls)
|
|
continue;
|
|
if (petless && bot_iter->GetPet())
|
|
continue;
|
|
if (target_type == ST_GroupTeleport) {
|
|
if (!target_mob)
|
|
return nullptr;
|
|
else if (bot_iter->GetGroup() != target_mob->GetGroup())
|
|
continue;
|
|
}
|
|
|
|
return bot_iter;
|
|
}
|
|
|
|
return nullptr;
|
|
}
|
|
|
|
// Filters actual 'sbl' list
|
|
static void Filter_ByClasses(Client* bot_owner, std::vector<Bot*>& sbl, uint16 class_mask) {
|
|
std::erase_if(sbl, [bot_owner](Bot* l) { return (!MyBots::IsMyBot(bot_owner, l)); });
|
|
std::erase_if(sbl, [class_mask](Bot* l) { return (GetPlayerClassBit(l->GetClass()) & (~class_mask)); });
|
|
}
|
|
|
|
static void Filter_ByMinLevel(Client* bot_owner, std::vector<Bot*>& sbl, uint8 min_level) {
|
|
std::erase_if(sbl, [bot_owner](Bot* l) { return (!MyBots::IsMyBot(bot_owner, l)); });
|
|
std::erase_if(sbl, [min_level](Bot* l) { return (l->GetLevel() < min_level); });
|
|
}
|
|
|
|
static void Filter_ByRanged(Client* bot_owner, std::vector<Bot*>& sbl) {
|
|
std::erase_if(sbl, [bot_owner](Bot* l) { return (!MyBots::IsMyBot(bot_owner, l)); });
|
|
std::erase_if(sbl, [bot_owner](Bot* l) { return (l->IsBotRanged()); });
|
|
}
|
|
|
|
static void Filter_ByHighestSkill(Client* bot_owner, std::vector<Bot*>& sbl, EQ::skills::SkillType skill_type, float& skill_value) {
|
|
std::erase_if(sbl, [bot_owner](Bot* l) { return (!MyBots::IsMyBot(bot_owner, l)); });
|
|
skill_value = 0.0f;
|
|
|
|
float mod_skill_value = 0.0f;
|
|
const Bot* skilled_bot = nullptr;
|
|
for (auto bot_iter : sbl) {
|
|
float base_skill_value = bot_iter->GetSkill(skill_type);
|
|
if (base_skill_value == 0.0f)
|
|
continue;
|
|
|
|
mod_skill_value = base_skill_value;
|
|
for (int16 index = EQ::invslot::EQUIPMENT_BEGIN; index <= EQ::invslot::EQUIPMENT_END; ++index) {
|
|
const EQ::ItemInstance* indexed_item = bot_iter->GetBotItem(index);
|
|
if (indexed_item && indexed_item->GetItem()->SkillModType == skill_type)
|
|
mod_skill_value += (base_skill_value * (((float)indexed_item->GetItem()->SkillModValue) / 100.0f));
|
|
}
|
|
|
|
if (!skilled_bot) {
|
|
skill_value = mod_skill_value;
|
|
skilled_bot = bot_iter;
|
|
}
|
|
else if (mod_skill_value > skill_value) {
|
|
skill_value = mod_skill_value;
|
|
skilled_bot = bot_iter;
|
|
}
|
|
}
|
|
std::erase_if(sbl, [skilled_bot](Bot* l) { return (l != skilled_bot); });
|
|
}
|
|
|
|
static void Filter_ByHighestPickLock(Client* bot_owner, std::vector<Bot*>& sbl, float& pick_lock_value) {
|
|
std::erase_if(sbl, [bot_owner](Bot* l) { return (!MyBots::IsMyBot(bot_owner, l)); });
|
|
std::erase_if(sbl, [bot_owner](Bot* l) { return (l->GetClass() != Class::Rogue && l->GetClass() != Class::Bard); });
|
|
std::erase_if(sbl, [bot_owner](Bot* l) { return (l->GetClass() == Class::Rogue && l->GetLevel() < 5); });
|
|
std::erase_if(sbl, [bot_owner](Bot* l) { return (l->GetClass() == Class::Bard && l->GetLevel() < 40); });
|
|
|
|
ActionableBots::Filter_ByHighestSkill(bot_owner, sbl, EQ::skills::SkillPickLock, pick_lock_value);
|
|
}
|
|
}
|
|
|
|
#define BOT_COMMAND_CHAR '^'
|
|
|
|
typedef void (*BotCmdFuncPtr)(Client *,const Seperator *);
|
|
|
|
typedef struct {
|
|
int access;
|
|
const char *desc; // description of bot command
|
|
BotCmdFuncPtr function; // null means perl function
|
|
} BotCommandRecord;
|
|
|
|
extern int (*bot_command_dispatch)(Client *,char const*);
|
|
extern int bot_command_count; // number of bot commands loaded
|
|
|
|
// Bot Command System:
|
|
int bot_command_init(void);
|
|
void bot_command_deinit(void);
|
|
int bot_command_add(std::string bot_command_name, const char *desc, int access, BotCmdFuncPtr function);
|
|
int bot_command_not_avail(Client *c, const char *message);
|
|
int bot_command_real_dispatch(Client *c, char const *message);
|
|
|
|
// Bot Commands
|
|
void bot_command_actionable(Client *c, const Seperator *sep);
|
|
void bot_command_apply_poison(Client *c, const Seperator *sep);
|
|
void bot_command_apply_potion(Client* c, const Seperator* sep);
|
|
void bot_command_attack(Client *c, const Seperator *sep);
|
|
void bot_command_behind_mob(Client* c, const Seperator* sep);
|
|
void bot_command_blocked_buffs(Client* c, const Seperator* sep);
|
|
void bot_command_blocked_pet_buffs(Client* c, const Seperator* sep);
|
|
void bot_command_bot(Client *c, const Seperator *sep);
|
|
void bot_command_bot_settings(Client* c, const Seperator* sep);
|
|
void bot_command_cast(Client* c, const Seperator* sep);
|
|
void bot_command_discipline(Client* c, const Seperator* sep);
|
|
void bot_command_distance_ranged(Client* c, const Seperator* sep);
|
|
void bot_command_class_race_list(Client* c, const Seperator* sep);
|
|
void bot_command_click_item(Client* c, const Seperator* sep);
|
|
void bot_command_copy_settings(Client* c, const Seperator* sep);
|
|
void bot_command_default_settings(Client* c, const Seperator* sep);
|
|
void bot_command_depart(Client *c, const Seperator *sep);
|
|
void bot_command_find_aliases(Client *c, const Seperator *sep);
|
|
void bot_command_follow(Client *c, const Seperator *sep);
|
|
void bot_command_guard(Client *c, const Seperator *sep);
|
|
void bot_command_heal_rotation(Client *c, const Seperator *sep);
|
|
void bot_command_help(Client *c, const Seperator *sep);
|
|
void bot_command_hold(Client *c, const Seperator *sep);
|
|
void bot_command_illusion_block(Client* c, const Seperator* sep);
|
|
void bot_command_inventory(Client *c, const Seperator *sep);
|
|
void bot_command_item_use(Client *c, const Seperator *sep);
|
|
void bot_command_max_melee_range(Client* c, const Seperator* sep);
|
|
void bot_command_owner_option(Client *c, const Seperator *sep);
|
|
void bot_command_pet(Client *c, const Seperator *sep);
|
|
void bot_command_pick_lock(Client *c, const Seperator *sep);
|
|
void bot_command_pickpocket(Client* c, const Seperator* sep);
|
|
void bot_command_precombat(Client* c, const Seperator* sep);
|
|
void bot_command_pull(Client *c, const Seperator *sep);
|
|
void bot_command_release(Client *c, const Seperator *sep);
|
|
void bot_command_sit_hp_percent(Client* c, const Seperator* sep);
|
|
void bot_command_sit_in_combat(Client* c, const Seperator* sep);
|
|
void bot_command_sit_mana_percent(Client* c, const Seperator* sep);
|
|
void bot_command_spell_aggro_checks(Client* c, const Seperator* sep);
|
|
void bot_command_spell_announce_cast(Client* c, const Seperator* sep);
|
|
void bot_command_spell_delays(Client* c, const Seperator* sep);
|
|
void bot_command_spell_engaged_priority(Client* c, const Seperator* sep);
|
|
void bot_command_spell_holds(Client* c, const Seperator* sep);
|
|
void bot_command_spell_idle_priority(Client* c, const Seperator* sep);
|
|
void bot_command_spell_max_hp_pct(Client* c, const Seperator* sep);
|
|
void bot_command_spell_max_mana_pct(Client* c, const Seperator* sep);
|
|
void bot_command_spell_max_thresholds(Client* c, const Seperator* sep);
|
|
void bot_command_spell_min_hp_pct(Client* c, const Seperator* sep);
|
|
void bot_command_spell_min_mana_pct(Client* c, const Seperator* sep);
|
|
void bot_command_spell_min_thresholds(Client* c, const Seperator* sep);
|
|
void bot_command_spell_pursue_priority(Client* c, const Seperator* sep);
|
|
void bot_command_spell_resist_limits(Client* c, const Seperator* sep);
|
|
void bot_command_spell_target_count(Client* c, const Seperator* sep);
|
|
void bot_command_spell_list(Client* c, const Seperator *sep);
|
|
void bot_command_spell_settings_add(Client* c, const Seperator *sep);
|
|
void bot_command_spell_settings_delete(Client* c, const Seperator *sep);
|
|
void bot_command_spell_settings_list(Client* c, const Seperator *sep);
|
|
void bot_command_spell_settings_toggle(Client* c, const Seperator *sep);
|
|
void bot_command_spell_settings_update(Client* c, const Seperator *sep);
|
|
void bot_command_spelltype_ids(Client* c, const Seperator* sep);
|
|
void bot_command_spelltype_names(Client* c, const Seperator* sep);
|
|
void bot_spell_info_dialogue_window(Client* c, const Seperator *sep);
|
|
void bot_command_enforce_spell_list(Client* c, const Seperator* sep);
|
|
void bot_command_suspend(Client *c, const Seperator *sep);
|
|
void bot_command_taunt(Client *c, const Seperator *sep);
|
|
void bot_command_timer(Client* c, const Seperator* sep);
|
|
void bot_command_track(Client *c, const Seperator *sep);
|
|
void bot_command_view_combos(Client *c, const Seperator *sep);
|
|
|
|
// Bot Subcommands
|
|
void bot_command_appearance(Client *c, const Seperator *sep);
|
|
void bot_command_beard_color(Client *c, const Seperator *sep);
|
|
void bot_command_beard_style(Client *c, const Seperator *sep);
|
|
void bot_command_camp(Client *c, const Seperator *sep);
|
|
void bot_command_clone(Client *c, const Seperator *sep);
|
|
void bot_command_create(Client *c, const Seperator *sep);
|
|
void bot_command_delete(Client *c, const Seperator *sep);
|
|
void bot_command_details(Client *c, const Seperator *sep);
|
|
void bot_command_dye_armor(Client *c, const Seperator *sep);
|
|
void bot_command_eyes(Client *c, const Seperator *sep);
|
|
void bot_command_face(Client *c, const Seperator *sep);
|
|
void bot_command_follow_distance(Client *c, const Seperator *sep);
|
|
void bot_command_hair_color(Client *c, const Seperator *sep);
|
|
void bot_command_hairstyle(Client *c, const Seperator *sep);
|
|
void bot_command_heritage(Client *c, const Seperator *sep);
|
|
void bot_command_inspect_message(Client *c, const Seperator *sep);
|
|
void bot_command_list_bots(Client *c, const Seperator *sep);
|
|
void bot_command_report(Client *c, const Seperator *sep);
|
|
void bot_command_set_assistee(Client* c, const Seperator* sep);
|
|
void bot_command_spawn(Client *c, const Seperator *sep);
|
|
void bot_command_stance(Client *c, const Seperator *sep);
|
|
void bot_command_stop_melee_level(Client *c, const Seperator *sep);
|
|
void bot_command_suffix(Client *c, const Seperator *sep);
|
|
void bot_command_summon(Client *c, const Seperator *sep);
|
|
void bot_command_surname(Client *c, const Seperator *sep);
|
|
void bot_command_tattoo(Client *c, const Seperator *sep);
|
|
void bot_command_title(Client *c, const Seperator *sep);
|
|
void bot_command_toggle_helm(Client *c, const Seperator *sep);
|
|
void bot_command_toggle_ranged(Client* c, const Seperator* sep);
|
|
void bot_command_update(Client *c, const Seperator *sep);
|
|
void bot_command_woad(Client *c, const Seperator *sep);
|
|
|
|
void bot_command_heal_rotation_adaptive_targeting(Client *c, const Seperator *sep);
|
|
void bot_command_heal_rotation_add_member(Client *c, const Seperator *sep);
|
|
void bot_command_heal_rotation_add_target(Client *c, const Seperator *sep);
|
|
void bot_command_heal_rotation_adjust_critical(Client *c, const Seperator *sep);
|
|
void bot_command_heal_rotation_adjust_safe(Client *c, const Seperator *sep);
|
|
void bot_command_heal_rotation_casting_override(Client *c, const Seperator *sep);
|
|
void bot_command_heal_rotation_change_interval(Client *c, const Seperator *sep);
|
|
void bot_command_heal_rotation_clear_hot(Client *c, const Seperator *sep);
|
|
void bot_command_heal_rotation_clear_targets(Client *c, const Seperator *sep);
|
|
void bot_command_heal_rotation_create(Client *c, const Seperator *sep);
|
|
void bot_command_heal_rotation_delete(Client *c, const Seperator *sep);
|
|
void bot_command_heal_rotation_fast_heals(Client *c, const Seperator *sep);
|
|
void bot_command_heal_rotation_list(Client *c, const Seperator *sep);
|
|
void bot_command_heal_rotation_remove_member(Client *c, const Seperator *sep);
|
|
void bot_command_heal_rotation_remove_target(Client *c, const Seperator *sep);
|
|
void bot_command_heal_rotation_reset_limits(Client *c, const Seperator *sep);
|
|
void bot_command_heal_rotation_save(Client *c, const Seperator *sep);
|
|
void bot_command_heal_rotation_set_hot(Client *c, const Seperator *sep);
|
|
void bot_command_heal_rotation_start(Client *c, const Seperator *sep);
|
|
void bot_command_heal_rotation_stop(Client *c, const Seperator *sep);
|
|
void bot_command_inventory_give(Client *c, const Seperator *sep);
|
|
void bot_command_inventory_list(Client *c, const Seperator *sep);
|
|
void bot_command_inventory_remove(Client *c, const Seperator *sep);
|
|
void bot_command_inventory_window(Client *c, const Seperator *sep);
|
|
void bot_command_pet_get_lost(Client *c, const Seperator *sep);
|
|
void bot_command_pet_remove(Client *c, const Seperator *sep);
|
|
void bot_command_pet_set_type(Client *c, const Seperator *sep);
|
|
|
|
|
|
// bot command helpers
|
|
bool helper_bot_appearance_fail(Client *bot_owner, Bot *my_bot, uint8 fail_type, const char* type_desc);
|
|
void helper_bot_appearance_form_final(Client *bot_owner, Bot *my_bot);
|
|
void helper_bot_appearance_form_update(Bot *my_bot);
|
|
uint32 helper_bot_create(Client *bot_owner, std::string bot_name, uint8 bot_class, uint16 bot_race, uint8 bot_gender);
|
|
int helper_bot_follow_option_chain(Client *bot_owner);
|
|
bool helper_command_disabled(Client *bot_owner, bool rule_value, const char *command);
|
|
bool helper_command_alias_fail(Client *bot_owner, const char* command_handler, const char *alias, const char *command);
|
|
bool helper_is_help_or_usage(const char* arg);
|
|
bool helper_no_available_bots(Client *bot_owner, Bot *my_bot = nullptr);
|
|
void helper_send_available_subcommands(Client *bot_owner, const char* command_simile, std::vector<const char*> subcommand_list);
|
|
void helper_send_usage_required_bots(Client *bot_owner, uint16 spell_type);
|
|
void SendSpellTypeWindow(Client* c, const Seperator* sep);
|
|
|
|
#endif
|