Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-CD-2011-Script-Decompilation
Path: blob/main/Scripts/R8/Scarab.txt
1319 views
1
//-------------------Sonic CD Scarab 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.XVelocity
8
#alias Object.Value2 : Object.XOriginPos
9
#alias Object.Value3 : Object.YOriginPos
10
#alias Object.Value4 : Object.LaunchDelay
11
#alias Object.Value5 : Object.LaunchSpeed
12
#alias Object.Value6 : Object.OnObject
13
#alias Object.Value7 : Object.CaryingMonitor
14
15
// States
16
#alias 0 : SCARAB_MOVE
17
#alias 1 : SCARAB_STOP
18
19
// Property Values
20
#alias 0 : DIR_FACING_RIGHT
21
#alias 1 : DIR_FACING_LEFT
22
#alias 2 : DIR_FACING_RIGHT_S
23
#alias 3 : DIR_FACING_LEFT_S
24
#alias 4 : DIR_FACING_RIGHT_W_OBJ
25
26
// Priority
27
#alias 0 : PRIORITY_BOUNDS
28
#alias 1 : PRIORITY_ACTIVE
29
30
// Warp Destination
31
#alias 0 : WARPDEST_NONE
32
33
// Collision Sides
34
#alias 0 : CSIDE_FLOOR
35
36
37
sub ObjectMain
38
switch Object.State
39
case SCARAB_MOVE
40
Object.Priority = PRIORITY_ACTIVE
41
42
if Object.Timer < 60
43
Object.Timer++
44
Object.XPos += Object.XVelocity
45
else
46
Object.Timer = 0
47
Object.State = SCARAB_STOP
48
end if
49
50
ObjectTileGrip(CSIDE_FLOOR, 0, 12, 0)
51
if Object.XVelocity > 0
52
TempValue0 = Object.XPos
53
TempValue0 -= Object.XOriginPos
54
if TempValue0 > 0x400000
55
FlipSign(Object.XVelocity)
56
end if
57
else
58
TempValue0 = Object.XOriginPos
59
TempValue0 -= Object.XPos
60
if TempValue0 > 0x400000
61
FlipSign(Object.XVelocity)
62
end if
63
end if
64
65
Object.AnimationTimer += Object.AnimationSpeed
66
Object.AnimationTimer %= 40
67
break
68
69
case SCARAB_STOP
70
if Object.Timer < 30
71
Object.Timer++
72
else
73
Object.Timer = 0
74
Object.State = SCARAB_MOVE
75
end if
76
break
77
end switch
78
79
if Object.LaunchDelay > 0
80
if Player.State == Player_State_Death
81
Object.LaunchDelay = 0
82
else
83
if Object.Direction == FACING_RIGHT
84
Player.XPos = Object.XPos
85
Player.XPos -= 0x180000
86
Player.YPos = Object.YPos
87
Player.YPos -= 0x30000
88
else
89
Player.XPos = Object.XPos
90
Player.XPos += 0x180000
91
Player.YPos = Object.YPos
92
Player.YPos -= 0x30000
93
end if
94
Object.LaunchDelay--
95
if Object.LaunchDelay == 0
96
Player.State = Player_State_Roll
97
Player.Speed = Object.LaunchSpeed
98
Player.XVelocity = Player.Speed
99
end if
100
end if
101
end if
102
103
if Object.CaryingMonitor == true
104
if Object[+1].Type == TypeName[Monitor]
105
Object[+1].XPos = Object.XPos
106
Object[+1].XPos -= 0x180000
107
108
Object[+1].YPos = Object.YPos
109
Object[+1].YPos -= 0x40000
110
else
111
Object[+1].Type = TypeName[Blank Object]
112
Object.CaryingMonitor = false
113
end if
114
end if
115
116
CallFunction(StageSetup_CheckGoodFuture)
117
if Object.OutOfBounds == true
118
TempValue0 = Object.XPos
119
TempValue1 = Object.YPos
120
121
Object.XPos = Object.XOriginPos
122
Object.YPos = Object.YOriginPos
123
124
if Object.OutOfBounds == true // If starting position was out of bounds too, then we can safely go back
125
Object.Priority = PRIORITY_BOUNDS
126
Object.State = SCARAB_MOVE
127
Object.Timer = 0
128
Object.AnimationTimer = 0
129
130
if Object.XVelocity < 0
131
FlipSign(Object.XVelocity)
132
end if
133
else
134
Object.XPos = TempValue0
135
Object.YPos = TempValue1
136
end if
137
end if
138
end sub
139
140
141
sub ObjectPlayerInteraction
142
if Object.State < 2 // This is always true
143
if Object.LaunchDelay == 0
144
if Object.Direction == FACING_RIGHT
145
PlayerObjectCollision(C_TOUCH, -32, -12, -12, 12)
146
if CheckResult == true
147
if Object.OnObject == false
148
Object.LaunchDelay = 120
149
150
Player.Animation = ANI_JUMPING
151
Player.State = Player_State_Static
152
153
Player.Speed = 0
154
Player.XVelocity = 0
155
Player.YVelocity = 0
156
157
Player.XPos = Object.XPos
158
Player.XPos -= 0x180000
159
160
Player.YPos = Object.YPos
161
Player.YPos -= 0x30000
162
163
Player.Direction = FACING_RIGHT
164
165
if Warp.Destination > WARPDEST_NONE
166
if Warp.Timer > 99
167
if Warp.Timer < 220 // They forgot to fix the warp timer here
168
Warp.Destination = WARPDEST_NONE
169
end if
170
end if
171
Warp.Timer = 0
172
end if
173
174
Object.OnObject = true
175
end if
176
else
177
Object.OnObject = false
178
PlayerObjectCollision(C_TOUCH, -12, -12, 20, 12)
179
if CheckResult == true
180
CallFunction(Player_BadnikBreak)
181
end if
182
end if
183
else
184
PlayerObjectCollision(C_TOUCH, 12, -12, 32, 12)
185
if CheckResult == true
186
if Object.OnObject == false
187
Object.LaunchDelay = 120
188
189
Player.Animation = ANI_JUMPING
190
Player.State = Player_State_Static
191
192
Player.Speed = 0
193
Player.XVelocity = 0
194
Player.YVelocity = 0
195
196
Player.XPos = Object.XPos
197
Player.XPos += 0x180000
198
199
Player.YPos = Object.YPos
200
Player.YPos -= 0x30000
201
202
Player.Direction = FACING_LEFT
203
204
if Warp.Destination > WARPDEST_NONE
205
if Warp.Timer > 99
206
if Warp.Timer < 220 // They forgot to fix the warp timer here
207
Warp.Destination = WARPDEST_NONE
208
end if
209
end if
210
Warp.Timer = 0
211
end if
212
213
Object.OnObject = true
214
end if
215
else
216
Object.OnObject = false
217
#platform: Use_Standalone
218
PlayerObjectCollision(C_TOUCH, -20, -12, 12, 12)
219
#endplatform
220
#platform: Use_Origins
221
PlayerObjectCollision(C_ENEMY, -20, -12, 12, 12)
222
#endplatform
223
if CheckResult == true
224
CallFunction(Player_BadnikBreak)
225
end if
226
end if
227
end if
228
end if
229
end if
230
end sub
231
232
233
sub ObjectDraw
234
if Object.State < 2 // This is always true
235
if Object.DrawOrder == 3
236
Object.Frame = Object.AnimationTimer
237
Object.Frame /= 20
238
Object.Frame += Object[ArrayPos0].PropertyValue // where's this ArrayPos0 even coming from..?
239
DrawSpriteFX(Object.Frame, FX_FLIP, Object.XPos, Object.YPos)
240
Object.Frame += 2
241
SetDrawListEntityRef(Object.EntityNo, 4, Screen.DrawListSize[4])
242
Screen.DrawListSize[4]++
243
Object.DrawOrder = 4
244
else
245
DrawSpriteFX(Object.Frame, FX_FLIP, Object.XPos, Object.YPos)
246
Object.DrawOrder = 3
247
end if
248
end if
249
end sub
250
251
252
sub ObjectStartup
253
LoadSpriteSheet("R8/Objects.gif")
254
255
SpriteFrame(-24, -12, 24, 24, 107, 206) // #0 - Scarab Arms frame 0
256
SpriteFrame(-32, -12, 32, 24, 132, 206) // #1 - Scarab Arms frame 1
257
258
SpriteFrame(-32, -12, 56, 24, 165, 206) // #2 - Scarab frame 0
259
SpriteFrame(-32, -12, 56, 24, 165, 231) // #3 - Scarab frame 1
260
261
SpriteFrame(-24, -12, 24, 24, 107, 206) // #4 - Scarab Arms frame 0
262
SpriteFrame(-32, -12, 32, 16, 67, 240) // #5 - Scarab Arms frame 1
263
264
SpriteFrame(-32, -12, 56, 24, 165, 206) // #6 - Scarab frame 0
265
SpriteFrame(-40, -12, 64, 24, 100, 231) // #7 - Scarab frame 1
266
267
ArrayPos0 = 32
268
while ArrayPos0 < 1056
269
if Object[ArrayPos0].Type == TypeName[Scarab]
270
Object[ArrayPos0].XOriginPos = Object[ArrayPos0].XPos
271
Object[ArrayPos0].YOriginPos = Object[ArrayPos0].YPos
272
273
switch Object[ArrayPos0].PropertyValue
274
case DIR_FACING_RIGHT
275
Object[ArrayPos0].PropertyValue = DIR_FACING_RIGHT // Set the animation to use un-streched arms
276
Object[ArrayPos0].XVelocity = 0x6000
277
Object[ArrayPos0].AnimationSpeed = 2
278
Object[ArrayPos0].Direction = FACING_RIGHT
279
Object[ArrayPos0].LaunchSpeed = -0xA0000
280
break
281
282
case DIR_FACING_LEFT
283
Object[ArrayPos0].PropertyValue = DIR_FACING_RIGHT // Set the animation to use un-streched arms
284
Object[ArrayPos0].XVelocity = 0x6000
285
Object[ArrayPos0].AnimationSpeed = 2
286
Object[ArrayPos0].Direction = FACING_LEFT
287
Object[ArrayPos0].LaunchSpeed = 0xA0000
288
break
289
290
case DIR_FACING_RIGHT_S
291
Object[ArrayPos0].PropertyValue = DIR_FACING_RIGHT_W_OBJ // Set the animation to use streched arms
292
Object[ArrayPos0].XVelocity = 0x3000
293
Object[ArrayPos0].AnimationSpeed = 1
294
Object[ArrayPos0].Direction = FACING_RIGHT
295
Object[ArrayPos0].LaunchSpeed = -0x50000
296
break
297
298
case DIR_FACING_LEFT_S
299
Object[ArrayPos0].PropertyValue = DIR_FACING_RIGHT_W_OBJ // Set the animation to use streched arms
300
Object[ArrayPos0].XVelocity = 0x3000
301
Object[ArrayPos0].AnimationSpeed = 1
302
Object[ArrayPos0].Direction = FACING_LEFT
303
Object[ArrayPos0].LaunchSpeed = 0x50000
304
break
305
306
case DIR_FACING_RIGHT_W_OBJ
307
Object[ArrayPos0].PropertyValue = DIR_FACING_RIGHT // Set the animation to use un-streched arms
308
Object[ArrayPos0].XVelocity = 0x6000
309
Object[ArrayPos0].AnimationSpeed = 2
310
Object[ArrayPos0].Direction = FACING_RIGHT
311
Object[ArrayPos0].LaunchSpeed = -0xA0000
312
Object[ArrayPos0].CaryingMonitor = true
313
break
314
end switch
315
end if
316
ArrayPos0++
317
loop
318
end sub
319
320
321
// ========================
322
// Editor Subs
323
// ========================
324
325
sub RSDKEdit
326
if Editor.ReturnVariable == true
327
switch Editor.VariableID
328
case EDIT_VAR_PROPVAL // Property Value
329
CheckResult = Object.PropertyValue
330
CheckResult %= 5
331
break
332
case 0 // type
333
CheckResult = Object.PropertyValue
334
CheckResult %= 5
335
break
336
end switch
337
else
338
switch Editor.VariableID
339
case EDIT_VAR_PROPVAL // Property Value
340
Object.PropertyValue = Editor.VariableValue
341
Object.PropertyValue %= 5
342
break
343
case 0 // type
344
Object.PropertyValue = Editor.VariableValue
345
Object.PropertyValue %= 5
346
break
347
end switch
348
end if
349
end sub
350
351
sub RSDKDraw
352
Object.Direction = FACING_RIGHT
353
switch Object.PropertyValue
354
case DIR_FACING_LEFT
355
Object.Direction = FACING_LEFT
356
case DIR_FACING_RIGHT
357
DrawSpriteFX(0, FX_FLIP, Object.XPos, Object.YPos)
358
DrawSpriteFX(2, FX_FLIP, Object.XPos, Object.YPos)
359
break
360
case DIR_FACING_LEFT_S
361
Object.Direction = FACING_LEFT
362
case DIR_FACING_RIGHT_S
363
DrawSpriteFX(5, FX_FLIP, Object.XPos, Object.YPos)
364
DrawSpriteFX(6, FX_FLIP, Object.XPos, Object.YPos)
365
break
366
case DIR_FACING_RIGHT_W_OBJ
367
DrawSpriteFX(5, FX_FLIP, Object.XPos, Object.YPos)
368
DrawSpriteFX(6, FX_FLIP, Object.XPos, Object.YPos)
369
if Editor.ShowGizmos == true
370
Editor.DrawingOverlay = true
371
if Object[+1].Type == TypeName[Monitor]
372
DrawLine(Object.XPos, Object.YPos, Object[+1].XPos, Object[+1].YPos, 0, 0, 255)
373
end if
374
Editor.DrawingOverlay = false
375
end if
376
break
377
end switch
378
end sub
379
380
381
sub RSDKLoad
382
LoadSpriteSheet("R8/Objects.gif")
383
384
SpriteFrame(-24, -12, 24, 24, 107, 206) // #0 - Scarab Arms frame 0
385
SpriteFrame(-32, -12, 32, 24, 132, 206) // #1 - Scarab Arms frame 1
386
387
SpriteFrame(-32, -12, 56, 24, 165, 206) // #2 - Scarab frame 0
388
SpriteFrame(-32, -12, 56, 24, 165, 231) // #3 - Scarab frame 1
389
390
SpriteFrame(-24, -12, 24, 24, 107, 206) // #4 - Scarab Arms frame 0
391
SpriteFrame(-32, -12, 32, 16, 67, 240) // #5 - Scarab Arms frame 1
392
393
SpriteFrame(-32, -12, 56, 24, 165, 206) // #6 - Scarab frame 0
394
SpriteFrame(-40, -12, 64, 24, 100, 231) // #7 - Scarab frame 1
395
396
AddEditorVariable("type")
397
SetActiveVariable("type")
398
AddEnumVariable("Facing Right", DIR_FACING_RIGHT)
399
AddEnumVariable("Facing Left", DIR_FACING_LEFT)
400
AddEnumVariable("Facing Right (Streched arms)", DIR_FACING_RIGHT_S)
401
AddEnumVariable("Facing Left (Streched arms)", DIR_FACING_LEFT_S)
402
AddEnumVariable("Facing Right (Carrying Object)", DIR_FACING_RIGHT_W_OBJ)
403
end sub
404
405