Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-CD-2011-Script-Decompilation
Path: blob/main/Scripts/R3/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.OnObject
7
#alias Object.Value1 : Object.LedgeStop
8
9
// Player Aliases
10
#alias Player.Value6 : Player.MinRollSpeed
11
12
// Gravity
13
#alias 0 : GRAVITY_GROUND
14
#alias 1 : GRAVITY_AIR
15
16
// Collision Modes
17
#alias 0 : CMODE_FLOOR
18
#alias 1 : CMODE_LWALL
19
#alias 2 : CMODE_ROOF
20
#alias 3 : CMODE_RWALL
21
22
// Property Values
23
#alias 0 : TUBESWITCH_H_L
24
#alias 1 : TUBESWITCH_H_R
25
#alias 2 : TUBESWITCH_V_T
26
#alias 3 : TUBESWITCH_V_B
27
#alias 4 : TUBESWITCH_ROLL_ALIGN
28
#alias 5 : TUBESWITCH_V_GROUNDED
29
#alias 6 : TUBESWITCH_V_FORCE_DW
30
#alias 7 : TUBESWITCH_V_FORCE_L_DW
31
#alias 8 : TUBESWITCH_FORCE_ROLL
32
#alias 9 : TUBESWITCH_V_GROUNDED_DW
33
#alias 10 : TUBESWITCH_GROUNDED_CANCEL
34
#alias 11 : TUBESWITCH_EDGE_BOUNCE
35
#alias 12 : TUBESWITCH_ROLL_MASK
36
37
// Player Aliases
38
#alias Player.Value2 : Player.RollAnimationSpeed
39
#alias Player.Value6 : Player.MinRollSpeed
40
41
42
sub ObjectPlayerInteraction
43
PlayerObjectCollision(C_TOUCH, -16, -16, 16, 16)
44
#platform: Use_Origins
45
if CheckResult == true
46
if Stage.PlayerListPos == PLAYER_KNUCKLES
47
if Player.State == Player_State_LedgePullUp
48
CheckResult = false
49
Object.LedgeStop = true
50
end if
51
end if
52
end if
53
#endplatform
54
if CheckResult == true
55
switch Object.PropertyValue
56
case TUBESWITCH_H_L
57
#platform: Use_Origins
58
if Object.LedgeStop == true
59
Player.Speed = 1
60
Object.LedgeStop = false
61
end if
62
#endplatform
63
if Player.Speed > 0
64
Player.Direction = FACING_RIGHT
65
Player.State = Player_State_TubeRoll
66
Player.Animation = ANI_JUMPING
67
Player.MinRollSpeed = 0xA0000
68
69
if Player.Speed < 0xA0000
70
Player.Speed = 0xA0000
71
end if
72
73
if Player.Gravity == GRAVITY_AIR
74
Player.Gravity = GRAVITY_GROUND
75
Player.YPos = Object.YPos
76
end if
77
else
78
if Player.Gravity == GRAVITY_GROUND
79
if Player.Speed > -0x20000
80
Player.Speed = -0x20000
81
end if
82
end if
83
84
Player.State = Player_State_Roll
85
Player.Animation = ANI_JUMPING
86
end if
87
break
88
89
case TUBESWITCH_H_R
90
if Player.Speed < 0
91
Player.State = Player_State_TubeRoll
92
Player.Animation = ANI_JUMPING
93
Player.MinRollSpeed = 0xA0000
94
95
if Player.Speed > -0xA0000
96
Player.Speed = -0xA0000
97
end if
98
else
99
if Player.Gravity == GRAVITY_GROUND
100
if Player.Speed < 0x20000
101
Player.Speed = 0x20000
102
end if
103
end if
104
105
Player.State = Player_State_Roll
106
Player.Animation = ANI_JUMPING
107
end if
108
break
109
110
case TUBESWITCH_V_T
111
if Object.OnObject == false
112
113
if Player.Gravity == GRAVITY_AIR
114
Player.Gravity = GRAVITY_GROUND
115
Player.State = Player_State_TubeRoll
116
Player.Animation = ANI_JUMPING
117
Player.CollisionMode = CMODE_RWALL
118
Player.Angle = 64
119
Player.Speed = 0x100000
120
Player.MinRollSpeed = 0x100000
121
else
122
if Player.Speed > 0
123
Player.Gravity = GRAVITY_GROUND
124
Player.State = Player_State_TubeRoll
125
Player.Animation = ANI_JUMPING
126
Player.CollisionMode = CMODE_RWALL
127
Player.Angle = 64
128
Player.Speed = 0x100000
129
Player.MinRollSpeed = 0x100000
130
else
131
Player.Gravity = GRAVITY_AIR
132
Player.YVelocity = Player.Speed
133
Player.Speed = 0
134
Player.XVelocity = 0
135
end if
136
137
end if
138
139
end if
140
break
141
142
case TUBESWITCH_V_B
143
if Object.OnObject == false
144
if Player.Gravity == GRAVITY_AIR
145
Player.Gravity = GRAVITY_GROUND
146
Player.State = Player_State_TubeRoll
147
Player.Animation = ANI_JUMPING
148
Player.CollisionMode = CMODE_RWALL
149
Player.Angle = 64
150
Player.Speed = -0xA0000
151
Player.MinRollSpeed = 0xA0000
152
end if
153
if Player.CollisionMode == CMODE_RWALL
154
if Player.Speed < 0
155
Player.Gravity = GRAVITY_GROUND
156
Player.State = Player_State_TubeRoll
157
Player.Animation = ANI_JUMPING
158
Player.CollisionMode = CMODE_RWALL
159
Player.Angle = 64
160
Player.Speed = -0xA0000
161
Player.MinRollSpeed = 0xA0000
162
else
163
Player.Gravity = GRAVITY_AIR
164
Player.YVelocity = Player.Speed
165
Player.Speed = 0
166
Player.XVelocity = 0
167
end if
168
end if
169
end if
170
break
171
172
case TUBESWITCH_ROLL_ALIGN
173
if Player.Gravity == GRAVITY_GROUND
174
Player.State = Player_State_Roll
175
else
176
#platform: Use_Origins
177
if Player.State != Player_State_Climb
178
Player.XPos = Object.XPos
179
end if
180
#endplatform
181
182
#platform: Use_Standalone
183
Player.XPos = Object.XPos
184
#endplatform
185
186
end if
187
if Player.Animation != ANI_JUMPING
188
Player.Animation = ANI_JUMPING
189
Player.RollAnimationSpeed = 240
190
end if
191
break
192
193
case TUBESWITCH_V_GROUNDED
194
if Object.OnObject == false
195
if Player.YVelocity > 0
196
Player.State = Player_State_TubeRoll
197
198
Player.Animation = ANI_JUMPING
199
200
Player.Gravity = GRAVITY_GROUND
201
Player.CollisionMode = CMODE_RWALL
202
203
Player.Angle = 64
204
Player.Speed = 0x100000
205
Player.MinRollSpeed = 0x100000
206
207
end if
208
else
209
210
#platform: Use_Origins
211
CheckEqual(Player.State, Player_State_Air_NoDropDash)
212
TempValue0 = CheckResult
213
CheckEqual(Player.State, Player_State_Air)
214
TempValue0 |= CheckResult
215
if TempValue0 != false
216
Player.Animation = ANI_JUMPING
217
end if
218
#endplatform
219
220
#platform: Use_Standalone
221
if Player.State == Player_State_Air
222
Player.Animation = ANI_JUMPING
223
end if
224
#endplatform
225
226
end if
227
break
228
229
case TUBESWITCH_V_FORCE_DW
230
if Object.OnObject == false
231
232
if Player.Gravity == GRAVITY_AIR
233
Player.Gravity = GRAVITY_GROUND
234
Player.State = Player_State_TubeRoll
235
Player.Animation = ANI_JUMPING
236
Player.CollisionMode = CMODE_RWALL
237
Player.Angle = 64
238
Player.Speed = 0x100000
239
Player.MinRollSpeed = 0x100000
240
else
241
Player.Gravity = GRAVITY_AIR
242
Player.YVelocity = Player.Speed
243
FlipSign(Player.YVelocity)
244
Player.Speed = 0
245
Player.XVelocity = 0
246
end if
247
248
end if
249
break
250
251
case TUBESWITCH_V_FORCE_L_DW
252
if Object.OnObject == false
253
if Player.YVelocity > 0
254
Player.Gravity = GRAVITY_GROUND
255
Player.State = Player_State_TubeRoll
256
Player.Animation = ANI_JUMPING
257
Player.CollisionMode = CMODE_LWALL
258
Player.Angle = 192
259
Player.Speed = -0x100000
260
Player.MinRollSpeed = 0x100000
261
end if
262
else
263
Player.Animation = ANI_JUMPING
264
end if
265
break
266
267
case TUBESWITCH_FORCE_ROLL
268
if Player.State != Player_State_Fly
269
if Player.Gravity == GRAVITY_GROUND
270
Player.State = Player_State_Roll
271
end if
272
Player.Animation = ANI_JUMPING
273
end if
274
break
275
276
case TUBESWITCH_V_GROUNDED_DW
277
if Object.OnObject == false
278
if Player.YVelocity > 0
279
Player.Gravity = GRAVITY_GROUND
280
Player.State = Player_State_TubeRoll
281
Player.Animation = ANI_JUMPING
282
Player.CollisionMode = CMODE_RWALL
283
Player.Angle = 64
284
Player.Speed = 0x80000
285
Player.MinRollSpeed = 0x80000
286
end if
287
else
288
Player.Animation = ANI_JUMPING
289
end if
290
break
291
292
case TUBESWITCH_GROUNDED_CANCEL
293
if Object.OnObject == false
294
if Player.Gravity == GRAVITY_GROUND
295
Player.Gravity = GRAVITY_AIR
296
Player.YVelocity = Player.Speed
297
Player.Speed = 0
298
Player.XVelocity = 0
299
end if
300
end if
301
break
302
303
case TUBESWITCH_EDGE_BOUNCE
304
if Player.YVelocity > 0
305
if Player.XPos > Object.XPos
306
TempValue0 = Player.XPos
307
TempValue0 -= Object.XPos
308
if TempValue0 < 0x60000
309
Player.Gravity = GRAVITY_AIR
310
Player.YVelocity = -0x30000
311
end if
312
else
313
TempValue0 = Object.XPos
314
TempValue0 -= Player.XPos
315
if TempValue0 < 0x60000
316
Player.Gravity = GRAVITY_AIR
317
Player.YVelocity = -0x30000
318
end if
319
end if
320
end if
321
break
322
323
case TUBESWITCH_ROLL_MASK
324
if Player.State != Player_State_Fly
325
if Player.XVelocity > 0x40000
326
if Player.Gravity == GRAVITY_GROUND
327
Player.State = Player_State_Roll
328
end if
329
Player.Animation = ANI_JUMPING
330
end if
331
end if
332
break
333
334
end switch
335
Object.OnObject = true
336
else
337
Object.OnObject = false
338
end if
339
end sub
340
341
342
// ========================
343
// Editor Subs
344
// ========================
345
346
sub RSDKDraw
347
TempValue0 = Object.XPos
348
TempValue0 -= 0x80000
349
TempValue1 = Object.YPos
350
TempValue1 -= 0x80000
351
352
DrawSpriteXY(0, TempValue0, TempValue1)
353
354
TempValue0 += 0x100000
355
DrawSpriteXY(0, TempValue0, TempValue1)
356
357
TempValue1 += 0x100000
358
DrawSpriteXY(0, TempValue0, TempValue1)
359
360
TempValue0 -= 0x100000
361
DrawSpriteXY(0, TempValue0, TempValue1)
362
end sub
363
364
365
sub RSDKLoad
366
LoadSpriteSheet("Global/Display.gif")
367
SpriteFrame(-8, -8, 16, 16, 173, 67) // #0 - "T" Icon
368
369
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
370
end sub
371
372