Advertisement
ZoriaRPG

Bobomb NPC Script

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