Advertisement
ManDudeCrashHacks

KongC

Feb 18th, 2020
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 7.10 KB | None | 0 0
  1. #gool KongC 45 3
  2.  
  3. #anim KONG_STAND_1 [KS1xV] 24
  4. #anim KONG_STAND_2 [KS2xV] 21
  5. #anim KONG_STAND_3 [KS3xV] 8
  6. #anim KONG_STAND_4 [KS4xV] 23
  7. #anim KONG_STAND_5 [KS5xV] 25
  8. #anim KONG_STAND_6 [KS6xV] 15
  9. #anim KONG_STAND_7 [KS7xV] 21
  10. #anim KONG_STAND_8 [KS8xV] 10
  11. #anim KONG_LIFT_1 [KL1xV] 15
  12. #anim KONG_LIFT_2 [KL2xV] 22
  13. #anim KONG_LIFT_3 [KL3xV] 24
  14. #anim KONG_WALK [KW1xV] 15
  15. #anim KONG_THROW_1 [KT1xV] 21
  16. #anim KONG_THROW_2 [KT2xV] 20
  17. #anim KONG_THROW_3 [KT3xV] 18
  18. #anim KONG_HOP [KH1xV] 16
  19. #anim KONG_HIT_1 [Kh1xV] 14
  20. #anim KONG_HIT_2 [Kh2xV] 16
  21. #anim KONG_DIE_1 [KD1xV] 18
  22. #anim KONG_DIE_2 [KD2xV] 18
  23.  
  24. #spawn SPAWN_DEFAULT    Kong_Default
  25. #spawn SPAWN_DONKEYKONG Kong_DonkeyKongSpawner
  26.  
  27. #include "GOOL_EXPR.gooc"
  28.  
  29. var loadstate, mem2, testduration
  30.  
  31. event EventHit => state Kong_Hit
  32.  
  33. /* unused, from levelg */
  34. state Kong_DonkeyKongSpawner {
  35.     code () {
  36.         x = parent->x + rand(-10m, 10m + 1)
  37.         z = parent->x + rand(-10m, 10m + 1)
  38.         mem2 = rand(5)
  39.         testduration = 1.8s + rand(4.8s)
  40.         statusb = FLAG_INVISIBLE
  41.         do {
  42.             var starttime = frametime
  43.             do {
  44.                 playanim(0, KONG_HOP)
  45.             } while (frametime - starttime < testduration)
  46.         } while (true)
  47.     }
  48. }
  49.  
  50. state Kong_Default {
  51.     code () {
  52.         GVAR_3 = self
  53.         statusb = 0
  54.         health = 0
  55.         spawn(29, 4, 1, 4.0, 2) // ShadC - ShabC, boss health bar
  56.         zindex = -20
  57.         pathprog = pathlen >> 1 // start in the middle of path
  58.         calcpath()
  59.         GVAR_1 = health
  60.         loadstate = 0
  61.         loadfile([Kh1xV])
  62.         loadfile([KS1xG])
  63.         loadfile([Kh2xV])
  64.         loadfile([KS1xG])
  65.         changestate(Kong_Stand)
  66.     }
  67. }
  68.  
  69. state Kong_Stand {
  70.     statusc 0
  71.     code () { // do stand (flex) animations then start throwing rocks
  72.         playframes(KONG_STAND_1, 1.0, 0, 23.0)
  73.         playframe(animframe, 0.4s)
  74.         playframes(KONG_STAND_2, 1.0, 0, 20.0)
  75.         playframes(KONG_STAND_3, 1.0, 0, 7.0)
  76.         playframe(animframe, 0.4s)
  77.         playframes(KONG_STAND_4, 1.0, 0, 22.0)
  78.         playframes(KONG_STAND_5, 1.0, 0, 24.0)
  79.         playframes(KONG_STAND_6, 1.0, 0, 14.0)
  80.         playframe(animframe, 0.4s)
  81.         playframes(KONG_STAND_7, 1.0, 0, 20.0)
  82.         playframes(KONG_STAND_8, 1.0, 0, 9.0)
  83.         changestate(Kong_Boss_NormalThrow)
  84.     }
  85.     event (e, a) {
  86.         accepteventandchangestate(Kong_Boss_NormalThrow, e == EventTriggered)
  87.     }
  88. }
  89.  
  90. sub SpawnTNT(p) {
  91.     var p = p
  92.     if (p == 0) {
  93.         if (player-> x < 0) {
  94.             v0 = 3m
  95.         }
  96.         else {
  97.             v0 = -3m
  98.         }
  99.         spawn(34, 16, 1, 5m, 60, v0, y, 4.5m) // BoxsC - 16
  100.     }
  101.     else if (p == 1.0) {
  102.         if (health >= 2.0) {
  103.             spawn(34, 16, 1, 5m, 60, 0, y, 4.5m) // BoxsC - 16
  104.         }
  105.     }
  106.     else if (p == 2.0 || p == 3.0) {
  107.         if (health >= 4.0) {
  108.             v0 = 0 - v0
  109.             spawn(34, 16, 1, 5m, 60, v0, y, 4.5m) // BoxsC - 16
  110.         }
  111.     }
  112. }
  113.  
  114. state Kong_Boss_NormalThrow {
  115.     statusc 0
  116.     code () {
  117.         /* set speed towards the right to 2.5x remaining length */
  118.         if (pathprog < pathlen + 1) {
  119.             velx = (pathlen - pathprog) * 30 / 12
  120.             playframes(KONG_HOP, 1.0, 0.0, 15.0)
  121.         }
  122.         velx = 0
  123.         {
  124.         var boulders = 0
  125.         do {
  126.             /* pick up a rock fast */
  127.             playframes(KONG_LIFT_1, 2.0, 0, 14.0)
  128.             playframe(animframe, 0.15s)
  129.             playframes(KONG_LIFT_2, 2.0, 0, 21.0)
  130.             playframes(KONG_LIFT_3, 2.0, 0, 23.0)
  131.             playframes(KONG_THROW_1, 2.0, 0, 20.0)
  132.             playframes(KONG_THROW_2, 1.0, 0, 19.0)
  133.             interrupter = objectget(13.0) // get object ID 13 (expecting KonOC object)
  134.             sendevent(Event27, interrupter, interrupter, x, modeb, boulders) // send an event to spawn a rock using the selected object's spline
  135.             SpawnTNT(boulders)
  136.             sounddecay(0.375)
  137.             soundpitch(3.6 + rand(0.8))
  138.             soundplay([jmp0A], 12.8 + rand(12.8))
  139.             playframes(KONG_THROW_3, 2.0, 0, 17.0)
  140.             boulders += 1.0
  141.         } while (boulders < 3.0)
  142.         }
  143.         /* pick up a rock slowly */
  144.         playframes(KONG_LIFT_1, 1.0, 0, 14.0)
  145.         playframe(animframe, 0.4s)
  146.         playframes(KONG_LIFT_2, 1.0, 0, 21.0)
  147.         playframes(KONG_LIFT_3, 1.0, 0, 23.0)
  148.         statetime = frametime
  149.         velx = -2.0
  150.         {
  151.         var walktime = 1.8s + rand(4.2s), step = 1.0
  152.         do {
  153.             SpawnTNT(step)
  154.             step += 1.0
  155.             playframes(KONG_WALK, 1.0, 0, 14.0)
  156.         } until (frametime - statetime >= walktime)
  157.         }
  158.         changestate(Kong_Boss_HeavyThrow)
  159.     }
  160.     event (e, a) {
  161.         if (e == EventHit) {
  162.             acceptevent()
  163.             sendevent(EventHit, interrupter, 0, 1)
  164.         }
  165.     }
  166.     trans {
  167.         if (!STATUS_FIRSTFRAME) {
  168.             /* progress along path */
  169.             pathprog = spd(pathprog, velx)
  170.             if (pathprog >= pathlen) {
  171.                 pathprog = pathlen - 1
  172.             }
  173.             calcpath()
  174.         }
  175.     }
  176. }
  177.  
  178. state Kong_Boss_HeavyThrow {
  179.     statusc 0
  180.     code () {
  181.         /* throw rock and go back to standing state */
  182.         playframes(KONG_THROW_1, 1.0, 0, 20.0)
  183.         playframes(KONG_THROW_2, 1.0, 0, 19.0)
  184.         interrupter = objectget(11.0) // get object ID 11 (expecting KonOC object)
  185.         sendevent(Event27, interrupter, interrupter, x, modeb, 1) // send an event to spawn a rock using the selected object's spline
  186.         sounddecay(0.375)
  187.         soundpitch(3.6 + rand(0.8))
  188.         soundplay([jmp0A], 12.8 + rand(12.8))
  189.         playframes(KONG_THROW_3, 1.0, 0, 17.0)
  190.         changestate(Kong_Stand)
  191.     }
  192.     event (e, a) {
  193.         if (e == EventHit) {
  194.             acceptevent()
  195.             sendevent(EventHit, interrupter, 0, 1)
  196.         }
  197.     }
  198. }
  199.  
  200. state Kong_Hit {
  201.     statusc 0
  202.     stateflag 0x3
  203.     code () {
  204.         /* become red */
  205.         setcolor(0xFF, 21)
  206.         setcolor(0x80, 22)
  207.         setcolor(0x80, 23)
  208.         setcolor(0xFF, 12)
  209.         setcolor(0x80, 13)
  210.         setcolor(0x80, 14)
  211.         setcolor(0xFF, 15)
  212.         setcolor(0x80, 16)
  213.         setcolor(0x80, 17)
  214.         setcolor(0xFF, 18)
  215.         setcolor(0x80, 19)
  216.         setcolor(0x80, 20)
  217.         sendevent(EventHit, interrupter, 0, 0)
  218.         health += 1.0
  219.         GVAR_1 = health
  220.         changestateif(Kong_Dead, health >= 4.0)
  221.         sounddecay(0.5625)
  222.         soundpitch(1.92 + rand(0.32))
  223.         soundplay([hit0A], 64.0 - 1)
  224.         playframes(KONG_HIT_1, 1.0, 0, 13.0)
  225.         playframes(KONG_HIT_2, 1.0, 0, 15.0)
  226.         /* become normal-colored */
  227.         setcolor(0xFF, 21)
  228.         setcolor(0xFF, 22)
  229.         setcolor(0xFF, 23)
  230.         setcolor(0xFF, 12)
  231.         setcolor(0xFF, 13)
  232.         setcolor(0xFF, 14)
  233.         setcolor(0xFF, 15)
  234.         setcolor(0xFF, 16)
  235.         setcolor(0xFF, 17)
  236.         setcolor(0xFF, 18)
  237.         setcolor(0xFF, 19)
  238.         setcolor(0xFF, 20)
  239.         /* Dead animations will play instead of Hit animations when on the last hit point,
  240.          * therefore we unload the Hit animations and load the Dead ones for use later
  241.          */
  242.         if (health >= 3.0) {
  243.             deloadfile([Kh1xV])
  244.             deloadfile([KS1xG])
  245.             deloadfile([Kh2xV])
  246.             deloadfile([KS1xG])
  247.             loadfile([KD1xV])
  248.             loadfile([KS1xG])
  249.             loadfile([KD2xV])
  250.             loadfile([KS1xG])
  251.             loadstate = 1.0
  252.         }
  253.         changestate(Kong_Boss_NormalThrow)
  254.     }
  255. }
  256.  
  257. state Kong_Dead {
  258.     statusc 0
  259.     stateflag 0x21
  260.     code () {
  261.         /* fall back, play sound and win boss */
  262.         entitysetspawn(0)
  263.         playframes(KONG_DIE_1, 1.0, 0, 17.0)
  264.         sounddecay(0.625)
  265.         soundpitch(3.6 + rand(0.8))
  266.         sounddelay(0.36s)
  267.         soundplay([BSlaA], 64.0 - 1)
  268.         playframes(KONG_DIE_2, 1.0, 0, 17.0)
  269.         sendevent(EventBossWin, player, 0, 0)
  270.         while (true) playframe(animframe, 2.1s);
  271.     }
  272. }
  273.  
  274. event Event19 => (e) {
  275.     /* deload selected assets. unknown object to send this event (boss win cleanup?) */
  276.     var loadstate = loadstate
  277.     if (loadstate == 0) {
  278.         deloadfile([Kh1xV])
  279.         deloadfile([KS1xG])
  280.         deloadfile([Kh2xV])
  281.         deloadfile([KS1xG])
  282.     }
  283.     else if (loadstate == 1.0) {
  284.         deloadfile([KD1xV])
  285.         deloadfile([KS1xG])
  286.         deloadfile([KD2xV])
  287.         deloadfile([KS1xG])
  288.     }
  289. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement