Advertisement
ZoriaRPG

Shadowblitz: debug DrawInt

Jan 10th, 2017
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 6.67 KB | None | 0 0
  1.  
  2.  
  3.     //import "std.zh"
  4.      
  5.     const int S_NORUPEES = 7;  //Message saying 'Not enough rupees'
  6.     const int S_THANKS   = 31; //Message saying 'Thanks for buying'
  7.     const int S_INVISABLE_COMBO  = 65279;
  8.     const int S_LINK_CARRY_TILE  = 34792;
  9.     const int S_LINK_CARRY_SPEED = 8;
  10.      
  11.     ffc script FFC_NPC{
  12.         void run(int msg, int sfx, int defdir, int dist, int ffcnumber, int input){
  13.             ffc NPC = this;
  14.             if(ffcnumber != 0) Screen->LoadFFC(ffcnumber);
  15.             NPC->Misc[0] = NPC->Data;
  16.             if(dist == 0) dist = 40;
  17.            
  18.             while(true){
  19.                 SetGraphic(NPC,defdir,dist);
  20.                 if(CanTalk(NPC,input)){
  21.                     SetInput(input,false);
  22.                     if(sfx != 0) Game->PlaySound(sfx);
  23.                     Screen->Message(msg);
  24.                 }
  25.                 Waitframe();
  26.             }
  27.         }
  28.         bool CanTalk(ffc NPC,int input){
  29.             return (SelectPressInput(input) && Abs(NPC->X-Link->X) < 24 && Abs(NPC->Y-Link->Y) < 24 && Link->Z == 0);
  30.         }
  31.         void SetGraphic(ffc NPC, int defdir, int dist){
  32.             int dx = NPC->X-Link->X; int ax = Abs(dx);
  33.             int dy = NPC->Y-Link->Y; int ay = Abs(dy);
  34.             if(defdir != 0){
  35.                 if(ax < dist && ay < dist){
  36.                     if(ax <= ay){
  37.                         if(dy >= 0) NPC->Data = NPC->Misc[0]+DIR_UP;
  38.                         else NPC->Data = NPC->Misc[0]+DIR_DOWN;
  39.                     }else{
  40.                         if(dx >= 0) NPC->Data = NPC->Misc[0]+DIR_LEFT;
  41.                         else NPC->Data = NPC->Misc[0]+DIR_RIGHT;
  42.                     }
  43.                 }else NPC->Data = NPC->Misc[0]+(defdir-1);
  44.             }
  45.         }
  46.     }
  47.      
  48.      
  49.     ffc script SecretSFX
  50.     {
  51.         void run(int playsound)
  52.         {
  53.         Game->PlaySound(playsound);
  54.         }
  55.     }
  56.      
  57.      
  58.     ffc script FFC_Shop{
  59.         void run(int tileoffset, int itm, int price, int info, int input){
  60.             int origTile = this->Data;
  61.             int origX    = this->X;
  62.             int origY    = this->Y;
  63.             int origCSet = this->CSet;
  64.             int pickedUp = 0;
  65.             int pickedUpFrame = 0;
  66.             int pickedUpDelay = 0;
  67.             while(true)
  68.             {
  69.                 if (pickedUp == 0)
  70.                 {
  71.             int ss[]="Tracing price: "; TraceS(ss); Trace(price);
  72.                     Screen->DrawInteger(3, this->X + 0,  this->Y -  12, FONT_MATRIX, 8, -1, 16, 16,  price, 0, 128);
  73.                     if (info > 0) Screen->DrawInteger(3, this->X + 16, this->Y +  8, FONT_MATRIX, 8, -1, 16, 16,   info, 0, 128);
  74.                     if(CanPick(input, origX, origY))
  75.                     {
  76.                         SetInput(0, 0);
  77.                         SetInput(1, 0);
  78.                         pickedUp = 1;
  79.                         this->Data = S_INVISABLE_COMBO;
  80.                         pickedUpFrame = 0;
  81.                     }
  82.                 }
  83.                 else
  84.                 {
  85.                
  86.                     SetInput(0, 0);
  87.                     SetInput(1, 0);
  88.                     if (Link->Action == LA_NONE)
  89.                     {
  90.                         pickedUpFrame = 0;
  91.                         pickedUpDelay = 0;
  92.                     }
  93.                     else
  94.                     {
  95.                         if (pickedUpDelay <= 0)
  96.                         {
  97.                             pickedUpFrame = (pickedUpFrame + 1) % 2;
  98.                             pickedUpDelay = 16;
  99.                         }
  100.                         else
  101.                             pickedUpDelay --;
  102.                     }
  103.                     Link->Invisible = true;
  104.                     Screen->FastTile(3, Link->X, Link->Y, S_LINK_CARRY_TILE + Link->Dir * 2 + Floor(pickedUpFrame), 6, 128);
  105.                     Screen->FastCombo(3, Link->X, Link->Y - 16, origTile + tileoffset, origCSet, 128);
  106.                     this->X = Link->X;
  107.                     this->Y = Link->Y - 8;
  108.                    
  109.                     if(CanPick(input, origX, origY))
  110.                     {
  111.                         SetInput(0, 0);
  112.                         SetInput(1, 0);
  113.                         Link->Invisible = false;
  114.                         pickedUp = 0;
  115.                         this->X  = origX;
  116.                         this->Y  = origY;
  117.                         this->Data = origTile;
  118.                     }
  119.                 }
  120.                 if (Link->Action != LA_NONE && Link->Action != LA_WALKING)
  121.                 {
  122.                     Link->Invisible = false;
  123.                     pickedUp = 0;
  124.                     this->X  = origX;
  125.                     this->Y  = origY;
  126.                     this->Data = origTile;
  127.                 }
  128.                 Waitframe();
  129.             }
  130.         }
  131.     }
  132.      
  133.     bool CanPick(int input, int x, int y)
  134.     {
  135.         return (Abs(Link->X-x) < 16 && Abs(Link->Y-(y+16)) < 8 && SelectPressInput(input) && Link->Dir == DIR_UP);
  136.     }
  137.      
  138.      
  139.     int GetFFCID(ffc ff){
  140.         int q; ffc f;
  141.         for ( q = 1; q <= 32; q++ ) {
  142.             f = Screen->LoadFFC(q);
  143.             if ( f == ff ) return q;
  144.         }
  145.     }
  146.     void ShopItemThanks(int itm){
  147.         Screen->Message(S_THANKS);
  148.         Game->PlaySound(SFX_SCALE);
  149.         WaitNoAction();
  150.         CreatePickupItem(Link->X,Link->Y,itm);
  151.         Game->PlaySound(SFX_PICKUP);
  152.         WaitNoAction();
  153.     }
  154.     void CreatePickupItem(int x, int y, int itm){
  155.         item Spawn = Screen->CreateItem(itm);
  156.         Spawn->Pickup |= (IP_TIMEOUT|IP_HOLDUP);
  157.         Spawn->HitWidth = 16; Spawn->HitHeight = 16;
  158.         Spawn->X = x; Spawn->Y = y;
  159.     }
  160.      
  161.     void DeductRupees(int amount){
  162.         FreezeScreen();
  163.         for(int i=0;i<amount;i++){
  164.             Game->PlaySound(SFX_MSG);
  165.             Game->Counter[CR_RUPEES]--;
  166.         Waitframe();
  167.         }
  168.         UnFreeze();
  169.     }
  170.      
  171.     int FreezeID;
  172.     void FreezeScreen(){
  173.         FreezeID = Screen->ComboT[0];
  174.         Screen->ComboT[0] = CT_SCREENFREEZE;
  175.     }
  176.     void UnFreeze(){
  177.         Screen->ComboT[0] = FreezeID;
  178.     }
  179.      
  180.     //These functions should only be included in your script file once
  181.     bool SelectPressInput(int input){
  182.         if(input == 0) return Link->PressA;
  183.         else if(input == 1) return Link->PressB;
  184.         else if(input == 2) return Link->PressL;
  185.         else if(input == 3) return Link->PressR;
  186.     }
  187.     void SetInput(int input, bool state){
  188.         if(input == 0) Link->InputA = state;
  189.         else if(input == 1) Link->InputB = state;
  190.         else if(input == 2) Link->InputL = state;
  191.         else if(input == 3) Link->InputR = state;
  192.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement