[Quest API] Add MaxSkills() to Perl/Lua. (#2621)

* [Quest API] Add MaxSkills() to Perl/Lua.

# Perl
- Add `$client->MaxSkills()`.

# Lua
- Add `client:MaxSkills()`.

# Notes
- Allows operators an easy short hand for maxing a player's skills for their level without needing to do all the looping and stuff on their own.

* Cleanup.

* Only set if it's higher than skill level player has.

* Add constant.
This commit is contained in:
Alex King 2022-12-06 08:46:21 -05:00 committed by GitHub
parent 91ea6462f2
commit f7fb1c9fe1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 45 additions and 14 deletions

View File

@ -12013,3 +12013,18 @@ std::string Client::GetGuildPublicNote()
return gci.public_note; return gci.public_note;
} }
void Client::MaxSkills()
{
for (const auto &s : EQ::skills::GetSkillTypeMap()) {
auto current_skill_value = (
EQ::skills::IsSpecializedSkill(s.first) ?
MAX_SPECIALIZED_SKILL :
content_db.GetSkillCap(GetClass(), s.first, GetLevel())
);
if (GetSkill(s.first) < current_skill_value) {
SetSkill(s.first, current_skill_value);
}
}
}

View File

@ -87,6 +87,7 @@ namespace EQ
#define CLIENT_LD_TIMEOUT 30000 // length of time client stays in zone after LDing #define CLIENT_LD_TIMEOUT 30000 // length of time client stays in zone after LDing
#define TARGETING_RANGE 200 // range for /assist and /target #define TARGETING_RANGE 200 // range for /assist and /target
#define XTARGET_HARDCAP 20 #define XTARGET_HARDCAP 20
#define MAX_SPECIALIZED_SKILL 50
extern Zone* zone; extern Zone* zone;
extern TaskManager *task_manager; extern TaskManager *task_manager;
@ -783,6 +784,7 @@ public:
uint16 MaxSkill(EQ::skills::SkillType skillid, uint16 class_, uint16 level) const; uint16 MaxSkill(EQ::skills::SkillType skillid, uint16 class_, uint16 level) const;
inline uint16 MaxSkill(EQ::skills::SkillType skillid) const { return MaxSkill(skillid, GetClass(), GetLevel()); } inline uint16 MaxSkill(EQ::skills::SkillType skillid) const { return MaxSkill(skillid, GetClass(), GetLevel()); }
uint8 SkillTrainLevel(EQ::skills::SkillType skillid, uint16 class_); uint8 SkillTrainLevel(EQ::skills::SkillType skillid, uint16 class_);
void MaxSkills();
void SendTradeskillSearchResults(const std::string &query, unsigned long objtype, unsigned long someid); void SendTradeskillSearchResults(const std::string &query, unsigned long objtype, unsigned long someid);
void SendTradeskillDetails(uint32 recipe_id); void SendTradeskillDetails(uint32 recipe_id);

View File

@ -210,7 +210,7 @@ int command_init(void)
command_add("logs", "Manage anything to do with logs", AccountStatus::GMImpossible, command_logs) || command_add("logs", "Manage anything to do with logs", AccountStatus::GMImpossible, command_logs) ||
command_add("makepet", "[Pet Name] - Make a pet", AccountStatus::Guide, command_makepet) || command_add("makepet", "[Pet Name] - Make a pet", AccountStatus::Guide, command_makepet) ||
command_add("mana", "Fill your or your target's mana", AccountStatus::Guide, command_mana) || command_add("mana", "Fill your or your target's mana", AccountStatus::Guide, command_mana) ||
command_add("maxskills", "Maxes skills for you.", AccountStatus::GMMgmt, command_max_all_skills) || command_add("maxskills", "Maxes skills for you or your player target.", AccountStatus::GMMgmt, command_max_all_skills) ||
command_add("memspell", "[Spell ID] [Spell Gem] - Memorize a Spell by ID to the specified Spell Gem for you or your target", AccountStatus::Guide, command_memspell) || command_add("memspell", "[Spell ID] [Spell Gem] - Memorize a Spell by ID to the specified Spell Gem for you or your target", AccountStatus::Guide, command_memspell) ||
command_add("merchant_close_shop", "Closes a merchant shop", AccountStatus::GMAdmin, command_merchantcloseshop) || command_add("merchant_close_shop", "Closes a merchant shop", AccountStatus::GMAdmin, command_merchantcloseshop) ||
command_add("merchant_open_shop", "Opens a merchants shop", AccountStatus::GMAdmin, command_merchantopenshop) || command_add("merchant_open_shop", "Opens a merchants shop", AccountStatus::GMAdmin, command_merchantopenshop) ||

View File

