[Cleanup] Cleanup Stance Code (#4368)

* [Cleanup] Cleanup Stance-based Code

* Command

* Update emu_constants.h

* Update stance.cpp

* Cleanup
This commit is contained in:
Alex King 2024-07-02 21:50:34 -04:00 committed by GitHub
parent e63f34638b
commit a85f4fb703
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
15 changed files with 206 additions and 144 deletions

View File

@ -80,39 +80,19 @@ bool Bug::IsValid(uint32 category_id)
return bug_category_names.find(category_id) != bug_category_names.end(); return bug_category_names.find(category_id) != bug_category_names.end();
} }
const char *EQ::constants::GetStanceName(StanceType stance_type) { std::string Stance::GetName(uint8 stance_id)
switch (stance_type) { {
case stanceUnknown: return IsValid(stance_id) ? stance_names[stance_id] : "UNKNOWN STANCE";
return "Unknown";
case stancePassive:
return "Passive";
case stanceBalanced:
return "Balanced";
case stanceEfficient:
return "Efficient";
case stanceReactive:
return "Reactive";
case stanceAggressive:
return "Aggressive";
case stanceAssist:
return "Assist";
case stanceBurn:
return "Burn";
case stanceEfficient2:
return "Efficient2";
case stanceBurnAE:
return "BurnAE";
default:
return "Invalid";
}
} }
int EQ::constants::ConvertStanceTypeToIndex(StanceType stance_type) { bool Stance::IsValid(uint8 stance_id)
if (EQ::ValueWithin(stance_type, EQ::constants::stancePassive, EQ::constants::stanceBurnAE)) { {
return (stance_type - EQ::constants::stancePassive); return stance_names.find(stance_id) != stance_names.end();
} }
return 0; uint8 Stance::GetIndex(uint8 stance_id)
{
return IsValid(stance_id) ? (stance_id - Stance::Passive) : 0;
} }
const std::map<uint8, std::string>& EQ::constants::GetLanguageMap() const std::map<uint8, std::string>& EQ::constants::GetLanguageMap()

View File

