Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-CD-2011-Script-Decompilation
Path: blob/main/Scripts/R5/RPlatform.txt
1319 views
1
//-----------------Sonic CD R Platform Script-----------------//
2
//--------Scripted by Christian Whitehead 'The Taxman'--------//
3
//-------Unpacked By Rubberduckycooly's Script Unpacker-------//
4
5
// Aliases
6
#alias Object.Value0 : Object.Angle
7
#alias Object.Value1 : Object.PlatformX
8
#alias Object.Value2 : Object.PlatformY
9
#alias Object.Value3 : Object.ChangeX
10
#alias Object.Value4 : Object.ChangeY
11
#alias Object.Value5 : Object.AltAngle
12
13
14
sub ObjectMain
15
16
switch Object.PropertyValue
17
case 1
18
// Full range version of the Platform, moving counter-clockwise
19
20
Object.Angle -= 2
21
22
if Object.Angle < 0
23
// Wrap around
24
Object.Angle += 512
25
end if
26
break
27
28
case 2
29
// Bottom half version of the Platform, swinging around the bottom 180 degrees
30
31
Object.AltAngle += 2
32
Object.AltAngle &= 511
33
34
Sin(Object.Angle, Object.AltAngle)
35
36
Object.Angle >>= 2
37
Object.Angle += 128
38
break
39
40
case 3
41
// Top half version of the Platform, swinging around the top 180 degrees
42
43
Object.AltAngle += 2
44
Object.AltAngle &= 511
45
46
Sin(Object.Angle, Object.AltAngle)
47
48
FlipSign(Object.Angle)
49
50
Object.Angle >>= 2
51
Object.Angle += 384
52
Object.Angle &= 511
53
break
54
55
end switch
56
57
// Radius value
58
TempValue1 = 96
59
60
Cos(Object.ChangeX, Object.Angle)
61
Object.ChangeX *= TempValue1
62
Object.ChangeX <<= 7
63
Object.ChangeX += Object.XPos
64
Object.ChangeX &= 0xFFFF0000 // Truncate the value
65
Object.ChangeX -= Object.PlatformX
66
67
Sin(Object.ChangeY, Object.Angle)
68
Object.ChangeY *= TempValue1
69
Object.ChangeY <<= 7
70
Object.ChangeY += Object.YPos
71
Object.ChangeY &= 0xFFFF0000 // Truncate the value
72
Object.ChangeY -= Object.PlatformY
73
74
end sub
75
76
77
sub ObjectPlayerInteraction
78
79
// Backup the Object's base position
80
TempValue0 = Object.XPos
81
TempValue1 = Object.YPos
82
83
// Move the Object to its Platform's position
84
Object.XPos = Object.PlatformX
85
Object.YPos = Object.PlatformY
86
87
// Act as a Platform for the player
88
PlayerObjectCollision(C_PLATFORM, -32, -8, 32, 8)
89
if CheckResult == true
90
91
// Move the Player along with the Platform
92
Player.XPos += Object.ChangeX
93
Player.YPos += Object.ChangeY
94
95
// The Platform is a Conveyor Belt as well, so move the Player in accordance with that too
96
if ConveyorBelt_Flag == 0
97
Player.XPos += ConveyorBelt_Speed
98
else
99
Player.XPos -= ConveyorBelt_Speed
100
end if
101
102
end if
103
104
// And now restore the Object back to its base position
105
Object.XPos = TempValue0
106
Object.YPos = TempValue1
107
108
end sub
109
110
111
sub ObjectDraw
112
113
// Draw the Post Frame
114
DrawSprite(0)
115
116
// Draw all the Chains
117
TempValue0 = 0
118
TempValue1 = 16
119
while TempValue0 < 5
120
Cos(TempValue2, Object.Angle)
121
TempValue2 *= TempValue1
122
TempValue2 <<= 7
123
TempValue2 += Object.XPos
124
125
Sin(TempValue3, Object.Angle)
126
TempValue3 *= TempValue1
127
TempValue3 <<= 7
128
TempValue3 += Object.YPos
129
130
DrawSpriteXY(1, TempValue2, TempValue3)
131
132
TempValue0++
133
TempValue1 += 16
134
loop
135
136
137
Cos(Object.PlatformX, Object.Angle)
138
Object.PlatformX *= TempValue1
139
Object.PlatformX <<= 7
140
Object.PlatformX += Object.XPos
141
Object.PlatformX &= 0xFFFF0000 // Truncate the value
142
143
Sin(Object.PlatformY, Object.Angle)
144
Object.PlatformY *= TempValue1
145
Object.PlatformY <<= 7
146
Object.PlatformY += Object.YPos
147
Object.PlatformY &= 0xFFFF0000 // Truncate the value
148
149
DrawSpriteXY(2, Object.PlatformX, Object.PlatformY)
150
151
end sub
152
153
154
sub ObjectStartup
155
LoadSpriteSheet("R5/Objects.gif")
156
157
// Post Frame
158
SpriteFrame(-8, -8, 16, 16, 1, 1)
159
160
// Chain Frame
161
SpriteFrame(-8, -8, 16, 16, 18, 1)
162
163
// Conveyor Platform Frame
164
SpriteFrame(-32, -8, 64, 16, 1, 208)
165
166
end sub
167
168
169
// ========================
170
// Editor Subs
171
// ========================
172
173
sub RSDKEdit
174
if Editor.ReturnVariable == true
175
switch Editor.VariableID
176
case EDIT_VAR_PROPVAL // Property Value
177
CheckResult = Object.PropertyValue
178
break
179
case 0 // Range
180
CheckResult = Object.PropertyValue
181
break
182
end switch
183
else
184
switch Editor.VariableID
185
case EDIT_VAR_PROPVAL // Property Value
186
Object.PropertyValue = Editor.VariableValue
187
break
188
case 0 // Range
189
Object.PropertyValue = Editor.VariableValue
190
break
191
end switch
192
end if
193
end sub
194
195
196
sub RSDKDraw
197
DrawSprite(0)
198
199
TempValue0 = 0
200
TempValue1 = 16
201
while TempValue0 < 5
202
Cos(TempValue2, 128)
203
TempValue2 *= TempValue1
204
TempValue2 <<= 7
205
TempValue2 += Object.XPos
206
Sin(TempValue3, 128)
207
TempValue3 *= TempValue1
208
TempValue3 <<= 7
209
TempValue3 += Object.YPos
210
DrawSpriteXY(1, TempValue2, TempValue3)
211
TempValue0++
212
TempValue1 += 16
213
loop
214
215
Cos(TempValue2, 128)
216
TempValue2 *= TempValue1
217
TempValue2 <<= 7
218
TempValue2 += Object.XPos
219
TempValue2 &= 0xFFFF0000 // Truncate the value
220
221
Sin(TempValue3, 128)
222
TempValue3 *= TempValue1
223
TempValue3 <<= 7
224
TempValue3 += Object.YPos
225
TempValue3 &= 0xFFFF0000 // Truncate the value
226
227
DrawSpriteXY(2, TempValue2, TempValue3)
228
end sub
229
230
231
sub RSDKLoad
232
LoadSpriteSheet("R5/Objects.gif")
233
SpriteFrame(-8, -8, 16, 16, 1, 1)
234
SpriteFrame(-8, -8, 16, 16, 18, 1)
235
SpriteFrame(-32, -8, 64, 16, 1, 208)
236
237
AddEditorVariable("Range")
238
SetActiveVariable("Range")
239
// 0 technically exists as a "Static" type but it isn't used in the game so
240
AddEnumVariable("Full Rotation", 1)
241
AddEnumVariable("Bottom Half", 2)
242
AddEnumVariable("Top Half", 3)
243
end sub
244
245