Advertisement
ZoriaRPG

Slash Combo NPCs and Landmines v0.4.2

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