Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-CD-2011-Script-Decompilation
Path: blob/main/Scripts/R5/VPlatformSmall.txt
1319 views
1
//--------------Sonic CD VPlatform Small 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 Oscillation Value
32
// (This value is stored per-Object, meaning that Platforms across the stage aren't synced)
33
Object.Oscillation++
34
if Object.Oscillation == 312
35
Object.Oscillation = 0
36
end if
37
38
// Get the Object's Angle value
39
// The final Angle value Will range from 0 to 510
40
Object.Angle = Object.Oscillation
41
Object.Angle <<= 6
42
Object.Angle /= 39
43
44
// Calculate its base Change value
45
Sin(Object.ChangeY, Object.Angle)
46
47
// From this base Change value, jump to the Platform handling type for what's further needed
48
switch Object.PropertyValue
49
case DOWNWARDS_PLAT
50
case DOWNWARDS_PLAT_CONV
51
// Downwards Platform
52
Object.ChangeY *= 0x1800
53
Object.ChangeY += 0x300000
54
Object.ChangeY += Object.YPos
55
Object.ChangeY &= 0xFFFF0000 // Truncate the value
56
Object.ChangeY -= Object.PlatformY
57
break
58
59
case UPWARDS_PLAT
60
case UPWARDS_PLAT_CONV
61
// Upwards Platform
62
Object.ChangeY *= -0x1800
63
Object.ChangeY -= 0x300000
64
Object.ChangeY += Object.YPos
65
Object.ChangeY &= 0xFFFF0000 // Truncate the value
66
Object.ChangeY -= Object.PlatformY
67
break
68
69
case DOWNWARDS_PLAT_UNUSED
70
// Unused duplicate of downwards platform
71
Object.ChangeY *= 0x1800
72
Object.ChangeY += 0x300000
73
Object.ChangeY += Object.YPos
74
Object.ChangeY &= 0xFFFF0000 // Truncate the value
75
Object.ChangeY -= Object.PlatformY
76
break
77
78
case UPWARDS_PLAT_UNUSED
79
// Unused duplicate of upwards platform
80
Object.ChangeY *= -0x1800
81
Object.ChangeY -= 0x300000
82
Object.ChangeY += Object.YPos
83
Object.ChangeY &= 0xFFFF0000 // Truncate the value
84
Object.ChangeY -= Object.PlatformY
85
break
86
87
end switch
88
89
end sub
90
91
92
sub ObjectPlayerInteraction
93
94
// Back up the Object's position...
95
TempValue0 = Object.YPos
96
97
// ...and move the Object to where the Platform actually is
98
Object.YPos = Object.PlatformY
99
100
switch Object.PropertyValue
101
case DOWNWARDS_PLAT
102
case UPWARDS_PLAT
103
// Normal Platform
104
PlayerObjectCollision(C_PLATFORM, -16, -16, 16, 12)
105
if CheckResult == true
106
// Move the Player along with the Platform
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, -16, -16, 16, 12)
115
if CheckResult == true
116
117
// Move the Player to match the Platform
118
Player.YPos += Object.ChangeY
119
120
// And then push them along with the Conveyor Belt too as needed
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
// Now that all the Collision's been done, it's safe to move the Object back now
133
Object.YPos = TempValue0
134
135
end sub
136
137
138
sub ObjectDraw
139
140
// All Platform types have their own Draw routines
141
switch Object.PropertyValue
142
case DOWNWARDS_PLAT
143
case DOWNWARDS_PLAT_UNUSED
144
// Standard Downards Platform
145
Sin(Object.PlatformY, Object.Angle)
146
Object.PlatformY *= 0x1800
147
Object.PlatformY += 0x300000
148
Object.PlatformY += Object.YPos
149
Object.PlatformY &= 0xFFFF0000 // Truncate the value
150
DrawSpriteXY(0, Object.XPos, Object.PlatformY)
151
break
152
153
case DOWNWARDS_PLAT_CONV
154
// Downards Conveyor Platform
155
Sin(Object.PlatformY, Object.Angle)
156
Object.PlatformY *= 0x1800
157
Object.PlatformY += 0x300000
158
Object.PlatformY += Object.YPos
159
Object.PlatformY &= 0xFFFF0000 // Truncate the value
160
DrawSpriteXY(0, Object.XPos, Object.PlatformY)
161
DrawSpriteXY(1, Object.XPos, Object.PlatformY)
162
break
163
164
case UPWARDS_PLAT
165
case UPWARDS_PLAT_UNUSED
166
// Standard Upwards Platform
167
Sin(Object.PlatformY, Object.Angle)
168
Object.PlatformY *= -0x1800
169
Object.PlatformY -= 0x300000
170
Object.PlatformY += Object.YPos
171
Object.PlatformY &= 0xFFFF0000 // Truncate the value
172
DrawSpriteXY(0, Object.XPos, Object.PlatformY)
173
break
174
175
case UPWARDS_PLAT_CONV
176
// Upwards Conveyor Platform
177
Sin(Object.PlatformY, Object.Angle)
178
Object.PlatformY *= -0x1800
179
Object.PlatformY -= 0x300000
180
Object.PlatformY += Object.YPos
181
Object.PlatformY &= 0xFFFF0000 // Truncate the value
182
DrawSpriteXY(0, Object.XPos, Object.PlatformY)
183
DrawSpriteXY(1, Object.XPos, Object.PlatformY)
184
break
185
186
end switch
187
188
end sub
189
190
191
sub ObjectStartup
192
193
LoadSpriteSheet("R5/Objects.gif")
194
195
// Different sprites for different time periods
196
197
// To avoid redundant labelling, the order of Sprite Frames will just be listed here
198
// 0 - Base Platform Frame
199
// 1 - Conveyor Frame, to be overlayed atop the base Platform Frame
200
201
switch HUD.CurrentTimePeriod
202
case TIME_PRESENT
203
LoadSpriteSheet("R5/Objects.gif")
204
SpriteFrame(-16, -16, 32, 32, 1, 51)
205
SpriteFrame(-16, -16, 32, 16, 65, 208)
206
break
207
208
case TIME_PAST
209
LoadSpriteSheet("R5/Objects3.gif")
210
SpriteFrame(-16, -16, 32, 32, 1, 170)
211
SpriteFrame(-16, -16, 32, 16, 223, 148)
212
break
213
214
case TIME_GOOD_FUTURE
215
LoadSpriteSheet("R5/Objects3.gif")
216
SpriteFrame(-16, -16, 32, 32, 1, 170)
217
SpriteFrame(-16, -16, 32, 16, 223, 182)
218
break
219
220
case TIME_BAD_FUTURE
221
LoadSpriteSheet("R5/Objects3.gif")
222
SpriteFrame(-16, -16, 32, 32, 1, 170)
223
SpriteFrame(-16, -16, 32, 16, 223, 216)
224
break
225
226
end switch
227
228
end sub
229
230
231
// ========================
232
// Editor Subs
233
// ========================
234
235
sub RSDKEdit
236
if Editor.ReturnVariable == true
237
switch Editor.VariableID
238
case EDIT_VAR_PROPVAL // Property Value
239
CheckResult = Object.PropertyValue
240
break
241
case 0 // Direction
242
CheckResult = Object.PropertyValue
243
break
244
end switch
245
else
246
switch Editor.VariableID
247
case EDIT_VAR_PROPVAL // Property Value
248
Object.PropertyValue = Editor.VariableValue
249
break
250
case 0 // Direction
251
Object.PropertyValue = Editor.VariableValue
252
break
253
end switch
254
end if
255
end sub
256
257
258
sub RSDKDraw
259
TempValue2 = false
260
261
// TempValue0 holds just about no use with this sytem, but may as well just grab it
262
263
switch Object.PropertyValue
264
case 2
265
TempValue2 = true
266
case 0
267
default
268
TempValue0 = 0x1800
269
TempValue1 = 0x300000
270
break
271
272
case 5
273
TempValue2 = true
274
case 3
275
TempValue0 = -0x1800
276
TempValue1 = -0x300000
277
break
278
279
end switch
280
281
TempValue3 = Object.YPos
282
TempValue3 &= 0xFFFF0000 // Truncate the value
283
DrawSpriteXY(0, Object.XPos, TempValue3)
284
285
if TempValue2 == true
286
DrawSpriteXY(1, Object.XPos, TempValue3)
287
end if
288
289
if Editor.ShowGizmos == true
290
291
Editor.DrawingOverlay = true
292
293
// Draw the Platform's path
294
295
Sin(TempValue4, 128)
296
TempValue4 *= TempValue0
297
TempValue4 += TempValue1
298
TempValue4 += Object.YPos
299
TempValue4 &= 0xFFFF0000 // Truncate the value
300
301
DrawLine(Object.XPos, TempValue3, Object.XPos, TempValue4, 255, 255, 255)
302
303
Editor.DrawingOverlay = false
304
305
end if
306
end sub
307
308
309
sub RSDKLoad
310
LoadSpriteSheet("R5/Objects.gif")
311
// Sticking with the Present version here...
312
// TODO: other time periods, hopefully there's some better method than 10 checkcurrentfolder checks?
313
SpriteFrame(-16, -16, 32, 32, 1, 51)
314
SpriteFrame(-16, -16, 32, 16, 65, 208)
315
316
AddEditorVariable("Direction")
317
SetActiveVariable("Direction")
318
AddEnumVariable("Downwards", 0)
319
// 1 is unused
320
AddEnumVariable("Downwards (Conveyor)", 2)
321
AddEnumVariable("Upwards", 3)
322
// 4 is unused
323
AddEnumVariable("Upwards (Conveyor)", 5)
324
end sub
325
326