Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-CD-2011-Script-Decompilation
Path: blob/main/Scripts/R5/HPlatformMedium2.txt
1319 views
1
//--------------Sonic CD HPlatformMedium2 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
sub ObjectMain
38
39
// Update the Platform's Oscillation value
40
// Do note, that because this Oscillation is per-object and
41
// not global, that means Platforms won't be synced
42
Object.Oscillation++
43
if Object.Oscillation == 312
44
Object.Oscillation = 0
45
end if
46
47
// From this Oscillation value, get the Platform's Angle to be at
48
// This resulting value will range from 0 to 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
Object.ChangeX *= 0x1800
60
Object.ChangeX += 0x300000
61
Object.ChangeX += Object.XPos
62
Object.ChangeX &= 0xFFFF0000 // Truncate the value
63
Object.ChangeX -= Object.PlatformX
64
break
65
case START_MOVING_LEFT
66
case START_MOVING_LEFT_W/CONV
67
Object.ChangeX *= -0x1800
68
Object.ChangeX -= 0x300000
69
Object.ChangeX += Object.XPos
70
Object.ChangeX &= 0xFFFF0000 // Truncate the value
71
Object.ChangeX -= Object.PlatformX
72
break
73
case START_MOVING_RIGHT_W/SPRING
74
Object.ChangeX *= 0x1800
75
Object.ChangeX += 0x300000
76
Object.ChangeX += Object.XPos
77
Object.ChangeX &= 0xFFFF0000 // Truncate the value
78
Object[+1].XPos = Object.ChangeX
79
Object[+1].XPos -= 0x100000
80
Object[+1].YPos = Object.YPos
81
Object[+1].YPos -= 0x180000
82
Object[+2].XPos = Object.ChangeX
83
Object[+2].XPos += 0x100000
84
Object[+2].YPos = Object.YPos
85
Object[+2].YPos -= 0x180000
86
Object.ChangeX -= Object.PlatformX
87
break
88
case START_MOVING_LEFT_W/SPRING
89
Object.ChangeX *= -0x1800
90
Object.ChangeX -= 0x300000
91
Object.ChangeX += Object.XPos
92
Object.ChangeX &= 0xFFFF0000 // Truncate the value
93
Object[+1].XPos = Object.ChangeX
94
Object[+1].XPos -= 0x100000
95
Object[+1].YPos = Object.YPos
96
Object[+1].YPos -= 0x180000
97
Object[+2].XPos = Object.ChangeX
98
Object[+2].XPos += 0x100000
99
Object[+2].YPos = Object.YPos
100
Object[+2].YPos -= 0x180000
101
Object.ChangeX -= Object.PlatformX
102
break
103
104
end switch
105
106
if Object.Pressed == true
107
if Object.PlatformY < 16
108
Object.PlatformY++
109
TempValue0 = Object.PlatformY
110
TempValue0 &= 3
111
if TempValue0 == 3
112
Object.ChangeY = 0x10000
113
else
114
Object.ChangeY = 0
115
end if
116
else
117
Object.ChangeY = 0
118
end if
119
else
120
if Object.PlatformY > 0
121
Object.PlatformY--
122
TempValue0 = Object.PlatformY
123
TempValue0 &= 3
124
if TempValue0 == 3
125
Object.ChangeY = -0x10000
126
else
127
Object.ChangeY = 0
128
end if
129
else
130
Object.ChangeY = 0
131
end if
132
end if
133
134
Object.Pressed = false
135
136
end sub
137
138
139
sub ObjectPlayerInteraction
140
141
// First, back up the Object's base position
142
TempValue0 = Object.XPos
143
144
// Then, move the Object to where its Platform is
145
Object.XPos = Object.PlatformX
146
147
// From here, jump as needed to the special handling type to be used
148
switch Object.PropertyValue
149
case START_MOVING_RIGHT
150
case START_MOVING_LEFT
151
// Standard Platform
152
153
PlayerObjectCollision(C_PLATFORM, -32, -16, 32, 12)
154
155
if CheckResult == true
156
157
// Let the Platform Object know that the Player's on it so that it can dip
158
Object.Pressed = true
159
160
// And move the Player along with the Platform
161
Player.XPos += Object.ChangeX
162
Player.YPos += Object.ChangeY
163
164
end if
165
break
166
167
case START_MOVING_RIGHT_W/CONV
168
case START_MOVING_LEFT_W/CONV
169
// Conveyor Platform
170
if Object.Cooldown == 0
171
PlayerObjectCollision(C_PLATFORM, -32, -16, 32, 12)
172
173
if CheckResult == true
174
175
// Now that the Player's on the Platform, let the Platform know
176
Object.Pressed = true
177
178
// And from here, carry the Player along with the Platform
179
Player.XPos += Object.ChangeX
180
Player.YPos += Object.ChangeY
181
182
// But also move them in them with the Conveyor Belt too
183
if ConveyorBelt_Flag == 0
184
Player.XPos += ConveyorBelt_Speed
185
else
186
Player.XPos -= ConveyorBelt_Speed
187
end if
188
189
// However, since this Platform is a conveyor belt Platform, there's a brief cooldown activated if the Player
190
// is seen to be on the Platform's edge
191
// This is here so that they don't get into a loop of pushed off -> regrabbed -> pushed off -> regrabbed -> [...]
192
// since that makes things look quite... odd
193
194
if Player.Animation == ANI_FLAILINGLEFT
195
Object.Cooldown = 30
196
end if
197
198
if Player.Animation == ANI_FLAILINGRIGHT
199
Object.Cooldown = 30
200
end if
201
end if
202
else
203
// Hold for a moment...
204
Object.Cooldown--
205
end if
206
break
207
208
end switch
209
210
// And now restore the Platform to its base Position
211
Object.XPos = TempValue0
212
213
end sub
214
215
216
sub ObjectDraw
217
218
// Move the Platform as needed for its dipping
219
Object.YPos += Object.ChangeY
220
221
switch Object.PropertyValue
222
case START_MOVING_RIGHT
223
case START_MOVING_RIGHT_W/SPRING
224
// Right-going Platform
225
Sin(Object.PlatformX, Object.Angle)
226
Object.PlatformX *= 0x1800
227
Object.PlatformX += 0x300000
228
Object.PlatformX += Object.XPos
229
Object.PlatformX &= 0xFFFF0000 // Truncate the value
230
DrawSpriteXY(0, Object.PlatformX, Object.YPos)
231
break
232
233
case START_MOVING_RIGHT_W/CONV
234
// Right-going Conveyor Platform
235
Sin(Object.PlatformX, Object.Angle)
236
Object.PlatformX *= 0x1800
237
Object.PlatformX += 0x300000
238
Object.PlatformX += Object.XPos
239
Object.PlatformX &= 0xFFFF0000 // Truncate the value
240
DrawSpriteXY(0, Object.PlatformX, Object.YPos)
241
DrawSpriteXY(1, Object.PlatformX, Object.YPos)
242
break
243
244
case START_MOVING_LEFT
245
case START_MOVING_LEFT_W/SPRING
246
// Left-moving Platform
247
Sin(Object.PlatformX, Object.Angle)
248
Object.PlatformX *= -0x1800
249
Object.PlatformX -= 0x300000
250
Object.PlatformX += Object.XPos
251
Object.PlatformX &= 0xFFFF0000 // Truncate the value
252
DrawSpriteXY(0, Object.PlatformX, Object.YPos)
253
break
254
255
case START_MOVING_LEFT_W/CONV
256
// Left-moving Conveyor Platform
257
Sin(Object.PlatformX, Object.Angle)
258
Object.PlatformX *= -0x1800
259
Object.PlatformX -= 0x300000
260
Object.PlatformX += Object.XPos
261
Object.PlatformX &= 0xFFFF0000 // Truncate the value
262
DrawSpriteXY(0, Object.PlatformX, Object.YPos)
263
DrawSpriteXY(1, Object.PlatformX, Object.YPos)
264
break
265
266
end switch
267
268
end sub
269
270
271
sub ObjectStartup
272
273
LoadSpriteSheet("R5/Objects.gif")
274
275
// Load different Sprites for the different Time Periods
276
switch HUD.CurrentTimePeriod
277
case TIME_PRESENT
278
LoadSpriteSheet("R5/Objects.gif")
279
SpriteFrame(-32, -16, 64, 32, 34, 51)
280
SpriteFrame(-32, -16, 64, 16, 1, 208)
281
break
282
283
case TIME_PAST
284
LoadSpriteSheet("R5/Objects3.gif")
285
SpriteFrame(-32, -16, 64, 32, 34, 170)
286
SpriteFrame(-32, -16, 64, 16, 159, 148)
287
break
288
289
case TIME_GOOD_FUTURE
290
LoadSpriteSheet("R5/Objects3.gif")
291
SpriteFrame(-32, -16, 64, 32, 34, 170)
292
SpriteFrame(-32, -16, 64, 16, 159, 182)
293
break
294
295
case TIME_BAD_FUTURE
296
LoadSpriteSheet("R5/Objects3.gif")
297
SpriteFrame(-32, -16, 64, 32, 34, 170)
298
SpriteFrame(-32, -16, 64, 16, 159, 216)
299
break
300
301
end switch
302
303
end sub
304
305
306
// ========================
307
// Editor Subs
308
// ========================
309
310
sub RSDKDraw
311
TempValue2 = 0
312
313
switch Object.PropertyValue
314
case 2
315
TempValue2 = 1
316
case 0
317
case 1
318
TempValue0 = 0x1800
319
TempValue1 = 0x300000
320
break
321
322
case 5
323
TempValue2 = 1
324
case 3
325
case 4
326
TempValue0 = -0x1800
327
TempValue1 = -0x300000
328
break
329
330
end switch
331
332
DrawSprite(0)
333
DrawSprite(TempValue2)
334
335
if Editor.ShowGizmos == true
336
337
TempValue3 = Object.XPos
338
TempValue3 &= 0xFFFF0000 // Truncate the value
339
340
Sin(TempValue4, 128)
341
TempValue4 *= TempValue0
342
TempValue4 += TempValue1
343
TempValue4 += Object.XPos
344
TempValue4 &= 0xFFFF0000 // Truncate the value
345
346
Editor.DrawingOverlay = true
347
348
// Draw the Platform's path
349
350
DrawLine(TempValue3, Object.YPos, TempValue4, Object.YPos, 255, 255, 255)
351
352
Editor.DrawingOverlay = false
353
end if
354
end sub
355
356
357
sub RSDKLoad
358
LoadSpriteSheet("R5/Objects.gif")
359
// TODO: using present graphics here, yada yada daba daba doo
360
SpriteFrame(-32, -16, 64, 32, 34, 51)
361
SpriteFrame(-32, -16, 64, 16, 1, 208)
362
363
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
364
end sub
365
366