Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-CD-2011-Script-Decompilation
Path: blob/main/Scripts/R5/HPlatformSmall.txt
1319 views
1
//--------------Sonic CD HPlatform Small Script---------------//
2
//--------Scripted by Christian Whitehead 'The Taxman'--------//
3
//-------Unpacked By Rubberduckycooly's Script Unpacker-------//
4
5
// Aliases
6
7
#alias Object.Value0 : Object.Pressed
8
9
#alias Object.Value1 : Object.PlatformY
10
#alias Object.Value2 : Object.ChangeY
11
12
#alias Object.Value3 : Object.PlatformX
13
#alias Object.Value4 : Object.ChangeX
14
15
#alias Object.Value5 : Object.Angle
16
#alias Object.Value6 : Object.Oscillation
17
18
#alias Object.Value7 : Object.Cooldown
19
20
// HUD Alias
21
#alias Object[24].PropertyValue : HUD.CurrentTimePeriod
22
23
// Time Period Aliases
24
#alias 0 : TIME_PRESENT
25
#alias 1 : TIME_PAST
26
#alias 2 : TIME_GOOD_FUTURE
27
#alias 3 : TIME_BAD_FUTURE
28
29
// Property Values
30
#alias 0 : START_MOVING_RIGHT
31
#alias 1 : START_MOVING_RIGHT_W/SPRING
32
#alias 2 : START_MOVING_RIGHT_W/CONV
33
#alias 3 : START_MOVING_LEFT
34
#alias 4 : START_MOVING_LEFT_W/SPRING
35
#alias 5 : START_MOVING_LEFT_W/CONV
36
37
38
sub ObjectMain
39
40
// Update the Platform's Oscillation value
41
Object.Oscillation++
42
if Object.Oscillation == 312
43
Object.Oscillation = 0
44
end if
45
46
// From that Oscillation value, get the Angle the Platform should be at
47
Object.Angle = Object.Oscillation
48
Object.Angle <<= 6
49
Object.Angle /= 39
50
51
// And then from this Angle, get the base Change Value
52
Sin(Object.ChangeX, Object.Angle)
53
54
switch Object.PropertyValue
55
case START_MOVING_RIGHT
56
case START_MOVING_RIGHT_W/CONV
57
// Going Right Platform
58
Object.ChangeX *= 0x1800
59
Object.ChangeX += 0x300000
60
Object.ChangeX += Object.XPos
61
Object.ChangeX &= 0xFFFF0000 // Truncate the value
62
Object.ChangeX -= Object.PlatformX
63
break
64
65
case START_MOVING_LEFT
66
case START_MOVING_LEFT_W/CONV
67
// Going Left Platform
68
Object.ChangeX *= -0x1800
69
Object.ChangeX -= 0x300000
70
Object.ChangeX += Object.XPos
71
Object.ChangeX &= 0xFFFF0000 // Truncate the value
72
Object.ChangeX -= Object.PlatformX
73
break
74
75
case START_MOVING_RIGHT_W/SPRING
76
// Going Right Platform, carrying an Object
77
Object.ChangeX *= 0x1800
78
Object.ChangeX += 0x300000
79
Object.ChangeX += Object.XPos
80
Object.ChangeX &= 0xFFFF0000 // Truncate the value
81
82
// Move the following Object along with the Platform
83
Object[+1].XPos = Object.ChangeX
84
85
// Make it 24 pixels above this Platform
86
Object[+1].YPos = Object.YPos
87
Object[+1].YPos -= 0x180000
88
89
// And then turn the "Change" value into the actual difference
90
Object.ChangeX -= Object.PlatformX
91
break
92
93
case START_MOVING_LEFT_W/SPRING
94
// Platform going Left, with a rider Object
95
Object.ChangeX *= -0x1800
96
Object.ChangeX -= 0x300000
97
Object.ChangeX += Object.XPos
98
Object.ChangeX &= 0xFFFF0000 // Truncate the value
99
100
// Move the riding Object to match this Platform
101
Object[+1].XPos = Object.ChangeX
102
103
// And make it 24 pixels above, so that its bottom is on this Platform's top
104
Object[+1].YPos = Object.YPos
105
Object[+1].YPos -= 0x180000
106
107
// And with that, get the actual Change value
108
Object.ChangeX -= Object.PlatformX
109
break
110
111
end switch
112
113
// Update Platforming dipping
114
if Object.Pressed == true
115
if Object.PlatformY < 16
116
Object.PlatformY++
117
TempValue0 = Object.PlatformY
118
TempValue0 &= 3
119
if TempValue0 == 3
120
// Move down a pixel
121
Object.ChangeY = 0x10000
122
else
123
Object.ChangeY = 0
124
end if
125
else
126
Object.ChangeY = 0
127
end if
128
else
129
if Object.PlatformY > 0
130
Object.PlatformY--
131
TempValue0 = Object.PlatformY
132
TempValue0 &= 3
133
if TempValue0 == 3
134
// Recover back up 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
end if
143
144
Object.Pressed = false
145
146
end sub
147
148
149
sub ObjectPlayerInteraction
150
151
// First, backup the Object's base Position
152
TempValue0 = Object.XPos
153
154
// Then, move it to where the Platform actually is
155
Object.XPos = Object.PlatformX
156
157
// From here, jump to the handling type needed
158
switch Object.PropertyValue
159
case START_MOVING_RIGHT
160
case START_MOVING_LEFT
161
// Standard Platform
162
163
PlayerObjectCollision(C_PLATFORM, -16, -16, 16, 12)
164
165
if CheckResult == true
166
167
// The Player is on the Platform, so set the Platform's variable so that
168
// it can dip accordingly
169
Object.Pressed = true
170
171
// And then move the Player with the Platform as needed
172
Player.XPos += Object.ChangeX
173
Player.YPos += Object.ChangeY
174
175
end if
176
break
177
178
case START_MOVING_RIGHT_W/CONV
179
case START_MOVING_LEFT_W/CONV
180
// Conveyor Platform
181
182
if Object.Cooldown == 0
183
PlayerObjectCollision(C_PLATFORM, -16, -16, 16, 12)
184
185
if CheckResult == true
186
187
// Let the Platform object know that the Player's mounted so that it can dip
188
Object.Pressed = true
189
190
// Carry the Player along with the Platform's movement
191
Player.XPos += Object.ChangeX
192
Player.YPos += Object.ChangeY
193
194
// And then update them for the Conveyor's movement too
195
if ConveyorBelt_Flag == 0
196
Player.XPos += ConveyorBelt_Speed
197
else
198
Player.XPos -= ConveyorBelt_Speed
199
end if
200
201
// If the Player is in their balancing animation, then it means that they're on the edge of the Platform
202
// However, this is a Conveyor Platform!
203
204
// To prevent an issue where
205
// the Player gets pushed off and then regrabbed by platform and then pushed off and then regrabbed and so on,
206
// there is a half second cooldown activated if the Player is noticed to be flailing on the edge
207
208
if Player.Animation == ANI_FLAILINGLEFT
209
Object.Cooldown = 30
210
end if
211
212
if Player.Animation == ANI_FLAILINGRIGHT
213
Object.Cooldown = 30
214
end if
215
end if
216
else
217
// Hold for a moment and decrease the countdown...
218
Object.Cooldown--
219
end if
220
break
221
222
// cases 1 & 4 are skipped over - they have springs riding them so
223
// the Player should never be able to land on the Platform itself
224
225
end switch
226
227
// And now restore the Object's Position
228
Object.XPos = TempValue0
229
230
end sub
231
232
233
sub ObjectDraw
234
235
// Move the Object as needed for its dipping
236
Object.YPos += Object.ChangeY
237
238
switch Object.PropertyValue
239
case START_MOVING_RIGHT
240
case START_MOVING_RIGHT_W/SPRING
241
// Right-moving Platform
242
Sin(Object.PlatformX, Object.Angle)
243
Object.PlatformX *= 0x1800
244
Object.PlatformX += 0x300000
245
Object.PlatformX += Object.XPos
246
Object.PlatformX &= 0xFFFF0000 // Truncate the value
247
DrawSpriteXY(0, Object.PlatformX, Object.YPos)
248
break
249
250
case START_MOVING_RIGHT_W/CONV
251
// Right-moving Conveyor Platform
252
Sin(Object.PlatformX, Object.Angle)
253
Object.PlatformX *= 0x1800
254
Object.PlatformX += 0x300000
255
Object.PlatformX += Object.XPos
256
Object.PlatformX &= 0xFFFF0000 // Truncate the value
257
DrawSpriteXY(0, Object.PlatformX, Object.YPos)
258
DrawSpriteXY(1, Object.PlatformX, Object.YPos)
259
break
260
261
case START_MOVING_LEFT
262
case START_MOVING_LEFT_W/SPRING
263
// Left-moving Platform
264
Sin(Object.PlatformX, Object.Angle)
265
Object.PlatformX *= -0x1800
266
Object.PlatformX -= 0x300000
267
Object.PlatformX += Object.XPos
268
Object.PlatformX &= 0xFFFF0000 // Truncate the value
269
DrawSpriteXY(0, Object.PlatformX, Object.YPos)
270
break
271
272
case START_MOVING_LEFT_W/CONV
273
// Left-moving Conveyor Platform
274
Sin(Object.PlatformX, Object.Angle)
275
Object.PlatformX *= -0x1800
276
Object.PlatformX -= 0x300000
277
Object.PlatformX += Object.XPos
278
Object.PlatformX &= 0xFFFF0000 // Truncate the value
279
DrawSpriteXY(0, Object.PlatformX, Object.YPos)
280
DrawSpriteXY(1, Object.PlatformX, Object.YPos)
281
break
282
283
end switch
284
285
end sub
286
287
288
sub ObjectStartup
289
290
LoadSpriteSheet("R5/Objects.gif")
291
292
// Load the needed sprites based on the current Time Period
293
switch HUD.CurrentTimePeriod
294
case TIME_PRESENT
295
LoadSpriteSheet("R5/Objects.gif")
296
SpriteFrame(-16, -16, 32, 32, 1, 51)
297
SpriteFrame(-16, -16, 32, 16, 65, 208)
298
break
299
300
case TIME_PAST
301
LoadSpriteSheet("R5/Objects3.gif")
302
SpriteFrame(-16, -16, 32, 32, 1, 170)
303
SpriteFrame(-16, -16, 32, 16, 223, 148)
304
break
305
306
case TIME_GOOD_FUTURE
307
LoadSpriteSheet("R5/Objects3.gif")
308
SpriteFrame(-16, -16, 32, 32, 1, 170)
309
SpriteFrame(-16, -16, 32, 16, 223, 182)
310
break
311
312
case TIME_BAD_FUTURE
313
LoadSpriteSheet("R5/Objects3.gif")
314
SpriteFrame(-16, -16, 32, 32, 1, 170)
315
SpriteFrame(-16, -16, 32, 16, 223, 216)
316
break
317
318
end switch
319
320
end sub
321
322
323
// ========================
324
// Editor Subs
325
// ========================
326
327
sub RSDKEdit
328
if Editor.ReturnVariable == true
329
switch Editor.VariableID
330
case EDIT_VAR_PROPVAL // Property Value
331
CheckResult = Object.PropertyValue
332
break
333
case 0 // Direction
334
CheckResult = Object.PropertyValue
335
break
336
end switch
337
else
338
switch Editor.VariableID
339
case EDIT_VAR_PROPVAL // Property Value
340
Object.PropertyValue = Editor.VariableValue
341
break
342
case 0 // Direction
343
Object.PropertyValue = Editor.VariableValue
344
break
345
end switch
346
end if
347
end sub
348
349
350
sub RSDKDraw
351
352
TempValue2 = 0
353
switch Object.PropertyValue
354
case 2
355
TempValue2 = 1
356
default
357
case 0
358
case 1
359
TempValue0 = 0x1800
360
TempValue1 = 0x300000
361
break
362
363
case 5
364
TempValue2 = 1
365
case 3
366
case 4
367
TempValue0 = -0x1800
368
TempValue1 = -0x300000
369
break
370
371
end switch
372
373
TempValue3 = Object.XPos
374
TempValue3 &= 0xFFFF0000 // Truncate the value
375
DrawSpriteXY(0, TempValue3, Object.YPos)
376
DrawSpriteXY(TempValue2, TempValue3, Object.YPos)
377
378
if Editor.ShowGizmos == true
379
380
// Get the end destination for the Platform
381
Sin(TempValue4, 128)
382
TempValue4 *= TempValue0
383
TempValue4 += TempValue1
384
TempValue4 += Object.XPos
385
TempValue4 &= 0xFFFF0000 // Truncate the value
386
387
Editor.DrawingOverlay = true
388
389
DrawLine(TempValue3, Object.YPos, TempValue4, Object.YPos, 255, 255, 255)
390
391
Editor.DrawingOverlay = false
392
end if
393
394
end sub
395
396
397
sub RSDKLoad
398
LoadSpriteSheet("R5/Objects.gif")
399
// TODO: using present frames, adapt this for other time periods
400
SpriteFrame(-16, -16, 32, 32, 1, 51)
401
SpriteFrame(-16, -16, 32, 16, 65, 208)
402
403
AddEditorVariable("Direction")
404
SetActiveVariable("Direction")
405
AddEnumVariable("Right", 0)
406
AddEnumVariable("Right (Spring)", 1)
407
AddEnumVariable("Right (Conveyor)", 2)
408
AddEnumVariable("Left", 3)
409
AddEnumVariable("Left (Spring)", 4)
410
AddEnumVariable("Left (Conveyor)", 5)
411
end sub
412
413