mirror of
https://github.com/EQEmu/Server.git
synced 2026-05-16 18:52:22 +00:00
[Bots] Save Bot Toggle Archer Setting between Loads. (#2612)
* [Bots] Save Bot Toggle Archer Setting between Loads. * [Bots] Save Bot Toggle Archer Setting between Loads. * Typo
This commit is contained in:
+20
-4
@@ -72,7 +72,6 @@ Bot::Bot(NPCType *npcTypeData, Client* botOwner) : NPC(npcTypeData, nullptr, glm
|
||||
SetBotID(0);
|
||||
SetBotSpellID(0);
|
||||
SetSpawnStatus(false);
|
||||
SetBotArcher(false);
|
||||
SetBotCharmer(false);
|
||||
SetPetChooser(false);
|
||||
SetRangerAutoWeaponSelect(false);
|
||||
@@ -167,7 +166,6 @@ Bot::Bot(uint32 botID, uint32 botOwnerCharacterID, uint32 botSpellsID, double to
|
||||
SetBotID(botID);
|
||||
SetBotSpellID(botSpellsID);
|
||||
SetSpawnStatus(false);
|
||||
SetBotArcher(false);
|
||||
SetBotCharmer(false);
|
||||
SetPetChooser(false);
|
||||
SetRangerAutoWeaponSelect(false);
|
||||
@@ -3164,12 +3162,12 @@ void Bot::AI_Process()
|
||||
|
||||
if (atArcheryRange && !IsBotArcher()) {
|
||||
|
||||
SetBotArcher(true);
|
||||
SetBotArcherySetting(true);
|
||||
changeWeapons = true;
|
||||
}
|
||||
else if (!atArcheryRange && IsBotArcher()) {
|
||||
|
||||
SetBotArcher(false);
|
||||
SetBotArcherySetting(false);
|
||||
changeWeapons = true;
|
||||
}
|
||||
|
||||
@@ -10867,6 +10865,24 @@ std::string Bot::GetHPString(int8 min_hp, int8 max_hp)
|
||||
return hp_string;
|
||||
}
|
||||
|
||||
void Bot::SetBotArcherySetting(bool bot_archer_setting, bool save)
|
||||
{
|
||||
m_bot_archery_setting = bot_archer_setting;
|
||||
if (save) {
|
||||
if (!database.botdb.SaveBotArcherSetting(GetBotID(), bot_archer_setting)) {
|
||||
if (GetBotOwner() && GetBotOwner()->IsClient()) {
|
||||
GetBotOwner()->CastToClient()->Message(
|
||||
Chat::White,
|
||||
fmt::format(
|
||||
"Failed to save archery settings for {}.",
|
||||
GetCleanName()
|
||||
).c_str()
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
uint8 Bot::spell_casting_chances[SPELL_TYPE_COUNT][PLAYER_CLASS_COUNT][EQ::constants::STANCE_TYPE_COUNT][cntHSND] = { 0 };
|
||||
|
||||
#endif
|
||||
|
||||
+3
-3
@@ -468,7 +468,7 @@ public:
|
||||
virtual bool GetSpawnStatus() { return _spawnStatus; }
|
||||
uint8 GetPetChooserID() { return _petChooserID; }
|
||||
bool IsPetChooser() { return _petChooser; }
|
||||
bool IsBotArcher() { return _botArcher; }
|
||||
bool IsBotArcher() { return m_bot_archery_setting; }
|
||||
bool IsBotCharmer() { return _botCharmer; }
|
||||
virtual bool IsBot() const { return true; }
|
||||
bool GetRangerAutoWeaponSelect() { return _rangerAutoWeaponSelect; }
|
||||
@@ -586,7 +586,7 @@ public:
|
||||
void SetBotSpellID(uint32 newSpellID);
|
||||
virtual void SetSpawnStatus(bool spawnStatus) { _spawnStatus = spawnStatus; }
|
||||
void SetPetChooserID(uint8 id) { _petChooserID = id; }
|
||||
void SetBotArcher(bool a) { _botArcher = a; }
|
||||
void SetBotArcherySetting(bool bot_archer_setting, bool save = false);
|
||||
void SetBotCharmer(bool c) { _botCharmer = c; }
|
||||
void SetPetChooser(bool p) { _petChooser = p; }
|
||||
void SetBotOwner(Mob* botOwner) { this->_botOwner = botOwner; }
|
||||
@@ -753,7 +753,7 @@ private:
|
||||
bool _spawnStatus;
|
||||
Mob* _botOwner;
|
||||
bool _botOrderAttack;
|
||||
bool _botArcher;
|
||||
bool m_bot_archery_setting;
|
||||
bool _botCharmer;
|
||||
bool _petChooser;
|
||||
uint8 _petChooserID;
|
||||
|
||||
+16
-12
@@ -6942,8 +6942,9 @@ void bot_subcommand_bot_tattoo(Client *c, const Seperator *sep)
|
||||
|
||||
void bot_subcommand_bot_toggle_archer(Client *c, const Seperator *sep)
|
||||
{
|
||||
if (helper_command_alias_fail(c, "bot_subcommand_bot_toggle_archer", sep->arg[0], "bottogglearcher"))
|
||||
if (helper_command_alias_fail(c, "bot_subcommand_bot_toggle_archer", sep->arg[0], "bottogglearcher")) {
|
||||
return;
|
||||
}
|
||||
if (helper_is_help_or_usage(sep->arg[1])) {
|
||||
c->Message(Chat::White, "usage: %s ([option: on | off]) ([actionable: target | byname] ([actionable_name]))", sep->arg[0]);
|
||||
return;
|
||||
@@ -6966,21 +6967,26 @@ void bot_subcommand_bot_toggle_archer(Client *c, const Seperator *sep)
|
||||
}
|
||||
|
||||
std::list<Bot*> sbl;
|
||||
if (ActionableBots::PopulateSBL(c, sep->arg[ab_arg], sbl, ab_mask, sep->arg[(ab_arg + 1)]) == ActionableBots::ABT_None)
|
||||
if (ActionableBots::PopulateSBL(c, sep->arg[ab_arg], sbl, ab_mask, sep->arg[(ab_arg + 1)]) == ActionableBots::ABT_None) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (auto bot_iter : sbl) {
|
||||
if (!bot_iter)
|
||||
if (!bot_iter) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (toggle_archer)
|
||||
bot_iter->SetBotArcher(!bot_iter->IsBotArcher());
|
||||
else
|
||||
bot_iter->SetBotArcher(archer_state);
|
||||
if (toggle_archer) {
|
||||
bot_iter->SetBotArcherySetting(!bot_iter->IsBotArcher(), true);
|
||||
}
|
||||
else {
|
||||
bot_iter->SetBotArcherySetting(archer_state, true);
|
||||
}
|
||||
bot_iter->ChangeBotArcherWeapons(bot_iter->IsBotArcher());
|
||||
|
||||
if (bot_iter->GetClass() == RANGER && bot_iter->GetLevel() >= 61)
|
||||
if (bot_iter->GetClass() == RANGER && bot_iter->GetLevel() >= 61) {
|
||||
bot_iter->SetRangerAutoWeaponSelect(bot_iter->IsBotArcher());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9368,11 +9374,9 @@ void bot_subcommand_inventory_remove(Client *c, const Seperator *sep)
|
||||
c->PushItemOnCursor(*inst, true);
|
||||
if (
|
||||
slot_id == EQ::invslot::slotRange ||
|
||||
slot_id == EQ::invslot::slotAmmo ||
|
||||
slot_id == EQ::invslot::slotPrimary ||
|
||||
slot_id == EQ::invslot::slotSecondary
|
||||
slot_id == EQ::invslot::slotAmmo
|
||||
) {
|
||||
my_bot->SetBotArcher(false);
|
||||
my_bot->SetBotArcherySetting(false, true);
|
||||
}
|
||||
|
||||
my_bot->RemoveBotItemBySlot(slot_id, &error_message);
|
||||
|
||||
+25
-1
@@ -410,7 +410,8 @@ bool BotDatabase::LoadBot(const uint32 bot_id, Bot*& loaded_bot)
|
||||
" `follow_distance`," // 26
|
||||
" `stop_melee_level`," // 27
|
||||
" `expansion_bitmask`," // 28
|
||||
" `enforce_spell_settings`" // 29
|
||||
" `enforce_spell_settings`," // 29
|
||||
" `archery_setting`" // 30
|
||||
" FROM `bot_data`"
|
||||
" WHERE `bot_id` = {}"
|
||||
" LIMIT 1",
|
||||
@@ -511,6 +512,8 @@ bool BotDatabase::LoadBot(const uint32 bot_id, Bot*& loaded_bot)
|
||||
loaded_bot->SetExpansionBitmask(eb, false);
|
||||
|
||||
loaded_bot->SetBotEnforceSpellSetting((std::stoi(row[29]) > 0 ? true : false));
|
||||
|
||||
loaded_bot->SetBotArcherySetting((std::stoi(row[30]) > 0 ? true : false));
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -3302,6 +3305,27 @@ bool BotDatabase::SaveEnforceSpellSetting(const uint32 bot_id, const bool enforc
|
||||
return true;
|
||||
}
|
||||
|
||||
bool BotDatabase::SaveBotArcherSetting(const uint32 bot_id, const bool bot_archer_setting)
|
||||
{
|
||||
if (!bot_id) {
|
||||
return false;
|
||||
}
|
||||
|
||||
query = fmt::format(
|
||||
"UPDATE `bot_data`"
|
||||
"SET `archery_setting` = {} "
|
||||
"WHERE `bot_id` = {}",
|
||||
(bot_archer_setting ? 1 : 0),
|
||||
bot_id
|
||||
);
|
||||
auto results = database.QueryDatabase(query);
|
||||
if (!results.Success()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/* fail::Bot functions */
|
||||
const char* BotDatabase::fail::LoadBotsList() { return "Failed to bots list"; }
|
||||
const char* BotDatabase::fail::LoadOwnerID() { return "Failed to load owner ID"; }
|
||||
|
||||
@@ -144,6 +144,8 @@ public:
|
||||
|
||||
bool SaveStopMeleeLevel(const uint32 owner_id, const uint32 bot_id, const uint8 sml_value);
|
||||
|
||||
bool SaveBotArcherSetting(const uint32 bot_id, const bool bot_archer_setting);
|
||||
|
||||
bool LoadOwnerOptions(Client *owner);
|
||||
bool SaveOwnerOption(const uint32 owner_id, size_t type, const bool flag);
|
||||
bool SaveOwnerOption(const uint32 owner_id, const std::pair<size_t, size_t> type, const std::pair<bool, bool> flag);
|
||||
|
||||
Reference in New Issue
Block a user