Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-CD-2011-Script-Decompilation
Path: blob/main/Scripts/R5/HPlatformMedium1.txt
1319 views
1
//--------------Sonic CD HPlatformMedium1 Script--------------//
2
//--------Scripted by Christian Whitehead 'The Taxman'--------//
3
//-------Unpacked By Rubberduckycooly's Script Unpacker-------//
4
5
// Aliases
6
#alias Object.Value0 : Object.Pressed
7
8
#alias Object.Value1 : Object.PlatformY
9
#alias Object.Value2 : Object.ChangeY
10
11
#alias Object.Value3 : Object.PlatformX
12
#alias Object.Value4 : Object.ChangeX
13
14
#alias Object.Value5 : Object.Angle
15
16
#alias Object.Value6 : Object.Cooldown
17
18
// HUD Alias
19
#alias Object[24].PropertyValue : HUD.CurrentTimePeriod
20
21
// Time Period Aliases
22
#alias 0 : TIME_PRESENT
23
#alias 1 : TIME_PAST
24
#alias 2 : TIME_GOOD_FUTURE
25
#alias 3 : TIME_BAD_FUTURE
26
27
// Property Values
28
#alias 0 : START_MOVING_RIGHT
29
#alias 1 : START_MOVING_RIGHT_W/SPRING
30
#alias 2 : START_MOVING_RIGHT_W/CONV
31
#alias 3 : START_MOVING_LEFT
32
#alias 4 : START_MOVING_LEFT_W/SPRING
33
#alias 5 : START_MOVING_LEFT_W/CONV
34
35
36
sub ObjectMain
37
38
Object.Angle += 2
39
Object.Angle &= 511
40
41
Sin(Object.ChangeX, Object.Angle)
42
43
switch Object.PropertyValue
44
case START_MOVING_RIGHT
45
case START_MOVING_RIGHT_W/CONV
46
// Right-moving Platform
47
Object.ChangeX *= 0x1000
48
Object.ChangeX += 0x200000
49
Object.ChangeX += Object.XPos
50
Object.ChangeX &= 0xFFFF0000 // Truncate the value
51
Object.ChangeX -= Object.PlatformX
52
break
53
54
case START_MOVING_LEFT
55
case START_MOVING_LEFT_W/CONV
56
// Left-moving Platform
57
Object.ChangeX *= -0x1000
58
Object.ChangeX -= 0x200000
59
Object.ChangeX += Object.XPos
60
Object.ChangeX &= 0xFFFF0000 // Truncate the value
61
Object.ChangeX -= Object.PlatformX
62
break
63
64
case START_MOVING_RIGHT_W/SPRING
65
// Right-moving Carrier Object
66
Object.ChangeX *= 0x1000
67
Object.ChangeX += 0x200000
68
Object.ChangeX += Object.XPos
69
Object.ChangeX &= 0xFFFF0000 // Truncate the value
70
71
// Move the first Following Object
72
73
// Make it 16 Pixels to the left
74
Object[+1].XPos = Object.ChangeX
75
Object[+1].XPos -= 0x100000
76
77
// And 24 pixels above
78
Object[+1].YPos = Object.YPos
79
Object[+1].YPos -= 0x180000
80
81
// And then move the next Follower Object
82
83
// Make this one 16 pixels to the right
84
Object[+2].XPos = Object.ChangeX
85
Object[+2].XPos += 0x100000
86
87
// And also 24 pixels above
88
Object[+2].YPos = Object.YPos
89
Object[+2].YPos -= 0x180000
90
91
Object.ChangeX -= Object.PlatformX
92
break
93
94
case START_MOVING_LEFT_W/SPRING
95
// Left-moving Carrier Object
96
Object.ChangeX *= -0x1000
97
Object.ChangeX -= 0x200000
98
Object.ChangeX += Object.XPos
99
Object.ChangeX &= 0xFFFF0000 // Truncate the value
100
101
// Moving the first Follower Object
102
103
// Move it 16 pixels to the left from this Object
104
Object[+1].XPos = Object.ChangeX
105
Object[+1].XPos -= 0x100000
106
107
// And 24 pixels above
108
Object[+1].YPos = Object.YPos
109
Object[+1].YPos -= 0x180000
110
111
// And then the second Following Object
112
113
// 16 pixels, but this time to the right!
114
Object[+2].XPos = Object.ChangeX
115
Object[+2].XPos += 0x100000
116
117
// But this part's still 24 pixels up, yeah
118
Object[+2].YPos = Object.YPos
119
Object[+2].YPos -= 0x180000
120
121
Object.ChangeX -= Object.PlatformX
122
break
123
124
end switch
125
126
// Object.Pressed is originally set in ObjectPlayerInteraction
127
128
if Object.Pressed == true
129
if Object.PlatformY < 16
130
Object.PlatformY++
131
TempValue0 = Object.PlatformY
132
TempValue0 &= 3
133
if TempValue0 == 3
134
// Dip the Platform down by a pixel
135
Object.ChangeY = 0x10000
136
else
137
Object.ChangeY = 0
138
end if
139
else
140
Object.ChangeY = 0
141
end if
142
else
143
if Object.PlatformY > 0
144
Object.PlatformY--
145
TempValue0 = Object.PlatformY
146
TempValue0 &= 3
147
if TempValue0 == 3
148
// Restore the Platform upwards a little
149
Object.ChangeY = -0x10000
150
else
151
Object.ChangeY = 0
152
end if
153
else
154
Object.ChangeY = 0
155
end if
156
end if
157
158
// Reset Object.Pressed to be set again later this frame by ObjectPlayerInteraction
159
Object.Pressed = false
160
161
end sub
162
163
164
sub ObjectPlayerInteraction
165
166
// First, back up the Object's base Position
167
TempValue0 = Object.XPos
168
169
// Now, move the Object to where its Platform is
170
Object.XPos = Object.PlatformX
171
172
// From here, jump to the further handling type needed
173
switch Object.PropertyValue
174
case START_MOVING_RIGHT
175
case START_MOVING_LEFT
176
// Standard Platform type
177
178
PlayerObjectCollision(C_PLATFORM, -32, -16, 32, 12)
179
180
if CheckResult == true
181
182
// Since the Player's on the Platform, let the Platform Object know so that it can dip if needed
183
Object.Pressed = true
184
185
// And move the Player along with the Platform
186
Player.XPos += Object.ChangeX
187
Player.YPos += Object.ChangeY
188
189
end if
190
break
191
192
case START_MOVING_RIGHT_W/CONV
193
case START_MOVING_LEFT_W/CONV
194
// Conveyor Platform
195
196
if Object.Cooldown == 0
197
PlayerObjectCollision(C_PLATFORM, -32, -16, 32, 12)
198
199
if CheckResult == true
200
201
// The Player's on the Platform, let the Platform Object know so that it can dip as needed
202
Object.Pressed = true
203
204
// Carry the Player along with the Platform in order to keep them on
205
Player.XPos += Object.ChangeX
206
Player.YPos += Object.ChangeY
207
208
// And then push the Player as needed for the Conveyor
209
if ConveyorBelt_Flag == 0
210
Player.XPos += ConveyorBelt_Speed
211
else
212
Player.XPos -= ConveyorBelt_Speed
213
end if
214
215
// If the Player is in a Flailing animation, then they're on the edge of the Platform
216
// However! This is a Conveyor Platform!
217
218
// So to prevent an issue where the Player gets pushed off, regrabbed the next frame, then pushed off, then [...]
219
// There's a cooldown if the Player is detected to be on the edge
220
221
// Perhaps half a second may be a bit long for the cooldown, but it serves its use nonetheless
222
223
if Player.Animation == ANI_FLAILINGLEFT
224
Object.Cooldown = 30
225
end if
226
227
if Player.Animation == ANI_FLAILINGRIGHT
228
Object.Cooldown = 30
229
end if
230
231
end if
232
else
233
// Don't want to catch the Player again just yet, hold...
234
Object.Cooldown--
235
end if
236
break
237
238
// cases 1/4 don't have anything
239
// They shouldn't interact with the Player, since they have Springs riding atop them
240
// so the Player shouldn't be able to land on the Platform itself
241
242
end switch
243
244
// And now restore the Object's Position
245
Object.XPos = TempValue0
246
247
end sub
248
249
250
sub ObjectDraw
251
252
// Move the Object to where its new Y position should be
253
Object.YPos += Object.ChangeY
254
255
switch Object.PropertyValue
256
case START_MOVING_RIGHT
257
case START_MOVING_RIGHT_W/SPRING
258
// Right-moving Platform
259
Sin(Object.PlatformX, Object.Angle)
260
Object.PlatformX *= 0x1000
261
Object.PlatformX += 0x200000
262
Object.PlatformX += Object.XPos
263
Object.PlatformX &= 0xFFFF0000 // Truncate the value
264
DrawSpriteXY(0, Object.PlatformX, Object.YPos)
265
break
266
267
case START_MOVING_RIGHT_W/CONV
268
// Right-moving Conveyor Platform
269
Sin(Object.PlatformX, Object.Angle)
270
Object.PlatformX *= 0x1000
271
Object.PlatformX += 0x200000
272
Object.PlatformX += Object.XPos
273
Object.PlatformX &= 0xFFFF0000 // Truncate the value
274
DrawSpriteXY(0, Object.PlatformX, Object.YPos)
275
DrawSpriteXY(1, Object.PlatformX, Object.YPos)
276
break
277
278
case START_MOVING_LEFT
279
case START_MOVING_LEFT_W/SPRING
280
// Left-moving Platform
281
Sin(Object.PlatformX, Object.Angle)
282
Object.PlatformX *= -0x1000
283
Object.PlatformX -= 0x200000
284
Object.PlatformX += Object.XPos
285
Object.PlatformX &= 0xFFFF0000 // Truncate the value
286
DrawSpriteXY(0, Object.PlatformX, Object.YPos)
287
break
288
289
case START_MOVING_LEFT_W/CONV
290
// Left-moving Conveyor Platform
291
Sin(Object.PlatformX, Object.Angle)
292
Object.PlatformX *= -0x1000
293
Object.PlatformX -= 0x200000
294
Object.PlatformX += Object.XPos
295
Object.PlatformX &= 0xFFFF0000 // Truncate the value
296
DrawSpriteXY(0, Object.PlatformX, Object.YPos)
297
DrawSpriteXY(1, Object.PlatformX, Object.YPos)
298
break
299
300
end switch
301
302
end sub
303
304
305
sub ObjectStartup
306
307
LoadSpriteSheet("R5/Objects.gif")
308
309
// Use different Sprites for the different Time Periods
310
switch HUD.CurrentTimePeriod
311
case TIME_PRESENT
312
LoadSpriteSheet("R5/Objects.gif")
313
SpriteFrame(-32, -16, 64, 32, 34, 51)
314
SpriteFrame(-32, -16, 64, 16, 1, 208)
315
break
316
317
case TIME_PAST
318
LoadSpriteSheet("R5/Objects3.gif")
319
SpriteFrame(-32, -16, 64, 32, 34, 170)
320
SpriteFrame(-32, -16, 64, 16, 159, 148)
321
break
322
323
case TIME_GOOD_FUTURE
324
LoadSpriteSheet("R5/Objects3.gif")
325
SpriteFrame(-32, -16, 64, 32, 34, 170)
326
SpriteFrame(-32, -16, 64, 16, 159, 182)
327
break
328
329
case TIME_BAD_FUTURE
330
LoadSpriteSheet("R5/Objects3.gif")
331
SpriteFrame(-32, -16, 64, 32, 34, 170)
332
SpriteFrame(-32, -16, 64, 16, 159, 216)
333
break
334
335
end switch
336
337
end sub
338
339
340
// ========================
341
// Editor Subs
342
// ========================
343
344
sub RSDKEdit
345
if Editor.ReturnVariable == true
346
switch Editor.VariableID
347
case EDIT_VAR_PROPVAL // Property Value
348
CheckResult = Object.PropertyValue
349
break
350
case 0 // Direction
351
CheckResult = Object.PropertyValue
352
break
353
end switch
354
else
355
switch Editor.VariableID
356
case EDIT_VAR_PROPVAL // Property Value
357
Object.PropertyValue = Editor.VariableValue
358
break
359
case 0 // Direction
360
Object.PropertyValue = Editor.VariableValue
361
break
362
end switch
363
end if
364
end sub
365
366
367
sub RSDKDraw
368
TempValue2 = 0
369
370
switch Object.PropertyValue
371
case 2
372
TempValue2 = 1
373
default
374
case 0
375
case 1
376
TempValue0 = 0x1000
377
TempValue1 = 0x200000
378
break
379
380
case 5
381
TempValue2 = 1
382
case 3
383
case 4
384
TempValue0 = -0x1000
385
TempValue1 = -0x200000
386
break
387
388
end switch
389
390
DrawSprite(0)
391
DrawSprite(TempValue2)
392
393
if Editor.ShowGizmos == true
394
Editor.DrawingOverlay = true
395
396
// Draw the Platform's path
397
398
TempValue3 = Object.XPos
399
TempValue3 &= 0xFFFF0000 // Truncate the value
400
401
Sin(TempValue4, 128)
402
TempValue4 *= TempValue0
403
TempValue4 += TempValue1
404
TempValue4 += Object.XPos
405
TempValue4 &= 0xFFFF0000 // Truncate the value
406
407
DrawLine(TempValue3, Object.YPos, TempValue4, Object.YPos, 255, 255, 255)
408
409
Editor.DrawingOverlay = false
410
end if
411
end sub
412
413
414
sub RSDKLoad
415
LoadSpriteSheet("R5/Objects.gif")
416
// TODO using present frames here, something something other time perids
417
SpriteFrame(-32, -16, 64, 32, 34, 51)
418
SpriteFrame(-32, -16, 64, 16, 1, 208)
419
420
AddEditorVariable("Direction")
421
SetActiveVariable("Direction")
422
AddEnumVariable("Right", 0)
423
AddEnumVariable("Right (Spring)", 1)
424
AddEnumVariable("Right (Conveyor)", 2)
425
AddEnumVariable("Left", 3)
426
AddEnumVariable("Left (Spring)", 4)
427
AddEnumVariable("Left (Conveyor)", 5)
428
end sub
429
430