mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-13 18:51:29 +00:00
[Tasks] Add pre-task update event (#2512)
This adds the player EVENT_TASK_BEFORE_UPDATE event which will allow quests to prevent a source controlled task update by returning non-zero.
This commit is contained in:
parent
43ec9dc815
commit
444a4f6744
@ -160,6 +160,7 @@ const char *QuestEventSubroutines[_LargestEventID] = {
|
|||||||
"EVENT_MERCHANT_BUY",
|
"EVENT_MERCHANT_BUY",
|
||||||
"EVENT_MERCHANT_SELL",
|
"EVENT_MERCHANT_SELL",
|
||||||
"EVENT_INSPECT",
|
"EVENT_INSPECT",
|
||||||
|
"EVENT_TASK_BEFORE_UPDATE",
|
||||||
};
|
};
|
||||||
|
|
||||||
PerlembParser::PerlembParser() : perl(nullptr)
|
PerlembParser::PerlembParser() : perl(nullptr)
|
||||||
@ -1465,6 +1466,7 @@ void PerlembParser::ExportEventVariables(
|
|||||||
}
|
}
|
||||||
|
|
||||||
case EVENT_TASK_COMPLETE:
|
case EVENT_TASK_COMPLETE:
|
||||||
|
case EVENT_TASK_BEFORE_UPDATE:
|
||||||
case EVENT_TASK_UPDATE: {
|
case EVENT_TASK_UPDATE: {
|
||||||
Seperator sep(data);
|
Seperator sep(data);
|
||||||
ExportVar(package_name.c_str(), "donecount", sep.arg[0]);
|
ExportVar(package_name.c_str(), "donecount", sep.arg[0]);
|
||||||
|
|||||||
@ -103,6 +103,7 @@ typedef enum {
|
|||||||
EVENT_MERCHANT_BUY,
|
EVENT_MERCHANT_BUY,
|
||||||
EVENT_MERCHANT_SELL,
|
EVENT_MERCHANT_SELL,
|
||||||
EVENT_INSPECT,
|
EVENT_INSPECT,
|
||||||
|
EVENT_TASK_BEFORE_UPDATE,
|
||||||
_LargestEventID
|
_LargestEventID
|
||||||
} QuestEventID;
|
} QuestEventID;
|
||||||
|
|
||||||
|
|||||||
@ -4307,7 +4307,8 @@ luabind::scope lua_register_events() {
|
|||||||
luabind::value("alt_currency_merchant_sell", static_cast<int>(EVENT_ALT_CURRENCY_MERCHANT_SELL)),
|
luabind::value("alt_currency_merchant_sell", static_cast<int>(EVENT_ALT_CURRENCY_MERCHANT_SELL)),
|
||||||
luabind::value("merchant_buy", static_cast<int>(EVENT_MERCHANT_BUY)),
|
luabind::value("merchant_buy", static_cast<int>(EVENT_MERCHANT_BUY)),
|
||||||
luabind::value("merchant_sell", static_cast<int>(EVENT_MERCHANT_SELL)),
|
luabind::value("merchant_sell", static_cast<int>(EVENT_MERCHANT_SELL)),
|
||||||
luabind::value("inspect", static_cast<int>(EVENT_INSPECT))
|
luabind::value("inspect", static_cast<int>(EVENT_INSPECT)),
|
||||||
|
luabind::value("task_before_update", static_cast<int>(EVENT_TASK_BEFORE_UPDATE))
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -147,6 +147,7 @@ const char *LuaEvents[_LargestEventID] = {
|
|||||||
"event_merchant_buy",
|
"event_merchant_buy",
|
||||||
"event_merchant_sell",
|
"event_merchant_sell",
|
||||||
"event_inspect",
|
"event_inspect",
|
||||||
|
"event_task_before_update",
|
||||||
};
|
};
|
||||||
|
|
||||||
extern Zone *zone;
|
extern Zone *zone;
|
||||||
@ -222,6 +223,7 @@ LuaParser::LuaParser() {
|
|||||||
PlayerArgumentDispatch[EVENT_TASK_STAGE_COMPLETE] = handle_player_task_stage_complete;
|
PlayerArgumentDispatch[EVENT_TASK_STAGE_COMPLETE] = handle_player_task_stage_complete;
|
||||||
PlayerArgumentDispatch[EVENT_TASK_COMPLETE] = handle_player_task_update;
|
PlayerArgumentDispatch[EVENT_TASK_COMPLETE] = handle_player_task_update;
|
||||||
PlayerArgumentDispatch[EVENT_TASK_UPDATE] = handle_player_task_update;
|
PlayerArgumentDispatch[EVENT_TASK_UPDATE] = handle_player_task_update;
|
||||||
|
PlayerArgumentDispatch[EVENT_TASK_BEFORE_UPDATE] = handle_player_task_update;
|
||||||
PlayerArgumentDispatch[EVENT_COMMAND] = handle_player_command;
|
PlayerArgumentDispatch[EVENT_COMMAND] = handle_player_command;
|
||||||
PlayerArgumentDispatch[EVENT_COMBINE_SUCCESS] = handle_player_combine;
|
PlayerArgumentDispatch[EVENT_COMBINE_SUCCESS] = handle_player_combine;
|
||||||
PlayerArgumentDispatch[EVENT_COMBINE_FAILURE] = handle_player_combine;
|
PlayerArgumentDispatch[EVENT_COMBINE_FAILURE] = handle_player_combine;
|
||||||
|
|||||||
@ -564,6 +564,15 @@ int ClientTaskState::UpdateTasks(Client* client, const TaskUpdateFilter& filter,
|
|||||||
|
|
||||||
if (CanUpdate(client, filter, client_task.task_id, activity, client_activity))
|
if (CanUpdate(client, filter, client_task.task_id, activity, client_activity))
|
||||||
{
|
{
|
||||||
|
auto args = fmt::format("{} {} {}", count, client_activity.activity_id, client_task.task_id);
|
||||||
|
if (parse->EventPlayer(EVENT_TASK_BEFORE_UPDATE, client, args, 0) != 0)
|
||||||
|
{
|
||||||
|
LogTasks("[UpdateTasks] client [{}] task [{}]-[{}] update prevented by quest",
|
||||||
|
client->GetName(), client_task.task_id, client_activity.activity_id);
|
||||||
|
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
LogTasks("[UpdateTasks] client [{}] task [{}] activity [{}] increment [{}]",
|
LogTasks("[UpdateTasks] client [{}] task [{}] activity [{}] increment [{}]",
|
||||||
client->GetName(), client_task.task_id, client_activity.activity_id, count);
|
client->GetName(), client_task.task_id, client_activity.activity_id, count);
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user