mirror of
https://github.com/EQEmu/Server.git
synced 2026-08-29 16:58:02 +00:00
[Commands] [Hotfix] Fix Illusion Block (#4666)
* [Commands] [Hotfix] Fix Illusion Block This wasn't properly being set or saved if bots were not enabled, moved to extended character profile for players. * Move out of EPP * ValueWithin * I learned a new word today - idempotent I'm dumb. Will forget it tomorrow. * Move saving to ZoneDatabase, inline SetIllusionBlock
This commit is contained in:
@@ -2345,6 +2345,7 @@ bool BotDatabase::SaveBotSettings(Mob* m)
|
||||
}
|
||||
|
||||
if (m->IsClient()) {
|
||||
/* Currently unused
|
||||
if (m->CastToClient()->GetDefaultBotSettings(BotSettingCategories::BaseSetting, BotBaseSettings::IllusionBlock) != m->CastToClient()->GetIllusionBlock()) { // Only illusion block supported
|
||||
auto e = BotSettingsRepository::BotSettings{
|
||||
.character_id = character_id,
|
||||
@@ -2361,6 +2362,7 @@ bool BotDatabase::SaveBotSettings(Mob* m)
|
||||
|
||||
LogBotSettings("{} says, 'Saving {} [{}] - set to [{}] default [{}].'", m->GetCleanName(), Bot::GetBotSettingCategoryName(BotBaseSettings::IllusionBlock), BotBaseSettings::IllusionBlock, e.value, m->CastToClient()->GetIllusionBlock());
|
||||
}
|
||||
*/
|
||||
|
||||
for (uint16 i = BotSettingCategories::START_CLIENT; i <= BotSettingCategories::END_CLIENT; ++i) {
|
||||
for (uint16 x = BotSpellTypes::START; x <= BotSpellTypes::END; ++x) {
|
||||
|
||||
+1
-1
@@ -13596,4 +13596,4 @@ void Client::CheckItemDiscoverability(uint32 item_id)
|
||||
}
|
||||
|
||||
DiscoverItem(item_id);
|
||||
}
|
||||
}
|
||||
+3
-3
@@ -2346,8 +2346,8 @@ public:
|
||||
inline bool SpellTypeRecastCheck(uint16 spellType) { return !m_bot_spell_settings[spellType].recast_timer.GetRemainingTime(); }
|
||||
void SetSpellTypeRecastTimer(uint16 spell_type, uint32 recast_time) { m_bot_spell_settings[spell_type].recast_timer.Start(recast_time); }
|
||||
|
||||
void SetIllusionBlock(bool value) { _illusionBlock = value; }
|
||||
bool GetIllusionBlock() const override { return _illusionBlock; }
|
||||
void SetIllusionBlock(bool value) { _illusion_block = value; }
|
||||
bool GetIllusionBlock() const override { return _illusion_block; }
|
||||
|
||||
private:
|
||||
bool bot_owner_options[_booCount];
|
||||
@@ -2355,7 +2355,7 @@ private:
|
||||
bool m_bot_precombat;
|
||||
uint32 bot_assistee;
|
||||
std::vector<BotSpellSettings> m_bot_spell_settings;
|
||||
bool _illusionBlock;
|
||||
bool _illusion_block;
|
||||
|
||||
bool CanTradeFVNoDropItem();
|
||||
void SendMobPositions();
|
||||
|
||||
+4
-4
@@ -223,9 +223,10 @@ void Client::CampAllBots(uint8 class_id) {
|
||||
void Client::LoadDefaultBotSettings() {
|
||||
m_bot_spell_settings.clear();
|
||||
|
||||
// Only illusion block supported currently
|
||||
/* No longer used, left as example.
|
||||
SetBotSetting(BotSettingCategories::BaseSetting, BotBaseSettings::IllusionBlock, GetDefaultBotSettings(BotSettingCategories::BaseSetting, BotBaseSettings::IllusionBlock));
|
||||
LogBotSettingsDetail("{} says, 'Setting default {} [{}] to [{}]'", GetCleanName(), CastToBot()->GetBotSettingCategoryName(BotBaseSettings::IllusionBlock), BotBaseSettings::IllusionBlock, GetDefaultBotSettings(BotSettingCategories::BaseSetting, BotBaseSettings::IllusionBlock));
|
||||
*/
|
||||
|
||||
for (uint16 i = BotSpellTypes::START; i <= BotSpellTypes::END; ++i) {
|
||||
BotSpellSettings t;
|
||||
@@ -263,7 +264,7 @@ int Client::GetDefaultBotSettings(uint8 setting_type, uint16 bot_setting) {
|
||||
int Client::GetBotSetting(uint8 setting_type, uint16 bot_setting) {
|
||||
switch (setting_type) {
|
||||
case BotSettingCategories::BaseSetting:
|
||||
return GetIllusionBlock(); // only setting supported currently
|
||||
return 0; // unused currently
|
||||
case BotSettingCategories::SpellDelay:
|
||||
return GetSpellTypeDelay(bot_setting);
|
||||
case BotSettingCategories::SpellMinThreshold:
|
||||
@@ -276,8 +277,7 @@ int Client::GetBotSetting(uint8 setting_type, uint16 bot_setting) {
|
||||
void Client::SetBotSetting(uint8 setting_type, uint16 bot_setting, uint32 setting_value) {
|
||||
switch (setting_type) {
|
||||
case BotSettingCategories::BaseSetting:
|
||||
SetIllusionBlock(setting_value); // only setting supported currently
|
||||
break;
|
||||
break; // unused currently
|
||||
case BotSettingCategories::SpellDelay:
|
||||
SetSpellTypeDelay(bot_setting, setting_value);
|
||||
break;
|
||||
|
||||
@@ -1299,7 +1299,7 @@ void Client::Handle_Connect_OP_ZoneEntry(const EQApplicationPacket *app)
|
||||
|
||||
/* Load Character Data */
|
||||
query = fmt::format(
|
||||
"SELECT `lfp`, `lfg`, `xtargets`, `firstlogon`, `guild_id`, `rank`, `exp_enabled`, `tribute_enable`, `extra_haste` FROM `character_data` LEFT JOIN `guild_members` ON `id` = `char_id` WHERE `id` = {}",
|
||||
"SELECT `lfp`, `lfg`, `xtargets`, `firstlogon`, `guild_id`, `rank`, `exp_enabled`, `tribute_enable`, `extra_haste`, `illusion_block` FROM `character_data` LEFT JOIN `guild_members` ON `id` = `char_id` WHERE `id` = {}",
|
||||
cid
|
||||
);
|
||||
auto results = database.QueryDatabase(query);
|
||||
@@ -1312,6 +1312,7 @@ void Client::Handle_Connect_OP_ZoneEntry(const EQApplicationPacket *app)
|
||||
|
||||
SetEXPEnabled(Strings::ToBool(row[6]));
|
||||
SetExtraHaste(Strings::ToInt(row[8]), false);
|
||||
SetIllusionBlock(Strings::ToBool(row[9]));
|
||||
|
||||
if (LFP) { LFP = Strings::ToInt(row[0]); }
|
||||
if (LFG) { LFG = Strings::ToInt(row[1]); }
|
||||
|
||||
@@ -7,6 +7,10 @@ void command_illusion_block(Client* c, const Seperator* sep)
|
||||
BotCommandHelpParams p;
|
||||
|
||||
p.description = { "Toggles whether or not you will block the illusion effects of spells cast by players or bots." };
|
||||
p.notes = {
|
||||
"- This will still allow other portions of a spell to land on you.",
|
||||
"- Spells cast by NPCs will ignore this setting and land as normal."
|
||||
};
|
||||
p.example_format = { fmt::format("{} [value]", sep->arg[0]) };
|
||||
p.examples_one =
|
||||
{
|
||||
@@ -35,7 +39,7 @@ void command_illusion_block(Client* c, const Seperator* sep)
|
||||
|
||||
if (sep->IsNumber(1)) {
|
||||
int set_status = atoi(sep->arg[1]);
|
||||
if (set_status == 0 || set_status == 1) {
|
||||
if (EQ::ValueWithin(set_status, 0, 1)) {
|
||||
c->SetIllusionBlock(set_status);
|
||||
c->Message(Chat::Green, "Your Illusion Block has been %s.", (set_status ? "enabled" : "disabled"));
|
||||
}
|
||||
|
||||
@@ -1158,6 +1158,7 @@ bool ZoneDatabase::SaveCharacterData(
|
||||
e.e_expended_aa_spent = m_epp->expended_aa;
|
||||
e.e_last_invsnapshot = m_epp->last_invsnapshot_time;
|
||||
e.mailkey = c->GetMailKeyFull();
|
||||
e.illusion_block = c->GetIllusionBlock();
|
||||
|
||||
const int replaced = CharacterDataRepository::ReplaceOne(database, e);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user