Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-1-Sonic-2-2013-Script-Decompilation
Path: blob/master/Sonic 2/Scripts/HPZ/EggmanMine.txt
1483 views
1
// ----------------------------------
2
// RSDK Project: Sonic 2
3
// Script Description: Eggman Mine 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.hitboxLeft
14
private alias object.value3 : object.hitboxTop
15
private alias object.value2 : object.hitboxRight
16
private alias object.value4 : object.hitboxBottom
17
private alias object.value5 : object.originPos.x
18
19
// States
20
private alias 0 : HPZEGGMANMINE_SETUP
21
private alias 1 : HPZEGGMANMINE_SMALL_FALL
22
private alias 2 : HPZEGGMANMINE_SMALL_RISE
23
private alias 3 : HPZEGGMANMINE_SMALL_FLOAT
24
private alias 4 : HPZEGGMANMINE_SMALL_EXPLODE
25
private alias 5 : HPZEGGMANMINE_BIG_FALL
26
private alias 6 : HPZEGGMANMINE_BIG_FOLLOW
27
private alias 7 : HPZEGGMANMINE_BIG_EXPLODE
28
private alias 8 : HPZEGGMANMINE_BIG_EXPLODED
29
30
private alias 0 : HPZEGGMANMINE_SMALL
31
private alias 2 : HPZEGGMANMINE_LARGE
32
33
// Player Aliases
34
private alias object.xpos : player.xpos
35
private alias object.ypos : player.ypos
36
37
38
// ========================
39
// Events
40
// ========================
41
42
event ObjectUpdate
43
switch object.state
44
case HPZEGGMANMINE_SETUP
45
if object.propertyValue == HPZEGGMANMINE_SMALL
46
object.hitboxLeft = -12
47
object.hitboxRight = 12
48
object.hitboxTop = -12
49
object.hitboxBottom = 12
50
else
51
object.hitboxLeft = -16
52
object.hitboxRight = 16
53
object.hitboxTop = -24
54
object.hitboxBottom = 16
55
end if
56
object.state++
57
break
58
59
case HPZEGGMANMINE_SMALL_FALL
60
object.ypos += object.yvel
61
object.yvel += 0x1800
62
63
temp0 = stage.waterLevel
64
temp0 <<= 16
65
if object.ypos > temp0
66
CreateTempObject(TypeName[Water Splash], 0, object.xpos, temp0)
67
PlaySfx(SfxName[Water Splash], false)
68
object[tempObjectPos].drawOrder = 4
69
object.yvel >>= 2
70
if object.propertyValue == HPZEGGMANMINE_SMALL
71
Sin(temp1, oscillation)
72
temp1 >>= 5
73
temp1 <<= 16
74
object.originPos.x = temp1
75
object.originPos.x += object.xpos
76
object.state++
77
else
78
object.state = HPZEGGMANMINE_BIG_FALL
79
end if
80
end if
81
break
82
83
case HPZEGGMANMINE_SMALL_RISE
84
object.ypos += object.yvel
85
object.yvel -= 0x1800
86
87
temp0 = stage.waterLevel
88
temp0 <<= 16
89
if object.ypos <= temp0
90
object.ypos = temp0
91
object.yvel = 0
92
object.state++
93
end if
94
95
Sin(object.xpos, oscillation)
96
object.xpos >>= 5
97
object.xpos <<= 16
98
FlipSign(object.xpos)
99
object.xpos += object.originPos.x
100
break
101
102
case HPZEGGMANMINE_SMALL_FLOAT
103
object.ypos = stage.waterLevel
104
object.ypos <<= 16
105
Sin(object.xpos, oscillation)
106
object.xpos >>= 5
107
object.xpos <<= 16
108
FlipSign(object.xpos)
109
object.xpos += object.originPos.x
110
break
111
112
case HPZEGGMANMINE_SMALL_EXPLODE
113
object.timer++
114
object.frame = object.animationTimer
115
object.frame >>= 5
116
object.animationTimer += object.timer
117
object.animationTimer &= 63
118
if object.timer == 60
119
object.hitboxTop -= 16
120
object.type = TypeName[Blank Object]
121
122
CreateTempObject(TypeName[Explosion], 0, object.xpos, object.ypos)
123
object[tempObjectPos].drawOrder = 4
124
125
CreateTempObject(TypeName[Explosion], 0, object.xpos, object.ypos)
126
object[tempObjectPos].ypos -= 0x180000
127
object[tempObjectPos].drawOrder = 4
128
129
CreateTempObject(TypeName[Water Splash], 0, object.xpos, object.ypos)
130
object[tempObjectPos].drawOrder = 4
131
132
PlaySfx(SfxName[Explosion], false)
133
end if
134
break
135
136
case HPZEGGMANMINE_BIG_FALL
137
object.ypos += object.yvel
138
object.yvel -= 0x1000
139
140
temp0 = stage.waterLevel
141
temp0 <<= 16
142
if object.ypos <= temp0
143
object.ypos = temp0
144
object.yvel = 0
145
object.state++
146
end if
147
break
148
149
case HPZEGGMANMINE_BIG_FOLLOW
150
object.ypos = stage.waterLevel
151
object.ypos <<= 16
152
153
temp0 = player[0].xpos
154
temp0 -= 0x20000
155
temp1 = player[0].xpos
156
temp1 += 0x20000
157
158
if object.xpos < temp0
159
object.xpos += 0x8000
160
object.direction = FLIP_X
161
end if
162
163
if object.xpos > temp1
164
object.xpos -= 0x8000
165
object.direction = FLIP_NONE
166
end if
167
168
object.timer++
169
if object.timer == 180
170
object.timer = 0
171
object.state++
172
end if
173
break
174
175
case HPZEGGMANMINE_BIG_EXPLODE
176
temp0 = player[0].xpos
177
temp0 -= 0x20000
178
temp1 = player[0].xpos
179
temp1 += 0x20000
180
if object.xpos < temp0
181
object.xpos += 0x8000
182
object.direction = FLIP_X
183
end if
184
185
if object.xpos > temp1
186
object.xpos -= 0x8000
187
object.direction = FLIP_NONE
188
end if
189
190
object.timer++
191
object.frame = object.animationTimer
192
object.frame >>= 5
193
object.animationTimer += object.timer
194
object.animationTimer &= 63
195
if object.timer == 60
196
object.timer = 0
197
object.state++
198
object.hitboxLeft = -32
199
object.hitboxRight = 32
200
201
arrayPos0 = object.entityPos
202
arrayPos0--
203
ResetObjectEntity(arrayPos0, TypeName[Water Geyser], true, object.xpos, object.ypos)
204
object[arrayPos0].drawOrder = 4
205
206
CreateTempObject(TypeName[Explosion], 0, object.xpos, object.ypos)
207
object[tempObjectPos].drawOrder = 4
208
209
CreateTempObject(TypeName[Water Splash], 0, object.xpos, object.ypos)
210
object[tempObjectPos].drawOrder = 4
211
212
PlaySfx(SfxName[Big Explosion], false)
213
end if
214
break
215
216
case HPZEGGMANMINE_BIG_EXPLODED
217
temp0 = object.timer
218
temp0 %= 6
219
if temp0 == 5
220
temp1 = object.xpos
221
temp1 -= 0x180000
222
temp2 = object.xpos
223
temp2 += 0x180000
224
225
CreateTempObject(TypeName[Smoke Puff], 0, temp1, object.ypos)
226
object[tempObjectPos].drawOrder = 4
227
228
CreateTempObject(TypeName[Smoke Puff], 0, temp2, object.ypos)
229
object[tempObjectPos].drawOrder = 4
230
231
object.ypos -= 0x180000
232
object.hitboxTop -= 24
233
CreateTempObject(TypeName[Explosion], 0, object.xpos, object.ypos)
234
object[tempObjectPos].drawOrder = 4
235
end if
236
237
object.timer++
238
if object.timer == 24
239
object.type = TypeName[Blank Object]
240
end if
241
break
242
243
end switch
244
245
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
246
BoxCollisionTest(C_TOUCH, object.entityPos, object.hitboxLeft, object.hitboxTop, object.hitboxRight, object.hitboxBottom, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)
247
if checkResult == true
248
CallFunction(Player_Hit)
249
end if
250
next
251
252
if object.outOfBounds == true
253
object.type = TypeName[Blank Object]
254
end if
255
end event
256
257
258
event ObjectDraw
259
if object.state < HPZEGGMANMINE_BIG_EXPLODED
260
temp0 = object.propertyValue
261
temp0 += object.frame
262
DrawSprite(temp0)
263
end if
264
end event
265
266
267
event ObjectStartup
268
LoadSpriteSheet("HPZ/Objects.gif")
269
SpriteFrame(-16, -16, 32, 32, 443, 99)
270
SpriteFrame(-16, -16, 32, 32, 367, 222)
271
SpriteFrame(-24, -24, 48, 48, 353, 66)
272
SpriteFrame(-24, -24, 48, 48, 400, 206)
273
end event
274
275
276
// ========================
277
// Editor Events
278
// ========================
279
280
event RSDKDraw
281
DrawSprite(0)
282
end event
283
284
285
event RSDKLoad
286
LoadSpriteSheet("HPZ/Objects.gif")
287
SpriteFrame(-16, -16, 32, 32, 443, 99)
288
289
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
290
end event
291
292