Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-CD-2011-Script-Decompilation
Path: blob/main/Scripts/R5/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
// The object isn't cleared upon being destroyed, it's just given a new state and made hidden instead...
10
#alias Object.State : Object.Destroyed
11
12
// HUD Alias
13
#alias Object[24].PropertyValue : HUD.CurrentTimePeriod
14
15
// Time Period Aliases
16
#alias 0 : TIME_PRESENT
17
#alias 1 : TIME_PAST
18
#alias 2 : TIME_GOOD_FUTURE
19
#alias 3 : TIME_BAD_FUTURE
20
21
// Global SFX
22
#alias 22 : SFX_G_EXPLOSION
23
24
// Priority
25
#alias 0 : PRIORITY_BOUNDS
26
#alias 1 : PRIORITY_ACTIVE
27
28
// Property Values
29
#alias 0 : BREAKWALL
30
#alias 1 : BREAKWALL_DEBRIS_1
31
#alias 2 : BREAKWALL_DEBRIS_2
32
#alias 3 : BREAKWALL_DEBRIS_3
33
#alias 4 : BREAKWALL_DEBRIS_4
34
#alias 5 : BREAKWALL_DEBRIS_5
35
#alias 6 : BREAKWALL_DEBRIS_6
36
#alias 7 : BREAKWALL_DEBRIS_7
37
#alias 8 : BREAKWALL_DEBRIS_8
38
39
40
sub ObjectMain
41
42
if Object.PropertyValue > 0
43
44
// Update Movements
45
Object.XPos += Object.XVelocity
46
Object.YPos += Object.YVelocity
47
48
// Apply a Gravity of 0.25 px per frame
49
Object.YVelocity += 0x4000
50
51
if Object.OutOfBounds == true
52
// Unload when no longer needed
53
Object.Type = TypeName[Blank Object]
54
end if
55
56
else
57
if Object.Destroyed == true
58
59
// Check to see if the Player's *not* within this giant range
60
PlayerObjectCollision(C_TOUCH, -384, -256, 384, 256)
61
62
if CheckResult == false
63
64
// The Player is nowhere near this object, so it's safe to reset since it's likely out of view now
65
Object.Destroyed = false
66
Object.Priority = PRIORITY_BOUNDS
67
68
end if
69
70
// Why a standard Object.OutOfBounds check isn't used is beyond me...
71
72
end if
73
end if
74
75
end sub
76
77
78
sub ObjectPlayerInteraction
79
80
if Object.PropertyValue < 1
81
if Object.Destroyed == false
82
CheckResult = false
83
if Player.Animation == ANI_JUMPING
84
CheckResult = true
85
end if
86
#platform: Use_Origins
87
if Stage.PlayerListPos == PLAYER_KNUCKLES
88
CheckResult = true
89
end if
90
if Stage.PlayerListPos == PLAYER_AMY
91
if Player.Animation == ANI_HAMMER_JUMP
92
CheckResult = true
93
end if
94
if Player.Animation == ANI_HAMMER_DASH
95
CheckResult = true
96
end if
97
end if
98
#endplatform
99
if CheckResult == true
100
#platform: Use_Origins
101
PlayerObjectCollision(C_ENEMY, -18, -48, 18, 48)
102
#endplatform
103
#platform: Use_Standalone
104
PlayerObjectCollision(C_TOUCH, -18, -48, 18, 48)
105
#endplatform
106
if CheckResult == true
107
Object.Destroyed = true
108
Object.Priority = PRIORITY_ACTIVE
109
PlaySfx(SFX_G_EXPLOSION, false)
110
111
// Spawn all the Wall Fragments
112
// - TempValue1 is left position (8 pixels left from this object's position)
113
// - TempValue2 is right position (8 pixels right from this object's position)
114
// - TempValue3 is Y Position, starting 24 pixels from this object's position
115
116
TempValue1 = Object.XPos
117
TempValue1 -= 0x80000
118
119
TempValue2 = Object.XPos
120
TempValue2 += 0x80000
121
122
TempValue3 = Object.YPos
123
TempValue3 -= 0x180000
124
125
CreateTempObject(TypeName[Breakable Wall], BREAKWALL_DEBRIS_1, TempValue1, TempValue3)
126
Object[TempObjectPos].XVelocity = -0x10000
127
Object[TempObjectPos].YVelocity = -0x20000
128
Object[TempObjectPos].DrawOrder = 5
129
130
CreateTempObject(TypeName[Breakable Wall], BREAKWALL_DEBRIS_2, TempValue2, TempValue3)
131
Object[TempObjectPos].XVelocity = 0x10000
132
Object[TempObjectPos].YVelocity = -0x20000
133
Object[TempObjectPos].DrawOrder = 5
134
135
TempValue3 += 0x100000
136
137
CreateTempObject(TypeName[Breakable Wall], BREAKWALL_DEBRIS_3, TempValue1, TempValue3)
138
Object[TempObjectPos].XVelocity = -0x20000
139
Object[TempObjectPos].YVelocity = -0x10000
140
Object[TempObjectPos].DrawOrder = 5
141
142
CreateTempObject(TypeName[Breakable Wall], BREAKWALL_DEBRIS_4, TempValue2, TempValue3)
143
Object[TempObjectPos].XVelocity = 0x20000
144
Object[TempObjectPos].YVelocity = -0x10000
145
Object[TempObjectPos].DrawOrder = 5
146
147
TempValue3 += 0x100000
148
149
CreateTempObject(TypeName[Breakable Wall], BREAKWALL_DEBRIS_5, TempValue1, TempValue3)
150
Object[TempObjectPos].XVelocity = -0x40000
151
Object[TempObjectPos].YVelocity = 0
152
Object[TempObjectPos].DrawOrder = 5
153
154
CreateTempObject(TypeName[Breakable Wall], BREAKWALL_DEBRIS_6, TempValue2, TempValue3)
155
Object[TempObjectPos].XVelocity = 0x40000
156
Object[TempObjectPos].YVelocity = 0
157
Object[TempObjectPos].DrawOrder = 5
158
159
TempValue3 += 0x100000
160
161
CreateTempObject(TypeName[Breakable Wall], BREAKWALL_DEBRIS_7, TempValue1, TempValue3)
162
Object[TempObjectPos].XVelocity = -0x20000
163
Object[TempObjectPos].YVelocity = 0x10000
164
Object[TempObjectPos].DrawOrder = 5
165
166
CreateTempObject(TypeName[Breakable Wall], BREAKWALL_DEBRIS_8, TempValue2, TempValue3)
167
Object[TempObjectPos].XVelocity = 0x20000
168
Object[TempObjectPos].YVelocity = 0x10000
169
Object[TempObjectPos].DrawOrder = 5
170
end if
171
else
172
PlayerObjectCollision(C_BOX, -16, -48, 16, 48)
173
PlayerObjectCollision(C_TOUCH, -16, -48, 16, 48)
174
if CheckResult == true
175
if Player.XPos < Object.XPos
176
Player.XPos = Player.CollisionLeft
177
Player.XPos <<= 16
178
Player.XPos += Object.XPos
179
Player.XPos -= 0x100000
180
else
181
Player.XPos = Player.CollisionRight
182
Player.XPos <<= 16
183
Player.XPos += Object.XPos
184
Player.XPos += 0x100000
185
end if
186
end if
187
end if
188
end if
189
end if
190
191
end sub
192
193
194
sub ObjectDraw
195
196
if Object.Destroyed == false
197
DrawSprite(Object.PropertyValue)
198
end if
199
200
end sub
201
202
203
sub ObjectStartup
204
205
switch HUD.CurrentTimePeriod
206
case TIME_PRESENT
207
LoadSpriteSheet("R5/Objects.gif")
208
SpriteFrame(-16, -48, 32, 96, 223, 141)
209
TempValue0 = 223
210
TempValue1 = 239
211
TempValue2 = 141
212
break
213
214
case TIME_PAST
215
LoadSpriteSheet("R5/Objects3.gif")
216
SpriteFrame(-16, -48, 32, 96, 132, 1)
217
TempValue0 = 132
218
TempValue1 = 148
219
TempValue2 = 1
220
break
221
222
case TIME_GOOD_FUTURE
223
LoadSpriteSheet("R5/Objects3.gif")
224
SpriteFrame(-16, -48, 32, 96, 66, 1)
225
TempValue0 = 66
226
TempValue1 = 82
227
TempValue2 = 1
228
break
229
230
case TIME_BAD_FUTURE
231
LoadSpriteSheet("R5/Objects3.gif")
232
SpriteFrame(-16, -48, 32, 96, 99, 1)
233
TempValue0 = 99
234
TempValue1 = 115
235
TempValue2 = 1
236
break
237
238
end switch
239
240
TempValue2 += 16
241
SpriteFrame(-8, -8, 16, 16, TempValue0, TempValue2)
242
SpriteFrame(-8, -8, 16, 16, TempValue1, TempValue2)
243
244
TempValue2 += 16
245
SpriteFrame(-8, -8, 16, 16, TempValue0, TempValue2)
246
SpriteFrame(-8, -8, 16, 16, TempValue1, TempValue2)
247
248
TempValue2 += 16
249
SpriteFrame(-8, -8, 16, 16, TempValue0, TempValue2)
250
SpriteFrame(-8, -8, 16, 16, TempValue1, TempValue2)
251
252
TempValue2 += 16
253
SpriteFrame(-8, -8, 16, 16, TempValue0, TempValue2)
254
SpriteFrame(-8, -8, 16, 16, TempValue1, TempValue2)
255
256
end sub
257
258
259
// ========================
260
// Editor Subs
261
// ========================
262
263
sub RSDKDraw
264
DrawSprite(0)
265
266
if Editor.ShowGizmos == true
267
TempValue0 = Object.iXPos
268
TempValue0 -= 16
269
TempValue1 = Object.iYPos
270
TempValue1 -= 48
271
272
DrawRectOutline(TempValue0, TempValue1, 32, 96, 255, 255, 255, 255)
273
end if
274
275
// TODO: perhaps it would be cool to show the deactivation hitbox, but at the same time, is it even that important anways?
276
end sub
277
278
279
sub RSDKLoad
280
LoadSpriteSheet("R5/Objects.gif")
281
282
// TODO: support other time periods
283
// Surely there's a better way to do it than a load of unique and boring checkCurrentStageFolder checks?
284
SpriteFrame(-16, -48, 32, 96, 223, 141)
285
286
287
// Although used by the object, it shouldn't be set from the editor
288
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
289
end sub
290
291