mirror of
https://github.com/EQEmu/Server.git
synced 2026-05-17 03:08:26 +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:
@@ -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) {
|
||||
QuestManagerCurrentQuestVars();
|
||||
if (!owner) {
|
||||
|
||||
Reference in New Issue
Block a user