Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-CD-2011-Script-Decompilation
Path: blob/main/Scripts/R3/R3Setup.txt
1319 views
1
//------------------Sonic CD R3 Setup Script------------------//
2
//--------Scripted by Christian Whitehead 'The Taxman'--------//
3
//-------Unpacked By Rubberduckycooly's Script Unpacker-------//
4
5
// Aliases
6
#alias Object.Value0 : Object.DeformTimer
7
#alias Object.Value2 : Object.BumperOscillation
8
#alias Object.Value3 : Object.TurnDirection
9
10
// HUD Alias
11
#alias Object[24].PropertyValue : HUD.CurrentTimePeriod
12
13
// Time Periods
14
#alias 1 : TIME_PAST
15
16
// Gravity
17
#alias 1 : GRAVITY_AIR
18
19
// Stage SFX
20
#alias 1 : SFX_S_BUMPER2
21
#alias 6 : SFX_S_MINIBUMPER
22
23
// Priority
24
#alias 1 : PRIORITY_ACTIVE
25
26
// Tile Info
27
#alias 1 : TILEINFO_DIRECTION
28
#alias 6 : TILEINFO_ANGLEA
29
30
// Deformation Layer
31
#alias 1 : DEFORM_FG_WATER
32
#alias 2 : DEFORM_BG
33
34
35
sub ObjectMain
36
if Object.TurnDirection == false
37
if Object.BumperOscillation < 0x300000
38
Object.BumperOscillation += 0x10000
39
else
40
Object.TurnDirection = true
41
end if
42
else
43
if Object.BumperOscillation > -0x300000
44
Object.BumperOscillation -= 0x10000
45
else
46
Object.TurnDirection = false
47
end if
48
end if
49
50
if HUD.CurrentTimePeriod != TIME_PAST
51
RotatingDrum_Timer++
52
RotatingDrum_Timer %= 20
53
end if
54
end sub
55
56
57
sub ObjectPlayerInteraction
58
TempValue2 = Player.XPos
59
TempValue2 >>= 16
60
61
TempValue4 = TempValue2
62
TempValue2 -= 8
63
TempValue4 += 8
64
65
TempValue3 = Player.YPos
66
TempValue3 >>= 16
67
68
if Player.YVelocity >= 0
69
TempValue3 += Player.CollisionBottom
70
TempValue3 -= 2
71
else
72
TempValue3 += Player.CollisionTop
73
TempValue3 += 2
74
end if
75
76
TempValue5 = TempValue3
77
TempValue7 = 0
78
Get16x16TileInfo(TempValue0, TempValue2, TempValue3, TILEINFO_ANGLEA)
79
switch TempValue0
80
case 1
81
TempValue7 = 1
82
break
83
84
case 3
85
TempValue7 = 3
86
Get16x16TileInfo(TempValue6, TempValue2, TempValue3, TILEINFO_DIRECTION)
87
break
88
89
case 5
90
TempValue7 = 2
91
break
92
93
end switch
94
95
// Note:
96
// So, funny story about this code segment here below, it has a bias.
97
// When you encounter the tiles using these values, like the ones in CCZ2A at x-3376 and y-1080, the right most two tiles will send the player right.
98
// While when you bounce on the left ones, the player will stay on top until they gets bounced by the tile that curves over to the left.
99
100
101
Get16x16TileInfo(TempValue0, TempValue4, TempValue5, TILEINFO_ANGLEA)
102
switch TempValue0
103
case 1
104
TempValue7 = 1
105
break
106
107
case 3
108
#platform: Use_Origins
109
if Player.Animation == ANI_CLIMBING
110
// Before bouncing him away, let's make sure Knuckles is in his normal air state, first
111
CallFunction(Player_CancelClimb)
112
end if
113
#endplatform
114
TempValue7 = 3
115
Get16x16TileInfo(TempValue6, TempValue4, TempValue5, TILEINFO_DIRECTION)
116
break
117
118
case 5
119
TempValue7 = 2
120
break
121
122
end switch
123
124
switch TempValue7
125
case 1
126
if Player.YVelocity >= 0
127
Player.Gravity = GRAVITY_AIR
128
PlayStageSfx(SFX_S_BUMPER2, false)
129
130
131
#platform: Use_Haptics
132
HapticEffect(11, 0, 0, 0)
133
#endplatform
134
135
if Player.State == Player_State_Fly
136
Player.YVelocity = -0x40000
137
else
138
Player.YVelocity = -0x70000
139
end if
140
141
if Player.State == Player_State_Hurt
142
143
#platform: Use_Origins
144
Player.State = Player_State_Air_NoDropDash
145
#endplatform
146
147
#platform: Use_Standalone
148
Player.State = Player_State_Air
149
#endplatform
150
Player.Timer = 0
151
end if
152
else
153
if Player.Gravity == GRAVITY_AIR
154
Player.YVelocity = 0x40000
155
PlayStageSfx(SFX_S_BUMPER2, false)
156
end if
157
end if
158
break
159
160
case 2
161
if Player.Gravity == GRAVITY_AIR
162
PlayStageSfx(SFX_S_MINIBUMPER, false)
163
164
#platform: Use_Haptics
165
HapticEffect(11, 0, 0, 0)
166
#endplatform
167
168
if Player.YVelocity >= 0
169
Player.YVelocity = -0x40000
170
else
171
Player.YVelocity = 0x40000
172
end if
173
end if
174
break
175
176
case 3
177
if Player.Gravity == GRAVITY_AIR
178
PlayStageSfx(SFX_S_BUMPER2, false)
179
180
#platform: Use_Haptics
181
HapticEffect(11, 0, 0, 0)
182
#endplatform
183
184
if Player.YVelocity >= 0
185
if Player.State == Player_State_Fly
186
Player.YVelocity = -0x40000
187
else
188
Player.YVelocity = -0x70000
189
end if
190
else
191
Player.YVelocity = 0x40000
192
end if
193
194
if TempValue6 == 0
195
if Player.XVelocity > 0
196
FlipSign(Player.XVelocity)
197
Player.XVelocity *= 5
198
Player.XVelocity >>= 2
199
if Player.XVelocity > -0x20000
200
Player.XVelocity = -0x20000
201
end if
202
else
203
if Player.XVelocity > -0x20000
204
Player.XVelocity = -0x20000
205
end if
206
end if
207
else
208
if Player.XVelocity < 0
209
FlipSign(Player.XVelocity)
210
Player.XVelocity *= 5
211
Player.XVelocity >>= 2
212
if Player.XVelocity < 0x20000
213
Player.XVelocity = 0x20000
214
end if
215
else
216
if Player.XVelocity < 0x20000
217
Player.XVelocity = 0x20000
218
end if
219
end if
220
end if
221
Player.Speed = Player.XVelocity
222
end if
223
break
224
end switch
225
226
TempValue3 = Player.YPos
227
TempValue3 >>= 16
228
229
TempValue5 = TempValue3
230
TempValue3 -= 6
231
TempValue5 += 6
232
233
TempValue2 = Player.XPos
234
TempValue2 >>= 16
235
236
if Player.XVelocity > 0
237
TempValue2 += 8
238
else
239
TempValue2 -= 8
240
end if
241
242
TempValue4 = TempValue2
243
TempValue7 = 0
244
Get16x16TileInfo(TempValue0, TempValue2, TempValue3, TILEINFO_ANGLEA)
245
switch TempValue0
246
case 3
247
TempValue7 = 1
248
break
249
250
case 5
251
TempValue7 = 2
252
break
253
254
case 7
255
TempValue7 = 1
256
break
257
258
end switch
259
260
Get16x16TileInfo(TempValue0, TempValue4, TempValue5, TILEINFO_ANGLEA)
261
switch TempValue0
262
case 3
263
TempValue7 = 1
264
break
265
266
case 5
267
TempValue7 = 2
268
break
269
270
case 7
271
TempValue7 = 1
272
break
273
274
end switch
275
276
switch TempValue7
277
case 1
278
#platform: Use_Origins
279
if Player.Animation == ANI_CLIMBING
280
// Before bouncing him away, let's make sure Knuckles is in his normal air state, first
281
CallFunction(Player_CancelClimb)
282
end if
283
#endplatform
284
if Player.XVelocity > 0
285
Player.XVelocity = -0x50000
286
else
287
Player.XVelocity = 0x50000
288
end if
289
Player.Speed = Player.XVelocity
290
#platform: Use_Origins
291
Player.Timer = 0
292
#endplatform
293
PlayStageSfx(SFX_S_BUMPER2, false)
294
break
295
296
case 2
297
if Player.XVelocity > 0
298
Player.XVelocity = -0x40000
299
else
300
Player.XVelocity = 0x40000
301
end if
302
Player.Speed = Player.XVelocity
303
PlayStageSfx(SFX_S_MINIBUMPER, false)
304
305
#platform: Use_Haptics
306
HapticEffect(11, 0, 0, 0)
307
#endplatform
308
break
309
310
end switch
311
end sub
312
313
314
sub ObjectDraw
315
Object.DeformTimer++
316
if Object.DeformTimer > 3
317
TileLayer[0].DeformationOffsetW++
318
TileLayer[1].DeformationOffset++
319
Object.DeformTimer = 0
320
end if
321
end sub
322
323
324
sub ObjectStartup
325
Object[29].Type = TypeName[R3 Setup]
326
Object[29].Priority = PRIORITY_ACTIVE
327
Object[29].DrawOrder = 0
328
329
SetLayerDeformation(DEFORM_BG, 128, 6, 0, 0, 0)
330
SetLayerDeformation(DEFORM_FG_WATER, 64, 4, 0, 0, 0)
331
332
Stage.WaterLevel = 1472
333
334
if HUD.CurrentTimePeriod == TIME_PAST
335
RotatingDrum_Timer = 1
336
else
337
RotatingDrum_Timer = 0
338
end if
339
end sub
340
341
342
// ========================
343
// Editor Subs
344
// ========================
345
346
sub RSDKDraw
347
DrawSprite(0)
348
end sub
349
350
351
sub RSDKLoad
352
LoadSpriteSheet("Global/Display.gif")
353
SpriteFrame(-16, -16, 32, 32, 1, 143) // #0 - "Script" Icon
354
355
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
356
end sub
357
358