mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-11 16:51:29 +00:00
[API] Methods for getting more information on quest timers. (#2060)
* hastimer * [API] Check quest timer duration, timer remaining and if timer exists. * [API] Methods for getting more information on quest timers. * [API] Methods for getting more information on quest timers. * [API] Methods for getting more information on quest timers.
This commit is contained in:
parent
bb897b755f
commit
bc875ae554
@ -590,6 +590,56 @@ XS(XS__zoneraid) {
|
||||
XSRETURN_EMPTY;
|
||||
}
|
||||
|
||||
XS(XS__hastimer);
|
||||
XS(XS__hastimer) {
|
||||
dXSARGS;
|
||||
if (items != 1)
|
||||
Perl_croak(aTHX_ "Usage: quest::hastimer(string timer_name)");
|
||||
|
||||
bool RETVAL;
|
||||
char *timer_name = (char *)SvPV_nolen(ST(0));
|
||||
|
||||
RETVAL = quest_manager.hastimer(timer_name);
|
||||
|
||||
ST(0) = boolSV(RETVAL);
|
||||
sv_2mortal(ST(0));
|
||||
XSRETURN(1);
|
||||
}
|
||||
|
||||
XS(XS__getremainingtimeMS);
|
||||
XS(XS__getremainingtimeMS) {
|
||||
dXSARGS;
|
||||
if (items != 1)
|
||||
Perl_croak(aTHX_ "Usage: quest::getremainingtimeMS(string timer_name)");
|
||||
|
||||
uint32 RETVAL;
|
||||
dXSTARG;
|
||||
char *timer_name = (char *)SvPV_nolen(ST(0));
|
||||
|
||||
RETVAL = quest_manager.getremainingtimeMS(timer_name);
|
||||
|
||||
XSprePUSH;
|
||||
PUSHu((IV)RETVAL);
|
||||
XSRETURN(1);
|
||||
}
|
||||
|
||||
XS(XS__gettimerdurationMS);
|
||||
XS(XS__gettimerdurationMS) {
|
||||
dXSARGS;
|
||||
if (items != 1)
|
||||
Perl_croak(aTHX_ "Usage: quest::gettimerdurationMS(string timer_name)");
|
||||
|
||||
uint32 RETVAL;
|
||||
dXSTARG;
|
||||
char *timer_name = (char *)SvPV_nolen(ST(0));
|
||||
|
||||
RETVAL = quest_manager.gettimerdurationMS(timer_name);
|
||||
|
||||
XSprePUSH;
|
||||
PUSHu((IV)RETVAL);
|
||||
XSRETURN(1);
|
||||
}
|
||||
|
||||
XS(XS__settimer);
|
||||
XS(XS__settimer) {
|
||||
dXSARGS;
|
||||
@ -8439,6 +8489,7 @@ EXTERN_C XS(boot_quest) {
|
||||
newXS(strcpy(buf, "getinventoryslotname"), XS__getinventoryslotname, file);
|
||||
newXS(strcpy(buf, "getraididbycharid"), XS__getraididbycharid, file);
|
||||
newXS(strcpy(buf, "getracename"), XS__getracename, file);
|
||||
newXS(strcpy(buf, "getremainingtimeMS"), XS__getremainingtimeMS, file);
|
||||
newXS(strcpy(buf, "getspell"), XS__getspell, file);
|
||||
newXS(strcpy(buf, "getspellname"), XS__getspellname, file);
|
||||
newXS(strcpy(buf, "get_spell_level"), XS__get_spell_level, file);
|
||||
@ -8450,10 +8501,12 @@ EXTERN_C XS(boot_quest) {
|
||||
newXS(strcpy(buf, "getplayercorpsecountbyzoneid"), XS__getplayercorpsecountbyzoneid, file);
|
||||
newXS(strcpy(buf, "gettaskactivitydonecount"), XS__gettaskactivitydonecount, file);
|
||||
newXS(strcpy(buf, "gettaskname"), XS__gettaskname, file);
|
||||
newXS(strcpy(buf, "gettimerdurationMS"), XS__gettimerdurationMS, file);
|
||||
newXS(strcpy(buf, "givecash"), XS__givecash, file);
|
||||
newXS(strcpy(buf, "gmmove"), XS__gmmove, file);
|
||||
newXS(strcpy(buf, "gmsay"), XS__gmsay, file);
|
||||
newXS(strcpy(buf, "has_zone_flag"), XS__has_zone_flag, file);
|
||||
newXS(strcpy(buf, "hastimer"), XS__hastimer, file);
|
||||
newXS(strcpy(buf, "incstat"), XS__incstat, file);
|
||||
newXS(strcpy(buf, "isdisctome"), XS__isdisctome, file);
|
||||
newXS(strcpy(buf, "isdooropen"), XS__isdooropen, file);
|
||||
|
||||
@ -361,6 +361,18 @@ bool lua_is_paused_timer(const char *timer) {
|
||||
return quest_manager.ispausedtimer(timer);
|
||||
}
|
||||
|
||||
bool lua_has_timer(const char *timer) {
|
||||
return quest_manager.hastimer(timer);
|
||||
}
|
||||
|
||||
uint32 lua_get_remaining_time(const char *timer) {
|
||||
return quest_manager.getremainingtimeMS(timer);
|
||||
}
|
||||
|
||||
uint32 lua_get_timer_duration(const char *timer) {
|
||||
return quest_manager.gettimerdurationMS(timer);
|
||||
}
|
||||
|
||||
void lua_depop() {
|
||||
quest_manager.depop(0);
|
||||
}
|
||||
@ -3583,6 +3595,9 @@ luabind::scope lua_register_general() {
|
||||
luabind::def("spawn_from_spawn2", (Lua_Mob(*)(uint32))&lua_spawn_from_spawn2),
|
||||
luabind::def("enable_spawn2", &lua_enable_spawn2),
|
||||
luabind::def("disable_spawn2", &lua_disable_spawn2),
|
||||
luabind::def("has_timer", (bool(*)(const char*))&lua_has_timer),
|
||||
luabind::def("get_remaining_time", (uint32(*)(const char*))&lua_get_remaining_time),
|
||||
luabind::def("get_timer_duration", (uint32(*)(const char*))&lua_get_timer_duration),
|
||||
luabind::def("set_timer", (void(*)(const char*, int))&lua_set_timer),
|
||||
luabind::def("set_timer", (void(*)(const char*, int, Lua_ItemInst))&lua_set_timer),
|
||||
luabind::def("set_timer", (void(*)(const char*, int, Lua_Mob))&lua_set_timer),
|
||||
|
||||
@ -683,6 +683,66 @@ bool QuestManager::ispausedtimer(const char *timer_name) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool QuestManager::hastimer(const char *timer_name) {
|
||||
QuestManagerCurrentQuestVars();
|
||||
|
||||
std::list<QuestTimer>::iterator cur = QTimerList.begin(), end;
|
||||
|
||||
end = QTimerList.end();
|
||||
while (cur != end)
|
||||
{
|
||||
if (cur->mob && cur->mob == owner && cur->name == timer_name)
|
||||
{
|
||||
if (cur->Timer_.Enabled())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
++cur;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
uint32 QuestManager::getremainingtimeMS(const char *timer_name) {
|
||||
QuestManagerCurrentQuestVars();
|
||||
|
||||
std::list<QuestTimer>::iterator cur = QTimerList.begin(), end;
|
||||
|
||||
end = QTimerList.end();
|
||||
while (cur != end)
|
||||
{
|
||||
if (cur->mob && cur->mob == owner && cur->name == timer_name)
|
||||
{
|
||||
if (cur->Timer_.Enabled())
|
||||
{
|
||||
return cur->Timer_.GetRemainingTime();
|
||||
}
|
||||
}
|
||||
++cur;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint32 QuestManager::gettimerdurationMS(const char *timer_name) {
|
||||
QuestManagerCurrentQuestVars();
|
||||
|
||||
std::list<QuestTimer>::iterator cur = QTimerList.begin(), end;
|
||||
|
||||
end = QTimerList.end();
|
||||
while (cur != end)
|
||||
{
|
||||
if (cur->mob && cur->mob == owner && cur->name == timer_name)
|
||||
{
|
||||
if (cur->Timer_.Enabled())
|
||||
{
|
||||
return cur->Timer_.GetDuration();
|
||||
}
|
||||
}
|
||||
++cur;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void QuestManager::emote(const char *str) {
|
||||
QuestManagerCurrentQuestVars();
|
||||
if (!owner) {
|
||||
|
||||
@ -94,6 +94,9 @@ public:
|
||||
void pausetimer(const char *timer_name);
|
||||
void resumetimer(const char *timer_name);
|
||||
bool ispausedtimer(const char *timer_name);
|
||||
bool hastimer(const char *timer_name);
|
||||
uint32 getremainingtimeMS(const char *timer_name);
|
||||
uint32 gettimerdurationMS(const char *timer_name);
|
||||
void emote(const char *str);
|
||||
void shout(const char *str);
|
||||
void shout2(const char *str);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user