Advertisement
ZoriaRPG

[Passive Item] Generic Weapon Direction Controller

Sep 16th, 2019
381
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.70 KB | None | 0 0
  1. //Script to control the child weapon of an item, mid-flight
  2. //This is a passive item script and must run as such.
  3. //v0.1, 16th September, 2019, by ZoriaRPG.
  4.  
  5. item script passive_weapon_dir_control
  6. {
  7.     void run()
  8.     {
  9.         lweapon child; int currentbutton;
  10.         for ( int q = Screen->NumLWeapons(); q > 0; --q ) //match the child weapon of this item to it
  11.         {
  12.             lweapon temp = Screen->LoadLWeapon(q);
  13.             if ( temp->Parent == this->ID )
  14.             {
  15.                 child = temp; break;
  16.             }
  17.         }
  18.         if ( !child ) Quit();
  19.         while(child->isValid())
  20.         {
  21.             if ( Hero->ItemA == this->ID )
  22.             {
  23.                 currentbutton = CB_A;
  24.             }
  25.             else if ( Hero->ItemB == this->ID )
  26.             {
  27.                 currentbutton = CB_B;
  28.             }
  29.             else currentbutton = 0;
  30.            
  31.             if ( currentbutton && Input->Button[currentbutton] )
  32.             {
  33.                 //holding down the item button
  34.                 if ( Input->Button[CB_UP] )
  35.                 {
  36.                     if ( Input->Button[CB_LEFT] )
  37.                     {
  38.                         child->Dir = DIR_LEFTUP;
  39.                     }
  40.                     else if ( Input->Button[CB_RIGHT] )
  41.                     {
  42.                         child->Dir = DIR_RIGHTUP;
  43.                     }
  44.                     else child->Dir = DIR_UP;
  45.                 }
  46.                 else if ( Input->Button[CB_DOWN] )
  47.                 {
  48.                     if ( Input->Button[CB_LEFT] )
  49.                     {
  50.                         child->Dir = DIR_LEFTDOWN;
  51.                     }
  52.                     else if ( Input->Button[CB_RIGHT] )
  53.                     {
  54.                         child->Dir = DIR_RIGHTDOWN;
  55.                     }
  56.                     else child->Dir = DIR_DOWN;
  57.             `   }
  58.                 else if ( Input->Button[CB_RIGHT] )     //'else if', so that we don't clash.
  59.                 {                   //Won't conflict with combining with up or down.
  60.                     child->Dir = DIR_RIGHT;
  61.                 }
  62.                 else if ( Input->Button[CB_LEFT] )      //'else if', so that we don't clash
  63.                 {                   //Won't conflict with combining with up or down.
  64.                     child->Dir = DIR_LEFT;
  65.                 }
  66.             }
  67.             Waitframe();
  68.         }
  69.     }
  70. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement