Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-CD-2011-Script-Decompilation
Path: blob/main/Scripts/R3/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
// R3Setup Aliases
14
#alias Object[29].Value2 : R3Setup.BumperOscillation
15
16
// States
17
#alias 0 : BUMPER_IDLE
18
#alias 1 : BUMPER_ACTIVE
19
20
// Gravity
21
#alias 0 : GRAVITY_GROUND
22
#alias 1 : GRAVITY_AIR
23
24
// Stage SFX
25
#alias 0 : SFX_S_BUMPER
26
27
// Priority
28
#alias 0 : PRIORITY_BOUNDS
29
#alias 1 : PRIORITY_ACTIVE
30
31
// Property Values
32
// _G properties use R3Setup oscillation
33
#alias 0 : BUMPER_STATIC
34
#alias 1 : BUMPER_RIGHT_TO_LEFT_G
35
#alias 2 : BUMPER_LEFT_TO_RIGHT_G
36
#alias 3 : BUMPER_TOP_TO_BOTTOM
37
#alias 4 : BUMPER_BOTTOM_TO_TOP
38
#alias 5 : BUMPER_TOP_TO_BOTTOM_G
39
#alias 6 : BUMPER_BOTTOM_TO_TOP_G
40
41
42
sub ObjectMain
43
switch Object.PropertyValue
44
case BUMPER_RIGHT_TO_LEFT_G
45
Object.XPos = Object.XOriginPos
46
Object.XPos += R3Setup.BumperOscillation
47
break
48
49
case BUMPER_LEFT_TO_RIGHT_G
50
Object.XPos = Object.XOriginPos
51
Object.XPos -= R3Setup.BumperOscillation
52
break
53
54
case BUMPER_TOP_TO_BOTTOM
55
if Object.TurnDirection == false
56
57
if Object.Oscillation < 0x380000
58
Object.Oscillation += 0x10000
59
else
60
Object.TurnDirection = true
61
end if
62
63
else
64
65
if Object.Oscillation > -0x380000
66
Object.Oscillation -= 0x10000
67
else
68
Object.TurnDirection = false
69
end if
70
71
end if
72
Object.YPos = Object.YOriginPos
73
Object.YPos += Object.Oscillation
74
break
75
76
case BUMPER_BOTTOM_TO_TOP
77
if Object.TurnDirection == false
78
79
if Object.Oscillation < 0x380000
80
Object.Oscillation += 0x10000
81
else
82
Object.TurnDirection = true
83
end if
84
85
else
86
87
if Object.Oscillation > -0x380000
88
Object.Oscillation -= 0x10000
89
else
90
Object.TurnDirection = false
91
end if
92
93
end if
94
Object.YPos = Object.YOriginPos
95
Object.YPos -= Object.Oscillation
96
break
97
98
case BUMPER_TOP_TO_BOTTOM_G
99
Object.YPos = Object.YOriginPos
100
Object.YPos += R3Setup.BumperOscillation
101
break
102
103
case BUMPER_BOTTOM_TO_TOP_G
104
Object.YPos = Object.YOriginPos
105
Object.YPos -= R3Setup.BumperOscillation
106
break
107
108
end switch
109
110
if Object.State > 0
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
122
end if
123
124
if Object.OutOfBounds == true
125
Object.BonusScore = 0
126
Object.Priority = PRIORITY_BOUNDS
127
end if
128
end sub
129
130
131
sub ObjectPlayerInteraction
132
if Player.Animation != ANI_HURT
133
PlayerObjectCollision(C_TOUCH, -14, -14, 14, 14)
134
if CheckResult == true
135
#platform: Use_Origins
136
if Player.Animation == ANI_CLIMBING
137
// Before bouncing him away, let's make sure Knuckles is in his normal air state, first
138
CallFunction(Player_CancelClimb)
139
end if
140
#endplatform
141
if Object.State == BUMPER_IDLE
142
PlayStageSfx(SFX_S_BUMPER, false)
143
144
#platform: Use_Haptics
145
HapticEffect(9, 0, 0, 0)
146
#endplatform
147
148
if Object.BonusScore < 5
149
CreateTempObject(TypeName[Object Score], 0, Object.XPos, Object.YPos)
150
Player.Score += 100
151
Object.BonusScore++
152
end if
153
end if
154
155
if Object.FrameTimer > 5
156
PlayStageSfx(SFX_S_BUMPER, false)
157
end if
158
159
Object.State = BUMPER_ACTIVE
160
161
Object.Priority = PRIORITY_ACTIVE
162
163
TempValue0 = Player.XPos
164
TempValue0 -= Object.XPos
165
166
TempValue1 = Player.YPos
167
TempValue1 -= Object.YPos
168
169
ATan2(TempValue2, TempValue0, TempValue1)
170
Cos256(TempValue0, TempValue2)
171
Sin256(TempValue1, TempValue2)
172
173
if Player.State == Player_State_Fly
174
TempValue0 <<= 10
175
TempValue1 <<= 10
176
else
177
TempValue0 *= 0x700
178
TempValue1 *= 0x700
179
Player.Timer = 0
180
end if
181
182
Player.XVelocity = TempValue0
183
Player.YVelocity = TempValue1
184
185
Player.Speed = Player.XVelocity
186
187
Player.Gravity = GRAVITY_AIR
188
end if
189
end if
190
end sub
191
192
193
sub ObjectDraw
194
DrawSprite(Object.Frame)
195
end sub
196
197
198
sub ObjectStartup
199
LoadSpriteSheet("R3/Objects.gif")
200
201
SpriteFrame(-16, -16, 32, 32, 67, 167) // #0 - Bumper
202
SpriteFrame(-12, -12, 24, 24, 206, 170) // #1 - Bumper Hit Frame 0
203
SpriteFrame(-20, -20, 40, 40, 215, 203) // #2 - Bumper Hit Frame 1
204
SpriteFrame(-12, -12, 24, 24, 206, 170) // #3 - Bumper Hit Frame 2
205
SpriteFrame(-20, -20, 40, 40, 215, 203) // #4 - Bumper Hit Frame 3
206
SpriteFrame(-20, -20, 40, 40, 215, 203) // #5 - Bumper Hit Frame 4
207
208
// Used to be below LoadSpriteSheet, moved here for consistency
209
ArrayPos0 = 32
210
while ArrayPos0 < 1056
211
if Object[ArrayPos0].Type == TypeName[Bumper]
212
Object[ArrayPos0].XOriginPos = Object[ArrayPos0].XPos
213
Object[ArrayPos0].YOriginPos = Object[ArrayPos0].YPos
214
end if
215
ArrayPos0++
216
loop
217
end sub
218
219
220
// ========================
221
// Editor Subs
222
// ========================
223
224
sub RSDKEdit
225
if Editor.ReturnVariable == true
226
switch Editor.VariableID
227
case EDIT_VAR_PROPVAL // Property Value
228
CheckResult = Object.PropertyValue
229
break
230
case 0 // pattern
231
CheckResult = Object.PropertyValue
232
break
233
end switch
234
else
235
switch Editor.VariableID
236
case EDIT_VAR_PROPVAL // Property Value
237
Object.PropertyValue = Editor.VariableValue
238
break
239
case 0 // pattern
240
Object.PropertyValue = Editor.VariableValue
241
break
242
end switch
243
end if
244
end sub
245
246
247
sub RSDKDraw
248
DrawSprite(0)
249
switch Object.PropertyValue
250
case 1
251
TempValue0 = Object.XPos
252
TempValue0 -= 0x300000
253
TempValue1 = Object.XPos
254
TempValue1 += 0x300000
255
TempValue2 = Object.YPos
256
TempValue2 -= 0x100000
257
258
if Editor.ShowGizmos == true
259
Editor.DrawingOverlay = true
260
DrawRectOutline(TempValue0, TempValue2, 0x60, 32, 255, 255, 0, 255)
261
DrawArrow(Object.XPos, Object.YPos, TempValue0, Object.YPos, 255, 255, 255, 0)
262
Editor.DrawingOverlay = false
263
end if
264
DrawArrow(Object.XPos, Object.YPos, TempValue1, Object.YPos, 255, 128, 0, 0)
265
break
266
case 2
267
TempValue0 = Object.XPos
268
TempValue0 += 0x300000
269
TempValue1 = Object.XPos
270
TempValue1 -= 0x300000
271
TempValue2 = Object.YPos
272
TempValue2 -= 0x100000
273
274
if Editor.ShowGizmos == true
275
Editor.DrawingOverlay = true
276
DrawRectOutline(TempValue0, TempValue2, -0x60, 32, 255, 255, 0, 255)
277
DrawArrow(Object.XPos, Object.YPos, TempValue0, Object.YPos, 255, 255, 255, 0)
278
Editor.DrawingOverlay = false
279
end if
280
281
DrawArrow(Object.XPos, Object.YPos, TempValue1, Object.YPos, 255, 128, 0, 0)
282
break
283
case 3
284
TempValue0 = Object.XPos
285
TempValue0 -= 0x100000
286
TempValue1 = Object.YPos
287
TempValue1 -= 0x380000
288
TempValue2 = Object.YPos
289
TempValue2 += 0x380000
290
291
if Editor.ShowGizmos == true
292
Editor.DrawingOverlay = true
293
DrawRectOutline(TempValue0, TempValue1, 32, 0x70, 255, 255, 0, 255)
294
DrawArrow(Object.XPos, Object.YPos, Object.XPos, TempValue1, 255, 255, 255, 0)
295
Editor.DrawingOverlay = false
296
end if
297
298
DrawArrow(Object.XPos, Object.YPos, Object.XPos, TempValue2, 255, 128, 0, 0)
299
break
300
case 5
301
TempValue0 = Object.XPos
302
TempValue0 -= 0x100000
303
TempValue1 = Object.YPos
304
TempValue1 -= 0x300000
305
TempValue2 = Object.YPos
306
TempValue2 += 0x300000
307
308
if Editor.ShowGizmos == true
309
Editor.DrawingOverlay = true
310
DrawRectOutline(TempValue0, TempValue1, 32, 0x60, 255, 255, 0, 255)
311
DrawArrow(Object.XPos, Object.YPos, Object.XPos, TempValue1, 255, 255, 255, 0)
312
Editor.DrawingOverlay = false
313
end if
314
315
DrawArrow(Object.XPos, Object.YPos, Object.XPos, TempValue2, 255, 128, 0, 0)
316
break
317
318
case 4
319
TempValue0 = Object.XPos
320
TempValue0 -= 0x100000
321
TempValue1 = Object.YPos
322
TempValue1 += 0x380000
323
TempValue2 = Object.YPos
324
TempValue2 -= 0x380000
325
326
if Editor.ShowGizmos == true
327
Editor.DrawingOverlay = true
328
DrawRectOutline(TempValue0, TempValue1, 32, -0x70, 255, 255, 0, 255)
329
DrawArrow(Object.XPos, Object.YPos, Object.XPos, TempValue1, 255, 255, 255, 0)
330
Editor.DrawingOverlay = false
331
end if
332
DrawArrow(Object.XPos, Object.YPos, Object.XPos, TempValue2, 255, 128, 0, 0)
333
break
334
case 6
335
TempValue0 = Object.XPos
336
TempValue0 -= 0x100000
337
TempValue1 = Object.YPos
338
TempValue1 += 0x300000
339
TempValue2 = Object.YPos
340
TempValue2 -= 0x300000
341
342
if Editor.ShowGizmos == true
343
Editor.DrawingOverlay = true
344
DrawRectOutline(TempValue0, TempValue1, 32, -0x60, 255, 255, 0, 255)
345
DrawArrow(Object.XPos, Object.YPos, Object.XPos, TempValue1, 255, 255, 255, 0)
346
Editor.DrawingOverlay = false
347
end if
348
DrawArrow(Object.XPos, Object.YPos, Object.XPos, TempValue2, 255, 128, 0, 0)
349
break
350
end switch
351
end sub
352
353
354
sub RSDKLoad
355
LoadSpriteSheet("R3/Objects.gif")
356
357
SpriteFrame(-16, -16, 32, 32, 67, 167) // #0 - Bumper
358
359
AddEditorVariable("Pattern")
360
SetActiveVariable("Pattern")
361
AddEnumVariable("Static", BUMPER_STATIC)
362
AddEnumVariable("Right to Left (Global Sync)", BUMPER_RIGHT_TO_LEFT_G)
363
AddEnumVariable("Left to Right (Global Sync)", BUMPER_LEFT_TO_RIGHT_G)
364
AddEnumVariable("Top to Bottom", BUMPER_TOP_TO_BOTTOM)
365
AddEnumVariable("Bottom to Top", BUMPER_BOTTOM_TO_TOP)
366
AddEnumVariable("Top to Bottom (Global Sync)", BUMPER_TOP_TO_BOTTOM_G)
367
AddEnumVariable("Bottom to Top (Global Sync)", BUMPER_BOTTOM_TO_TOP_G)
368
end sub
369
370