Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-CD-2011-Script-Decompilation
Path: blob/main/Scripts/R7/SpeedBooster.txt
1319 views
1
//---------------Sonic CD Speed Booster 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.DrawOffsetX
8
9
// Booster Cartridge Aliases
10
#alias Object.Value1 : Object.XVelocity
11
#alias Object.Value2 : Object.YVelocity
12
13
// Base State
14
#alias 0 : SPEEDBOOSTER_IDLE
15
16
// Pair of States for when the player is shot right
17
#alias 1 : SPEEDBOOSTER_RECOIL_R
18
#alias 2 : SPEEDBOOSTER_RECOVER_R
19
20
// Pair of States for when the player is shot left
21
#alias 3 : SPEEDBOOSTER_RECOIL_L
22
#alias 4 : SPEEDBOOSTER_RECOVER_L
23
24
// Priority
25
#alias 0 : PRIORITY_BOUNDS
26
#alias 1 : PRIORITY_ACTIVE
27
28
// Stage SFX
29
#alias 0 : SFX_S_LARGEBOOSTER // In origins, this SFX is Launcher
30
#alias 1 : SFX_S_SWITCH
31
32
33
sub ObjectMain
34
switch Object.State
35
case SPEEDBOOSTER_RECOIL_R
36
if Object.Timer < 6
37
Object.DrawOffsetX -= 0x80000
38
Object.Timer++
39
else
40
Object.Timer = 0
41
Object.State++
42
end if
43
break
44
45
case SPEEDBOOSTER_RECOVER_R
46
if Object.Timer < 6
47
Object.DrawOffsetX += 0x80000
48
Object.Timer++
49
else
50
Object.Timer = 0
51
Object.State = SPEEDBOOSTER_IDLE
52
Object.Priority = PRIORITY_BOUNDS
53
end if
54
break
55
56
case SPEEDBOOSTER_RECOIL_L
57
if Object.Timer < 6
58
Object.DrawOffsetX += 0x80000
59
Object.Timer++
60
else
61
Object.Timer = 0
62
Object.State++
63
end if
64
break
65
66
case SPEEDBOOSTER_RECOVER_L
67
if Object.Timer < 6
68
Object.DrawOffsetX -= 0x80000
69
Object.Timer++
70
else
71
Object.Timer = 0
72
Object.State = SPEEDBOOSTER_IDLE
73
Object.Priority = PRIORITY_BOUNDS
74
end if
75
break
76
77
end switch
78
end sub
79
80
81
sub ObjectPlayerInteraction
82
83
if Object.State == SPEEDBOOSTER_IDLE
84
if Player.State != Player_State_Air
85
PlayerObjectCollision(C_TOUCH, -32, -12, 32, 4)
86
if CheckResult == true
87
88
// Make the Speed Boster always active for the next few frames
89
Object.Priority = PRIORITY_ACTIVE
90
91
PlayStageSfx(SFX_S_LARGEBOOSTER, false)
92
93
#platform: Use_Haptics
94
HapticEffect(30, 0, 0, 0)
95
#endplatform
96
97
// Different actions for the different directions the player will be sent
98
if Player.Speed > 0
99
Object.State = SPEEDBOOSTER_RECOIL_R
100
Player.Speed = 0x100000
101
Player.Direction = FACING_RIGHT
102
103
CreateTempObject(TypeName[Fire Trail], 0, Object.XPos, Object.YPos)
104
Object[TempObjectPos].XPos -= 0x180000
105
Object[TempObjectPos].YPos -= 0x60000
106
107
CreateTempObject(TypeName[BoosterCartridge], 0, Object.XPos, Object.YPos)
108
Object[TempObjectPos].XVelocity = -0x20000
109
Object[TempObjectPos].YVelocity = -0x70000
110
else
111
Object.State = SPEEDBOOSTER_RECOIL_L
112
Player.Speed = -0x100000
113
Player.Direction = FACING_LEFT
114
115
CreateTempObject(TypeName[Fire Trail], 0, Object.XPos, Object.YPos)
116
Object[TempObjectPos].XPos += 0x180000
117
Object[TempObjectPos].YPos -= 0x60000
118
Object[TempObjectPos].Direction = FACING_LEFT
119
120
CreateTempObject(TypeName[BoosterCartridge], 0, Object.XPos, Object.YPos)
121
Object[TempObjectPos].XVelocity = 0x20000
122
Object[TempObjectPos].YVelocity = -0x70000
123
Object[TempObjectPos].Direction = FACING_LEFT
124
end if
125
end if
126
end if
127
end if
128
129
end sub
130
131
132
sub ObjectDraw
133
134
TempValue0 = Object.DrawOffsetX
135
TempValue0 += Object.XPos
136
DrawSpriteXY(0, TempValue0, Object.YPos)
137
138
end sub
139
140
141
sub ObjectStartup
142
143
LoadSpriteSheet("R7/Objects.gif")
144
145
// Booster Frame
146
SpriteFrame(-32, -12, 64, 24, 34, 96)
147
148
ArrayPos0 = 32
149
while ArrayPos0 < 1056
150
if Object[ArrayPos0].Type == TypeName[Speed Booster]
151
Object[ArrayPos0].DrawOrder = 4
152
end if
153
154
ArrayPos0++
155
loop
156
157
end sub
158
159
160
// ========================
161
// Editor Subs
162
// ========================
163
164
sub RSDKDraw
165
DrawSprite(0)
166
167
if Editor.ShowGizmos == true
168
// Draw the Booster's activation box
169
170
TempValue0 = Object.iXPos
171
TempValue0 -= 32
172
TempValue1 = Object.iYPos
173
TempValue1 -= 12
174
DrawRectOutline(TempValue0, TempValue1, 64, 16, 255, 255, 255, 255)
175
end if
176
end sub
177
178
179
sub RSDKLoad
180
LoadSpriteSheet("R7/Objects.gif")
181
SpriteFrame(-32, -12, 64, 24, 34, 96)
182
183
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
184
end sub
185
186