@ -274,19 +274,6 @@ namespace EQ
const size_t SAY_LINK_CLOSER_SIZE = 1; const size_t SAY_LINK_CLOSER_SIZE = 1;
const size_t SAY_LINK_MAXIMUM_SIZE = (SAY_LINK_OPENER_SIZE + SAY_LINK_BODY_SIZE + SAY_LINK_TEXT_SIZE + SAY_LINK_CLOSER_SIZE); const size_t SAY_LINK_MAXIMUM_SIZE = (SAY_LINK_OPENER_SIZE + SAY_LINK_BODY_SIZE + SAY_LINK_TEXT_SIZE + SAY_LINK_CLOSER_SIZE);
enum StanceType : int {
stanceUnknown = 0,
stancePassive,
stanceBalanced,
stanceEfficient,
stanceReactive,
stanceAggressive,
stanceAssist,
stanceBurn,
stanceEfficient2,
stanceBurnAE
};
enum BotSpellIDs : int { enum BotSpellIDs : int {
Warrior = 3001, Warrior = 3001,
Cleric, Cleric,
@ -362,9 +349,6 @@ namespace EQ
Proximity Proximity
}; };
const char *GetStanceName(StanceType stance_type);
int ConvertStanceTypeToIndex(StanceType stance_type);
extern const std::map<uint8, std::string>& GetLanguageMap(); extern const std::map<uint8, std::string>& GetLanguageMap();
std::string GetLanguageName(uint8 language_id); std::string GetLanguageName(uint8 language_id);
@ -401,10 +385,6 @@ namespace EQ
extern const std::map<uint32, std::string>& GetConsiderColorMap(); extern const std::map<uint32, std::string>& GetConsiderColorMap();
std::string GetConsiderColorName(uint32 consider_color); std::string GetConsiderColorName(uint32 consider_color);
const int STANCE_TYPE_FIRST = stancePassive;
const int STANCE_TYPE_LAST = stanceBurnAE;
const int STANCE_TYPE_COUNT = stanceBurnAE;
} /*constants*/ } /*constants*/
namespace profile { namespace profile {
@ -471,7 +451,7 @@ namespace EQ
Raid, Raid,
Guild Guild
}; };
}; // namespace consent };
} /*EQEmu*/ } /*EQEmu*/
enum ServerLockType : int { enum ServerLockType : int {
@ -741,4 +721,34 @@ static std::map<uint32, std::string> bug_category_names = {
{ Bug::Category::Mercenaries, "Mercenaries" } { Bug::Category::Mercenaries, "Mercenaries" }
}; };
namespace Stance {
constexpr uint32 Unknown = 0;
constexpr uint32 Passive = 1;
constexpr uint32 Balanced = 2;
constexpr uint32 Efficient = 3;
constexpr uint32 Reactive = 4;
constexpr uint32 Aggressive = 5;
constexpr uint32 Assist = 6;
constexpr uint32 Burn = 7;
constexpr uint32 Efficient2 = 8;
constexpr uint32 AEBurn = 9;
std::string GetName(uint8 stance_id);
uint8 GetIndex(uint8 stance_id);
bool IsValid(uint8 stance_id);
}
static std::map<uint32, std::string> stance_names = {
{ Stance::Unknown, "Unknown" },
{ Stance::Passive, "Passive" },
{ Stance::Balanced, "Balanced" },
{ Stance::Efficient, "Efficient" },
{ Stance::Reactive, "Reactive" },
{ Stance::Aggressive, "Aggressive" },
{ Stance::Assist, "Assist" },
{ Stance::Burn, "Burn" },
{ Stance::Efficient2, "Efficient" },
{ Stance::AEBurn, "AE Burn" }
};
#endif /*COMMON_EMU_CONSTANTS_H*/ #endif /*COMMON_EMU_CONSTANTS_H*/

View File

@ -66,6 +66,7 @@ public:
{.parent_command = "find", .sub_command = "recipe", .access_level = AccountStatus::QuestTroupe, .top_level_aliases = "findrecipe"}, {.parent_command = "find", .sub_command = "recipe", .access_level = AccountStatus::QuestTroupe, .top_level_aliases = "findrecipe"},
{.parent_command = "find", .sub_command = "skill", .access_level = AccountStatus::QuestTroupe, .top_level_aliases = "findskill"}, {.parent_command = "find", .sub_command = "skill", .access_level = AccountStatus::QuestTroupe, .top_level_aliases = "findskill"},
{.parent_command = "find", .sub_command = "special_ability", .access_level = AccountStatus::QuestTroupe, .top_level_aliases = "fsa|findspecialability"}, {.parent_command = "find", .sub_command = "special_ability", .access_level = AccountStatus::QuestTroupe, .top_level_aliases = "fsa|findspecialability"},
{.parent_command = "find", .sub_command = "stance", .access_level = AccountStatus::QuestTroupe, .top_level_aliases = "findstance"},
{.parent_command = "find", .sub_command = "spell", .access_level = AccountStatus::QuestTroupe, .top_level_aliases = "fs|findspell"}, {.parent_command = "find", .sub_command = "spell", .access_level = AccountStatus::QuestTroupe, .top_level_aliases = "fs|findspell"},
{.parent_command = "find", .sub_command = "task", .access_level = AccountStatus::QuestTroupe, .top_level_aliases = "findtask"}, {.parent_command = "find", .sub_command = "task", .access_level = AccountStatus::QuestTroupe, .top_level_aliases = "findtask"},
{.parent_command = "find", .sub_command = "zone", .access_level = AccountStatus::QuestTroupe, .top_level_aliases = "fz|findzone"}, {.parent_command = "find", .sub_command = "zone", .access_level = AccountStatus::QuestTroupe, .top_level_aliases = "fz|findzone"},

View File

@ -204,7 +204,7 @@ Bot::Bot(
); );
} }
SetTaunting((GetClass() == Class::Warrior || GetClass() == Class::Paladin || GetClass() == Class::ShadowKnight) && (GetBotStance() == EQ::constants::stanceAggressive)); SetTaunting((GetClass() == Class::Warrior || GetClass() == Class::Paladin || GetClass() == Class::ShadowKnight) && (GetBotStance() == Stance::Aggressive));
SetPauseAI(false); SetPauseAI(false);
m_auto_defend_timer.Disable(); m_auto_defend_timer.Disable();
@ -1899,8 +1899,8 @@ void Bot::AI_Process()
#define NOT_GUARDING (!GetGuardFlag()) #define NOT_GUARDING (!GetGuardFlag())
#define HOLDING (GetHoldFlag()) #define HOLDING (GetHoldFlag())
#define NOT_HOLDING (!GetHoldFlag()) #define NOT_HOLDING (!GetHoldFlag())
#define PASSIVE (GetBotStance() == EQ::constants::stancePassive) #define PASSIVE (GetBotStance() == Stance::Passive)
#define NOT_PASSIVE (GetBotStance() != EQ::constants::stancePassive) #define NOT_PASSIVE (GetBotStance() != Stance::Passive)
Client* bot_owner = (GetBotOwner() && GetBotOwner()->IsClient() ? GetBotOwner()->CastToClient() : nullptr); Client* bot_owner = (GetBotOwner() && GetBotOwner()->IsClient() ? GetBotOwner()->CastToClient() : nullptr);
@ -6912,16 +6912,16 @@ bool EntityList::Bot_AICheckCloseBeneficialSpells(Bot* caster, uint8 iChance, fl
if ((botCasterClass == Class::Paladin || botCasterClass == Class::Beastlord || botCasterClass == Class::Ranger) && (caster->HasGroup() || caster->IsRaidGrouped())) { if ((botCasterClass == Class::Paladin || botCasterClass == Class::Beastlord || botCasterClass == Class::Ranger) && (caster->HasGroup() || caster->IsRaidGrouped())) {
float hpRatioToHeal = 25.0f; float hpRatioToHeal = 25.0f;
switch(caster->GetBotStance()) { switch(caster->GetBotStance()) {
case EQ::constants::stanceReactive: case Stance::Reactive:
case EQ::constants::stanceBalanced: case Stance::Balanced:
hpRatioToHeal = 50.0f; hpRatioToHeal = 50.0f;
break; break;
case EQ::constants::stanceBurn: case Stance::Burn:
case EQ::constants::stanceBurnAE: case Stance::AEBurn:
hpRatioToHeal = 20.0f; hpRatioToHeal = 20.0f;
break; break;
case EQ::constants::stanceAggressive: case Stance::Aggressive:
case EQ::constants::stanceEfficient: case Stance::Efficient:
default: default:
hpRatioToHeal = 25.0f; hpRatioToHeal = 25.0f;
break; break;
@ -7655,11 +7655,7 @@ bool Bot::HasOrMayGetAggro() {
} }
void Bot::SetDefaultBotStance() { void Bot::SetDefaultBotStance() {
EQ::constants::StanceType defaultStance = EQ::constants::stanceBalanced; _botStance = GetClass() == Class::Warrior ? Stance::Aggressive : Stance::Balanced;
if (GetClass() == Class::Warrior)
defaultStance = EQ::constants::stanceAggressive;
_botStance = defaultStance;
} }
void Bot::BotGroupSay(Mob* speaker, const char* msg, ...) { void Bot::BotGroupSay(Mob* speaker, const char* msg, ...) {
@ -9233,4 +9229,4 @@ void Bot::DoItemClick(const EQ::ItemData *item, uint16 slot_id)
} }
uint8 Bot::spell_casting_chances[SPELL_TYPE_COUNT][Class::PLAYER_CLASS_COUNT][EQ::constants::STANCE_TYPE_COUNT][cntHSND] = { 0 }; uint8 Bot::spell_casting_chances[SPELL_TYPE_COUNT][Class::PLAYER_CLASS_COUNT][Stance::AEBurn][cntHSND] = { 0 };

View File

@ -484,7 +484,7 @@ public:
bool IsOfClientBotMerc() const override { return true; } bool IsOfClientBotMerc() const override { return true; }
bool GetRangerAutoWeaponSelect() { return _rangerAutoWeaponSelect; } bool GetRangerAutoWeaponSelect() { return _rangerAutoWeaponSelect; }
EQ::constants::StanceType GetBotStance() { return _botStance; } uint8 GetBotStance() { return _botStance; }
uint8 GetChanceToCastBySpellType(uint32 spellType); uint8 GetChanceToCastBySpellType(uint32 spellType);
bool GetBotEnforceSpellSetting() { return m_enforce_spell_settings; } bool GetBotEnforceSpellSetting() { return m_enforce_spell_settings; }
float GetBotCasterMaxRange(float melee_distance_max); float GetBotCasterMaxRange(float melee_distance_max);
@ -605,12 +605,7 @@ public:
void SetPetChooser(bool p) { _petChooser = p; } void SetPetChooser(bool p) { _petChooser = p; }
void SetBotOwner(Mob* botOwner) { this->_botOwner = botOwner; } void SetBotOwner(Mob* botOwner) { this->_botOwner = botOwner; }
void SetRangerAutoWeaponSelect(bool enable) { GetClass() == Class::Ranger ? _rangerAutoWeaponSelect = enable : _rangerAutoWeaponSelect = false; } void SetRangerAutoWeaponSelect(bool enable) { GetClass() == Class::Ranger ? _rangerAutoWeaponSelect = enable : _rangerAutoWeaponSelect = false; }
void SetBotStance(EQ::constants::StanceType botStance) { void SetBotStance(uint8 stance_id) { _botStance = Stance::IsValid(stance_id) ? Stance::Passive : stance_id; }
if (botStance >= EQ::constants::stancePassive && botStance <= EQ::constants::stanceBurnAE)
_botStance = botStance;
else
_botStance = EQ::constants::stancePassive;
}
void SetBotCasterRange(uint32 bot_caster_range) { m_bot_caster_range = bot_caster_range; } void SetBotCasterRange(uint32 bot_caster_range) { m_bot_caster_range = bot_caster_range; }
uint32 GetSpellRecastTimer(uint16 spell_id = 0); uint32 GetSpellRecastTimer(uint16 spell_id = 0);
bool CheckSpellRecastTimer(uint16 spell_id = 0); bool CheckSpellRecastTimer(uint16 spell_id = 0);
@ -753,7 +748,7 @@ public:
//Raid additions //Raid additions
Raid* p_raid_instance; Raid* p_raid_instance;
static uint8 spell_casting_chances[SPELL_TYPE_COUNT][Class::PLAYER_CLASS_COUNT][EQ::constants::STANCE_TYPE_COUNT][cntHSND]; static uint8 spell_casting_chances[SPELL_TYPE_COUNT][Class::PLAYER_CLASS_COUNT][Stance::AEBurn][cntHSND];
bool BotCastMez(Mob* tar, uint8 botLevel, bool checked_los, BotSpell& botSpell, Raid* raid); bool BotCastMez(Mob* tar, uint8 botLevel, bool checked_los, BotSpell& botSpell, Raid* raid);
bool BotCastHeal(Mob* tar, uint8 botLevel, uint8 botClass, BotSpell& botSpell, Raid* raid); bool BotCastHeal(Mob* tar, uint8 botLevel, uint8 botClass, BotSpell& botSpell, Raid* raid);
@ -870,7 +865,7 @@ private:
std::string _suffix; std::string _suffix;
uint32 _lastZoneId; uint32 _lastZoneId;
bool _rangerAutoWeaponSelect; bool _rangerAutoWeaponSelect;
EQ::constants::StanceType _botStance; uint8 _botStance;
unsigned int RestRegenHP; unsigned int RestRegenHP;
unsigned int RestRegenMana; unsigned int RestRegenMana;
unsigned int RestRegenEndurance; unsigned int RestRegenEndurance;

View File

@ -40,7 +40,7 @@ void bot_command_attack(Client *c, const Seperator *sep)
sbl.remove(nullptr); sbl.remove(nullptr);
for (auto bot_iter : sbl) { for (auto bot_iter : sbl) {
if (bot_iter->GetAppearance() != eaDead && bot_iter->GetBotStance() != EQ::constants::stancePassive) { if (bot_iter->GetAppearance() != eaDead && bot_iter->GetBotStance() != Stance::Passive) {
if (!first_attacker) { if (!first_attacker) {
first_attacker = bot_iter; first_attacker = bot_iter;

View File

@ -198,7 +198,7 @@ void bot_command_clone(Client *c, const Seperator *sep)
return; return;
} }
int clone_stance = EQ::constants::stancePassive; int clone_stance = Stance::Passive;
if (!database.botdb.LoadStance(my_bot->GetBotID(), clone_stance)) { if (!database.botdb.LoadStance(my_bot->GetBotID(), clone_stance)) {
c->Message( c->Message(
Chat::White, Chat::White,
@ -1058,33 +1058,47 @@ void bot_command_stance(Client *c, const Seperator *sep)
return; return;
if (helper_is_help_or_usage(sep->arg[1])) { if (helper_is_help_or_usage(sep->arg[1])) {
c->Message(Chat::White, "usage: %s [current | value: 1-9] ([actionable: target | byname] ([actionable_name]))", sep->arg[0]); c->Message(Chat::White, "usage: %s [current | value: 1-9] ([actionable: target | byname] ([actionable_name]))", sep->arg[0]);
c->Message(Chat::White, "value: %u(%s), %u(%s), %u(%s), %u(%s), %u(%s), %u(%s), %u(%s)", c->Message(
EQ::constants::stancePassive, EQ::constants::GetStanceName(EQ::constants::stancePassive), Chat::White,
EQ::constants::stanceBalanced, EQ::constants::GetStanceName(EQ::constants::stanceBalanced), fmt::format(
EQ::constants::stanceEfficient, EQ::constants::GetStanceName(EQ::constants::stanceEfficient), "Value: {} ({}), {} ({}), {} ({}), {} ({}), {} ({}), {} ({}), {} ({}), {} ({}), {} ({})",
EQ::constants::stanceReactive, EQ::constants::GetStanceName(EQ::constants::stanceReactive), Stance::Passive,
EQ::constants::stanceAggressive, EQ::constants::GetStanceName(EQ::constants::stanceAggressive), Stance::GetName(Stance::Passive),
EQ::constants::stanceAssist, EQ::constants::GetStanceName(EQ::constants::stanceAssist), Stance::Balanced,
EQ::constants::stanceBurn, EQ::constants::GetStanceName(EQ::constants::stanceBurn), Stance::GetName(Stance::Balanced),
EQ::constants::stanceEfficient2, EQ::constants::GetStanceName(EQ::constants::stanceEfficient2), Stance::Efficient,
EQ::constants::stanceBurnAE, EQ::constants::GetStanceName(EQ::constants::stanceBurnAE) Stance::GetName(Stance::Efficient),
Stance::Reactive,
Stance::GetName(Stance::Reactive),
Stance::Aggressive,
Stance::GetName(Stance::Aggressive),
Stance::Assist,
Stance::GetName(Stance::Assist),
Stance::Burn,
Stance::GetName(Stance::Burn),
Stance::Efficient2,
Stance::GetName(Stance::Efficient2),
Stance::AEBurn,
Stance::GetName(Stance::AEBurn)
).c_str()
); );
return; return;
} }
int ab_mask = (ActionableBots::ABM_Target | ActionableBots::ABM_ByName); int ab_mask = (ActionableBots::ABM_Target | ActionableBots::ABM_ByName);
bool current_flag = false; bool current_flag = false;
auto bst = EQ::constants::stanceUnknown; uint8 bst = Stance::Unknown;
if (!strcasecmp(sep->arg[1], "current")) if (!strcasecmp(sep->arg[1], "current"))
current_flag = true; current_flag = true;
else if (sep->IsNumber(1)) { else if (sep->IsNumber(1)) {
bst = (EQ::constants::StanceType)Strings::ToInt(sep->arg[1]); bst = static_cast<uint8>(Strings::ToUnsignedInt(sep->arg[1]));
if (bst < EQ::constants::stanceUnknown || bst > EQ::constants::stanceBurnAE) if (!Stance::IsValid(bst)) {
bst = EQ::constants::stanceUnknown; bst = Stance::Unknown;
}
} }
if (!current_flag && bst == EQ::constants::stanceUnknown) { if (!current_flag && bst == Stance::Unknown) {
c->Message(Chat::White, "A [current] argument or valid numeric [value] is required to use this command"); c->Message(Chat::White, "A [current] argument or valid numeric [value] is required to use this command");
return; return;
} }
@ -1106,8 +1120,8 @@ void bot_command_stance(Client *c, const Seperator *sep)
bot_iter, bot_iter,
fmt::format( fmt::format(
"My current stance is {} ({}).", "My current stance is {} ({}).",
EQ::constants::GetStanceName(bot_iter->GetBotStance()), Stance::GetName(bot_iter->GetBotStance()),
static_cast<int>(bot_iter->GetBotStance()) bot_iter->GetBotStance()
).c_str() ).c_str()
); );
} }

View File

@ -34,7 +34,7 @@ void bot_command_pull(Client *c, const Seperator *sep)
Bot* bot_puller = nullptr; Bot* bot_puller = nullptr;
for (auto bot_iter : sbl) { for (auto bot_iter : sbl) {
if (bot_iter->GetAppearance() == eaDead || bot_iter->GetBotStance() == EQ::constants::stancePassive) { if (bot_iter->GetAppearance() == eaDead || bot_iter->GetBotStance() == Stance::Passive) {
continue; continue;
} }

View File

@ -135,7 +135,7 @@ bool BotDatabase::LoadBotSpellCastingChances()
if ( if (
e.spell_type_index >= Bot::SPELL_TYPE_COUNT || e.spell_type_index >= Bot::SPELL_TYPE_COUNT ||
!IsPlayerClass(e.class_id) || !IsPlayerClass(e.class_id) ||
e.stance_index >= EQ::constants::STANCE_TYPE_COUNT e.stance_index >= Stance::AEBurn
) { ) {
continue; continue;
} }
@ -761,7 +761,7 @@ bool BotDatabase::LoadStance(Bot* b, bool& stance_flag)
auto e = l.front(); auto e = l.front();
b->SetBotStance(static_cast<EQ::constants::StanceType>(e.stance_id)); b->SetBotStance(e.stance_id);
stance_flag = true; stance_flag = true;
@ -793,7 +793,7 @@ bool BotDatabase::SaveStance(Bot* b)
database, database,
BotStancesRepository::BotStances{ BotStancesRepository::BotStances{
.bot_id = b->GetBotID(), .bot_id = b->GetBotID(),
.stance_id = static_cast<uint8_t>(b->GetBotStance()) .stance_id = b->GetBotStance()
} }
); );
} }
@ -2208,7 +2208,7 @@ uint8 BotDatabase::GetSpellCastingChance(uint8 spell_type_index, uint8 class_ind
if ( if (
spell_type_index >= Bot::SPELL_TYPE_COUNT || spell_type_index >= Bot::SPELL_TYPE_COUNT ||
class_index >= Class::PLAYER_CLASS_COUNT || class_index >= Class::PLAYER_CLASS_COUNT ||
stance_index >= EQ::constants::STANCE_TYPE_COUNT || stance_index >= Stance::AEBurn ||
conditional_index >= cntHSND conditional_index >= cntHSND
) { ) {
return 0; return 0;

View File

@ -629,16 +629,16 @@ bool Bot::BotCastCombatBuff(Mob* tar, uint8 botLevel, uint8 botClass) {
float manaRatioToCast = 75.0f; float manaRatioToCast = 75.0f;
switch(GetBotStance()) { switch(GetBotStance()) {
case EQ::constants::stanceEfficient: case Stance::Efficient:
manaRatioToCast = 90.0f; manaRatioToCast = 90.0f;
break; break;
case EQ::constants::stanceBalanced: case Stance::Balanced:
case EQ::constants::stanceAggressive: case Stance::Aggressive:
manaRatioToCast = 75.0f; manaRatioToCast = 75.0f;
break; break;
case EQ::constants::stanceReactive: case Stance::Reactive:
case EQ::constants::stanceBurn: case Stance::Burn:
case EQ::constants::stanceBurnAE: case Stance::AEBurn:
manaRatioToCast = 50.0f; manaRatioToCast = 50.0f;
break; break;
default: default:
@ -746,18 +746,18 @@ bool Bot::BotCastNuke(Mob* tar, uint8 botLevel, uint8 botClass, BotSpell& botSpe
float manaRatioToCast = 75.0f; float manaRatioToCast = 75.0f;
switch(GetBotStance()) { switch(GetBotStance()) {
case EQ::constants::stanceEfficient: case Stance::Efficient:
manaRatioToCast = 90.0f; manaRatioToCast = 90.0f;
break; break;
case EQ::constants::stanceBalanced: case Stance::Balanced:
manaRatioToCast = 75.0f; manaRatioToCast = 75.0f;
break; break;
case EQ::constants::stanceReactive: case Stance::Reactive:
case EQ::constants::stanceAggressive: case Stance::Aggressive:
manaRatioToCast = 50.0f; manaRatioToCast = 50.0f;
break; break;
case EQ::constants::stanceBurn: case Stance::Burn:
case EQ::constants::stanceBurnAE: case Stance::AEBurn:
manaRatioToCast = 25.0f; manaRatioToCast = 25.0f;
break; break;
default: default:
@ -924,16 +924,16 @@ bool Bot::BotCastBuff(Mob* tar, uint8 botLevel, uint8 botClass) {
float manaRatioToCast = 75.0f; float manaRatioToCast = 75.0f;
switch (GetBotStance()) { switch (GetBotStance()) {
case EQ::constants::stanceEfficient: case Stance::Efficient:
manaRatioToCast = 90.0f; manaRatioToCast = 90.0f;
break; break;
case EQ::constants::stanceBalanced: case Stance::Balanced:
case EQ::constants::stanceAggressive: case Stance::Aggressive:
manaRatioToCast = 75.0f; manaRatioToCast = 75.0f;
break; break;
case EQ::constants::stanceReactive: case Stance::Reactive:
case EQ::constants::stanceBurn: case Stance::Burn:
case EQ::constants::stanceBurnAE: case Stance::AEBurn:
manaRatioToCast = 50.0f; manaRatioToCast = 50.0f;
break; break;
default: default:
@ -1088,18 +1088,18 @@ bool Bot::BotCastHeal(Mob* tar, uint8 botLevel, uint8 botClass, BotSpell& botSpe
float hpRatioToCast = 0.0f; float hpRatioToCast = 0.0f;
switch (GetBotStance()) { switch (GetBotStance()) {
case EQ::constants::stanceEfficient: case Stance::Efficient:
case EQ::constants::stanceAggressive: case Stance::Aggressive:
hpRatioToCast = isPrimaryHealer ? 90.0f : 50.0f; hpRatioToCast = isPrimaryHealer ? 90.0f : 50.0f;
break; break;
case EQ::constants::stanceBalanced: case Stance::Balanced:
hpRatioToCast = isPrimaryHealer ? 95.0f : 75.0f; hpRatioToCast = isPrimaryHealer ? 95.0f : 75.0f;
break; break;
case EQ::constants::stanceReactive: case Stance::Reactive:
hpRatioToCast = isPrimaryHealer ? 100.0f : 90.0f; hpRatioToCast = isPrimaryHealer ? 100.0f : 90.0f;
break; break;
case EQ::constants::stanceBurn: case Stance::Burn:
case EQ::constants::stanceBurnAE: case Stance::AEBurn:
hpRatioToCast = isPrimaryHealer ? 75.0f : 25.0f; hpRatioToCast = isPrimaryHealer ? 75.0f : 25.0f;
break; break;
default: default:
@ -2939,11 +2939,12 @@ uint8 Bot::GetChanceToCastBySpellType(uint32 spellType)
return 0; return 0;
--class_index; --class_index;
EQ::constants::StanceType stance_type = GetBotStance(); uint32 stance_id = GetBotStance();
if (stance_type < EQ::constants::stancePassive || stance_type > EQ::constants::stanceBurnAE) if (!Stance::IsValid(stance_id)) {
return 0; return 0;
}
uint8 stance_index = EQ::constants::ConvertStanceTypeToIndex(stance_type); uint8 stance_index = Stance::GetIndex(stance_id);
uint8 type_index = nHSND; uint8 type_index = nHSND;
if (HasGroup()) { if (HasGroup()) {

View File

@ -10514,7 +10514,7 @@ void Client::Handle_OP_MercenaryCommand(const EQApplicationPacket *app)
//check to see if selected option is a valid stance slot (option is the slot the stance is in, not the actual stance) //check to see if selected option is a valid stance slot (option is the slot the stance is in, not the actual stance)
if (option >= 0 && option < numStances) if (option >= 0 && option < numStances)
{ {
merc->SetStance((EQ::constants::StanceType)mercTemplate->Stances[option]); merc->SetStance(mercTemplate->Stances[option]);
GetMercInfo().Stance = mercTemplate->Stances[option]; GetMercInfo().Stance = mercTemplate->Stances[option];
Log(Logs::General, Logs::Mercenaries, "Set Stance: %u for %s (%s)", merc->GetStance(), merc->GetName(), GetName()); Log(Logs::General, Logs::Mercenaries, "Set Stance: %u for %s (%s)", merc->GetStance(), merc->GetName(), GetName());

View File

@ -16,6 +16,7 @@
#include "find/race.cpp" #include "find/race.cpp"
#include "find/recipe.cpp" #include "find/recipe.cpp"
#include "find/skill.cpp" #include "find/skill.cpp"
#include "find/stance.cpp"
#include "find/spell.cpp" #include "find/spell.cpp"
#include "find/special_ability.cpp" #include "find/special_ability.cpp"
#include "find/task.cpp" #include "find/task.cpp"
@ -58,6 +59,7 @@ void command_find(Client *c, const Seperator *sep)
Cmd{.cmd = "recipe", .u = "recipe [Search Criteria]", .fn = FindRecipe, .a = {"#findrecipe"}}, Cmd{.cmd = "recipe", .u = "recipe [Search Criteria]", .fn = FindRecipe, .a = {"#findrecipe"}},
Cmd{.cmd = "skill", .u = "skill [Search Criteria]", .fn = FindSkill, .a = {"#findskill"}}, Cmd{.cmd = "skill", .u = "skill [Search Criteria]", .fn = FindSkill, .a = {"#findskill"}},
Cmd{.cmd = "special_ability", .u = "special_ability [Search Criteria]", .fn = FindSpecialAbility, .a = {"#fsa", "#findspecialability"}}, Cmd{.cmd = "special_ability", .u = "special_ability [Search Criteria]", .fn = FindSpecialAbility, .a = {"#fsa", "#findspecialability"}},
Cmd{.cmd = "stance", .u = "stance [Search Criteria]", .fn = FindStance, .a = {"#findstance"}},
Cmd{.cmd = "spell", .u = "spell [Search Criteria]", .fn = FindSpell, .a = {"#fs", "#findspell"}}, Cmd{.cmd = "spell", .u = "spell [Search Criteria]", .fn = FindSpell, .a = {"#fs", "#findspell"}},
Cmd{.cmd = "task", .u = "task [Search Criteria]", .fn = FindTask, .a = {"#findtask"}}, Cmd{.cmd = "task", .u = "task [Search Criteria]", .fn = FindTask, .a = {"#findtask"}},
Cmd{.cmd = "zone", .u = "zone [Search Criteria]", .fn = FindZone, .a = {"#fz", "#findzone"}}, Cmd{.cmd = "zone", .u = "zone [Search Criteria]", .fn = FindZone, .a = {"#fz", "#findzone"}},

View File

@ -0,0 +1,63 @@
#include "../../client.h"
void FindStance(Client *c, const Seperator *sep)
{
if (sep->IsNumber(2)) {
const uint8 stance_id = static_cast<uint8>(Strings::ToUnsignedInt(sep->arg[2]));
const std::string& stance_name = Stance::GetName(stance_id);
if (Strings::EqualFold(stance_name, "UNKNOWN STANCE")) {
c->Message(
Chat::White,
fmt::format(
"Stance ID {} does not exist.",
stance_id
).c_str()
);
return;
}
c->Message(
Chat::White,
fmt::format(
"Stance {} | {}",
stance_id,
stance_name
).c_str()
);
return;
}
const std::string& search_criteria = Strings::ToLower(sep->argplus[2]);
uint32 found_count = 0;
for (const auto& e : stance_names) {
const std::string& stance_name_lower = Strings::ToLower(e.second);
if (!Strings::Contains(stance_name_lower, search_criteria)) {
continue;
}
c->Message(
Chat::White,
fmt::format(
"Stance {} | {}",
e.first,
e.second
).c_str()
);
found_count++;
}
c->Message(
Chat::White,
fmt::format(
"{} Stance{} found matching '{}'.",
found_count,
found_count != 1 ? "s" : "",
sep->argplus[2]
).c_str()
);
}

View File

@ -58,7 +58,7 @@ Merc::Merc(const NPCType* d, float x, float y, float z, float heading)
memset(equipment, 0, sizeof(equipment)); memset(equipment, 0, sizeof(equipment));
SetMercID(0); SetMercID(0);
SetStance(EQ::constants::stanceBalanced); SetStance(Stance::Balanced);
rest_timer.Disable(); rest_timer.Disable();
if (GetClass() == Class::Rogue) if (GetClass() == Class::Rogue)
@ -3192,13 +3192,13 @@ MercSpell Merc::GetBestMercSpellForAENuke(Merc* caster, Mob* tar) {
switch(caster->GetStance()) switch(caster->GetStance())
{ {
case EQ::constants::stanceBurnAE: case Stance::AEBurn:
initialCastChance = 50; initialCastChance = 50;
break; break;
case EQ::constants::stanceBalanced: case Stance::Balanced:
initialCastChance = 25; initialCastChance = 25;
break; break;
case EQ::constants::stanceBurn: case Stance::Burn:
initialCastChance = 0; initialCastChance = 0;
break; break;
} }
@ -3244,11 +3244,11 @@ MercSpell Merc::GetBestMercSpellForTargetedAENuke(Merc* caster, Mob* tar) {
switch(caster->GetStance()) switch(caster->GetStance())
{ {
case EQ::constants::stanceBurnAE: case Stance::AEBurn:
numTargetsCheck = 1; numTargetsCheck = 1;
break; break;
case EQ::constants::stanceBalanced: case Stance::Balanced:
case EQ::constants::stanceBurn: case Stance::Burn:
numTargetsCheck = 2; numTargetsCheck = 2;
break; break;
} }
@ -3298,11 +3298,11 @@ MercSpell Merc::GetBestMercSpellForPBAENuke(Merc* caster, Mob* tar) {
switch(caster->GetStance()) switch(caster->GetStance())
{ {
case EQ::constants::stanceBurnAE: case Stance::AEBurn:
numTargetsCheck = 2; numTargetsCheck = 2;
break; break;
case EQ::constants::stanceBalanced: case Stance::Balanced:
case EQ::constants::stanceBurn: case Stance::Burn:
numTargetsCheck = 3; numTargetsCheck = 3;
break; break;
} }
@ -3351,11 +3351,11 @@ MercSpell Merc::GetBestMercSpellForAERainNuke(Merc* caster, Mob* tar) {
switch(caster->GetStance()) switch(caster->GetStance())
{ {
case EQ::constants::stanceBurnAE: case Stance::AEBurn:
numTargetsCheck = 1; numTargetsCheck = 1;
break; break;
case EQ::constants::stanceBalanced: case Stance::Balanced:
case EQ::constants::stanceBurn: case Stance::Burn:
numTargetsCheck = 2; numTargetsCheck = 2;
break; break;
} }
@ -5186,7 +5186,7 @@ void Client::SpawnMerc(Merc* merc, bool setMaxStats) {
merc->SetSuspended(false); merc->SetSuspended(false);
SetMerc(merc); SetMerc(merc);
merc->Unsuspend(setMaxStats); merc->Unsuspend(setMaxStats);
merc->SetStance((EQ::constants::StanceType)GetMercInfo().Stance); merc->SetStance(GetMercInfo().Stance);
Log(Logs::General, Logs::Mercenaries, "SpawnMerc Success for %s.", GetName()); Log(Logs::General, Logs::Mercenaries, "SpawnMerc Success for %s.", GetName());

View File

@ -162,7 +162,7 @@ public:
uint8 GetTierID() { return _TierID; } uint8 GetTierID() { return _TierID; }
uint32 GetCostFormula() { return _CostFormula; } uint32 GetCostFormula() { return _CostFormula; }
uint32 GetMercNameType() { return _NameType; } uint32 GetMercNameType() { return _NameType; }
EQ::constants::StanceType GetStance() { return _currentStance; } uint8 GetStance() { return _currentStance; }
int GetHatedCount() { return _hatedCount; } int GetHatedCount() { return _hatedCount; }
inline const uint8 GetClientVersion() const { return _OwnerClientVersion; } inline const uint8 GetClientVersion() const { return _OwnerClientVersion; }
@ -252,7 +252,7 @@ public:
void SetMercNameType( uint8 nametype ) { _NameType = nametype; } void SetMercNameType( uint8 nametype ) { _NameType = nametype; }
void SetClientVersion(uint8 clientVersion) { _OwnerClientVersion = clientVersion; } void SetClientVersion(uint8 clientVersion) { _OwnerClientVersion = clientVersion; }
void SetSuspended(bool suspended) { _suspended = suspended; } void SetSuspended(bool suspended) { _suspended = suspended; }
void SetStance( EQ::constants::StanceType stance ) { _currentStance = stance; } void SetStance(uint8 stance_id) { _currentStance = stance_id; }
void SetHatedCount( int count ) { _hatedCount = count; } void SetHatedCount( int count ) { _hatedCount = count; }
void Sit(); void Sit();
@ -364,7 +364,7 @@ private:
uint8 _CostFormula; uint8 _CostFormula;
uint8 _NameType; uint8 _NameType;
uint8 _OwnerClientVersion; uint8 _OwnerClientVersion;
EQ::constants::StanceType _currentStance; uint8 _currentStance;
EQ::InventoryProfile m_inv; EQ::InventoryProfile m_inv;
int64 max_end; int64 max_end;