Advertisement
ZoriaRPG

Slash Combo NPCs and Landmines

Oct 27th, 2016
201
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 7.82 KB | None | 0 0
  1. /////////////////////////////////////////
  2. /// Slash->Next Jack-In-The-Jox Enemy ///
  3. /// and Slash->Next Z3 Landmines      ///
  4. /// 29-Oct-2016 -  v0.3               ///
  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 = 190;
  13. const int NPC_GUARD_GREEN = 191;
  14. const int NPC_GUARD_RED = 192;
  15.  
  16. //This array holds the enemy IDs for enemies that can be spawned by item 'I_ENEMY_SPAWN'.
  17. int ItemDropSpawnsEnemies[]={NPC_MOBLIN, NPC_ZOL, NPC_STALFOS, NPC_GUARD_GREEN, NPC_GUARD_GREEN, NPC_GUARD_RED};
  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->Flag[SF_LANDMINES]&SF_LANDMINE_SET != 0) )
  56. //if ( USE_SCREEN_FLAG_TO_PERMIT_SHASH_NEXT_NPCS && ( Screen->Flag[SF_SLASHNEXTNPC]&SF_SLASHNEXTNPC_SET != 0 ) )
  57. //if ( USE_SCREEN_FLAG_TO_FORBID_LANDMINES && (Screen->Flag[SF_LANDMINES]&SF_LANDMINE_SET == 0) )
  58. //if ( USE_SCREEN_FLAG_TO_FORBID_SHASH_NEXT_NPCS && ( Screen->Flag[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->Flag[SF_SLASHNEXTNPC]&SF_SLASHNEXTNPC_SET != 0) ) ||
  63. //  ( USE_SCREEN_FLAG_TO_FORBID_SHASH_NEXT_NPCS && (Screen->Flag[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->Flag[SF_LANDMINES]&SF_LANDMINE_SET != 0) ) ||
  67. //  ( USE_SCREEN_FLAG_TO_FORBID_LANDMINES && (Screen->Flag[SF_LANDMINES]&SF_LANDMINE_SET == 0) ) ) )
  68.  
  69. void ItemSpawnsEnemyOrLandmine(){
  70.     for ( int q = Screen->NumItems(); q > 0; q-- ) {
  71.         item i = Screen->LoadItem(q);
  72.         if ( i->ID == I_ENEMY_SPAWN ) {
  73.             if ( ( !USE_SCREEN_FLAG_TO_FORBID_SHASH_NEXT_NPCS && !USE_SCREEN_FLAG_TO_PERMIT_SHASH_NEXT_NPCS ) ||
  74.                 ( ( USE_SCREEN_FLAG_TO_PERMIT_SHASH_NEXT_NPCS && (Screen->Flag[SF_SLASHNEXTNPC]&SF_SLASHNEXTNPC_SET != 0) ) ||
  75.                 ( USE_SCREEN_FLAG_TO_FORBID_SHASH_NEXT_NPCS && (Screen->Flag[SF_SLASHNEXTNPC]&SF_SLASHNEXTNPC_SET == 0) ) )
  76.             ) {
  77.                 i->HiXOffset = -200;
  78.                 npc n = Screen->CreateNPC( ItemDropSpawnsEnemies[Rand(SizeOfArray(ItemDropSpawnsEnemies))] );
  79.                 n->X = i->X; n->Y = i->Y;
  80.             }
  81.             Remove(i);
  82.         }
  83.         if ( i->ID == I_LANDMINE ) {
  84.            
  85.             if ( ( !USE_SCREEN_FLAG_TO_FORBID_LANDMINES && !USE_SCREEN_FLAG_TO_PERMIT_LANDMINES ) ||
  86.                 ( ( USE_SCREEN_FLAG_TO_PERMIT_LANDMINES && (Screen->Flag[SF_LANDMINES]&SF_LANDMINE_SET != 0) ) ||
  87.                 ( USE_SCREEN_FLAG_TO_FORBID_LANDMINES && (Screen->Flag[SF_LANDMINES]&SF_LANDMINE_SET == 0) ) )
  88.             ) {
  89.                 if ( !i->Misc[1] ) {
  90.                     i->HitXOffset = -200;
  91.                     i->Misc[MISC_LANDMINE_TIMER] = -LANDMINE_TIMER_DELAY;
  92.                 }
  93.                 if ( i->Misc[1] ) {
  94.                     if ( i->Misc[MISC_LANDMINE_TIMER] == LANDMINE_TIMER_EXPLODE ) {
  95.                         if ( LANDMINE_SPARKLE_SPRITE ) {
  96.                             lweapon l = Screen->CreateLWeapon(LW_SPARKLE);
  97.                             l->UseSprite = LANDMINE_SPARKLE_SPRITE;
  98.                             l->HitXOffset = -200;
  99.                             l->X = i->X;
  100.                             l->Y = i->Y;
  101.                            
  102.                             ew = Screen->CreateEWeapon(LANDMINE_ALT_DAMAGE_EFFECT_TYPE);
  103.                             ew->X = i->X + LANDMINE_ALT_DAMAGE_EFFECT_HITX;
  104.                             ew->Y = i->Y + LANDMINE_ALT_DAMAGE_EFFECT_HITY;
  105.                             ew->HitXOffset = LANDMINE_ALT_DAMAGE_EFFECT_HITXOFFSET;
  106.                             ew->HitYOffset = LANDMINE_ALT_DAMAGE_EFFECT_HITYOFFSET;
  107.                         }
  108.                        
  109.                         else {
  110.                             if ( LANDMINE_USE_BOMB_NOT_BOMBLAST ) eweapon ew = Screen->CreateEWeapon(EW_BOMBBLAST);
  111.                             else eweapon ew = Screen->CreateEWeapon(EW_BOMBBLAST);
  112.                             ew->X = i->X; ew->Y = i->Y;
  113.                         }
  114.                         Remove(i);
  115.                     }
  116.                     if ( i->Misc[MISC_LANDMINE_TIMER] < LANDMINE_TIMER_DELAY_TOUCHED && LinkCollision(i) ) {
  117.                         //I would prefer collision only with the lower part of Link for this, as a step trigger.
  118.                         // ew = Screen->CreateEWeapon(EW_BOMBBLAST);
  119.                         //ew->X = i->X; ew->Y = i->Y;
  120.                         //Remove(i);
  121.                         i->Misc[MISC_LANDMINE_TIMER] = LANDMINE_TIMER_DELAY_TOUCHED; //Advance the delay when touched.
  122.                     }
  123.                     else i->Misc[MISC_LANDMINE_TIMER]++;
  124.                 }
  125.             }
  126.             else Remove(i);
  127.         }
  128.     }
  129. }
  130.  
  131. void ItemSpawnsEnemy(){
  132.     for ( int q = Screen->NumItems(); q > 0; q-- ) {
  133.         item i = Screen->LoadItem(q);
  134.         if ( i->ID == I_ENEMY_SPAWN ) {
  135.             i->HiXOffset = -200;
  136.             npc n = Screen->CreateNPC( ItemDropSpawnsEnemies[Rand(SizeOfArray(ItemDropSpawnsEnemies))] );
  137.             n->X = i->X; n->Y = i->Y;
  138.         }
  139.     }
  140. }
  141.  
  142. //! Example Global Script
  143. global script BushSurpriseDemo{
  144.     void run(){
  145.         while(true){
  146.             ItemSpawnsEnemyOrLandmine();
  147.             Waitdraw();
  148.             Waitframe();
  149.         }
  150.     }
  151. }
  152.  
  153. //! FFC to manually place lndmines, or enemies.
  154. //! If you wish to manually place NPCs or Landmines to appear out of pots, or bushes, or if you do not
  155. //! want to allow these things to appear under any slash combo, use this ffc to generate them.
  156. //! Using this, you do not need to add I_LANDMINE or I_ENEMY_SPAWN to shash combo droplists, although
  157. //! you may still add either, or both, if you wish.
  158. //Set D0 as follows: -1 for random NPC from list, 0 for landmine, positive number for a specific npc (use the npc ID).
  159. //Set D1 if you use a specific npc, to set a delay before spawning it, or to add a delay into other effects.
  160. ffc script PlaceSLashNextNPC_or_Landmine{
  161.     void run(int npc_id, int comboID, int delay){
  162.         npc n; item i;
  163.         while(true){
  164.             if ( ComboAt(this->X, this->Y) == combo_ID ) {
  165.                 if ( npc_id > 0 ) {
  166.                     Waitframes(delay);
  167.                     n = Screen->CreateNPC(npc_id);
  168.                     n->X = this->X; n->Y = this->Y;
  169.                     Waitframe(); this->Data = 0; this->Script = 0; Quit();
  170.                 }
  171.                 if ( npc_id < 0 ) {
  172.                     Waitframes(delay);
  173.                     i = Screen->CreateItem(I_ENEMY_SPAWN);
  174.                     i->X = this->X; i->Y = this->Y;
  175.                     Waitframe(); this->Data = 0; this->Script = 0; Quit();
  176.                 }
  177.                 if ( !npc_id ) {
  178.                     Waitframes(delay);
  179.                     i = Screen->CreateItem(I_LANDMINE);
  180.                     i->X = this->X; i->Y = this->Y;
  181.                     Waitframe(); this->Data = 0; this->Script = 0; Quit();
  182.                 }
  183.                 Waitframe();
  184.             }
  185.         }
  186.     }
  187. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement