Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-CD-2011-Script-Decompilation
Path: blob/main/Scripts/R1/CLedge5.txt
1319 views
1
//---------------Sonic CD Crumble Ledge 5 Script--------------//
2
//--------Scripted by Christian Whitehead 'The Taxman'--------//
3
//-------Unpacked By Rubberduckycooly's Script Unpacker-------//
4
5
// Aliases
6
#alias Object.Value0 : Object.HitboxLeft
7
#alias Object.Value1 : Object.HitboxRight
8
#alias Object.Value2 : Object.Timer
9
#alias Object.Value3 : Object.Length
10
#alias Object.Value4 : Object.YVelocity
11
12
// States
13
#alias 0 : CLEDGE5_IDLE
14
#alias 1 : CLEDGE5_DELAY_FROM_RIGHT
15
#alias 2 : CLEDGE5_DELAY_FROM_LEFT
16
#alias 3 : CLEDGE5_COLLAPSE_RIGHT
17
#alias 4 : CLEDGE5_COLLAPSE_LEFT
18
#alias 5 : CLEDGE5_RESTORE // Unused
19
20
#alias 6 : CLEDGE5_DEBRIS
21
22
// Stage SFX
23
#alias 0 : SFX_S_CRUMBLE
24
25
// Priority
26
#alias 0 : PRIORITY_BOUNDS
27
#alias 1 : PRIORITY_ACTIVE
28
29
30
sub ObjectMain
31
switch Object.State
32
case CLEDGE5_DELAY_FROM_RIGHT
33
if Object.Timer > 0
34
Object.Timer--
35
else
36
PlayStageSfx(SFX_S_CRUMBLE, false)
37
Object.State = CLEDGE5_COLLAPSE_RIGHT
38
end if
39
break
40
41
case CLEDGE5_DELAY_FROM_LEFT
42
if Object.Timer > 0
43
Object.Timer--
44
else
45
PlayStageSfx(SFX_S_CRUMBLE, false)
46
Object.State = CLEDGE5_COLLAPSE_LEFT
47
end if
48
break
49
50
case CLEDGE5_COLLAPSE_RIGHT
51
Object.Timer++
52
if Object.Timer == 12
53
Object.Timer = 0
54
if Object.HitboxRight > Object.HitboxLeft
55
56
Object.HitboxRight -= 16
57
TempValue0 = Object.HitboxRight
58
TempValue0 += 8
59
TempValue0 <<= 16
60
TempValue0 += Object.XPos
61
CreateTempObject(TypeName[Crumble Ledge 5], 0, TempValue0, Object.YPos)
62
Object[TempObjectPos].State = CLEDGE5_DEBRIS
63
if Object.Length == 1
64
Object[TempObjectPos].Frame = 4
65
else
66
if Object.Length == Object.PropertyValue
67
Object[TempObjectPos].Frame = 2
68
else
69
Object[TempObjectPos].Frame = 3
70
end if
71
end if
72
Object.Length--
73
else
74
ResetObjectEntity(Object.EntityNo, TypeName[Blank Object], 0, 0, 0)
75
end if
76
end if
77
break
78
79
case CLEDGE5_COLLAPSE_LEFT
80
Object.Timer++
81
if Object.Timer == 12
82
83
Object.Timer = 0
84
if Object.HitboxLeft < Object.HitboxRight
85
86
Object.HitboxLeft += 16
87
TempValue0 = Object.HitboxLeft
88
TempValue0 -= 8
89
TempValue0 <<= 16
90
TempValue0 += Object.XPos
91
92
CreateTempObject(TypeName[Crumble Ledge 5], 0, TempValue0, Object.YPos)
93
Object[TempObjectPos].State = CLEDGE5_DEBRIS
94
95
if Object.Length == 1
96
Object[TempObjectPos].Frame = 2
97
else
98
if Object.Length == Object.PropertyValue
99
Object[TempObjectPos].Frame = 4
100
else
101
Object[TempObjectPos].Frame = 3
102
end if
103
end if
104
Object.Length--
105
else
106
ResetObjectEntity(Object.EntityNo, TypeName[Blank Object], 0, 0, 0)
107
end if
108
end if
109
break
110
111
case CLEDGE5_RESTORE
112
if Object.OutOfBounds == true
113
Object.State = CLEDGE5_IDLE
114
Object.Length = Object.PropertyValue
115
116
Object.HitboxLeft = Object.PropertyValue
117
Object.HitboxLeft <<= 3
118
119
Object.HitboxRight = Object.HitboxLeft
120
FlipSign(Object.HitboxLeft)
121
122
Object.Priority = PRIORITY_BOUNDS
123
Object.Timer = 0
124
end if
125
break
126
127
case CLEDGE5_DEBRIS
128
Object.YVelocity += 0x4000
129
if Object.YVelocity > 0
130
Object.YPos += Object.YVelocity
131
end if
132
133
if Object.OutOfBounds == true
134
Object.Type = TypeName[Blank Object]
135
end if
136
break
137
138
end switch
139
end sub
140
141
142
sub ObjectPlayerInteraction
143
if Object.State == CLEDGE5_IDLE
144
PlayerObjectCollision(C_PLATFORM, Object.HitboxLeft, -24, Object.HitboxRight, 16)
145
if CheckResult == true
146
Object.Timer = 1
147
Object.Priority = PRIORITY_ACTIVE
148
if Player.XPos > Object.XPos
149
Object.State = CLEDGE5_DELAY_FROM_RIGHT
150
else
151
Object.State = CLEDGE5_DELAY_FROM_LEFT
152
end if
153
end if
154
else
155
PlayerObjectCollision(C_PLATFORM, Object.HitboxLeft, -24, Object.HitboxRight, 16)
156
end if
157
end sub
158
159
160
161
sub ObjectDraw
162
switch Object.State
163
case CLEDGE5_IDLE
164
case CLEDGE5_DELAY_FROM_RIGHT
165
case CLEDGE5_DELAY_FROM_LEFT
166
case CLEDGE5_COLLAPSE_RIGHT
167
TempValue0 = 0
168
TempValue1 = Object.HitboxLeft
169
TempValue1 <<= 16
170
TempValue1 += 0x80000
171
TempValue1 += Object.XPos
172
TempValue2 = Object.PropertyValue
173
TempValue2--
174
while TempValue0 < Object.Length
175
DrawSpriteXY(0, TempValue1, Object.YPos)
176
DrawSpriteXY(1, TempValue1, Object.YPos)
177
if TempValue0 == TempValue2
178
DrawSpriteXY(4, TempValue1, Object.YPos)
179
else
180
if TempValue0 == 0
181
DrawSpriteXY(2, TempValue1, Object.YPos)
182
else
183
DrawSpriteXY(3, TempValue1, Object.YPos)
184
end if
185
end if
186
TempValue0++
187
TempValue1 += 0x100000
188
loop
189
break
190
191
case CLEDGE5_COLLAPSE_LEFT
192
TempValue0 = 0
193
TempValue1 = Object.HitboxRight
194
TempValue1 <<= 16
195
TempValue1 -= 0x80000
196
TempValue1 += Object.XPos
197
TempValue2 = Object.PropertyValue
198
TempValue2--
199
while TempValue0 < Object.Length
200
DrawSpriteXY(0, TempValue1, Object.YPos)
201
DrawSpriteXY(1, TempValue1, Object.YPos)
202
if TempValue0 == TempValue2
203
DrawSpriteXY(2, TempValue1, Object.YPos)
204
else
205
if TempValue0 == 0
206
DrawSpriteXY(4, TempValue1, Object.YPos)
207
else
208
DrawSpriteXY(3, TempValue1, Object.YPos)
209
end if
210
end if
211
TempValue0++
212
TempValue1 -= 0x100000
213
loop
214
break
215
216
case CLEDGE5_DEBRIS
217
DrawSprite(0)
218
DrawSprite(1)
219
DrawSprite(Object.Frame)
220
break
221
end switch
222
end sub
223
224
225
sub ObjectStartup
226
LoadSpriteSheet("R1/Objects2.gif")
227
228
SpriteFrame(-8, -40, 16, 48, 163, 1) // #0 - Ledge top
229
SpriteFrame(-8, 8, 16, 16, 190, 66) // #1 - Ledge middle
230
SpriteFrame(-8, 24, 16, 16, 82, 49) // #2 - Ledge bottom left
231
SpriteFrame(-8, 24, 16, 16, 98, 49) // #3 - Ledge bottom middle
232
SpriteFrame(-8, 24, 16, 16, 130, 49) // #4 - Ledge bottom right
233
234
// original code have this below LoadSpriteSheet, moved for consistency with the rest
235
ArrayPos0 = 32
236
while ArrayPos0 < 1056
237
if Object[ArrayPos0].Type == TypeName[Crumble Ledge 5]
238
Object[ArrayPos0].Length = Object[ArrayPos0].PropertyValue
239
Object[ArrayPos0].HitboxLeft = Object[ArrayPos0].PropertyValue
240
Object[ArrayPos0].HitboxLeft <<= 3
241
Object[ArrayPos0].HitboxRight = Object[ArrayPos0].HitboxLeft
242
FlipSign(Object[ArrayPos0].HitboxLeft)
243
end if
244
ArrayPos0++
245
loop
246
end sub
247
248
249
// ========================
250
// Editor Subs
251
// ========================
252
253
sub RSDKDraw
254
Object.Length = Object.PropertyValue
255
Object.HitboxLeft = Object.PropertyValue
256
Object.HitboxLeft <<= 3
257
Object.HitboxRight = Object.HitboxLeft
258
FlipSign(Object.HitboxLeft)
259
260
TempValue0 = 0
261
TempValue1 = Object.HitboxLeft
262
TempValue1 <<= 16
263
TempValue1 += 0x80000
264
TempValue1 += Object.XPos
265
TempValue2 = Object.PropertyValue
266
TempValue2--
267
while TempValue0 < Object.Length
268
DrawSpriteXY(0, TempValue1, Object.YPos)
269
DrawSpriteXY(1, TempValue1, Object.YPos)
270
if TempValue0 == TempValue2
271
DrawSpriteXY(4, TempValue1, Object.YPos)
272
else
273
if TempValue0 == 0
274
DrawSpriteXY(2, TempValue1, Object.YPos)
275
else
276
DrawSpriteXY(3, TempValue1, Object.YPos)
277
end if
278
end if
279
TempValue0++
280
TempValue1 += 0x100000
281
loop
282
end sub
283
284
285
sub RSDKLoad
286
LoadSpriteSheet("R1/Objects2.gif")
287
288
SpriteFrame(-8, -40, 16, 48, 163, 1) // #0 - Ledge top
289
SpriteFrame(-8, 8, 16, 16, 190, 66) // #1 - Ledge middle
290
SpriteFrame(-8, 24, 16, 16, 82, 49) // #2 - Ledge bottom left
291
SpriteFrame(-8, 24, 16, 16, 98, 49) // #3 - Ledge bottom middle
292
SpriteFrame(-8, 24, 16, 16, 130, 49) // #4 - Ledge bottom right
293
294
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
295
end sub
296
297