Demonlink

Spinnut.z by Lejes

Apr 15th, 2020
38
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.60 KB | None | 0 0
  1. // Necessary headers, uncomment (remove "//") if you haven't already imported these.
  2. //import "std.zh"
  3. //import "string.zh"
  4. //import "ghost.zh"
  5.  
  6. const int SPRITE_NULL = 93; // A sprite with a blank tile. Tile 0 is NOT a blank tile.
  7. const int TILE_SPINNUT_SWORD = 28782; // The tile of the Spinnut's sword. Only a single tile is needed, a sword with its blade pointing right.
  8. const int CSET_SPINNUT_SWORD = 7; // Default CSet of Spinnut's sword. Flashes through CSets 7 through 9 while charging spin attack.
  9. const int SFX_SPINNUT_READY = 35; // SFX played when starting charge for spin attack.
  10. const int SFX_SPINNUT_GO = 54; // SFX played when starting spin attack.
  11.  
  12. // ENEMY MISC. ATTRIBUTES
  13. // Misc. Attribute 1: How long Spinnut stops before it begins charging its sword.
  14. // Misc. Attribute 2: How long Spinnut charges its sword before spinning.
  15. // Misc. Attribute 3: How long Spinnut spins.
  16. ffc script Spinnut
  17. {
  18. void run(int enemyID)
  19. {
  20. npc ghost = Ghost_InitAutoGhost(this, enemyID);
  21. Ghost_SetFlag(GHF_SET_DIRECTION);
  22.  
  23. int counter = -1;
  24. float angle;
  25. int sword_tile_x;
  26. int sword_tile_y;
  27. int sword_flash = 7;
  28. int halt_time = ghost->Attributes[0]; // Set to 60 for demo purposes.
  29. int charge_time = ghost->Attributes[1]; // Set to 120 for demo purposes.
  30. int spin_time = ghost->Attributes[2]; // Set to 240 for demo purposes.
  31.  
  32. while (true)
  33. {
  34. // Arbitrarily large number used for halt time argument, since Spinnut does something else after halt_time frames anyway.
  35. counter = Ghost_HaltingWalk4(counter, ghost->Step, ghost->Rate, ghost->Homing, ghost->Hunger, ghost->Haltrate, 65535);
  36.  
  37. if (counter == 65535 - halt_time)
  38. {
  39. counter = 15;
  40. Game->PlaySound(SFX_SPINNUT_READY);
  41. if (Ghost_Dir == DIR_UP)
  42. {
  43. angle = 270;
  44. }
  45. if (Ghost_Dir == DIR_DOWN)
  46. {
  47. angle = 90;
  48. }
  49. if (Ghost_Dir == DIR_LEFT)
  50. {
  51. angle = 180;
  52. }
  53. if (Ghost_Dir == DIR_RIGHT)
  54. {
  55. angle = 0;
  56. }
  57. sword_tile_x = Ghost_X + (12 * Cos(angle));
  58. sword_tile_y = Ghost_Y + (12 * Sin(angle));
  59. for (int i = 0; i < charge_time; i++)
  60. {
  61. Screen->DrawTile(2, sword_tile_x, sword_tile_y, TILE_SPINNUT_SWORD, 1, 1, sword_flash, -1, -1, sword_tile_x, sword_tile_y, angle, 0, true, OP_OPAQUE);
  62. if (i % 3 == 0)
  63. {
  64. sword_flash = (((sword_flash - 7) + 1) % 3) + 7;
  65. }
  66. Spinnut_Sword(sword_tile_x, sword_tile_y, ghost->WeaponDamage, angle);
  67. Ghost_Waitframe(this, ghost);
  68. }
  69. Game->PlaySound(SFX_SPINNUT_GO);
  70.  
  71. for (int i = 0; i < spin_time; i++)
  72. {
  73. Ghost_MoveTowardLink(ghost->Step * 0.01, 2);
  74. Ghost_Dir = AngleDir4(WrapDegrees(angle));
  75.  
  76. sword_tile_x = Ghost_X + (12 * Cos(angle));
  77. sword_tile_y = Ghost_Y + (12 * Sin(angle));
  78.  
  79. Spinnut_Sword(sword_tile_x, sword_tile_y, ghost->WeaponDamage, angle);
  80.  
  81. Screen->DrawTile(2, sword_tile_x, sword_tile_y, TILE_SPINNUT_SWORD, 1, 1, CSET_SPINNUT_SWORD, -1, -1, sword_tile_x, sword_tile_y, angle, 0, true, OP_OPAQUE);
  82. angle = (angle + 24) % 360;
  83. if (i % 15 == 0)
  84. {
  85. Game->PlaySound(SFX_SPINATTACK);
  86. }
  87. Ghost_Waitframe(this, ghost);
  88. }
  89. }
  90.  
  91. Ghost_Waitframe(this, ghost);
  92. }
  93. }
  94. }
  95.  
  96. // The Spinnut's big sword.
  97. void Spinnut_Sword(int sword_tile_x, int sword_tile_y, int damage, int angle)
  98. {
  99. eweapon sword = FireNonAngularEWeapon(EW_SCRIPT1, sword_tile_x, sword_tile_y, Ghost_Dir, 0, damage, SPRITE_NULL, 0, EWF_UNBLOCKABLE);
  100. SetEWeaponLifespan(sword, EWL_TIMER, 1);
  101. SetEWeaponDeathEffect(sword, EWD_VANISH, 0);
  102. sword->Dir = AngleDir8(WrapDegrees(angle));
  103. }
Add Comment
Please, Sign In to add comment