diff --git a/zone/embparser.cpp b/zone/embparser.cpp index cdf4e5735..ff917c3e3 100644 --- a/zone/embparser.cpp +++ b/zone/embparser.cpp @@ -670,11 +670,11 @@ int PerlembParser::SendCommands(const char *pkgprefix, const char *event, uint32 ret_value = perl->dosub(std::string(pkgprefix).append("::").append(event).c_str()); #ifdef EMBPERL_XS_CLASSES - std::string eval_str = (std::string)"$" + (std::string)pkgprefix + (std::string)"::client = undef;"; - eval_str += (std::string)"$" + (std::string)pkgprefix + (std::string)"::npc = undef;"; - eval_str += (std::string)"$" + (std::string)pkgprefix + (std::string)"::questitem = undef;"; - eval_str += (std::string)"$" + (std::string)pkgprefix + (std::string)"::entity_list = undef;"; - perl->eval(eval_str.c_str()); +// std::string eval_str = (std::string)"$" + (std::string)pkgprefix + (std::string)"::client = undef;"; +// eval_str += (std::string)"$" + (std::string)pkgprefix + (std::string)"::npc = undef;"; +// eval_str += (std::string)"$" + (std::string)pkgprefix + (std::string)"::questitem = undef;"; +// eval_str += (std::string)"$" + (std::string)pkgprefix + (std::string)"::entity_list = undef;"; +// perl->eval(eval_str.c_str()); #endif } catch(const char * err) { @@ -687,7 +687,8 @@ int PerlembParser::SendCommands(const char *pkgprefix, const char *event, uint32 error += "::"; error += event; error += " - "; - error += err; + if(strlen(err) > 0) + error += err; AddError(error); } } diff --git a/zone/lua_general.cpp b/zone/lua_general.cpp index cca71641e..c6e551d85 100644 --- a/zone/lua_general.cpp +++ b/zone/lua_general.cpp @@ -168,14 +168,38 @@ void lua_set_timer(const char *timer, int time_ms) { quest_manager.settimerMS(timer, time_ms); } +void lua_set_timer(const char *timer, int time_ms, Lua_ItemInst inst) { + quest_manager.settimerMS(timer, time_ms, inst); +} + +void lua_set_timer(const char *timer, int time_ms, Lua_Mob mob) { + quest_manager.settimerMS(timer, time_ms, mob); +} + void lua_stop_timer(const char *timer) { quest_manager.stoptimer(timer); } +void lua_stop_timer(const char *timer, Lua_ItemInst inst) { + quest_manager.stoptimer(timer, inst); +} + +void lua_stop_timer(const char *timer, Lua_Mob mob) { + quest_manager.stoptimer(timer, mob); +} + void lua_stop_all_timers() { quest_manager.stopalltimers(); } +void lua_stop_all_timers(Lua_ItemInst inst) { + quest_manager.stopalltimers(inst); +} + +void lua_stop_all_timers(Lua_Mob mob) { + quest_manager.stopalltimers(mob); +} + void lua_depop() { quest_manager.depop(0); } @@ -1099,9 +1123,15 @@ 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("set_timer", &lua_set_timer), - luabind::def("stop_timer", &lua_stop_timer), - luabind::def("stop_all_timers", &lua_stop_all_timers), + 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), + luabind::def("stop_timer", (void(*)(const char*))&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_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_Mob))&lua_stop_all_timers), luabind::def("depop", (void(*)(void))&lua_depop), luabind::def("depop", (void(*)(int))&lua_depop), luabind::def("depop_with_timer", (void(*)(void))&lua_depop_with_timer), diff --git a/zone/questmgr.cpp b/zone/questmgr.cpp index 3d51cf6c6..4e5ceb1da 100644 --- a/zone/questmgr.cpp +++ b/zone/questmgr.cpp @@ -484,6 +484,29 @@ void QuestManager::settimerMS(const char *timer_name, int milliseconds) { QTimerList.push_back(QuestTimer(milliseconds, owner, timer_name)); } +void QuestManager::settimerMS(const char *timer_name, int milliseconds, ItemInst *inst) { + if (inst) { + inst->SetTimer(timer_name, milliseconds); + } +} + +void QuestManager::settimerMS(const char *timer_name, int milliseconds, Mob *mob) { + std::list::iterator cur = QTimerList.begin(), end; + + end = QTimerList.end(); + while (cur != end) { + if (cur->mob && cur->mob == mob && cur->name == timer_name) + { + cur->Timer_.Enable(); + cur->Timer_.Start(milliseconds, false); + return; + } + ++cur; + } + + QTimerList.push_back(QuestTimer(milliseconds, mob, timer_name)); +} + void QuestManager::stoptimer(const char *timer_name) { QuestManagerCurrentQuestVars(); @@ -504,6 +527,25 @@ void QuestManager::stoptimer(const char *timer_name) { } } +void QuestManager::stoptimer(const char *timer_name, ItemInst *inst) { + if (inst) { + inst->StopTimer(timer_name); + } +} + +void QuestManager::stoptimer(const char *timer_name, Mob *mob) { + std::list::iterator cur = QTimerList.begin(), end; + + end = QTimerList.end(); + while (cur != end) { + if (cur->mob && cur->mob == mob && cur->name == timer_name) { + QTimerList.erase(cur); + return; + } + ++cur; + } +} + void QuestManager::stopalltimers() { QuestManagerCurrentQuestVars(); @@ -523,6 +565,24 @@ void QuestManager::stopalltimers() { } } +void QuestManager::stopalltimers(ItemInst *inst) { + if (inst) { + inst->ClearTimers(); + } +} + +void QuestManager::stopalltimers(Mob *mob) { + std::list::iterator cur = QTimerList.begin(), end, tmp; + + end = QTimerList.end(); + while (cur != end) { + if (cur->mob && cur->mob == mob) + cur = QTimerList.erase(cur); + else + ++cur; + } +} + void QuestManager::emote(const char *str) { QuestManagerCurrentQuestVars(); if (!owner) { diff --git a/zone/questmgr.h b/zone/questmgr.h index 86568349c..ca74e938a 100644 --- a/zone/questmgr.h +++ b/zone/questmgr.h @@ -66,9 +66,15 @@ public: void addloot(int item_id, int charges = 0, bool equipitem = true); void Zone(const char *zone_name); void settimer(const char *timer_name, int seconds); - void settimerMS(const char *timer_name, int milliseconds); + void settimerMS(const char *timer_name, int milliseconds); + void settimerMS(const char *timer_name, int milliseconds, ItemInst *inst); + void settimerMS(const char *timer_name, int milliseconds, Mob *mob); void stoptimer(const char *timer_name); + void stoptimer(const char *timer_name, ItemInst *inst); + void stoptimer(const char *timer_name, Mob *mob); void stopalltimers(); + void stopalltimers(ItemInst *inst); + void stopalltimers(Mob *mob); void emote(const char *str); void shout(const char *str); void shout2(const char *str);