mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-12 09:31:30 +00:00
Implemented lua methods eq.pause_timer("timername") and eq.resume_tim…
…er("timername"). This allows developers to pause and resume the given timer on the current NPC.
Added lua method eq.is_paused_timer("timername") to check to see if y…
…ou have a paused timer or not. Example usage:
if(eq.is_paused_timer("test"))then
e.self:Say("You have a paused timer.");
else
e.self:Say("You do not have a paused timer.");
end
(credit goes to Cavedude)
This commit is contained in:
parent
7d99becca9
commit
f7fe10fc98
@ -341,6 +341,19 @@ void lua_stop_all_timers(Lua_Encounter enc) {
|
|||||||
quest_manager.stopalltimers(enc);
|
quest_manager.stopalltimers(enc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void lua_pause_timer(const char *timer) {
|
||||||
|
quest_manager.pausetimer(timer);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void lua_resume_timer(const char *timer) {
|
||||||
|
quest_manager.resumetimer(timer);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool lua_is_paused_timer(const char *timer) {
|
||||||
|
return quest_manager.ispausedtimer(timer);
|
||||||
|
}
|
||||||
|
|
||||||
void lua_depop() {
|
void lua_depop() {
|
||||||
quest_manager.depop(0);
|
quest_manager.depop(0);
|
||||||
}
|
}
|
||||||
@ -1543,6 +1556,9 @@ luabind::scope lua_register_general() {
|
|||||||
luabind::def("stop_timer", (void(*)(const char*, Lua_ItemInst))&lua_stop_timer),
|
luabind::def("stop_timer", (void(*)(const char*, Lua_ItemInst))&lua_stop_timer),
|
||||||
luabind::def("stop_timer", (void(*)(const char*, Lua_Mob))&lua_stop_timer),
|
luabind::def("stop_timer", (void(*)(const char*, Lua_Mob))&lua_stop_timer),
|
||||||
luabind::def("stop_timer", (void(*)(const char*, Lua_Encounter))&lua_stop_timer),
|
luabind::def("stop_timer", (void(*)(const char*, Lua_Encounter))&lua_stop_timer),
|
||||||
|
luabind::def("pause_timer", (void(*)(const char*))&lua_pause_timer),
|
||||||
|
luabind::def("resume_timer", (void(*)(const char*))&lua_resume_timer),
|
||||||
|
luabind::def("is_paused_timer", (bool(*)(const char*))&lua_is_paused_timer),
|
||||||
luabind::def("stop_all_timers", (void(*)(void))&lua_stop_all_timers),
|
luabind::def("stop_all_timers", (void(*)(void))&lua_stop_all_timers),
|
||||||
luabind::def("stop_all_timers", (void(*)(Lua_ItemInst))&lua_stop_all_timers),
|
luabind::def("stop_all_timers", (void(*)(Lua_ItemInst))&lua_stop_all_timers),
|
||||||
luabind::def("stop_all_timers", (void(*)(Lua_Mob))&lua_stop_all_timers),
|
luabind::def("stop_all_timers", (void(*)(Lua_Mob))&lua_stop_all_timers),
|
||||||
|
|||||||
@ -555,6 +555,107 @@ void QuestManager::stopalltimers(Mob *mob) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void QuestManager::pausetimer(const char *timer_name) {
|
||||||
|
QuestManagerCurrentQuestVars();
|
||||||
|
|
||||||
|
std::list<QuestTimer>::iterator cur = QTimerList.begin(), end;
|
||||||
|
std::list<PausedTimer>::iterator pcur = PTimerList.begin(), pend;
|
||||||
|
PausedTimer pt;
|
||||||
|
uint32 milliseconds = 0;
|
||||||
|
|
||||||
|
pend = PTimerList.end();
|
||||||
|
while (pcur != pend)
|
||||||
|
{
|
||||||
|
if (pcur->owner && pcur->owner == owner && pcur->name == timer_name)
|
||||||
|
{
|
||||||
|
Log(Logs::General, Logs::Quests, "Timer %s is already paused for %s. Returning...", timer_name, owner->GetName());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
++pcur;
|
||||||
|
}
|
||||||
|
|
||||||
|
end = QTimerList.end();
|
||||||
|
while (cur != end)
|
||||||
|
{
|
||||||
|
if (cur->mob && cur->mob == owner && cur->name == timer_name)
|
||||||
|
{
|
||||||
|
milliseconds = cur->Timer_.GetRemainingTime();
|
||||||
|
QTimerList.erase(cur);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
++cur;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string timername = timer_name;
|
||||||
|
pt.name = timername;
|
||||||
|
pt.owner = owner;
|
||||||
|
pt.time = milliseconds;
|
||||||
|
Log(Logs::General, Logs::Quests, "Pausing timer %s for %s with %d ms remaining.", timer_name, owner->GetName(), milliseconds);
|
||||||
|
PTimerList.push_back(pt);
|
||||||
|
}
|
||||||
|
|
||||||
|
void QuestManager::resumetimer(const char *timer_name) {
|
||||||
|
QuestManagerCurrentQuestVars();
|
||||||
|
|
||||||
|
std::list<QuestTimer>::iterator cur = QTimerList.begin(), end;
|
||||||
|
std::list<PausedTimer>::iterator pcur = PTimerList.begin(), pend;
|
||||||
|
PausedTimer pt;
|
||||||
|
uint32 milliseconds = 0;
|
||||||
|
|
||||||
|
pend = PTimerList.end();
|
||||||
|
while (pcur != pend)
|
||||||
|
{
|
||||||
|
if (pcur->owner && pcur->owner == owner && pcur->name == timer_name)
|
||||||
|
{
|
||||||
|
milliseconds = pcur->time;
|
||||||
|
PTimerList.erase(pcur);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
++pcur;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (milliseconds == 0)
|
||||||
|
{
|
||||||
|
Log(Logs::General, Logs::Quests, "Paused timer %s not found or has expired. Returning...", timer_name);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
end = QTimerList.end();
|
||||||
|
while (cur != end)
|
||||||
|
{
|
||||||
|
if (cur->mob && cur->mob == owner && cur->name == timer_name)
|
||||||
|
{
|
||||||
|
cur->Timer_.Enable();
|
||||||
|
cur->Timer_.Start(milliseconds, false);
|
||||||
|
Log(Logs::General, Logs::Quests, "Resuming timer %s for %s with %d ms remaining.", timer_name, owner->GetName(), milliseconds);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
++cur;
|
||||||
|
}
|
||||||
|
|
||||||
|
QTimerList.push_back(QuestTimer(milliseconds, owner, timer_name));
|
||||||
|
Log(Logs::General, Logs::Quests, "Creating a new timer and resuming %s for %s with %d ms remaining.", timer_name, owner->GetName(), milliseconds);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
bool QuestManager::ispausedtimer(const char *timer_name) {
|
||||||
|
QuestManagerCurrentQuestVars();
|
||||||
|
|
||||||
|
std::list<PausedTimer>::iterator pcur = PTimerList.begin(), pend;
|
||||||
|
|
||||||
|
pend = PTimerList.end();
|
||||||
|
while (pcur != pend)
|
||||||
|
{
|
||||||
|
if (pcur->owner && pcur->owner == owner && pcur->name == timer_name)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
++pcur;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
void QuestManager::emote(const char *str) {
|
void QuestManager::emote(const char *str) {
|
||||||
QuestManagerCurrentQuestVars();
|
QuestManagerCurrentQuestVars();
|
||||||
if (!owner) {
|
if (!owner) {
|
||||||
|
|||||||
@ -41,6 +41,12 @@ class QuestManager {
|
|||||||
bool depop_npc;
|
bool depop_npc;
|
||||||
std::string encounter;
|
std::string encounter;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct PausedTimer {
|
||||||
|
Mob * owner;
|
||||||
|
std::string name;
|
||||||
|
uint32 time;
|
||||||
|
};
|
||||||
public:
|
public:
|
||||||
QuestManager();
|
QuestManager();
|
||||||
virtual ~QuestManager();
|
virtual ~QuestManager();
|
||||||
@ -82,6 +88,9 @@ public:
|
|||||||
void stopalltimers();
|
void stopalltimers();
|
||||||
void stopalltimers(EQEmu::ItemInstance *inst);
|
void stopalltimers(EQEmu::ItemInstance *inst);
|
||||||
void stopalltimers(Mob *mob);
|
void stopalltimers(Mob *mob);
|
||||||
|
void pausetimer(const char *timer_name);
|
||||||
|
void resumetimer(const char *timer_name);
|
||||||
|
bool ispausedtimer(const char *timer_name);
|
||||||
void emote(const char *str);
|
void emote(const char *str);
|
||||||
void shout(const char *str);
|
void shout(const char *str);
|
||||||
void shout2(const char *str);
|
void shout2(const char *str);
|
||||||
@ -304,6 +313,7 @@ private:
|
|||||||
};
|
};
|
||||||
std::list<QuestTimer> QTimerList;
|
std::list<QuestTimer> QTimerList;
|
||||||
std::list<SignalTimer> STimerList;
|
std::list<SignalTimer> STimerList;
|
||||||
|
std::list<PausedTimer> PTimerList;
|
||||||
size_t item_timers;
|
size_t item_timers;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user