Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-CD-2011-Script-Decompilation
Path: blob/main/Scripts/R5/VPlatformLarge.txt
1319 views
1
//--------------Sonic CD VPlatform Large Script---------------//
2
//--------Scripted by Christian Whitehead 'The Taxman'--------//
3
//-------Unpacked By Rubberduckycooly's Script Unpacker-------//
4
5
// Aliases
6
#alias Object.Value0 : Object.Oscillation
7
#alias Object.Value1 : Object.PlatformY
8
#alias Object.Value2 : Object.ChangeY
9
#alias Object.Value3 : Object.Angle
10
11
// HUD Alias
12
#alias Object[24].PropertyValue : HUD.CurrentTimePeriod
13
14
// Time Period Aliases
15
#alias 0 : TIME_PRESENT
16
#alias 1 : TIME_PAST
17
#alias 2 : TIME_GOOD_FUTURE
18
#alias 3 : TIME_BAD_FUTURE
19
20
// Property Values
21
#alias 0 : DOWNWARDS_PLAT
22
#alias 1 : DOWNWARDS_PLAT_UNUSED
23
#alias 2 : DOWNWARDS_PLAT_CONV
24
#alias 3 : UPWARDS_PLAT
25
#alias 4 : UPWARDS_PLAT_UNUSED
26
#alias 5 : UPWARDS_PLAT_CONV
27
28
29
sub ObjectMain
30
31
// Update the Platform's base Oscillation Value
32
Object.Oscillation++
33
if Object.Oscillation == 312
34
Object.Oscillation = 0
35
end if
36
37
// From that Oscillation Value, get the Angle for the Platform to be at
38
// The result will range somewhere from 0 to 510
39
Object.Angle = Object.Oscillation
40
Object.Angle <<= 6
41
Object.Angle /= 39
42
43
// Get the base Y change value for the Platform
44
Sin(Object.ChangeY, Object.Angle)
45
46
// And from here, jump to the specific handling case needed for the different Platform types
47
switch Object.PropertyValue
48
case DOWNWARDS_PLAT
49
case DOWNWARDS_PLAT_CONV
50
// Downwards Platform
51
Object.ChangeY *= 0x1800
52
Object.ChangeY += 0x300000
53
Object.ChangeY += Object.YPos
54
Object.ChangeY &= 0xFFFF0000 // Truncate the value
55
Object.ChangeY -= Object.PlatformY
56
break
57
58
case UPWARDS_PLAT
59
case UPWARDS_PLAT_CONV
60
// Upwards Platform
61
Object.ChangeY *= -0x1800
62
Object.ChangeY -= 0x300000
63
Object.ChangeY += Object.YPos
64
Object.ChangeY &= 0xFFFF0000 // Truncate the value
65
Object.ChangeY -= Object.PlatformY
66
break
67
68
case DOWNWARDS_PLAT_UNUSED
69
// Unused duplicate of down Platform
70
Object.ChangeY *= 0x1800
71
Object.ChangeY += 0x300000
72
Object.ChangeY += Object.YPos
73
Object.ChangeY &= 0xFFFF0000 // Truncate the value
74
Object.ChangeY -= Object.PlatformY
75
break
76
77
case UPWARDS_PLAT_UNUSED
78
// Unused duplicate of upwards Platform
79
Object.ChangeY *= -0x1800
80
Object.ChangeY -= 0x300000
81
Object.ChangeY += Object.YPos
82
Object.ChangeY &= 0xFFFF0000 // Truncate the value
83
Object.ChangeY -= Object.PlatformY
84
break
85
86
end switch
87
88
end sub
89
90
91
sub ObjectPlayerInteraction
92
93
// First, back up the Object's base Y Position
94
TempValue0 = Object.YPos
95
96
// Then, move the Object to where its Platform is
97
Object.YPos = Object.PlatformY
98
99
// From here, jump as needed to the needed Platform type
100
switch Object.PropertyValue
101
case DOWNWARDS_PLAT
102
case UPWARDS_PLAT
103
// Standard Platform
104
PlayerObjectCollision(C_PLATFORM, -48, -16, 48, 12)
105
if CheckResult == true
106
// Move the Player along with the Platform to keep them on
107
Player.YPos += Object.ChangeY
108
end if
109
break
110
111
case DOWNWARDS_PLAT_CONV
112
case UPWARDS_PLAT_CONV
113
// Conveyor Platform
114
PlayerObjectCollision(C_PLATFORM, -48, -16, 48, 12)
115
if CheckResult == true
116
117
// Move the Player vertically to say with the Platform
118
Player.YPos += Object.ChangeY
119
120
// And then move the player horizontally as needed with the Conveyor Belt
121
if ConveyorBelt_Flag == 0
122
Player.XPos += ConveyorBelt_Speed
123
else
124
Player.XPos -= ConveyorBelt_Speed
125
end if
126
127
end if
128
break
129
130
end switch
131
132
// And now restore the Object's base Y Position
133
Object.YPos = TempValue0
134
135
end sub
136
137
138
sub ObjectDraw
139
140
switch Object.PropertyValue
141
case DOWNWARDS_PLAT
142
case DOWNWARDS_PLAT_UNUSED
143
// Standard downwards Platform
144
Sin(Object.PlatformY, Object.Angle)
145
Object.PlatformY *= 0x1800
146
Object.PlatformY += 0x300000
147
Object.PlatformY += Object.YPos
148
Object.PlatformY &= 0xFFFF0000 // Truncate the value
149
DrawSpriteXY(0, Object.XPos, Object.PlatformY)
150
break
151
152
case DOWNWARDS_PLAT_CONV
153
// Downwards Conveyor Platform
154
Sin(Object.PlatformY, Object.Angle)
155
Object.PlatformY *= 0x1800
156
Object.PlatformY += 0x300000
157
Object.PlatformY += Object.YPos
158
Object.PlatformY &= 0xFFFF0000 // Truncate the value
159
DrawSpriteXY(0, Object.XPos, Object.PlatformY)
160
DrawSpriteXY(1, Object.XPos, Object.PlatformY)
161
break
162
163
case UPWARDS_PLAT
164
case UPWARDS_PLAT_UNUSED
165
// Standard upwards Platform
166
Sin(Object.PlatformY, Object.Angle)
167
Object.PlatformY *= -0x1800
168
Object.PlatformY -= 0x300000
169
Object.PlatformY += Object.YPos
170
Object.PlatformY &= 0xFFFF0000 // Truncate the value
171
DrawSpriteXY(0, Object.XPos, Object.PlatformY)
172
break
173
174
case UPWARDS_PLAT_CONV
175
// Upwards Conveyor Platform
176
Sin(Object.PlatformY, Object.Angle)
177
Object.PlatformY *= -0x1800
178
Object.PlatformY -= 0x300000
179
Object.PlatformY += Object.YPos
180
Object.PlatformY &= 0xFFFF0000 // Truncate the value
181
DrawSpriteXY(0, Object.XPos, Object.PlatformY)
182
DrawSpriteXY(1, Object.XPos, Object.PlatformY)
183
break
184
185
end switch
186
187
end sub
188
189
190
sub ObjectStartup
191
192
// Use different Sprites for the different Time Periods
193
switch HUD.CurrentTimePeriod
194
case TIME_PRESENT
195
LoadSpriteSheet("R5/Objects.gif")
196
SpriteFrame(-48, -16, 96, 32, 1, 84)
197
SpriteFrame(-48, -16, 96, 16, 1, 191)
198
break
199
200
case TIME_PAST
201
LoadSpriteSheet("R5/Objects3.gif")
202
SpriteFrame(-48, -16, 96, 32, 1, 203)
203
SpriteFrame(-48, -16, 96, 16, 159, 131)
204
break
205
206
case TIME_GOOD_FUTURE
207
LoadSpriteSheet("R5/Objects3.gif")
208
SpriteFrame(-48, -16, 96, 32, 1, 203)
209
SpriteFrame(-48, -16, 96, 16, 159, 165)
210
break
211
212
case TIME_BAD_FUTURE
213
LoadSpriteSheet("R5/Objects3.gif")
214
SpriteFrame(-48, -16, 96, 32, 1, 203)
215
SpriteFrame(-48, -16, 96, 16, 159, 199)
216
break
217
218
end switch
219
220
end sub
221
222
223
// ========================
224
// Editor Subs
225
// ========================
226
227
sub RSDKEdit
228
if Editor.ReturnVariable == true
229
switch Editor.VariableID
230
case EDIT_VAR_PROPVAL // Property Value
231
CheckResult = Object.PropertyValue
232
break
233
case 0 // Direction
234
CheckResult = Object.PropertyValue
235
break
236
end switch
237
else
238
switch Editor.VariableID
239
case EDIT_VAR_PROPVAL // Property Value
240
Object.PropertyValue = Editor.VariableValue
241
break
242
case 0 // Direction
243
Object.PropertyValue = Editor.VariableValue
244
break
245
end switch
246
end if
247
end sub
248
249
250
sub RSDKDraw
251
TempValue2 = false
252
253
switch Object.PropertyValue
254
case 2
255
TempValue2 = true
256
case 0
257
default
258
TempValue0 = 0x1800
259
TempValue1 = 0x300000
260
break
261
262
case 5
263
TempValue2 = true
264
case 3
265
TempValue0 *= -0x1800
266
TempValue1 -= 0x300000
267
break
268
269
end switch
270
271
TempValue3 = Object.YPos
272
TempValue3 &= 0xFFFF0000 // Truncate the value
273
DrawSpriteXY(0, Object.XPos, TempValue3)
274
275
if TempValue2 == true
276
DrawSpriteXY(1, Object.XPos, TempValue3)
277
end if
278
279
if Editor.ShowGizmos == true
280
281
// Draw the Platform's path as a line
282
283
Sin(TempValue4, 128)
284
TempValue4 *= TempValue0
285
TempValue4 += TempValue1
286
TempValue4 += Object.YPos
287
TempValue4 &= 0xFFFF0000 // Truncate the value
288
289
Editor.DrawingOverlay = true
290
291
DrawLine(Object.XPos, TempValue3, Object.XPos, TempValue4, 255, 255, 255)
292
293
Editor.DrawingOverlay = false
294
295
end if
296
end sub
297
298
299
sub RSDKLoad
300
LoadSpriteSheet("R5/Objects.gif")
301
// TODO: using present frames here, do something for other time periods
302
SpriteFrame(-48, -16, 96, 32, 1, 84)
303
SpriteFrame(-48, -16, 96, 16, 1, 191)
304
305
AddEditorVariable("Direction")
306
SetActiveVariable("Direction")
307
AddEnumVariable("Downwards", 0)
308
// 1 is unused
309
AddEnumVariable("Downwards (Conveyor)", 2)
310
AddEnumVariable("Upwards", 3)
311
// 4 is unused
312
AddEnumVariable("Upwards (Conveyor)", 5)
313
end sub
314
315