[Quest API] Add ResetCastbarCooldownBySlot / ResetCastbarCooldownBySpellID / ResetAllCastbarCooldowns (#1873)

* New function to reset spellbar in perl/lua ResetCastbarCooldownsBySlot -1 for all slots and anything else to do it by slot number

* Add ResetCastbarCooldownsBySlot / ResetCastbarCooldownsBySpellID / ResetAllCastbarCooldowns
This commit is contained in:
Natedog2012 2021-12-08 21:39:35 -06:00 committed by GitHub
parent 294e51fca7
commit 42f439c4b7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 133 additions and 0 deletions

View File

@ -1014,6 +1014,10 @@ public:
void SetLinkedSpellReuseTimer(uint32 timer_id, uint32 duration);
bool IsLinkedSpellReuseTimerReady(uint32 timer_id);
void ResetCastbarCooldownBySlot(int slot);
void ResetAllCastbarCooldowns();
void ResetCastbarCooldownBySpellID(uint32 spell_id);
bool CheckTitle(int titleset);
void EnableTitle(int titleset);

View File

@ -2321,6 +2321,21 @@ int Lua_Client::GetNextAvailableDisciplineSlot(int starting_slot) {
return self->GetNextAvailableDisciplineSlot(starting_slot);
}
void Lua_Client::ResetCastbarCooldownBySlot(int slot) {
Lua_Safe_Call_Void();
self->ResetCastbarCooldownBySlot(slot);
}
void Lua_Client::ResetAllCastbarCooldowns() {
Lua_Safe_Call_Void();
self->ResetAllCastbarCooldowns();
}
void Lua_Client::ResetCastbarCooldownBySpellID(uint32 spell_id) {
Lua_Safe_Call_Void();
self->ResetCastbarCooldownBySpellID(spell_id);
}
luabind::scope lua_register_client() {
return luabind::class_<Lua_Client, Lua_Mob>("Client")
.def(luabind::constructor<>())
@ -2598,6 +2613,9 @@ luabind::scope lua_register_client() {
.def("RemoveLDoNWin", (void(Lua_Client::*)(uint32))&Lua_Client::RemoveLDoNWin)
.def("ResetAA", (void(Lua_Client::*)(void))&Lua_Client::ResetAA)
.def("ResetAllDisciplineTimers", (void(Lua_Client::*)(void))&Lua_Client::ResetAllDisciplineTimers)
.def("ResetAllCastbarCooldowns", (void(Lua_Client::*)(void))&Lua_Client::ResetAllCastbarCooldowns)
.def("ResetCastbarCooldownBySlot", (void(Lua_Client::*)(int))&Lua_Client::ResetCastbarCooldownBySlot)
.def("ResetCastbarCooldownBySpellID", (void(Lua_Client::*)(uint32))&Lua_Client::ResetCastbarCooldownBySpellID)
.def("ResetDisciplineTimer", (void(Lua_Client::*)(uint32))&Lua_Client::ResetDisciplineTimer)
.def("ResetTrade", (void(Lua_Client::*)(void))&Lua_Client::ResetTrade)
.def("Save", (void(Lua_Client::*)(int))&Lua_Client::Save)

View File

@ -241,6 +241,9 @@ public:
void ResetTrade();
uint32 GetDisciplineTimer(uint32 timer_id);
void ResetDisciplineTimer(uint32 timer_id);
void ResetCastbarCooldownBySlot(int slot);
void ResetAllCastbarCooldowns();
void ResetCastbarCooldownBySpellID(uint32 spell_id);
void ResetAllDisciplineTimers();
bool UseDiscipline(int spell_id, int target_id);
bool HasDisciplineLearned(uint16 spell_id);

View File

@ -5935,6 +5935,47 @@ XS(XS_Client_LearnDisciplines) {
XSRETURN(1);
}
XS(XS_Client_ResetCastbarCooldownBySlot);
XS(XS_Client_ResetCastbarCooldownBySlot) {
dXSARGS;
if (items != 2)
Perl_croak(aTHX_ "Usage: Client::ResetCastbarCooldownBySlot(THIS, int slot)");
{
Client* THIS;
int slot = (int) SvIV(ST(1));
VALIDATE_THIS_IS_CLIENT;
THIS->ResetCastbarCooldownBySlot(slot);
}
XSRETURN_EMPTY;
}
XS(XS_Client_ResetAllCastbarCooldowns);
XS(XS_Client_ResetAllCastbarCooldowns) {
dXSARGS;
if (items != 1)
Perl_croak(aTHX_ "Usage: Client::ResetAllCastbarCooldowns(THIS)");
{
Client* THIS;
VALIDATE_THIS_IS_CLIENT;
THIS->ResetAllCastbarCooldowns();
}
XSRETURN_EMPTY;
}
XS(XS_Client_ResetCastbarCooldownBySpellID);
XS(XS_Client_ResetCastbarCooldownBySpellID) {
dXSARGS;
if (items != 2)
Perl_croak(aTHX_ "Usage: Client::ResetCastbarCooldownBySpellID(THIS, uint32 spell_id)");
{
Client* THIS;
uint32 spell_id = (uint32) SvUV(ST(1));
VALIDATE_THIS_IS_CLIENT;
THIS->ResetCastbarCooldownBySpellID(spell_id);
}
XSRETURN_EMPTY;
}
#ifdef __cplusplus
extern "C"
#endif
@ -6169,6 +6210,9 @@ XS(boot_Client) {
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, "ResetAllCastbarCooldowns"), XS_Client_ResetAllCastbarCooldowns, file, "$");
newXSproto(strcpy(buf, "ResetCastbarCooldownBySlot"), XS_Client_ResetCastbarCooldownBySlot, file, "$$");
newXSproto(strcpy(buf, "ResetCastbarCooldownBySpellID"), XS_Client_ResetCastbarCooldownBySpellID, 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, "$$");

View File

@ -6449,3 +6449,67 @@ int Client::GetNextAvailableDisciplineSlot(int starting_slot) {
return -1; // Return -1 if No Slots open
}
void Client::ResetCastbarCooldownBySlot(int slot) {
if (slot < 0) {
for (unsigned int i = 0; i < EQ::spells::SPELL_GEM_COUNT; ++i) {
if(IsValidSpell(m_pp.mem_spells[i])) {
m_pp.spellSlotRefresh[i] = 1;
GetPTimers().Clear(&database, (pTimerSpellStart + m_pp.mem_spells[i]));
if (!IsLinkedSpellReuseTimerReady(spells[m_pp.mem_spells[i]].timer_id)) {
GetPTimers().Clear(&database, (pTimerLinkedSpellReuseStart + spells[m_pp.mem_spells[i]].timer_id));
}
if (spells[m_pp.mem_spells[i]].timer_id > 0 && spells[m_pp.mem_spells[i]].timer_id < MAX_DISCIPLINE_TIMERS) {
SetLinkedSpellReuseTimer(spells[m_pp.mem_spells[i]].timer_id, 0);
}
SendSpellBarEnable(m_pp.mem_spells[i]);
}
}
} else if (slot < EQ::spells::SPELL_GEM_COUNT) {
if(IsValidSpell(m_pp.mem_spells[slot])) {
m_pp.spellSlotRefresh[slot] = 1;
GetPTimers().Clear(&database, (pTimerSpellStart + m_pp.mem_spells[slot]));
if (!IsLinkedSpellReuseTimerReady(spells[m_pp.mem_spells[slot]].timer_id)) {
GetPTimers().Clear(&database, (pTimerLinkedSpellReuseStart + spells[m_pp.mem_spells[slot]].timer_id));
}
if (spells[m_pp.mem_spells[slot]].timer_id > 0 && spells[m_pp.mem_spells[slot]].timer_id < MAX_DISCIPLINE_TIMERS) {
SetLinkedSpellReuseTimer(spells[m_pp.mem_spells[slot]].timer_id, 0);
}
SendSpellBarEnable(m_pp.mem_spells[slot]);
}
}
}
void Client::ResetAllCastbarCooldowns() {
for (unsigned int i = 0; i < EQ::spells::SPELL_GEM_COUNT; ++i) {
if(IsValidSpell(m_pp.mem_spells[i])) {
m_pp.spellSlotRefresh[i] = 1;
GetPTimers().Clear(&database, (pTimerSpellStart + m_pp.mem_spells[i]));
if (!IsLinkedSpellReuseTimerReady(spells[m_pp.mem_spells[i]].timer_id)) {
GetPTimers().Clear(&database, (pTimerLinkedSpellReuseStart + spells[m_pp.mem_spells[i]].timer_id));
}
if (spells[m_pp.mem_spells[i]].timer_id > 0 && spells[m_pp.mem_spells[i]].timer_id < MAX_DISCIPLINE_TIMERS) {
SetLinkedSpellReuseTimer(spells[m_pp.mem_spells[i]].timer_id, 0);
}
SendSpellBarEnable(m_pp.mem_spells[i]);
}
}
}
void Client::ResetCastbarCooldownBySpellID(uint32 spell_id) {
for (unsigned int i = 0; i < EQ::spells::SPELL_GEM_COUNT; ++i) {
if(IsValidSpell(m_pp.mem_spells[i]) && m_pp.mem_spells[i] == spell_id) {
m_pp.spellSlotRefresh[i] = 1;
GetPTimers().Clear(&database, (pTimerSpellStart + m_pp.mem_spells[i]));
if (!IsLinkedSpellReuseTimerReady(spells[m_pp.mem_spells[i]].timer_id)) {
GetPTimers().Clear(&database, (pTimerLinkedSpellReuseStart + spells[m_pp.mem_spells[i]].timer_id));
}
if (spells[m_pp.mem_spells[i]].timer_id > 0 && spells[m_pp.mem_spells[i]].timer_id < MAX_DISCIPLINE_TIMERS) {
SetLinkedSpellReuseTimer(spells[m_pp.mem_spells[i]].timer_id, 0);
}
SendSpellBarEnable(m_pp.mem_spells[i]);
break;
}
}
}