mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-13 06:21:28 +00:00
[Quest API] Add RemoveAAPoints() and AA Loss Event to Perl/Lua (#4174)
* [Quest API] Add RemoveAAPoints() and AA Loss Event to Perl/Lua # Perl - Add `$client->RemoveAAPoints(points)`. - Add `EVENT_AA_LOSS`, exports `$aa_lost`. # Lua - Add `client:RemoveAAPoints(points)`. - Add `event_aa_loss`, exports `e.aa_lost`. # Notes - Allows operators to more easily remove AA Points. - Has a bool return type that will return false if the player does not have enough AA Points to complete the removal. * Update client.cpp
This commit is contained in:
parent
96370e0298
commit
3bfb148bdc
@ -11473,6 +11473,37 @@ void Client::SetLockSavePosition(bool lock_save_position)
|
||||
Client::m_lock_save_position = lock_save_position;
|
||||
}
|
||||
|
||||
void Client::SetAAPoints(uint32 points)
|
||||
{
|
||||
const uint32 current_points = m_pp.aapoints;
|
||||
|
||||
m_pp.aapoints = points;
|
||||
|
||||
QuestEventID event_id = points > current_points ? EVENT_AA_GAIN : EVENT_AA_LOSS;
|
||||
const uint32 change = event_id == EVENT_AA_GAIN ? points - current_points : current_points - points;
|
||||
|
||||
if (parse->PlayerHasQuestSub(event_id)) {
|
||||
parse->EventPlayer(event_id, this, std::to_string(change), 0);
|
||||
}
|
||||
|
||||
SendAlternateAdvancementStats();
|
||||
}
|
||||
|
||||
bool Client::RemoveAAPoints(uint32 points)
|
||||
{
|
||||
if (m_pp.aapoints < points) {
|
||||
return false;
|
||||
}
|
||||
|
||||
m_pp.aapoints -= points;
|
||||
|
||||
if (parse->PlayerHasQuestSub(EVENT_AA_LOSS)) {
|
||||
parse->EventPlayer(EVENT_AA_LOSS, this, std::to_string(points), 0);
|
||||
}
|
||||
|
||||
SendAlternateAdvancementStats();
|
||||
}
|
||||
|
||||
void Client::AddAAPoints(uint32 points)
|
||||
{
|
||||
m_pp.aapoints += points;
|
||||
|
||||
@ -933,8 +933,9 @@ public:
|
||||
void ResetAlternateAdvancementTimers();
|
||||
void ResetOnDeathAlternateAdvancement();
|
||||
|
||||
void SetAAPoints(uint32 points) { m_pp.aapoints = points; SendAlternateAdvancementStats(); }
|
||||
void SetAAPoints(uint32 points);
|
||||
void AddAAPoints(uint32 points);
|
||||
bool RemoveAAPoints(uint32 points);
|
||||
int GetAAPoints() { return m_pp.aapoints; }
|
||||
int GetSpentAA() { return m_pp.aapoints_spent; }
|
||||
uint32 GetRequiredAAExperience();
|
||||
|
||||
@ -200,6 +200,7 @@ const char* QuestEventSubroutines[_LargestEventID] = {
|
||||
"EVENT_ENTITY_VARIABLE_DELETE",
|
||||
"EVENT_ENTITY_VARIABLE_SET",
|
||||
"EVENT_ENTITY_VARIABLE_UPDATE",
|
||||
"EVENT_AA_LOSS",
|
||||
|
||||
// Add new events before these or Lua crashes
|
||||
"EVENT_SPELL_EFFECT_BOT",
|
||||
@ -2273,6 +2274,11 @@ void PerlembParser::ExportEventVariables(
|
||||
break;
|
||||
}
|
||||
|
||||
case EVENT_AA_LOSS: {
|
||||
ExportVar(package_name.c_str(), "aa_lost", data);
|
||||
break;
|
||||
}
|
||||
|
||||
case EVENT_AA_EXP_GAIN: {
|
||||
ExportVar(package_name.c_str(), "aa_exp_gained", data);
|
||||
break;
|
||||
|
||||
@ -142,6 +142,7 @@ typedef enum {
|
||||
EVENT_ENTITY_VARIABLE_DELETE,
|
||||
EVENT_ENTITY_VARIABLE_SET,
|
||||
EVENT_ENTITY_VARIABLE_UPDATE,
|
||||
EVENT_AA_LOSS,
|
||||
|
||||
// Add new events before these or Lua crashes
|
||||
EVENT_SPELL_EFFECT_BOT,
|
||||
|
||||
@ -3296,6 +3296,12 @@ bool Lua_Client::IsInAGuild()
|
||||
return self->IsInAGuild();
|
||||
}
|
||||
|
||||
bool Lua_Client::RemoveAAPoints(uint32 points)
|
||||
{
|
||||
Lua_Safe_Call_Bool();
|
||||
return self->RemoveAAPoints(points);
|
||||
}
|
||||
|
||||
luabind::scope lua_register_client() {
|
||||
return luabind::class_<Lua_Client, Lua_Mob>("Client")
|
||||
.def(luabind::constructor<>())
|
||||
@ -3669,6 +3675,7 @@ luabind::scope lua_register_client() {
|
||||
.def("ReadBookByName", (void(Lua_Client::*)(std::string,uint8))&Lua_Client::ReadBookByName)
|
||||
.def("RefundAA", (void(Lua_Client::*)(void))&Lua_Client::RefundAA)
|
||||
.def("ReloadDataBuckets", (bool(Lua_Client::*)(void))&Lua_Client::ReloadDataBuckets)
|
||||
.def("RemoveAAPoints", (bool(Lua_Client::*)(uint32))&Lua_Client::RemoveAAPoints)
|
||||
.def("RemoveAllExpeditionLockouts", (void(Lua_Client::*)(std::string))&Lua_Client::RemoveAllExpeditionLockouts)
|
||||
.def("RemoveAllExpeditionLockouts", (void(Lua_Client::*)(void))&Lua_Client::RemoveAllExpeditionLockouts)
|
||||
.def("RemoveExpeditionLockout", (void(Lua_Client::*)(std::string, std::string))&Lua_Client::RemoveExpeditionLockout)
|
||||
|
||||
@ -566,6 +566,7 @@ public:
|
||||
void SetBotSpawnLimit(int new_spawn_limit, uint8 class_id);
|
||||
void CampAllBots();
|
||||
void CampAllBots(uint8 class_id);
|
||||
bool RemoveAAPoints(uint32 points);
|
||||
|
||||
void DialogueWindow(std::string markdown);
|
||||
|
||||
|
||||
@ -6733,7 +6733,8 @@ luabind::scope lua_register_events() {
|
||||
luabind::value("timer_stop", static_cast<int>(EVENT_TIMER_STOP)),
|
||||
luabind::value("entity_variable_delete", static_cast<int>(EVENT_ENTITY_VARIABLE_DELETE)),
|
||||
luabind::value("entity_variable_set", static_cast<int>(EVENT_ENTITY_VARIABLE_SET)),
|
||||
luabind::value("entity_variable_update", static_cast<int>(EVENT_ENTITY_VARIABLE_UPDATE))
|
||||
luabind::value("entity_variable_update", static_cast<int>(EVENT_ENTITY_VARIABLE_UPDATE)),
|
||||
luabind::value("aa_loss", static_cast<int>(EVENT_AA_LOSS))
|
||||
)];
|
||||
}
|
||||
|
||||
|
||||
@ -182,7 +182,8 @@ const char *LuaEvents[_LargestEventID] = {
|
||||
"event_timer_stop",
|
||||
"event_entity_variable_delete",
|
||||
"event_entity_variable_set",
|
||||
"event_entity_variable_update"
|
||||
"event_entity_variable_update",
|
||||
"event_aa_loss"
|
||||
};
|
||||
|
||||
extern Zone *zone;
|
||||
@ -343,6 +344,7 @@ LuaParser::LuaParser() {
|
||||
PlayerArgumentDispatch[EVENT_ENTITY_VARIABLE_DELETE] = handle_player_entity_variable;
|
||||
PlayerArgumentDispatch[EVENT_ENTITY_VARIABLE_SET] = handle_player_entity_variable;
|
||||
PlayerArgumentDispatch[EVENT_ENTITY_VARIABLE_UPDATE] = handle_player_entity_variable;
|
||||
PlayerArgumentDispatch[EVENT_AA_LOSS] = handle_player_aa_loss;
|
||||
|
||||
ItemArgumentDispatch[EVENT_ITEM_CLICK] = handle_item_click;
|
||||
ItemArgumentDispatch[EVENT_ITEM_CLICK_CAST] = handle_item_click;
|
||||
|
||||
@ -1667,6 +1667,18 @@ void handle_player_entity_variable(
|
||||
}
|
||||
}
|
||||
|
||||
void handle_player_aa_loss(
|
||||
QuestInterface *parse,
|
||||
lua_State* L,
|
||||
Client* client,
|
||||
std::string data,
|
||||
uint32 extra_data,
|
||||
std::vector<std::any> *extra_pointers
|
||||
) {
|
||||
lua_pushinteger(L, Strings::ToInt(data));
|
||||
lua_setfield(L, -2, "aa_lost");
|
||||
}
|
||||
|
||||
// Item
|
||||
void handle_item_click(
|
||||
QuestInterface *parse,
|
||||
|
||||
@ -827,6 +827,15 @@ void handle_player_entity_variable(
|
||||
std::vector<std::any> *extra_pointers
|
||||
);
|
||||
|
||||
void handle_player_aa_loss(
|
||||
QuestInterface *parse,
|
||||
lua_State* L,
|
||||
Client* client,
|
||||
std::string data,
|
||||
uint32 extra_data,
|
||||
std::vector<std::any> *extra_pointers
|
||||
);
|
||||
|
||||
// Item
|
||||
void handle_item_click(
|
||||
QuestInterface *parse,
|
||||
|
||||
@ -3103,6 +3103,11 @@ bool Perl_Client_IsInAGuild(Client* self)
|
||||
return self->IsInAGuild();
|
||||
}
|
||||
|
||||
bool Perl_Client_RemoveAAPoints(Client* self, uint32 points)
|
||||
{
|
||||
return self->RemoveAAPoints(points);
|
||||
}
|
||||
|
||||
void perl_register_client()
|
||||
{
|
||||
perl::interpreter perl(PERL_GET_THX);
|
||||
@ -3470,6 +3475,7 @@ void perl_register_client()
|
||||
package.add("ReadBookByName", &Perl_Client_ReadBookByName);
|
||||
package.add("RefundAA", &Perl_Client_RefundAA);
|
||||
package.add("ReloadDataBuckets", &Perl_Client_ReloadDataBuckets);
|
||||
package.add("RemoveAAPoints", &Perl_Client_RemoveAAPoints);
|
||||
package.add("RemoveAllExpeditionLockouts", (void(*)(Client*))&Perl_Client_RemoveAllExpeditionLockouts);
|
||||
package.add("RemoveAllExpeditionLockouts", (void(*)(Client*, std::string))&Perl_Client_RemoveAllExpeditionLockouts);
|
||||
package.add("RemoveEbonCrystals", &Perl_Client_RemoveEbonCrystals);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user