From 40b676c3203d0066de99514380d855590acf2e87 Mon Sep 17 00:00:00 2001 From: nytmyr <53322305+nytmyr@users.noreply.github.com> Date: Thu, 9 Jan 2025 23:01:48 -0600 Subject: [PATCH] code cleanup 1 --- zone/bot.cpp | 69 +++++--- zone/bot_command.cpp | 45 +---- zone/bot_commands/bot_settings.cpp | 71 ++++---- zone/bot_database.cpp | 24 +-- zone/client.cpp | 8 +- zone/mob.cpp | 262 +++++++++++++++-------------- zone/mob.h | 68 ++++---- zone/spells.cpp | 8 +- 8 files changed, 281 insertions(+), 274 deletions(-) diff --git a/zone/bot.cpp b/zone/bot.cpp index 4e36611b3..76268c03f 100644 --- a/zone/bot.cpp +++ b/zone/bot.cpp @@ -9441,7 +9441,7 @@ bool Bot::CastChecks(uint16 spell_id, Mob* tar, uint16 spellType, bool doPrechec if (chance && zone->random.Roll(chance)) { LogBotPreChecksDetail("{} says, 'Cancelling cast of {} due to focusFcMute.'", GetCleanName(), GetSpellName(spell_id)); - return(false); + return false; } } @@ -11389,11 +11389,7 @@ void Bot::DoCombatPositioning( bool Bot::CheckDoubleRangedAttack() { int32 chance = spellbonuses.DoubleRangedAttack + itembonuses.DoubleRangedAttack + aabonuses.DoubleRangedAttack; - if (chance && zone->random.Roll(chance)) { - return true; - } - - return false; + return (chance && zone->random.Roll(chance)); } bool Bot::RequiresLoSForPositioning() { @@ -11775,7 +11771,10 @@ bool Bot::IsValidSpellTypeSubType(uint16 spellType, uint16 subType, uint16 spell switch (subType) { case CommandedSubTypes::SingleTarget: - if (!IsAnyAESpell(spell_id) && !IsGroupSpell(spell_id)) { + if ( + !IsAnyAESpell(spell_id) && + !IsGroupSpell(spell_id) + ) { return true; } @@ -11787,7 +11786,10 @@ bool Bot::IsValidSpellTypeSubType(uint16 spellType, uint16 subType, uint16 spell break; case CommandedSubTypes::AETarget: - if (IsAnyAESpell(spell_id) && !IsGroupSpell(spell_id)) { + if ( + IsAnyAESpell(spell_id) && + !IsGroupSpell(spell_id) + ) { return true; } @@ -11799,43 +11801,70 @@ bool Bot::IsValidSpellTypeSubType(uint16 spellType, uint16 subType, uint16 spell break; case CommandedSubTypes::Invis: - if (IsEffectInSpell(spell_id, SE_Invisibility) || IsEffectInSpell(spell_id, SE_Invisibility2)) { + if ( + IsEffectInSpell(spell_id, SE_Invisibility) || + IsEffectInSpell(spell_id, SE_Invisibility2) + ) { return true; } break; case CommandedSubTypes::InvisUndead: - if (IsEffectInSpell(spell_id, SE_InvisVsUndead) || IsEffectInSpell(spell_id, SE_InvisVsUndead2)) { + if ( + IsEffectInSpell(spell_id, SE_InvisVsUndead) || + IsEffectInSpell(spell_id, SE_InvisVsUndead2) + ) { return true; } - -break; + + break; case CommandedSubTypes::InvisAnimals: - if (IsEffectInSpell(spell_id, SE_InvisVsAnimals) || IsEffectInSpell(spell_id, SE_ImprovedInvisAnimals)) { + if ( + IsEffectInSpell(spell_id, SE_InvisVsAnimals) || + IsEffectInSpell(spell_id, SE_ImprovedInvisAnimals) + ) { return true; } break; case CommandedSubTypes::Shrink: if ( - (IsEffectInSpell(spell_id, SE_ModelSize) && CalcSpellEffectValue(spell_id, GetSpellEffectIndex(spell_id, SE_ModelSize), GetLevel()) < 100) || - (IsEffectInSpell(spell_id, SE_ChangeHeight) && CalcSpellEffectValue(spell_id, GetSpellEffectIndex(spell_id, SE_ChangeHeight), GetLevel()) < 100) - ) { + ( + IsEffectInSpell(spell_id, SE_ModelSize) && + CalcSpellEffectValue(spell_id, GetSpellEffectIndex(spell_id, SE_ModelSize), GetLevel()) < 100 + ) + || + ( + IsEffectInSpell(spell_id, SE_ChangeHeight) && + CalcSpellEffectValue(spell_id, GetSpellEffectIndex(spell_id, SE_ChangeHeight), GetLevel()) < 100 + ) + ) { return true; } break; case CommandedSubTypes::Grow: if ( - (IsEffectInSpell(spell_id, SE_ModelSize) && CalcSpellEffectValue(spell_id, GetSpellEffectIndex(spell_id, SE_ModelSize), GetLevel()) > 100) || - (IsEffectInSpell(spell_id, SE_ChangeHeight) && CalcSpellEffectValue(spell_id, GetSpellEffectIndex(spell_id, SE_ChangeHeight), GetLevel()) > 100) - ) { + ( + IsEffectInSpell(spell_id, SE_ModelSize) && + CalcSpellEffectValue(spell_id, GetSpellEffectIndex(spell_id, SE_ModelSize), GetLevel()) > 100 + ) + || + ( + IsEffectInSpell(spell_id, SE_ChangeHeight) && + CalcSpellEffectValue(spell_id, GetSpellEffectIndex(spell_id, SE_ChangeHeight), GetLevel()) > 100 + ) + ) { return true; } break; case CommandedSubTypes::Selo: - if (IsBeneficialSpell(spell_id) && IsEffectInSpell(spell_id, SE_MovementSpeed) && IsBardSong(spell_id)) { + if ( + IsBeneficialSpell(spell_id) && + IsEffectInSpell(spell_id, SE_MovementSpeed) && + IsBardSong(spell_id) + ) { return true; } diff --git a/zone/bot_command.cpp b/zone/bot_command.cpp index e30503901..33b40ce79 100644 --- a/zone/bot_command.cpp +++ b/zone/bot_command.cpp @@ -2147,33 +2147,15 @@ void SendSpellTypeWindow(Client* c, const Seperator* sep) { std::string shortnameField = "Short Name"; std::string popup_text = DialogueWindow::TableRow( - DialogueWindow::TableCell( - fmt::format( - "{}", - DialogueWindow::ColorMessage(goldenrod, spellTypeField) - ) - ) + - DialogueWindow::TableCell( - fmt::format( - "{}", - (!arg0.compare("^spelltypeids") ? DialogueWindow::ColorMessage(goldenrod, idField) : DialogueWindow::ColorMessage(goldenrod, shortnameField)) - ) - ) + DialogueWindow::TableCell(DialogueWindow::ColorMessage(goldenrod, spellTypeField)) + + + DialogueWindow::TableCell((!arg0.compare("^spelltypeids") ? DialogueWindow::ColorMessage(goldenrod, idField) : DialogueWindow::ColorMessage(goldenrod, shortnameField))) ); popup_text += DialogueWindow::TableRow( - DialogueWindow::TableCell( - fmt::format( - "{}", - DialogueWindow::ColorMessage(gold, fillerLine) - ) - ) + - DialogueWindow::TableCell( - fmt::format( - "{}", - DialogueWindow::ColorMessage(gold, fillerLine) - ) - ) + DialogueWindow::TableCell(DialogueWindow::ColorMessage(gold, fillerLine)) + + + DialogueWindow::TableCell(DialogueWindow::ColorMessage(gold, fillerLine)) ); for (int i = minCount; i <= maxCount; ++i) { @@ -2182,18 +2164,9 @@ void SendSpellTypeWindow(Client* c, const Seperator* sep) { } popup_text += DialogueWindow::TableRow( - DialogueWindow::TableCell( - fmt::format( - "{}", - DialogueWindow::ColorMessage(forest_green, c->GetSpellTypeNameByID(i)) - ) - ) + - DialogueWindow::TableCell( - fmt::format( - "{}", - (!arg0.compare("^spelltypeids") ? DialogueWindow::ColorMessage(slate_blue, std::to_string(i)) : DialogueWindow::ColorMessage(slate_blue, c->GetSpellTypeShortNameByID(i))) - ) - ) + DialogueWindow::TableCell(DialogueWindow::ColorMessage(forest_green, c->GetSpellTypeNameByID(i))) + + + DialogueWindow::TableCell((!arg0.compare("^spelltypeids") ? DialogueWindow::ColorMessage(slate_blue, std::to_string(i)) : DialogueWindow::ColorMessage(slate_blue, c->GetSpellTypeShortNameByID(i)))) ); } diff --git a/zone/bot_commands/bot_settings.cpp b/zone/bot_commands/bot_settings.cpp index d42df0b07..758916ca0 100644 --- a/zone/bot_commands/bot_settings.cpp +++ b/zone/bot_commands/bot_settings.cpp @@ -2,41 +2,42 @@ void bot_command_bot_settings(Client* c, const Seperator* sep) { - std::list subcommand_list; - subcommand_list.push_back("behindmob"); - subcommand_list.push_back("blockedbuffs"); - subcommand_list.push_back("blockedpetbuffs"); - subcommand_list.push_back("distanceranged"); - subcommand_list.push_back("copysettings"); - subcommand_list.push_back("defaultsettings"); - subcommand_list.push_back("enforcespelllist"); - subcommand_list.push_back("follow"); - subcommand_list.push_back("followdistance"); - subcommand_list.push_back("illusionblock"); - subcommand_list.push_back("maxmeleerange"); - subcommand_list.push_back("owneroption"); - subcommand_list.push_back("petsettype"); - subcommand_list.push_back("sithppercent"); - subcommand_list.push_back("sitincombat"); - subcommand_list.push_back("sitmanapercent"); - subcommand_list.push_back("sithppercent"); - subcommand_list.push_back("spellaggrocheck"); - subcommand_list.push_back("spelldelays"); - subcommand_list.push_back("spellengagedpriority"); - subcommand_list.push_back("spellholds"); - subcommand_list.push_back("spellidlepriority"); - subcommand_list.push_back("spellmaxhppct"); - subcommand_list.push_back("spellmaxmanapct"); - subcommand_list.push_back("spellmaxthresholds"); - subcommand_list.push_back("spellminhppct"); - subcommand_list.push_back("spellminmanapct"); - subcommand_list.push_back("spellminthresholds"); - subcommand_list.push_back("spellpursuepriority"); - subcommand_list.push_back("spelltargetcount"); - subcommand_list.push_back("spelllist"); - subcommand_list.push_back("stance"); - subcommand_list.push_back("togglehelm"); - subcommand_list.push_back("bottoggleranged"); + std::vector subcommand_list = { + "behindmob", + "blockedbuffs", + "blockedpetbuffs", + "distanceranged", + "copysettings", + "defaultsettings", + "enforcespelllist", + "follow", + "followdistance", + "illusionblock", + "maxmeleerange", + "owneroption", + "petsettype", + "sithppercent", + "sitincombat", + "sitmanapercent", + "sithppercent", + "spellaggrocheck", + "spelldelays", + "spellengagedpriority", + "spellholds", + "spellidlepriority", + "spellmaxhppct", + "spellmaxmanapct", + "spellmaxthresholds", + "spellminhppct", + "spellminmanapct", + "spellminthresholds", + "spellpursuepriority", + "spelltargetcount", + "spelllist", + "stance", + "togglehelm", + "bottoggleranged" + }; if (helper_command_alias_fail(c, "bot_command_bot_settings", sep->arg[0], "botsettings")) return; diff --git a/zone/bot_database.cpp b/zone/bot_database.cpp index 53cf76225..3ca0f0e45 100644 --- a/zone/bot_database.cpp +++ b/zone/bot_database.cpp @@ -2239,21 +2239,21 @@ bool BotDatabase::LoadBotSettings(Mob* m) for (const auto& e : l) { if (e.setting_type == BotSettingCategories::BaseSetting) { - LogBotSettings("[{}] says, 'Loading {} [{}] - setting to [{}]." - , m->GetCleanName() - , m->GetBotSettingCategoryName(e.setting_type) - , e.setting_type - , e.value + LogBotSettings("[{}] says, 'Loading {} [{}] - setting to [{}].", + m->GetCleanName(), + m->GetBotSettingCategoryName(e.setting_type), + e.setting_type, + e.value ); } else { - LogBotSettings("[{}] says, 'Loading {} [{}], {} [{}] - setting to [{}]." - , m->GetCleanName() - , m->GetBotSpellCategoryName(e.setting_type) - , e.setting_type - , m->GetSpellTypeNameByID(e.setting_id) - , e.setting_id - , e.value + LogBotSettings("[{}] says, 'Loading {} [{}], {} [{}] - setting to [{}].", + m->GetCleanName(), + m->GetBotSpellCategoryName(e.setting_type), + e.setting_type, + m->GetSpellTypeNameByID(e.setting_id), + e.setting_id, + e.value ); } diff --git a/zone/client.cpp b/zone/client.cpp index 31ac137c9..27480804b 100644 --- a/zone/client.cpp +++ b/zone/client.cpp @@ -13308,14 +13308,8 @@ std::string Client::SplitCommandHelpText(std::vector msg, std::stri for (const auto& s : msg_split) { returnText += DialogueWindow::TableRow( - DialogueWindow::TableCell( - fmt::format( - "{}", - DialogueWindow::ColorMessage(((secondColor && i == 0) ? color : secondaryColor), s) - ) - ) + DialogueWindow::TableCell(DialogueWindow::ColorMessage(((secondColor && i == 0) ? color : secondaryColor), s)) ); - } } diff --git a/zone/mob.cpp b/zone/mob.cpp index 314a3a601..3f8426d08 100644 --- a/zone/mob.cpp +++ b/zone/mob.cpp @@ -4822,7 +4822,7 @@ bool Mob::PlotPositionAroundTarget(Mob* target, float &x_dest, float &y_dest, fl return Result; } -bool Mob::PlotBotPositionAroundTarget(Mob* target, float& x_dest, float& y_dest, float& z_dest, float min_distance, float max_distance, bool behindOnly, bool frontOnly, bool bypassLoS) { +bool Mob::PlotBotPositionAroundTarget(Mob* target, float& x_dest, float& y_dest, float& z_dest, float min_distance, float max_distance, bool behind_only, bool front_only, bool bypass_los) { bool Result = false; if (target) { @@ -4830,41 +4830,41 @@ bool Mob::PlotBotPositionAroundTarget(Mob* target, float& x_dest, float& y_dest, min_distance = min_distance; max_distance = max_distance; - float tempX = 0; - float tempY = 0; - float tempZ = target->GetZ(); - float bestZ = 0; + float temp_x = 0; + float temp_y = 0; + float temp_z = target->GetZ(); + float best_z = 0; auto offset = GetZOffset(); - const float tarX = target->GetX(); - const float tarY = target->GetY(); + const float tar_x = target->GetX(); + const float tar_y = target->GetY(); float tar_distance = 0; glm::vec3 temp_z_Position; glm::vec4 temp_m_Position; - const uint16 maxIterationsAllowed = 50; + const uint16 max_iterations_allowed = 50; uint16 counter = 0; - while (counter < maxIterationsAllowed) { - tempX = tarX + zone->random.Real(-max_distance, max_distance); - tempY = tarY + zone->random.Real(-max_distance, max_distance); + while (counter < max_iterations_allowed) { + temp_x = tar_x + zone->random.Real(-max_distance, max_distance); + temp_y = tar_y + zone->random.Real(-max_distance, max_distance); - temp_z_Position.x = tempX; - temp_z_Position.y = tempY; - temp_z_Position.z = tempZ; - bestZ = GetFixedZ(temp_z_Position); + temp_z_Position.x = temp_z; + temp_z_Position.y = temp_y; + temp_z_Position.z = temp_z; + best_z = GetFixedZ(temp_z_Position); - if (bestZ != BEST_Z_INVALID) { - tempZ = bestZ; + if (best_z != BEST_Z_INVALID) { + temp_z = best_z; } else { counter++; continue; } - temp_m_Position.x = tempX; - temp_m_Position.y = tempY; - temp_m_Position.z = tempZ; + temp_m_Position.x = temp_x; + temp_m_Position.y = temp_y; + temp_m_Position.z = temp_z; tar_distance = Distance(target->GetPosition(), temp_m_Position); @@ -4872,15 +4872,15 @@ bool Mob::PlotBotPositionAroundTarget(Mob* target, float& x_dest, float& y_dest, counter++; continue; } - if (frontOnly && !InFrontMob(target, tempX, tempY)) { + if (front_only && !InFrontMob(target, temp_x, temp_y)) { counter++; continue; } - else if (behindOnly && !BehindMob(target, tempX, tempY)) { + else if (behind_only && !BehindMob(target, temp_x, temp_y)) { counter++; continue; } - if (!bypassLoS && CastToBot()->RequiresLoSForPositioning() && !CheckPositioningLosFN(target, tempX, tempY, tempZ)) { + if (!bypass_los && CastToBot()->RequiresLoSForPositioning() && !CheckPositioningLosFN(target, temp_x, temp_y, temp_z)) { counter++; continue; } @@ -4890,9 +4890,9 @@ bool Mob::PlotBotPositionAroundTarget(Mob* target, float& x_dest, float& y_dest, } if (Result) { - x_dest = tempX; - y_dest = tempY; - z_dest = tempZ; + x_dest = temp_x; + y_dest = temp_y; + z_dest = temp_z; } } @@ -8690,7 +8690,7 @@ void Mob::CheckScanCloseMobsMovingTimer() } } -std::vector Mob::GatherSpellTargets(bool entireRaid, Mob* target, bool noClients, bool noBots, bool noPets) { +std::vector Mob::GatherSpellTargets(bool entire_raid, Mob* target, bool no_clients, bool no_bots, bool no_pets) { std::vector valid_spell_targets; if (IsRaidGrouped()) { @@ -8704,25 +8704,32 @@ std::vector Mob::GatherSpellTargets(bool entireRaid, Mob* target, bool noC } if (raid) { - if (entireRaid) { + if (entire_raid) { for (const auto& m : raid->members) { - if (m.member && m.group_number != RAID_GROUPLESS && ((m.member->IsClient() && !noClients) || (m.member->IsBot() && !noBots))) { + if (m.member && m.group_number != RAID_GROUPLESS && ((m.member->IsClient() && !no_clients) || (m.member->IsBot() && !no_bots))) { valid_spell_targets.emplace_back(m.member); } } } else { - std::vector raidGroup; + std::vector raid_group; if (target) { - raidGroup = raid->GetRaidGroupMembers(raid->GetGroup(target->GetName())); + raid_group = raid->GetRaidGroupMembers(raid->GetGroup(target->GetName())); } else { - raidGroup = raid->GetRaidGroupMembers(raid->GetGroup(GetName())); + raid_group = raid->GetRaidGroupMembers(raid->GetGroup(GetName())); } - for (const auto& m : raidGroup) { - if (m.member && m.group_number != RAID_GROUPLESS && ((m.member->IsClient() && !noClients) || (m.member->IsBot() && !noBots))) { + for (const auto& m : raid_group) { + if ( + m.member && + m.group_number != RAID_GROUPLESS && + ( + (m.member->IsClient() && !no_clients) || + (m.member->IsBot() && !no_bots) + ) + ) { valid_spell_targets.emplace_back(m.member); } } @@ -8734,7 +8741,7 @@ std::vector Mob::GatherSpellTargets(bool entireRaid, Mob* target, bool noC if (group) { for (const auto& m : group->members) { - if (m && ((m->IsClient() && !noClients) || (m->IsBot() && !noBots))) { + if (m && ((m->IsClient() && !no_clients) || (m->IsBot() && !no_bots))) { valid_spell_targets.emplace_back(m); } } @@ -8747,16 +8754,16 @@ std::vector Mob::GatherSpellTargets(bool entireRaid, Mob* target, bool noC return valid_spell_targets; } -uint16 Mob::GetSpellTypeIDByShortName(std::string spellTypeString) { +uint16 Mob::GetSpellTypeIDByShortName(std::string spell_type_string) { for (int i = BotSpellTypes::START; i <= BotSpellTypes::END; ++i) { - if (!Strings::ToLower(spellTypeString).compare(GetSpellTypeShortNameByID(i))) { + if (!Strings::ToLower(spell_type_string).compare(GetSpellTypeShortNameByID(i))) { return i; } } for (int i = BotSpellTypes::COMMANDED_START; i <= BotSpellTypes::COMMANDED_END; ++i) { - if (!Strings::ToLower(spellTypeString).compare(GetSpellTypeShortNameByID(i))) { + if (!Strings::ToLower(spell_type_string).compare(GetSpellTypeShortNameByID(i))) { return i; } } @@ -8765,16 +8772,16 @@ uint16 Mob::GetSpellTypeIDByShortName(std::string spellTypeString) { } bool Mob::IsValidBotSpellCategory(uint8 setting_type) { - return (setting_type >= BotSettingCategories::START && setting_type <= BotSettingCategories::END_FULL); + return EQ::ValueWithin(setting_type, BotSettingCategories::START, BotSettingCategories::END_FULL); } std::string Mob::GetBotSpellCategoryName(uint8 setting_type) { return IsValidBotBaseSetting(setting_type) ? botSpellCategory_names[setting_type] : "UNKNOWN CATEGORY"; } -uint16 Mob::GetBotSpellCategoryIDByShortName(std::string settingString) { +uint16 Mob::GetBotSpellCategoryIDByShortName(std::string setting_string) { for (int i = BotSettingCategories::START; i <= BotSettingCategories::END; ++i) { - if (!Strings::ToLower(settingString).compare(Strings::ToLower(GetBotSpellCategoryName(i)))) { + if (!Strings::ToLower(setting_string).compare(Strings::ToLower(GetBotSpellCategoryName(i)))) { return i; } } @@ -8783,16 +8790,16 @@ uint16 Mob::GetBotSpellCategoryIDByShortName(std::string settingString) { } bool Mob::IsValidBotBaseSetting(uint16 setting_type) { - return (setting_type >= BotBaseSettings::START_ALL && setting_type <= BotBaseSettings::END); + return EQ::ValueWithin(setting_type, BotBaseSettings::START_ALL, BotBaseSettings::END); } std::string Mob::GetBotSettingCategoryName(uint16 setting_type) { return IsValidBotBaseSetting(setting_type) ? botBaseSettings_names[setting_type] : "UNKNOWN SETTING"; } -uint16 Mob::GetBaseSettingIDByShortName(std::string settingString) { +uint16 Mob::GetBaseSettingIDByShortName(std::string setting_string) { for (int i = BotSettingCategories::START; i <= BotSettingCategories::END; ++i) { - if (!Strings::ToLower(settingString).compare(Strings::ToLower(GetBotSettingCategoryName(i)))) { + if (!Strings::ToLower(setting_string).compare(Strings::ToLower(GetBotSettingCategoryName(i)))) { return i; } } @@ -8800,30 +8807,33 @@ uint16 Mob::GetBaseSettingIDByShortName(std::string settingString) { return UINT16_MAX; } -bool Mob::IsValidSpellType(uint16 spellType) { - return (spellType >= BotSpellTypes::START && spellType <= BotSpellTypes::END) || (spellType >= BotSpellTypes::COMMANDED_START && spellType <= BotSpellTypes::COMMANDED_END); +bool Mob::IsValidSpellType(uint16 spell_type) { + return ( + EQ::ValueWithin(spell_type, BotSpellTypes::START, BotSpellTypes::END) || + EQ::ValueWithin(spell_type, BotSpellTypes::COMMANDED_START, BotSpellTypes::COMMANDED_END) + ); } -std::string Mob::GetSpellTypeShortNameByID(uint16 spellType) { - return IsValidSpellType(spellType) ? spellType_shortNames[spellType] : "UNKNOWN SPELLTYPE"; +std::string Mob::GetSpellTypeShortNameByID(uint16 spell_type) { + return IsValidSpellType(spell_type) ? spellType_shortNames[spell_type] : "UNKNOWN SPELLTYPE"; } -std::string Mob::GetSpellTypeNameByID(uint16 spellType) { - return IsValidSpellType(spellType) ? spellType_names[spellType] : "UNKNOWN SPELLTYPE"; +std::string Mob::GetSpellTypeNameByID(uint16 spell_type) { + return IsValidSpellType(spell_type) ? spellType_names[spell_type] : "UNKNOWN SPELLTYPE"; } -bool Mob::IsValidSubType(uint16 subType) { - return (subType >= CommandedSubTypes::START && subType <= CommandedSubTypes::END); +bool Mob::IsValidSubType(uint16 sub_type) { + return EQ::ValueWithin(sub_type, CommandedSubTypes::START, CommandedSubTypes::END); } -std::string Mob::GetSubTypeNameByID(uint16 subType) { - return IsValidSpellType(subType) ? botSubType_names[subType] : "UNKNOWN SUBTYPE"; +std::string Mob::GetSubTypeNameByID(uint16 sub_type) { + return IsValidSpellType(sub_type) ? botSubType_names[sub_type] : "UNKNOWN SUBTYPE"; } -bool Mob::GetDefaultSpellHold(uint16 spellType, uint8 stance) { - uint8 botClass = GetClass(); +bool Mob::GetDefaultSpellHold(uint16 spell_type, uint8 stance) { + uint8 bot_class = GetClass(); - switch (spellType) { + switch (spell_type) { case BotSpellTypes::FastHeals: case BotSpellTypes::VeryFastHeals: case BotSpellTypes::Pet: @@ -8866,7 +8876,7 @@ bool Mob::GetDefaultSpellHold(uint16 spellType, uint8 stance) { case BotSpellTypes::InCombatBuffSong: case BotSpellTypes::OutOfCombatBuffSong: case BotSpellTypes::PreCombatBuffSong: - if (botClass == Class::Bard) { + if (bot_class == Class::Bard) { return false; } else { @@ -8917,7 +8927,7 @@ bool Mob::GetDefaultSpellHold(uint16 spellType, uint8 stance) { return false; } case BotSpellTypes::HateLine: - if (botClass == Class::ShadowKnight || botClass == Class::Paladin) { + if (bot_class == Class::ShadowKnight || bot_class == Class::Paladin) { switch (stance) { case Stance::Aggressive: return false; @@ -8948,8 +8958,8 @@ bool Mob::GetDefaultSpellHold(uint16 spellType, uint8 stance) { } } -uint16 Mob::GetDefaultSpellDelay(uint16 spellType, uint8 stance) { - switch (spellType) { +uint16 Mob::GetDefaultSpellDelay(uint16 spell_type, uint8 stance) { + switch (spell_type) { case BotSpellTypes::VeryFastHeals: case BotSpellTypes::PetVeryFastHeals: return 1500; @@ -9015,8 +9025,8 @@ uint16 Mob::GetDefaultSpellDelay(uint16 spellType, uint8 stance) { } } -uint8 Mob::GetDefaultSpellMinThreshold(uint16 spellType, uint8 stance) { - switch (spellType) { +uint8 Mob::GetDefaultSpellMinThreshold(uint16 spell_type, uint8 stance) { + switch (spell_type) { case BotSpellTypes::AEDebuff: case BotSpellTypes::Debuff: case BotSpellTypes::AEDispel: @@ -9063,10 +9073,10 @@ uint8 Mob::GetDefaultSpellMinThreshold(uint16 spellType, uint8 stance) { } } -uint8 Mob::GetDefaultSpellMaxThreshold(uint16 spellType, uint8 stance) { - uint8 botClass = GetClass(); +uint8 Mob::GetDefaultSpellMaxThreshold(uint16 spell_type, uint8 stance) { + uint8 bot_class = GetClass(); - switch (spellType) { + switch (spell_type) { case BotSpellTypes::Escape: case BotSpellTypes::VeryFastHeals: case BotSpellTypes::PetVeryFastHeals: @@ -9153,7 +9163,7 @@ uint8 Mob::GetDefaultSpellMaxThreshold(uint16 spellType, uint8 stance) { case BotSpellTypes::GroupHoTHeals: case BotSpellTypes::HoTHeals: case BotSpellTypes::PetHoTHeals: - if (botClass == Class::Necromancer || botClass == Class::Shaman) { + if (bot_class == Class::Necromancer || bot_class == Class::Shaman) { return 60; } else { @@ -9195,24 +9205,24 @@ uint8 Mob::GetDefaultSpellMaxThreshold(uint16 spellType, uint8 stance) { } } -void Mob::SetSpellHold(uint16 spellType, bool holdStatus) { - _spellSettings[spellType].hold = holdStatus; +void Mob::SetSpellHold(uint16 spell_type, bool hold_status) { + _spellSettings[spell_type].hold = hold_status; } -void Mob::SetSpellDelay(uint16 spellType, uint16 delayValue) { - _spellSettings[spellType].delay = delayValue; +void Mob::SetSpellDelay(uint16 spell_type, uint16 delay_value) { + _spellSettings[spell_type].delay = delay_value; } -void Mob::SetSpellMinThreshold(uint16 spellType, uint8 thresholdValue) { - _spellSettings[spellType].minThreshold = thresholdValue; +void Mob::SetSpellMinThreshold(uint16 spell_type, uint8 threshold_value) { + _spellSettings[spell_type].minThreshold = threshold_value; } -void Mob::SetSpellMaxThreshold(uint16 spellType, uint8 thresholdValue) { - _spellSettings[spellType].maxThreshold = thresholdValue; +void Mob::SetSpellMaxThreshold(uint16 spell_type, uint8 threshold_value) { + _spellSettings[spell_type].maxThreshold = threshold_value; } -void Mob::SetSpellTypeRecastTimer(uint16 spellType, uint32 recastTime) { - _spellSettings[spellType].recastTimer.Start(recastTime); +void Mob::SetSpellTypeRecastTimer(uint16 spell_type, uint32 recast_time) { + _spellSettings[spell_type].recastTimer.Start(recast_time); } void Mob::StartBotSpellTimers() { @@ -9227,84 +9237,84 @@ void Mob::DisableBotSpellTimers() { } } -bool Mob::GetUltimateSpellHold(uint16 spellType, Mob* tar) { +bool Mob::GetUltimateSpellHold(uint16 spell_type, Mob* tar) { if (!tar) { - return GetSpellHold(spellType); + return GetSpellHold(spell_type); } if (tar->IsPet() && tar->GetOwner() && tar->GetOwner()->IsOfClientBot()) { - return tar->GetOwner()->GetSpellHold(GetPetSpellType(spellType)); + return tar->GetOwner()->GetSpellHold(GetPetSpellType(spell_type)); } - return GetSpellHold(spellType); + return GetSpellHold(spell_type); } -uint16 Mob::GetUltimateSpellDelay(uint16 spellType, Mob* tar) { +uint16 Mob::GetUltimateSpellDelay(uint16 spell_type, Mob* tar) { if (!tar) { - return GetSpellDelay(spellType); + return GetSpellDelay(spell_type); } if (tar->IsPet() && tar->GetOwner() && tar->GetOwner()->IsOfClientBot()) { - return tar->GetOwner()->GetSpellDelay(GetPetSpellType(spellType)); + return tar->GetOwner()->GetSpellDelay(GetPetSpellType(spell_type)); } - if (IsBotSpellTypeOtherBeneficial(spellType) && tar->IsOfClientBot()) { - return tar->GetSpellDelay(spellType); + if (IsBotSpellTypeOtherBeneficial(spell_type) && tar->IsOfClientBot()) { + return tar->GetSpellDelay(spell_type); } - return GetSpellDelay(spellType); + return GetSpellDelay(spell_type); } -bool Mob::GetUltimateSpellDelayCheck(uint16 spellType, Mob* tar) { +bool Mob::GetUltimateSpellDelayCheck(uint16 spell_type, Mob* tar) { if (!tar) { - return SpellTypeRecastCheck(spellType); + return SpellTypeRecastCheck(spell_type); } if (tar->IsPet() && tar->GetOwner() && tar->GetOwner()->IsOfClientBot()) { - return tar->GetOwner()->SpellTypeRecastCheck(GetPetSpellType(spellType)); + return tar->GetOwner()->SpellTypeRecastCheck(GetPetSpellType(spell_type)); } - if (IsBotSpellTypeOtherBeneficial(spellType) && tar->IsOfClientBot()) { - return tar->SpellTypeRecastCheck(spellType); + if (IsBotSpellTypeOtherBeneficial(spell_type) && tar->IsOfClientBot()) { + return tar->SpellTypeRecastCheck(spell_type); } - return SpellTypeRecastCheck(spellType); + return SpellTypeRecastCheck(spell_type); } -uint8 Mob::GetUltimateSpellMinThreshold(uint16 spellType, Mob* tar) { +uint8 Mob::GetUltimateSpellMinThreshold(uint16 spell_type, Mob* tar) { if (!tar) { - return GetSpellMinThreshold(spellType); + return GetSpellMinThreshold(spell_type); } if (tar->IsPet() && tar->GetOwner() && tar->GetOwner()->IsOfClientBot()) { - return tar->GetOwner()->GetSpellMinThreshold(GetPetSpellType(spellType)); + return tar->GetOwner()->GetSpellMinThreshold(GetPetSpellType(spell_type)); } - if (IsBotSpellTypeOtherBeneficial(spellType) && tar->IsOfClientBot()) { - return tar->GetSpellMinThreshold(spellType); + if (IsBotSpellTypeOtherBeneficial(spell_type) && tar->IsOfClientBot()) { + return tar->GetSpellMinThreshold(spell_type); } - return GetSpellMinThreshold(spellType); + return GetSpellMinThreshold(spell_type); } -uint8 Mob::GetUltimateSpellMaxThreshold(uint16 spellType, Mob* tar) { +uint8 Mob::GetUltimateSpellMaxThreshold(uint16 spell_type, Mob* tar) { if (!tar) { - return GetSpellMaxThreshold(spellType); + return GetSpellMaxThreshold(spell_type); } if (tar->IsPet() && tar->GetOwner() && tar->GetOwner()->IsOfClientBot()) { - return tar->GetOwner()->GetSpellMaxThreshold(GetPetSpellType(spellType)); + return tar->GetOwner()->GetSpellMaxThreshold(GetPetSpellType(spell_type)); } - if (IsBotSpellTypeOtherBeneficial(spellType) && tar->IsOfClientBot()) { - return tar->GetSpellMaxThreshold(spellType); + if (IsBotSpellTypeOtherBeneficial(spell_type) && tar->IsOfClientBot()) { + return tar->GetSpellMaxThreshold(spell_type); } - return GetSpellMaxThreshold(spellType); + return GetSpellMaxThreshold(spell_type); } -uint16 Mob::GetPetSpellType(uint16 spellType) { - switch (spellType) { +uint16 Mob::GetPetSpellType(uint16 spell_type) { + switch (spell_type) { case BotSpellTypes::VeryFastHeals: return BotSpellTypes::PetVeryFastHeals; case BotSpellTypes::FastHeals: @@ -9327,11 +9337,11 @@ uint16 Mob::GetPetSpellType(uint16 spellType) { break; } - return spellType; + return spell_type; } -uint8 Mob::GetHPRatioForSpellType(uint16 spellType, Mob* tar) { - switch (spellType) { +uint8 Mob::GetHPRatioForSpellType(uint16 spell_type, Mob* tar) { + switch (spell_type) { case BotSpellTypes::Escape: case BotSpellTypes::HateRedux: case BotSpellTypes::InCombatBuff: @@ -9350,28 +9360,28 @@ uint8 Mob::GetHPRatioForSpellType(uint16 spellType, Mob* tar) { return tar->GetHPRatio(); } -void Mob::SetBotSetting(uint8 settingType, uint16 botSetting, int settingValue) { +void Mob::SetBotSetting(uint8 setting_type, uint16 bot_setting, int setting_value) { if (!IsOfClientBot()) { return; } if (IsClient()) { - CastToClient()->SetBotSetting(settingType, botSetting, settingValue); + CastToClient()->SetBotSetting(setting_type, bot_setting, setting_value); return; } if (IsBot()) { - CastToBot()->SetBotSetting(settingType, botSetting, settingValue); + CastToBot()->SetBotSetting(setting_type, bot_setting, setting_value); return; } return; } -void Mob::SetBaseSetting(uint16 baseSetting, int settingValue) { - switch (baseSetting) { +void Mob::SetBaseSetting(uint16 base_setting, int setting_value) { + switch (base_setting) { case BotBaseSettings::IllusionBlock: - SetIllusionBlock(settingValue); + SetIllusionBlock(setting_value); break; default: break; @@ -9409,7 +9419,7 @@ void Mob::ClearDataBucketCache() } } -bool Mob::IsInGroupOrRaid(Mob *other, bool sameRaidGroup) { +bool Mob::IsInGroupOrRaid(Mob *other, bool same_raid_group) { if (!other || !IsOfClientBotMerc() || !other->IsOfClientBotMerc()) { return false; } @@ -9440,23 +9450,23 @@ bool Mob::IsInGroupOrRaid(Mob *other, bool sameRaidGroup) { return false; } - Raid* otherRaid = nullptr; + Raid* other_raid = nullptr; if (other->IsBot()) { - otherRaid = other->CastToBot()->GetStoredRaid(); + other_raid = other->CastToBot()->GetStoredRaid(); } else { - otherRaid = other->GetRaid(); + other_raid = other->GetRaid(); } - if (!otherRaid) { + if (!other_raid) { return false; } - auto rGroup = raid->GetGroup(GetCleanName()); - auto rOGroup = otherRaid->GetGroup(other->GetCleanName()); + auto raid_group = raid->GetGroup(GetCleanName()); + auto raid_other_group = other_raid->GetGroup(other->GetCleanName()); - if (rGroup == RAID_GROUPLESS || rOGroup == RAID_GROUPLESS || (sameRaidGroup && rGroup != rOGroup)) { + if (raid_group == RAID_GROUPLESS || raid_other_group == RAID_GROUPLESS || (same_raid_group && raid_group != raid_other_group)) { return false; } @@ -9464,10 +9474,10 @@ bool Mob::IsInGroupOrRaid(Mob *other, bool sameRaidGroup) { } else { auto* group = GetGroup(); - auto* groupOther = other->GetGroup(); + auto* group_other = other->GetGroup(); if (group) { - if (!groupOther || group != groupOther) { + if (!group_other || group != group_other) { return false; } diff --git a/zone/mob.h b/zone/mob.h index 3bd97c7ce..ae121c772 100644 --- a/zone/mob.h +++ b/zone/mob.h @@ -432,53 +432,53 @@ public: inline bool SpellTypeRecastCheck(uint16 spellType) { return (IsClient() ? true : _spellSettings[spellType].recastTimer.GetRemainingTime() > 0 ? false : true); } - std::vector GatherSpellTargets(bool entireRaid = false, Mob* target = nullptr, bool noClients = false, bool noBots = false, bool noPets = false); + std::vector GatherSpellTargets(bool entireRaid = false, Mob* target = nullptr, bool no_clients = false, bool no_bots = false, bool no_pets = false); - uint16 GetSpellTypeIDByShortName(std::string spellTypeString); + uint16 GetSpellTypeIDByShortName(std::string spellType_string); bool IsValidBotSpellCategory(uint8 setting_type); std::string GetBotSpellCategoryName(uint8 setting_type); - uint16 GetBotSpellCategoryIDByShortName(std::string settingString); + uint16 GetBotSpellCategoryIDByShortName(std::string setting_string); bool IsValidBotBaseSetting(uint16 setting_type); std::string GetBotSettingCategoryName(uint16 setting_type); - uint16 GetBaseSettingIDByShortName(std::string settingString); - bool IsValidSpellType(uint16 spellType); - std::string GetSpellTypeNameByID(uint16 spellType); - std::string GetSpellTypeShortNameByID(uint16 spellType); - bool IsValidSubType(uint16 subType); - std::string GetSubTypeNameByID(uint16 subType); + uint16 GetBaseSettingIDByShortName(std::string setting_string); + bool IsValidSpellType(uint16 spell_type); + std::string GetSpellTypeNameByID(uint16 spell_type); + std::string GetSpellTypeShortNameByID(uint16 spell_type); + bool IsValidSubType(uint16 sub_type); + std::string GetSubTypeNameByID(uint16 sub_type); - bool GetDefaultSpellHold(uint16 spellType, uint8 stance = Stance::Balanced); - uint16 GetDefaultSpellDelay(uint16 spellType, uint8 stance = Stance::Balanced); - uint8 GetDefaultSpellMinThreshold(uint16 spellType, uint8 stance = Stance::Balanced); - uint8 GetDefaultSpellMaxThreshold(uint16 spellType, uint8 stance = Stance::Balanced); + bool GetDefaultSpellHold(uint16 spell_type, uint8 stance = Stance::Balanced); + uint16 GetDefaultSpellDelay(uint16 spell_type, uint8 stance = Stance::Balanced); + uint8 GetDefaultSpellMinThreshold(uint16 spell_type, uint8 stance = Stance::Balanced); + uint8 GetDefaultSpellMaxThreshold(uint16 spell_type, uint8 stance = Stance::Balanced); - inline bool GetSpellHold(uint16 spellType) const { return _spellSettings[spellType].hold; } - void SetSpellHold(uint16 spellType, bool holdStatus); - inline uint16 GetSpellDelay(uint16 spellType) const { return _spellSettings[spellType].delay; } - void SetSpellDelay(uint16 spellType, uint16 delayValue); - inline uint8 GetSpellMinThreshold(uint16 spellType) const { return _spellSettings[spellType].minThreshold; } - void SetSpellMinThreshold(uint16 spellType, uint8 thresholdValue); - inline uint8 GetSpellMaxThreshold(uint16 spellType) const { return _spellSettings[spellType].maxThreshold; } - void SetSpellMaxThreshold(uint16 spellType, uint8 thresholdValue); + inline bool GetSpellHold(uint16 spell_type) const { return _spellSettings[spell_type].hold; } + void SetSpellHold(uint16 spell_type, bool hold_status); + inline uint16 GetSpellDelay(uint16 spell_type) const { return _spellSettings[spell_type].delay; } + void SetSpellDelay(uint16 spell_type, uint16 delay_value); + inline uint8 GetSpellMinThreshold(uint16 spell_type) const { return _spellSettings[spell_type].minThreshold; } + void SetSpellMinThreshold(uint16 spell_type, uint8 threshold_value); + inline uint8 GetSpellMaxThreshold(uint16 spell_type) const { return _spellSettings[spell_type].maxThreshold; } + void SetSpellMaxThreshold(uint16 spell_type, uint8 threshold_value); - inline uint16 GetSpellTypeRecastTimer(uint16 spellType) { return _spellSettings[spellType].recastTimer.GetRemainingTime(); } - void SetSpellTypeRecastTimer(uint16 spellType, uint32 recastTime); + inline uint16 GetSpellTypeRecastTimer(uint16 spell_type) { return _spellSettings[spell_type].recastTimer.GetRemainingTime(); } + void SetSpellTypeRecastTimer(uint16 spell_type, uint32 recast_time); - uint8 GetHPRatioForSpellType(uint16 spellType, Mob* tar); - bool GetUltimateSpellHold(uint16 spellType, Mob* tar); - uint16 GetUltimateSpellDelay(uint16 spellType, Mob* tar); - bool GetUltimateSpellDelayCheck(uint16 spellType, Mob* tar); - uint8 GetUltimateSpellMinThreshold(uint16 spellType, Mob* tar); - uint8 GetUltimateSpellMaxThreshold(uint16 spellType, Mob* tar); + uint8 GetHPRatioForSpellType(uint16 spell_type, Mob* tar); + bool GetUltimateSpellHold(uint16 spell_type, Mob* tar); + uint16 GetUltimateSpellDelay(uint16 spell_type, Mob* tar); + bool GetUltimateSpellDelayCheck(uint16 spell_type, Mob* tar); + uint8 GetUltimateSpellMinThreshold(uint16 spell_type, Mob* tar); + uint8 GetUltimateSpellMaxThreshold(uint16 spell_type, Mob* tar); - uint16 GetPetSpellType(uint16 spellType); + uint16 GetPetSpellType(uint16 spell_type); void DisableBotSpellTimers(); void StartBotSpellTimers(); - void SetBotSetting(uint8 settingType, uint16 botSetting, int settingValue); - void SetBaseSetting(uint16 baseSetting, int settingValue); + void SetBotSetting(uint8 spell_type, uint16 bot_setting, int setting_value); + void SetBaseSetting(uint16 base_setting, int setting_value); void SetIllusionBlock(bool value) { _illusionBlock = value; } bool GetIllusionBlock() const { return _illusionBlock; } @@ -785,7 +785,7 @@ public: virtual bool HasGroup() = 0; virtual Raid* GetRaid() = 0; virtual Group* GetGroup() = 0; - bool IsInGroupOrRaid(Mob* other, bool sameRaidGroup = false); + bool IsInGroupOrRaid(Mob* other, bool same_raid_group = false); //Faction virtual inline int32 GetPrimaryFaction() const { return 0; } @@ -940,7 +940,7 @@ public: void ShowStats(Client* client); void ShowBuffs(Client* c); bool PlotPositionAroundTarget(Mob* target, float &x_dest, float &y_dest, float &z_dest, bool lookForAftArc = true); - bool PlotBotPositionAroundTarget(Mob* target, float& x_dest, float& y_dest, float& z_dest, float min_distance, float max_distance, bool behindOnly = false, bool frontOnly = false, bool bypassLoS = false); + bool PlotBotPositionAroundTarget(Mob* target, float& x_dest, float& y_dest, float& z_dest, float min_distance, float max_distance, bool behind_only = false, bool front_only = false, bool bypass_los = false); virtual int GetKillExpMod() const { return 100; } // aura functions diff --git a/zone/spells.cpp b/zone/spells.cpp index 8d427aeb1..919706d42 100644 --- a/zone/spells.cpp +++ b/zone/spells.cpp @@ -2180,14 +2180,14 @@ bool Mob::DetermineSpellTargets(uint16 spell_id, Mob *&spell_target, Mob *&ae_ce IsClient() && CastToClient()->TGB() && IsTGBCompatibleSpell(spell_id) && (slot != CastingSlot::Item || RuleB(Spells, AllowItemTGB)) - ) { + ) { if ( !target || target->IsCorpse() || ( target->IsNPC() && !(target->GetOwner() && target->GetOwner()->IsClient()) - ) + ) ) { spell_target = this; } @@ -7549,8 +7549,8 @@ bool Mob::IsImmuneToBotSpell(uint16 spell_id, Mob* caster) { int effect_index; - if (caster == nullptr) { - return(false); + if (!caster) { + return false; } //TODO: this function loops through the effect list for