-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathitemupdates.lua
151 lines (135 loc) · 4.86 KB
/
itemupdates.lua
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
function updateProgressiveBow(segment)
local item = Tracker:FindObjectForCode("bow")
local prevActive = item.Active
local data = { nil, nil, nil }
if segment:ContainsAddress(0x7ef340) then
data[1] = segment:ReadUInt8(0x7ef340)
data[2] = AutoTracker:ReadU8(0x7ef38e, 0)
data[3] = AutoTracker:ReadU8(0x7ef377, 0)
elseif segment:ContainsAddress(0x7ef38e) then
data[1] = AutoTracker:ReadU8(0x7ef340, 0)
data[2] = segment:ReadUInt8(0x7ef38e)
data[3] = AutoTracker:ReadU8(0x7ef377, 0)
elseif segment:ContainsAddress(0x7ef377) then
data[1] = AutoTracker:ReadU8(0x7ef340, 0)
data[2] = AutoTracker:ReadU8(0x7ef38e, 0)
data[3] = segment:ReadUInt8(0x7ef377)
end
if Tracker.ActiveVariantUID == "vanilla" then
if data[1] > 2 then
item.Active = true
item.CurrentStage = 2
elseif data[1] > 0 then
item.Active = true
item.CurrentStage = 1
else
item.Active = false
item.CurrentStage = 0
end
else
if data[2] & 0x80 > 0 and data[1] > 0 then
item.Active = true
elseif not item.Active or not STATUS.AutotrackerInGame then
item.Active = false
end
if data[2] & 0x40 > 0 then
if OBJ_RETRO:getState() > 0 and data[3] == 0 then
item.CurrentStage = 0
else
item.CurrentStage = 2
end
elseif OBJ_RETRO:getState() == 0 or (OBJ_RETRO:getState() > 0 and data[3] == 0) then
item.CurrentStage = 0
else
item.CurrentStage = 1
end
end
if not prevActive and item.Active then
itemFlippedOn("bow")
end
end
function updateProgressiveMirror(segment)
local item = Tracker:FindObjectForCode("mirror")
if segment:ReadUInt8(0x7ef353) & 0x02 > 0 then
if item.CurrentStage ~= 2 then
itemFlippedOn("mirror")
end
item.CurrentStage = 2
else
item.CurrentStage = (segment:ReadUInt8(0x7ef353) + 1) % 2
end
end
function updateFlute(segment)
local item = Tracker:FindObjectForCode("flute")
if Tracker.ActiveVariantUID == "vanilla" then
print("NO FLUTE HERE")
item.Active = segment:ReadUInt8(0x7ef34c) > 1
else
local value = 0
if segment:ContainsAddress(0x7ef38c) then
value = segment:ReadUInt8(0x7ef38c)
else
value = AutoTracker:ReadU8(0x7ef38c, 0)
end
local fakeFlute = value & 0x02
local realFlute = value & 0x01
if realFlute ~= 0 then
if item.CurrentStage == 0 then
itemFlippedOn("flute2")
end
item.Active = true
item.CurrentStage = 1
elseif fakeFlute ~= 0 then
if not item.Active then
itemFlippedOn("flute")
end
item.Active = true
item.CurrentStage = 0
elseif not item.Active or not STATUS.AutotrackerInGame then
item.Active = false
end
end
end
function updateBottles(segment)
for i = 0, 3, 1 do
local item = Tracker:FindObjectForCode("bottle"..i)
local contents = segment:ReadUInt8(0x7ef35c + i)
if contents == 0 then
item.CurrentStage = 0
else
item.CurrentStage = contents - 1
end
end
end
function updateBatIndicatorStatus(status)
local item = Tracker:FindObjectForCode("powder_used")
if item and (not item.Active or not STATUS.AutotrackerInGame) then
item.Active = status
end
end
function updateShovelIndicatorStatus(status)
local item = Tracker:FindObjectForCode("shovel_used")
if item and (not item.Active or not STATUS.AutotrackerInGame) then
item.Active = status
end
end
function doStatsMessage()
function read32BitTimer(baseAddress)
local timer = 0
timer = timer | (AutoTracker:ReadU8(baseAddress + 3, 0) << 24)
timer = timer | (AutoTracker:ReadU8(baseAddress + 2, 0) << 16)
timer = timer | (AutoTracker:ReadU8(baseAddress + 1, 0) << 8)
timer = timer | (AutoTracker:ReadU8(baseAddress + 0, 0) << 0)
local hours = timer // (60 * 60 * 60)
local minutes = (timer % (60 * 60 * 60)) // (60 * 60)
local seconds = (timer % (60 * 60)) // (60)
local frames = timer % 60
return hours, minutes, seconds, frames
end
-- Read completion timer
local hours, minutes, seconds, frames = read32BitTimer(0x7ef43e)
local deaths = AutoTracker:ReadU8(0x7ef449, 0)
local bonks = AutoTracker:ReadU8(0x7ef420, 0)
local markdown = string.format(DATA.StatsMarkdownFormat, CACHE.CollectionRate, math.max(CACHE.CollectionMax, 216), deaths, bonks, hours, minutes, seconds, frames)
ScriptHost:PushMarkdownNotification(NotificationType.Celebration, markdown)
end