BossShowerheadAI.gml 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. function boss_showerhead_ai()
  2. {
  3. image_xscale = -boss_side;
  4. switch(state)
  5. {
  6. case "AWAIT":
  7. if global.player.x <= 3/4 * room_width
  8. {
  9. state = "SPAWN";
  10. animation_spd = 0.25;
  11. lock_player();
  12. lock_door();
  13. }
  14. case "SPAWN":
  15. if image_index == 10
  16. {
  17. for(var i = 0; i < 5; i++)
  18. icd(oShockwave, x, y, 0, {delay : i * 10});
  19. screen_shake(20);
  20. }
  21. else if animation_end()
  22. {
  23. unlock_player();
  24. state = "IDLE";
  25. idle_timer = 60;
  26. }
  27. break;
  28. case "WINDUP":
  29. if animation_end()
  30. {
  31. shoot_count = 0;
  32. state = "SHOOT";
  33. set_sprite(sBossShowerheadShoot);
  34. }
  35. break;
  36. case "SHOOT":
  37. if animation_end()
  38. {
  39. var _bomb = icl(oShowerheadBomb, x, y - 64);
  40. _bomb.x_spd = -boss_side * (4 - shoot_count * 1.5);
  41. _bomb.y_spd = -10;
  42. image_index = 0;
  43. if ++shoot_count >= 3
  44. {
  45. state = "IDLE";
  46. idle_timer = 60;
  47. set_sprite(sBossShowerheadIdle);
  48. }
  49. }
  50. break;
  51. case "SLAM":
  52. if animation_end()
  53. {
  54. var _sep = 240;
  55. var _start = irandom(_sep - 1);
  56. var _x = _start;
  57. while _x < room_width
  58. {
  59. icl(oShowerheadColumn, _x, room_height);
  60. _x += _sep;
  61. }
  62. screen_shake(10);
  63. state = "IDLE";
  64. idle_timer = 60;
  65. set_sprite(sBossShowerheadIdle);
  66. }
  67. break;
  68. case "IDLE":
  69. if --idle_timer <= 0
  70. {
  71. var _next = attack_queue[attack_index];
  72. attack_index = (attack_index + 1) % array_length(attack_queue);
  73. switch(_next)
  74. {
  75. case 1:
  76. state = "WINDUP";
  77. set_sprite(sBossShowerheadWindup);
  78. break;
  79. case 2:
  80. state = "SLAM";
  81. set_sprite(sBossShowerheadSlam);
  82. break;
  83. case 3:
  84. x_spd = boss_side * retreat_spd;
  85. state = "RETREAT";
  86. set_sprite(sBossShowerheadRetreat);
  87. break;
  88. }
  89. }
  90. break;
  91. case "RETREAT":
  92. var _target = (boss_side == 1) ? anchor_r + 128 : anchor_l - 128;
  93. if (boss_side == 1 && x >= _target) || (boss_side == -1 && x <= _target)
  94. {
  95. x = _target;
  96. x_spd = -boss_side * charge_spd;
  97. state = "CHARGE";
  98. set_sprite(sBossShowerheadCharge);
  99. }
  100. break;
  101. case "CHARGE":
  102. var _target = (boss_side == 1) ? anchor_l : anchor_r;
  103. if (boss_side == 1 && x <= _target) || (boss_side == -1 && x >= _target)
  104. {
  105. x = _target;
  106. x_spd = 0;
  107. boss_side *= -1;
  108. state = "IDLE";
  109. idle_timer = 60;
  110. set_sprite(sBossShowerheadIdle);
  111. }
  112. break;
  113. }
  114. }