ESO Lua File v100010

ingame/scriptedworldevents/scriptedworldevents.lua

[◄ back to folders ]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
local function ExpandSimpleTextParams(data, timeLeft)
    return { data.eventName, timeLeft }
end
local function ExpandNamedTextParams(data, timeLeft)
    return { data.eventInviter, data.eventName, timeLeft}
end
local function ExpandSimpleQuestTextParams(data, timeLeft)
    return { data.eventName, data.questName, timeLeft }
end
local function ExpandNamedQuestTextParams(data, timeLeft)
    return { data.eventInviter, data.eventName, data.questName, timeLeft }
end
    ZO_Dialogs_ShowDialog(name, data, { mainTextParams = textParamExpandFunction(data, SCRIPTED_WORLD_EVENT_TIMEOUT_MS) })
end
local function ShowEventDialog(data)
    if GetFrameTimeMilliseconds() > data.inviteEnds then
        return -- no longer a valid event
    end
    if data.eventInviter == "" then
        if data.questName == "" then
            ShowDialog("SCRIPTED_WORLD_EVENT_INVITE", data, ExpandSimpleTextParams)
        else
            ShowDialog("SCRIPTED_WORLD_EVENT_INVITE_QUEST", data, ExpandSimpleQuestTextParams)
        end
    else
        if data.questName == "" then
            ShowDialog("SCRIPTED_WORLD_EVENT_INVITE_NAMED", data, ExpandNamedTextParams)
        else
            ShowDialog("SCRIPTED_WORLD_EVENT_INVITE_NAMED_QUEST", data, ExpandNamedQuestTextParams)
        end
    end
end
local g_queuedScriptedWorldEventInvite = nil
local function OnScriptedWorldEventInvite(eventCode, eventId, eventName, eventInviter, questName)
    local data = {
        eventInviter = eventInviter,
        eventName = eventName,
        eventId = eventId, 
        questName = questName,
        inviteEnds = SCRIPTED_WORLD_EVENT_TIMEOUT_MS + GetFrameTimeMilliseconds(),
    }
    if SYSTEMS:IsShowing("interact") then
        g_queuedScriptedWorldEventInvite = data
    else
        g_queuedScriptedWorldEventInvite = nil
        ShowEventDialog(data)
    end
end
    local interactScene = SCENE_MANAGER:GetScene("interact")
    local gamepadInteractScene = SCENE_MANAGER:GetScene("gamepadInteract")
    local function OnStateChange(oldState, newState)
        if newState == SCENE_HIDDEN then      
            if g_queuedScriptedWorldEventInvite then
                ShowEventDialog(g_queuedScriptedWorldEventInvite)
                g_queuedScriptedWorldEventInvite = nil
            end
        end
    end
    if interactScene then
        interactScene:RegisterCallback("StateChange", OnStateChange)
    end
    if gamepadInteractScene then
        gamepadInteractScene:RegisterCallback("StateChange", OnStateChange)
    end
    EVENT_MANAGER:RegisterForEvent("ZO_ScriptedWorldEvent", EVENT_SCRIPTED_WORLD_EVENT_INVITE, OnScriptedWorldEventInvite)
end