Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-CD-2011-Script-Decompilation
Path: blob/main/Scripts/R5/Sasuri.txt
1319 views
1
//-------------------Sonic CD Sasuri Script-------------------//
2
//--------Scripted by Christian Whitehead 'The Taxman'--------//
3
//-------Unpacked By Rubberduckycooly's Script Unpacker-------//
4
5
// Aliases
6
#alias Object.Value0 : Object.MoveTimer
7
#alias Object.Value1 : Object.CannonTimer
8
9
#alias Object.PropertyValue : Object.Quality
10
11
// Sasuri Bullet (SBullet) Aliases
12
#alias Object.Value1 : Object.XVelocity
13
14
// States
15
#alias 0 : SASURI_FINDGROUND
16
#alias 1 : SASURI_CRAWLLEFT
17
#alias 2 : SASURI_CRAWLRIGHT
18
#alias 3 : SASURI_SPOTPLAYER
19
#alias 4 : SASURI_SHOOT
20
#alias 5 : SASURI_RETRACTCANNON
21
22
// Badnik Quality / Property Values
23
#alias 0 : GOOD_QUALITY
24
#alias 1 : BAD_QUALITY
25
26
// Collision Sides
27
#alias 0 : CSIDE_FLOOR
28
29
// Stage SFX
30
#alias 2 : SFX_S_SHOT
31
32
sub ObjectMain
33
34
// Animate the Sasuri
35
Object.Frame++
36
Object.Frame %= 60
37
38
if Object.Quality == GOOD_QUALITY
39
switch Object.State
40
case SASURI_FINDGROUND
41
// See if there's any ground for the Sasuri to stand on
42
// Note - is this an error? Should it be ObjectTileGrip instead? That's what all the other stuff around here uses...
43
ObjectTileCollision(CSIDE_FLOOR, 0, 13, 0)
44
45
if CheckResult == true
46
// If there is, then start crawling
47
Object.State = SASURI_CRAWLLEFT
48
else
49
// If there isn't, then move a pixel down and try again next frame
50
Object.YPos += 0x10000
51
end if
52
break
53
54
case SASURI_CRAWLLEFT
55
56
// Move the Sasuri left by one pixel
57
Object.XPos -= 0x10000
58
59
// Increment its movement timer, and see if it's time to turn around now
60
Object.MoveTimer--
61
if Object.MoveTimer <= -80
62
Object.State = SASURI_CRAWLRIGHT
63
Object.Direction = FACING_LEFT
64
end if
65
66
// Also, see if the Sasuri is still on ground
67
// -> If it isn't, then turn around
68
ObjectTileGrip(CSIDE_FLOOR, 0, 13, 0)
69
if CheckResult == false
70
Object.State = SASURI_CRAWLRIGHT
71
Object.MoveTimer = 0
72
Object.Direction = FACING_LEFT
73
end if
74
break
75
76
case SASURI_CRAWLRIGHT
77
78
// Move the Sasuri one pixel right
79
Object.XPos += 0x10000
80
81
// As with above, do timer stuff and see if the Sasuri should turn around now
82
Object.MoveTimer++
83
if Object.MoveTimer >= 80
84
Object.State = SASURI_CRAWLLEFT
85
Object.Direction = FACING_RIGHT
86
end if
87
88
// Also like above, see if the Sasuri's still on ground and if it isn't, then turn around
89
ObjectTileGrip(CSIDE_FLOOR, 0, 13, 0)
90
if CheckResult == false
91
Object.State = SASURI_CRAWLLEFT
92
Object.MoveTimer = 0
93
Object.Direction = FACING_RIGHT
94
end if
95
break
96
97
case SASURI_SPOTPLAYER
98
// This state's set in ObjectPlayerInteraction if the Player is within shooting range
99
100
if Object.CannonTimer < 30
101
Object.CannonTimer++
102
else
103
Object.State = SASURI_SHOOT
104
Object.CannonTimer = 0
105
end if
106
break
107
108
case SASURI_SHOOT
109
if Object.CannonTimer < 40
110
if Object.CannonTimer == 10
111
PlayStageSfx(SFX_S_SHOT, false)
112
113
// Create the Bullet that the Sasuri shot
114
CreateTempObject(TypeName[Sasuri Bullet], 0, Object.XPos, Object.YPos)
115
116
// Move the Bullet 24 pixels up, to match where the Sasuri's cannon is drawn
117
Object[TempObjectPos].YPos -= 0x180000
118
119
// Move it 24 pixels in the Sasuri's direction, as well as giving it a velocity of 3px per frame in that very same direction too
120
if Object.Direction == FACING_RIGHT
121
Object[TempObjectPos].XPos -= 0x70000
122
Object[TempObjectPos].XVelocity = -0x30000
123
else
124
Object[TempObjectPos].XPos += 0x70000
125
Object[TempObjectPos].XVelocity = 0x30000
126
end if
127
128
// Move the Sasuri up a Draw Order in order to make it drawn on top of the shot Bullet
129
Object.DrawOrder = 4
130
end if
131
132
Object.CannonTimer++
133
else
134
// Pull the cannon back in
135
Object.State = SASURI_RETRACTCANNON
136
Object.CannonTimer = 0
137
138
// Move the Sasuri back to its original Draw Order as well, as at this point,
139
// the Bullet's definitely beyond the Sasuri now
140
Object.DrawOrder = 3
141
end if
142
break
143
144
case SASURI_RETRACTCANNON
145
if Object.CannonTimer < 30
146
Object.CannonTimer++
147
else
148
149
// ...what?
150
// Why make it shoot again? The State's set proper in a couple of lines after anyway...
151
Object.State = SASURI_SHOOT
152
153
if Object.Direction == FACING_RIGHT
154
Object.State = SASURI_CRAWLLEFT
155
else
156
Object.State = SASURI_CRAWLRIGHT
157
end if
158
end if
159
break
160
161
end switch
162
else
163
switch Object.State
164
case SASURI_FINDGROUND
165
// See if there's any ground for the Sasuri to stand on
166
// (Interestingly, the Good version of this state uses ObjectTileCollision instead,
167
// but I believe the error lies in the Good version rather than here)
168
ObjectTileGrip(CSIDE_FLOOR, 0, 13, 0)
169
170
if CheckResult == true
171
// If the Sasuri foung ground collision, then start prowling around
172
Object.State = SASURI_CRAWLLEFT
173
else
174
// If collision wasn't found, however, then move a pixel down and wait 'till next frame
175
Object.YPos += 0x10000
176
end if
177
break
178
179
case SASURI_CRAWLLEFT
180
181
// Move at a rate of half a pixel left per frame
182
Object.XPos -= 0x8000
183
184
// Allow the Sasuri to advance for 2 and two-thirds seconds before turning around
185
Object.MoveTimer--
186
if Object.MoveTimer <= -160
187
Object.State = SASURI_CRAWLRIGHT
188
Object.Direction = FACING_LEFT
189
end if
190
191
// In addition to the timer condition, the Sasuri can also run out of ground as another condition for turning around
192
ObjectTileGrip(CSIDE_FLOOR, 0, 13, 0)
193
if CheckResult == false
194
Object.State = SASURI_CRAWLRIGHT
195
Object.MoveTimer = 0
196
Object.Direction = FACING_LEFT
197
end if
198
break
199
200
case SASURI_CRAWLRIGHT
201
202
// Just like before, move the Sasuri at a 0.5px rate, but this time to the right
203
Object.XPos += 0x8000
204
205
// Same timing of 2 and two-thirds seconds, though do note that the Move Timer will likely be -160 when entering this state
206
// so the time is doubled
207
Object.MoveTimer++
208
if Object.MoveTimer >= 160
209
Object.State = SASURI_CRAWLLEFT
210
Object.Direction = FACING_RIGHT
211
end if
212
213
// And like before, another condition for turning around is reached at the end of the ground
214
ObjectTileGrip(CSIDE_FLOOR, 0, 13, 0)
215
if CheckResult == false
216
Object.State = SASURI_CRAWLLEFT
217
Object.MoveTimer = 0
218
Object.Direction = FACING_RIGHT
219
end if
220
break
221
222
case SASURI_SPOTPLAYER
223
if Object.CannonTimer < 30
224
Object.CannonTimer++
225
else
226
Object.State = SASURI_SHOOT
227
Object.CannonTimer = 0
228
end if
229
break
230
231
case SASURI_SHOOT
232
// Poor Bad Sasuri... it can't even shoot, yet it tries anyway...
233
234
if Object.CannonTimer < 40
235
Object.CannonTimer++
236
else
237
Object.State = SASURI_RETRACTCANNON
238
Object.CannonTimer = 0
239
end if
240
break
241
242
case SASURI_RETRACTCANNON
243
if Object.CannonTimer < 30
244
Object.CannonTimer++
245
else
246
// huh? why is this here?
247
// it gets changed again a line later anyway...
248
Object.State = SASURI_SHOOT
249
250
if Object.Direction == FACING_RIGHT
251
Object.State = SASURI_CRAWLLEFT
252
else
253
Object.State = SASURI_CRAWLRIGHT
254
end if
255
end if
256
break
257
258
end switch
259
end if
260
261
// See if the Sasuri should become a Flower instead
262
CallFunction(StageSetup_CheckGoodFuture)
263
264
end sub
265
266
267
sub ObjectPlayerInteraction
268
#platform: Use_Standalone
269
PlayerObjectCollision(C_TOUCH, -22, -14, 22, 14)
270
#endplatform
271
#platform: Use_Origins
272
PlayerObjectCollision(C_ENEMY, -22, -14, 22, 14)
273
#endplatform
274
if CheckResult == true
275
CallFunction(Player_BadnikBreak)
276
end if
277
278
switch Object.State
279
case SASURI_CRAWLLEFT
280
case SASURI_CRAWLRIGHT
281
// If in a movement state, then see if the Sasuri
282
if Object.CannonTimer == 0
283
PlayerObjectCollision(C_TOUCH, -64, -24, 64, 24)
284
if CheckResult == true
285
Object.State = SASURI_SPOTPLAYER
286
287
if Player.XPos < Object.XPos
288
Object.Direction = FACING_RIGHT
289
else
290
Object.Direction = FACING_LEFT
291
end if
292
end if
293
else
294
Object.CannonTimer = 0
295
end if
296
break
297
298
end switch
299
300
end sub
301
302
303
sub ObjectDraw
304
305
if Object.Quality == GOOD_QUALITY
306
if Object.Frame < 30
307
// In this order, draw the:
308
// - back paw
309
// - main body
310
// - front paw
311
312
DrawSpriteFX(2, FX_FLIP, Object.XPos, Object.YPos)
313
DrawSpriteFX(0, FX_FLIP, Object.XPos, Object.YPos)
314
DrawSpriteFX(3, FX_FLIP, Object.XPos, Object.YPos)
315
else
316
// These are the same order as detailed above, just with different frames for the paws
317
318
DrawSpriteFX(4, FX_FLIP, Object.XPos, Object.YPos)
319
DrawSpriteFX(0, FX_FLIP, Object.XPos, Object.YPos)
320
DrawSpriteFX(5, FX_FLIP, Object.XPos, Object.YPos)
321
end if
322
323
switch Object.State
324
case SASURI_CRAWLLEFT
325
case SASURI_CRAWLRIGHT
326
case SASURI_SPOTPLAYER
327
case SASURI_RETRACTCANNON
328
// Draw the pulled back cannon frame
329
DrawSpriteFX(10, FX_FLIP, Object.XPos, Object.YPos)
330
break
331
332
case SASURI_SHOOT
333
// The Sasuri's shooting, so draw the extended cannon frame
334
DrawSpriteFX(11, FX_FLIP, Object.XPos, Object.YPos)
335
break
336
337
end switch
338
else
339
// Bad Sasuri version, use the broken versions of the Sasuri's sprites
340
341
if Object.Frame < 30
342
DrawSpriteFX(6, FX_FLIP, Object.XPos, Object.YPos)
343
DrawSpriteFX(1, FX_FLIP, Object.XPos, Object.YPos)
344
DrawSpriteFX(7, FX_FLIP, Object.XPos, Object.YPos)
345
else
346
DrawSpriteFX(8, FX_FLIP, Object.XPos, Object.YPos)
347
DrawSpriteFX(1, FX_FLIP, Object.XPos, Object.YPos)
348
DrawSpriteFX(9, FX_FLIP, Object.XPos, Object.YPos)
349
end if
350
351
switch Object.State
352
case SASURI_CRAWLLEFT
353
case SASURI_CRAWLRIGHT
354
case SASURI_SPOTPLAYER
355
case SASURI_RETRACTCANNON
356
// Draw the Sasuri's broken retracted cannon frame
357
DrawSpriteFX(12, FX_FLIP, Object.XPos, Object.YPos)
358
break
359
360
case SASURI_SHOOT
361
// The cannon's broken but the Sasuri's gonna try and use it anyway,
362
// draw the extended cannon frame
363
DrawSpriteFX(13, FX_FLIP, Object.XPos, Object.YPos)
364
break
365
366
end switch
367
end if
368
369
end sub
370
371
372
sub ObjectStartup
373
LoadSpriteSheet("R5/Objects.gif")
374
375
// Sasuri Frames
376
377
// Good Main Sasuri Frame
378
SpriteFrame(-24, -16, 48, 32, 174, 141)
379
380
// Bad Main Sasuri Frame
381
SpriteFrame(-24, -16, 48, 32, 174, 174)
382
383
// Good Sasuri Paw Frames
384
SpriteFrame(-32, -4, 32, 16, 100, 110)
385
SpriteFrame(-21, -3, 32, 16, 100, 110)
386
SpriteFrame(-28, -4, 32, 16, 100, 110)
387
SpriteFrame(-25, -3, 32, 16, 100, 110)
388
389
// Bad Sasuri Paw Frames
390
SpriteFrame(-32, -4, 32, 16, 100, 127)
391
SpriteFrame(-21, -3, 32, 16, 100, 127)
392
SpriteFrame(-28, -4, 32, 16, 100, 127)
393
SpriteFrame(-25, -3, 32, 16, 100, 127)
394
395
// Good Sasuri Cannon Frames
396
SpriteFrame(-9, -24, 24, 16, 100, 93)
397
SpriteFrame(-5, -29, 24, 16, 100, 93)
398
399
// Bad Sasuri Cannon Frames
400
SpriteFrame(-1, -24, 16, 16, 133, 110)
401
SpriteFrame(3, -29, 16, 16, 133, 110)
402
403
end sub
404
405
406
// ========================
407
// Editor Subs
408
// ========================
409
410
sub RSDKEdit
411
if Editor.ReturnVariable == true
412
switch Editor.VariableID
413
case EDIT_VAR_PROPVAL // Property Value
414
CheckResult = Object.PropertyValue
415
break
416
case 0 // Condition
417
CheckResult = Object.PropertyValue
418
break
419
end switch
420
else
421
switch Editor.VariableID
422
case EDIT_VAR_PROPVAL // Property Value
423
Object.PropertyValue = Editor.VariableValue
424
break
425
case 0 // Condition
426
Object.PropertyValue = Editor.VariableValue
427
break
428
end switch
429
end if
430
end sub
431
432
433
sub RSDKDraw
434
if Object.PropertyValue == GOOD_QUALITY
435
DrawSpriteFX(2, FX_FLIP, Object.XPos, Object.YPos)
436
DrawSpriteFX(0, FX_FLIP, Object.XPos, Object.YPos)
437
DrawSpriteFX(3, FX_FLIP, Object.XPos, Object.YPos)
438
DrawSpriteFX(6, FX_FLIP, Object.XPos, Object.YPos)
439
else
440
DrawSpriteFX(4, FX_FLIP, Object.XPos, Object.YPos)
441
DrawSpriteFX(1, FX_FLIP, Object.XPos, Object.YPos)
442
DrawSpriteFX(5, FX_FLIP, Object.XPos, Object.YPos)
443
DrawSpriteFX(7, FX_FLIP, Object.XPos, Object.YPos)
444
end if
445
end sub
446
447
448
sub RSDKLoad
449
LoadSpriteSheet("R5/Objects.gif")
450
451
SpriteFrame(-24, -16, 48, 32, 174, 141)
452
SpriteFrame(-24, -16, 48, 32, 174, 174)
453
454
SpriteFrame(-32, -4, 32, 16, 100, 110)
455
SpriteFrame(-21, -3, 32, 16, 100, 110)
456
457
SpriteFrame(-32, -4, 32, 16, 100, 127)
458
SpriteFrame(-21, -3, 32, 16, 100, 127)
459
460
SpriteFrame(-9, -24, 24, 16, 100, 93)
461
SpriteFrame(-1, -24, 16, 16, 133, 110)
462
463
AddEditorVariable("Condition")
464
SetActiveVariable("Condition")
465
AddEnumVariable("Good", GOOD_QUALITY)
466
AddEnumVariable("Bad", BAD_QUALITY)
467
end sub
468
469