Merge pull request #1014 from EQEmu/gettaskname

Add gettaskname(task_id) to Perl/Lua.
This commit is contained in:
Chris Miles 2020-03-31 22:20:58 -05:00 committed by GitHub
commit 58b9b719f4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 46 additions and 0 deletions

View File

@ -2628,6 +2628,23 @@ XS(XS__istaskappropriate) {
XSRETURN(1); XSRETURN(1);
} }
XS(XS__gettaskname);
XS(XS__gettaskname) {
dXSARGS;
if (items != 1) {
Perl_croak(aTHX_ "Usage: quest::gettaskname(uint32 task_id)");
}
dXSTARG;
uint32 task_id = (int) SvIV(ST(0));
std::string task_name = quest_manager.gettaskname(task_id);
sv_setpv(TARG, task_name.c_str());
XSprePUSH;
PUSHTARG;
XSRETURN(1);
}
XS(XS__popup); // prototype to pass -Wmissing-prototypes XS(XS__popup); // prototype to pass -Wmissing-prototypes
XS(XS__popup) { XS(XS__popup) {
dXSARGS; dXSARGS;
@ -4049,6 +4066,7 @@ EXTERN_C XS(boot_quest) {
newXS(strcpy(buf, "getplayercorpsecount"), XS__getplayercorpsecount, file); newXS(strcpy(buf, "getplayercorpsecount"), XS__getplayercorpsecount, file);
newXS(strcpy(buf, "getplayercorpsecountbyzoneid"), XS__getplayercorpsecountbyzoneid, file); newXS(strcpy(buf, "getplayercorpsecountbyzoneid"), XS__getplayercorpsecountbyzoneid, file);
newXS(strcpy(buf, "gettaskactivitydonecount"), XS__gettaskactivitydonecount, file); newXS(strcpy(buf, "gettaskactivitydonecount"), XS__gettaskactivitydonecount, file);
newXS(strcpy(buf, "gettaskname"), XS__gettaskname, file);
newXS(strcpy(buf, "givecash"), XS__givecash, file); newXS(strcpy(buf, "givecash"), XS__givecash, file);
newXS(strcpy(buf, "gmmove"), XS__gmmove, file); newXS(strcpy(buf, "gmmove"), XS__gmmove, file);
newXS(strcpy(buf, "gmsay"), XS__gmsay, file); newXS(strcpy(buf, "gmsay"), XS__gmsay, file);

View File

@ -733,6 +733,10 @@ bool lua_is_task_appropriate(int task) {
return quest_manager.istaskappropriate(task); return quest_manager.istaskappropriate(task);
} }
std::string lua_get_task_name(uint32 task_id) {
return quest_manager.gettaskname(task_id);
}
void lua_popup(const char *title, const char *text, uint32 id, uint32 buttons, uint32 duration) { void lua_popup(const char *title, const char *text, uint32 id, uint32 buttons, uint32 duration) {
quest_manager.popup(title, text, id, buttons, duration); quest_manager.popup(title, text, id, buttons, duration);
} }
@ -1724,6 +1728,7 @@ luabind::scope lua_register_general() {
luabind::def("active_tasks_in_set", &lua_active_tasks_in_set), luabind::def("active_tasks_in_set", &lua_active_tasks_in_set),
luabind::def("completed_tasks_in_set", &lua_completed_tasks_in_set), luabind::def("completed_tasks_in_set", &lua_completed_tasks_in_set),
luabind::def("is_task_appropriate", &lua_is_task_appropriate), luabind::def("is_task_appropriate", &lua_is_task_appropriate),
luabind::def("get_task_name", (std::string(*)(uint32))&lua_get_task_name),
luabind::def("popup", &lua_popup), luabind::def("popup", &lua_popup),
luabind::def("clear_spawn_timers", &lua_clear_spawn_timers), luabind::def("clear_spawn_timers", &lua_clear_spawn_timers),
luabind::def("zone_emote", &lua_zone_emote), luabind::def("zone_emote", &lua_zone_emote),

View File

@ -2441,6 +2441,16 @@ bool QuestManager::istaskappropriate(int task) {
return false; return false;
} }
std::string QuestManager::gettaskname(uint32 task_id) {
QuestManagerCurrentQuestVars();
if (RuleB(TaskSystem, EnableTaskSystem)) {
return taskmanager->GetTaskName(task_id);
}
return std::string();
}
void QuestManager::clearspawntimers() { void QuestManager::clearspawntimers() {
if(!zone) if(!zone)
return; return;

View File

@ -214,6 +214,7 @@ public:
int activetasksinset(int taskset); int activetasksinset(int taskset);
int completedtasksinset(int taskset); int completedtasksinset(int taskset);
bool istaskappropriate(int task); bool istaskappropriate(int task);
std::string gettaskname(uint32 task_id);
void clearspawntimers(); void clearspawntimers();
void ze(int type, const char *str); void ze(int type, const char *str);
void we(int type, const char *str); void we(int type, const char *str);

View File

@ -955,6 +955,17 @@ bool TaskManager::AppropriateLevel(int TaskID, int PlayerLevel) {
} }
std::string TaskManager::GetTaskName(uint32 task_id)
{
if (task_id > 0 && task_id < MAXTASKS) {
if (Tasks[task_id] != nullptr) {
return Tasks[task_id]->Title;
}
}
return std::string();
}
int TaskManager::GetTaskMinLevel(int TaskID) int TaskManager::GetTaskMinLevel(int TaskID)
{ {
if (Tasks[TaskID]->MinLevel) if (Tasks[TaskID]->MinLevel)

View File

@ -299,6 +299,7 @@ public:
bool AppropriateLevel(int TaskID, int PlayerLevel); bool AppropriateLevel(int TaskID, int PlayerLevel);
int GetTaskMinLevel(int TaskID); int GetTaskMinLevel(int TaskID);
int GetTaskMaxLevel(int TaskID); int GetTaskMaxLevel(int TaskID);
std::string GetTaskName(uint32 task_id);
void TaskSetSelector(Client *c, ClientTaskState *state, Mob *mob, int TaskSetID); void TaskSetSelector(Client *c, ClientTaskState *state, Mob *mob, int TaskSetID);
void TaskQuestSetSelector(Client *c, ClientTaskState *state, Mob *mob, int count, int *tasks); // task list provided by QuestManager (perl/lua) void TaskQuestSetSelector(Client *c, ClientTaskState *state, Mob *mob, int count, int *tasks); // task list provided by QuestManager (perl/lua)
void SendActiveTasksToClient(Client *c, bool TaskComplete=false); void SendActiveTasksToClient(Client *c, bool TaskComplete=false);