Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-CD-2011-Script-Decompilation
Path: blob/main/Scripts/R5/HPlatformLarge.txt
1319 views
1
//--------------Sonic CD HPlatform Large 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
#alias Object.Value6 : Object.Oscillation
16
17
#alias Object.Value7 : Object.Cooldown
18
19
// HUD Alias
20
#alias Object[24].PropertyValue : HUD.CurrentTimePeriod
21
22
// Time Period Aliases
23
#alias 0 : TIME_PRESENT
24
#alias 1 : TIME_PAST
25
#alias 2 : TIME_GOOD_FUTURE
26
#alias 3 : TIME_BAD_FUTURE
27
28
// Property Values
29
#alias 0 : START_MOVING_RIGHT
30
#alias 1 : START_MOVING_RIGHT_W/SPRING
31
#alias 2 : START_MOVING_RIGHT_W/CONV
32
#alias 3 : START_MOVING_LEFT
33
#alias 4 : START_MOVING_LEFT_W/SPRING
34
#alias 5 : START_MOVING_LEFT_W/CONV
35
36
37
38
sub ObjectMain
39
40
// Update this Object's Oscillation Value
41
// 312 may seem like a rather random value, but you'll see why it's used in a moment...
42
Object.Oscillation++
43
if Object.Oscillation == 312
44
Object.Oscillation = 0
45
end if
46
47
// From this Oscillation value, get the object's Angle
48
// This Angle will range from 0-510
49
Object.Angle = Object.Oscillation
50
Object.Angle <<= 6
51
Object.Angle /= 39
52
53
// And then from this Angle, get the base X Change Value
54
Sin(Object.ChangeX, Object.Angle)
55
56
switch Object.PropertyValue
57
case START_MOVING_RIGHT
58
case START_MOVING_RIGHT_W/CONV
59
// Right-moving Platform
60
Object.ChangeX *= 0x1800
61
Object.ChangeX += 0x300000
62
Object.ChangeX += Object.XPos
63
Object.ChangeX &= 0xFFFF0000 // Truncate the value
64
Object.ChangeX -= Object.PlatformX
65
break
66
67
case START_MOVING_LEFT
68
case START_MOVING_LEFT_W/CONV
69
// Left-moving Platform
70
Object.ChangeX *= -0x1800
71
Object.ChangeX -= 0x300000
72
Object.ChangeX += Object.XPos
73
Object.ChangeX &= 0xFFFF0000 // Truncate the value
74
Object.ChangeX -= Object.PlatformX
75
break
76
77
case START_MOVING_RIGHT_W/SPRING
78
// Right-moving Carrier Platform
79
Object.ChangeX *= 0x1800
80
Object.ChangeX += 0x300000
81
Object.ChangeX += Object.XPos
82
Object.ChangeX &= 0xFFFF0000 // Truncate the value
83
84
// Move the first following Object
85
86
// Make it 32 pixels to the left of this Object
87
Object[+1].XPos = Object.ChangeX
88
Object[+1].XPos -= 0x200000
89
90
// And 24 pixels above
91
Object[+1].YPos = Object.YPos
92
Object[+1].YPos -= 0x180000
93
94
// And then comes the second following Object
95
96
// This one will be in the center of the Platform
97
Object[+2].XPos = Object.ChangeX
98
99
// And also 24 pixels above
100
Object[+2].YPos = Object.YPos
101
Object[+2].YPos -= 0x180000
102
103
// And then the last, third riding Object
104
105
// 32 pixels to the right
106
Object[+3].XPos = Object.ChangeX
107
Object[+3].XPos += 0x200000
108
109
// And, of course, 24 pixels above again
110
Object[+3].YPos = Object.YPos
111
Object[+3].YPos -= 0x180000
112
113
Object.ChangeX -= Object.PlatformX
114
break
115
116
case START_MOVING_LEFT_W/SPRING
117
// Left-moving Carrier Platform
118
Object.ChangeX *= -0x1800
119
Object.ChangeX -= 0x300000
120
Object.ChangeX += Object.XPos
121
Object.ChangeX &= 0xFFFF0000 // Truncate the value
122
123
// Move the first Following Object
124
125
// 32 pixels to the left
126
Object[+1].XPos = Object.ChangeX
127
Object[+1].XPos -= 0x200000
128
129
// 24 pixels above
130
Object[+1].YPos = Object.YPos
131
Object[+1].YPos -= 0x180000
132
133
// Next Object!
134
135
// Same X as the Platform
136
Object[+2].XPos = Object.ChangeX
137
138
// 24 pixels above
139
Object[+2].YPos = Object.YPos
140
Object[+2].YPos -= 0x180000
141
142
// Final Rider Object!
143
144
// 32 pixels right
145
Object[+3].XPos = Object.ChangeX
146
Object[+3].XPos += 0x200000
147
148
// And 24 pixels above
149
Object[+3].YPos = Object.YPos
150
Object[+3].YPos -= 0x180000
151
152
Object.ChangeX -= Object.PlatformX
153
break
154
155
end switch
156
157
if Object.Pressed == true
158
if Object.PlatformY < 16
159
Object.PlatformY++
160
TempValue0 = Object.PlatformY
161
TempValue0 &= 3
162
if TempValue0 == 3
163
// Dip a pixel down
164
Object.ChangeY = 0x10000
165
else
166
Object.ChangeY = 0
167
end if
168
else
169
Object.ChangeY = 0
170
end if
171
else
172
if Object.PlatformY > 0
173
Object.PlatformY--
174
TempValue0 = Object.PlatformY
175
TempValue0 &= 3
176
if TempValue0 == 3
177
// Go back up a pixel
178
Object.ChangeY = -0x10000
179
else
180
Object.ChangeY = 0
181
end if
182
else
183
Object.ChangeY = 0
184
end if
185
end if
186
187
Object.Pressed = false
188
189
end sub
190
191
192
sub ObjectPlayerInteraction
193
194
// Before doing anything else, back up the Object's base position
195
TempValue0 = Object.XPos
196
197
// Then, move the Object to where its Platform is
198
Object.XPos = Object.PlatformX
199
200
// And now, jump to the handling type needed
201
switch Object.PropertyValue
202
case START_MOVING_RIGHT
203
case START_MOVING_LEFT
204
// Standard Platform
205
206
PlayerObjectCollision(C_PLATFORM, -48, -16, 48, 12)
207
208
if CheckResult == true
209
210
// Since the Player's on the Platform, let the Platform Object know so it can dip
211
Object.Pressed = true
212
213
// And carry the Player along with the Platform
214
Player.XPos += Object.ChangeX
215
Player.YPos += Object.ChangeY
216
217
end if
218
break
219
220
case START_MOVING_RIGHT_W/CONV
221
case START_MOVING_LEFT_W/CONV
222
// Conveyor Platform
223
224
if Object.Cooldown == 0
225
PlayerObjectCollision(C_PLATFORM, -48, -16, 48, 12)
226
227
if CheckResult == true
228
229
// Now that the Player's on the Platform, let the Platform Object know
230
Object.Pressed = true
231
232
// Move the Player along with the Platform to keep them on
233
Player.XPos += Object.ChangeX
234
Player.YPos += Object.ChangeY
235
236
if ConveyorBelt_Flag == false
237
Player.XPos += ConveyorBelt_Speed
238
else
239
Player.XPos -= ConveyorBelt_Speed
240
end if
241
242
// On the note of keeping the Player on the Platform...
243
244
// Activate a small cooldown if the Player is seen to be on the edge of this Platform
245
// This is to prevent an issue where the Player will repeatedly get pushed off and regrabbed by the Platform
246
247
if Player.Animation == ANI_FLAILINGLEFT
248
Object.Cooldown = 30
249
end if
250
if Player.Animation == ANI_FLAILINGRIGHT
251
Object.Cooldown = 30
252
end if
253
end if
254
else
255
// Hold...
256
Object.Cooldown--
257
end if
258
break
259
260
end switch
261
262
// And now restore the Object's Position
263
Object.XPos = TempValue0
264
265
end sub
266
267
268
sub ObjectDraw
269
270
// Move the Object to match where it should be
271
Object.YPos += Object.ChangeY
272
273
switch Object.PropertyValue
274
case START_MOVING_RIGHT
275
case START_MOVING_RIGHT_W/SPRING
276
// Right-moving Platform
277
Sin(Object.PlatformX, Object.Angle)
278
Object.PlatformX *= 0x1800
279
Object.PlatformX += 0x300000
280
Object.PlatformX += Object.XPos
281
Object.PlatformX &= 0xFFFF0000 // Truncate the value
282
DrawSpriteXY(0, Object.PlatformX, Object.YPos)
283
break
284
285
case START_MOVING_RIGHT_W/CONV
286
// Right-moving Conveyor Platform
287
Sin(Object.PlatformX, Object.Angle)
288
Object.PlatformX *= 0x1800
289
Object.PlatformX += 0x300000
290
Object.PlatformX += Object.XPos
291
Object.PlatformX &= 0xFFFF0000 // Truncate the value
292
DrawSpriteXY(0, Object.PlatformX, Object.YPos)
293
DrawSpriteXY(1, Object.PlatformX, Object.YPos)
294
break
295
296
case START_MOVING_LEFT
297
case START_MOVING_LEFT_W/SPRING
298
// Left-moving Platform
299
Sin(Object.PlatformX, Object.Angle)
300
Object.PlatformX *= -0x1800
301
Object.PlatformX -= 0x300000
302
Object.PlatformX += Object.XPos
303
Object.PlatformX &= 0xFFFF0000 // Truncate the value
304
DrawSpriteXY(0, Object.PlatformX, Object.YPos)
305
break
306
307
case START_MOVING_LEFT_W/CONV
308
// Left-moving Conveyor Platform
309
Sin(Object.PlatformX, Object.Angle)
310
Object.PlatformX *= -0x1800
311
Object.PlatformX -= 0x300000
312
Object.PlatformX += Object.XPos
313
Object.PlatformX &= 0xFFFF0000 // Truncate the value
314
DrawSpriteXY(0, Object.PlatformX, Object.YPos)
315
DrawSpriteXY(1, Object.PlatformX, Object.YPos)
316
break
317
318
end switch
319
320
end sub
321
322
323
sub ObjectStartup
324
325
LoadSpriteSheet("R5/Objects.gif")
326
327
// Use different graphics for the different Time Periods
328
switch HUD.CurrentTimePeriod
329
case TIME_PRESENT
330
LoadSpriteSheet("R5/Objects.gif")
331
SpriteFrame(-48, -16, 96, 32, 1, 84)
332
SpriteFrame(-48, -16, 96, 16, 1, 191)
333
break
334
335
case TIME_PAST
336
LoadSpriteSheet("R5/Objects3.gif")
337
SpriteFrame(-48, -16, 96, 32, 1, 203)
338
SpriteFrame(-48, -16, 96, 16, 159, 131)
339
break
340
341
case TIME_GOOD_FUTURE
342
LoadSpriteSheet("R5/Objects3.gif")
343
SpriteFrame(-48, -16, 96, 32, 1, 203)
344
SpriteFrame(-48, -16, 96, 16, 159, 165)
345
break
346
347
case TIME_BAD_FUTURE
348
LoadSpriteSheet("R5/Objects3.gif")
349
SpriteFrame(-48, -16, 96, 32, 1, 203)
350
SpriteFrame(-48, -16, 96, 16, 159, 199)
351
break
352
353
end switch
354
355
end sub
356
357
358
// ========================
359
// Editor Subs
360
// ========================
361
362
sub RSDKDraw
363
364
TempValue2 = false
365
366
switch Object.PropertyValue
367
case 2
368
TempValue2 = true
369
case 0
370
case 1
371
TempValue0 = 0x1800
372
TempValue1 = 0x300000
373
break
374
375
376
case 5
377
TempValue2 = true
378
case 3
379
case 4
380
TempValue0 = -0x1800
381
TempValue1 = -0x300000
382
break
383
384
end switch
385
386
TempValue3 = Object.XPos
387
TempValue3 &= 0xFFFF0000 // Truncate the value
388
DrawSpriteXY(0, TempValue3, Object.YPos)
389
DrawSpriteXY(TempValue2, TempValue3, Object.YPos)
390
391
if Editor.ShowGizmos == true
392
Editor.DrawingOverlay = true
393
394
// Show the Platform's path
395
396
Sin(TempValue4, 128)
397
TempValue4 *= TempValue0
398
TempValue4 += TempValue1
399
TempValue4 += Object.XPos
400
TempValue4 &= 0xFFFF0000 // Truncate the value
401
402
DrawLine(TempValue3, Object.YPos, TempValue4, Object.YPos, 255, 255, 255)
403
404
Editor.DrawingOverlay = false
405
end if
406
407
end sub
408
409
410
sub RSDKLoad
411
LoadSpriteSheet("R5/Objects.gif")
412
// TODO: using present frames, why does r5 have like 20 platform objects i've wrote this comment like 19 times already
413
SpriteFrame(-48, -16, 96, 32, 1, 84)
414
SpriteFrame(-48, -16, 96, 16, 1, 191)
415
416
AddEditorVariable("Direction")
417
SetActiveVariable("Direction")
418
AddEnumVariable("Right", 0)
419
AddEnumVariable("Right (Spring)", 1)
420
AddEnumVariable("Right (Conveyor)", 2)
421
AddEnumVariable("Left", 3)
422
AddEnumVariable("Left (Spring)", 4)
423
AddEnumVariable("Left (Conveyor)", 5)
424
end sub
425
426