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/GHZ/BreakWall.txt
1483 views
1
// ----------------------------------
2
// RSDK Project: Sonic 1
3
// Script Description: Breakable Wall Object
4
// Script Author: Christian Whitehead/Simon Thomley
5
// Unpacked by Rubberduckycooly's script unpacker
6
// ----------------------------------
7
8
// ========================
9
// Aliases
10
// ========================
11
12
// Player Aliases
13
private alias object.state : player.state
14
private alias object.xpos : player.xpos
15
private alias object.speed : player.speed
16
private alias object.direction : player.direction
17
private alias object.animation : player.animation
18
private alias object.value40 : player.hitboxLeft
19
private alias object.value38 : player.hitboxTop
20
private alias object.value41 : player.hitboxRight
21
private alias object.value39 : player.hitboxBottom
22
private alias object.value16 : player.isSidekick
23
24
private alias object.value17 : debugMode.currentSelection
25
26
private alias 1 : SUPERSTATE_SUPER
27
28
29
// ========================
30
// Function Declarations
31
// ========================
32
33
reserve function EditorHelpers_DrawHitboxOutline
34
reserve function BreakableWall_DebugDraw
35
reserve function BreakableWall_DebugSpawn
36
37
38
// ========================
39
// Static Values
40
// ========================
41
42
private value BreakableWall_startDebugID = 0
43
44
45
// ========================
46
// Function Definitions
47
// ========================
48
49
private function BreakableWall_DebugDraw
50
temp0 = debugMode[0].currentSelection
51
temp0 -= BreakableWall_startDebugID
52
DrawSprite(temp0)
53
end function
54
55
56
private function BreakableWall_DebugSpawn
57
temp0 = debugMode[0].currentSelection
58
temp0 -= BreakableWall_startDebugID
59
CreateTempObject(TypeName[Breakable Wall], temp0, object.xpos, object.ypos)
60
object[tempObjectPos].drawOrder = 4
61
end function
62
63
64
// ========================
65
// Events
66
// ========================
67
68
event ObjectUpdate
69
if object.propertyValue > 2
70
// Wall fragment, just fly through the air and unload when possible
71
72
object.xpos += object.xvel
73
object.ypos += object.yvel
74
object.yvel += 0x7000
75
76
if object.outOfBounds == true
77
object.type = TypeName[Blank Object]
78
end if
79
else
80
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
81
checkResult = false
82
83
if player[currentPlayer].state == Player_State_Roll
84
if player[currentPlayer].speed >= 0x48000
85
checkResult = true
86
end if
87
88
if player[currentPlayer].speed <= -0x48000
89
checkResult = true
90
end if
91
end if
92
93
if stage.playerListPos == PLAYER_KNUCKLES_A
94
// Knuckles can break all walls, regardless if he's rolling or not
95
// (Though, this implementation results in P2 Tails also being able to break all walls if Knux is P1...)
96
checkResult = true
97
end if
98
99
if Player_superState == SUPERSTATE_SUPER
100
// Similarly, this also means P2 Tails can break any walls he pleases too...
101
checkResult = true
102
end if
103
104
#platform: USE_STANDALONE
105
if checkResult == true
106
BoxCollisionTest(C_TOUCH, object.entityPos, -17, -32, 17, 32, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)
107
#endplatform
108
109
#platform: USE_ORIGINS
110
if stage.playerListPos == PLAYER_AMY
111
if player[currentPlayer].isSidekick == false
112
if player[currentPlayer].animation == ANI_HAMMER_JUMP
113
checkResult = 2
114
end if
115
if player[currentPlayer].animation == ANI_HAMMER_DASH
116
checkResult = 2
117
end if
118
end if
119
end if
120
if checkResult != 0
121
switch checkResult
122
case 1
123
BoxCollisionTest(C_TOUCH, object.entityPos, -17, -32, 17, 32, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)
124
break
125
case 2
126
BoxCollisionTest(C_TOUCH, object.entityPos, -17, -32, 17, 32, currentPlayer, player[currentPlayer].hitboxLeft, player[currentPlayer].hitboxTop, player[currentPlayer].hitboxRight, player[currentPlayer].hitboxBottom)
127
break
128
end switch
129
#endplatform
130
if checkResult == true
131
object.type = TypeName[Blank Object]
132
PlaySfx(SfxName[Block Break], false)
133
134
temp0 = object.propertyValue
135
temp0 <<= 1
136
temp0 += 3
137
temp1 = temp0
138
temp1++
139
140
temp2 = object.xpos
141
temp2 -= 0x80000
142
temp3 = object.xpos
143
temp3 += 0x80000
144
temp4 = object.ypos
145
temp4 -= 0x180000
146
147
if player[currentPlayer].xpos < object.xpos
148
CreateTempObject(TypeName[Breakable Wall], temp0, temp2, temp4)
149
object[tempObjectPos].xvel = -0x60000
150
object[tempObjectPos].yvel = -0x60000
151
object[tempObjectPos].drawOrder = 4
152
153
CreateTempObject(TypeName[Breakable Wall], temp1, temp3, temp4)
154
object[tempObjectPos].xvel = -0x40000
155
object[tempObjectPos].yvel = -0x50000
156
object[tempObjectPos].drawOrder = 4
157
temp4 += 0x100000
158
159
CreateTempObject(TypeName[Breakable Wall], temp0, temp2, temp4)
160
object[tempObjectPos].xvel = -0x80000
161
object[tempObjectPos].yvel = -0x20000
162
object[tempObjectPos].drawOrder = 4
163
164
CreateTempObject(TypeName[Breakable Wall], temp1, temp3, temp4)
165
object[tempObjectPos].xvel = -0x60000
166
object[tempObjectPos].yvel = -0x10000
167
object[tempObjectPos].drawOrder = 4
168
temp4 += 0x100000
169
170
CreateTempObject(TypeName[Breakable Wall], temp0, temp2, temp4)
171
object[tempObjectPos].xvel = -0x80000
172
object[tempObjectPos].yvel = 0x20000
173
object[tempObjectPos].drawOrder = 4
174
175
CreateTempObject(TypeName[Breakable Wall], temp1, temp3, temp4)
176
object[tempObjectPos].xvel = -0x60000
177
object[tempObjectPos].yvel = 0x10000
178
object[tempObjectPos].drawOrder = 4
179
temp4 += 0x100000
180
181
CreateTempObject(TypeName[Breakable Wall], temp0, temp2, temp4)
182
object[tempObjectPos].xvel = -0x60000
183
object[tempObjectPos].yvel = 0x60000
184
object[tempObjectPos].drawOrder = 4
185
186
CreateTempObject(TypeName[Breakable Wall], temp1, temp3, temp4)
187
object[tempObjectPos].xvel = -0x40000
188
object[tempObjectPos].yvel = 0x50000
189
object[tempObjectPos].drawOrder = 4
190
else
191
CreateTempObject(TypeName[Breakable Wall], temp0, temp2, temp4)
192
object[tempObjectPos].xvel = 0x40000
193
object[tempObjectPos].yvel = -0x50000
194
object[tempObjectPos].drawOrder = 4
195
196
CreateTempObject(TypeName[Breakable Wall], temp1, temp3, temp4)
197
object[tempObjectPos].xvel = 0x60000
198
object[tempObjectPos].yvel = -0x60000
199
object[tempObjectPos].drawOrder = 4
200
temp4 += 0x100000
201
202
CreateTempObject(TypeName[Breakable Wall], temp0, temp2, temp4)
203
object[tempObjectPos].xvel = 0x60000
204
object[tempObjectPos].yvel = -0x10000
205
object[tempObjectPos].drawOrder = 4
206
207
CreateTempObject(TypeName[Breakable Wall], temp1, temp3, temp4)
208
object[tempObjectPos].xvel = 0x80000
209
object[tempObjectPos].yvel = -0x20000
210
object[tempObjectPos].drawOrder = 4
211
temp4 += 0x100000
212
213
CreateTempObject(TypeName[Breakable Wall], temp0, temp2, temp4)
214
object[tempObjectPos].xvel = 0x60000
215
object[tempObjectPos].yvel = 0x10000
216
object[tempObjectPos].drawOrder = 4
217
218
CreateTempObject(TypeName[Breakable Wall], temp1, temp3, temp4)
219
object[tempObjectPos].xvel = 0x80000
220
object[tempObjectPos].yvel = 0x20000
221
object[tempObjectPos].drawOrder = 4
222
temp4 += 0x100000
223
224
CreateTempObject(TypeName[Breakable Wall], temp0, temp2, temp4)
225
object[tempObjectPos].xvel = 0x40000
226
object[tempObjectPos].yvel = 0x50000
227
object[tempObjectPos].drawOrder = 4
228
229
CreateTempObject(TypeName[Breakable Wall], temp1, temp3, temp4)
230
object[tempObjectPos].xvel = 0x60000
231
object[tempObjectPos].yvel = 0x60000
232
object[tempObjectPos].drawOrder = 4
233
end if
234
235
if player[currentPlayer].animation == ANI_GLIDING
236
// Make Knuckles drop, since he's collided into an unclimbable wall
237
player[currentPlayer].animation = ANI_GLIDING_DROP
238
player[currentPlayer].state = Player_State_GlideDrop
239
if player[currentPlayer].direction == FACING_LEFT
240
FlipSign(player[currentPlayer].speed)
241
end if
242
end if
243
end if
244
else
245
BoxCollisionTest(C_SOLID, object.entityPos, -16, -32, 16, 32, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)
246
end if
247
next
248
end if
249
end event
250
251
252
event ObjectDraw
253
DrawSprite(object.propertyValue)
254
end event
255
256
257
event ObjectStartup
258
LoadSpriteSheet("GHZ/Objects.gif")
259
260
foreach (TypeName[Breakable Wall], arrayPos0, ALL_ENTITIES)
261
object[arrayPos0].drawOrder = 4
262
next
263
264
// 0 - Left Wall Frame
265
SpriteFrame(-16, -32, 32, 64, 191, 146)
266
267
// 1 - Middle Wall Frame
268
SpriteFrame(-16, -32, 32, 64, 207, 146)
269
270
// 2 - Right Wall Frame
271
SpriteFrame(-16, -32, 32, 64, 223, 146)
272
273
// 3-8 - Wall Fragment Frames
274
SpriteFrame(-8, -8, 16, 16, 191, 146)
275
SpriteFrame(-8, -8, 16, 16, 207, 146)
276
SpriteFrame(-8, -8, 16, 16, 207, 146)
277
SpriteFrame(-8, -8, 16, 16, 223, 146)
278
SpriteFrame(-8, -8, 16, 16, 223, 146)
279
SpriteFrame(-8, -8, 16, 16, 239, 146)
280
281
// Add the object to the Debug Object List thrice, for every type
282
temp0 = 0
283
BreakableWall_startDebugID = DebugMode_ObjCount
284
while temp0 < 3
285
SetTableValue(TypeName[Breakable Wall], DebugMode_ObjCount, DebugMode_TypesTable)
286
SetTableValue(BreakableWall_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)
287
SetTableValue(BreakableWall_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)
288
DebugMode_ObjCount++
289
temp0++
290
loop
291
end event
292
293
294
// ========================
295
// Editor Events
296
// ========================
297
298
event RSDKEdit
299
if editor.returnVariable == true
300
switch editor.variableID
301
case EDIT_VAR_PROPVAL // property value
302
checkResult = object.propertyValue
303
break
304
305
case 0 // type
306
checkResult = object.propertyValue
307
break
308
309
end switch
310
else
311
switch editor.variableID
312
case EDIT_VAR_PROPVAL // property value
313
object.propertyValue = editor.variableValue
314
break
315
316
case 0 // type
317
object.propertyValue = editor.variableValue
318
break
319
320
end switch
321
end if
322
end event
323
324
325
event RSDKDraw
326
DrawSprite(object.propertyValue)
327
328
if editor.showGizmos == true
329
editor.drawingOverlay = true
330
331
// These objects are made to blend in with the terrain, give them a little outline to make them more distinct
332
333
temp0 = 16; temp1 = 32; temp2 = 16; temp3 = 32;
334
CallFunction(EditorHelpers_DrawHitbox)
335
336
editor.drawingOverlay = false
337
end if
338
end event
339
340
341
event RSDKLoad
342
LoadSpriteSheet("GHZ/Objects.gif")
343
SpriteFrame(-16, -32, 32, 64, 191, 146)
344
SpriteFrame(-16, -32, 32, 64, 207, 146)
345
SpriteFrame(-16, -32, 32, 64, 223, 146)
346
347
AddEditorVariable("type")
348
SetActiveVariable("type")
349
AddEnumVariable("Left", 0)
350
AddEnumVariable("Middle", 1)
351
AddEnumVariable("Right", 2)
352
end event
353
354