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/OOZ/BreakBlock.txt
1478 views
1
// ----------------------------------
2
// RSDK Project: Sonic 2
3
// Script Description: Gas Break Block Object
4
// Script Author: Christian Whitehead/Simon Thomley
5
// Unpacked by Rubberduckycooly's script unpacker
6
// ----------------------------------
7
8
// ========================
9
// Aliases
10
// ========================
11
12
// States
13
private alias 0 : GASBREAKBLOCK_BLOCKS
14
private alias 1 : GASBREAKBLOCK_LAUNCHER
15
private alias 2 : GASBREAKBLOCK_DEBRIS
16
17
// Player Aliases
18
private alias object.state : player.state
19
private alias object.xpos : player.xpos
20
private alias object.ypos : player.ypos
21
private alias object.xvel : player.xvel
22
private alias object.yvel : player.yvel
23
private alias object.gravity : player.gravity
24
private alias object.animationSpeed : player.animationSpeed
25
private alias object.animation : player.animation
26
27
private alias object.value5 : player.rollAnimationSpeed
28
private alias object.value17 : debugMode.currentSelection
29
private alias object.value40 : player.hitboxLeft
30
private alias object.value38 : player.hitboxTop
31
private alias object.value41 : player.hitboxRight
32
private alias object.value39 : player.hitboxBottom
33
34
35
// ========================
36
// Function Declarations
37
// ========================
38
39
reserve function GasBreakBlock_DebugDraw
40
reserve function GasBreakBlock_DebugSpawn
41
42
43
// ========================
44
// Static Values
45
// ========================
46
47
private value GasBreakBlock_startDebugID = 0
48
49
50
// ========================
51
// Tables
52
// ========================
53
54
// btw these tables are public cuz Checkered Ball uses 'em too
55
56
// Holds position offsets for blocks
57
public table GasBreakBlock_blockOffsets
58
-0xC0000, -0xC0000
59
-0x40000, -0xC0000
60
0x40000, -0xC0000
61
0xC0000, -0xC0000
62
-0xC0000, -0x40000
63
-0x40000, -0x40000
64
0x40000, -0x40000
65
0xC0000, -0x40000
66
-0xC0000, 0x40000
67
-0x40000, 0x40000
68
0x40000, 0x40000
69
0xC0000, 0x40000
70
-0xC0000, 0xC0000
71
-0x40000, 0xC0000
72
0x40000, 0xC0000
73
0xC0000, 0xC0000
74
end table
75
76
// Holds starting velocity for blocks
77
public table GasBreakBlock_blockVelocities
78
-0x40000, -0x40000
79
-0x20000, -0x40000
80
0x20000, -0x40000
81
0x40000, -0x40000
82
-0x3C000, -0x20000
83
-0x1C000, -0x20000
84
0x1C000, -0x20000
85
0x3C000, -0x20000
86
-0x38000, 0x20000
87
-0x18000, 0x20000
88
0x18000, 0x20000
89
0x38000, 0x20000
90
-0x34000, 0x40000
91
-0x14000, 0x40000
92
0x14000, 0x40000
93
0x34000, 0x40000
94
end table
95
96
// Holds frame IDs for block fragments to display
97
public table GasBreakBlock_blockFrames
98
2, 3, 4, 5
99
2, 3, 4, 5
100
2, 3, 4, 5
101
2, 3, 4, 5
102
end table
103
104
// Holds frame IDs for block fragments to display, but now for a horizontal block
105
// Even though there are (otherwise unused) SpriteFrames for it, this goes unused anyways..
106
private table GasBreakBlock_unusedTable
107
6, 6, 6, 6
108
7, 7, 7, 7
109
8, 8, 8, 8
110
9, 9, 9, 9
111
end table
112
113
114
// ========================
115
// Function Definitions
116
// ========================
117
118
private function GasBreakBlock_DebugDraw
119
temp0 = debugMode[0].currentSelection
120
temp0 -= GasBreakBlock_startDebugID
121
DrawSprite(temp0)
122
end function
123
124
125
private function GasBreakBlock_DebugSpawn
126
temp0 = debugMode[0].currentSelection
127
temp0 -= GasBreakBlock_startDebugID
128
CreateTempObject(TypeName[Gas Break Block], temp0, object.xpos, object.ypos)
129
object[tempObjectPos].frame = temp0
130
object[tempObjectPos].drawOrder = 4
131
end function
132
133
134
// ========================
135
// Events
136
// ========================
137
138
event ObjectUpdate
139
switch object.state
140
case GASBREAKBLOCK_BLOCKS
141
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
142
#platform: USE_STANDALONE
143
if player[currentPlayer].animation == ANI_JUMPING
144
#endplatform
145
#platform: USE_ORIGINS
146
checkResult = false
147
148
if player[currentPlayer].animation == ANI_JUMPING
149
checkResult = true
150
end if
151
152
if player[currentPlayer].animation == ANI_HAMMER_JUMP
153
checkResult = 2
154
end if
155
156
if checkResult != false
157
#endplatform
158
if object.state == GASBREAKBLOCK_BLOCKS
159
temp0 = player[currentPlayer].yvel
160
#platform: USE_STANDALONE
161
BoxCollisionTest(C_SOLID, object.entityPos, -16, -16, 16, 16, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)
162
#endplatform
163
#platform: USE_ORIGINS
164
switch checkResult
165
case 1
166
BoxCollisionTest(C_SOLID, object.entityPos, -16, -16, 16, 16, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)
167
break
168
169
case 2
170
BoxCollisionTest(C_SOLID, object.entityPos, -16, -16, 16, 16, currentPlayer, player[currentPlayer].hitboxLeft, player[currentPlayer].hitboxTop, player[currentPlayer].hitboxRight, player[currentPlayer].hitboxBottom)
171
break
172
end switch
173
#endplatform
174
player[currentPlayer].yvel = temp0
175
if checkResult == COL_TOP
176
player[currentPlayer].gravity = GRAVITY_AIR
177
temp0 = 0
178
temp1 = 0
179
while temp0 < 16
180
CreateTempObject(TypeName[Gas Break Block], 0, object.xpos, object.ypos)
181
GetTableValue(object[tempObjectPos].frame, temp0, GasBreakBlock_blockFrames) // these blocks compose a Vertical block, there's no extra version of the table for Horizontal blocks
182
GetTableValue(temp2, temp1, GasBreakBlock_blockOffsets)
183
GetTableValue(object[tempObjectPos].xvel, temp1, GasBreakBlock_blockVelocities)
184
temp1++
185
186
GetTableValue(temp3, temp1, GasBreakBlock_blockOffsets)
187
GetTableValue(object[tempObjectPos].yvel, temp1, GasBreakBlock_blockVelocities)
188
temp1++
189
190
object[tempObjectPos].xpos += temp2
191
object[tempObjectPos].ypos += temp3
192
object[tempObjectPos].state = GASBREAKBLOCK_DEBRIS
193
object[tempObjectPos].drawOrder = 5
194
temp0++
195
loop
196
object.state++
197
198
if object.priority != PRIORITY_XBOUNDS_DESTROY
199
object.priority = PRIORITY_ACTIVE
200
end if
201
PlaySfx(SfxName[Block Break], false)
202
end if
203
end if
204
else
205
BoxCollisionTest(C_SOLID, object.entityPos, -16, -16, 16, 16, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)
206
end if
207
next
208
break
209
210
case GASBREAKBLOCK_LAUNCHER
211
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
212
if player[currentPlayer].state != Player_State_Static
213
BoxCollisionTest(C_TOUCH, object.entityPos, -8, -4, 8, 4, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)
214
if checkResult == true
215
player[currentPlayer].state = Player_State_Static
216
player[currentPlayer].animation = ANI_JUMPING
217
player[currentPlayer].animationSpeed = 0xF0
218
player[currentPlayer].rollAnimationSpeed = 0xF0
219
player[currentPlayer].xpos = object.xpos
220
player[currentPlayer].ypos = object.ypos
221
#platform: USE_ORIGINS
222
player[currentPlayer].gravity = GRAVITY_AIR
223
#endplatform
224
if object.propertyValue == 0
225
// Vertical Block
226
player[currentPlayer].xvel = 0
227
player[currentPlayer].yvel = -0x80000
228
else
229
// Horizontal Block
230
player[currentPlayer].xvel = 0x80000
231
player[currentPlayer].yvel = 0
232
end if
233
PlaySfx(SfxName[Rolling], false)
234
end if
235
end if
236
next
237
238
if object.outOfBounds == true
239
if object.priority != PRIORITY_XBOUNDS_DESTROY
240
object.priority = PRIORITY_BOUNDS
241
object.state = GASBREAKBLOCK_BLOCKS
242
end if
243
end if
244
break
245
246
case GASBREAKBLOCK_DEBRIS
247
object.xpos += object.xvel
248
object.ypos += object.yvel
249
object.yvel += 0x1800
250
251
if object.outOfBounds == true
252
object.type = TypeName[Blank Object]
253
end if
254
break
255
256
end switch
257
end event
258
259
260
event ObjectDraw
261
if object.state != GASBREAKBLOCK_LAUNCHER
262
DrawSprite(object.frame)
263
end if
264
end event
265
266
267
event ObjectStartup
268
CheckCurrentStageFolder("Zone07")
269
if checkResult == true
270
LoadSpriteSheet("OOZ/Objects.gif")
271
SpriteFrame(-16, -16, 32, 32, 69, 141) // Vertical Frame - #0
272
SpriteFrame(-16, -16, 32, 32, 69, 174) // Horizontal Frame - #1
273
SpriteFrame(-4, -4, 8, 8, 69, 141) // V Block Debris Frame 0 - #2
274
SpriteFrame(-4, -4, 8, 8, 77, 141) // V Block Debris Frame 1 - #3
275
SpriteFrame(-4, -4, 8, 8, 85, 141) // V Block Debris Frame 2 - #4
276
SpriteFrame(-4, -4, 8, 8, 93, 141) // V Block Debris Frame 3 - #5
277
SpriteFrame(-4, -4, 8, 8, 69, 141) // H Block Debris Frame 4 (Unused) - #6
278
SpriteFrame(-4, -4, 8, 8, 69, 141) // H Block Debris Frame 5 (Unused) - #7
279
SpriteFrame(-4, -4, 8, 8, 69, 141) // H Block Debris Frame 6 (Unused) - #8
280
SpriteFrame(-4, -4, 8, 8, 69, 141) // H Block Debris Frame 7 (Unused) - #9
281
else
282
LoadSpriteSheet("MBZ/Objects.gif")
283
SpriteFrame(-16, -16, 32, 32, 991, 843) // Vertical Frame - #0
284
SpriteFrame(-16, -16, 32, 32, 991, 876) // Horizontal Frame - #1
285
SpriteFrame(-4, -4, 8, 8, 991, 843) // V Block Debris Frame 0 - #2
286
SpriteFrame(-4, -4, 8, 8, 999, 843) // V Block Debris Frame 1 - #3
287
SpriteFrame(-4, -4, 8, 8, 1007, 843) // V Block Debris Frame 2 - #4
288
SpriteFrame(-4, -4, 8, 8, 1015, 843) // V Block Debris Frame 3 - #5
289
SpriteFrame(-4, -4, 8, 8, 991, 843) // H Block Debris Frame 4 (Unused) - #6
290
SpriteFrame(-4, -4, 8, 8, 991, 843) // H Block Debris Frame 5 (Unused) - #7
291
SpriteFrame(-4, -4, 8, 8, 991, 843) // H Block Debris Frame 6 (Unused) - #8
292
SpriteFrame(-4, -4, 8, 8, 991, 843) // H Block Debris Frame 7 (Unused) - #9
293
end if
294
295
foreach (TypeName[Gas Break Block], arrayPos0, ALL_ENTITIES)
296
object[arrayPos0].propertyValue &= 1
297
object[arrayPos0].frame = object[arrayPos0].propertyValue
298
object[arrayPos0].drawOrder = 4
299
next
300
301
temp0 = 0
302
GasBreakBlock_startDebugID = DebugMode_ObjCount
303
while temp0 < 2
304
SetTableValue(TypeName[Gas Break Block], DebugMode_ObjCount, DebugMode_TypesTable)
305
SetTableValue(GasBreakBlock_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)
306
SetTableValue(GasBreakBlock_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)
307
DebugMode_ObjCount++
308
temp0++
309
loop
310
end event
311
312
313
// ========================
314
// Editor Events
315
// ========================
316
317
event RSDKEdit
318
if editor.returnVariable == true
319
switch editor.variableID
320
case EDIT_VAR_PROPVAL // property value
321
checkResult = object.propertyValue
322
break
323
324
case 0 // frameID
325
checkResult = object.propertyValue
326
checkResult &= 1
327
break
328
329
end switch
330
else
331
switch editor.variableID
332
case EDIT_VAR_PROPVAL // property value
333
object.propertyValue = editor.variableValue
334
break
335
336
case 0 // frameID
337
editor.variableValue &= 1
338
339
object.propertyValue = editor.variableValue
340
break
341
342
end switch
343
end if
344
end event
345
346
347
event RSDKDraw
348
object.frame = object.propertyValue
349
object.frame &= 1
350
DrawSprite(object.frame)
351
352
if editor.showGizmos == true
353
editor.drawingOverlay = true
354
355
object.inkEffect = INK_NONE
356
GetBit(temp0, object.propertyValue, 0)
357
if temp0 == 0
358
// Vertical (upwards) block
359
temp0 = object.ypos
360
temp0 -= 0x480000
361
DrawArrow(object.xpos, object.ypos, object.xpos, temp0, 0xFF, 0x00, 0x00)
362
else
363
// Horizontal (right) block
364
temp0 = object.xpos
365
temp0 += 0x480000
366
DrawArrow(object.xpos, object.ypos, temp0, object.ypos, 0xFF, 0x00, 0x00)
367
end if
368
369
editor.drawingOverlay = false
370
end if
371
end event
372
373
374
event RSDKLoad
375
CheckCurrentStageFolder("Zone07")
376
if checkResult == true
377
LoadSpriteSheet("OOZ/Objects.gif")
378
SpriteFrame(-16, -16, 32, 32, 69, 141) // Vertical Frame
379
SpriteFrame(-16, -16, 32, 32, 69, 174) // Horizontal Frame
380
else
381
LoadSpriteSheet("MBZ/Objects.gif")
382
SpriteFrame(-16, -16, 32, 32, 991, 843) // Vertical Frame
383
SpriteFrame(-16, -16, 32, 32, 991, 876) // Horizontal Frame
384
end if
385
386
AddEditorVariable("orientation")
387
SetActiveVariable("orientation")
388
AddEnumVariable("Vertical", 0)
389
AddEnumVariable("Horizontal", 1)
390
end event
391
392