Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-CD-2011-Script-Decompilation
Path: blob/main/Scripts/R1/BreakWall.txt
1319 views
1
//---------------Sonic CD Breakable Wall Script---------------//
2
//--------Scripted by Christian Whitehead 'The Taxman'--------//
3
//-------Unpacked By Rubberduckycooly's Script Unpacker-------//
4
5
// Aliases
6
#alias Object.Value0 : Object.XVelocity
7
#alias Object.Value1 : Object.YVelocity
8
9
// Global SFX
10
#alias 22 : SFX_G_EXPLOSION
11
12
// Property Values
13
#alias 0 : VARIANT_1_SMALL
14
#alias 1 : VARIANT_1_BIG_LEFT
15
#alias 2 : VARIANT_1_BIG_MIDDLE
16
#alias 3 : VARIANT_1_BIG_RIGHT
17
18
#alias 4 : VARIANT_2_SMALL
19
#alias 5 : VARIANT_2_BIG_LEFT
20
#alias 6 : VARIANT_2_BIG_MIDDLE
21
#alias 7 : VARIANT_2_BIG_RIGHT
22
23
// from 8 onwards it will be considered debris
24
25
26
sub ObjectMain
27
if Object.PropertyValue > 7
28
Object.XPos += Object.XVelocity
29
Object.YPos += Object.YVelocity
30
Object.YVelocity += 0x4000
31
if Object.OutOfBounds == true
32
Object.Type = TypeName[Blank Object]
33
end if
34
end if
35
end sub
36
37
38
sub ObjectPlayerInteraction
39
// Checks:
40
// That the object is not debris
41
// The Player is rolling/jumping, if this one doesn't happen then it will act like a normal wall
42
// The Player collided
43
if Object.PropertyValue < 8
44
// if Player.Animation == ANI_JUMPING // Standalone/Preplus check
45
CheckResult = false
46
if Player.Animation == ANI_JUMPING
47
CheckResult = true
48
end if
49
#platform: Use_Origins
50
if Stage.PlayerListPos == PLAYER_KNUCKLES
51
CheckResult = true
52
end if
53
if Stage.PlayerListPos == PLAYER_AMY
54
if Player.Animation == ANI_HAMMER_JUMP
55
CheckResult = true
56
end if
57
if Player.Animation == ANI_HAMMER_DASH
58
CheckResult = true
59
end if
60
end if
61
#endplatform
62
if CheckResult == true
63
#platform: Use_Origins
64
PlayerObjectCollision(C_ENEMY, -17, -24, 17, 24)
65
#endplatform
66
#platform: Use_Standalone
67
PlayerObjectCollision(C_TOUCH, -17, -24, 17, 24)
68
#endplatform
69
if CheckResult == true
70
71
Object.Type = TypeName[Blank Object]
72
PlaySfx(SFX_G_EXPLOSION, false)
73
TempValue0 = Object.PropertyValue
74
TempValue0 *= 6
75
TempValue0 += 8
76
77
TempValue1 = Object.XPos
78
TempValue1 -= 0x80000
79
80
TempValue2 = Object.XPos
81
TempValue2 += 0x80000
82
83
TempValue3 = Object.YPos
84
TempValue3 -= 0x100000
85
86
if Player.XPos < Object.XPos
87
CreateTempObject(TypeName[Breakable Wall], TempValue0, TempValue1, TempValue3)
88
Object[TempObjectPos].XVelocity = -0x30000
89
Object[TempObjectPos].YVelocity = -0x20000
90
Object[TempObjectPos].DrawOrder = 4
91
TempValue0++
92
93
CreateTempObject(TypeName[Breakable Wall], TempValue0, TempValue2, TempValue3)
94
Object[TempObjectPos].XVelocity = -0x20000
95
Object[TempObjectPos].YVelocity = -0x20000
96
Object[TempObjectPos].DrawOrder = 4
97
TempValue0++
98
99
TempValue3 += 0x100000
100
CreateTempObject(TypeName[Breakable Wall], TempValue0, TempValue1, TempValue3)
101
Object[TempObjectPos].XVelocity = -0x40000
102
Object[TempObjectPos].YVelocity = -0x10000
103
Object[TempObjectPos].DrawOrder = 4
104
TempValue0++
105
106
CreateTempObject(TypeName[Breakable Wall], TempValue0, TempValue2, TempValue3)
107
Object[TempObjectPos].XVelocity = -0x30000
108
Object[TempObjectPos].YVelocity = -0x10000
109
Object[TempObjectPos].DrawOrder = 4
110
TempValue0++
111
112
TempValue3 += 0x100000
113
CreateTempObject(TypeName[Breakable Wall], TempValue0, TempValue1, TempValue3)
114
Object[TempObjectPos].XVelocity = -0x30000
115
Object[TempObjectPos].YVelocity = 0x10000
116
Object[TempObjectPos].DrawOrder = 4
117
TempValue0++
118
119
CreateTempObject(TypeName[Breakable Wall], TempValue0, TempValue2, TempValue3)
120
Object[TempObjectPos].XVelocity = -0x20000
121
Object[TempObjectPos].YVelocity = 0x10000
122
Object[TempObjectPos].DrawOrder = 4
123
TempValue0++
124
125
TempValue3 += 0x100000
126
else
127
CreateTempObject(TypeName[Breakable Wall], TempValue0, TempValue1, TempValue3)
128
Object[TempObjectPos].XVelocity = 0x20000
129
Object[TempObjectPos].YVelocity = -0x20000
130
Object[TempObjectPos].DrawOrder = 4
131
TempValue0++
132
133
CreateTempObject(TypeName[Breakable Wall], TempValue0, TempValue2, TempValue3)
134
Object[TempObjectPos].XVelocity = 0x30000
135
Object[TempObjectPos].YVelocity = -0x20000
136
Object[TempObjectPos].DrawOrder = 4
137
TempValue0++
138
139
TempValue3 += 0x100000
140
CreateTempObject(TypeName[Breakable Wall], TempValue0, TempValue1, TempValue3)
141
Object[TempObjectPos].XVelocity = 0x30000
142
Object[TempObjectPos].YVelocity = -0x10000
143
Object[TempObjectPos].DrawOrder = 4
144
TempValue0++
145
146
CreateTempObject(TypeName[Breakable Wall], TempValue0, TempValue2, TempValue3)
147
Object[TempObjectPos].XVelocity = 0x40000
148
Object[TempObjectPos].YVelocity = -0x10000
149
Object[TempObjectPos].DrawOrder = 4
150
TempValue0++
151
152
TempValue3 += 0x100000
153
CreateTempObject(TypeName[Breakable Wall], TempValue0, TempValue1, TempValue3)
154
Object[TempObjectPos].XVelocity = 0x20000
155
Object[TempObjectPos].YVelocity = 0x10000
156
Object[TempObjectPos].DrawOrder = 4
157
TempValue0++
158
159
CreateTempObject(TypeName[Breakable Wall], TempValue0, TempValue2, TempValue3)
160
Object[TempObjectPos].XVelocity = 0x30000
161
Object[TempObjectPos].YVelocity = 0x10000
162
Object[TempObjectPos].DrawOrder = 4
163
TempValue0++
164
TempValue3 += 0x100000
165
end if
166
end if
167
else
168
// "Fake" Wall Collision
169
PlayerObjectCollision(C_TOUCH, -17, -24, 16, 24)
170
if CheckResult == true
171
if Player.XPos < Object.XPos
172
Player.XPos = Player.CollisionLeft
173
Player.XPos <<= 16
174
Player.XPos += Object.XPos
175
Player.XPos -= 0x100000
176
Player.Speed = 0
177
Player.XVelocity = 0
178
if Player.Right == true
179
if Player.Direction == FACING_RIGHT
180
Player.Pushing = 2
181
end if
182
end if
183
else
184
Player.XPos = Player.CollisionRight
185
Player.XPos <<= 16
186
Player.XPos += Object.XPos
187
Player.XPos += 0x100000
188
Player.Speed = 0
189
Player.XVelocity = 0
190
if Player.Direction == FACING_LEFT
191
Player.Pushing = 2
192
end if
193
end if
194
end if
195
end if
196
end if
197
end sub
198
199
200
sub ObjectDraw
201
DrawSprite(Object.PropertyValue)
202
end sub
203
204
205
sub ObjectStartup
206
LoadSpriteSheet("R1/Objects2.gif")
207
208
// Variant 1
209
SpriteFrame(-16, -24, 32, 48, 190, 1) // #0 - BreakWall singular piece
210
SpriteFrame(-16, -24, 32, 48, 223, 1) // #1 - BreakWall left piece
211
SpriteFrame(-16, -24, 32, 48, 190, 50) // #2 - BreakWall middle piece
212
SpriteFrame(-16, -24, 32, 48, 223, 50) // #3 - BreakWall right piece
213
// Variant 2
214
SpriteFrame(-16, -24, 32, 48, 190, 99) // #4 - BreakWall singular piece
215
SpriteFrame(-16, -24, 32, 48, 223, 99) // #5 - BreakWall left piece
216
SpriteFrame(-16, -24, 32, 48, 190, 148) // #6 - BreakWall middle piece
217
SpriteFrame(-16, -24, 32, 48, 223, 148) // #7 - BreakWall right piece
218
219
// Variant 1 debris chunks
220
221
// Debris chunks BreakWall singular piece
222
TempValue0 = 0
223
TempValue3 = 1
224
while TempValue0 < 3
225
TempValue1 = 0
226
TempValue2 = 190
227
while TempValue1 < 2
228
SpriteFrame(-8, -8, 16, 16, TempValue2, TempValue3)
229
TempValue1++
230
TempValue2 += 16
231
loop
232
TempValue0++
233
TempValue3 += 16
234
loop
235
236
// Debris chunks BreakWall left piece
237
TempValue0 = 0
238
TempValue3 = 1
239
while TempValue0 < 3
240
TempValue1 = 0
241
TempValue2 = 223
242
while TempValue1 < 2
243
SpriteFrame(-8, -8, 16, 16, TempValue2, TempValue3)
244
TempValue1++
245
TempValue2 += 16
246
loop
247
TempValue0++
248
TempValue3 += 16
249
loop
250
251
// Debris chunks BreakWall middle piece
252
TempValue0 = 0
253
TempValue3 = 50
254
while TempValue0 < 3
255
TempValue1 = 0
256
TempValue2 = 190
257
while TempValue1 < 2
258
SpriteFrame(-8, -8, 16, 16, TempValue2, TempValue3)
259
TempValue1++
260
TempValue2 += 16
261
loop
262
TempValue0++
263
TempValue3 += 16
264
loop
265
266
// Debris chunks BreakWall right piece
267
TempValue0 = 0
268
TempValue3 = 50
269
while TempValue0 < 3
270
TempValue1 = 0
271
TempValue2 = 223
272
while TempValue1 < 2
273
SpriteFrame(-8, -8, 16, 16, TempValue2, TempValue3)
274
TempValue1++
275
TempValue2 += 16
276
loop
277
TempValue0++
278
TempValue3 += 16
279
loop
280
281
// Variant 2 debris chunks
282
283
// Debris chunks BreakWall singular piece
284
TempValue0 = 0
285
TempValue3 = 99
286
while TempValue0 < 3
287
TempValue1 = 0
288
TempValue2 = 190
289
while TempValue1 < 2
290
SpriteFrame(-8, -8, 16, 16, TempValue2, TempValue3)
291
TempValue1++
292
TempValue2 += 16
293
loop
294
TempValue0++
295
TempValue3 += 16
296
loop
297
298
// Debris chunks BreakWall left piece
299
TempValue0 = 0
300
TempValue3 = 99
301
while TempValue0 < 3
302
TempValue1 = 0
303
TempValue2 = 223
304
while TempValue1 < 2
305
SpriteFrame(-8, -8, 16, 16, TempValue2, TempValue3)
306
TempValue1++
307
TempValue2 += 16
308
loop
309
TempValue0++
310
TempValue3 += 16
311
loop
312
313
// Debris chunks BreakWall middle piece
314
TempValue0 = 0
315
TempValue3 = 148
316
while TempValue0 < 3
317
TempValue1 = 0
318
TempValue2 = 190
319
while TempValue1 < 2
320
SpriteFrame(-8, -8, 16, 16, TempValue2, TempValue3)
321
TempValue1++
322
TempValue2 += 16
323
loop
324
TempValue0++
325
TempValue3 += 16
326
loop
327
328
// Debris chunks BreakWall right piece
329
TempValue0 = 0
330
TempValue3 = 148
331
while TempValue0 < 3
332
TempValue1 = 0
333
TempValue2 = 223
334
while TempValue1 < 2
335
SpriteFrame(-8, -8, 16, 16, TempValue2, TempValue3)
336
TempValue1++
337
TempValue2 += 16
338
loop
339
TempValue0++
340
TempValue3 += 16
341
loop
342
343
// original code have this below LoadSpriteSheet, moved for consistency with the rest
344
ArrayPos0 = 32
345
while ArrayPos0 < 1056
346
if Object[ArrayPos0].Type == TypeName[Breakable Wall]
347
Object[ArrayPos0].DrawOrder = 4
348
end if
349
ArrayPos0++
350
loop
351
end sub
352
353
354
// ========================
355
// Editor Subs
356
// ========================
357
358
sub RSDKEdit
359
if Editor.ReturnVariable == true
360
switch Editor.VariableID
361
case EDIT_VAR_PROPVAL // Property Value
362
CheckResult = Object.PropertyValue
363
CheckResult &= 7
364
break
365
case 0 // type
366
CheckResult = Object.PropertyValue
367
CheckResult &= 7
368
break
369
end switch
370
else
371
switch Editor.VariableID
372
case EDIT_VAR_PROPVAL // Property Value
373
Object.PropertyValue = Editor.VariableValue
374
Object.PropertyValue &= 7
375
break
376
case 0 // type
377
Object.PropertyValue = Editor.VariableValue
378
Object.PropertyValue &= 7
379
break
380
end switch
381
end if
382
end sub
383
384
385
sub RSDKDraw
386
DrawSprite(Object.PropertyValue)
387
end sub
388
389
390
sub RSDKLoad
391
LoadSpriteSheet("R1/Objects2.gif")
392
393
// Variant 1
394
SpriteFrame(-16, -24, 32, 48, 190, 1) // #0 - BreakWall singular piece
395
SpriteFrame(-16, -24, 32, 48, 223, 1) // #1 - BreakWall left piece
396
SpriteFrame(-16, -24, 32, 48, 190, 50) // #2 - BreakWall middle piece
397
SpriteFrame(-16, -24, 32, 48, 223, 50) // #3 - BreakWall right piece
398
// Variant 2
399
SpriteFrame(-16, -24, 32, 48, 190, 99) // #4 - BreakWall singular piece
400
SpriteFrame(-16, -24, 32, 48, 223, 99) // #5 - BreakWall left piece
401
SpriteFrame(-16, -24, 32, 48, 190, 148) // #6 - BreakWall middle piece
402
SpriteFrame(-16, -24, 32, 48, 223, 148) // #7 - BreakWall right piece
403
404
405
AddEditorVariable("type")
406
SetActiveVariable("type")
407
AddEnumVariable("Variant 1 (Single)", 0)
408
AddEnumVariable("Variant 1 (Left)", 1)
409
AddEnumVariable("Variant 1 (Middle)", 2)
410
AddEnumVariable("Variant 1 (Right)", 3)
411
AddEnumVariable("Variant 2 (Single)", 4)
412
AddEnumVariable("Variant 2 (Left)", 5)
413
AddEnumVariable("Variant 2 (Middle)", 6)
414
AddEnumVariable("Variant 2 (Right)", 7)
415
end sub
416
417