@ -2,19 +2,19 @@
void command_max_all_skills(Client *c, const Seperator *sep) void command_max_all_skills(Client *c, const Seperator *sep)
{ {
if (c) { auto t = c;
Client *client_target = (c->GetTarget() ? (c->GetTarget()->IsClient() ? c->GetTarget()->CastToClient() : c) if (c->GetTarget() && c->GetTarget()->IsClient()) {
: c); t = c->GetTarget()->CastToClient();
auto Skills = EQ::skills::GetSkillTypeMap(); }
for (auto &skills_iter : Skills) {
auto skill_id = skills_iter.first; t->MaxSkills();
auto current_skill_value = (
(EQ::skills::IsSpecializedSkill(skill_id)) ? c->Message(
50 : Chat::White,
content_db.GetSkillCap(client_target->GetClass(), skill_id, client_target->GetLevel()) fmt::format(
"Maxed skills for {}.",
c->GetTargetDescription(t)
).c_str()
); );
client_target->SetSkill(skill_id, current_skill_value);
}
}
} }

View File

@ -2886,6 +2886,12 @@ std::string Lua_Client::GetGuildPublicNote()
return self->GetGuildPublicNote(); return self->GetGuildPublicNote();
} }
void Lua_Client::MaxSkills()
{
Lua_Safe_Call_Void();
self->MaxSkills();
}
#ifdef BOTS #ifdef BOTS
int Lua_Client::GetBotRequiredLevel() int Lua_Client::GetBotRequiredLevel()
@ -3251,6 +3257,7 @@ luabind::scope lua_register_client() {
.def("Marquee", (void(Lua_Client::*)(uint32, std::string, uint32))&Lua_Client::SendMarqueeMessage) .def("Marquee", (void(Lua_Client::*)(uint32, std::string, uint32))&Lua_Client::SendMarqueeMessage)
.def("Marquee", (void(Lua_Client::*)(uint32, uint32, uint32, uint32, uint32, std::string))&Lua_Client::SendMarqueeMessage) .def("Marquee", (void(Lua_Client::*)(uint32, uint32, uint32, uint32, uint32, std::string))&Lua_Client::SendMarqueeMessage)
.def("MaxSkill", (int(Lua_Client::*)(int))&Lua_Client::MaxSkill) .def("MaxSkill", (int(Lua_Client::*)(int))&Lua_Client::MaxSkill)
.def("MaxSkills", (void(Lua_Client::*)(void))&Lua_Client::MaxSkills)
.def("MemSpell", (void(Lua_Client::*)(int,int))&Lua_Client::MemSpell) .def("MemSpell", (void(Lua_Client::*)(int,int))&Lua_Client::MemSpell)
.def("MemSpell", (void(Lua_Client::*)(int,int,bool))&Lua_Client::MemSpell) .def("MemSpell", (void(Lua_Client::*)(int,int,bool))&Lua_Client::MemSpell)
.def("MemmedCount", (int(Lua_Client::*)(void))&Lua_Client::MemmedCount) .def("MemmedCount", (int(Lua_Client::*)(void))&Lua_Client::MemmedCount)

View File

@ -453,6 +453,7 @@ public:
void SendPayload(int payload_id); void SendPayload(int payload_id);
void SendPayload(int payload_id, std::string payload_value); void SendPayload(int payload_id, std::string payload_value);
std::string GetGuildPublicNote(); std::string GetGuildPublicNote();
void MaxSkills();
void ApplySpell(int spell_id); void ApplySpell(int spell_id);
void ApplySpell(int spell_id, int duration); void ApplySpell(int spell_id, int duration);

View File

@ -2767,6 +2767,11 @@ std::string Perl_Client_GetGuildPublicNote(Client* self)
return self->GetGuildPublicNote(); return self->GetGuildPublicNote();
} }
void Perl_Client_MaxSkills(Client* self)
{
self->MaxSkills();
}
#ifdef BOTS #ifdef BOTS
int Perl_Client_GetBotRequiredLevel(Client* self) int Perl_Client_GetBotRequiredLevel(Client* self)
@ -3126,6 +3131,7 @@ void perl_register_client()
package.add("MaxSkill", (int(*)(Client*, uint16))&Perl_Client_MaxSkill); package.add("MaxSkill", (int(*)(Client*, uint16))&Perl_Client_MaxSkill);
package.add("MaxSkill", (int(*)(Client*, uint16, uint16))&Perl_Client_MaxSkill); package.add("MaxSkill", (int(*)(Client*, uint16, uint16))&Perl_Client_MaxSkill);
package.add("MaxSkill", (int(*)(Client*, uint16, uint16, uint16))&Perl_Client_MaxSkill); package.add("MaxSkill", (int(*)(Client*, uint16, uint16, uint16))&Perl_Client_MaxSkill);
package.add("MaxSkills", &Perl_Client_MaxSkills);
package.add("MemSpell", (void(*)(Client*, uint16, int))&Perl_Client_MemSpell); package.add("MemSpell", (void(*)(Client*, uint16, int))&Perl_Client_MemSpell);
package.add("MemSpell", (void(*)(Client*, uint16, int, bool))&Perl_Client_MemSpell); package.add("MemSpell", (void(*)(Client*, uint16, int, bool))&Perl_Client_MemSpell);
package.add("MemmedCount", &Perl_Client_MemmedCount); package.add("MemmedCount", &Perl_Client_MemmedCount);