Advertisement
ZoriaRPG

Bobomb NPC Script v0,.2

Mar 5th, 2019
189
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.34 KB | None | 0 0
  1. import "std.zh"
  2.  
  3. //////////////////////////////////
  4. /// BobOmb for 2.55            ///
  5. /// By: ZoriaRPG               ///
  6. /// 5th May, 2019              ///
  7. /// v0.2                       ///
  8. //////////////////////////////////
  9.  
  10. //v0.2 Fixed a typo in the call to isValid().
  11.  
  12. //const int NPC_BOBOMB = 177; //Moved to bobomb.ID
  13.  
  14. //Use on a walking enemy with every defence set to Stun
  15. npc script bobomb
  16. {
  17.     const int TIMER     = 14; //Misc Index to store Timer
  18.     const int CSET      = 13; //Misc Index to store CSet
  19.     const int FLASH_CSET    = 8; //Some defaults. IDK if I should auto-assign them.
  20.     const int DURATION  = 120; //Some defaults. IDK if I should auto-assign them.
  21.     const int ID        = 177; //The enemy ID. Call as bobomb.ID elsewhere, if needed.
  22.     //Damage of explosion, misc index of timer, misc index to store base cset, value fo flash cset, duration of timer
  23.     void run(int misc_timer, int misc_cset, int flash_cset)
  24.     {
  25.         itemdata id = Game->LoadItemData(I_BOMB);
  26.         int pow = (this->WeaponDamage > 0) ? (this->WeaponDamage) : id->Power;
  27.        
  28.         //Auto-assign if the user forgot to set them.
  29.         misc_timer = ( misc_timer > 0 ) ? misc_timer : TIMER;
  30.         misc_cset = ( misc_cset > 0 ) ? misc_cset : CSET;
  31.         flash_cset = ( flash_cset > 0 ) ? flash_cset : FLASH_CSET;
  32.         this->Misc[misc_timer] = -1;
  33.         while(this->isValid())
  34.         {
  35.             if ( this->Stun > 1 )
  36.             {
  37.                 //check its timer
  38.                
  39.                 switch(this->Misc[misc_timer])
  40.                 {
  41.                     case -1:
  42.                     {
  43.                         //uninitialised
  44.                         this->Misc[misc_timer] = 0;
  45.                         continue; //initialise and move on to case 0.
  46.                         //This is to ensure that the effect does not repeat.
  47.                     }
  48.                     case 0:
  49.                     {
  50.                         //its not yet flashing, so set its timer.
  51.                         this->Misc[misc_timer] = DURATION;  //This is the duration of the flash, not the explosion.
  52.                         this->Misc[misc_cset] = this->CSet;
  53.                         break;
  54.                     }
  55.                     default:
  56.                     {
  57.                         this->Misc[misc_timer]--;
  58.                         if ( !(this->Misc[misc_timer] % 5) )
  59.                         {
  60.                             //Make it flash
  61.                             this->CSet = flash_cset;
  62.                         }
  63.                         else this->CSet = this->Misc[misc_cset];
  64.                         break;
  65.                     }
  66.                 }
  67.                
  68.             }
  69.             if ( this->Stun == 1 )
  70.             {
  71.                 //time to explode
  72.                 eweapon e = Screen->CreateEWeapon(EW_SBOMBBLAST);
  73.                 e->Damage = pow;
  74.                 e->X = this->X; e->Y = this->Y;
  75.                 this->HP = -9999;
  76.             }
  77.            
  78.             Waitframe();
  79.         }
  80.     }
  81. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement