mirror of
https://github.com/EQEmu/Server.git
synced 2026-05-31 04:56:20 +00:00
[Bots] Make expansion settings universal
Expansion Bitmask settings were saved by stances and should be universal for the bot. This addresses that as well as moves the data back to the `bot_data` table instead of the `bot_settings` table. This will check current settings saved and take the highest value of the stances to save to `bot_data`, if none are found (default), it will use the value from the rule `Bots:BotExpansionSettings`
This commit is contained in:
+2
-9
@@ -10395,9 +10395,6 @@ void Bot::SetBotSetting(uint8 setting_type, uint16 bot_setting, int setting_valu
|
||||
|
||||
void Bot::SetBotBaseSetting(uint16 bot_setting, int setting_value) {
|
||||
switch (bot_setting) {
|
||||
case BotBaseSettings::ExpansionBitmask:
|
||||
SetExpansionBitmask(setting_value);
|
||||
break;
|
||||
case BotBaseSettings::ShowHelm:
|
||||
SetShowHelm(setting_value);
|
||||
break;
|
||||
@@ -10444,8 +10441,6 @@ void Bot::SetBotBaseSetting(uint16 bot_setting, int setting_value) {
|
||||
|
||||
int Bot::GetBotBaseSetting(uint16 bot_setting) {
|
||||
switch (bot_setting) {
|
||||
case BotBaseSettings::ExpansionBitmask:
|
||||
return GetExpansionBitmask();
|
||||
case BotBaseSettings::ShowHelm:
|
||||
return GetShowHelm();
|
||||
case BotBaseSettings::FollowDistance:
|
||||
@@ -10481,8 +10476,6 @@ int Bot::GetBotBaseSetting(uint16 bot_setting) {
|
||||
|
||||
int Bot::GetDefaultBotBaseSetting(uint16 bot_setting, uint8 stance) {
|
||||
switch (bot_setting) {
|
||||
case BotBaseSettings::ExpansionBitmask:
|
||||
return RuleI(Bots, BotExpansionSettings);
|
||||
case BotBaseSettings::ShowHelm:
|
||||
return true;
|
||||
case BotBaseSettings::FollowDistance:
|
||||
@@ -10541,7 +10534,7 @@ void Bot::LoadDefaultBotSettings() {
|
||||
|
||||
uint8 bot_stance = GetBotStance();
|
||||
|
||||
for (uint16 i = BotBaseSettings::START_ALL; i <= BotBaseSettings::END; ++i) {
|
||||
for (uint16 i = BotBaseSettings::START; i <= BotBaseSettings::END; ++i) {
|
||||
SetBotBaseSetting(i, GetDefaultSetting(BotSettingCategories::BaseSetting, i, bot_stance));
|
||||
LogBotSettingsDetail("{} says, 'Setting default {} [{}] to [{}]'", GetCleanName(), GetBotSettingCategoryName(i), i, GetDefaultBotBaseSetting(i, bot_stance));
|
||||
}
|
||||
@@ -12925,7 +12918,7 @@ uint16 Bot::GetBotSpellCategoryIDByShortName(std::string setting_string) {
|
||||
}
|
||||
|
||||
bool Bot::IsValidBotBaseSetting(uint16 setting_type) {
|
||||
return EQ::ValueWithin(setting_type, BotBaseSettings::START_ALL, BotBaseSettings::END);
|
||||
return EQ::ValueWithin(setting_type, BotBaseSettings::START, BotBaseSettings::END);
|
||||
}
|
||||
|
||||
std::string Bot::GetBotSettingCategoryName(uint16 setting_type) {
|
||||
|
||||
+1
-4
@@ -159,7 +159,6 @@ namespace BotPriorityCategories {
|
||||
};
|
||||
|
||||
namespace BotBaseSettings {
|
||||
constexpr uint16 ExpansionBitmask = 0;
|
||||
constexpr uint16 ShowHelm = 1;
|
||||
constexpr uint16 FollowDistance = 2;
|
||||
constexpr uint16 StopMeleeLevel = 3;
|
||||
@@ -174,13 +173,11 @@ namespace BotBaseSettings {
|
||||
constexpr uint16 SitHPPct = 12;
|
||||
constexpr uint16 SitManaPct = 13;
|
||||
|
||||
constexpr uint16 START_ALL = ExpansionBitmask;
|
||||
constexpr uint16 START = BotBaseSettings::ShowHelm; // Everything above this cannot be copied, changed or viewed by players
|
||||
constexpr uint16 START = BotBaseSettings::ShowHelm;
|
||||
constexpr uint16 END = BotBaseSettings::SitManaPct; // Increment as needed
|
||||
};
|
||||
|
||||
static std::map<uint16, std::string> botBaseSettings_names = {
|
||||
{ BotBaseSettings::ExpansionBitmask, "ExpansionBitmask" },
|
||||
{ BotBaseSettings::ShowHelm, "ShowHelm" },
|
||||
{ BotBaseSettings::FollowDistance, "FollowDistance" },
|
||||
{ BotBaseSettings::StopMeleeLevel, "StopMeleeLevel" },
|
||||
|
||||
@@ -460,6 +460,7 @@ bool BotDatabase::LoadBot(const uint32 bot_id, Bot*& loaded_bot)
|
||||
loaded_bot->SetSurname(e.last_name);
|
||||
loaded_bot->SetTitle(e.title);
|
||||
loaded_bot->SetSuffix(e.suffix);
|
||||
loaded_bot->SetExpansionBitmask(e.expansion_bitmask);
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -514,6 +515,7 @@ bool BotDatabase::SaveNewBot(Bot* b, uint32& bot_id)
|
||||
e.poison = b->GetBasePR();
|
||||
e.disease = b->GetBaseDR();
|
||||
e.corruption = b->GetBaseCorrup();
|
||||
e.expansion_bitmask = b->GetExpansionBitmask();
|
||||
|
||||
e = BotDataRepository::InsertOne(database, e);
|
||||
|
||||
@@ -578,6 +580,7 @@ bool BotDatabase::SaveBot(Bot* b)
|
||||
e.poison = b->GetBasePR();
|
||||
e.disease = b->GetBaseDR();
|
||||
e.corruption = b->GetBaseCorrup();
|
||||
e.expansion_bitmask = b->GetExpansionBitmask();
|
||||
|
||||
return BotDataRepository::UpdateOne(database, e);
|
||||
}
|
||||
@@ -2351,7 +2354,7 @@ bool BotDatabase::SaveBotSettings(Mob* m)
|
||||
if (m->IsBot()) {
|
||||
uint8 bot_stance = m->CastToBot()->GetBotStance();
|
||||
|
||||
for (uint16 i = BotBaseSettings::START_ALL; i <= BotBaseSettings::END; ++i) {
|
||||
for (uint16 i = BotBaseSettings::START; i <= BotBaseSettings::END; ++i) {
|
||||
if (m->CastToBot()->GetBotBaseSetting(i) != m->CastToBot()->GetDefaultBotBaseSetting(i, bot_stance)) {
|
||||
auto e = BotSettingsRepository::BotSettings{
|
||||
.character_id = character_id,
|
||||
|
||||
Reference in New Issue
Block a user