ZoriaRPG

Digging Game for Judasrising [v0.6]

Apr 8th, 2018
49
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //////////////////////////////////
  2. /// Digging Game for ZC 2.50.2 ///
  3. /// for JudasRising            ///
  4. /// By: ZoriaRPG               ///
  5. /// v0.6                       ///
  6. /// 8th April, 2018            ///
  7. //////////////////////////////////
  8.  
  9. const int I_SHOVEL          = 100; //Item ID of shovel item.
  10.  
  11. const int MISC_GAMES            = 5; //Link->Misc[]
  12. const int GT_SHOVEL             = 1; //bit for Link->Misc[MISC_GAMES]
  13.  
  14. const int SHOVELGAME_D = 6;  // Screen->D[] Register
  15. const int SHOVELGAME_BIT =; // Bit used by D[] register.
  16.  
  17.  
  18. const int SHOVEL_GAME_RUNNING       = 0; //index for shovelgame[]
  19. const int SHOVEL_GAME_TIMER         = 1; //index for shovelgame[]
  20. const int SHOVEL_GAME_ACTIVE        = 2; //index for shovelgame[]
  21. const int SHOVEL_GAME_HAS_SHOVEL    = 3; //index for shovelgame[]
  22. const int SHOVEL_GAME_PREV_B_ITEM   = 4; //index for shovelgame[]
  23.  
  24. const int SHOVEL_GAME_LINE_Y        = 50; //Y position of invisible line.
  25.  
  26. const int SHOVEL_GAME_TIMER_X       = 90; //Timer X diaplsy position.
  27. const int SHOVEL_GAME_TIMER_Y       = 16; //Timer Y display position.
  28. const int SHOVEL_GAME_TIMER_SIZE_X  = 32; //Timer text character width. Warning: This was BROKEN in 2.50.2 and earlier!
  29. const int SHOVEL_GAME_TIMER_SIZE_Y  = 32; //Timer text character height. Warning: This was BROKEN in 2.50.2 and earlier!
  30. const int SHOVEL_GAME_TIMER_FONT    = 1; //Z3
  31. const int SHOVEL_GAME_TIMER_LAYER   = 6;
  32. const int SHOVEL_GAME_TIMER_COLOUR  = 0x01; //white
  33. const int SHOVEL_GAME_TIMER_VALUE   = 15; //DEFAULT
  34.  
  35. const int SHOVEL_GAME_MESSAGE_GAMEOVER  = 90; //The message to display when the game ends.
  36.  
  37. const int SHOVEL_GAME_GUY_DISTX     = 10; //Max disance from guy ffc.
  38. const int SHOVEL_GAME_GUY_DISTY     = 10; //Max disance from guy ffc.
  39. const int SHOVEL_GAME_COST      = 60;   //Default cost.
  40.  
  41. //Which buttons to allow to press to activate the menu.
  42. //1 to allow, 0 to disallow.
  43. const int SHOVEL_GAME_BUTTON_A      = 1;
  44. const int SHOVEL_GAME_BUTTON_B      = 1;
  45. const int SHOVEL_GAME_BUTTON_L      = 1;
  46. const int SHOVEL_GAME_BUTTON_R      = 1;
  47. const int SHOVEL_GAME_BUTTON_EX1    = 1;
  48. const int SHOVEL_GAME_BUTTON_EX2    = 1;
  49. const int SHOVEL_GAME_BUTTON_EX3    = 1;
  50. const int SHOVEL_GAME_BUTTON_EX4    = 1;
  51.  
  52. //const int SHOVEL_GAME_
  53. //const int SHOVEL_GAME_
  54. //const int SHOVEL_GAME_
  55. //const int SHOVEL_GAME_
  56.  
  57.  
  58. //Place this ffc on the screen, and give it the data of am NPC. Place over a solid combo.
  59. ffc script ShovelGame
  60. {
  61.     //D0: Game duration timer (in seconds!). Defaults to 15.
  62.     //D1: Cost to play in Rupees
  63.     void run(int time, int cost)
  64.     {
  65.        
  66.         int shovelgame[256];
  67.         //0 == timer
  68.         //1 == running
  69.         //2 == active
  70.         //3 == has the shovel in inventory
  71.         shovelgame[SHOVEL_GAME_ACTIVE] = 1;
  72.         shovelgame[SHOVEL_GAME_HAS_SHOVEL] = Link->Item[I_SHOVEL];
  73.         cost = Cond(cost > 0, cost, SHOVEL_GAME_COST);
  74.         while(shovelgame[SHOVEL_GAME_ACTIVE])
  75.         {
  76.             //The NPC here is set by the FFC data:
  77.             //If below or to the right of him
  78.             if ( _DG_Below(this) || _DG_RightOf(this) )
  79.             {
  80.                 //if Link is facing the guy
  81.                 if ( _DG_Facing(this, DIR_DOWN) || _DG_Facing(this, DIR_Right) )
  82.                 {
  83.                     //and within a set distance
  84.                     if ( _DG_DistX(Link->X, this->X, SHOVEL_GAME_GUY_DISTX) )
  85.                     {
  86.                         if ( _DG_DistY(Link->Y, this->Y, SHOVEL_GAME_GUY_DISTX) )
  87.                         {
  88.                             //and presses the correct button
  89.                             if ( PressShovelGameButton() )
  90.                             {
  91.                                 //create yes/no tango menu
  92.                                 //if menu returns (1) then the game is running
  93.                                 shovelgame[SHOVEL_GAME_RUNNING] = ShovelGameMenu(cost);
  94.                             }
  95.                         }
  96.                     }
  97.                 }
  98.             }
  99.            
  100.            
  101.             //while runnning
  102.             while(shovelgame[SHOVEL_GAME_RUNNING])
  103.             {
  104.                 //if Link doesnt have the shovel, give it to him here:
  105.                
  106.                 if ( !shovelgame[SHOVEL_GAME_HAS_SHOVEL] )
  107.                 {
  108.                     if ( !Link->Item[I_SHOVEL] ) Link->Item[I_SHOVEL] = true;
  109.                     //Set the shovel as the active B item.
  110.                     if ( GetEquipmentB() |= I_SHOVEL )
  111.                     {
  112.                         if ( GetEquipmentA() != I_SHOVEL )
  113.                         {
  114.                             shovelgame[SHOVEL_GAME_PREV_B_ITEM] = GetEquipmentB();
  115.                             SetShovelToB(); //Set the shovel to B every frame if not already on A!
  116.                         }
  117.                     }
  118.                 }
  119.                 //wait for Link to cross the invisible line
  120.                 do
  121.                 {
  122.                     continue;
  123.                 } while(Link->Y < SHOVEL_GAME_LINE_Y );
  124.                
  125.                 //once he does...
  126.                
  127.                 shovelgame[SHOVEL_GAME_TIMER] = Cond(time > 0, time, SHOVEL_GAME_TIMER_VALUE); //set the timer
  128.                 shovelgame[SHOVEL_GAME_TIMER] *= 60; //make it frames.
  129.                
  130.                 //Begin the game
  131.                 IsShovelGame(true); //set game running
  132.                 while(shovelgame[SHOVEL_GAME_TIMER]-- > -1 ) //This check is in frames; the display is in seconds.
  133.                 {
  134.                     //while the timer is above -1
  135.                
  136.                     //display the game time.
  137.                    
  138.                
  139.                     Screen->DrawInteger
  140.                         (SHOVEL_GAME_TIMER_LAYER, SHOVEL_GAME_TIMER_X, SHOVEL_GAME_TIMER_Y,                
  141.                             SHOVEL_GAME_TIMER_FONT, SHOVEL_GAME_TIMER_COLOUR, 0,
  142.                             SHOVEL_GAME_TIMER_SIZE_X, SHOVEL_GAME_TIMER_SIZE_Y,
  143.                             ((shovelgame[SHOVEL_GAME_TIMER]/60) << 0), 0, 128);
  144.                
  145.                    
  146.                     Waitframe(); continue;
  147.                     //if the timer expires, end the game.
  148.                 }
  149.            
  150.                 shovelgame[SHOVEL_GAME_RUNNING] = 0;
  151.                 Waitframe(); continue;
  152.             }
  153.        
  154.             //Game is over.
  155.            
  156.             //Show a message
  157.             Screen->Message(SHOVEL_GAME_MESSAGE_GAMEOVER);
  158.             //set game off
  159.             IsShovelGame(false);
  160.            
  161.             //take the shovel away if Link does not own one.
  162.            
  163.             if ( !shovelgame[SHOVEL_GAME_HAS_SHOVEL] )
  164.             {
  165.                 if ( Link->Item[I_SHOVEL] ) Link->Item[I_SHOVEL] = false;
  166.                 //Set the shovel as the active B item.
  167.             }
  168.            
  169.             Waitframe(); continue;
  170.         }
  171.        
  172.         //if you want the guy to say something else, or if you want to offer a new game,
  173.         //then, you could do that.
  174.        
  175.     }  
  176.  
  177.  
  178.    //ffc functions
  179.  
  180.  
  181.      bool _DG_DistY(ffc a, int distance)
  182.      {
  183.          int dist;
  184.          if ( a->Y > Link->Y ) dist = a->Y - Link->Y;
  185.           else dist = Link->Y - a->Y;
  186.          return ( dist <= distance );
  187.      }
  188.  
  189.      bool _DG_Below(ffc n){ return Link->Y > n->Y; }
  190.      bool _DG_RightOf(ffc n){ return Link->X > n->X; }
  191.  
  192.      bool _DG_Facing (ffc f, int ffc_dir)
  193.      {
  194.            if ( ffc_dir == DIR_UP && Link->Y < f->Y ) return true;
  195.            if ( ffc_dir == DIR_DOWN && Link->Y > f->Y ) return true;
  196.            if ( ffc_dir == DIR_RIGHT && Link->X > f->X ) return true;
  197.            if ( ffc_dir == DIR_LEFT && Link->X < f->X ) return true;
  198.            return false;
  199.      }
  200.  
  201.  
  202.      bool _DG_DistX(ffc a, int distance)
  203.      {
  204.          int dist;
  205.          if ( a->X > Link->X ) dist = a->X - Link->X;
  206.                else dist = Link->X - a->X;
  207.          return ( dist <= distance );
  208.       }
  209.  
  210.       bool PressShovelGameButton()
  211.       {
  212.              if ( SHOVEL_GAME_BUTTON_A && Link->PressA )
  213.              {
  214.                  Link->PressA = false; Link->InputA = false; return true;
  215.              }
  216.              if ( SHOVEL_GAME_BUTTON_B && Link->PressB )
  217.              {
  218.                  Link->PressB = false; Link->InputB = false; return true;
  219.              }
  220.              if ( SHOVEL_GAME_BUTTON_L && Link->PressL )
  221.              {
  222.                  Link->PressL = false; Link->InputL = false; return true;
  223.              }
  224.              if ( SHOVEL_GAME_BUTTON_R && Link->PressR )
  225.              {
  226.                  Link->PressR = false; Link->InputR = false; return true;
  227.              }
  228.              if ( SHOVEL_GAME_BUTTON_EX1 && Link->PressEx1 )
  229.              {
  230.                  Link->PressEx1 = false; Link->InputEx1 = false; return true;
  231.           }
  232.              if ( SHOVEL_GAME_BUTTON_EX2 && Link->PressEx2 )
  233.              {
  234.                  Link->PressEx2 = false; Link->InputEx2 = false; return true;
  235.              }
  236.              if ( SHOVEL_GAME_BUTTON_EX3 && Link->PressEx3 )
  237.              {
  238.                  Link->PressEx3 = false; Link->InputEx3 = false; return true;
  239.              }
  240.              if ( SHOVEL_GAME_BUTTON_EX4 && Link->PressEx4 )
  241.              {
  242.                  Link->PressEx4 = false; Link->InputEx4 = false; return true;
  243.              }
  244.              return false;
  245.          }
  246.        
  247.     }
  248.  
  249.     void SetShovelToB()
  250.     {
  251.        
  252.         int ___end = GetEquipmentB();
  253.         do Link->SelectBWeapon(DIR_RIGHT);
  254.         while(GetEquipmentB() != I_SHOVEL && GetEquipmentB() != ___end );
  255.     }
  256.     //The 'yes/no' menu called by the ffc.
  257.     int ShovelGameMenu(int cost)
  258.     {
  259.         Tango_D[0] = cost; //We store a game variable in the Tango_D array, so that we can reference it inside the menu.
  260.    
  261.         int lineBreak[]="@26";
  262.         int line1[]="@choice(1)Play the shovel game for @tab(8)@number(@d0) rupees?@26";
  263.         int line2[]="@choice(2)Not interested.@domenu(1)@suspend()";
  264.        
  265.         SetUpWindow(WINDOW_SLOT_1, WINDOW_STYLE_3, 32, 32, SIZE_LARGE);
  266.         Tango_LoadString(WINDOW_SLOT_1, line1);
  267.         Tango_AppendString(WINDOW_SLOT_1, line2);
  268.         Tango_ActivateSlot(WINDOW_SLOT_1);
  269.  
  270.        
  271.         while(!Tango_MenuIsActive())
  272.         {
  273.        
  274.             Waitframe();
  275.         }
  276.        
  277.         // Save the state again...
  278.         int slotState[278];
  279.         int menuState[960];
  280.         int cursorPos;
  281.         Tango_SaveSlotState(WINDOW_SLOT_1, slotState);
  282.         Tango_SaveMenuState(menuState);
  283.        
  284.         int done = 0;
  285.         int choice;
  286.         int ret;
  287.         while(!done){
  288.        
  289.             while( Tango_MenuIsActive() )
  290.             {
  291.                 cursorPos=Tango_GetMenuCursorPosition();
  292.                 Waitframe();
  293.             }
  294.        
  295.             choice = Tango_GetLastMenuChoice();
  296.             if ( choice == 1 ) // play the game
  297.             {
  298.                 if ( Game->Counter[CR_RUPEES] < cost )
  299.                 {
  300.                     ret = 0;
  301.                     done = 1;
  302.                 }
  303.                 else
  304.                 {
  305.                     Game->DCounter[CR_RUPEES] -= cost;
  306.                     ret = 1;
  307.                     done = 1;
  308.                 }
  309.             }
  310.             else if ( choice == 2 ) //not interested.
  311.             {
  312.                 ret = 0;
  313.                 menuArg = choice;
  314.                 done = 1;
  315.             }
  316.        
  317.            
  318.             else done = 1;
  319.  
  320.             if ( done )
  321.             {
  322.                 break;
  323.             }
  324.             else
  325.             {
  326.                 Tango_RestoreSlotState(WINDOW_SLOT_1, slotState);
  327.                 Tango_RestoreMenuState(menuState);
  328.                 Tango_SetMenuCursorPosition(cursorPos);
  329.             }
  330.         }
  331.        
  332.         Tango_ClearSlot(WINDOW_SLOT_1);
  333.         return ret;
  334.     }
  335. }
  336.  
  337. //Huzzah, this script now uses a way more practical injection model for usage! ~Lunaria
  338.  
  339. //The combo type for generic digging on overworld.
  340. const int Shovel_ComboType = 143;   //Script 2 (143) is default for this.
  341.  
  342.  
  343. //The flag to dig on to trigger secrets. (Does not need to be on a digable combo type!)
  344. const int Shovel_SecretFlag = 99;   //General Purpose 2  (99) is default for this.
  345.  
  346.  
  347. //Digging on proper combos will change the combo to this one:
  348. const int Shovel_DugCombo = 969;        //Change to 0 to use the screens undercombo instead.
  349.  
  350.  
  351. //Start of 8 combos in a row for the dig animation. (Up 1, Down 1, Left 1, Right 1, Up 2, Down 2, Left 2, Right 2)
  352. const int Shovel_Anima_Start = 3780;
  353. //Start of 4 combos for the dirt clut
  354. const int Shovel_FlyingDirt = 3788;
  355.  
  356.  
  357.  
  358. //FFC slot for the shovel script. This now uses an FFC slot because fancier animation, woo!
  359. const int Shovel_FFC_Script = 168;
  360.  
  361.  
  362. // This is the sound to be played when you successfully dig.
  363. const int Shovel_Sound = 74;
  364. // The sound to be played when you attempt to dig an undiggable combo.
  365. const int Shovel_Fail = 101;
  366. // The secret sound to be played when you dig a secret.
  367. const int Shovel_SecretSFX = 27;
  368.  
  369. item script Shovel{
  370.     void run(){
  371.         int s_dig[]="Shovel_Diggy";
  372.         int s_dig_game[]="Shovel_Diggy_Game";
  373.         int useScript = Cond(IsShovelGame(), s_dig_game, s_dig);
  374.         if(Link->Z > 0) return;
  375.         //int args[] = {103,0,0,0,0,0,0,0};
  376.         RunFFCScript(useScript, NULL);
  377.        
  378.        
  379.     }
  380. }
  381.  
  382.  
  383. ffc script Shovel_Diggy_Game{
  384.   void run(){
  385.     int chance;
  386.     int itemdrop;
  387.     int itemlocx;
  388.     int itemlocy;
  389.     // Link->Action=LA_ATTACKING;
  390.    
  391.     item ShovelLoot;
  392.    
  393.     bool DigSuccess = false;
  394.    
  395.     int DigComboX;
  396.     int DigComboY;
  397.     if(Link->Dir == 0){
  398.         DigComboX = Link->X + 8;
  399.         DigComboY = Link->Y - 2;
  400.     }
  401.     else if(Link->Dir == 1){
  402.         DigComboX = Link->X + 8;
  403.         DigComboY = Link->Y + 18;
  404.     }
  405.     else if(Link->Dir == 2){
  406.         DigComboX = Link->X - 2;
  407.         DigComboY = Link->Y + 8;
  408.     }
  409.     else if(Link->Dir == 3){
  410.         DigComboX = Link->X + 18;
  411.         DigComboY = Link->Y + 8;
  412.     }
  413.    
  414.     int DigComboX2 = ComboAt(DigComboX,DigComboY) % 16;
  415.     DigComboX2 = DigComboX2 * 16;
  416.     int DigComboY2 = ComboAt(DigComboX,DigComboY) / 16;
  417.     DigComboY2 = Floor(DigComboY2);
  418.     DigComboY2 = DigComboY2 * 16;
  419.    
  420.    
  421.     for(int i; i != 10; i ++){
  422.         Link->Invisible = true;
  423.        
  424.         Screen->FastCombo(2, Link->X, Link->Y, Shovel_Anima_Start + Link->Dir, 6, OP_OPAQUE);
  425.         NoAction();
  426.        
  427.         Waitframe();
  428.         Link->Invisible = false;
  429.     }
  430.  
  431.    
  432.     if(Screen->ComboT[ComboAt(DigComboX,DigComboY)] != Shovel_ComboType
  433.     && Screen->ComboI[ComboAt(DigComboX,DigComboY)] != Shovel_SecretFlag
  434.     && Screen->ComboF[ComboAt(DigComboX,DigComboY)] != Shovel_SecretFlag){
  435.        Game->PlaySound(Shovel_Fail);
  436.     }
  437.     else{
  438.        
  439.        Game->PlaySound(Shovel_Sound);
  440.        DigSuccess = true;
  441.        
  442.        chance=Rand(100)+1;
  443.        
  444.        if(Screen->ComboT[ComboAt(DigComboX,DigComboY)] == Shovel_ComboType && Screen->ComboI[ComboAt(DigComboX,DigComboY)] == Shovel_SecretFlag){
  445.            
  446.            Screen->ComboD[ComboAt(DigComboX,DigComboY)] = Screen->UnderCombo;
  447.            chance = 101;
  448.            
  449.        }
  450.        else if(Screen->ComboF[ComboAt(DigComboX,DigComboY)] == Shovel_SecretFlag || Screen->ComboI[ComboAt(DigComboX,DigComboY)] == Shovel_SecretFlag){
  451.            Game->PlaySound(Shovel_SecretSFX);
  452.            Screen->TriggerSecrets();
  453.            Screen->State[ST_SECRET] = true;
  454.            chance = 101;
  455.        }
  456.        else{
  457.            Screen->ComboD[ComboAt(DigComboX,DigComboY)] = Screen->UnderCombo;
  458.            
  459.            if(Shovel_DugCombo > 0){
  460.                Screen->ComboD[ComboAt(DigComboX,DigComboY)] = Shovel_DugCombo;
  461.            }
  462.        }
  463.    
  464.     //The drops for the special shovel game are defined in the function ShovelDigItem();
  465.        itemdrop = ShovelDigItem();
  466.  
  467.        if(Link->Dir==0){    //Spawn location
  468.            itemlocx=Link->X;
  469.            itemlocy=Link->Y-16;
  470.        }
  471.        if(Link->Dir==1){
  472.            itemlocx=Link->X;
  473.            itemlocy=Link->Y+16;
  474.        }
  475.        if(Link->Dir==2){
  476.            itemlocx=Link->X-16;
  477.            itemlocy=Link->Y;
  478.        }
  479.        if(Link->Dir==3){
  480.            itemlocx=Link->X+16;
  481.            itemlocy=Link->Y;
  482.        }
  483.  
  484.        if(itemdrop != -999){
  485.            ShovelLoot=Screen->CreateItem(itemdrop);
  486.            ShovelLoot->X=itemlocx;
  487.            ShovelLoot->Y=itemlocy;
  488.            ShovelLoot->Z=2;
  489.            ShovelLoot->Jump = 2;
  490.            ShovelLoot->Pickup=IP_TIMEOUT;
  491.        }
  492.     }
  493.    
  494.     int shovel_item_dir = Link->Dir;
  495.     int DirtClutX = DigComboX2;
  496.     int DirtClutY = DigComboY2;
  497.    
  498.    
  499.     for(int i; i != 10; i ++){
  500.         Link->Invisible = true;
  501.        
  502.         Screen->FastCombo(2, Link->X, Link->Y, Shovel_Anima_Start + 4 + Link->Dir, 6, OP_OPAQUE);
  503.         NoAction();
  504.        
  505.         if(i < 5){
  506.            
  507.             if(shovel_item_dir == 0)DirtClutY --;
  508.             if(shovel_item_dir == 1 && i % 2 == 0)DirtClutY ++;
  509.            
  510.             //sideways
  511.             if(shovel_item_dir > 1)DirtClutY --;
  512.             if(shovel_item_dir == 3)DirtClutX = DigComboX + (i / 2);
  513.             if(shovel_item_dir == 2)DirtClutX = DigComboX - (i / 2);
  514.            
  515.         }
  516.         else{
  517.            
  518.             if(shovel_item_dir == 0 && i % 2 == 0)DirtClutY --;
  519.             if(shovel_item_dir == 1)DirtClutY ++;
  520.            
  521.             //sideways
  522.             if(shovel_item_dir > 1)DirtClutY ++;
  523.             if(shovel_item_dir == 3)DirtClutX = DigComboX + (i / 2);
  524.             if(shovel_item_dir == 2)DirtClutX = DigComboX - (i / 2);
  525.            
  526.         }
  527.         if(DigSuccess)Screen->FastCombo(2, DirtClutX, DirtClutY, Shovel_FlyingDirt + shovel_item_dir, 6, OP_OPAQUE);
  528.        
  529.        
  530.         if(Screen->ComboS[ComboAt(ShovelLoot->X + 8, ShovelLoot->Y + 8)] == 0){
  531.            
  532.             if(shovel_item_dir == 0)ShovelLoot->Y --;
  533.             else if(shovel_item_dir == 1)ShovelLoot->Y ++;
  534.             else if(shovel_item_dir == 2)ShovelLoot->X --;
  535.             else if(shovel_item_dir == 3)ShovelLoot->X ++;
  536.            
  537.         }
  538.        
  539.        
  540.         Waitframe();
  541.         Link->Invisible = false;
  542.     }
  543.    
  544.     while(ShovelLoot->Z > 0){
  545.        
  546.         if(Screen->ComboS[ComboAt(ShovelLoot->X + 8, ShovelLoot->Y + 8)] == 0){
  547.            
  548.             if(shovel_item_dir == 0)ShovelLoot->Y --;
  549.             else if(shovel_item_dir == 1)ShovelLoot->Y ++;
  550.             else if(shovel_item_dir == 2)ShovelLoot->X --;
  551.             else if(shovel_item_dir == 3)ShovelLoot->X ++;
  552.            
  553.         }
  554.        
  555.         Waitframe();
  556.        
  557.     }
  558.    
  559.   }
  560.  
  561.   //These tables define the prizes to award during the DIGGING GAME! -Z
  562.   int ShovelDigItem()
  563.     {
  564.         int prizeChances[100]=
  565.         {
  566.             //Define shovel game prizes, here.
  567.             0,0,0,0,0,0,0,0,0,0,
  568.             2,2,2,2,2,2,2,2,2,2,
  569.             34,34,34,
  570.             1,1,1,1,1,
  571.             87,-999, //29
  572.             //30
  573.             -999,-999,-999,-999,-999,-999,-999,-999,-999,-999,
  574.             //40
  575.             -999,-999,-999,-999,-999,-999,-999,-999,-999,-999,
  576.             //50
  577.             -999,-999,-999,-999,-999,-999,-999,-999,-999,-999,
  578.             //60
  579.             -999,-999,-999,-999,-999,-999,-999,-999,-999,-999,
  580.             //70
  581.             -999,-999,-999,-999,-999,-999,-999,-999,-999,-999,
  582.             //80
  583.             -999,-999,-999,-999,-999,-999,-999,-999,-999,-999,
  584.             //90
  585.             -999,-999,-999,-999,-999,-999,-999,-999,-999,-999
  586.         };
  587.         int specialPrizeChances[100]=
  588.         {
  589.             //Define special prizes here.
  590.             0,0,0,0,0,0,0,0,0,0,
  591.             2,2,2,2,2,2,2,2,2,2,
  592.             34,34,34,
  593.             1,1,1,1,1,
  594.             87,-999, //29
  595.             //30
  596.             -999,-999,-999,-999,-999,-999,-999,-999,-999,-999,
  597.             //40
  598.             -999,-999,-999,-999,-999,-999,-999,-999,-999,-999,
  599.             //50
  600.             -999,-999,-999,-999,-999,-999,-999,-999,-999,-999,
  601.             //60
  602.             -999,-999,-999,-999,-999,-999,-999,-999,-999,-999,
  603.             //70
  604.             -999,-999,-999,-999,-999,-999,-999,-999,-999,-999,
  605.             //80
  606.             -999,-999,-999,-999,-999,-999,-999,-999,-999,-999,
  607.             //90
  608.             -999,-999,-999,-999,-999,-999,-999,-999,-999,-999
  609.         };
  610.         if ( !GetScreenDBit(SHOVELGAME_D, SHOVELGAME_BIT) )
  611.             return specialPrizeChances[Rand(0,99)];
  612.         else return prizeChances[Rand(0,99)];
  613.     }
  614. }
  615.  
  616. //Normal, non-digging-game, script. (Unchanged) -Z
  617. ffc script Shovel_Diggy{
  618.   void run(){
  619.     int chance;
  620.     int itemdrop;
  621.     int itemlocx;
  622.     int itemlocy;
  623.     // Link->Action=LA_ATTACKING;
  624.    
  625.     item ShovelLoot;
  626.    
  627.     bool DigSuccess = false;
  628.    
  629.     int DigComboX;
  630.     int DigComboY;
  631.     if(Link->Dir == 0){
  632.         DigComboX = Link->X + 8;
  633.         DigComboY = Link->Y - 2;
  634.     }
  635.     else if(Link->Dir == 1){
  636.         DigComboX = Link->X + 8;
  637.         DigComboY = Link->Y + 18;
  638.     }
  639.     else if(Link->Dir == 2){
  640.         DigComboX = Link->X - 2;
  641.         DigComboY = Link->Y + 8;
  642.     }
  643.     else if(Link->Dir == 3){
  644.         DigComboX = Link->X + 18;
  645.         DigComboY = Link->Y + 8;
  646.     }
  647.    
  648.     int DigComboX2 = ComboAt(DigComboX,DigComboY) % 16;
  649.     DigComboX2 = DigComboX2 * 16;
  650.     int DigComboY2 = ComboAt(DigComboX,DigComboY) / 16;
  651.     DigComboY2 = Floor(DigComboY2);
  652.     DigComboY2 = DigComboY2 * 16;
  653.    
  654.    
  655.     for(int i; i != 10; i ++){
  656.         Link->Invisible = true;
  657.        
  658.         Screen->FastCombo(2, Link->X, Link->Y, Shovel_Anima_Start + Link->Dir, 6, OP_OPAQUE);
  659.         NoAction();
  660.        
  661.         Waitframe();
  662.         Link->Invisible = false;
  663.     }
  664.  
  665.    
  666.     if(Screen->ComboT[ComboAt(DigComboX,DigComboY)] != Shovel_ComboType
  667.     && Screen->ComboI[ComboAt(DigComboX,DigComboY)] != Shovel_SecretFlag
  668.     && Screen->ComboF[ComboAt(DigComboX,DigComboY)] != Shovel_SecretFlag){
  669.        Game->PlaySound(Shovel_Fail);
  670.     }
  671.     else{
  672.        
  673.        Game->PlaySound(Shovel_Sound);
  674.        DigSuccess = true;
  675.        
  676.        chance=Rand(100)+1;
  677.        
  678.        if(Screen->ComboT[ComboAt(DigComboX,DigComboY)] == Shovel_ComboType && Screen->ComboI[ComboAt(DigComboX,DigComboY)] == Shovel_SecretFlag){
  679.            
  680.            Screen->ComboD[ComboAt(DigComboX,DigComboY)] = Screen->UnderCombo;
  681.            chance = 101;
  682.            
  683.        }
  684.        else if(Screen->ComboF[ComboAt(DigComboX,DigComboY)] == Shovel_SecretFlag || Screen->ComboI[ComboAt(DigComboX,DigComboY)] == Shovel_SecretFlag){
  685.            Game->PlaySound(Shovel_SecretSFX);
  686.            Screen->TriggerSecrets();
  687.            Screen->State[ST_SECRET] = true;
  688.            chance = 101;
  689.        }
  690.        else{
  691.            Screen->ComboD[ComboAt(DigComboX,DigComboY)] = Screen->UnderCombo;
  692.            
  693.            if(Shovel_DugCombo > 0){
  694.                Screen->ComboD[ComboAt(DigComboX,DigComboY)] = Shovel_DugCombo;
  695.            }
  696.        }
  697.        
  698.         //Drop ratio is the current number minus the last one.
  699.        if(chance<=10){      //10%
  700.            itemdrop = 0;    //1 rupee
  701.        }
  702.        else if(chance<=20){ //10%
  703.            itemdrop = 2;    //Recovery heart
  704.        }
  705.        else if(chance<=23){ //3%
  706.            itemdrop = 34;   //Fairy
  707.        }
  708.        else if(chance<=27){ //4%
  709.            itemdrop = 1;    //5 Rupee
  710.        }
  711.        else if(chance<=28){ //1%
  712.            itemdrop = 87;   //100 Rupee
  713.        }
  714.        else{
  715.            itemdrop = - 999;    //No item drop
  716.        }
  717.  
  718.        if(Link->Dir==0){    //Spawn location
  719.            itemlocx=Link->X;
  720.            itemlocy=Link->Y-16;
  721.        }
  722.        if(Link->Dir==1){
  723.            itemlocx=Link->X;
  724.            itemlocy=Link->Y+16;
  725.        }
  726.        if(Link->Dir==2){
  727.            itemlocx=Link->X-16;
  728.            itemlocy=Link->Y;
  729.        }
  730.        if(Link->Dir==3){
  731.            itemlocx=Link->X+16;
  732.            itemlocy=Link->Y;
  733.        }
  734.  
  735.        if(itemdrop != -999){
  736.            ShovelLoot=Screen->CreateItem(itemdrop);
  737.            ShovelLoot->X=itemlocx;
  738.            ShovelLoot->Y=itemlocy;
  739.            ShovelLoot->Z=2;
  740.            ShovelLoot->Jump = 2;
  741.            ShovelLoot->Pickup=IP_TIMEOUT;
  742.        }
  743.     }
  744.    
  745.     int shovel_item_dir = Link->Dir;
  746.     int DirtClutX = DigComboX2;
  747.     int DirtClutY = DigComboY2;
  748.    
  749.    
  750.     for(int i; i != 10; i ++){
  751.         Link->Invisible = true;
  752.        
  753.         Screen->FastCombo(2, Link->X, Link->Y, Shovel_Anima_Start + 4 + Link->Dir, 6, OP_OPAQUE);
  754.         NoAction();
  755.        
  756.         if(i < 5){
  757.            
  758.             if(shovel_item_dir == 0)DirtClutY --;
  759.             if(shovel_item_dir == 1 && i % 2 == 0)DirtClutY ++;
  760.            
  761.             //sideways
  762.             if(shovel_item_dir > 1)DirtClutY --;
  763.             if(shovel_item_dir == 3)DirtClutX = DigComboX + (i / 2);
  764.             if(shovel_item_dir == 2)DirtClutX = DigComboX - (i / 2);
  765.            
  766.         }
  767.         else{
  768.            
  769.             if(shovel_item_dir == 0 && i % 2 == 0)DirtClutY --;
  770.             if(shovel_item_dir == 1)DirtClutY ++;
  771.            
  772.             //sideways
  773.             if(shovel_item_dir > 1)DirtClutY ++;
  774.             if(shovel_item_dir == 3)DirtClutX = DigComboX + (i / 2);
  775.             if(shovel_item_dir == 2)DirtClutX = DigComboX - (i / 2);
  776.            
  777.         }
  778.         if(DigSuccess)Screen->FastCombo(2, DirtClutX, DirtClutY, Shovel_FlyingDirt + shovel_item_dir, 6, OP_OPAQUE);
  779.        
  780.        
  781.         if(Screen->ComboS[ComboAt(ShovelLoot->X + 8, ShovelLoot->Y + 8)] == 0){
  782.            
  783.             if(shovel_item_dir == 0)ShovelLoot->Y --;
  784.             else if(shovel_item_dir == 1)ShovelLoot->Y ++;
  785.             else if(shovel_item_dir == 2)ShovelLoot->X --;
  786.             else if(shovel_item_dir == 3)ShovelLoot->X ++;
  787.            
  788.         }
  789.        
  790.        
  791.         Waitframe();
  792.         Link->Invisible = false;
  793.     }
  794.    
  795.     while(ShovelLoot->Z > 0){
  796.        
  797.         if(Screen->ComboS[ComboAt(ShovelLoot->X + 8, ShovelLoot->Y + 8)] == 0){
  798.            
  799.             if(shovel_item_dir == 0)ShovelLoot->Y --;
  800.             else if(shovel_item_dir == 1)ShovelLoot->Y ++;
  801.             else if(shovel_item_dir == 2)ShovelLoot->X --;
  802.             else if(shovel_item_dir == 3)ShovelLoot->X ++;
  803.            
  804.         }
  805.        
  806.         Waitframe();
  807.        
  808.     }
  809.    
  810.   }
  811. }
  812.  
  813. ffc script Shovel_SP_DigPoint{
  814.     void run(int Replace_Combo, int Replace_CSet, int Secret_Item){
  815.        
  816.         //  just script a FFC as "dig point" that changes it's combo to something specific when dug
  817.         //  probably the best solution
  818.         //  since you could define on the fly what you'd want it to be
  819.        
  820.        
  821.         if(Screen->State[ST_SECRET] == false){
  822.            
  823.            
  824.         }
  825.         else{
  826.            
  827.            
  828.            
  829.         }
  830.        
  831.     }
  832. }
  833.  
  834. //Returns if the digging game is active. Used to communicate with other scripts.
  835. bool IsShovelGame()
  836. {
  837.     return (Link->Misc[MISC_GAMES]&GT_SHOVEL);
  838. }
  839.  
  840. //Sets a global condition via Link->Misc.
  841. void IsShovelGame(bool s)
  842. {
  843.     if ( s )
  844.     {
  845.         Link->Misc[MISC_GAMES] |= GT_SHOVEL;
  846.     }
  847.     else    Link->Misc[MISC_GAMES] |= ~GT_SHOVEL;
  848. }
  849.  
  850. //Clears all games from Link->Misc. Call after run() in the active script.
  851. void ClearLinkMiscGames()
  852. {
  853.     Link->Misc[MISC_GAMES] = 0;
  854. }
  855.  
  856. //global script active
  857. //  void run()
  858. //  {
  859. //      ClearLinkMiscGames(); //Put it here!
  860. //
RAW Paste Data