Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-CD-2011-Script-Decompilation
Path: blob/main/Scripts/R5/Kemusi.txt
1319 views
1
//-------------------Sonic CD Kemusi 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
#alias Object.Value1 : Object.BodyPosition1X
9
#alias Object.Value4 : Object.BodyPosition1Y
10
11
#alias Object.Value2 : Object.BodyPosition2X
12
#alias Object.Value5 : Object.BodyPosition2Y
13
14
#alias Object.Value3 : Object.BodyPosition3X
15
#alias Object.Value6 : Object.BodyPosition3Y
16
17
// (The head's position is base XPos and YPos)
18
19
// Bitfield for all the directions of the individual pieces
20
#alias Object.Value7 : Object.PieceDirection
21
22
// The range the Kemusi will go, stored in rather unconventional values...
23
#alias Object.Scale : Object.BoundsL
24
#alias Object.Rotation : Object.BoundsR
25
26
#alias Object.PropertyValue : Object.Quality
27
28
// States
29
#alias 0 : KEMUSI_INIT
30
#alias 1 : KEMUSI_FINDGROUND
31
#alias 2 : KEMUSI_SPIKED_ADVANCE
32
#alias 3 : KEMUSI_SPIKED_RETRACT
33
#alias 4 : KEMUSI_NORMAL_ADVANCE
34
#alias 5 : KEMUSI_NORMAL_RETRACT
35
36
// Collision Sides
37
#alias 0 : CSIDE_FLOOR
38
39
// Badnik Quality / Property Values
40
#alias 0 : GOOD_QUALITY
41
#alias 1 : BAD_QUALITY
42
43
44
sub ObjectMain
45
46
switch Object.State
47
case KEMUSI_INIT
48
// Set initial body part positions
49
50
// Setup the first body fragment to be 12 pixels to the right from the head
51
Object.BodyPosition1X = Object.XPos
52
Object.BodyPosition1X += 0xC0000
53
54
// Set the second body fragment to be 24 pixels away from the head
55
Object.BodyPosition2X = Object.XPos
56
Object.BodyPosition2X += 0x180000
57
58
// And then make the third, and last, body fragment 36 pixels away from the head
59
Object.BodyPosition3X = Object.XPos
60
Object.BodyPosition3X += 0x240000
61
62
// All the body fragments start on the same Y Position as the head
63
Object.BodyPosition1Y = Object.YPos
64
Object.BodyPosition2Y = Object.YPos
65
Object.BodyPosition3Y = Object.YPos
66
67
// And setup initial bounds too
68
69
// Left bounds is 64 pixels away
70
Object.BoundsL = Object.XPos
71
Object.BoundsL -= 0x400000
72
73
// And right bounds is 64 pixels away too, adding up to a total of 128 pixels range
74
Object.BoundsR = Object.XPos
75
Object.BoundsR += 0x400000
76
77
Object.State = KEMUSI_FINDGROUND
78
break
79
80
case KEMUSI_FINDGROUND
81
// Get the directions of every piece (incl. head)
82
GetBit(TempValue0, Object.PieceDirection, 0)
83
GetBit(TempValue1, Object.PieceDirection, 1)
84
GetBit(TempValue2, Object.PieceDirection, 2)
85
GetBit(TempValue3, Object.PieceDirection, 3)
86
87
// First, update make the head track the ground if needed
88
if TempValue0 == false
89
ObjectTileCollision(CSIDE_FLOOR, 0, 8, 0)
90
if CheckResult == false
91
// If there was no collision, move the head down by a pixel
92
Object.YPos += 0x10000
93
else
94
TempValue0 = CheckResult
95
end if
96
end if
97
98
// ObjectTileCollision can only pull from Object.XPos and Object.YPos, no custom values, so it's rapidly
99
// changing throughout this section
100
// With that, back it up now so it can be properly set again later
101
TempValue4 = Object.XPos
102
TempValue5 = Object.YPos
103
104
// Then, update following piece 1
105
if TempValue1 == false
106
Object.XPos = Object.BodyPosition1X
107
Object.YPos = Object.BodyPosition1Y
108
109
ObjectTileCollision(CSIDE_FLOOR, 0, 8, 0)
110
if CheckResult == false
111
Object.BodyPosition1Y += 0x10000
112
else
113
TempValue1 = CheckResult
114
Object.BodyPosition1Y = Object.YPos
115
end if
116
end if
117
118
// Now, update piece 2's grip to the ground
119
if TempValue2 == false
120
Object.XPos = Object.BodyPosition2X
121
Object.YPos = Object.BodyPosition2Y
122
123
ObjectTileCollision(CSIDE_FLOOR, 0, 8, 0)
124
if CheckResult == false
125
Object.BodyPosition2Y += 0x10000
126
else
127
TempValue2 = CheckResult
128
Object.BodyPosition2Y = Object.YPos
129
end if
130
end if
131
132
// And finally, piece 3
133
if TempValue3 == false
134
Object.XPos = Object.BodyPosition3X
135
Object.YPos = Object.BodyPosition3Y
136
137
ObjectTileCollision(CSIDE_FLOOR, 0, 8, 0)
138
if CheckResult == false
139
Object.BodyPosition3Y += 0x10000
140
else
141
TempValue3 = CheckResult
142
Object.BodyPosition3Y = Object.YPos
143
end if
144
end if
145
146
// Restore the Object's position, now that all the Object Tile Collision checks have been done
147
Object.XPos = TempValue4
148
Object.YPos = TempValue5
149
150
// Add the collision results of all individual pieces
151
// (0 if in the air, 1 if on the ground)
152
TempValue4 = TempValue0
153
TempValue4 += TempValue1
154
TempValue4 += TempValue2
155
TempValue4 += TempValue3
156
157
// 4 means, are all pieces are touching the ground?
158
if TempValue4 == 4
159
if Object.Quality == GOOD_QUALITY
160
Object.State = KEMUSI_SPIKED_RETRACT
161
else
162
Object.State = KEMUSI_NORMAL_RETRACT
163
end if
164
165
Object.PieceDirection = 0
166
else
167
// Store the current collision states for use next frame
168
SetBit(Object.PieceDirection, 0, TempValue0)
169
SetBit(Object.PieceDirection, 1, TempValue1)
170
SetBit(Object.PieceDirection, 2, TempValue2)
171
SetBit(Object.PieceDirection, 3, TempValue3)
172
end if
173
break
174
175
case KEMUSI_SPIKED_ADVANCE
176
if Object.Timer < 36
177
Object.Timer++
178
179
// See which way the Head's facing
180
GetBit(TempValue0, Object.PieceDirection, 0)
181
182
if TempValue0 == 0
183
// The Head's facing left
184
185
// Move it half a pixel to the left
186
Object.XPos -= 0x8000
187
188
// See if it's still the ground
189
ObjectTileGrip(CSIDE_FLOOR, 0, 8, 0)
190
191
if CheckResult == true
192
// The Head's still on the ground, that's good
193
194
if Object.XPos < Object.BoundsL
195
// However, if the Head's now past the Object's Left bounds, then turn around
196
SetBit(Object.PieceDirection, 0, 1)
197
end if
198
else
199
// The Head's now in the air, turn it around
200
SetBit(Object.PieceDirection, 0, 1)
201
end if
202
else
203
// The Head's facing right
204
205
// Move it a half pixel to the right
206
Object.XPos += 0x8000
207
208
// See if the Head's still on the ground
209
ObjectTileGrip(CSIDE_FLOOR, 0, 8, 0)
210
211
if CheckResult == true
212
// Yup the Head's still grounded, that's good
213
214
if Object.XPos > Object.BoundsR
215
// However, the Head's beyond the Right bounds, so turn around
216
SetBit(Object.PieceDirection, 0, 0)
217
end if
218
else
219
// Head's now in the air, turn around
220
SetBit(Object.PieceDirection, 0, 0)
221
end if
222
end if
223
224
// Now, onto the Body segments!
225
226
// First, backup the Object's base Position
227
TempValue1 = Object.XPos
228
TempValue2 = Object.YPos
229
230
// Get Body Piece 1's Direction
231
GetBit(TempValue0, Object.PieceDirection, 1)
232
233
if TempValue0 == 0
234
// Facing left
235
236
// Move it left by about 0.333 pixels
237
Object.BodyPosition1X -= 0x5555
238
239
// Move the entire Object to this Body Piece's Position
240
Object.XPos = Object.BodyPosition1X
241
Object.YPos = Object.BodyPosition1Y
242
243
// Check to see if it can Grip to a tile
244
ObjectTileGrip(CSIDE_FLOOR, 0, 8, 0)
245
246
if CheckResult == true
247
// Move this Body Piece to be on the floor
248
Object.BodyPosition1Y = Object.YPos
249
250
if Object.BodyPosition1X < Object.BoundsL
251
// Left bounds reached, turn around
252
SetBit(Object.PieceDirection, 1, 1)
253
end if
254
else
255
// It's in the air, so turn around
256
SetBit(Object.PieceDirection, 1, 1)
257
end if
258
else
259
// Facing right
260
261
// Move abut a third of a pixel right
262
Object.BodyPosition1X += 0x5555
263
264
// Move the entire Object to the current Body Piece's Position
265
Object.XPos = Object.BodyPosition1X
266
Object.YPos = Object.BodyPosition1Y
267
268
// Check Grip to the Tile, this is why the Object needed to be moved
269
ObjectTileGrip(CSIDE_FLOOR, 0, 8, 0)
270
271
if CheckResult == true
272
// Move the Body Piece to where the ground grip is
273
Object.BodyPosition1Y = Object.YPos
274
275
if Object.BodyPosition1X > Object.BoundsR
276
// The Piece is past its right Bounds, turn it around
277
SetBit(Object.PieceDirection, 1, 0)
278
end if
279
else
280
// The Object's in the air, turn around
281
SetBit(Object.PieceDirection, 1, 0)
282
end if
283
end if
284
285
// Get the direction of Body Fragment 2
286
GetBit(TempValue0, Object.PieceDirection, 2)
287
288
if TempValue0 == 0
289
// Piece is facing left
290
291
// Move the Piece about 0.1666 pixels left
292
Object.BodyPosition2X -= 0x2AAA
293
294
// And now move the entire Object to this Piece's Position
295
Object.XPos = Object.BodyPosition2X
296
Object.YPos = Object.BodyPosition2Y
297
298
// Grip this Piece to the tile
299
ObjectTileGrip(CSIDE_FLOOR, 0, 8, 0)
300
301
if CheckResult == true
302
Object.BodyPosition2Y = Object.YPos
303
if Object.BodyPosition2X < Object.BoundsL
304
SetBit(Object.PieceDirection, 2, 1)
305
end if
306
else
307
SetBit(Object.PieceDirection, 2, 1)
308
end if
309
else
310
Object.BodyPosition2X += 0x2AAA
311
312
Object.XPos = Object.BodyPosition2X
313
Object.YPos = Object.BodyPosition2Y
314
315
ObjectTileGrip(CSIDE_FLOOR, 0, 8, 0)
316
if CheckResult == true
317
Object.BodyPosition2Y = Object.YPos
318
319
if Object.BodyPosition2X > Object.BoundsR
320
SetBit(Object.PieceDirection, 2, 0)
321
end if
322
else
323
SetBit(Object.PieceDirection, 2, 0)
324
end if
325
end if
326
327
Object.XPos = TempValue1
328
Object.YPos = TempValue2
329
else
330
331
// Are all Pieces facing left?
332
if Object.PieceDirection == 0
333
Object.BodyPosition1X = Object.XPos
334
Object.BodyPosition1X += 0xC0000
335
336
Object.BodyPosition2X = Object.XPos
337
Object.BodyPosition2X += 0x180000
338
339
Object.BodyPosition3X = Object.XPos
340
Object.BodyPosition3X += 0x240000
341
end if
342
343
// Are all Pieces facing right?
344
if Object.PieceDirection == 15
345
Object.BodyPosition1X = Object.XPos
346
Object.BodyPosition1X -= 0xC0000
347
348
Object.BodyPosition2X = Object.XPos
349
Object.BodyPosition2X -= 0x180000
350
351
Object.BodyPosition3X = Object.XPos
352
Object.BodyPosition3X -= 0x240000
353
end if
354
355
Object.Timer = 0
356
Object.State = KEMUSI_SPIKED_RETRACT
357
end if
358
break
359
360
case KEMUSI_SPIKED_RETRACT
361
if Object.Timer < 36
362
Object.Timer++
363
364
TempValue1 = Object.XPos
365
TempValue2 = Object.YPos
366
367
GetBit(TempValue0, Object.PieceDirection, 1)
368
if TempValue0 == 0
369
Object.BodyPosition1X -= 0x2AAA
370
371
Object.XPos = Object.BodyPosition1X
372
Object.YPos = Object.BodyPosition1Y
373
374
ObjectTileGrip(CSIDE_FLOOR, 0, 8, 0)
375
if CheckResult == true
376
Object.BodyPosition1Y = Object.YPos
377
378
if Object.BodyPosition1X < Object.BoundsL
379
SetBit(Object.PieceDirection, 1, 1)
380
end if
381
else
382
SetBit(Object.PieceDirection, 1, 1)
383
end if
384
else
385
Object.BodyPosition1X += 0x2AAA
386
387
Object.XPos = Object.BodyPosition1X
388
Object.YPos = Object.BodyPosition1Y
389
390
ObjectTileGrip(CSIDE_FLOOR, 0, 8, 0)
391
if CheckResult == true
392
Object.BodyPosition1Y = Object.YPos
393
394
if Object.BodyPosition1X > Object.BoundsR
395
SetBit(Object.PieceDirection, 1, 0)
396
end if
397
else
398
SetBit(Object.PieceDirection, 1, 0)
399
end if
400
end if
401
402
GetBit(TempValue0, Object.PieceDirection, 2)
403
if TempValue0 == 0
404
Object.BodyPosition2X -= 0x5555
405
406
Object.XPos = Object.BodyPosition2X
407
Object.YPos = Object.BodyPosition2Y
408
409
ObjectTileGrip(CSIDE_FLOOR, 0, 8, 0)
410
if CheckResult == true
411
Object.BodyPosition2Y = Object.YPos
412
413
if Object.BodyPosition2X < Object.BoundsL
414
SetBit(Object.PieceDirection, 2, 1)
415
end if
416
else
417
SetBit(Object.PieceDirection, 2, 1)
418
end if
419
else
420
Object.BodyPosition2X += 0x5555
421
422
Object.XPos = Object.BodyPosition2X
423
Object.YPos = Object.BodyPosition2Y
424
425
ObjectTileGrip(CSIDE_FLOOR, 0, 8, 0)
426
if CheckResult == true
427
Object.BodyPosition2Y = Object.YPos
428
429
if Object.BodyPosition2X > Object.BoundsR
430
SetBit(Object.PieceDirection, 2, 0)
431
end if
432
else
433
SetBit(Object.PieceDirection, 2, 0)
434
end if
435
end if
436
437
GetBit(TempValue0, Object.PieceDirection, 3)
438
if TempValue0 == 0
439
Object.BodyPosition3X -= 0x8000
440
441
Object.XPos = Object.BodyPosition3X
442
Object.YPos = Object.BodyPosition3Y
443
444
ObjectTileGrip(CSIDE_FLOOR, 0, 8, 0)
445
if CheckResult == true
446
Object.BodyPosition3Y = Object.YPos
447
448
if Object.BodyPosition3X < Object.BoundsL
449
SetBit(Object.PieceDirection, 3, 1)
450
end if
451
else
452
SetBit(Object.PieceDirection, 3, 1)
453
end if
454
else
455
Object.BodyPosition3X += 0x8000
456
457
Object.XPos = Object.BodyPosition3X
458
Object.YPos = Object.BodyPosition3Y
459
460
ObjectTileGrip(CSIDE_FLOOR, 0, 8, 0)
461
462
if CheckResult == true
463
Object.BodyPosition3Y = Object.YPos
464
465
if Object.BodyPosition3X > Object.BoundsR
466
SetBit(Object.PieceDirection, 3, 0)
467
end if
468
else
469
SetBit(Object.PieceDirection, 3, 0)
470
end if
471
end if
472
473
Object.XPos = TempValue1
474
Object.YPos = TempValue2
475
else
476
Object.Timer = 0
477
Object.State = KEMUSI_SPIKED_ADVANCE
478
end if
479
break
480
481
case KEMUSI_NORMAL_ADVANCE
482
if Object.Timer < 36
483
Object.Timer++
484
485
GetBit(TempValue0, Object.PieceDirection, 0)
486
if TempValue0 == 0
487
Object.XPos -= 0x4000
488
489
ObjectTileGrip(CSIDE_FLOOR, 0, 8, 0)
490
491
if CheckResult == true
492
if Object.XPos < Object.BoundsL
493
SetBit(Object.PieceDirection, 0, 1)
494
end if
495
else
496
SetBit(Object.PieceDirection, 0, 1)
497
end if
498
else
499
Object.XPos += 0x4000
500
501
ObjectTileGrip(CSIDE_FLOOR, 0, 8, 0)
502
503
if CheckResult == true
504
if Object.XPos > Object.BoundsR
505
SetBit(Object.PieceDirection, 0, 0)
506
end if
507
else
508
SetBit(Object.PieceDirection, 0, 0)
509
end if
510
end if
511
512
TempValue1 = Object.XPos
513
TempValue2 = Object.YPos
514
515
GetBit(TempValue0, Object.PieceDirection, 1)
516
if TempValue0 == 0
517
Object.BodyPosition1X -= 0x2AAA
518
519
Object.XPos = Object.BodyPosition1X
520
Object.YPos = Object.BodyPosition1Y
521
522
ObjectTileGrip(CSIDE_FLOOR, 0, 8, 0)
523
524
if CheckResult == true
525
Object.BodyPosition1Y = Object.YPos
526
527
if Object.BodyPosition1X < Object.BoundsL
528
SetBit(Object.PieceDirection, 1, 1)
529
end if
530
else
531
SetBit(Object.PieceDirection, 1, 1)
532
end if
533
else
534
Object.BodyPosition1X += 0x2AAA
535
536
Object.XPos = Object.BodyPosition1X
537
Object.YPos = Object.BodyPosition1Y
538
539
ObjectTileGrip(CSIDE_FLOOR, 0, 8, 0)
540
541
if CheckResult == true
542
Object.BodyPosition1Y = Object.YPos
543
544
if Object.BodyPosition1X > Object.BoundsR
545
SetBit(Object.PieceDirection, 1, 0)
546
end if
547
else
548
SetBit(Object.PieceDirection, 1, 0)
549
end if
550
end if
551
552
GetBit(TempValue0, Object.PieceDirection, 2)
553
if TempValue0 == 0
554
Object.BodyPosition2X -= 0x1555
555
556
Object.XPos = Object.BodyPosition2X
557
Object.YPos = Object.BodyPosition2Y
558
559
ObjectTileGrip(CSIDE_FLOOR, 0, 8, 0)
560
561
if CheckResult == true
562
Object.BodyPosition2Y = Object.YPos
563
564
if Object.BodyPosition2X < Object.BoundsL
565
SetBit(Object.PieceDirection, 2, 1)
566
end if
567
else
568
SetBit(Object.PieceDirection, 2, 1)
569
end if
570
else
571
Object.BodyPosition2X += 0x1555
572
573
Object.XPos = Object.BodyPosition2X
574
Object.YPos = Object.BodyPosition2Y
575
576
ObjectTileGrip(CSIDE_FLOOR, 0, 8, 0)
577
578
if CheckResult == true
579
Object.BodyPosition2Y = Object.YPos
580
581
if Object.BodyPosition2X > Object.BoundsR
582
SetBit(Object.PieceDirection, 2, 0)
583
end if
584
else
585
SetBit(Object.PieceDirection, 2, 0)
586
end if
587
end if
588
589
Object.XPos = TempValue1
590
Object.YPos = TempValue2
591
else
592
if Object.PieceDirection == 0
593
Object.BodyPosition1X = Object.XPos
594
Object.BodyPosition1X += 0xC0000
595
596
Object.BodyPosition2X = Object.XPos
597
Object.BodyPosition2X += 0x180000
598
599
Object.BodyPosition3X = Object.XPos
600
Object.BodyPosition3X += 0x240000
601
end if
602
603
if Object.PieceDirection == 15
604
Object.BodyPosition1X = Object.XPos
605
Object.BodyPosition1X -= 0xC0000
606
607
Object.BodyPosition2X = Object.XPos
608
Object.BodyPosition2X -= 0x180000
609
610
Object.BodyPosition3X = Object.XPos
611
Object.BodyPosition3X -= 0x240000
612
end if
613
614
Object.Timer = 0
615
Object.State = KEMUSI_NORMAL_RETRACT
616
end if
617
break
618
619
case KEMUSI_NORMAL_RETRACT
620
if Object.Timer < 36
621
Object.Timer++
622
623
TempValue1 = Object.XPos
624
TempValue2 = Object.YPos
625
626
GetBit(TempValue0, Object.PieceDirection, 1)
627
if TempValue0 == 0
628
Object.BodyPosition1X -= 0x1555
629
630
Object.XPos = Object.BodyPosition1X
631
Object.YPos = Object.BodyPosition1Y
632
633
ObjectTileGrip(CSIDE_FLOOR, 0, 8, 0)
634
if CheckResult == true
635
Object.BodyPosition1Y = Object.YPos
636
637
if Object.BodyPosition1X < Object.BoundsL
638
SetBit(Object.PieceDirection, 1, 1)
639
end if
640
else
641
SetBit(Object.PieceDirection, 1, 1)
642
end if
643
else
644
Object.BodyPosition1X += 0x1555
645
646
Object.XPos = Object.BodyPosition1X
647
Object.YPos = Object.BodyPosition1Y
648
649
ObjectTileGrip(CSIDE_FLOOR, 0, 8, 0)
650
651
if CheckResult == true
652
Object.BodyPosition1Y = Object.YPos
653
654
if Object.BodyPosition1X > Object.BoundsR
655
SetBit(Object.PieceDirection, 1, 0)
656
end if
657
else
658
SetBit(Object.PieceDirection, 1, 0)
659
end if
660
end if
661
662
GetBit(TempValue0, Object.PieceDirection, 2)
663
if TempValue0 == 0
664
Object.BodyPosition2X -= 0x2AAA
665
666
Object.XPos = Object.BodyPosition2X
667
Object.YPos = Object.BodyPosition2Y
668
669
ObjectTileGrip(CSIDE_FLOOR, 0, 8, 0)
670
671
if CheckResult == true
672
Object.BodyPosition2Y = Object.YPos
673
674
if Object.BodyPosition2X < Object.BoundsL
675
SetBit(Object.PieceDirection, 2, 1)
676
end if
677
else
678
SetBit(Object.PieceDirection, 2, 1)
679
end if
680
else
681
Object.BodyPosition2X += 0x2AAA
682
683
Object.XPos = Object.BodyPosition2X
684
Object.YPos = Object.BodyPosition2Y
685
686
ObjectTileGrip(CSIDE_FLOOR, 0, 8, 0)
687
688
if CheckResult == true
689
Object.BodyPosition2Y = Object.YPos
690
691
if Object.BodyPosition2X > Object.BoundsR
692
SetBit(Object.PieceDirection, 2, 0)
693
end if
694
else
695
SetBit(Object.PieceDirection, 2, 0)
696
end if
697
end if
698
699
GetBit(TempValue0, Object.PieceDirection, 3)
700
if TempValue0 == 0
701
Object.BodyPosition3X -= 0x4000
702
703
Object.XPos = Object.BodyPosition3X
704
Object.YPos = Object.BodyPosition3Y
705
706
ObjectTileGrip(CSIDE_FLOOR, 0, 8, 0)
707
708
if CheckResult == true
709
Object.BodyPosition3Y = Object.YPos
710
711
if Object.BodyPosition3X < Object.BoundsL
712
SetBit(Object.PieceDirection, 3, 1)
713
end if
714
else
715
SetBit(Object.PieceDirection, 3, 1)
716
end if
717
else
718
Object.BodyPosition3X += 0x4000
719
720
Object.XPos = Object.BodyPosition3X
721
Object.YPos = Object.BodyPosition3Y
722
723
ObjectTileGrip(CSIDE_FLOOR, 0, 8, 0)
724
725
if CheckResult == true
726
Object.BodyPosition3Y = Object.YPos
727
728
if Object.BodyPosition3X > Object.BoundsR
729
SetBit(Object.PieceDirection, 3, 0)
730
end if
731
else
732
SetBit(Object.PieceDirection, 3, 0)
733
end if
734
end if
735
736
Object.XPos = TempValue1
737
Object.YPos = TempValue2
738
739
else
740
Object.Timer = 0
741
Object.State = KEMUSI_NORMAL_ADVANCE
742
end if
743
break
744
745
end switch
746
747
CallFunction(StageSetup_CheckGoodFuture)
748
749
end sub
750
751
752
sub ObjectPlayerInteraction
753
754
// First, check for the head
755
#platform: Use_Standalone
756
PlayerObjectCollision(C_TOUCH, -8, -10, 8, 8)
757
#endplatform
758
759
#platform: Use_Origins
760
PlayerObjectCollision(C_ENEMY, -8, -10, 8, 8)
761
#endplatform
762
763
if CheckResult == true
764
CallFunction(Player_BadnikBreak)
765
else
766
// The head wasn't hit, so now check against every body fragment
767
768
// First, backup the Object's base Position
769
TempValue1 = Object.XPos
770
TempValue2 = Object.YPos
771
772
if Object.Quality == GOOD_QUALITY
773
Object.XPos = Object.BodyPosition1X
774
Object.YPos = Object.BodyPosition1Y
775
776
PlayerObjectCollision(C_TOUCH, -8, -10, 8, 8)
777
778
if CheckResult == true
779
CallFunction(Player_Hit)
780
else
781
Object.XPos = Object.BodyPosition2X
782
Object.YPos = Object.BodyPosition2Y
783
784
PlayerObjectCollision(C_TOUCH, -8, -10, 8, 8)
785
786
if CheckResult == true
787
CallFunction(Player_Hit)
788
else
789
Object.XPos = Object.BodyPosition3X
790
Object.YPos = Object.BodyPosition3Y
791
792
PlayerObjectCollision(C_TOUCH, -8, -10, 8, 8)
793
794
if CheckResult == true
795
CallFunction(Player_Hit)
796
end if
797
end if
798
end if
799
else
800
Object.XPos = Object.BodyPosition1X
801
Object.YPos = Object.BodyPosition1Y
802
#platform: Use_Standalone
803
PlayerObjectCollision(C_TOUCH, -8, -8, 8, 8)
804
#endplatform
805
806
#platform: Use_Origins
807
PlayerObjectCollision(C_ENEMY, -8, -8, 8, 8)
808
#endplatform
809
if CheckResult == true
810
CallFunction(Player_BadnikBreak)
811
else
812
Object.XPos = Object.BodyPosition2X
813
Object.YPos = Object.BodyPosition2Y
814
#platform: Use_Standalone
815
PlayerObjectCollision(C_TOUCH, -8, -8, 8, 8)
816
#endplatform
817
818
#platform: Use_Origins
819
PlayerObjectCollision(C_ENEMY, -8, -8, 8, 8)
820
#endplatform
821
if CheckResult == true
822
CallFunction(Player_BadnikBreak)
823
else
824
Object.XPos = Object.BodyPosition3X
825
Object.YPos = Object.BodyPosition3Y
826
#platform: Use_Standalone
827
PlayerObjectCollision(C_TOUCH, -8, -8, 8, 8)
828
#endplatform
829
830
#platform: Use_Origins
831
PlayerObjectCollision(C_ENEMY, -8, -8, 8, 8)
832
#endplatform
833
if CheckResult == true
834
CallFunction(Player_BadnikBreak)
835
end if
836
end if
837
end if
838
end if
839
840
// It's safe to restore the Object's base Position now
841
Object.XPos = TempValue1
842
Object.YPos = TempValue2
843
844
end if
845
end sub
846
847
848
sub ObjectDraw
849
850
if Object.Quality == GOOD_QUALITY
851
GetBit(Object.Direction, Object.PieceDirection, 3)
852
DrawSpriteFX(2, FX_FLIP, Object.BodyPosition3X, Object.BodyPosition3Y)
853
854
GetBit(Object.Direction, Object.PieceDirection, 2)
855
DrawSpriteFX(2, FX_FLIP, Object.BodyPosition2X, Object.BodyPosition2Y)
856
857
GetBit(Object.Direction, Object.PieceDirection, 1)
858
DrawSpriteFX(2, FX_FLIP, Object.BodyPosition1X, Object.BodyPosition1Y)
859
else
860
GetBit(Object.Direction, Object.PieceDirection, 3)
861
DrawSpriteFX(3, FX_FLIP, Object.BodyPosition3X, Object.BodyPosition3Y)
862
863
GetBit(Object.Direction, Object.PieceDirection, 2)
864
DrawSpriteFX(3, FX_FLIP, Object.BodyPosition2X, Object.BodyPosition2Y)
865
866
GetBit(Object.Direction, Object.PieceDirection, 1)
867
DrawSpriteFX(3, FX_FLIP, Object.BodyPosition1X, Object.BodyPosition1Y)
868
end if
869
870
// Get the direction of the head
871
GetBit(Object.Direction, Object.PieceDirection, 0)
872
873
switch Object.State
874
case KEMUSI_INIT
875
case KEMUSI_FINDGROUND
876
case KEMUSI_SPIKED_RETRACT
877
case KEMUSI_NORMAL_RETRACT
878
// Closed mouth Frame
879
DrawSpriteFX(0, FX_FLIP, Object.XPos, Object.YPos)
880
break
881
882
case KEMUSI_SPIKED_ADVANCE
883
case KEMUSI_NORMAL_ADVANCE
884
// Mouth Open Frame
885
DrawSpriteFX(1, FX_FLIP, Object.XPos, Object.YPos)
886
break
887
888
end switch
889
890
end sub
891
892
893
sub ObjectStartup
894
LoadSpriteSheet("R5/Objects.gif")
895
896
// 0 - Kemusi Closed Mouth Frame
897
SpriteFrame(-8, -16, 16, 24, 125, 75)
898
899
// 1 - Kemusi Smiling Frame
900
SpriteFrame(-8, -16, 16, 24, 125, 50)
901
902
// 2- Kemusi Spiked Fragment Frame
903
SpriteFrame(-8, -16, 16, 24, 67, 150)
904
905
// 2- Kemusi Normal Fragment Frame
906
SpriteFrame(-8, -8, 16, 16, 52, 1)
907
908
end sub
909
910
911
// ========================
912
// Editor Subs
913
// ========================
914
915
sub RSDKEdit
916
if Editor.ReturnVariable == true
917
switch Editor.VariableID
918
case EDIT_VAR_PROPVAL // Property Value
919
CheckResult = Object.PropertyValue
920
break
921
case 0 // Type
922
CheckResult = Object.PropertyValue
923
break
924
end switch
925
else
926
switch Editor.VariableID
927
case EDIT_VAR_PROPVAL // Property Value
928
Object.PropertyValue = Editor.VariableValue
929
break
930
case 0 // Type
931
Object.PropertyValue = Editor.VariableValue
932
break
933
end switch
934
end if
935
end sub
936
937
938
sub RSDKDraw
939
TempValue0 = Object.XPos
940
TempValue0 += 0x240000
941
942
DrawSpriteXY(Object.PropertyValue, TempValue0, Object.YPos)
943
944
TempValue0 -= 0xC0000
945
DrawSpriteXY(Object.PropertyValue, TempValue0, Object.YPos)
946
947
TempValue0 -= 0xC0000
948
DrawSpriteXY(Object.PropertyValue, TempValue0, Object.YPos)
949
950
TempValue0 -= 0xC0000
951
DrawSpriteXY(2, TempValue0, Object.YPos) // smile :)
952
end sub
953
954
955
sub RSDKLoad
956
LoadSpriteSheet("R5/Objects.gif")
957
SpriteFrame(-8, -16, 16, 24, 67, 150)
958
SpriteFrame(-8, -8, 16, 16, 52, 1)
959
SpriteFrame(-8, -16, 16, 24, 125, 50)
960
961
AddEditorVariable("condition")
962
SetActiveVariable("condition")
963
AddEnumVariable("Good Quality", GOOD_QUALITY)
964
AddEnumVariable("Bad Quality", BAD_QUALITY)
965
end sub
966
967