[Database] Add Extra Haste to Bots/Character Tables (#4286)

* [Database] Add Extra Haste to Bots/Character Tables

* Remove Database::GetExtraHasteByCharacterID

* Update database.h

* Update mob.cpp

* Update database_update_manifest.cpp

---------

Co-authored-by: Akkadius <akkadius1@gmail.com>
This commit is contained in:
Alex King
2024-05-04 19:21:41 -04:00
committed by GitHub
parent a71ad416b4
commit 7ad97ce168
16 changed files with 380 additions and 255 deletions
+4
View File
@@ -118,6 +118,8 @@ Bot::Bot(NPCType *npcTypeData, Client* botOwner) : NPC(npcTypeData, nullptr, glm
mana_regen = CalcManaRegen();
end_regen = CalcEnduranceRegen();
SetExtraHaste(database.botdb.GetBotExtraHasteByID(GetBotID()), false);
strcpy(name, GetCleanName());
memset(&_botInspectMessage, 0, sizeof(InspectMessage_Struct));
}
@@ -445,6 +447,8 @@ Bot::Bot(
}
cur_end = max_end;
SetExtraHaste(database.botdb.GetBotExtraHasteByID(GetBotID()), false);
}
Bot::~Bot() {
+7
View File
@@ -2353,3 +2353,10 @@ const uint16 BotDatabase::GetBotRaceByID(const uint32 bot_id)
return e.bot_id ? e.race : Race::Doug;
}
const int BotDatabase::GetBotExtraHasteByID(const uint32 bot_id)
{
const auto& e = BotDataRepository::FindOne(database, bot_id);
return e.bot_id ? e.extra_haste : 0;
}
+1
View File
@@ -166,6 +166,7 @@ public:
const uint8 GetBotLevelByID(const uint32 bot_id);
const std::string GetBotNameByID(const uint32 bot_id);
const uint16 GetBotRaceByID(const uint32 bot_id);
const int GetBotExtraHasteByID(const uint32 bot_id);
class fail {
public:
+2 -2
View File
@@ -322,7 +322,7 @@ int64 Client::CalcMaxHP()
//but the actual effect sent on live causes the client
//to apply it to (basehp + itemhp).. I will oblige to the client's whims over
//the aa description
nd += aabonuses.PercentMaxHPChange + spellbonuses.PercentMaxHPChange + itembonuses.PercentMaxHPChange; //Natural Durability, Physical Enhancement, Planar Durability
max_hp = (float)max_hp * (float)nd / (float)10000; //this is to fix the HP-above-495k issue
max_hp += spellbonuses.FlatMaxHPChange + aabonuses.FlatMaxHPChange + itembonuses.FlatMaxHPChange;
@@ -999,7 +999,7 @@ int Client::CalcHaste()
else { // 1-50
h += spellbonuses.hastetype3 > 10 ? 10 : spellbonuses.hastetype3;
}
h += ExtraHaste; //GM granted haste.
h += extra_haste; //GM granted haste.
Haste = 100 + h;
return Haste;
}
+3 -2
View File
@@ -1284,7 +1284,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` 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` FROM `character_data` LEFT JOIN `guild_members` ON `id` = `char_id` WHERE `id` = {}",
cid
);
auto results = database.QueryDatabase(query);
@@ -1295,7 +1295,8 @@ void Client::Handle_Connect_OP_ZoneEntry(const EQApplicationPacket *app)
guild_tribute_opt_in = row[7] ? Strings::ToBool(row[7]) : 0;
}
SetEXPEnabled(atobool(row[6]));
SetEXPEnabled(Strings::ToBool(row[6]));
SetExtraHaste(Strings::ToInt(row[8]), false);
if (LFP) { LFP = Strings::ToInt(row[0]); }
if (LFG) { LFG = Strings::ToInt(row[1]); }
+17 -9
View File
@@ -2,28 +2,36 @@
void SetHaste(Client *c, const Seperator *sep)
{
const auto arguments = sep->argnum;
const uint16 arguments = sep->argnum;
if (arguments < 2 || !sep->IsNumber(2)) {
c->Message(Chat::White, "Usage: #set haste [Percentage] - Set GM Bonus Haste (100 is 100% more Attack Speed)");
c->Message(Chat::White, "Usage: #set haste [Percentage] [Save] - Set GM Bonus Haste (100 is 100% more Attack Speed) (Save is optional)");
return;
}
auto t = c;
if (c->GetGM() && c->GetTarget() && c->GetTarget()->IsClient()) {
t = c->GetTarget()->CastToClient();
Mob* t = c;
if (c->GetGM() && c->GetTarget() && c->GetTarget()->IsOfClientBot()) {
t = c->GetTarget();
}
const int extra_haste = Strings::ToInt(sep->arg[2]);
const int extra_haste = Strings::ToInt(sep->arg[2]);
const bool need_to_save = sep->arg[3] ? Strings::ToBool(sep->arg[3]) : false;
t->SetExtraHaste(extra_haste, need_to_save);
if (t->IsBot()) {
t->CastToBot()->CalcBonuses();
} else if (t->IsClient()) {
t->CastToClient()->CalcBonuses();
}
t->SetExtraHaste(extra_haste);
t->CalcBonuses();
t->SetAttackTimer();
c->Message(
Chat::White,
fmt::format(
"GM Haste Bonus set to {}%% for {}.",
"GM Haste Bonus set to {}%%{} for {}.",
Strings::Commify(extra_haste),
need_to_save ? " and saved" : "",
c->GetTargetDescription(t)
).c_str()
);
+13
View File
@@ -1186,6 +1186,11 @@ void Lua_Mob::SetExtraHaste(int haste) {
self->SetExtraHaste(haste);
}
void Lua_Mob::SetExtraHaste(int haste, bool need_to_save) {
Lua_Safe_Call_Void();
self->SetExtraHaste(haste, need_to_save);
}
int Lua_Mob::GetHaste() {
Lua_Safe_Call_Int();
return self->GetHaste();
@@ -3369,6 +3374,12 @@ std::string Lua_Mob::GetConsiderColor(uint8 other_level)
return EQ::constants::GetConsiderColorName(self->GetLevelCon(other_level));
}
int Lua_Mob::GetExtraHaste()
{
Lua_Safe_Call_Int();
return self->GetExtraHaste();
}
luabind::scope lua_register_mob() {
return luabind::class_<Lua_Mob, Lua_Entity>("Mob")
.def(luabind::constructor<>())
@@ -3605,6 +3616,7 @@ luabind::scope lua_register_mob() {
.def("GetDrakkinTattoo", &Lua_Mob::GetDrakkinTattoo)
.def("GetEntityVariable", &Lua_Mob::GetEntityVariable)
.def("GetEntityVariables",&Lua_Mob::GetEntityVariables)
.def("GetExtraHaste",&Lua_Mob::GetExtraHaste)
.def("GetEyeColor1", &Lua_Mob::GetEyeColor1)
.def("GetEyeColor2", &Lua_Mob::GetEyeColor2)
.def("GetFR", &Lua_Mob::GetFR)
@@ -3868,6 +3880,7 @@ luabind::scope lua_register_mob() {
.def("SetDisableMelee", (void(Lua_Mob::*)(bool))&Lua_Mob::SetDisableMelee)
.def("SetEntityVariable", &Lua_Mob::SetEntityVariable)
.def("SetExtraHaste", (void(Lua_Mob::*)(int))&Lua_Mob::SetExtraHaste)
.def("SetExtraHaste", (void(Lua_Mob::*)(int,bool))&Lua_Mob::SetExtraHaste)
.def("SetFlurryChance", (void(Lua_Mob::*)(int))&Lua_Mob::SetFlurryChance)
.def("SetFlyMode", (void(Lua_Mob::*)(int))&Lua_Mob::SetFlyMode)
.def("SetGender", (void(Lua_Mob::*)(uint8))&Lua_Mob::SetGender)
+3 -1
View File
@@ -269,7 +269,6 @@ public:
bool CanThisClassBlock();
void SetInvul(bool value);
bool GetInvul();
void SetExtraHaste(int haste);
int GetHaste();
int GetHandToHandDamage();
int GetHandToHandDelay();
@@ -592,6 +591,9 @@ public:
bool IsWisdomCasterClass();
std::string GetConsiderColor(Lua_Mob other);
std::string GetConsiderColor(uint8 other_level);
int GetExtraHaste();
void SetExtraHaste(int haste);
void SetExtraHaste(int haste, bool need_to_save);
};
#endif
+34 -4
View File
@@ -21,6 +21,9 @@
#include "../common/strings.h"
#include "../common/misc_functions.h"
#include "../common/repositories/bot_data_repository.h"
#include "../common/repositories/character_data_repository.h"
#include "data_bucket.h"
#include "quest_parser_collection.h"
#include "string_ids.h"
@@ -260,7 +263,7 @@ Mob::Mob(
WIS = in_wis;
CHA = in_cha;
MR = CR = FR = DR = PR = Corrup = PhR = 0;
ExtraHaste = 0;
extra_haste = 0;
bEnraged = false;
current_mana = 0;
max_mana = 0;
@@ -2408,7 +2411,7 @@ void Mob::SendStatsWindow(Client* c, bool use_window)
DialogueWindow::TableRow(
DialogueWindow::TableCell(Strings::Commify(itembonuses.haste)) +
DialogueWindow::TableCell(Strings::Commify(spellbonuses.haste + spellbonuses.hastetype2)) +
DialogueWindow::TableCell(Strings::Commify(spellbonuses.hastetype3 + ExtraHaste)) +
DialogueWindow::TableCell(Strings::Commify(spellbonuses.hastetype3 + extra_haste)) +
DialogueWindow::TableCell(
fmt::format(
"{} ({})",
@@ -2688,7 +2691,7 @@ void Mob::SendStatsWindow(Client* c, bool use_window)
Strings::Commify(RuleI(Character, HasteCap)),
Strings::Commify(itembonuses.haste),
Strings::Commify(spellbonuses.haste + spellbonuses.hastetype2),
Strings::Commify(spellbonuses.hastetype3 + ExtraHaste)
Strings::Commify(spellbonuses.hastetype3 + extra_haste)
).c_str()
);
}
@@ -5460,7 +5463,7 @@ int Mob::GetHaste()
} else { // 1-50
h += spellbonuses.hastetype3 > 10 ? 10 : spellbonuses.hastetype3;
}
h += ExtraHaste; //GM granted haste.
h += extra_haste; //GM granted haste.
return 100 + h;
}
@@ -8550,3 +8553,30 @@ void Mob::HandleDoorOpen()
}
}
}
void Mob::SetExtraHaste(int haste, bool need_to_save)
{
extra_haste = haste;
if (need_to_save) {
if (IsBot()) {
auto e = BotDataRepository::FindOne(database, CastToBot()->GetBotID());
if (!e.bot_id) {
return;
}
e.extra_haste = haste;
BotDataRepository::UpdateOne(database, e);
} else if (IsClient()) {
auto e = CharacterDataRepository::FindOne(database, CastToClient()->CharacterID());
if (!e.id) {
return;
}
e.extra_haste = haste;
CharacterDataRepository::UpdateOne(database, e);
}
}
}
+3 -2
View File
@@ -1104,7 +1104,8 @@ public:
virtual void SetAttackTimer();
inline void SetInvul(bool invul) { invulnerable=invul; }
inline bool GetInvul(void) { return invulnerable; }
inline void SetExtraHaste(int Haste) { ExtraHaste = Haste; }
void SetExtraHaste(int haste, bool need_to_save = true);
inline int GetExtraHaste() { return extra_haste; }
virtual int GetHaste();
int32 GetMeleeMitigation();
@@ -1722,7 +1723,7 @@ protected:
uint8 aa_title;
int ExtraHaste; // for the #haste command
int extra_haste; // for the #haste command
bool mezzed;
bool stunned;
bool charmed; //this isnt fully implemented yet
+13 -1
View File
@@ -1154,6 +1154,16 @@ void Perl_Mob_SetExtraHaste(Mob* self, int haste) // @categories Script Utility,
self->SetExtraHaste(haste);
}
void Perl_Mob_SetExtraHaste(Mob* self, int haste, bool need_to_save) // @categories Script Utility, Stats and Attributes
{
self->SetExtraHaste(haste, need_to_save);
}
int Perl_Mob_GetExtraHaste(Mob* self) // @categories Script Utility, Stats and Attributes
{
return self->GetExtraHaste();
}
int Perl_Mob_GetHaste(Mob* self) // @categories Stats and Attributes
{
return self->GetHaste();
@@ -3700,6 +3710,7 @@ void perl_register_mob()
package.add("GetEquipment", &Perl_Mob_GetEquipment);
package.add("GetEquipmentColor", &Perl_Mob_GetEquipmentColor);
package.add("GetEquipmentMaterial", &Perl_Mob_GetEquipmentMaterial);
package.add("GetExtraHaste", &Perl_Mob_GetExtraHaste);
package.add("GetEyeColor1", &Perl_Mob_GetEyeColor1);
package.add("GetEyeColor2", &Perl_Mob_GetEyeColor2);
package.add("GetFR", &Perl_Mob_GetFR);
@@ -4023,7 +4034,8 @@ void perl_register_mob()
package.add("SetDeltas", &Perl_Mob_SetDeltas);
package.add("SetDisableMelee", &Perl_Mob_SetDisableMelee);
package.add("SetEntityVariable", &Perl_Mob_SetEntityVariable);
package.add("SetExtraHaste", &Perl_Mob_SetExtraHaste);
package.add("SetExtraHaste", (void(*)(Mob*, int))&Perl_Mob_SetExtraHaste);
package.add("SetExtraHaste", (void(*)(Mob*, int, bool))&Perl_Mob_SetExtraHaste);
package.add("SetFlurryChance", &Perl_Mob_SetFlurryChance);
package.add("SetFlyMode", &Perl_Mob_SetFlyMode);
package.add("SetFollowID", &Perl_Mob_SetFollowID);