Advertisement
ZoriaRPG

Slash Combo NPCs and Landmines v0.4.9 (Compiles, verified)

Nov 12th, 2016
230
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 10.35 KB | None | 0 0
  1. /////////////////////////////////////////
  2. /// Slash->Next Jack-In-The-Jox Enemy ///
  3. /// and Slash->Next Z3 Landmines      ///
  4. /// 12-Nov-2016 -  v0.4.9             ///
  5. /// By: ZoriaRPG                      ///
  6. /////////////////////////////////////////
  7. /// Testers:                          ///
  8. /// JudasRising - Initial Debug Tests ///
  9. /////////////////////////////////////////
  10.  
  11. //Bush Enemy
  12.  
  13. const int I_ENEMY_SPAWN = 200; //Add this to your dropsets to allow random npc spawns from slash combos.
  14. const int NPC_GUARD_BLUE = 49;
  15. const int NPC_GUARD_GREEN = 79;
  16. const int NPC_GUARD_RED = 50;
  17.  
  18. //This array holds the enemy IDs for enemies that can be spawned by item 'I_ENEMY_SPAWN'.
  19. int ItemDropSpawnsEnemies[]={NPC_MOBLIN1, NPC_GUARD_RED, NPC_ROPE1, NPC_MOBLIN1, NPC_MOBLIN1, NPC_ZOL, NPC_STALFOS1, NPC_ROPE1, NPC_STALFOS1, NPC_GUARD_BLUE, NPC_GUARD_RED, NPC_GUARD_RED, NPC_GUARD_BLUE, NPC_ROPE2, NPC_GUARD_BLUE, NPC_GUARD_BLUE, NPC_GUARD_BLUE, NPC_GUARD_BLUE, NPC_GUARD_GREEN, NPC_GUARD_RED, NPC_DODONGO, NPC_ROPE1};
  20.  
  21. //Bush Landmine
  22.  
  23. const int I_LANDMINE = 201; //Add this to your dropsets to allow random landmines from slash combos.
  24. const int MISC_LANDMINE_TIMER = 1; //The index of item->Misc[] to use for the timer.
  25. const int LANDMINE_TIMER_DELAY = -40; //The initial value of the timer.
  26. const int LANDMINE_TIMER_DELAY_TOUCHED = -10; //A value to jump to, if the timer is less than this, and the landmine is touched.
  27. const int LANDMINE_TIMER_EXPLODE = -1; //We explode at this value.
  28.  
  29. const int LANDMINE_USE_BOMB_NOT_BOMBLAST = 0; //If set, a lit bomb will appear instead of a bombblast.
  30.  
  31. //Setting the following disables both the bombblast, and the lit boms, and allows setting up a custom weapon.
  32. const int LANDMINE_SPARKLE_SPRITE = 0; //If set, the explosion will use an different sprite and a type specified below:
  33.     //Set up a custom weapon, with hitbox sizing.
  34. const int LANDMINE_ALT_DAMAGE_EFFECT_TYPE = 140; //EW_FIRE
  35. const int LANDMINE_ALT_DAMAGE_EFFECT_HITX = 24; //EW_* Hitbox X Size
  36. const int LANDMINE_ALT_DAMAGE_EFFECT_HITXOFFSET = -8; //EW_* Hitbox X Offset
  37. const int LANDMINE_ALT_DAMAGE_EFFECT_HITY = 24; //EW_* Hitbox Y Size
  38. const int LANDMINE_ALT_DAMAGE_EFFECT_HITYOFFSET = -8; //EW_* Hitbox Y Offset
  39.  
  40. //Settings
  41. const int USE_SCREEN_FLAG_TO_PERMIT_LANDMINES = 0;
  42. const int USE_SCREEN_FLAG_TO_PERMIT_SHASH_NEXT_NPCS = 0;
  43.  
  44. const int USE_SCREEN_FLAG_TO_FORBID_LANDMINES = 0;
  45. const int USE_SCREEN_FLAG_TO_FORBID_SHASH_NEXT_NPCS = 0;
  46.  
  47. //See std_constants.zh for a list of these flags.
  48.  
  49. //Flag category
  50. const int SF_LANDMINES = 9; //SF_MISC
  51. const int SF_SLASHNEXTNPC = 9;
  52.  
  53. //Flag in the category
  54. const int SF_LANDMINE_SET = 2; //Misc_1
  55. const int SF_SLASHNEXTNPC_SET = 3;  //Misc_2
  56.  
  57. //if ( USE_SCREEN_FLAG_TO_PERMIT_LANDMINES && (Screen->Flags[SF_LANDMINES]&SF_LANDMINE_SET != 0) )
  58. //if ( USE_SCREEN_FLAG_TO_PERMIT_SHASH_NEXT_NPCS && ( Screen->Flags[SF_SLASHNEXTNPC]&SF_SLASHNEXTNPC_SET != 0 ) )
  59. //if ( USE_SCREEN_FLAG_TO_FORBID_LANDMINES && (Screen->Flags[SF_LANDMINES]&SF_LANDMINE_SET == 0) )
  60. //if ( USE_SCREEN_FLAG_TO_FORBID_SHASH_NEXT_NPCS && ( Screen->Flags[SF_SLASHNEXTNPC]&SF_SLASHNEXTNPC_SET == 0 ) )
  61.  
  62. //! Formula for statements that mesh with these options:
  63. //if ( ( !USE_SCREEN_FLAG_TO_FORBID_SHASH_NEXT_NPCS && !USE_SCREEN_FLAG_TO_PERMIT_SHASH_NEXT_NPCS ) ||
  64. //  ( ( USE_SCREEN_FLAG_TO_PERMIT_SHASH_NEXT_NPCS && (Screen->Flags[SF_SLASHNEXTNPC]&SF_SLASHNEXTNPC_SET != 0) ) ||
  65. //  ( USE_SCREEN_FLAG_TO_FORBID_SHASH_NEXT_NPCS && (Screen->Flags[SF_SLASHNEXTNPC]&SF_SLASHNEXTNPC_SET == 0) ) ) )
  66. //
  67. //if ( ( !USE_SCREEN_FLAG_TO_FORBID_LANDMINES && !USE_SCREEN_FLAG_TO_PERMIT_LANDMINES ) ||
  68. //  ( ( USE_SCREEN_FLAG_TO_PERMIT_LANDMINES && (Screen->Flags[SF_LANDMINES]&SF_LANDMINE_SET != 0) ) ||
  69. //  ( USE_SCREEN_FLAG_TO_FORBID_LANDMINES && (Screen->Flags[SF_LANDMINES]&SF_LANDMINE_SET == 0) ) ) )
  70.  
  71. //Use a specific combo as part of slash->Next instead of a dropset item.
  72. const int AUTO_LANDMINES_USE_COMBO_NOT_ITEM = 0;
  73. const int AUTO_JACKINTHEBOX_USE_COMBO_NOT_ITEM = 0;
  74.  
  75. const int SHOW_LANDMINE_TIMER = 1; //This only works if using an item for the landmine.
  76. const int FLASH_LANDMIN_TIMER_DISPLAY = 1;
  77.  
  78. const int LANDMINE_TIMER_FONT = 16; //LA
  79. const int LANDMINE_FONT_BG_COLOUR = 0x0F;
  80. const int LANDMINE_FONT_FG_COLOUR = 0x01;
  81. const int LANDMINE_FONT_FG_COLOUR_FLASH = 0x03;
  82. const int LANDMINE_FONT_FG_X_OFFSET = 17;
  83. const int LANDMINE_FONT_FG_Y_OFFSET = 18;
  84. const int LANDMINE_FONT_BG_X_OFFSET = 16;
  85. const int LANDMINE_FONT_BG_Y_OFFSET = 17;
  86. const int LANDMINE_FONT_WIDTH = 4;
  87. const int LANDMINE_FONT_HEIGHT = 4;
  88. const int LANDMINE_FONT_OPACITY = 128;
  89. const int LANDMINE_FONT_LAYER = 1;
  90. const int LANDMINE_TIMER_DISPLAY_DIVISOR = 10;
  91. const int LANDMINE_TIMER_FLASH_TIMING = 4;
  92.  
  93.  
  94. void ItemSpawnsEnemyOrLandmine(){
  95.     for ( int q = Screen->NumItems(); q > 0; q-- ) {
  96.         item i = Screen->LoadItem(q);
  97.         eweapon ew; lweapon l;
  98.         if ( i->ID == I_ENEMY_SPAWN ) {
  99.             if ( ( !USE_SCREEN_FLAG_TO_FORBID_SHASH_NEXT_NPCS && !USE_SCREEN_FLAG_TO_PERMIT_SHASH_NEXT_NPCS ) ||
  100.                 ( ( USE_SCREEN_FLAG_TO_PERMIT_SHASH_NEXT_NPCS && ScreenFlag(SF_SLASHNEXTNPC,SF_SLASHNEXTNPC_SET) ) ||
  101.                 ( USE_SCREEN_FLAG_TO_FORBID_SHASH_NEXT_NPCS && !ScreenFlag(SF_SLASHNEXTNPC,SF_SLASHNEXTNPC_SET) ) )
  102.             ) {
  103.                 i->HitXOffset = -200;
  104.                 npc n = Screen->CreateNPC( ItemDropSpawnsEnemies[Rand(SizeOfArray(ItemDropSpawnsEnemies))] );
  105.                 n->X = i->X; n->Y = i->Y;
  106.             }
  107.             Remove(i);
  108.         }
  109.         if ( i->ID == I_LANDMINE ) {
  110.            
  111.                
  112.             if ( ( !USE_SCREEN_FLAG_TO_FORBID_LANDMINES && !USE_SCREEN_FLAG_TO_PERMIT_LANDMINES ) ||
  113.                 ( ( USE_SCREEN_FLAG_TO_PERMIT_LANDMINES && ScreenFlag(SF_LANDMINES,SF_LANDMINE_SET) ) ||
  114.                 ( USE_SCREEN_FLAG_TO_FORBID_LANDMINES && !ScreenFlag(SF_LANDMINES,SF_LANDMINE_SET) ) )
  115.             ) {
  116.                 if ( SHOW_LANDMINE_TIMER && i->Misc[MISC_LANDMINE_TIMER] < 0 ) {
  117.                     Screen->DrawInteger( LANDMINE_FONT_LAYER, i->X + LANDMINE_FONT_BG_X_OFFSET, i->Y + LANDMINE_FONT_BG_Y_OFFSET,
  118.                         LANDMINE_TIMER_FONT, LANDMINE_FONT_BG_COLOUR, 0, LANDMINE_FONT_WIDTH, LANDMINE_FONT_HEIGHT, ( ( LANDMINE_TIMER_DELAY * -1 ) - ( i->Misc[MISC_LANDMINE_TIMER] * -1 ) ) / LANDMINE_TIMER_DISPLAY_DIVISOR,
  119.                         0, LANDMINE_FONT_OPACITY);
  120.            
  121.                     if ( !FLASH_LANDMIN_TIMER_DISPLAY ||
  122.                         FLASH_LANDMIN_TIMER_DISPLAY && ( i->Misc[MISC_LANDMINE_TIMER] * -1 ) % LANDMINE_TIMER_FLASH_TIMING != 0 )
  123.                             Screen->DrawInteger( LANDMINE_FONT_LAYER, i->X + LANDMINE_FONT_FG_X_OFFSET, i->Y + LANDMINE_FONT_FG_Y_OFFSET,
  124.                             LANDMINE_TIMER_FONT, LANDMINE_FONT_FG_COLOUR, 0, LANDMINE_FONT_WIDTH, LANDMINE_FONT_HEIGHT, ( ( LANDMINE_TIMER_DELAY * -1 ) - ( i->Misc[MISC_LANDMINE_TIMER] * -1 ) ) / LANDMINE_TIMER_DISPLAY_DIVISOR,
  125.                             0, LANDMINE_FONT_OPACITY);
  126.                    
  127.                     else Screen->DrawInteger( LANDMINE_FONT_LAYER, i->X + LANDMINE_FONT_FG_X_OFFSET, i->Y + LANDMINE_FONT_FG_Y_OFFSET,
  128.                             LANDMINE_TIMER_FONT, LANDMINE_FONT_FG_COLOUR_FLASH, 0, LANDMINE_FONT_WIDTH, LANDMINE_FONT_HEIGHT, ( ( LANDMINE_TIMER_DELAY * -1 ) - ( i->Misc[MISC_LANDMINE_TIMER] * -1 ) ) / LANDMINE_TIMER_DISPLAY_DIVISOR,
  129.                             0, LANDMINE_FONT_OPACITY);
  130.                 }
  131.                    
  132.                 if ( !i->Misc[1] ) {
  133.                     i->HitXOffset = -200;
  134.                     i->Misc[MISC_LANDMINE_TIMER] = LANDMINE_TIMER_DELAY;
  135.                 }
  136.                 if ( i->Misc[1] ) {
  137.                     if ( i->Misc[MISC_LANDMINE_TIMER] == LANDMINE_TIMER_EXPLODE ) {
  138.                         if ( LANDMINE_SPARKLE_SPRITE ) {
  139.                             l = Screen->CreateLWeapon(LW_SPARKLE);
  140.                             l->UseSprite(LANDMINE_SPARKLE_SPRITE);
  141.                             l->HitXOffset = -200;
  142.                             l->X = i->X;
  143.                             l->Y = i->Y;
  144.                            
  145.                             ew = Screen->CreateEWeapon(LANDMINE_ALT_DAMAGE_EFFECT_TYPE);
  146.                             ew->X = i->X + LANDMINE_ALT_DAMAGE_EFFECT_HITX;
  147.                             ew->Y = i->Y + LANDMINE_ALT_DAMAGE_EFFECT_HITY;
  148.                             ew->HitXOffset = LANDMINE_ALT_DAMAGE_EFFECT_HITXOFFSET;
  149.                             ew->HitYOffset = LANDMINE_ALT_DAMAGE_EFFECT_HITYOFFSET;
  150.                         }
  151.                        
  152.                         else {
  153.                             if ( LANDMINE_USE_BOMB_NOT_BOMBLAST ) ew = Screen->CreateEWeapon(EW_BOMBBLAST);
  154.                             else ew = Screen->CreateEWeapon(EW_BOMBBLAST);
  155.                             ew->X = i->X; ew->Y = i->Y;
  156.                         }
  157.                         Remove(i);
  158.                     }
  159.                     if ( i->Misc[MISC_LANDMINE_TIMER] < LANDMINE_TIMER_DELAY_TOUCHED && LinkCollision(i) ) {
  160.                         //I would prefer collision only with the lower part of Link for this, as a step trigger.
  161.                         // ew = Screen->CreateEWeapon(EW_BOMBBLAST);
  162.                         //ew->X = i->X; ew->Y = i->Y;
  163.                         //Remove(i);
  164.                         i->Misc[MISC_LANDMINE_TIMER] = LANDMINE_TIMER_DELAY_TOUCHED; //Advance the delay when touched.
  165.                     }
  166.                     else i->Misc[MISC_LANDMINE_TIMER]++;
  167.                 }
  168.             }
  169.             else Remove(i);
  170.         }
  171.     }
  172. }
  173.  
  174. void ItemSpawnsEnemy(){
  175.     for ( int q = Screen->NumItems(); q > 0; q-- ) {
  176.         item i = Screen->LoadItem(q);
  177.         if ( i->ID == I_ENEMY_SPAWN ) {
  178.             i->HitXOffset = -200;
  179.             npc n = Screen->CreateNPC( ItemDropSpawnsEnemies[Rand(SizeOfArray(ItemDropSpawnsEnemies))] );
  180.             n->X = i->X; n->Y = i->Y;
  181.         }
  182.     }
  183. }
  184.  
  185. //! Example Global Script
  186. global script BushSurpriseDemo{
  187.     void run(){
  188.         while(true){
  189.             ItemSpawnsEnemyOrLandmine();
  190.             Waitdraw();
  191.             Waitframe();
  192.         }
  193.     }
  194. }
  195.  
  196. //! FFC to manually place lndmines, or enemies.
  197. //! If you wish to manually place NPCs or Landmines to appear out of pots, or bushes, or if you do not
  198. //! want to allow these things to appear under any slash combo, use this ffc to generate them.
  199. //! Using this, you do not need to add I_LANDMINE or I_ENEMY_SPAWN to shash combo droplists, although
  200. //! you may still add either, or both, if you wish.
  201. //Set D0 as follows: -1 for random NPC from list, 0 for landmine, positive number for a specific npc (use the npc ID).
  202. //Set D1 if you use a specific npc, to set a delay before spawning it, or to add a delay into other effects.
  203. ffc script PlaceSLashNextNPC_or_Landmine{
  204.     void run(int npc_id, int comboID, int delay){
  205.         npc n; item i;
  206.         while(true){
  207.             if ( ComboAt(this->X, this->Y) == comboID ) {
  208.                 if ( npc_id > 0 ) {
  209.                     Waitframes(delay);
  210.                     n = Screen->CreateNPC(npc_id);
  211.                     n->X = this->X; n->Y = this->Y;
  212.                     Waitframe(); this->Data = 0; this->Script = 0; Quit();
  213.                 }
  214.                 if ( npc_id < 0 ) {
  215.                     Waitframes(delay);
  216.                     i = Screen->CreateItem(I_ENEMY_SPAWN);
  217.                     i->X = this->X; i->Y = this->Y;
  218.                     Waitframe(); this->Data = 0; this->Script = 0; Quit();
  219.                 }
  220.                 if ( !npc_id ) {
  221.                     Waitframes(delay);
  222.                     i = Screen->CreateItem(I_LANDMINE);
  223.                     i->X = this->X; i->Y = this->Y;
  224.                     Waitframe(); this->Data = 0; this->Script = 0; Quit();
  225.                 }
  226.                
  227.             }
  228.             Waitframe();
  229.         }
  230.     }
  231. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement