Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-CD-2011-Script-Decompilation
Path: blob/main/Scripts/R3/ScoreChute.txt
1319 views
1
//----------------Sonic CD Score Chute Script-----------------//
2
//--------Scripted by Christian Whitehead 'The Taxman'--------//
3
//-------Unpacked By Rubberduckycooly's Script Unpacker-------//
4
5
// Aliases
6
#alias Object.Value0 : Object.Timer
7
#alias Object.Value1 : Object.ScoreBonus
8
9
// Player Aliases
10
#alias Player.Value4 : Player.InvincibleTimer
11
#alias Player.Value5 : Player.BlinkTimer
12
13
// States
14
#alias 0 : SCORECHUTE_IDLE
15
#alias 1 : SCORECHUTE_CATCH_PLAYER
16
#alias 2 : SCORECHUTE_INSERT_1
17
#alias 3 : SCORECHUTE_INSERT_2
18
#alias 4 : SCORECHUTE_GIVE_POINTS
19
#alias 5 : SCORECHUTE_PULL_PLAYER
20
#alias 6 : SCORECHUTE_EJECT_PLAYER
21
#alias 7 : SCORECHUTE_COOLDOWN
22
23
// Players
24
#alias 0 : PLAYER_SONIC_A
25
26
// Stage SFX
27
#alias 2 : SFX_S_SCORECHUTE
28
#alias 3 : SFX_S_CHUTEEXIT
29
30
// Priority
31
#alias 0 : PRIORITY_BOUNDS
32
#alias 1 : PRIORITY_ACTIVE
33
34
35
sub ObjectMain
36
switch Object.State
37
case SCORECHUTE_CATCH_PLAYER
38
if Object.Timer < 8
39
Object.Timer++
40
Player.XPos = Object.XPos
41
Player.YPos = Object.YPos
42
Player.YPos -= 0x80000
43
Player.YVelocity = 0
44
Player.XVelocity = 0
45
Player.Speed = 0
46
else
47
Object.State = SCORECHUTE_INSERT_1
48
Object.Timer = 0
49
Player.YVelocity = 0
50
Player.XVelocity = 0
51
Player.Visible = false
52
if Player.BlinkTimer > 0
53
Player.InvincibleTimer = 0
54
Player.BlinkTimer = 0
55
end if
56
Player.State = Player_State_Static
57
end if
58
break
59
60
case SCORECHUTE_INSERT_1
61
if Object.Timer < 8
62
Object.Timer++
63
Player.XPos = Object.XPos
64
Player.YPos = Object.YPos
65
Player.YPos -= 0x80000
66
else
67
Object.State = SCORECHUTE_INSERT_2
68
Object.Timer = 0
69
end if
70
break
71
72
case SCORECHUTE_INSERT_2
73
if Object.Timer < 4
74
Object.Timer++
75
else
76
Object.State = SCORECHUTE_GIVE_POINTS
77
Object.Timer = 0
78
end if
79
// in case of time over
80
if Player.State == Player_State_Death
81
Object.State = SCORECHUTE_COOLDOWN
82
Object.Timer = 0
83
Player.Visible = true
84
end if
85
break
86
87
case SCORECHUTE_GIVE_POINTS
88
if Object.ScoreBonus < 4
89
if Object.Timer == 32
90
CreateTempObject(TypeName[Object Score], 0, Object.XPos, Object.YPos)
91
Player.Score += 100
92
end if
93
end if
94
if Object.ScoreBonus < 3
95
if Object.Timer == 64
96
CreateTempObject(TypeName[Object Score], 0, Object.XPos, Object.YPos)
97
Player.Score += 100
98
end if
99
end if
100
if Object.Timer < 80
101
Object.Timer++
102
else
103
Object.State = SCORECHUTE_PULL_PLAYER
104
Object.Timer = 0
105
end if
106
// in case of time over
107
if Player.State == Player_State_Death
108
Object.State = SCORECHUTE_COOLDOWN
109
Object.Timer = 0
110
Player.Visible = true
111
end if
112
break
113
114
case SCORECHUTE_PULL_PLAYER
115
if Object.Timer < 4
116
Object.Timer++
117
else
118
Object.State = SCORECHUTE_EJECT_PLAYER
119
Object.Timer = 0
120
end if
121
if Player.State == Player_State_Death // in case of time over
122
Object.State = SCORECHUTE_COOLDOWN
123
Object.Timer = 0
124
Player.Visible = true
125
end if
126
break
127
128
case SCORECHUTE_EJECT_PLAYER
129
if Object.Timer < 8
130
Object.Timer++
131
else
132
Object.State = SCORECHUTE_COOLDOWN
133
Object.Timer = 0
134
135
#platform: Use_Origins
136
Player.State = Player_State_Air_NoDropDash
137
#endplatform
138
139
#platform: Use_Standalone
140
Player.State = Player_State_Air
141
#endplatform
142
143
Player.Visible = true
144
Player.Animation = ANI_JUMPING
145
146
Player.ObjectInteraction = true
147
148
Player.YVelocity = -0x74000
149
Player.Timer = 0
150
PlayStageSfx(SFX_S_CHUTEEXIT, false)
151
end if
152
break
153
154
case SCORECHUTE_COOLDOWN
155
if Object.Timer < 120
156
Object.Timer++
157
else
158
Object.State = SCORECHUTE_IDLE
159
Object.Timer = 0
160
Object.ScoreBonus++
161
end if
162
break
163
164
end switch
165
166
if Object.OutOfBounds == true
167
Object.ScoreBonus = 0
168
Object.Priority = PRIORITY_BOUNDS
169
end if
170
end sub
171
172
173
sub ObjectPlayerInteraction
174
if Object.State == SCORECHUTE_IDLE
175
if Player.YVelocity >= 0
176
PlayerObjectCollision(C_TOUCH, -16, -8, 16, 16)
177
if CheckResult == true
178
Object.State = SCORECHUTE_CATCH_PLAYER
179
Object.Priority = PRIORITY_ACTIVE
180
181
Player.Animation = ANI_JUMPING
182
Player.ObjectInteraction = false
183
184
PlayStageSfx(SFX_S_SCORECHUTE, false)
185
186
#platform: Use_Haptics
187
HapticEffect(55, 0, 0, 0)
188
#endplatform
189
190
end if
191
end if
192
end if
193
end sub
194
195
196
sub ObjectDraw
197
switch Object.State
198
case SCORECHUTE_CATCH_PLAYER
199
DrawSprite(0)
200
break
201
202
case SCORECHUTE_INSERT_1
203
DrawSprite(0)
204
DrawSprite(1)
205
break
206
207
case SCORECHUTE_INSERT_2
208
DrawSprite(0)
209
DrawSprite(2)
210
break
211
212
case SCORECHUTE_GIVE_POINTS
213
TempValue0 = Object.Timer
214
TempValue0 &= 7
215
TempValue0 >>= 2
216
if TempValue0 > 0
217
DrawSprite(0)
218
end if
219
break
220
221
case SCORECHUTE_PULL_PLAYER
222
DrawSprite(0)
223
DrawSprite(2)
224
break
225
226
case SCORECHUTE_EJECT_PLAYER
227
DrawSprite(0)
228
DrawSprite(1)
229
break
230
231
end switch
232
end sub
233
234
235
sub ObjectStartup
236
#platform: Use_Standalone
237
LoadSpriteSheet("R3/Objects.gif")
238
SpriteFrame(-24, -8, 48, 16, 117, 233) // #0 - Score Chute Active
239
240
if Stage.PlayerListPos == PLAYER_SONIC_A
241
SpriteFrame(-16, -24, 32, 16, 2, 240) // #1 - Jump Insert Frame 0
242
SpriteFrame(-8, -16, 16, 8, 35, 241) // #2 - Jump Insert Frame 1
243
else
244
SpriteFrame(-12, -20, 24, 12, 228, 244) // #1 - Jump Insert Frame 0
245
SpriteFrame(-8, -16, 16, 8, 211, 247) // #2 - Jump Insert Frame 1
246
end if
247
#endplatform
248
249
#platform: Use_Origins
250
if Stage.PlayerListPos == PLAYER_SONIC
251
LoadSpriteSheet("R3/Objects.gif")
252
SpriteFrame(-24, -8, 48, 16, 117, 233) // #0 - Score Chute Active
253
SpriteFrame(-16, -24, 32, 16, 2, 240) // #1 - Jump Insert Frame 0
254
SpriteFrame(-8, -16, 16, 8, 35, 241) // #2 - Jump Insert Frame 1
255
end if
256
257
if Stage.PlayerListPos == PLAYER_TAILS
258
LoadSpriteSheet("R3/Objects.gif")
259
SpriteFrame(-24, -8, 48, 16, 117, 233) // #0 - Score Chute Active
260
SpriteFrame(-12, -20, 24, 12, 228, 244) // #1 - Jump Insert Frame 0
261
SpriteFrame(-8, -16, 16, 8, 211, 247) // #2 - Jump Insert Frame 1
262
end if
263
264
if Stage.PlayerListPos == PLAYER_KNUCKLES
265
LoadSpriteSheet("R3/Objects3.gif")
266
SpriteFrame(-24, -8, 48, 16, 99, 133) // #0 - Score Chute Active
267
SpriteFrame(-16, -24, 32, 16, 66, 150) // #1 - Jump Insert Frame 0
268
SpriteFrame(-8, -16, 16, 8, 116, 150) // #2 - Jump Insert Frame 1
269
end if
270
271
if Stage.PlayerListPos == PLAYER_AMY
272
LoadSpriteSheet("R3/Objects3.gif")
273
SpriteFrame(-24, -8, 48, 16, 99, 133) // #0 - Score Chute Active
274
SpriteFrame(-16, -24, 32, 16, 66, 133) // #1 - Jump Insert Frame 0
275
SpriteFrame(-8, -16, 16, 8, 99, 150) // #2 - Jump Insert Frame 1
276
end if
277
#endplatform
278
279
// Used to be below LoadSpriteSheet, moved here for consistency
280
ArrayPos0 = 32
281
while ArrayPos0 < 1056
282
if Object[ArrayPos0].Type == TypeName[Score Chute]
283
Object[ArrayPos0].DrawOrder = 4
284
end if
285
ArrayPos0++
286
loop
287
end sub
288
289
290
// ========================
291
// Editor Subs
292
// ========================
293
294
sub RSDKDraw
295
DrawSprite(0)
296
end sub
297
298
299
sub RSDKLoad
300
LoadSpriteSheet("R3/Objects.gif")
301
302
SpriteFrame(-24, -8, 48, 16, 117, 233) // #0 - Score Chute Active
303
304
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
305
end sub
306
307