Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-CD-2011-Script-Decompilation
Path: blob/main/Scripts/R6/HSpinPlatform.txt
1319 views
1
//----------Sonic CD Horizontal Spin Platform Script----------//
2
//--------Scripted by Christian Whitehead 'The Taxman'--------//
3
//-------Unpacked By Rubberduckycooly's Script Unpacker-------//
4
5
// Aliases
6
#alias Object.Value0 : Object.PlayerOffSetAngle
7
#alias Object.Value1 : Object.OffSetXPos
8
#alias Object.Value2 : Object.XVelocity
9
#alias Object.Value3 : Object.Angle
10
#alias Object.Value4 : Object.KickPlayer
11
#alias Object.Value5 : Object.PlatAnimFrame
12
#alias Object.Value6 : Object.LightAnimFrame
13
14
// Player Aliases
15
#alias Player.Value6 : Player.MinRollSpeed
16
17
// Global SFX
18
#alias 0 : SFX_G_JUMP
19
20
// Gravity
21
#alias 0 : GRAVITY_GROUND
22
23
// Property Values
24
// This property values only cover the starting position
25
#alias 0 : START_MOVING_LEFT
26
#alias 1 : START_MOVING_RIGHT
27
28
29
sub ObjectMain
30
Object.Angle = Oscillation
31
Object.Angle <<= 1
32
if Object.PropertyValue == START_MOVING_RIGHT
33
Object.Angle += 256
34
end if
35
36
Sin(Object.XVelocity, Object.Angle)
37
Object.XVelocity <<= 13
38
Object.XVelocity += Object.XPos
39
Object.XVelocity &= 0xFFFF0000 // Truncate the value
40
Object.XVelocity -= Object.OffSetXPos
41
end sub
42
43
44
sub ObjectPlayerInteraction
45
TempValue1 = Object.XPos
46
Object.XPos = Object.OffSetXPos
47
PlayerObjectCollision(C_PLATFORM, -24, -12, 24, 8)
48
if CheckResult == true
49
Player.XPos += Object.XVelocity
50
51
if Player.State != Player_State_SpinningTop
52
Player.Speed = 0
53
Object.KickPlayer = true
54
Player.MinRollSpeed = 0xC00
55
if Player.XPos > Object.XPos
56
Player.Timer = Player.XPos
57
Player.Timer -= Object.XPos
58
Object.PlayerOffSetAngle = 128
59
else
60
Player.Timer = Object.XPos
61
Player.Timer -= Player.XPos
62
Object.PlayerOffSetAngle = 384
63
end if
64
end if
65
66
if Player.XPos > Object.XPos
67
if Player.Left == true
68
Player.Timer -= 2048
69
end if
70
if Player.Right == true
71
Player.Timer += 2048
72
end if
73
else
74
if Player.Left == true
75
Player.Timer += 2048
76
end if
77
if Player.Right == true
78
Player.Timer -= 2048
79
end if
80
end if
81
82
Player.State = Player_State_SpinningTop
83
Player.Animation = ANI_SPINNING_TOP
84
85
Sin(Player.XPos, Object.PlayerOffSetAngle)
86
Player.XPos *= Player.Timer
87
Player.XPos >>= 9
88
Player.XPos += Object.XPos
89
90
TempValue0 = Object.PlayerOffSetAngle
91
TempValue0 -= 128
92
TempValue0 /= 86
93
94
Player.Frame = TempValue0
95
96
Object.PlayerOffSetAngle += 8
97
if Object.PlayerOffSetAngle > 639
98
Object.PlayerOffSetAngle -= 512
99
end if
100
101
if Player.JumpPress == true
102
CallFunction(Player_Action_Jump)
103
104
Player.Speed = Player.XPos
105
Player.Speed -= Object.XPos
106
Player.Speed >>= 3
107
108
#platform: Use_Origins
109
Player.State = Player_State_Air_NoDropDash
110
#endplatform
111
112
#platform: Use_Standalone
113
Player.State = Player_State_Air
114
#endplatform
115
116
Player.Timer = 0
117
PlaySfx(SFX_G_JUMP, false)
118
end if
119
else
120
if Object.KickPlayer == true
121
if Player.State == Player_State_SpinningTop
122
if Player.Gravity == GRAVITY_GROUND
123
Player.State = Player_State_Ground
124
Object.KickPlayer = false
125
Player.Timer = 0
126
else
127
#platform: Use_Origins
128
Object.KickPlayer = false
129
Player.Timer = 0
130
Player.State = Player_State_Air_NoDropDash
131
Player.Animation = ANI_WALKING
132
CallFunction(Player_HandleAirMovement)
133
#endplatform
134
end if
135
end if
136
end if
137
end if
138
Object.XPos = TempValue1
139
end sub
140
141
142
sub ObjectDraw
143
Sin(Object.OffSetXPos, Object.Angle)
144
Object.OffSetXPos <<= 13
145
Object.OffSetXPos += Object.XPos
146
Object.OffSetXPos &= 0xFFFF0000 // Truncate the value
147
148
TempValue0 = Object.PlatAnimFrame
149
TempValue0 /= 10
150
151
Object.PlatAnimFrame++
152
Object.PlatAnimFrame %= 20
153
154
DrawSpriteXY(TempValue0, Object.OffSetXPos, Object.YPos)
155
156
TempValue0 = Object.LightAnimFrame
157
TempValue0 /= 10
158
TempValue0 += 2
159
160
Object.LightAnimFrame++
161
Object.LightAnimFrame %= 60
162
163
DrawSpriteXY(TempValue0, Object.OffSetXPos, Object.YPos)
164
end sub
165
166
167
sub ObjectStartup
168
LoadSpriteSheet("R6/Objects.gif")
169
170
SpriteFrame(-24, -16, 48, 32, 1, 84) // #0 - Horizontal Spin Platform frame 0
171
SpriteFrame(-24, -16, 48, 32, 50, 84) // #1 - Horizontal Spin Platform frame 1
172
173
SpriteFrame(-8, 16, 16, 16, 1, 117) // #2 - Spin Platform Light frame 0
174
SpriteFrame(-8, 16, 16, 16, 18, 117) // #3 - Spin Platform Light frame 1
175
SpriteFrame(-8, 16, 16, 16, 35, 117) // #4 - Spin Platform Light frame 2
176
SpriteFrame(-8, 16, 16, 16, 35, 117) // #5 - Spin Platform Light frame 3
177
SpriteFrame(-8, 16, 16, 16, 35, 117) // #6 - Spin Platform Light frame 4
178
SpriteFrame(-8, 16, 16, 16, 52, 117) // #7 - Spin Platform Light frame 5
179
180
ArrayPos0 = 32
181
while ArrayPos0 < 1056
182
if Object[ArrayPos0].Type == TypeName[H Spin Platform]
183
Object[ArrayPos0].DrawOrder = 4
184
end if
185
ArrayPos0++
186
loop
187
end sub
188
189
190
// ========================
191
// Editor Subs
192
// ========================
193
194
sub RSDKEdit
195
if Editor.ReturnVariable == true
196
switch Editor.VariableID
197
case EDIT_VAR_PROPVAL // Property Value
198
CheckResult = Object.PropertyValue
199
CheckResult &= 1
200
break
201
case 0 // startDir
202
CheckResult = Object.PropertyValue
203
CheckResult &= 1
204
break
205
end switch
206
else
207
switch Editor.VariableID
208
case EDIT_VAR_PROPVAL // Property Value
209
Object.PropertyValue = Editor.VariableValue
210
Object.PropertyValue &= 1
211
break
212
case 0 // startDir
213
Object.PropertyValue = Editor.VariableValue
214
Object.PropertyValue &= 1
215
break
216
end switch
217
end if
218
end sub
219
220
221
sub RSDKDraw
222
DrawSprite(0)
223
DrawSprite(1)
224
switch Object.PropertyValue
225
case START_MOVING_LEFT
226
TempValue1 = 255
227
TempValue2 = 255
228
TempValue3 = 128
229
TempValue4 = 0
230
break
231
case START_MOVING_RIGHT
232
TempValue1 = 128
233
TempValue2 = 0
234
TempValue3 = 255
235
TempValue4 = 255
236
break
237
end switch
238
TempValue0 = Object.XPos
239
TempValue0 -= 0x490000
240
TempValue5 = Object.YPos
241
TempValue5 -= 0x100000
242
if object.PropertyValue == START_MOVING_LEFT
243
DrawArrow(Object.XPos, Object.YPos, TempValue0, Object.YPos, 255, TempValue3, TempValue4, 0)
244
if Editor.ShowGizmos == true
245
Editor.DrawingOverlay = true
246
DrawRectOutline(TempValue0, TempValue5, 0x90, 0x30, 255, 255, 255, 255)
247
TempValue0 = Object.XPos
248
TempValue0 += 0x490000
249
DrawArrow(Object.XPos, Object.YPos, TempValue0, Object.YPos, 255, TempValue1, TempValue2, 0)
250
Editor.DrawingOverlay = false
251
end if
252
else
253
TempValue0 = Object.XPos
254
TempValue0 += 0x490000
255
DrawArrow(Object.XPos, Object.YPos, TempValue0, Object.YPos, 255, TempValue1, TempValue2, 0)
256
if Editor.ShowGizmos == true
257
Editor.DrawingOverlay = true
258
TempValue0 = Object.XPos
259
TempValue0 -= 0x490000
260
DrawRectOutline(TempValue0, TempValue5, 0x90, 0x30, 255, 255, 255, 255)
261
DrawArrow(Object.XPos, Object.YPos, TempValue0, Object.YPos, 255, TempValue3, TempValue4, 0)
262
Editor.DrawingOverlay = false
263
end if
264
end if
265
end sub
266
267
sub RSDKLoad
268
LoadSpriteSheet("R6/Objects.gif")
269
SpriteFrame(-24, -16, 48, 32, 1, 84) // #0 - Horizontal Spin Platform frame 0
270
SpriteFrame(-8, 16, 16, 16, 18, 117) // #1 - Spin Platform Light frame 1
271
272
AddEditorVariable("startDir")
273
SetActiveVariable("startDir")
274
AddEnumVariable("Left", START_MOVING_LEFT)
275
AddEnumVariable("Right", START_MOVING_RIGHT)
276
end sub
277
278