Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-CD-2011-Script-Decompilation
Path: blob/main/Scripts/R4/RPlatform.txt
1319 views
1
//--------------Sonic CD Rotating 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
12
// For the button mounted atop this Object, either true or false
13
#alias Object.PropertyValue : Object.Pressed
14
15
// Stage SFX
16
#alias 8 : SFX_S_SWITCH
17
18
19
sub ObjectMain
20
21
Object.Angle += 2
22
Object.Angle &= 511
23
24
TempValue1 = 96
25
26
Cos(Object.ChangeX, Object.Angle)
27
Object.ChangeX *= TempValue1
28
Object.ChangeX <<= 7
29
Object.ChangeX += Object.XPos
30
Object.ChangeX &= 0xFFFF0000 // Truncate the value
31
Object.ChangeX -= Object.PlatformX
32
33
Sin(Object.ChangeY, Object.Angle)
34
Object.ChangeY *= TempValue1
35
Object.ChangeY <<= 7
36
Object.ChangeY += Object.YPos
37
Object.ChangeY &= 0xFFFF0000 // Truncate the value
38
Object.ChangeY -= Object.PlatformY
39
end sub
40
41
42
sub ObjectPlayerInteraction
43
44
// Backup the Object's base position
45
TempValue0 = Object.XPos
46
TempValue1 = Object.YPos
47
48
// Move to where the Object's Platform is
49
Object.XPos = Object.PlatformX
50
Object.YPos = Object.PlatformY
51
52
// Check to see if the Player is riding on it
53
PlayerObjectCollision(C_PLATFORM, -32, -8, 32, 8)
54
if CheckResult == true
55
// Move the Player along with the Platform
56
57
Player.XPos += Object.ChangeX
58
Player.YPos += Object.ChangeY
59
end if
60
61
if Object.Pressed == false
62
PlayerObjectCollision(C_BOX, 0, -24, 32, 0)
63
if CheckResult == true
64
// The Player is on the button
65
66
if Object.Pressed == false
67
PlayStageSfx(SFX_S_SWITCH, false)
68
end if
69
70
Object.Pressed = true
71
72
// Move the Player along with the Platform's movements
73
Player.YPos += 0x80000
74
Player.XPos += Object.ChangeX
75
Player.YPos += Object.ChangeY
76
else
77
Object.Pressed = false
78
end if
79
else
80
PlayerObjectCollision(C_BOX, 0, -16, 32, 0)
81
if CheckResult == true
82
Object.Pressed = true
83
Player.XPos += Object.ChangeX
84
Player.YPos += Object.ChangeY
85
else
86
Object.Pressed = false
87
end if
88
end if
89
90
// Move the Object back to its base position
91
Object.XPos = TempValue0
92
Object.YPos = TempValue1
93
94
end sub
95
96
97
sub ObjectDraw
98
99
// First, draw the Object's Joint
100
DrawSprite(2)
101
102
// Then, draw all the Chains connecting the Platform to its Joint
103
TempValue0 = 0
104
TempValue1 = 16
105
while TempValue0 < 5
106
Cos(TempValue2, Object.Angle)
107
TempValue2 *= TempValue1
108
TempValue2 <<= 7
109
TempValue2 += Object.XPos
110
111
Sin(TempValue3, Object.Angle)
112
TempValue3 *= TempValue1
113
TempValue3 <<= 7
114
TempValue3 += Object.YPos
115
116
DrawSpriteXY(3, TempValue2, TempValue3)
117
118
TempValue0++
119
TempValue1 += 16
120
loop
121
122
// And now, find the positions to draw the Platform at
123
Cos(Object.PlatformX, Object.Angle)
124
Object.PlatformX *= TempValue1
125
Object.PlatformX <<= 7
126
Object.PlatformX += Object.XPos
127
Object.PlatformX &= 0xFFFF0000 // Truncate the value
128
129
Sin(Object.PlatformY, Object.Angle)
130
Object.PlatformY *= TempValue1
131
Object.PlatformY <<= 7
132
Object.PlatformY += Object.YPos
133
Object.PlatformY &= 0xFFFF0000 // Truncate the value
134
135
// Finally, draw the Platform itself
136
DrawSpriteXY(4, Object.PlatformX, Object.PlatformY)
137
138
// But wait! There's a button that rides the Platform, so draw that too!
139
DrawSpriteXY(Object.Pressed, Object.PlatformX, Object.PlatformY)
140
141
end sub
142
143
144
sub ObjectStartup
145
LoadSpriteSheet("R4/Objects.gif")
146
147
SpriteFrame(0, -24, 32, 16, 130, 35) // #0 - Push Button
148
SpriteFrame(0, -24, 32, 16, 130, 52) // #1 - Push Button Pressed
149
SpriteFrame(-8, -8, 16, 16, 163, 52) // #2 - Platform Joint
150
SpriteFrame(-8, -8, 16, 16, 180, 52) // #3 - Platform Chain
151
SpriteFrame(-32, -8, 64, 16, 147, 69) // #4 - Platform
152
end sub
153
154
155
// ========================
156
// Editor Subs
157
// ========================
158
159
sub RSDKDraw
160
DrawSprite(2)
161
162
TempValue0 = 0
163
TempValue1 = 16
164
while TempValue0 < 5
165
Cos(TempValue2, 128)
166
TempValue2 *= TempValue1
167
TempValue2 <<= 7
168
TempValue2 += Object.XPos
169
170
Sin(TempValue3, 128)
171
TempValue3 *= TempValue1
172
TempValue3 <<= 7
173
TempValue3 += Object.YPos
174
175
DrawSpriteXY(3, TempValue2, TempValue3)
176
177
TempValue0++
178
TempValue1 += 16
179
loop
180
181
Cos(Object.PlatformX, 128)
182
Object.PlatformX *= TempValue1
183
Object.PlatformX <<= 7
184
Object.PlatformX += Object.XPos
185
Object.PlatformX &= 0xFFFF0000 // Truncate the value
186
187
Sin(Object.PlatformY, 128)
188
Object.PlatformY *= TempValue1
189
Object.PlatformY <<= 7
190
Object.PlatformY += Object.YPos
191
Object.PlatformY &= 0xFFFF0000 // Truncate the value
192
193
DrawSpriteXY(4, Object.PlatformX, Object.PlatformY)
194
195
DrawSpriteXY(Object.Pressed, Object.PlatformX, Object.PlatformY)
196
end sub
197
198
199
sub RSDKLoad
200
LoadSpriteSheet("R4/Objects.gif")
201
202
SpriteFrame(0, -24, 32, 16, 130, 35) // #0 - Push Button
203
SpriteFrame(0, -24, 32, 16, 130, 52) // #1 - Push Button Pressed
204
SpriteFrame(-8, -8, 16, 16, 163, 52) // #2 - Platform Joint
205
SpriteFrame(-8, -8, 16, 16, 180, 52) // #3 - Platform Chain
206
SpriteFrame(-32, -8, 64, 16, 147, 69) // #4 - Platform
207
208
// Although used by the Object, it shouldn't be set from the editor
209
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
210
end sub
211
212