Advertisement
ZoriaRPG

Hate Spell Item (Bane Weapon) v0.3

Sep 8th, 2019
433
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.97 KB | None | 0 0
  1. //Hate Spell, v0.3; 8th August, 2019; ZoriaRPG
  2. //Spell Item to increase weapon power of a specific itemclass while the item is active.
  3. //D0: A sound to play as an error...
  4. //D1: The item class to use. Defaults to IC_SWORD.
  5. //D2: Damage Multiplier
  6.  
  7. //Item Editor Fields
  8. // Cost Counter: The counter to check.
  9. // Cost: The cost to apply per revolution.
  10. // Timer: The number of frames to wait before checking the cost.
  11.  
  12. item script hatespell
  13. {  
  14.     void run(int errSfx, int affectedItemClass, float power_multiplier)
  15.     {
  16.         int f;
  17.         bool quit_by_button_press;
  18.         affectedItemClass = ( affectedItemClass > 0 ) affectedItemClass : IC_SWORD;
  19.         power_multiplier = ( power_multiplier > 0 ) power_multiplier : 1.5000;
  20.         int tempitmpower[256];
  21.        
  22.        
  23.        
  24.         if ( Game->Counter[this->CostCounter] < this->Cost )
  25.         {
  26.             Audio->PlaySound(errSfx); Quit(); //If we can't pay the cost, quit.
  27.         }
  28.        
  29.         for ( int q = 0; q < 256; ++q )
  30.         {
  31.             itemdata theItem = Game->LoadItemData(q);
  32.             if ( theItem->Class == affectedItemClass )
  33.             {
  34.                 tempitmpower[q] = theItem->Power+1;
  35.                 theItem->Power *= power_multiplier;
  36.             }
  37.         }
  38.         while(1)
  39.         {
  40.             ++f;
  41.             if ( f < 0 ) f = 1; //fix underflows
  42.             unless ( ((f%this->CostTimer)) ) //every n frames, apply the cost
  43.             {
  44.                 if((Game->Counter[this->CostCounter] -= this->Cost) > 0)
  45.                 {
  46.                     Waitframe();
  47.                 }
  48.                 else break;
  49.             }
  50.             if (( Hero->PressA && Hero->ItemA == this->ID ) ||( Hero->PressB && Hero->ItemB == this->ID ) || quit_by_button_press )
  51.             {
  52.                 break; ///Using the item again, ends its effect.
  53.             }
  54.             Waitframe();
  55.         }
  56.        
  57.         Audio->PlaySound(this->UseSound); //Play the use sound again, when deactivating.
  58.         //Restore original item Power values, as the effect has ended.
  59.         for ( int q = 0; q < 256; ++q )
  60.         {
  61.             itemdata theItem = Game->LoadItemData(q);
  62.             if ( theItem->Class == affectedItemClass )
  63.             {
  64.                 if ( tempitmpower[q] )
  65.                 {
  66.                     theItem->Power = tempitmpower[q]-1;
  67.                 }
  68.             }
  69.         }  
  70.         Quit();
  71.     }
  72.        
  73. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement