Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-1-Sonic-2-2013-Script-Decompilation
Path: blob/master/Sonic 1/Scripts/MZ/LavaGeyser.txt
1480 views
1
// ----------------------------------
2
// RSDK Project: Sonic 1
3
// Script Description: Lava Geyser Object
4
// Script Author: Christian Whitehead/Simon Thomley
5
// Unpacked by Rubberduckycooly's script unpacker
6
// ----------------------------------
7
8
// ========================
9
// Aliases
10
// ========================
11
12
private alias object.value0 : object.timer
13
private alias object.value1 : object.drawPos.y
14
private alias object.value2 : object.eruptAnimTimer
15
private alias object.value3 : object.plumeFrame
16
private alias object.value4 : object.eruptFrame
17
18
private alias 0 : LAVAGEYSER_AWAITBLOCK
19
private alias 1 : LAVAGEYSER_STARTERUPT
20
private alias 2 : LAVAGEYSER_SHOWPLUME
21
private alias 3 : LAVAGEYSER_ERUPTING
22
private alias 4 : LAVAGEYSER_ERUPTED
23
private alias 5 : LAVAGEYSER_HANDLEFINISH
24
25
26
// ========================
27
// Function Declarations
28
// ========================
29
30
reserve function LavaGeyser_DebugDraw
31
reserve function LavaGeyser_DebugSpawn
32
33
34
// ========================
35
// Function Definitions
36
// ========================
37
38
private function LavaGeyser_DebugDraw
39
DrawSprite(2)
40
end function
41
42
43
private function LavaGeyser_DebugSpawn
44
CreateTempObject(TypeName[Lava Geyser], 0, object.xpos, object.ypos)
45
object[tempObjectPos].drawPos.y = object.ypos
46
object[tempObjectPos].drawOrder = 5
47
end function
48
49
50
// ========================
51
// Events
52
// ========================
53
54
event ObjectUpdate
55
switch object.state
56
case LAVAGEYSER_AWAITBLOCK
57
foreach (TypeName[Push Block], arrayPos0, ACTIVE_ENTITIES)
58
BoxCollisionTest(C_TOUCH, arrayPos0, -16, -16, 16, 16, object.entityPos, -16, -32, 16, 16)
59
if checkResult == true
60
object.state = LAVAGEYSER_STARTERUPT
61
object.animationTimer = 0
62
object.eruptAnimTimer = 0
63
object.eruptFrame = 4
64
end if
65
next
66
break
67
68
case LAVAGEYSER_STARTERUPT
69
object.eruptFrame = object.eruptAnimTimer
70
object.eruptFrame /= 3
71
object.eruptFrame += 4
72
object.eruptAnimTimer++
73
object.eruptAnimTimer %= 6
74
75
object.timer++
76
if object.timer == 12
77
object.timer = 0
78
object.state++
79
end if
80
break
81
82
case LAVAGEYSER_SHOWPLUME
83
object.eruptFrame = object.eruptAnimTimer
84
object.eruptFrame /= 3
85
object.eruptFrame += 6
86
object.eruptAnimTimer++
87
object.eruptAnimTimer %= 6
88
89
object.timer++
90
if object.timer == 12
91
object.timer = 0
92
object.frame = 0
93
object.plumeFrame = 8
94
object.yvel = -0x54000
95
object.state++
96
PlaySfx(SfxName[Fire Burn], false)
97
foreach (TypeName[Push Block], arrayPos0, ACTIVE_ENTITIES)
98
BoxCollisionTest(C_TOUCH, arrayPos0, -16, -16, 16, 16, object.entityPos, -32, -32, 32, 16)
99
if checkResult == true
100
object[arrayPos0].yvel = -0x59000
101
object[arrayPos0].gravity = GRAVITY_AIR
102
end if
103
next
104
end if
105
break
106
107
case LAVAGEYSER_ERUPTING
108
object.yvel += 0x1800
109
object.ypos += object.yvel
110
if object.ypos >= object.drawPos.y
111
object.ypos = object.drawPos.y
112
object.state++
113
end if
114
115
object.eruptFrame = object.eruptAnimTimer
116
object.eruptFrame /= 3
117
object.plumeFrame = object.eruptFrame
118
object.eruptFrame += 2
119
object.plumeFrame += 8
120
object.eruptAnimTimer++
121
object.eruptAnimTimer %= 6
122
object.frame = object.animationTimer
123
object.frame >>= 3
124
object.animationTimer++
125
object.animationTimer &= 15
126
127
temp0 = object.drawPos.y
128
temp0 -= object.ypos
129
temp0 >>= 16
130
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
131
BoxCollisionTest(C_TOUCH, object.entityPos, -32, 0, 32, temp0, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)
132
if checkResult == true
133
CallFunction(Player_FireHit)
134
end if
135
next
136
break
137
138
case LAVAGEYSER_ERUPTED
139
object.eruptFrame = object.eruptAnimTimer
140
object.eruptFrame /= 3
141
object.eruptFrame += 2
142
object.eruptAnimTimer++
143
object.eruptAnimTimer %= 6
144
145
object.timer++
146
if object.timer == 12
147
object.timer = 0
148
object.state++
149
end if
150
break
151
152
case LAVAGEYSER_HANDLEFINISH
153
object.eruptFrame = object.eruptAnimTimer
154
object.eruptFrame /= 3
155
object.eruptFrame += 4
156
object.eruptAnimTimer++
157
object.eruptAnimTimer %= 6
158
object.timer++
159
if object.timer == 12
160
object.timer = 0
161
object.state = LAVAGEYSER_AWAITBLOCK
162
end if
163
break
164
165
end switch
166
end event
167
168
169
event ObjectDraw
170
switch object.state
171
case LAVAGEYSER_STARTERUPT
172
case LAVAGEYSER_SHOWPLUME
173
case LAVAGEYSER_ERUPTED
174
case LAVAGEYSER_HANDLEFINISH
175
DrawSpriteXY(object.eruptFrame, object.xpos, object.drawPos.y)
176
break
177
178
case LAVAGEYSER_ERUPTING
179
temp0 = object.drawPos.y
180
temp0 -= object.ypos
181
temp0 >>= 16
182
temp1 = temp0
183
FlipSign(temp1)
184
if object.frame == 0
185
EditFrame(0, -32, temp1, 64, temp0, 317, 1)
186
else
187
EditFrame(1, -32, temp1, 64, temp0, 382, 1)
188
end if
189
DrawSpriteXY(object.frame, object.xpos, object.drawPos.y)
190
DrawSprite(object.plumeFrame)
191
DrawSpriteXY(object.eruptFrame, object.xpos, object.drawPos.y)
192
break
193
194
end switch
195
end event
196
197
198
event ObjectStartup
199
LoadSpriteSheet("MZ/Objects.gif")
200
SpriteFrame(-32, -128, 64, 256, 317, 1)
201
SpriteFrame(-32, -128, 64, 256, 382, 1)
202
203
SpriteFrame(-56, -18, 112, 30, 288, 332)
204
SpriteFrame(-55, -18, 110, 30, 401, 332)
205
206
SpriteFrame(-24, -18, 48, 30, 268, 1)
207
SpriteFrame(-23, -18, 46, 30, 270, 32)
208
209
SpriteFrame(-56, -22, 112, 34, 288, 297)
210
SpriteFrame(-55, -22, 110, 34, 401, 297)
211
SpriteFrame(-56, -26, 112, 38, 288, 258)
212
SpriteFrame(-55, -26, 110, 38, 401, 258)
213
214
foreach (TypeName[Lava Geyser], arrayPos0, ALL_ENTITIES)
215
object[arrayPos0].drawPos.y = object[arrayPos0].ypos
216
object[arrayPos0].drawOrder = 5
217
next
218
219
SetTableValue(TypeName[Lava Geyser], DebugMode_ObjCount, DebugMode_TypesTable)
220
SetTableValue(LavaGeyser_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)
221
SetTableValue(LavaGeyser_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)
222
DebugMode_ObjCount++
223
end event
224
225
226
// ========================
227
// Editor Events
228
// ========================
229
230
event RSDKDraw
231
DrawSprite(4)
232
end event
233
234
235
event RSDKLoad
236
LoadSpriteSheet("MZ/Objects.gif")
237
SpriteFrame(-32, -128, 64, 256, 317, 1)
238
SpriteFrame(-32, -128, 64, 256, 382, 1)
239
SpriteFrame(-56, -18, 112, 30, 288, 332)
240
SpriteFrame(-55, -18, 110, 30, 401, 332)
241
SpriteFrame(-24, -18, 48, 30, 268, 1)
242
SpriteFrame(-23, -18, 46, 30, 270, 32)
243
SpriteFrame(-56, -22, 112, 34, 288, 297)
244
SpriteFrame(-55, -22, 110, 34, 401, 297)
245
SpriteFrame(-56, -26, 112, 38, 288, 258)
246
SpriteFrame(-55, -26, 110, 38, 401, 258)
247
248
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
249
end event
250
251