Advertisement
ZoriaRPG

Bomb Arrows for 2.55, v0.2

Mar 19th, 2019
480
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.55 KB | None | 0 0
  1. //Bomb Arrow Script for 2.55
  2. //v0.2
  3. //By ZoriaRPG
  4. //19th March, 2019
  5.  
  6. //v0.1 : Initial
  7. //v0.2 : Fix comppile, and fix how we check if the arrow is dead to create the explosion.
  8. //     : We cannot run the explosion after while(this->isValid()), because the script runs out of scope if the
  9. //     : sprite is no longer on the screen. Thus, we check its deadstate, while it is valid.
  10.  
  11. lweapon script bombarrow
  12. {
  13.     void run()
  14.     {
  15.        
  16.         itemdata bomb; bool found; bool super; int x; int y; int pow;
  17.         bomb = Game->LoadItemData(Link->ItemA);
  18.         if ( bomb->Family == IC_BOMB ) found = true;
  19.         if ( bomb->Family == IC_SBOMB ) { found = true; super = true; }
  20.         if ( !found )
  21.         {
  22.             bomb = Game->LoadItemData(Link->ItemB);
  23.             if ( bomb->Family == IC_BOMB ) { found = true; }
  24.             if ( bomb->Family == IC_SBOMB ) { found = true; super = true; }
  25.         }
  26.         if ( !found ) Quit(); //quit if bombs not in a slot
  27.         else
  28.         {
  29.             pow = bomb->Power;
  30.             if ( super )
  31.             {
  32.                 if ( !Game->Counter[CR_SBOMBS] ) Quit(); //quit if not enough bombs
  33.                 else --Game->Counter[CR_SBOMBS];
  34.             }
  35.             else
  36.             {
  37.                 if ( !Game->Counter[CR_BOMBS] ) Quit(); //quit if not enough bombs
  38.                 else --Game->Counter[CR_BOMBS];
  39.             }
  40.         }
  41.        
  42.        
  43.         while(this->isValid())
  44.         {
  45.             x = this->X; y = this->Y;
  46.            
  47.             if ( this->DeadState != WDS_ALIVE ) //When the arrow itself dies, make an explosion.
  48.             {
  49.                 lweapon boom = Screen->CreateLWeapon( (( super ) ? LW_SBOMBBLAST : LW_BOMBBLAST ));
  50.                 boom->Damage = pow;
  51.                 boom->X = x;
  52.                 boom->Y = y;
  53.             }
  54.            
  55.             Waitframe();
  56.         }
  57.        
  58.     }
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement