Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-CD-2011-Script-Decompilation
Path: blob/main/Scripts/R3/FlatBumper.txt
1319 views
1
//-----------------Sonic CD Flat Bumper 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
8
// HUD Alias
9
#alias Object[24].PropertyValue : HUD.CurrentTimePeriod
10
11
// States
12
#alias 0 : FLATBUMPER_MOVE_R_OR_U
13
#alias 1 : FLATBUMPER_MOVE_L_OR_D
14
15
// Time Periods
16
#alias 0 : TIME_PRESENT
17
#alias 1 : TIME_PAST
18
#alias 2 : TIME_GOOD_FUTURE
19
#alias 3 : TIME_BAD_FUTURE
20
21
// Gravity
22
#alias 1 : GRAVITY_AIR
23
24
// Collision
25
#alias 1 : PLAYER_COL_FLOOR
26
#alias 4 : PLAYER_COL_ROOF
27
28
// Stage SFX
29
#alias 1 : SFX_S_BUMPER2
30
31
// Property Values
32
#alias 0 : MOVE_HORIZONTALLY
33
#alias 1 : MOVE_VERTICALLY
34
35
36
sub ObjectMain
37
switch Object.State
38
case FLATBUMPER_MOVE_R_OR_U
39
if Object.Timer < 96
40
Object.Timer++
41
if Object.PropertyValue == MOVE_HORIZONTALLY
42
Object.XPos += 0x10000
43
else
44
Object.YPos += 0x10000
45
end if
46
else
47
Object.State = FLATBUMPER_MOVE_L_OR_D
48
end if
49
50
break
51
52
case FLATBUMPER_MOVE_L_OR_D
53
if Object.Timer > -96
54
Object.Timer--
55
if Object.PropertyValue == MOVE_HORIZONTALLY
56
Object.XPos -= 0x10000
57
else
58
Object.YPos -= 0x10000
59
end if
60
else
61
Object.State = FLATBUMPER_MOVE_R_OR_U
62
end if
63
64
break
65
66
end switch
67
end sub
68
69
70
sub ObjectPlayerInteraction
71
TempValue0 = false
72
PlayerObjectCollision(C_TOUCH, -34, -16, -28, 16) // Left
73
TempValue1 = CheckResult
74
PlayerObjectCollision(C_TOUCH, 28, -16, 34, 16) // Right
75
TempValue2 = CheckResult
76
PlayerObjectCollision(C_BOX, -32, -14, 32, 14) // Check if you touched the bumper
77
switch CheckResult
78
case PLAYER_COL_FLOOR
79
if Player.State == Player_State_Fly
80
Player.YVelocity = -0x40000
81
else
82
Player.YVelocity = -0x70000
83
Player.Timer = 0
84
end if
85
Player.Gravity = GRAVITY_AIR
86
TempValue0 = true
87
break
88
89
case PLAYER_COL_ROOF
90
if Player.State == Player_State_Fly
91
Player.YVelocity = 0x40000
92
else
93
Player.YVelocity = 0x70000
94
Player.Timer = 0
95
end if
96
Player.Timer = 0
97
Player.Gravity = GRAVITY_AIR
98
TempValue0 = true
99
break
100
101
end switch
102
103
if TempValue1 == true // Check if you collided with the left side of the bumper
104
Player.Speed = -0x70000
105
Player.XVelocity = -0x70000
106
TempValue0 = true
107
end if
108
109
if TempValue2 == true // Check if you collided with the right side of the bumper
110
Player.Speed = 0x70000
111
Player.XVelocity = 0x70000
112
TempValue0 = true
113
end if
114
115
PlayerObjectCollision(C_TOUCH, -16, -14, 16, 0) // Check if you collided with the center from the top
116
if CheckResult == true
117
if Player.State == Player_State_Fly
118
Player.YVelocity = -0x40000
119
else
120
Player.YVelocity = -0x70000
121
Player.Timer = 0
122
end if
123
Player.Gravity = GRAVITY_AIR
124
TempValue0 = true
125
end if
126
127
PlayerObjectCollision(C_TOUCH, -16, 0, 16, 14) // Check if you collided with the center from the bottom
128
if CheckResult == true
129
if Player.State == Player_State_Fly
130
Player.YVelocity = 0x40000
131
else
132
Player.YVelocity = 0x70000
133
Player.Timer = 0
134
end if
135
Player.Gravity = GRAVITY_AIR
136
TempValue0 = true
137
end if
138
139
if TempValue0 == true
140
PlayStageSfx(SFX_S_BUMPER2, false)
141
142
#platform: Use_Haptics
143
HapticEffect(10, 0, 0, 0)
144
#endplatform
145
146
end if
147
end sub
148
149
150
sub ObjectDraw
151
DrawSprite(0)
152
end sub
153
154
155
sub ObjectStartup
156
switch HUD.CurrentTimePeriod
157
case TIME_PRESENT
158
case TIME_PAST
159
LoadSpriteSheet("R3/Objects.gif")
160
161
SpriteFrame(-32, -16, 64, 32, 1, 75)
162
break
163
164
case TIME_GOOD_FUTURE
165
LoadSpriteSheet("R3/Objects3.gif")
166
167
SpriteFrame(-32, -16, 64, 32, 132, 67)
168
break
169
170
case TIME_BAD_FUTURE
171
LoadSpriteSheet("R3/Objects3.gif")
172
173
SpriteFrame(-32, -16, 64, 32, 132, 100)
174
break
175
end switch
176
end sub
177
178
179
// ========================
180
// Editor Subs
181
// ========================
182
183
sub RSDKEdit
184
if Editor.ReturnVariable == true
185
switch Editor.VariableID
186
case EDIT_VAR_PROPVAL // Property Value
187
case 0 // Type
188
CheckResult = Object.PropertyValue
189
CheckResult &= 1
190
break
191
end switch
192
else
193
switch Editor.VariableID
194
case EDIT_VAR_PROPVAL // Property Value
195
case 0 // Type
196
Object.PropertyValue = Editor.VariableValue
197
Object.PropertyValue &= 1
198
break
199
end switch
200
end if
201
end sub
202
203
204
sub RSDKDraw
205
DrawSprite(0)
206
if object.PropertyValue == MOVE_HORIZONTALLY
207
TempValue0 = Object.XPos
208
TempValue0 += 0x600000
209
210
TempValue1 = Object.XPos
211
TempValue1 -= 0x600000
212
213
TempValue2 = Object.YPos
214
TempValue2 -= 0x100000
215
216
if Editor.ShowGizmos == true
217
Editor.DrawingOverlay = true
218
DrawRectOutline(TempValue1, TempValue2, 0xC0, 32, 255, 255, 0, 255)
219
DrawArrow(Object.XPos, Object.YPos, TempValue1, Object.YPos, 255, 255, 255, 0)
220
Editor.DrawingOverlay = false
221
end if
222
223
DrawArrow(Object.XPos, Object.YPos, TempValue0, Object.YPos, 255, 128, 0, 0)
224
else
225
TempValue0 = Object.YPos
226
TempValue0 += 0x600000
227
228
TempValue1 = Object.YPos
229
TempValue1 -= 0x600000
230
231
TempValue2 = Object.XPos
232
TempValue2 -= 0x100000
233
234
if Editor.ShowGizmos == true
235
Editor.DrawingOverlay = true
236
DrawRectOutline(TempValue2, TempValue1, 0x32, 0xC0, 255, 255, 0, 255)
237
DrawArrow(Object.XPos, Object.YPos, Object.XPos, TempValue0, 255, 255, 255, 0)
238
Editor.DrawingOverlay = false
239
end if
240
241
DrawArrow(Object.XPos, Object.YPos, Object.XPos, TempValue1, 255, 128, 0, 0)
242
end if
243
end sub
244
245
246
sub RSDKLoad
247
CallFunction(EditorHelpers_FindTimePeriod)
248
switch CheckResult
249
case TIME_PRESENT
250
case TIME_PAST
251
LoadSpriteSheet("R3/Objects.gif")
252
SpriteFrame(-32, -16, 64, 32, 1, 75)
253
break
254
case TIME_GOOD_FUTURE
255
LoadSpriteSheet("R3/Objects3.gif")
256
SpriteFrame(-32, -16, 64, 32, 132, 67)
257
break
258
case TIME_BAD_FUTURE
259
LoadSpriteSheet("R3/Objects3.gif")
260
SpriteFrame(-32, -16, 64, 32, 132, 100)
261
break
262
end switch
263
264
AddEditorVariable("Type")
265
SetActiveVariable("Type")
266
AddEnumVariable("Horizontal", MOVE_HORIZONTALLY)
267
AddEnumVariable("Vertical", MOVE_VERTICALLY)
268
end sub
269
270