Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-CD-2011-Script-Decompilation
Path: blob/main/Scripts/R8/CrushingPlatform.txt
1319 views
1
//--------------Sonic CD Crush Platform Script----------------//
2
//--------Scripted by Christian Whitehead 'The Taxman'--------//
3
//-------Unpacked By Rubberduckycooly's Script Unpacker-------//
4
5
// Aliases
6
#alias Object.Value0 : Object.Timer
7
#alias Object.Value1 : Object.YDrawPos
8
#alias Object.Value2 : Object.YCollisionOffset
9
#alias Object.Value3 : Object.Oscillation
10
#alias Object.Value4 : Object.Speed
11
#alias Object.Value5 : Object.LargePlatform
12
#alias Object.Value6 : Object.IncreaseValue
13
14
// Player Aliases
15
#alias Player.Value7 : Player.AnimationReserve
16
17
#alias 0 : CRUSHPLATFORM_DESCEND
18
#alias 1 : CRUSHPLATFORM_WAIT
19
#alias 2 : CRUSHPLATFORM_ASCEND
20
#alias 3 : CRUSHPLATFORM_WAIT_2
21
22
// Property Values
23
#alias 0 : PLATFORM_START_TOP
24
#alias 1 : PLATFORM_START_BOTTOM
25
26
// Collision
27
#alias 1 : PLAYER_COL_FLOOR
28
#alias 4 : PLAYER_COL_ROOF
29
30
// Gravity
31
#alias 0 : GRAVITY_GROUND
32
#alias 1 : GRAVITY_AIR
33
34
// Property Values
35
#alias 0 : NORMAL_SPEED
36
#alias 5 : LARGE_NORMAL_SPEED
37
#alias 69 : LARGE_FAST_SPEED
38
#alias 72 : NORMAL_FAST_LAUNCH
39
40
41
sub ObjectMain
42
if Object.LargePlatform == false
43
Object.Oscillation += Object.IncreaseValue
44
Object.Oscillation &= 511
45
if Object.PropertyValue == PLATFORM_START_BOTTOM
46
Object.Oscillation += 256
47
end if
48
49
Sin(Object.YCollisionOffset, Object.Oscillation)
50
Object.YCollisionOffset *= Object.Speed
51
Object.YCollisionOffset += Object.YPos
52
Object.YCollisionOffset &= 0xFFFF0000 // Truncate the value
53
Object.YCollisionOffset -= Object.YDrawPos
54
else
55
switch Object.State
56
case CRUSHPLATFORM_DESCEND
57
Object.Oscillation += 4
58
Object.Oscillation &= 511
59
if Object.Oscillation == 128
60
Object.State++
61
end if
62
break
63
64
case CRUSHPLATFORM_WAIT
65
if Object.Timer < 64
66
Object.Timer++
67
else
68
Object.Timer = 0
69
Object.State++
70
end if
71
break
72
73
case CRUSHPLATFORM_ASCEND
74
Object.Oscillation += 4
75
Object.Oscillation &= 511
76
if Object.Oscillation == 384
77
Object.State++
78
end if
79
break
80
81
case CRUSHPLATFORM_WAIT_2
82
if Object.Timer < 64
83
Object.Timer++
84
else
85
Object.Timer = 0
86
Object.State = CRUSHPLATFORM_DESCEND
87
end if
88
break
89
end switch
90
91
Sin(Object.YCollisionOffset, Object.Oscillation)
92
Object.YCollisionOffset *= Object.Speed
93
Object.YCollisionOffset += Object.YPos
94
Object.YCollisionOffset &= 0xFFFF0000 // Truncate the value
95
Object.YCollisionOffset -= Object.YDrawPos
96
end if
97
end sub
98
99
100
sub ObjectPlayerInteraction
101
TempValue0 = Object.YPos
102
TempValue1 = Player.YPos
103
Object.YPos = Object.YDrawPos
104
105
if Object.LargePlatform == false
106
#platform: Use_Origins
107
PlayerObjectCollision(C_BOX2, -32, -32, 32, 32)
108
#endplatform
109
#platform: Use_Standalone
110
PlayerObjectCollision(C_BOX, -32, -32, 32, 32)
111
#endplatform
112
if CheckResult == PLAYER_COL_FLOOR
113
Player.YPos += Object.YCollisionOffset
114
else
115
if CheckResult == PLAYER_COL_ROOF
116
if Player.Gravity == GRAVITY_GROUND
117
if Object.YCollisionOffset > 0
118
CallFunction(Player_Kill)
119
else
120
Player.YPos = TempValue1
121
end if
122
else
123
#platform: Use_Origins
124
if Player.State == Player_State_LedgePullUp
125
CallFunction(Player_Kill)
126
end if
127
#endplatform
128
end if
129
end if
130
end if
131
else
132
#platform: Use_Origins
133
PlayerObjectCollision(C_BOX2, -32, -96, 32, 96)
134
#endplatform
135
#platform: Use_Standalone
136
PlayerObjectCollision(C_BOX, -32, -96, 32, 96)
137
#endplatform
138
if CheckResult == PLAYER_COL_FLOOR
139
Player.YPos += Object.YCollisionOffset
140
if Object.Oscillation == 320
141
142
#platform: Use_Origins
143
Player.State = Player_State_Air_NoDropDash
144
#endplatform
145
146
#platform: Use_Standalone
147
Player.State = Player_State_Air
148
#endplatform
149
Player.Timer = 0
150
Player.YVelocity = -0x100000
151
Player.Animation = ANI_BOUNCING
152
Player.Gravity = GRAVITY_AIR
153
Player.AnimationReserve = ANI_WALKING
154
end if
155
else
156
if CheckResult == PLAYER_COL_ROOF
157
if Player.Gravity == GRAVITY_GROUND
158
if Object.YCollisionOffset > 0
159
CallFunction(Player_Kill)
160
else
161
Player.YPos = TempValue1
162
end if
163
else
164
#platform: Use_Origins
165
if Player.State == Player_State_LedgePullUp
166
CallFunction(Player_Kill)
167
end if
168
#endplatform
169
end if
170
end if
171
end if
172
end if
173
Object.YPos = TempValue0
174
175
end sub
176
177
178
sub ObjectDraw
179
Sin(Object.YDrawPos, Object.Oscillation)
180
Object.YDrawPos *= Object.Speed
181
Object.YDrawPos += Object.YPos
182
Object.YDrawPos &= 0xFFFF0000 // Truncate the value
183
DrawSpriteXY(0, Object.XPos, Object.YDrawPos)
184
if Object.LargePlatform == true
185
DrawSpriteXY(1, Object.XPos, Object.YDrawPos)
186
DrawSpriteXY(2, Object.XPos, Object.YDrawPos)
187
end if
188
end sub
189
190
191
sub ObjectStartup
192
LoadSpriteSheet("R8/Objects.gif")
193
194
SpriteFrame(-32, -32, 64, 64, 1, 1) // #0 - Crush Platform (also the middle of the large Crush Platform)
195
SpriteFrame(-32, -96, 64, 64, 1, 1) // #1 - Large Crush Platform Top
196
SpriteFrame(-32, 32, 64, 64, 1, 1) // #2 - Large Crush Platform Bottom
197
198
199
ArrayPos0 = 32
200
while ArrayPos0 < 1056
201
if Object[ArrayPos0].Type == TypeName[Crush Platform]
202
Object[ArrayPos0].IncreaseValue = 2
203
if Object[ArrayPos0].PropertyValue == NORMAL_SPEED
204
Object[ArrayPos0].Speed = 0x1000
205
else
206
Object[ArrayPos0].Speed = 0x1800
207
end if
208
209
if Object[ArrayPos0].PropertyValue == LARGE_NORMAL_SPEED
210
Object[ArrayPos0].LargePlatform = true
211
Object[ArrayPos0].Speed = 0x1000
212
end if
213
214
if Object[ArrayPos0].PropertyValue == LARGE_FAST_SPEED
215
Object[ArrayPos0].LargePlatform = true
216
Object[ArrayPos0].Speed = 0x1800
217
end if
218
219
if Object[ArrayPos0].PropertyValue == NORMAL_FAST_LAUNCH
220
Object[ArrayPos0].IncreaseValue = 6
221
end if
222
end if
223
ArrayPos0++
224
loop
225
end sub
226
227
228
// ========================
229
// Editor Subs
230
// ========================
231
232
sub RSDKEdit
233
if Editor.ReturnVariable == true
234
switch Editor.VariableID
235
case EDIT_VAR_PROPVAL // Property Value
236
case 0 // Property Value
237
CheckResult = Object.PropertyValue
238
break
239
end switch
240
else
241
switch Editor.VariableID
242
case EDIT_VAR_PROPVAL // Property Value
243
if Editor.VariableValue >= 72
244
Object.PropertyValue = 72
245
else
246
if Editor.VariableValue >= 69
247
Object.PropertyValue = 69
248
else
249
if Editor.VariableValue >= 5
250
Object.PropertyValue = 5
251
else
252
if Editor.VariableValue >= 2
253
Object.PropertyValue = 2
254
else
255
Object.PropertyValue = Editor.VariableValue
256
end if
257
end if
258
end if
259
end if
260
break
261
case 0 // type
262
switch Editor.VariableValue
263
case 0
264
Object.PropertyValue = 0
265
break
266
case 1
267
Object.PropertyValue = 1
268
break
269
case 2
270
Object.PropertyValue = 5
271
break
272
case 3
273
Object.PropertyValue = 69
274
break
275
case 4
276
Object.PropertyValue = 72
277
break
278
end switch
279
break
280
end switch
281
end if
282
end sub
283
284
285
sub RSDKDraw
286
switch Object.PropertyValue
287
case NORMAL_SPEED
288
case LARGE_NORMAL_SPEED
289
TempValue2 = 0x1000
290
break
291
default
292
case LARGE_FAST_SPEED
293
TempValue2 = 0x1800
294
break
295
endswitch
296
297
Sin(TempValue5, 0)
298
TempValue5 *= TempValue2
299
TempValue5 += Object.YPos
300
TempValue5 &= 0xFFFF0000 // Truncate the value
301
DrawSpriteXY(0, Object.XPos, TempValue5)
302
switch Object.PropertyValue
303
case LARGE_NORMAL_SPEED
304
case LARGE_FAST_SPEED
305
DrawSpriteXY(1, Object.XPos, TempValue5)
306
DrawSpriteXY(2, Object.XPos, TempValue5)
307
break
308
end switch
309
if Editor.ShowGizmos == true
310
Editor.DrawingOverlay = true
311
TempValue0 = Object.YPos
312
switch Object.PropertyValue
313
case NORMAL_SPEED
314
case NORMAL_FAST_LAUNCH
315
TempValue0 -= 0x400000
316
DrawArrow(Object.XPos, Object.YPos, Object.XPos, TempValue0, 255, 255, 0)
317
TempValue0 += 0x800000
318
DrawArrow(Object.XPos, Object.YPos, Object.XPos, TempValue0, 255, 255, 0)
319
break
320
case LARGE_NORMAL_SPEED
321
case LARGE_FAST_SPEED
322
TempValue0 -= 0x800000
323
DrawArrow(Object.XPos, Object.YPos, Object.XPos, TempValue0, 255, 255, 0)
324
TempValue0 += 0x1100000
325
DrawArrow(Object.XPos, Object.YPos, Object.XPos, TempValue0, 255, 255, 0)
326
break
327
end switch
328
Editor.DrawingOverlay = false
329
end if
330
end sub
331
332
333
sub RSDKLoad
334
LoadSpriteSheet("R8/Objects.gif")
335
336
SpriteFrame(-32, -32, 64, 64, 1, 1) // #0 - Crush Platform (also the middle of the large Crush Platform)
337
SpriteFrame(-32, -96, 64, 64, 1, 1) // #1 - Large Crush Platform Top
338
SpriteFrame(-32, 32, 64, 64, 1, 1) // #2 - Large Crush Platform Bottom
339
340
AddEditorVariable("type")
341
SetActiveVariable("type")
342
AddEnumVariable("Normal Speed", 0)
343
AddEnumVariable("Normal Speed, Start Bottom", 1)
344
AddEnumVariable("Large, Normal Speed", 2)
345
AddEnumVariable("Large, Fast Speed", 3)
346
AddEnumVariable("Normal Speed, Fast Launch", 4)
347
end sub
348
349