Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-CD-2011-Script-Decompilation
Path: blob/main/Scripts/R8/Bumper.txt
1319 views
1
//-----------------Sonic CD Bumper Script---------------------//
2
//--------Scripted by Christian Whitehead 'The Taxman'--------//
3
//-------Unpacked By Rubberduckycooly's Script Unpacker-------//
4
5
// Aliases
6
#alias Object.Value0 : Object.FrameTimer
7
#alias Object.Value1 : Object.BonusScore
8
#alias Object.Value2 : Object.Oscillation
9
#alias Object.Value3 : Object.TurnDirection
10
#alias Object.Value4 : Object.XOriginPos
11
#alias Object.Value5 : Object.YOriginPos
12
13
// States
14
#alias 0 : BUMPER_IDLE
15
#alias 1 : BUMPER_ACTIVE
16
17
// Gravity
18
#alias 0 : GRAVITY_GROUND
19
#alias 1 : GRAVITY_AIR
20
21
// Stage SFX
22
#alias 3 : SFX_S_BUMPER
23
24
// Priority
25
#alias 0 : PRIORITY_BOUNDS
26
#alias 1 : PRIORITY_ACTIVE
27
28
// Property Values
29
#alias 1 : BUMPER_RIGHT_TO_LEFT
30
#alias 2 : BUMPER_LEFT_TO_RIGHT
31
#alias 3 : BUMPER_TOP_TO_BOTTOM
32
#alias 4 : BUMPER_BOTTOM_TO_TOP
33
34
35
sub ObjectMain
36
switch Object.PropertyValue
37
case BUMPER_RIGHT_TO_LEFT
38
if Object.TurnDirection == false
39
if Object.Oscillation < 0x300000
40
Object.Oscillation += 0x10000
41
else
42
Object.TurnDirection = true
43
end if
44
else
45
if Object.Oscillation > -0x300000
46
Object.Oscillation -= 0x10000
47
else
48
Object.TurnDirection = false
49
end if
50
end if
51
Object.XPos = Object.XOriginPos
52
Object.XPos += Object.Oscillation
53
break
54
55
case BUMPER_LEFT_TO_RIGHT
56
if Object.TurnDirection == false
57
if Object.Oscillation < 0x300000
58
Object.Oscillation += 0x10000
59
else
60
Object.TurnDirection = true
61
end if
62
else
63
if Object.Oscillation > -0x300000
64
Object.Oscillation -= 0x10000
65
else
66
Object.TurnDirection = false
67
end if
68
end if
69
Object.XPos = Object.XOriginPos
70
Object.XPos += Object.Oscillation
71
break
72
73
case BUMPER_TOP_TO_BOTTOM
74
if Object.TurnDirection == false
75
if Object.Oscillation < 0x300000
76
Object.Oscillation += 0x10000
77
else
78
Object.TurnDirection = true
79
end if
80
else
81
if Object.Oscillation > -0x300000
82
Object.Oscillation -= 0x10000
83
else
84
Object.TurnDirection = false
85
end if
86
end if
87
Object.YPos = Object.YOriginPos
88
Object.YPos += Object.Oscillation
89
break
90
91
case BUMPER_BOTTOM_TO_TOP
92
if Object.TurnDirection == false
93
if Object.Oscillation < 0x300000
94
Object.Oscillation += 0x10000
95
else
96
Object.TurnDirection = true
97
end if
98
else
99
if Object.Oscillation > -0x300000
100
Object.Oscillation -= 0x10000
101
else
102
Object.TurnDirection = false
103
end if
104
end if
105
Object.YPos = Object.YOriginPos
106
Object.YPos -= Object.Oscillation
107
break
108
end switch
109
110
if Object.State > BUMPER_IDLE // Check that is being used
111
Object.Frame = Object.FrameTimer
112
Object.Frame /= 5
113
Object.Frame++
114
115
Object.FrameTimer++
116
if Object.FrameTimer > 22
117
Object.FrameTimer = 0
118
Object.State = BUMPER_IDLE
119
Object.Frame = 0
120
end if
121
end if
122
123
if Object.OutOfBounds == true
124
Object.BonusScore = 0
125
Object.Priority = PRIORITY_BOUNDS
126
end if
127
end sub
128
129
130
sub ObjectPlayerInteraction
131
if Player.Animation != ANI_HURT
132
133
PlayerObjectCollision(C_TOUCH, -14, -14, 14, 14)
134
if CheckResult == true
135
136
#platform: Use_Origins
137
if Player.Animation == ANI_CLIMBING
138
// Before bouncing him away, let's make sure Knuckles is in his normal air state, first
139
CallFunction(Player_CancelClimb)
140
end if
141
#endplatform
142
143
if Object.State == BUMPER_IDLE
144
PlayStageSfx(SFX_S_BUMPER, false)
145
if Object.BonusScore < 5
146
CreateTempObject(TypeName[Object Score], 0, Object.XPos, Object.YPos)
147
Player.Score += 100
148
Object.BonusScore++
149
end if
150
end if
151
if Object.FrameTimer > 5
152
PlayStageSfx(SFX_S_BUMPER, false)
153
154
#platform: Use_Haptics
155
HapticEffect(9, 0, 0, 0)
156
#endplatform
157
158
end if
159
Object.State = BUMPER_ACTIVE
160
161
Object.Priority = PRIORITY_ACTIVE
162
163
TempValue0 = Player.XPos
164
TempValue0 -= Object.XPos
165
TempValue1 = Player.YPos
166
TempValue1 -= Object.YPos
167
ATan2(TempValue2, TempValue0, TempValue1)
168
Cos256(TempValue0, TempValue2)
169
Sin256(TempValue1, TempValue2)
170
171
if Player.State == Player_State_Fly
172
TempValue0 <<= 10
173
TempValue1 <<= 10
174
else
175
TempValue0 *= 0x700
176
TempValue1 *= 0x700
177
Player.Timer = 0
178
end if
179
Player.XVelocity = TempValue0
180
Player.YVelocity = TempValue1
181
Player.Speed = Player.XVelocity
182
183
Player.Gravity = GRAVITY_AIR
184
end if
185
end if
186
end sub
187
188
189
sub ObjectDraw
190
DrawSprite(Object.Frame)
191
end sub
192
193
194
sub ObjectStartup
195
LoadSpriteSheet("R8/Objects3.gif")
196
197
SpriteFrame(-16, -16, 32, 32, 100, 100) // #0 - Bumper
198
SpriteFrame(-12, -12, 24, 24, 1, 228) // #1 - Bumper Hit Frame 0
199
SpriteFrame(-20, -20, 40, 40, 1, 187) // #2 - Bumper Hit Frame 1
200
SpriteFrame(-12, -12, 24, 24, 1, 228) // #3 - Bumper Hit Frame 2
201
SpriteFrame(-20, -20, 40, 40, 1, 187) // #4 - Bumper Hit Frame 3
202
SpriteFrame(-20, -20, 40, 40, 1, 187) // #5 - Bumper Hit Frame 4
203
204
// Used to be below LoadSpriteSheet, moved here for consistency with the rest
205
ArrayPos0 = 32
206
while ArrayPos0 < 1056
207
if Object[ArrayPos0].Type == TypeName[Bumper]
208
Object[ArrayPos0].XOriginPos = Object[ArrayPos0].XPos
209
Object[ArrayPos0].YOriginPos = Object[ArrayPos0].YPos
210
end if
211
ArrayPos0++
212
loop
213
end sub
214
215
216
// ========================
217
// Editor Subs
218
// ========================
219
220
sub RSDKDraw
221
DrawSprite(0)
222
end sub
223
224
225
sub RSDKLoad
226
LoadSpriteSheet("R8/Objects3.gif")
227
228
SpriteFrame(-16, -16, 32, 32, 100, 100) // #0 - Bumper
229
230
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
231
end sub
232
233