ZoriaRPG

Great Book of Cheating (effectively requested by Sans)

Mar 26th, 2019
149
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //////////////////////////////
  2. /// Great Book of Cheating ///
  3. /// v0.1.2 for ZC 2.55     ///
  4. /// 26th March, 2019       ///
  5. /// By: ZoriaRPG           ///
  6. //////////////////////////////
  7. /*
  8.  
  9. D[0] : The turn off / run out of energy SFX
  10. D[1] : The modulus factor for the movement speed frame timer.
  11. D[2] : The modulus factor for the upkeep cost frame timer.
  12.  
  13. Sprites[4] : The sprite for the black hole weapon.
  14. */
  15.  
  16. item script GreatBookOfCheating
  17. {
  18.     void run(int sfxoff, int speedmod, int upkeep_frames)
  19.     {
  20.         speedmod = ( speedmod > 0 ) ? speedmod : 2;
  21.         sfxoff = ( sfxoff > 0 ) ? sfxoff : 64;
  22.         Link->Invisible = true;
  23.         Link->CollDetection = false;
  24.         int frame; int dir; lweapon blackhole;
  25.         blackhole = Screen->CreateLWeapon(LW_SCRIPT);
  26.         blackhole->X = 1;
  27.         blackhole->Y = 1;
  28.         blackhole->DrawXOffset = -32768;
  29.         blackhole->DrawYOffset = -32768;
  30.         blackhole->CollDetection = false;
  31.         blackhole->Script = this->WeaponScript;
  32.         int pos;
  33.         for ( int q = 0; q < 8; ++q ) blackhole->InitD[q] = this->WeaponInitD[q];
  34.        
  35.         //sprite is blac hold from Sprites[4];
  36.         while(1)
  37.         {
  38.             //If the player taes this item out of its slot, or it is removed from inventory
  39.             //end the effect.
  40.             if ( Hero->ItemA != this->ID && Hero->ItemB != this->ID ) end(blackhole);
  41.             if ( !Hero->Item[this->ID] ) end(blackhole);
  42.             ++frame;
  43.            
  44.             if ( frame%speedmod )
  45.             {
  46.                 if ( Input->Hold[CB_UP] )
  47.                 {
  48.                     dir = DIR_UP;
  49.                     if ( Input->Hold[CB_LEFT] ) dir+=4;
  50.                     if ( Input->Hold[CB_RIGHT] ) dir+=5;
  51.                 }
  52.                 else if ( Input->Hold[CB_DOWN] )
  53.                 {
  54.                     dir = DIR_DOWN;
  55.                     if ( Input->Hold[CB_LEFT] ) dir+=5;
  56.                     if ( Input->Hold[CB_RIGHT] ) dir+=6;
  57.                 }
  58.                 else if ( Input->Hold[CB_RIGHT] )
  59.                 {
  60.                     dir = DIR_RIGHT;
  61.                 }
  62.                 else if ( Input->Hold[CB_LEFT] )
  63.                 {
  64.                     dir = DIR_LEFT;
  65.                 }
  66.                 else dir = -1;
  67.                    
  68.                 switch(dir)
  69.                 {
  70.                     case DIR_UP: --Hero->Y; break;
  71.                     case DIR_DOWN: ++Hero->Y; break;
  72.                     case DIR_LEFT: --Hero->X; break;
  73.                     case DIR_RIGHT: ++Hero->X; break;
  74.                     case DIR_LEFTUP: --Hero->X; --Hero->Y; break;
  75.                     case DIR_RIGHTUP: ++Hero->X; --Hero->Y; break;
  76.                     case DIR_LEFTDOWN: --Hero->X; ++Hero->Y; break;
  77.                     case DIR_RIGHTDOWN: ++Hero->X; ++Hero->Y; break;
  78.                     default break;
  79.                 }
  80.             }
  81.             if ( upkeep_frames > 0 ) //if we have an upeep timer
  82.             {
  83.                 if ( !(frame%upkeep_frames) ) //cost in upeep
  84.                 {
  85.                     if ( Game->Counter[this->CostCounter] < this->Cost )
  86.                     {
  87.                         end(blackhole,sfxoff);
  88.                     }
  89.                     else Game->DCounter[this->CostCounter] -= this->Cost;
  90.                 }
  91.             }
  92.             if ( Hero->ItemA == this->ID )
  93.             {
  94.                 if ( Hero->PressA ) end(blackhole,sfxoff);
  95.             }
  96.             if ( Hero->ItemB == this->ID )
  97.             {
  98.                 if ( Hero->PressB ) end(blackhole,sfxoff);
  99.             }
  100.             if ( CanWalk(Hero->X, Hero->Y, Hero->Dir, 0) ) pos = ComboAt(CenterLinkX(), CenterLinkY());
  101.             blackhole->DrawXOffset = Link->X - 1;
  102.             blackhole->DrawYOffset = Link->Y - 1;
  103.             Waitframe();
  104.         }
  105.         if ( CanWalk(Hero->X, Hero->Y, Hero->Dir, 0) )
  106.         {
  107.             //Hero is stuck in solid
  108.            
  109.             Hero->X = ComboX(pos);
  110.             Hero->Y = ComboY(pos);
  111.            
  112.             blackhole->DrawXOffset = Link->X - 1;
  113.             blackhole->DrawYOffset = Link->Y - 1;
  114.            
  115.             //or use Adjacentcombo to find the closest nonsolid and push him back out?
  116.         }
  117.     }
  118.     void end(lweapon hole, int sfxoff)
  119.     {
  120.         Link->Invisible = false;
  121.         Link->CollDetection = true;
  122.         Audio->PlaySound(sfxoff);
  123.         Remove(hole);
  124.         Quit();
  125.     }
  126. }
RAW Paste Data