diff --git a/zone/client.h b/zone/client.h index 649f9d31f..a9266230d 100644 --- a/zone/client.h +++ b/zone/client.h @@ -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); diff --git a/zone/lua_client.cpp b/zone/lua_client.cpp index ec4c1bd65..8da35c6fa 100644 --- a/zone/lua_client.cpp +++ b/zone/lua_client.cpp @@ -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_("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) diff --git a/zone/lua_client.h b/zone/lua_client.h index 7e91ea9f1..ee6881160 100644 --- a/zone/lua_client.h +++ b/zone/lua_client.h @@ -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); diff --git a/zone/perl_client.cpp b/zone/perl_client.cpp index bb5ee2310..d51c79fdd 100644 --- a/zone/perl_client.cpp +++ b/zone/perl_client.cpp @@ -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, "$$"); diff --git a/zone/spells.cpp b/zone/spells.cpp index e14d100ce..ea0f15c22 100644 --- a/zone/spells.cpp +++ b/zone/spells.cpp @@ -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; + } + } +}