[Quest API] Add ResetAllDisciplineTimers() to Perl/Lua. (#1395)

- Add $client->ResetAllDisciplineTimers() to Perl.
- Add client:ResetAllDisciplineTimers() to Lua.
This commit is contained in:
Alex 2021-06-13 19:06:36 -04:00 committed by GitHub
parent 8d90b5a2e7
commit 0e4361955d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 36 additions and 4 deletions

View File

@ -985,6 +985,7 @@ public:
bool MemorizeSpellFromItem(uint32 item_id);
void TrainDiscBySpellID(int32 spell_id);
uint32 GetDisciplineTimer(uint32 timer_id);
void ResetAllDisciplineTimers();
int GetDiscSlotBySpellID(int32 spellid);
void ResetDisciplineTimer(uint32 timer_id);
void SendDisciplineUpdate();

View File

@ -722,7 +722,7 @@ bool Client::UseDiscipline(uint32 spell_id, uint32 target) {
uint32 Client::GetDisciplineTimer(uint32 timer_id) {
pTimerType disc_timer_id = pTimerDisciplineReuseStart + timer_id;
uint32 disc_timer = 0;
if (GetPTimers().Enabled((uint32)disc_timer_id)) {
if (GetPTimers().Enabled(disc_timer_id)) {
disc_timer = GetPTimers().GetRemainingTime(disc_timer_id);
}
return disc_timer;
@ -730,12 +730,22 @@ uint32 Client::GetDisciplineTimer(uint32 timer_id) {
void Client::ResetDisciplineTimer(uint32 timer_id) {
pTimerType disc_timer_id = pTimerDisciplineReuseStart + timer_id;
if (GetPTimers().Enabled((uint32)disc_timer_id)) {
GetPTimers().Clear(&database, (uint32)disc_timer_id);
if (GetPTimers().Enabled(disc_timer_id)) {
GetPTimers().Clear(&database, disc_timer_id);
}
SendDisciplineTimer(timer_id, 0);
}
void Client::ResetAllDisciplineTimers() {
for (pTimerType disc_timer_id = pTimerDisciplineReuseStart; disc_timer_id <= pTimerDisciplineReuseEnd; disc_timer_id++) {
uint32 current_timer_id = (disc_timer_id - pTimerDisciplineReuseStart);
if (GetPTimers().Enabled(disc_timer_id)) {
GetPTimers().Clear(&database, disc_timer_id);
}
SendDisciplineTimer(current_timer_id, 0);
}
}
bool Client::HasDisciplineLearned(uint16 spell_id) {
bool has_learned = false;
for (auto index = 0; index < MAX_PP_DISCIPLINES; ++index) {

View File

@ -2098,6 +2098,11 @@ void Lua_Client::SetHideMe(bool hide_me_state) {
self->SetHideMe(hide_me_state);
}
void Lua_Client::ResetAllDisciplineTimers() {
Lua_Safe_Call_Void();
self->ResetAllDisciplineTimers();
}
luabind::scope lua_register_client() {
return luabind::class_<Lua_Client, Lua_Mob>("Client")
.def(luabind::constructor<>())
@ -2453,7 +2458,8 @@ luabind::scope lua_register_client() {
.def("SetEXPModifier", (void(Lua_Client::*)(uint32,double))&Lua_Client::SetEXPModifier)
.def("AddLDoNLoss", (void(Lua_Client::*)(uint32))&Lua_Client::AddLDoNLoss)
.def("AddLDoNWin", (void(Lua_Client::*)(uint32))&Lua_Client::AddLDoNWin)
.def("SetHideMe", (void(Lua_Client::*)(bool))&Lua_Client::SetHideMe);
.def("SetHideMe", (void(Lua_Client::*)(bool))&Lua_Client::SetHideMe)
.def("ResetAllDisciplineTimers", (void(Lua_Client::*)(void))&Lua_Client::ResetAllDisciplineTimers);
}
luabind::scope lua_register_inventory_where() {

View File

@ -230,6 +230,7 @@ public:
void ResetTrade();
uint32 GetDisciplineTimer(uint32 timer_id);
void ResetDisciplineTimer(uint32 timer_id);
void ResetAllDisciplineTimers();
bool UseDiscipline(int spell_id, int target_id);
bool HasDisciplineLearned(uint16 spell_id);
int GetCharacterFactionLevel(int faction_id);

View File

@ -5332,6 +5332,19 @@ XS(XS_Client_SetHideMe) {
XSRETURN_EMPTY;
}
XS(XS_Client_ResetAllDisciplineTimers);
XS(XS_Client_ResetAllDisciplineTimers) {
dXSARGS;
if (items != 1)
Perl_croak(aTHX_ "Usage: Client::ResetAllDisciplineTimers(THIS)"); // @categories Spells and Disciplines
{
Client *THIS;
VALIDATE_THIS_IS_CLIENT;
THIS->ResetAllDisciplineTimers();
}
XSRETURN_EMPTY;
}
#ifdef __cplusplus
extern "C"
#endif
@ -5552,6 +5565,7 @@ XS(boot_Client) {
newXSproto(strcpy(buf, "RemoveExpeditionLockout"), XS_Client_RemoveExpeditionLockout, file, "$$$");
newXSproto(strcpy(buf, "RemoveNoRent"), XS_Client_RemoveNoRent, file, "$");
newXSproto(strcpy(buf, "ResetAA"), XS_Client_ResetAA, file, "$");
newXSproto(strcpy(buf, "ResetAllDisciplineTimers"), XS_Client_ResetAllDisciplineTimers, file, "$");
newXSproto(strcpy(buf, "ResetDisciplineTimer"), XS_Client_ResetDisciplineTimer, file, "$$");
newXSproto(strcpy(buf, "ResetTrade"), XS_Client_ResetTrade, file, "$");
newXSproto(strcpy(buf, "Save"), XS_Client_Save, file, "$$");