ZoriaRPG

Jack-in-the-Box Enemies & Zelda 3 Landmines v0.5.5 (Tested)

Nov 12th, 2016
126
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /////////////////////////////////////////
  2. /// Slash->Next Jack-In-The-Jox Enemy ///
  3. /// and Slash->Next Z3 Landmines      ///
  4. /// 12-Nov-2016 -  v0.5.5             ///
  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 = 10;
  87. const int LANDMINE_FONT_HEIGHT = 10;
  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. const int LANDMINE_BOMB_PLACEMENT_OFFSET_X = -8;
  94. const int LANDMINE_BOMB_PLACEMENT_OFFSET_Y = -8;
  95.  
  96. void ItemSpawnsEnemyOrLandmine(){
  97.     for ( int q = Screen->NumItems(); q > 0; q-- ) {
  98.         item i = Screen->LoadItem(q);
  99.         eweapon ew; lweapon l; bool proceed;
  100.         if ( i->ID == I_ENEMY_SPAWN ) {
  101.             i->Pickup = IP_DUMMY;
  102.             if ( !USE_SCREEN_FLAG_TO_FORBID_SHASH_NEXT_NPCS && !USE_SCREEN_FLAG_TO_PERMIT_SHASH_NEXT_NPCS ) proceed = true;
  103.             if ( USE_SCREEN_FLAG_TO_PERMIT_SHASH_NEXT_NPCS && ScreenFlag(SF_SLASHNEXTNPC,SF_SLASHNEXTNPC_SET) ) proceed = true;
  104.             if ( USE_SCREEN_FLAG_TO_FORBID_SHASH_NEXT_NPCS && !ScreenFlag(SF_SLASHNEXTNPC,SF_SLASHNEXTNPC_SET) ) proceed = true;
  105.             if ( proceed ) {
  106.                 npc n = Screen->CreateNPC( ItemDropSpawnsEnemies[Rand(SizeOfArray(ItemDropSpawnsEnemies))] );
  107.                 n->X = i->X; n->Y = i->Y;
  108.                 Remove(i);
  109.             }
  110.             else Remove(i);
  111.         }
  112.         if ( i->ID == I_LANDMINE ) {
  113.             i->Pickup = IP_DUMMY;
  114.                
  115.             if ( !USE_SCREEN_FLAG_TO_FORBID_LANDMINES && !USE_SCREEN_FLAG_TO_PERMIT_LANDMINES ) proceed = true;
  116.             if ( USE_SCREEN_FLAG_TO_PERMIT_LANDMINES && ScreenFlag(SF_LANDMINES,SF_LANDMINE_SET) ) proceed = true;
  117.             if ( USE_SCREEN_FLAG_TO_FORBID_LANDMINES && !ScreenFlag(SF_LANDMINES,SF_LANDMINE_SET) ) proceed = true;
  118.             if ( proceed ) {
  119.                
  120.                    
  121.                 if ( !i->Misc[MISC_LANDMINE_TIMER] ) {
  122.                     i->Misc[MISC_LANDMINE_TIMER] = LANDMINE_TIMER_DELAY;
  123.                 }
  124.                 if ( i->Misc[MISC_LANDMINE_TIMER] ) {
  125.                    
  126.                     if ( SHOW_LANDMINE_TIMER ) {
  127.                         Screen->DrawInteger( LANDMINE_FONT_LAYER, i->X + LANDMINE_FONT_BG_X_OFFSET, i->Y + LANDMINE_FONT_BG_Y_OFFSET,
  128.                             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,
  129.                             0, LANDMINE_FONT_OPACITY);
  130.                
  131.                         if ( !FLASH_LANDMIN_TIMER_DISPLAY ||
  132.                             FLASH_LANDMIN_TIMER_DISPLAY && ( i->Misc[MISC_LANDMINE_TIMER] * -1 ) % LANDMINE_TIMER_FLASH_TIMING != 0 )
  133.                                 Screen->DrawInteger( LANDMINE_FONT_LAYER, i->X + LANDMINE_FONT_FG_X_OFFSET, i->Y + LANDMINE_FONT_FG_Y_OFFSET,
  134.                                 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,
  135.                                 0, LANDMINE_FONT_OPACITY);
  136.                        
  137.                         else Screen->DrawInteger( LANDMINE_FONT_LAYER, i->X + LANDMINE_FONT_FG_X_OFFSET, i->Y + LANDMINE_FONT_FG_Y_OFFSET,
  138.                                 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,
  139.                                 0, LANDMINE_FONT_OPACITY);
  140.                     }
  141.                    
  142.                    
  143.                     if ( i->Misc[MISC_LANDMINE_TIMER] == LANDMINE_TIMER_EXPLODE ) {
  144.                         if ( LANDMINE_SPARKLE_SPRITE ) {
  145.                             l = Screen->CreateLWeapon(LW_SPARKLE);
  146.                             l->UseSprite(LANDMINE_SPARKLE_SPRITE);
  147.                             l->HitXOffset = -200;
  148.                             l->X = i->X;
  149.                             l->Y = i->Y;
  150.                            
  151.                             ew = Screen->CreateEWeapon(LANDMINE_ALT_DAMAGE_EFFECT_TYPE);
  152.                             ew->X = i->X + LANDMINE_ALT_DAMAGE_EFFECT_HITX;
  153.                             ew->Y = i->Y + LANDMINE_ALT_DAMAGE_EFFECT_HITY;
  154.                             ew->HitXOffset = LANDMINE_ALT_DAMAGE_EFFECT_HITXOFFSET;
  155.                             ew->HitYOffset = LANDMINE_ALT_DAMAGE_EFFECT_HITYOFFSET;
  156.                         }
  157.                        
  158.                         else {
  159.                             if ( LANDMINE_USE_BOMB_NOT_BOMBLAST ) ew = Screen->CreateEWeapon(EW_BOMBBLAST); //this is wrong
  160.                             else ew = Screen->CreateEWeapon(EW_BOMBBLAST);
  161.                             ew->X = i->X + LANDMINE_BOMB_PLACEMENT_OFFSET_X;
  162.                             ew->Y = i->Y + LANDMINE_BOMB_PLACEMENT_OFFSET_Y;
  163.                         }
  164.                         Remove(i);
  165.                     }
  166.                     if ( i->Misc[MISC_LANDMINE_TIMER] < LANDMINE_TIMER_DELAY_TOUCHED && LinkCollision(i) ) {
  167.                         //I would prefer collision only with the lower part of Link for this, as a step trigger.
  168.                         // ew = Screen->CreateEWeapon(EW_BOMBBLAST);
  169.                         //ew->X = i->X; ew->Y = i->Y;
  170.                         //Remove(i);
  171.                         i->Misc[MISC_LANDMINE_TIMER] = LANDMINE_TIMER_DELAY_TOUCHED; //Advance the delay when touched.
  172.                     }
  173.                     else i->Misc[MISC_LANDMINE_TIMER]++;
  174.                 }
  175.             }
  176.             else Remove(i);
  177.         }
  178.     }
  179. }
  180.  
  181. void ItemSpawnsEnemy(){
  182.     for ( int q = Screen->NumItems(); q > 0; q-- ) {
  183.         item i = Screen->LoadItem(q);
  184.         if ( i->ID == I_ENEMY_SPAWN ) {
  185.             i->HitXOffset = -200;
  186.             npc n = Screen->CreateNPC( ItemDropSpawnsEnemies[Rand(SizeOfArray(ItemDropSpawnsEnemies))] );
  187.             n->X = i->X; n->Y = i->Y;
  188.         }
  189.     }
  190. }
  191.  
  192. //! Example Global Script
  193. global script BushSurpriseDemo{
  194.     void run(){
  195.         while(true){
  196.             ItemSpawnsEnemyOrLandmine();
  197.             Waitdraw();
  198.             Waitframe();
  199.         }
  200.     }
  201. }
  202.  
  203. //! FFC to manually place lndmines, or enemies.
  204. //!!! This ffc works in conjunction with the global script. You must use the global script to generate
  205. //!!! npcs and explosions.
  206. //! If you wish to manually place NPCs or Landmines to appear out of pots, or bushes, or if you do not
  207. //! want to allow these things to appear under any slash combo, use this ffc to generate them.
  208. //! Using this, you do not need to add I_LANDMINE or I_ENEMY_SPAWN to shash combo droplists, although
  209. //! you may still add either, or both, if you wish.
  210. //Set D0 as follows: -1 for random NPC from list, 0 for landmine, positive number for a specific npc (use the npc ID).
  211. //Set D1 to the second combo of a Slash->Next pair. If a pot combo is ID 120, then this value should be 121 (broken pot).
  212. //Set D2 if you use a specific npc, to set a delay before spawning it, or to add a delay into other effects.
  213. ffc script PlaceSLashNextNPC_or_Landmine{
  214.     void run(int npc_id, int comboID, int delay){
  215.         npc n; item i;
  216.         while(true){
  217.             if ( Screen->ComboD[ComboAt(this->X, this->Y)] == comboID ) {
  218.                 if ( npc_id > 0 ) {
  219.                     Waitframes(delay);
  220.                     n = Screen->CreateNPC(npc_id);
  221.                     n->X = this->X; n->Y = this->Y;
  222.                     Waitframe(); this->Data = 0; this->Script = 0; Quit();
  223.                 }
  224.                 if ( npc_id < 0 ) {
  225.                     Waitframes(delay);
  226.                     i = Screen->CreateItem(I_ENEMY_SPAWN);
  227.                     i->Pickup = IP_DUMMY;
  228.                     i->X = this->X; i->Y = this->Y;
  229.                     Waitframe(); this->Data = 0; this->Script = 0; Quit();
  230.                 }
  231.                 if ( !npc_id ) {
  232.                     Waitframes(delay);
  233.                     i = Screen->CreateItem(I_LANDMINE);
  234.                     i->Pickup = IP_DUMMY;
  235.                     i->X = this->X; i->Y = this->Y;
  236.                     Waitframe(); this->Data = 0; this->Script = 0; Quit();
  237.                 }
  238.                
  239.             }
  240.             Waitframe();
  241.         }
  242.     }
  243. }
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×