Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-CD-2011-Script-Decompilation
Path: blob/main/Scripts/R5/TubeSwitch.txt
1319 views
1
//----------------Sonic CD Tube Switch Script-----------------//
2
//--------Scripted by Christian Whitehead 'The Taxman'--------//
3
//-------Unpacked By Rubberduckycooly's Script Unpacker-------//
4
5
// Aliases
6
#alias Object.Value0 : Object.InTube
7
#alias Object.Value1 : Object.LedgeStop
8
9
// Player Aliases
10
#alias Player.Value2 : Player.RollAnimationSpeed
11
#alias Player.Value6 : Player.MinRollSpeed
12
13
// Warp Star Aliases
14
#alias Object.Value0 : Object.Timer
15
16
// Global SFX
17
#alias 6 : SFX_G_CHARGE
18
#alias 7 : SFX_G_RELEASE
19
20
// Gravity
21
#alias 0 : GRAVITY_GROUND
22
#alias 1 : GRAVITY_AIR
23
24
// Collision Modes
25
#alias 0 : CMODE_FLOOR
26
#alias 3 : CMODE_RWALL
27
28
// Warp Destination
29
#alias 0 : WARPDEST_NONE
30
31
32
// 0 - standard (biased towards right)
33
// 1 - standard (biased towards left)
34
// 2 - downards sender
35
// 3 - downards conveyer tube
36
// 4 - upwards conveyer tube
37
// 5 - XXXXXX
38
// 7 - vertical tunnel, middle
39
// 8 - vertical tunnel, endpoints
40
41
42
sub ObjectPlayerInteraction
43
PlayerObjectCollision(C_TOUCH, -16, -16, 16, 16)
44
45
#platform: Use_Origins
46
if CheckResult == true
47
if Stage.PlayerListPos == PLAYER_KNUCKLES
48
if Player.State == Player_State_LedgePullUp
49
CheckResult = false
50
Object.LedgeStop = true
51
end if
52
end if
53
end if
54
#endplatform
55
56
if CheckResult == true
57
switch Object.PropertyValue
58
case 0
59
#platform: Use_Origins
60
if Object.LedgeStop == true
61
Player.Speed = 1
62
Object.LedgeStop = false
63
end if
64
#endplatform
65
66
if Player.Speed >= 0
67
if Player.State != Player_State_TubeRoll
68
PlaySfx(SFX_G_CHARGE, false)
69
end if
70
Player.Direction = FACING_RIGHT
71
Player.State = Player_State_TubeRoll
72
Player.Animation = ANI_JUMPING
73
Player.MinRollSpeed = 0x20000
74
if Player.Speed < 0x20000
75
Player.Speed = 0x20000
76
end if
77
else
78
if Player.Speed > -0x20000
79
Player.Speed = -0x20000
80
end if
81
Player.State = Player_State_Roll
82
Player.Animation = ANI_JUMPING
83
end if
84
break
85
86
case 1
87
if Player.Speed <= 0
88
if Player.State != Player_State_TubeRoll
89
PlaySfx(SFX_G_CHARGE, false)
90
end if
91
Player.State = Player_State_TubeRoll
92
Player.Animation = ANI_JUMPING
93
Player.MinRollSpeed = 0x80000
94
if Player.Speed > -0x20000
95
Player.Speed = -0x20000
96
end if
97
else
98
if Player.Speed < 0x20000
99
Player.Speed = 0x20000
100
end if
101
Player.State = Player_State_Roll
102
Player.Animation = ANI_JUMPING
103
end if
104
break
105
106
case 2
107
Player.Gravity = GRAVITY_AIR
108
Player.CollisionMode = CMODE_FLOOR
109
Player.XVelocity = 0
110
Player.Speed = 0
111
break
112
113
case 3
114
if ConveyorBelt_Flag == 0
115
if Player.YPos < Object.YPos
116
if Player.State != Player_State_Static
117
PlaySfx(SFX_G_RELEASE, false)
118
end if
119
Player.State = Player_State_Static
120
if Player.Animation != ANI_JUMPING
121
Player.Animation = ANI_JUMPING
122
end if
123
Player.RollAnimationSpeed = 240
124
Player.Speed = 0
125
Player.Timer = 0
126
Player.XPos = Object.XPos
127
Player.XVelocity = 0
128
Player.YVelocity = 0xA0000
129
end if
130
else
131
if Player.State == Player_State_Static
132
#platform: Use_Origins
133
Player.State = Player_State_Air_NoDropDash
134
#endplatform
135
136
#platform: Use_Standalone
137
Player.State = Player_State_Air
138
#endplatform
139
end if
140
end if
141
break
142
143
case 4
144
if ConveyorBelt_Flag == 3
145
if Player.YPos > Object.YPos
146
// Hold the Player's Warp, if needed
147
// -> This section of code wasn't in the initial version of the game (Steam)
148
// and is only present in updated versions (mobile & Origins)
149
if Warp.Destination > WARPDEST_NONE
150
if Warp.Timer == 0
151
Warp.Timer = 1
152
153
ResetObjectEntity(3, TypeName[Warp Star], 0, Player.XPos, Player.YPos)
154
Object[3].Timer = 7
155
Object[3].DrawOrder = 4
156
end if
157
end if
158
159
if Player.State != Player_State_Static
160
PlaySfx(SFX_G_RELEASE, false)
161
end if
162
163
Player.State = Player_State_Static
164
if Player.Animation != ANI_JUMPING
165
Player.Animation = ANI_JUMPING
166
end if
167
Player.RollAnimationSpeed = 240
168
Player.Speed = 0
169
Player.Timer = 0
170
Player.XPos = Object.XPos
171
Player.XVelocity = 0
172
Player.YVelocity = -0x80000
173
end if
174
else
175
if Player.State == Player_State_Static
176
#platform: Use_Origins
177
Player.State = Player_State_Air_NoDropDash
178
#endplatform
179
180
#platform: Use_Standalone
181
Player.State = Player_State_Air
182
#endplatform
183
end if
184
end if
185
break
186
187
case 5
188
if Player.YVelocity < 0
189
Player.Gravity = GRAVITY_GROUND
190
Player.State = Player_State_TubeRoll
191
Player.Animation = ANI_JUMPING
192
Player.CollisionMode = CMODE_RWALL
193
Player.Angle = 64
194
Player.Speed = -0xA0000
195
Player.MinRollSpeed = 0xA0000
196
end if
197
break
198
199
case 6
200
if Player.YVelocity > 0
201
Player.Gravity = GRAVITY_GROUND
202
Player.State = Player_State_TubeRoll
203
Player.Animation = ANI_JUMPING
204
Player.CollisionMode = CMODE_RWALL
205
Player.Angle = 64
206
Player.Speed = Player.YVelocity
207
Player.MinRollSpeed = 0xA0000
208
end if
209
break
210
211
case 7
212
Player.Gravity = GRAVITY_GROUND
213
Player.State = Player_State_TubeRoll
214
Player.Animation = ANI_JUMPING
215
if Player.CollisionMode != CMODE_RWALL
216
Player.CollisionMode = CMODE_RWALL
217
Player.Angle = 64
218
end if
219
220
if ConveyorBelt_Flag == 3
221
Player.Speed = -0xD0000
222
Player.MinRollSpeed = 0xD0000
223
else
224
Player.Speed = 0xA0000
225
Player.MinRollSpeed = 0xA0000
226
end if
227
break
228
229
case 8
230
if ConveyorBelt_Flag == 3
231
Player.Gravity = GRAVITY_GROUND
232
Player.State = Player_State_TubeRoll
233
Player.Animation = ANI_JUMPING
234
Player.CollisionMode = CMODE_RWALL
235
Player.Angle = 64
236
Player.Speed = -0xD0000
237
Player.MinRollSpeed = 0xD0000
238
if Object.InTube == false
239
PlaySfx(SFX_G_RELEASE, false)
240
end if
241
end if
242
break
243
end switch
244
245
Object.InTube = true
246
else
247
Object.InTube = false
248
end if
249
end sub
250
251
252
// ========================
253
// Editor Subs
254
// ========================
255
256
// TODO: gonna hold off on doing editor stuff for this one, wanna wait 'til i can actually see everything before i start doing stuff
257
// basic notes are labelled up above through if someone else wants to do it
258
259
sub RSDKDraw
260
// Draw a square out of Tube Switch icons
261
262
TempValue0 = Object.XPos
263
TempValue0 -= 0x80000
264
TempValue1 = Object.YPos
265
TempValue1 -= 0x80000
266
DrawSpriteXY(0, TempValue0, TempValue1)
267
TempValue0 += 0x100000
268
DrawSpriteXY(0, TempValue0, TempValue1)
269
TempValue1 += 0x100000
270
DrawSpriteXY(0, TempValue0, TempValue1)
271
TempValue0 -= 0x100000
272
DrawSpriteXY(0, TempValue0, TempValue1)
273
274
if Editor.ShowGizmos == true
275
TempValue0 = Object.XPos
276
TempValue0 -= 8
277
TempValue1 = Object.YPos
278
TempValue1 -= 8
279
DrawRectOutline(TempValue0, TempValue1, 16, 16, 255, 255, 255, 255)
280
end if
281
end sub
282
283
284
sub RSDKLoad
285
LoadSpriteSheet("Global/Display.gif")
286
SpriteFrame(-8, -8, 16, 16, 173, 67) // "T" (ubeswitch) icon
287
288
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
289
end sub
290
291