Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-CD-2011-Script-Decompilation
Path: blob/main/Scripts/R7/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.Value2 : Object.LedgeStop
8
// Player Aliases
9
#alias Player.Value6 : Player.MinRollSpeed
10
11
// Collision Modes
12
#alias 0 : CMODE_FLOOR
13
#alias 1 : CMODE_LWALL
14
#alias 2 : CMODE_ROOF
15
#alias 3 : CMODE_RWALL
16
17
// Gravity
18
#alias 0 : GRAVITY_GROUND
19
#alias 1 : GRAVITY_AIR
20
21
// Property Values
22
#alias 0 : TUBESW_ENTER_H_L
23
#alias 1 : TUBESW_ENTER_V
24
#alias 2 : TUBESW_ENTER_V_TUBE
25
#alias 3 : TUBESW_H_LABYRINTH
26
#alias 4 : TUBESW_ENTER_H_R
27
#alias 5 : TUBESW_V_LABYRINTH
28
#alias 6 : TUBESW_LABYRINTH_SPRING
29
#alias 7 : TUBESW_LABYRINTH_EXIT_UPWARDS
30
31
32
sub ObjectPlayerInteraction
33
PlayerObjectCollision(C_TOUCH, -16, -16, 16, 16)
34
#platform: Use_Origins
35
if CheckResult == true
36
if Stage.PlayerListPos == PLAYER_KNUCKLES
37
if Player.State == Player_State_LedgePullUp
38
CheckResult = false
39
Object.LedgeStop = true
40
end if
41
end if
42
end if
43
#endplatform
44
if CheckResult == true
45
switch Object.PropertyValue
46
case TUBESW_ENTER_H_L
47
#platform: Use_Origins
48
if Object.LedgeStop == true
49
Player.Speed = 1
50
Object.LedgeStop = false
51
end if
52
#endplatform
53
if Object.InTube == false
54
if Player.State != Player_State_TubeAirRoll
55
Player.State = Player_State_TubeAirRoll
56
Player.Gravity = GRAVITY_GROUND
57
Player.Animation = ANI_JUMPING
58
Player.MinRollSpeed = 0xD0000
59
else
60
Player.State = Player_State_Roll
61
Player.Animation = ANI_JUMPING
62
end if
63
end if
64
break
65
66
case TUBESW_ENTER_V
67
68
#platform: Use_Origins
69
Player.State = Player_State_Air_NoDropDash
70
#endplatform
71
72
#platform: Use_Standalone
73
Player.State = Player_State_Air
74
#endplatform
75
76
Player.Animation = ANI_JUMPING
77
if Player.Gravity == GRAVITY_AIR
78
if Player.YVelocity < 0
79
Player.YVelocity = -0xD0000
80
else
81
Player.YVelocity = 0xD0000
82
end if
83
else
84
switch Player.CollisionMode
85
case CMODE_LWALL
86
if Player.Speed < 0
87
Player.YVelocity = 0xD0000
88
else
89
Player.YVelocity = -0xD0000
90
end if
91
break
92
case CMODE_RWALL
93
if Player.Speed < 0
94
Player.YVelocity = -0xD0000
95
else
96
Player.YVelocity = 0xD0000
97
end if
98
break
99
end switch
100
end if
101
Player.Gravity = GRAVITY_AIR
102
Player.XPos = Object.XPos
103
Player.XVelocity = 0
104
Player.Speed = 0
105
break
106
107
case TUBESW_ENTER_V_TUBE
108
if Object.InTube == false
109
if Player.State != Player_State_TubeAirRoll
110
Player.XPos = Object.XPos
111
Player.State = Player_State_TubeAirRoll
112
Player.Animation = ANI_JUMPING
113
Player.MinRollSpeed = 0xD0000
114
Player.CollisionMode = CMODE_RWALL
115
Player.Angle = 64
116
Player.Gravity = GRAVITY_GROUND
117
Player.XVelocity = 0
118
if Player.YVelocity < 0
119
Player.Speed = -0xD0000
120
else
121
Player.Speed = 0xD0000
122
end if
123
Player.YVelocity = 0
124
Player.Right = false
125
Player.Left = false
126
else
127
128
#platform: Use_Origins
129
Player.State = Player_State_Air_NoDropDash
130
#endplatform
131
132
#platform: Use_Standalone
133
Player.State = Player_State_Air
134
#endplatform
135
Player.Animation = ANI_JUMPING
136
switch Player.CollisionMode
137
case 1
138
if Player.Speed < 0
139
Player.YVelocity = 0xD0000
140
else
141
Player.YVelocity = -0xD0000
142
end if
143
break
144
case 3
145
if Player.Speed < 0
146
Player.YVelocity = -0xD0000
147
else
148
Player.YVelocity = 0xD0000
149
end if
150
break
151
end switch
152
Player.Gravity = GRAVITY_AIR
153
Player.XPos = Object.XPos
154
Player.XVelocity = 0
155
Player.Speed = 0
156
end if
157
end if
158
break
159
160
case TUBESW_H_LABYRINTH
161
if Object.InTube == false
162
if Player.CollisionMode == CMODE_ROOF
163
Player.CollisionMode = CMODE_FLOOR
164
Player.Angle = 0
165
FlipSign(Player.Speed)
166
FlipSign(Player.XVelocity)
167
end if
168
end if
169
break
170
171
case TUBESW_ENTER_H_R
172
if Object.InTube == false
173
Player.State = Player_State_Roll
174
Player.Animation = ANI_JUMPING
175
if Player.XPos < Object.XPos
176
if Player.Speed < 0xA0000
177
Player.Speed = 0xA0000
178
end if
179
Player.Direction = FACING_RIGHT
180
else
181
if Player.Speed > -0xA0000
182
Player.Speed = -0xA0000
183
end if
184
Player.Direction = FACING_LEFT
185
end if
186
end if
187
break
188
189
case TUBESW_V_LABYRINTH
190
if Player.YVelocity < 0
191
if Player.State != Player_State_TubeAirRoll
192
if Player.Left == true
193
Player.State = Player_State_TubeAirRoll
194
Player.Gravity = GRAVITY_GROUND
195
Player.CollisionMode = CMODE_RWALL
196
Player.Angle = 64
197
Player.Animation = ANI_JUMPING
198
Player.MinRollSpeed = 0xD0000
199
Player.Speed = -0xD0000
200
Player.XVelocity = 0
201
Player.YVelocity = 0
202
Player.XPos -= 0x80000
203
end if
204
205
if Player.Right == true
206
Player.State = Player_State_TubeAirRoll
207
Player.Gravity = GRAVITY_GROUND
208
Player.CollisionMode = CMODE_LWALL
209
Player.Angle = 192
210
Player.Animation = ANI_JUMPING
211
Player.MinRollSpeed = 0xD0000
212
Player.Speed = 0xD0000
213
Player.XVelocity = 0
214
Player.YVelocity = 0
215
Player.XPos += 0x80000
216
end if
217
end if
218
end if
219
break
220
221
case TUBESW_LABYRINTH_SPRING
222
if Object.InTube == false
223
224
#platform: Use_Origins
225
// In Origins, both versions of the Air state are checked against just in case
226
CheckEqual(Player.State, Player_State_Air_NoDropDash)
227
TempValue0 = CheckResult
228
CheckEqual(Player.State, Player_State_Air)
229
TempValue0 |= CheckResult
230
if TempValue0 != false
231
Player.XPos = Object.XPos
232
Player.XVelocity = 0
233
Player.Speed = 0
234
end if
235
#endplatform
236
237
#platform: Use_Standalone
238
// In Standalone, we don't have any pesky Dropdash to worry about
239
if Player.State == Player_State_Air
240
Player.XPos = Object.XPos
241
Player.XVelocity = 0
242
Player.Speed = 0
243
end if
244
#endplatform
245
246
end if
247
break
248
249
case TUBESW_LABYRINTH_EXIT_UPWARDS
250
if Object.InTube == false
251
if Player.CollisionMode == CMODE_ROOF
252
Player.CollisionMode = CMODE_FLOOR
253
Player.Angle += 128
254
FlipSign(Player.Speed)
255
FlipSign(Player.XVelocity)
256
end if
257
end if
258
break
259
260
end switch
261
262
Object.InTube = true
263
else
264
Object.InTube = false
265
end if
266
end sub
267
268
269
// ========================
270
// Editor Subs
271
// ========================
272
273
sub RSDKDraw
274
// This object doesn't have a debug view, so this is custom
275
// It draws a square out of tubeswitch icons
276
277
TempValue0 = Object.XPos
278
TempValue0 -= 0x80000
279
TempValue1 = Object.YPos
280
TempValue1 -= 0x80000
281
DrawSpriteXY(0, TempValue0, TempValue1)
282
TempValue0 += 0x100000
283
DrawSpriteXY(0, TempValue0, TempValue1)
284
TempValue1 += 0x100000
285
DrawSpriteXY(0, TempValue0, TempValue1)
286
TempValue0 -= 0x100000
287
DrawSpriteXY(0, TempValue0, TempValue1)
288
289
if Editor.ShowGizmos == true
290
// Draw the tube switch's hitbox, purposefully ignoring Editor.DrawingOverlay
291
292
TempValue0 = Object.iXPos
293
TempValue0 -= 16
294
TempValue1 = Object.iYPos
295
TempValue1 -= 16
296
DrawRectOutline(TempValue0, TempValue1, 32, 32, 255, 255, 255, 255)
297
end if
298
end sub
299
300
301
sub RSDKLoad
302
LoadSpriteSheet("Global/Display.gif")
303
SpriteFrame(-8, -8, 16, 16, 173, 67) // "T" (ubeswitch) icon
304
305
// TODO: how would you even name these
306
end sub
307
308