Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-CD-2011-Script-Decompilation
Path: blob/main/Scripts/R8/InvisiblePlatform.txt
1319 views
1
//------------Sonic CD Invisible Platform Script--------------//
2
//--------Scripted by Christian Whitehead 'The Taxman'--------//
3
//-------Unpacked By Rubberduckycooly's Script Unpacker-------//
4
5
// Aliases
6
#alias Object.Value0 : Object.FirstPlatTimer
7
#alias Object.Value1 : Object.FirstPlatMaxTimer
8
9
#alias Object.Value2 : Object.SecondPlatTimer
10
#alias Object.Value3 : Object.SecondPlatMaxTimer
11
#alias Object.Value4 : Object.SecondPlatFrame
12
13
#alias Object.Value5 : Object.ThirdPlatTimer
14
#alias Object.Value6 : Object.ThirdPlatMaxTimer
15
#alias Object.Value7 : Object.ThirdPlatFrame
16
17
// Property Values
18
#alias 0 : ONE_BLOCK
19
#alias 1 : TWO_BLOCKS // Seems unused in the game
20
#alias 2 : THREE_BLOCK_STAIR
21
22
// Function declarations
23
#function InvPlatform_SetMaxTimer
24
25
function InvPlatform_SetMaxTimer
26
switch TempValue0
27
case 0
28
TempValue1 = 60
29
break
30
case 1
31
case 3
32
case 5
33
case 7
34
case 9
35
case 11
36
case 14
37
case 16
38
case 18
39
case 20
40
case 22
41
case 24
42
TempValue1 = 5
43
break
44
case 2
45
case 4
46
case 6
47
case 8
48
case 10
49
case 12
50
case 15
51
case 17
52
case 19
53
case 21
54
case 23
55
case 25
56
TempValue1 = 3
57
break
58
case 13
59
TempValue1 = 160
60
break
61
end switch
62
end function
63
64
65
sub ObjectMain
66
if Object.FirstPlatTimer < Object.FirstPlatMaxTimer
67
Object.FirstPlatTimer++
68
else
69
Object.FirstPlatTimer = 0
70
Object.Frame++
71
Object.Frame %= 26
72
TempValue0 = Object.Frame
73
CallFunction(InvPlatform_SetMaxTimer)
74
Object.FirstPlatMaxTimer = TempValue1
75
end if
76
77
if Object.PropertyValue == THREE_BLOCK_STAIR
78
if Object.SecondPlatTimer < Object.SecondPlatMaxTimer
79
Object.SecondPlatTimer++
80
else
81
Object.SecondPlatTimer = 0
82
Object.SecondPlatFrame++
83
Object.SecondPlatFrame %= 26
84
TempValue0 = Object.SecondPlatFrame
85
CallFunction(InvPlatform_SetMaxTimer)
86
Object.SecondPlatMaxTimer = TempValue1
87
end if
88
89
if Object.ThirdPlatTimer < Object.ThirdPlatMaxTimer
90
Object.ThirdPlatTimer++
91
else
92
Object.ThirdPlatTimer = 0
93
Object.ThirdPlatFrame++
94
Object.ThirdPlatFrame %= 26
95
TempValue0 = Object.ThirdPlatFrame
96
CallFunction(InvPlatform_SetMaxTimer)
97
Object.ThirdPlatMaxTimer = TempValue1
98
end if
99
end if
100
end sub
101
102
103
sub ObjectPlayerInteraction
104
switch Object.PropertyValue
105
case ONE_BLOCK
106
if Object.Frame == 13
107
PlayerObjectCollision(C_PLATFORM, -16, -16, 16, 0)
108
end if
109
break
110
case TWO_BLOCKS
111
if Object.Frame == 13
112
PlayerObjectCollision(C_PLATFORM, -16, -16, 48, 0)
113
end if
114
break
115
case THREE_BLOCK_STAIR
116
if Object.Frame == 13
117
PlayerObjectCollision(C_PLATFORM, -16, -16, 16, 0)
118
end if
119
if Object.SecondPlatFrame == 13
120
PlayerObjectCollision(C_PLATFORM, 16, 0, 48, 16)
121
end if
122
if Object.ThirdPlatFrame == 13
123
PlayerObjectCollision(C_PLATFORM, 48, 16, 80, 32)
124
end if
125
break
126
end switch
127
end sub
128
129
130
sub ObjectDraw
131
switch Object.PropertyValue
132
case ONE_BLOCK
133
DrawSprite(Object.Frame)
134
break
135
case TWO_BLOCKS
136
TempValue0 = Object.XPos
137
DrawSpriteXY(Object.Frame, TempValue0, Object.YPos)
138
TempValue0 += 0x200000
139
DrawSpriteXY(Object.Frame, TempValue0, Object.YPos)
140
break
141
case THREE_BLOCK_STAIR
142
TempValue0 = Object.XPos
143
TempValue1 = Object.YPos
144
DrawSpriteXY(Object.Frame, TempValue0, TempValue1)
145
TempValue0 += 0x200000
146
TempValue1 += 0x100000
147
DrawSpriteXY(Object.SecondPlatFrame, TempValue0, TempValue1)
148
TempValue0 += 0x200000
149
TempValue1 += 0x100000
150
DrawSpriteXY(Object.ThirdPlatFrame, TempValue0, TempValue1)
151
break
152
end switch
153
end sub
154
155
156
sub ObjectStartup
157
LoadSpriteSheet("R8/Objects2.gif")
158
159
SpriteFrame(-4, -16, 0, 0, 190, 223) // #0 - Blank
160
161
// 1/3 width
162
SpriteFrame(-4, -16, 8, 32, 190, 223) // #1 - Vanishing Platform
163
SpriteFrame(-4, -16, 8, 32, 223, 223) // #2 - Solid Platform
164
SpriteFrame(-4, -16, 8, 32, 190, 223) // #3 - Vanishing Platform
165
SpriteFrame(-4, -16, 8, 32, 223, 223) // #4 - Solid Platform
166
167
// 2/3 width
168
SpriteFrame(-8, -16, 16, 32, 190, 223) // #5 - Vanishing Platform
169
SpriteFrame(-8, -16, 16, 32, 223, 223) // #6 - Solid Platform
170
SpriteFrame(-8, -16, 16, 32, 190, 223) // #7 - Vanishing Platform
171
SpriteFrame(-8, -16, 16, 32, 223, 223) // #8 - Solid Platform
172
173
// Full width
174
SpriteFrame(-16, -16, 32, 32, 190, 223) // #9 - Vanishing Platform
175
SpriteFrame(-16, -16, 32, 32, 223, 223) // #10 - Solid Platform
176
SpriteFrame(-16, -16, 32, 32, 190, 223) // #11 - Vanishing Platform
177
SpriteFrame(-16, -16, 32, 32, 223, 223) // #12 - Solid Platform
178
SpriteFrame(-16, -16, 32, 32, 223, 223) // #13 - Solid Platform
179
SpriteFrame(-16, -16, 32, 32, 190, 223) // #14 - Vanishing Platform
180
SpriteFrame(-16, -16, 32, 32, 223, 223) // #15 - Solid Platform
181
SpriteFrame(-16, -16, 32, 32, 190, 223) // #16 - Vanishing Platform
182
SpriteFrame(-16, -16, 32, 32, 223, 223) // #17 - Solid Platform
183
184
// 2/3 width
185
SpriteFrame(-8, -16, 16, 32, 190, 223) // #18 - Vanishing Platform
186
SpriteFrame(-8, -16, 16, 32, 223, 223) // #19 - Solid Platform
187
SpriteFrame(-8, -16, 16, 32, 190, 223) // #20 - Vanishing Platform
188
SpriteFrame(-8, -16, 16, 32, 223, 223) // #21 - Solid Platform
189
190
// 1/3 width
191
SpriteFrame(-4, -16, 8, 32, 190, 223) // #22 - Vanishing Platform
192
SpriteFrame(-4, -16, 8, 32, 223, 223) // #23 - Solid Platform
193
SpriteFrame(-4, -16, 8, 32, 190, 223) // #24 - Vanishing Platform
194
SpriteFrame(-4, -16, 8, 32, 223, 223) // #25 - Solid Platform
195
196
ArrayPos0 = 32
197
while ArrayPos0 < 1056
198
if Object[ArrayPos0].Type == TypeName[Inv Platform]
199
switch Object[ArrayPos0].PropertyValue
200
case ONE_BLOCK
201
case TWO_BLOCKS
202
Object[ArrayPos0].FirstPlatMaxTimer = 60
203
break
204
case THREE_BLOCK_STAIR
205
Object[ArrayPos0].FirstPlatMaxTimer = 60
206
Object[ArrayPos0].SecondPlatMaxTimer = 108
207
Object[ArrayPos0].ThirdPlatMaxTimer = 156
208
break
209
end switch
210
end if
211
ArrayPos0++
212
loop
213
end sub
214
215
216
// ========================
217
// Editor Subs
218
// ========================
219
220
sub RSDKEdit
221
if Editor.ReturnVariable == true
222
switch Editor.VariableID
223
case EDIT_VAR_PROPVAL // Property Value
224
CheckResult = Object.PropertyValue
225
CheckResult %= 3
226
break
227
case 0 // type
228
CheckResult = Object.PropertyValue
229
CheckResult %= 3
230
break
231
end switch
232
else
233
switch Editor.VariableID
234
case EDIT_VAR_PROPVAL // Property Value
235
Object.PropertyValue = Editor.VariableValue
236
Object.PropertyValue %= 3
237
break
238
case 0 // type
239
Object.PropertyValue = Editor.VariableValue
240
Object.PropertyValue %= 3
241
break
242
end switch
243
end if
244
end sub
245
246
sub RSDKDraw
247
switch Object.PropertyValue
248
case ONE_BLOCK
249
DrawSprite(9)
250
break
251
case TWO_BLOCKS
252
TempValue0 = Object.XPos
253
DrawSpriteXY(9, TempValue0, Object.YPos)
254
TempValue0 += 0x200000
255
DrawSpriteXY(9, TempValue0, Object.YPos)
256
break
257
case THREE_BLOCK_STAIR
258
TempValue0 = Object.XPos
259
TempValue1 = Object.YPos
260
DrawSpriteXY(9, TempValue0, TempValue1)
261
TempValue0 += 0x200000
262
TempValue1 += 0x100000
263
DrawSpriteXY(9, TempValue0, TempValue1)
264
TempValue0 += 0x200000
265
TempValue1 += 0x100000
266
DrawSpriteXY(9, TempValue0, TempValue1)
267
break
268
end switch
269
end sub
270
271
272
sub RSDKLoad
273
LoadSpriteSheet("R8/Objects2.gif")
274
275
SpriteFrame(-4, -16, 0, 0, 190, 223) // #0 - Blank
276
277
// 1/3 width
278
SpriteFrame(-4, -16, 8, 32, 190, 223) // #1 - Vanishing Platform
279
SpriteFrame(-4, -16, 8, 32, 223, 223) // #2 - Solid Platform
280
SpriteFrame(-4, -16, 8, 32, 190, 223) // #3 - Vanishing Platform
281
SpriteFrame(-4, -16, 8, 32, 223, 223) // #4 - Solid Platform
282
283
// 2/3 width
284
SpriteFrame(-8, -16, 16, 32, 190, 223) // #5 - Vanishing Platform
285
SpriteFrame(-8, -16, 16, 32, 223, 223) // #6 - Solid Platform
286
SpriteFrame(-8, -16, 16, 32, 190, 223) // #7 - Vanishing Platform
287
SpriteFrame(-8, -16, 16, 32, 223, 223) // #8 - Solid Platform
288
289
// Full width
290
SpriteFrame(-16, -16, 32, 32, 190, 223) // #9 - Vanishing Platform
291
SpriteFrame(-16, -16, 32, 32, 223, 223) // #10 - Solid Platform
292
SpriteFrame(-16, -16, 32, 32, 190, 223) // #11 - Vanishing Platform
293
SpriteFrame(-16, -16, 32, 32, 223, 223) // #12 - Solid Platform
294
SpriteFrame(-16, -16, 32, 32, 223, 223) // #13 - Solid Platform
295
SpriteFrame(-16, -16, 32, 32, 190, 223) // #14 - Vanishing Platform
296
SpriteFrame(-16, -16, 32, 32, 223, 223) // #15 - Solid Platform
297
SpriteFrame(-16, -16, 32, 32, 190, 223) // #16 - Vanishing Platform
298
SpriteFrame(-16, -16, 32, 32, 223, 223) // #17 - Solid Platform
299
300
// 2/3 width
301
SpriteFrame(-8, -16, 16, 32, 190, 223) // #18 - Vanishing Platform
302
SpriteFrame(-8, -16, 16, 32, 223, 223) // #19 - Solid Platform
303
SpriteFrame(-8, -16, 16, 32, 190, 223) // #20 - Vanishing Platform
304
SpriteFrame(-8, -16, 16, 32, 223, 223) // #21 - Solid Platform
305
306
// 1/3 width
307
SpriteFrame(-4, -16, 8, 32, 190, 223) // #22 - Vanishing Platform
308
SpriteFrame(-4, -16, 8, 32, 223, 223) // #23 - Solid Platform
309
SpriteFrame(-4, -16, 8, 32, 190, 223) // #24 - Vanishing Platform
310
SpriteFrame(-4, -16, 8, 32, 223, 223) // #25 - Solid Platform
311
312
AddEditorVariable("type")
313
SetActiveVariable("type")
314
AddEnumVariable("1 Block", ONE_BLOCK)
315
AddEnumVariable("2 Blocks", TWO_BLOCKS)
316
AddEnumVariable("3-Block Stair", THREE_BLOCK_STAIR)
317
end sub
318
319