Skip to content

Commit

Permalink
[Quest API] Add GrantAllAAPoints() Overload To Perl/Lua (#4474)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kinglykrab authored Sep 20, 2024
1 parent 1af2524 commit b52719a
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 6 deletions.
6 changes: 5 additions & 1 deletion zone/aa.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2185,7 +2185,7 @@ void Client::AutoGrantAAPoints() {
SendAlternateAdvancementStats();
}

void Client::GrantAllAAPoints(uint8 unlock_level)
void Client::GrantAllAAPoints(uint8 unlock_level, bool skip_grant_only)
{
//iterate through every AA
for (auto& aa : zone->aa_abilities) {
Expand All @@ -2195,6 +2195,10 @@ void Client::GrantAllAAPoints(uint8 unlock_level)
continue;
}

if (ability->grant_only && skip_grant_only) {
continue;
}

const uint8 level = unlock_level ? unlock_level : GetLevel();

AA::Rank* rank = ability->first;
Expand Down
2 changes: 1 addition & 1 deletion zone/client.h
Original file line number Diff line number Diff line change
Expand Up @@ -1025,7 +1025,7 @@ class Client : public Mob
int GetSpentAA() { return m_pp.aapoints_spent; }
uint32 GetRequiredAAExperience();
void AutoGrantAAPoints();
void GrantAllAAPoints(uint8 unlock_level = 0);
void GrantAllAAPoints(uint8 unlock_level = 0, bool skip_grant_only = false);
bool HasAlreadyPurchasedRank(AA::Rank* rank);
void ListPurchasedAAs(Client *to, std::string search_criteria = std::string());

Expand Down
10 changes: 6 additions & 4 deletions zone/gm_commands/grantaa.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,16 @@ void command_grantaa(Client *c, const Seperator *sep)
return;
}

const uint8 unlock_level = sep->IsNumber(1) ? static_cast<uint8>(Strings::ToUnsignedInt(sep->arg[1])) : 0;
const uint8 unlock_level = sep->IsNumber(1) ? static_cast<uint8>(Strings::ToUnsignedInt(sep->arg[1])) : 0;
const bool skip_grant_only = sep->IsNumber(2) ? Strings::ToBool(sep->arg[2]) : false;

auto t = c->GetTarget()->CastToClient();
t->GrantAllAAPoints(unlock_level);
t->GrantAllAAPoints(unlock_level, skip_grant_only);

c->Message(
Chat::White,
fmt::format(
"Successfully granted all Alternate Advancements for {}{}.",
"Successfully granted all Alternate Advancements for {}{}{}.",
c->GetTargetDescription(t),
(
unlock_level ?
Expand All @@ -24,7 +25,8 @@ void command_grantaa(Client *c, const Seperator *sep)
unlock_level
) :
""
)
),
skip_grant_only ? "except for grant only AAs" : ""
).c_str()
);
}
7 changes: 7 additions & 0 deletions zone/lua_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3216,6 +3216,12 @@ void Lua_Client::GrantAllAAPoints(uint8 unlock_level)
self->GrantAllAAPoints(unlock_level);
}

void Lua_Client::GrantAllAAPoints(uint8 unlock_level, bool skip_grant_only)
{
Lua_Safe_Call_Void();
self->GrantAllAAPoints(unlock_level, skip_grant_only);
}

void Lua_Client::AddEbonCrystals(uint32 amount)
{
Lua_Safe_Call_Void();
Expand Down Expand Up @@ -3699,6 +3705,7 @@ luabind::scope lua_register_client() {
.def("GoFish", (void(Lua_Client::*)(void))&Lua_Client::GoFish)
.def("GrantAllAAPoints", (void(Lua_Client::*)(void))&Lua_Client::GrantAllAAPoints)
.def("GrantAllAAPoints", (void(Lua_Client::*)(uint8))&Lua_Client::GrantAllAAPoints)
.def("GrantAllAAPoints", (void(Lua_Client::*)(uint8,bool))&Lua_Client::GrantAllAAPoints)
.def("GrantAlternateAdvancementAbility", (bool(Lua_Client::*)(int, int))&Lua_Client::GrantAlternateAdvancementAbility)
.def("GrantAlternateAdvancementAbility", (bool(Lua_Client::*)(int, int, bool))&Lua_Client::GrantAlternateAdvancementAbility)
.def("GuildID", (uint32(Lua_Client::*)(void))&Lua_Client::GuildID)
Expand Down
1 change: 1 addition & 0 deletions zone/lua_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -487,6 +487,7 @@ class Lua_Client : public Lua_Mob
void SetBucket(std::string bucket_name, std::string bucket_value, std::string expiration);
void GrantAllAAPoints();
void GrantAllAAPoints(uint8 unlock_level);
void GrantAllAAPoints(uint8 unlock_level, bool skip_grant_only);
void AddEbonCrystals(uint32 amount);
void AddRadiantCrystals(uint32 amount);
void RemoveEbonCrystals(uint32 amount);
Expand Down
6 changes: 6 additions & 0 deletions zone/perl_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3031,6 +3031,11 @@ void Perl_Client_GrantAllAAPoints(Client* self, uint8 unlock_level)
self->GrantAllAAPoints(unlock_level);
}

void Perl_Client_GrantAllAAPoints(Client* self, uint8 unlock_level, bool skip_grant_only)
{
self->GrantAllAAPoints(unlock_level, skip_grant_only);
}

void Perl_Client_AddEbonCrystals(Client* self, uint32 amount)
{
self->AddEbonCrystals(amount);
Expand Down Expand Up @@ -3471,6 +3476,7 @@ void perl_register_client()
package.add("GoFish", &Perl_Client_GoFish);
package.add("GrantAllAAPoints", (void(*)(Client*))&Perl_Client_GrantAllAAPoints);
package.add("GrantAllAAPoints", (void(*)(Client*, uint8))&Perl_Client_GrantAllAAPoints);
package.add("GrantAllAAPoints", (void(*)(Client*, uint8, bool))&Perl_Client_GrantAllAAPoints);
package.add("GrantAlternateAdvancementAbility", (bool(*)(Client*, int, int))&Perl_Client_GrantAlternateAdvancementAbility);
package.add("GrantAlternateAdvancementAbility", (bool(*)(Client*, int, int, bool))&Perl_Client_GrantAlternateAdvancementAbility);
package.add("GuildID", &Perl_Client_GuildID);
Expand Down

0 comments on commit b52719a

Please sign in to comment.