From 3ec500244e558325f4af28cd84feb183e069203b Mon Sep 17 00:00:00 2001 From: kentai Date: Tue, 12 Mar 2019 19:21:30 +1100 Subject: [PATCH 1/4] Added bot commands ^bottitle, ^botsuffix --- changelog.txt | 7 ++++- zone/bot.cpp | 4 ++- zone/bot.h | 7 +++++ zone/bot_command.cpp | 64 +++++++++++++++++++++++++++++++++++++++++++ zone/bot_command.h | 2 ++ zone/bot_database.cpp | 9 ++++-- 6 files changed, 89 insertions(+), 4 deletions(-) diff --git a/changelog.txt b/changelog.txt index 2ea309812..3535cb982 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,6 +1,11 @@ EQEMu Changelog (Started on Sept 24, 2003 15:50) ------------------------------------------------------- - +== 3/12/2019 == +KentaiVZ: Added two new bot commands to make use of the already present database fields. + + - ^bottitle - Gives targeted bot a custom title ( I.E Pathfinder ) + - ^botsuffix - Gives targeted bot a custom suffix ( I.E of The Grand Creation ) + == 3/1/2019 == Noudess: Major faction conversion to use client data. diff --git a/zone/bot.cpp b/zone/bot.cpp index b221620e2..c726aa841 100644 --- a/zone/bot.cpp +++ b/zone/bot.cpp @@ -3259,7 +3259,7 @@ bool Bot::Spawn(Client* botCharacterOwner) { else this->GetBotOwner()->CastToClient()->Message(13, "%s save failed!", this->GetCleanName()); - // Spawn the bot at the bow owner's loc + // Spawn the bot at the bot owner's loc this->m_Position.x = botCharacterOwner->GetX(); this->m_Position.y = botCharacterOwner->GetY(); this->m_Position.z = botCharacterOwner->GetZ(); @@ -3364,6 +3364,8 @@ void Bot::FillSpawnStruct(NewSpawn_Struct* ns, Mob* ForWho) { ns->spawn.helm = helmtexture; //(GetShowHelm() ? helmtexture : 0); //0xFF; ns->spawn.equip_chest2 = texture; //0xFF; ns->spawn.show_name = true; + strcpy(ns->spawn.title, GetTitle().c_str()); + strcpy(ns->spawn.suffix, GetSuffix().c_str()); const EQEmu::ItemData* item = nullptr; const EQEmu::ItemInstance* inst = nullptr; uint32 spawnedbotid = 0; diff --git a/zone/bot.h b/zone/bot.h index 602b2912d..a70b32cc5 100644 --- a/zone/bot.h +++ b/zone/bot.h @@ -272,6 +272,11 @@ public: bool HasOrMayGetAggro(); void SetDefaultBotStance(); + void setTitle(std::string bot_title) { title = bot_title; } + void setSuffix(std::string bot_suffix) { suffix = bot_suffix; } + std::string GetTitle() { return title; } + std::string GetSuffix() { return suffix; } + inline virtual int32 GetMaxStat(); inline virtual int32 GetMaxResist(); inline virtual int32 GetMaxSTR(); @@ -651,6 +656,8 @@ private: uint32 _guildId; uint8 _guildRank; std::string _guildName; + std::string title; + std::string suffix; uint32 _lastZoneId; bool _rangerAutoWeaponSelect; BotRoleType _botRole; diff --git a/zone/bot_command.cpp b/zone/bot_command.cpp index 085a730ea..b0aa9ae29 100644 --- a/zone/bot_command.cpp +++ b/zone/bot_command.cpp @@ -1352,6 +1352,8 @@ int bot_command_init(void) bot_command_add("botstopmeleelevel", "Sets the level a caster or spell-casting fighter bot will stop melee combat", 0, bot_subcommand_bot_stop_melee_level) || bot_command_add("botsummon", "Summons bot(s) to your location", 0, bot_subcommand_bot_summon) || bot_command_add("bottattoo", "Changes the Drakkin tattoo of a bot", 0, bot_subcommand_bot_tattoo) || + bot_command_add("bottitle", "For changing the bot title", 0, bot_subcommand_bot_title) || + bot_command_add("botsuffix", "For changing the bot suffix", 0, bot_subcommand_bot_suffix) || bot_command_add("bottogglearcher", "Toggles a archer bot between melee and ranged weapon use", 0, bot_subcommand_bot_toggle_archer) || bot_command_add("bottogglehelm", "Toggles the helm visibility of a bot between shown and hidden", 0, bot_subcommand_bot_toggle_helm) || bot_command_add("botupdate", "Updates a bot to reflect any level changes that you have experienced", 0, bot_subcommand_bot_update) || @@ -5540,6 +5542,68 @@ void bot_subcommand_bot_update(Client *c, const Seperator *sep) c->Message(m_action, "Updated %i of your %i spawned bots", bot_count, sbl.size()); } +void bot_subcommand_bot_title(Client *c, const Seperator *sep) +{ + if (sep->arg[1][0] == '\0' || sep->IsNumber(1)) { + c->Message(m_fail, "You must specify a [title] to use this command"); + return; + } + auto my_bot = ActionableBots::AsTarget_ByBot(c); + if (!my_bot) { + c->Message(m_fail, "You must a bot that you own to use this command"); + return; + } + + if (strlen(sep->arg[1]) > 31) { + c->Message(13, "Title must be 31 characters or less."); + return; + } + + std::string bot_title = sep->arg[1]; + + my_bot->setTitle(bot_title); + if (!botdb.SaveBot(my_bot)) { + c->Message(m_fail, BotDatabase::fail::SaveBot()); + return; + } + else { + my_bot->CastToClient()->SetAATitle(bot_title.c_str()); + c->Message(m_action, "Bot Saved."); + } +} + +void bot_subcommand_bot_suffix(Client *c, const Seperator *sep) +{ + if (sep->arg[1][0] == '\0' || sep->IsNumber(1)) { + c->Message(m_fail, "You must specify a [suffix] to use this command (use underscores for any spaces)"); + return; + } + auto my_bot = ActionableBots::AsTarget_ByBot(c); + if (!my_bot) { + c->Message(m_fail, "You must a bot that you own to use this command"); + return; + } + + if (strlen(sep->arg[1]) > 31) { + c->Message(13, "Suffix must be 31 characters or less."); + return; + } + + std::string bot_suffix = sep->arg[1]; + std::replace(bot_suffix.begin(), bot_suffix.end(), '_', ' '); + bot_suffix = bot_suffix.substr(0, 31); + my_bot->setSuffix(bot_suffix); + + if (!botdb.SaveBot(my_bot)) { + c->Message(m_fail, BotDatabase::fail::SaveBot()); + return; + } + else { + my_bot->CastToClient()->SetTitleSuffix(bot_suffix.c_str()); + c->Message(m_action, "Bot Saved."); + } +} + void bot_subcommand_bot_woad(Client *c, const Seperator *sep) { if (helper_command_alias_fail(c, "bot_subcommand_bot_woad", sep->arg[0], "botwoad")) diff --git a/zone/bot_command.h b/zone/bot_command.h index 603852b38..3cad47523 100644 --- a/zone/bot_command.h +++ b/zone/bot_command.h @@ -593,6 +593,8 @@ void bot_command_water_breathing(Client *c, const Seperator *sep); // bot subcommands void bot_subcommand_bot_appearance(Client *c, const Seperator *sep); +void bot_subcommand_bot_title(Client *c, const Seperator *sep); +void bot_subcommand_bot_suffix(Client *c, const Seperator *sep); void bot_subcommand_bot_beard_color(Client *c, const Seperator *sep); void bot_subcommand_bot_beard_style(Client *c, const Seperator *sep); void bot_subcommand_bot_camp(Client *c, const Seperator *sep); diff --git a/zone/bot_database.cpp b/zone/bot_database.cpp index ea5154598..0d4c72a23 100644 --- a/zone/bot_database.cpp +++ b/zone/bot_database.cpp @@ -395,7 +395,8 @@ bool BotDatabase::LoadBot(const uint32 bot_id, Bot*& loaded_bot) loaded_bot = new Bot(bot_id, atoi(row[0]), atoi(row[1]), atof(row[14]), atoi(row[6]), tempNPCStruct); if (loaded_bot) { loaded_bot->SetShowHelm((atoi(row[43]) > 0 ? true : false)); - + loaded_bot->setTitle(row[4]); + loaded_bot->setSuffix(row[5]); uint32 bfd = atoi(row[44]); if (bfd < 1) bfd = 1; @@ -604,7 +605,9 @@ bool BotDatabase::SaveBot(Bot* bot_inst) " `corruption` = '%i'," " `show_helm` = '%i'," " `follow_distance` = '%i'," - " `stop_melee_level` = '%u'" + " `stop_melee_level` = '%u'," + " `title` = '%s'," + " `suffix` = '%s'" " WHERE `bot_id` = '%u'", bot_inst->GetBotOwnerCharacterID(), bot_inst->GetBotSpellID(), @@ -647,6 +650,8 @@ bool BotDatabase::SaveBot(Bot* bot_inst) ((bot_inst->GetShowHelm()) ? (1) : (0)), bot_inst->GetFollowDistance(), bot_inst->GetStopMeleeLevel(), + bot_inst->GetTitle().c_str(), + bot_inst->GetSuffix().c_str(), bot_inst->GetBotID() ); auto results = QueryDatabase(query); From b2dd3df1e2017774a6612a9074b6e7a4e8776db7 Mon Sep 17 00:00:00 2001 From: kentai Date: Sat, 16 Mar 2019 17:16:49 +1100 Subject: [PATCH 2/4] Revert "Added bot commands" This reverts commit 3ec500244e558325f4af28cd84feb183e069203b. --- changelog.txt | 7 +---- zone/bot.cpp | 4 +-- zone/bot.h | 7 ----- zone/bot_command.cpp | 64 ------------------------------------------- zone/bot_command.h | 2 -- zone/bot_database.cpp | 9 ++---- 6 files changed, 4 insertions(+), 89 deletions(-) diff --git a/changelog.txt b/changelog.txt index 3535cb982..2ea309812 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,11 +1,6 @@ EQEMu Changelog (Started on Sept 24, 2003 15:50) ------------------------------------------------------- -== 3/12/2019 == -KentaiVZ: Added two new bot commands to make use of the already present database fields. - - - ^bottitle - Gives targeted bot a custom title ( I.E Pathfinder ) - - ^botsuffix - Gives targeted bot a custom suffix ( I.E of The Grand Creation ) - + == 3/1/2019 == Noudess: Major faction conversion to use client data. diff --git a/zone/bot.cpp b/zone/bot.cpp index c726aa841..b221620e2 100644 --- a/zone/bot.cpp +++ b/zone/bot.cpp @@ -3259,7 +3259,7 @@ bool Bot::Spawn(Client* botCharacterOwner) { else this->GetBotOwner()->CastToClient()->Message(13, "%s save failed!", this->GetCleanName()); - // Spawn the bot at the bot owner's loc + // Spawn the bot at the bow owner's loc this->m_Position.x = botCharacterOwner->GetX(); this->m_Position.y = botCharacterOwner->GetY(); this->m_Position.z = botCharacterOwner->GetZ(); @@ -3364,8 +3364,6 @@ void Bot::FillSpawnStruct(NewSpawn_Struct* ns, Mob* ForWho) { ns->spawn.helm = helmtexture; //(GetShowHelm() ? helmtexture : 0); //0xFF; ns->spawn.equip_chest2 = texture; //0xFF; ns->spawn.show_name = true; - strcpy(ns->spawn.title, GetTitle().c_str()); - strcpy(ns->spawn.suffix, GetSuffix().c_str()); const EQEmu::ItemData* item = nullptr; const EQEmu::ItemInstance* inst = nullptr; uint32 spawnedbotid = 0; diff --git a/zone/bot.h b/zone/bot.h index a70b32cc5..602b2912d 100644 --- a/zone/bot.h +++ b/zone/bot.h @@ -272,11 +272,6 @@ public: bool HasOrMayGetAggro(); void SetDefaultBotStance(); - void setTitle(std::string bot_title) { title = bot_title; } - void setSuffix(std::string bot_suffix) { suffix = bot_suffix; } - std::string GetTitle() { return title; } - std::string GetSuffix() { return suffix; } - inline virtual int32 GetMaxStat(); inline virtual int32 GetMaxResist(); inline virtual int32 GetMaxSTR(); @@ -656,8 +651,6 @@ private: uint32 _guildId; uint8 _guildRank; std::string _guildName; - std::string title; - std::string suffix; uint32 _lastZoneId; bool _rangerAutoWeaponSelect; BotRoleType _botRole; diff --git a/zone/bot_command.cpp b/zone/bot_command.cpp index b0aa9ae29..085a730ea 100644 --- a/zone/bot_command.cpp +++ b/zone/bot_command.cpp @@ -1352,8 +1352,6 @@ int bot_command_init(void) bot_command_add("botstopmeleelevel", "Sets the level a caster or spell-casting fighter bot will stop melee combat", 0, bot_subcommand_bot_stop_melee_level) || bot_command_add("botsummon", "Summons bot(s) to your location", 0, bot_subcommand_bot_summon) || bot_command_add("bottattoo", "Changes the Drakkin tattoo of a bot", 0, bot_subcommand_bot_tattoo) || - bot_command_add("bottitle", "For changing the bot title", 0, bot_subcommand_bot_title) || - bot_command_add("botsuffix", "For changing the bot suffix", 0, bot_subcommand_bot_suffix) || bot_command_add("bottogglearcher", "Toggles a archer bot between melee and ranged weapon use", 0, bot_subcommand_bot_toggle_archer) || bot_command_add("bottogglehelm", "Toggles the helm visibility of a bot between shown and hidden", 0, bot_subcommand_bot_toggle_helm) || bot_command_add("botupdate", "Updates a bot to reflect any level changes that you have experienced", 0, bot_subcommand_bot_update) || @@ -5542,68 +5540,6 @@ void bot_subcommand_bot_update(Client *c, const Seperator *sep) c->Message(m_action, "Updated %i of your %i spawned bots", bot_count, sbl.size()); } -void bot_subcommand_bot_title(Client *c, const Seperator *sep) -{ - if (sep->arg[1][0] == '\0' || sep->IsNumber(1)) { - c->Message(m_fail, "You must specify a [title] to use this command"); - return; - } - auto my_bot = ActionableBots::AsTarget_ByBot(c); - if (!my_bot) { - c->Message(m_fail, "You must a bot that you own to use this command"); - return; - } - - if (strlen(sep->arg[1]) > 31) { - c->Message(13, "Title must be 31 characters or less."); - return; - } - - std::string bot_title = sep->arg[1]; - - my_bot->setTitle(bot_title); - if (!botdb.SaveBot(my_bot)) { - c->Message(m_fail, BotDatabase::fail::SaveBot()); - return; - } - else { - my_bot->CastToClient()->SetAATitle(bot_title.c_str()); - c->Message(m_action, "Bot Saved."); - } -} - -void bot_subcommand_bot_suffix(Client *c, const Seperator *sep) -{ - if (sep->arg[1][0] == '\0' || sep->IsNumber(1)) { - c->Message(m_fail, "You must specify a [suffix] to use this command (use underscores for any spaces)"); - return; - } - auto my_bot = ActionableBots::AsTarget_ByBot(c); - if (!my_bot) { - c->Message(m_fail, "You must a bot that you own to use this command"); - return; - } - - if (strlen(sep->arg[1]) > 31) { - c->Message(13, "Suffix must be 31 characters or less."); - return; - } - - std::string bot_suffix = sep->arg[1]; - std::replace(bot_suffix.begin(), bot_suffix.end(), '_', ' '); - bot_suffix = bot_suffix.substr(0, 31); - my_bot->setSuffix(bot_suffix); - - if (!botdb.SaveBot(my_bot)) { - c->Message(m_fail, BotDatabase::fail::SaveBot()); - return; - } - else { - my_bot->CastToClient()->SetTitleSuffix(bot_suffix.c_str()); - c->Message(m_action, "Bot Saved."); - } -} - void bot_subcommand_bot_woad(Client *c, const Seperator *sep) { if (helper_command_alias_fail(c, "bot_subcommand_bot_woad", sep->arg[0], "botwoad")) diff --git a/zone/bot_command.h b/zone/bot_command.h index 3cad47523..603852b38 100644 --- a/zone/bot_command.h +++ b/zone/bot_command.h @@ -593,8 +593,6 @@ void bot_command_water_breathing(Client *c, const Seperator *sep); // bot subcommands void bot_subcommand_bot_appearance(Client *c, const Seperator *sep); -void bot_subcommand_bot_title(Client *c, const Seperator *sep); -void bot_subcommand_bot_suffix(Client *c, const Seperator *sep); void bot_subcommand_bot_beard_color(Client *c, const Seperator *sep); void bot_subcommand_bot_beard_style(Client *c, const Seperator *sep); void bot_subcommand_bot_camp(Client *c, const Seperator *sep); diff --git a/zone/bot_database.cpp b/zone/bot_database.cpp index 0d4c72a23..ea5154598 100644 --- a/zone/bot_database.cpp +++ b/zone/bot_database.cpp @@ -395,8 +395,7 @@ bool BotDatabase::LoadBot(const uint32 bot_id, Bot*& loaded_bot) loaded_bot = new Bot(bot_id, atoi(row[0]), atoi(row[1]), atof(row[14]), atoi(row[6]), tempNPCStruct); if (loaded_bot) { loaded_bot->SetShowHelm((atoi(row[43]) > 0 ? true : false)); - loaded_bot->setTitle(row[4]); - loaded_bot->setSuffix(row[5]); + uint32 bfd = atoi(row[44]); if (bfd < 1) bfd = 1; @@ -605,9 +604,7 @@ bool BotDatabase::SaveBot(Bot* bot_inst) " `corruption` = '%i'," " `show_helm` = '%i'," " `follow_distance` = '%i'," - " `stop_melee_level` = '%u'," - " `title` = '%s'," - " `suffix` = '%s'" + " `stop_melee_level` = '%u'" " WHERE `bot_id` = '%u'", bot_inst->GetBotOwnerCharacterID(), bot_inst->GetBotSpellID(), @@ -650,8 +647,6 @@ bool BotDatabase::SaveBot(Bot* bot_inst) ((bot_inst->GetShowHelm()) ? (1) : (0)), bot_inst->GetFollowDistance(), bot_inst->GetStopMeleeLevel(), - bot_inst->GetTitle().c_str(), - bot_inst->GetSuffix().c_str(), bot_inst->GetBotID() ); auto results = QueryDatabase(query); From 6ddc5ea8e8cce49b60f4475bce285a33c32be684 Mon Sep 17 00:00:00 2001 From: kentai Date: Thu, 20 Feb 2020 14:23:06 +1100 Subject: [PATCH 3/4] CheckIncreaseSkill() from Client::ThrowingAttack() to DoThrowingAttackDmg() so it gets called during combat abilities(zerker volley), as well as regular throws(monk ranged). --- zone/special_attacks.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/zone/special_attacks.cpp b/zone/special_attacks.cpp index b7cdebf02..6a073fc38 100644 --- a/zone/special_attacks.cpp +++ b/zone/special_attacks.cpp @@ -1408,6 +1408,9 @@ void Mob::DoThrowingAttackDmg(Mob *other, const EQEmu::ItemInstance *RangeWeapon else TrySkillProc(other, EQEmu::skills::SkillThrowing, 0, false, EQEmu::invslot::slotRange); } + if (IsClient()) { + CastToClient()->CheckIncreaseSkill(EQEmu::skills::SkillThrowing, GetTarget()); + } } void Mob::SendItemAnimation(Mob *to, const EQEmu::ItemData *item, EQEmu::skills::SkillType skillInUse, float velocity) { From 0043f569843059eacbfffb0390084cc02a60ac04 Mon Sep 17 00:00:00 2001 From: kentai Date: Thu, 20 Feb 2020 14:37:26 +1100 Subject: [PATCH 4/4] ... --- zone/special_attacks.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/zone/special_attacks.cpp b/zone/special_attacks.cpp index 6a073fc38..42ec94616 100644 --- a/zone/special_attacks.cpp +++ b/zone/special_attacks.cpp @@ -1294,7 +1294,6 @@ void Client::ThrowingAttack(Mob* other, bool CanDoubleAttack) { //old was 51 //consume ammo DeleteItemInInventory(ammo_slot, 1, true); - CheckIncreaseSkill(EQEmu::skills::SkillThrowing, GetTarget()); CommonBreakInvisibleFromCombat(); }