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