Advertisement
ZoriaRPG

Digging Game for JudasRising [v0.4]

Apr 8th, 2018
239
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 21.02 KB | None | 0 0
  1. //////////////////////////////////
  2. /// Digging Game for ZC 2.50.2 ///
  3. /// for JudasRising            ///
  4. /// By: ZoriaRPG               ///
  5. /// v0.4                       ///
  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 SHIVELGAME_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 ( Below(this) || RightOf(this) )
  79.             {
  80.                 //if Link is facing the guy
  81.                 if ( Facing(this) )
  82.                 {
  83.                     //and within a set distance
  84.                     if ( DistX(Link->X, this->X, SHOVEL_GAME_GUY_DISTX) )
  85.                     {
  86.                         if ( 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.     bool PressShovelGameButton()
  177.     {
  178.         if ( SHOVEL_GAME_BUTTON_A && Link->PressA )
  179.         {
  180.             Link->PressA = false; Link->InputA = false; return true;
  181.         }
  182.         if ( SHOVEL_GAME_BUTTON_B && Link->PressB )
  183.         {
  184.             Link->PressB = false; Link->InputB = false; return true;
  185.         }
  186.         if ( SHOVEL_GAME_BUTTON_L && Link->PressL )
  187.         {
  188.             Link->PressL = false; Link->InputL = false; return true;
  189.         }
  190.         if ( SHOVEL_GAME_BUTTON_R && Link->PressR )
  191.         {
  192.             Link->PressR = false; Link->InputR = false; return true;
  193.         }
  194.         if ( SHOVEL_GAME_BUTTON_EX1 && Link->PressEx1 )
  195.         {
  196.             Link->PressEx1 = false; Link->InputEx1 = false; return true;
  197.         }
  198.         if ( SHOVEL_GAME_BUTTON_EX2 && Link->PressEx2 )
  199.         {
  200.             Link->PressEx2 = false; Link->InputEx2 = false; return true;
  201.         }
  202.         if ( SHOVEL_GAME_BUTTON_EX3 && Link->PressEx3 )
  203.         {
  204.             Link->PressEx3 = false; Link->InputEx3 = false; return true;
  205.         }
  206.         if ( SHOVEL_GAME_BUTTON_EX4 && Link->PressEx4 )
  207.         {
  208.             Link->PressEx4 = false; Link->InputEx4 = false; return true;
  209.         }
  210.         return false;
  211.     }
  212.        
  213.     }
  214.  
  215.     void SetShovelToB()
  216.     {
  217.        
  218.         int ___end = GetEquipmentB();
  219.         do Link->SelectBWeapon(DIR_RIGHT);
  220.         while(GetEquipmentB() != I_SHOVEL && GetEquipmentB() != ___end );
  221.     }
  222.     //The 'yes/no' menu called by the ffc.
  223.     int ShovelGameMenu(int cost)
  224.     {
  225.         Tango_D[0] = cost; //We store a game variable in the Tango_D array, so that we can reference it inside the menu.
  226.    
  227.         int lineBreak[]="@26";
  228.         int line1[]="@choice(1)Play the shovel game for @tab(8)@number(@d0) rupees?@26";
  229.         int line2[]="@choice(2)Not interested.@domenu(1)@suspend()";
  230.        
  231.         SetUpWindow(WINDOW_SLOT_1, WINDOW_STYLE_3, 32, 32, SIZE_LARGE);
  232.         Tango_LoadString(WINDOW_SLOT_1, line1);
  233.         Tango_AppendString(WINDOW_SLOT_1, line2);
  234.         Tango_ActivateSlot(WINDOW_SLOT_1);
  235.  
  236.        
  237.         while(!Tango_MenuIsActive())
  238.         {
  239.        
  240.             Waitframe();
  241.         }
  242.        
  243.         // Save the state again...
  244.         int slotState[278];
  245.         int menuState[960];
  246.         int cursorPos;
  247.         Tango_SaveSlotState(WINDOW_SLOT_1, slotState);
  248.         Tango_SaveMenuState(menuState);
  249.        
  250.         int done = 0;
  251.         int choice;
  252.         int ret;
  253.         while(!done){
  254.        
  255.             while( Tango_MenuIsActive() )
  256.             {
  257.                 cursorPos=Tango_GetMenuCursorPosition();
  258.                 Waitframe();
  259.             }
  260.        
  261.             choice = Tango_GetLastMenuChoice();
  262.             if ( choice == 1 ) // play the game
  263.             {
  264.                 if ( Game->Counter[CR_RUPEES] < cost )
  265.                 {
  266.                     ret = 0;
  267.                     done = 1;
  268.                 }
  269.                 else
  270.                 {
  271.                     Game->DCounter[CR_RUPEES] -= cost;
  272.                     ret = 1;
  273.                     done = 1;
  274.                 }
  275.             }
  276.             else if ( choice == 2 ) //not interested.
  277.             {
  278.                 ret = 0;
  279.                 menuArg = choice;
  280.                 done = 1;
  281.             }
  282.        
  283.            
  284.             else done = 1;
  285.  
  286.             if ( done )
  287.             {
  288.                 break;
  289.             }
  290.             else
  291.             {
  292.                 Tango_RestoreSlotState(WINDOW_SLOT_1, slotState);
  293.                 Tango_RestoreMenuState(menuState);
  294.                 Tango_SetMenuCursorPosition(cursorPos);
  295.             }
  296.         }
  297.        
  298.         Tango_ClearSlot(WINDOW_SLOT_1);
  299.         return ret;
  300.     }
  301. }
  302.  
  303. //Huzzah, this script now uses a way more practical injection model for usage! ~Lunaria
  304.  
  305. //The combo type for generic digging on overworld.
  306. const int Shovel_ComboType = 143;   //Script 2 (143) is default for this.
  307.  
  308.  
  309. //The flag to dig on to trigger secrets. (Does not need to be on a digable combo type!)
  310. const int Shovel_SecretFlag = 99;   //General Purpose 2  (99) is default for this.
  311.  
  312.  
  313. //Digging on proper combos will change the combo to this one:
  314. const int Shovel_DugCombo = 969;        //Change to 0 to use the screens undercombo instead.
  315.  
  316.  
  317. //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)
  318. const int Shovel_Anima_Start = 3780;
  319. //Start of 4 combos for the dirt clut
  320. const int Shovel_FlyingDirt = 3788;
  321.  
  322.  
  323.  
  324. //FFC slot for the shovel script. This now uses an FFC slot because fancier animation, woo!
  325. const int Shovel_FFC_Script = 168;
  326.  
  327.  
  328. // This is the sound to be played when you successfully dig.
  329. const int Shovel_Sound = 74;
  330. // The sound to be played when you attempt to dig an undiggable combo.
  331. const int Shovel_Fail = 101;
  332. // The secret sound to be played when you dig a secret.
  333. const int Shovel_SecretSFX = 27;
  334.  
  335. item script Shovel{
  336.     void run(){
  337.         int s_dig[]="Shovel_Diggy";
  338.         int s_dig_game[]="Shovel_Diggy_Game";
  339.         int useScript = Cond(IsShovelGame(), s_dig_game, s_dig);
  340.         if(Link->Z > 0) return;
  341.         //int args[] = {103,0,0,0,0,0,0,0};
  342.         RunFFCScript(useScript, NULL);
  343.        
  344.        
  345.     }
  346. }
  347.  
  348.  
  349. ffc script Shovel_Diggy_Game{
  350.   void run(){
  351.     int chance;
  352.     int itemdrop;
  353.     int itemlocx;
  354.     int itemlocy;
  355.     // Link->Action=LA_ATTACKING;
  356.    
  357.     item ShovelLoot;
  358.    
  359.     bool DigSuccess = false;
  360.    
  361.     int DigComboX;
  362.     int DigComboY;
  363.     if(Link->Dir == 0){
  364.         DigComboX = Link->X + 8;
  365.         DigComboY = Link->Y - 2;
  366.     }
  367.     else if(Link->Dir == 1){
  368.         DigComboX = Link->X + 8;
  369.         DigComboY = Link->Y + 18;
  370.     }
  371.     else if(Link->Dir == 2){
  372.         DigComboX = Link->X - 2;
  373.         DigComboY = Link->Y + 8;
  374.     }
  375.     else if(Link->Dir == 3){
  376.         DigComboX = Link->X + 18;
  377.         DigComboY = Link->Y + 8;
  378.     }
  379.    
  380.     int DigComboX2 = ComboAt(DigComboX,DigComboY) % 16;
  381.     DigComboX2 = DigComboX2 * 16;
  382.     int DigComboY2 = ComboAt(DigComboX,DigComboY) / 16;
  383.     DigComboY2 = Floor(DigComboY2);
  384.     DigComboY2 = DigComboY2 * 16;
  385.    
  386.    
  387.     for(int i; i != 10; i ++){
  388.         Link->Invisible = true;
  389.        
  390.         Screen->FastCombo(2, Link->X, Link->Y, Shovel_Anima_Start + Link->Dir, 6, OP_OPAQUE);
  391.         NoAction();
  392.        
  393.         Waitframe();
  394.         Link->Invisible = false;
  395.     }
  396.  
  397.    
  398.     if(Screen->ComboT[ComboAt(DigComboX,DigComboY)] != Shovel_ComboType
  399.     && Screen->ComboI[ComboAt(DigComboX,DigComboY)] != Shovel_SecretFlag
  400.     && Screen->ComboF[ComboAt(DigComboX,DigComboY)] != Shovel_SecretFlag){
  401.        Game->PlaySound(Shovel_Fail);
  402.     }
  403.     else{
  404.        
  405.        Game->PlaySound(Shovel_Sound);
  406.        DigSuccess = true;
  407.        
  408.        chance=Rand(100)+1;
  409.        
  410.        if(Screen->ComboT[ComboAt(DigComboX,DigComboY)] == Shovel_ComboType && Screen->ComboI[ComboAt(DigComboX,DigComboY)] == Shovel_SecretFlag){
  411.            
  412.            Screen->ComboD[ComboAt(DigComboX,DigComboY)] = Screen->UnderCombo;
  413.            chance = 101;
  414.            
  415.        }
  416.        else if(Screen->ComboF[ComboAt(DigComboX,DigComboY)] == Shovel_SecretFlag || Screen->ComboI[ComboAt(DigComboX,DigComboY)] == Shovel_SecretFlag){
  417.            Game->PlaySound(Shovel_SecretSFX);
  418.            Screen->TriggerSecrets();
  419.            Screen->State[ST_SECRET] = true;
  420.            chance = 101;
  421.        }
  422.        else{
  423.            Screen->ComboD[ComboAt(DigComboX,DigComboY)] = Screen->UnderCombo;
  424.            
  425.            if(Shovel_DugCombo > 0){
  426.                Screen->ComboD[ComboAt(DigComboX,DigComboY)] = Shovel_DugCombo;
  427.            }
  428.        }
  429.    
  430.     //The drops for the special shovel game are defined in the function ShovelDigItem();
  431.        itemdrop = ShovelDigItem();
  432.  
  433.        if(Link->Dir==0){    //Spawn location
  434.            itemlocx=Link->X;
  435.            itemlocy=Link->Y-16;
  436.        }
  437.        if(Link->Dir==1){
  438.            itemlocx=Link->X;
  439.            itemlocy=Link->Y+16;
  440.        }
  441.        if(Link->Dir==2){
  442.            itemlocx=Link->X-16;
  443.            itemlocy=Link->Y;
  444.        }
  445.        if(Link->Dir==3){
  446.            itemlocx=Link->X+16;
  447.            itemlocy=Link->Y;
  448.        }
  449.  
  450.        if(itemdrop != -999){
  451.            ShovelLoot=Screen->CreateItem(itemdrop);
  452.            ShovelLoot->X=itemlocx;
  453.            ShovelLoot->Y=itemlocy;
  454.            ShovelLoot->Z=2;
  455.            ShovelLoot->Jump = 2;
  456.            ShovelLoot->Pickup=IP_TIMEOUT;
  457.        }
  458.     }
  459.    
  460.     int shovel_item_dir = Link->Dir;
  461.     int DirtClutX = DigComboX2;
  462.     int DirtClutY = DigComboY2;
  463.    
  464.    
  465.     for(int i; i != 10; i ++){
  466.         Link->Invisible = true;
  467.        
  468.         Screen->FastCombo(2, Link->X, Link->Y, Shovel_Anima_Start + 4 + Link->Dir, 6, OP_OPAQUE);
  469.         NoAction();
  470.        
  471.         if(i < 5){
  472.            
  473.             if(shovel_item_dir == 0)DirtClutY --;
  474.             if(shovel_item_dir == 1 && i % 2 == 0)DirtClutY ++;
  475.            
  476.             //sideways
  477.             if(shovel_item_dir > 1)DirtClutY --;
  478.             if(shovel_item_dir == 3)DirtClutX = DigComboX + (i / 2);
  479.             if(shovel_item_dir == 2)DirtClutX = DigComboX - (i / 2);
  480.            
  481.         }
  482.         else{
  483.            
  484.             if(shovel_item_dir == 0 && i % 2 == 0)DirtClutY --;
  485.             if(shovel_item_dir == 1)DirtClutY ++;
  486.            
  487.             //sideways
  488.             if(shovel_item_dir > 1)DirtClutY ++;
  489.             if(shovel_item_dir == 3)DirtClutX = DigComboX + (i / 2);
  490.             if(shovel_item_dir == 2)DirtClutX = DigComboX - (i / 2);
  491.            
  492.         }
  493.         if(DigSuccess)Screen->FastCombo(2, DirtClutX, DirtClutY, Shovel_FlyingDirt + shovel_item_dir, 6, OP_OPAQUE);
  494.        
  495.        
  496.         if(Screen->ComboS[ComboAt(ShovelLoot->X + 8, ShovelLoot->Y + 8)] == 0){
  497.            
  498.             if(shovel_item_dir == 0)ShovelLoot->Y --;
  499.             else if(shovel_item_dir == 1)ShovelLoot->Y ++;
  500.             else if(shovel_item_dir == 2)ShovelLoot->X --;
  501.             else if(shovel_item_dir == 3)ShovelLoot->X ++;
  502.            
  503.         }
  504.        
  505.        
  506.         Waitframe();
  507.         Link->Invisible = false;
  508.     }
  509.    
  510.     while(ShovelLoot->Z > 0){
  511.        
  512.         if(Screen->ComboS[ComboAt(ShovelLoot->X + 8, ShovelLoot->Y + 8)] == 0){
  513.            
  514.             if(shovel_item_dir == 0)ShovelLoot->Y --;
  515.             else if(shovel_item_dir == 1)ShovelLoot->Y ++;
  516.             else if(shovel_item_dir == 2)ShovelLoot->X --;
  517.             else if(shovel_item_dir == 3)ShovelLoot->X ++;
  518.            
  519.         }
  520.        
  521.         Waitframe();
  522.        
  523.     }
  524.    
  525.   }
  526.  
  527.   //These tables define the prizes to award during the DIGGING GAME! -Z
  528.   int ShovelDigItem()
  529.     {
  530.         int prizeChances[100]=
  531.         {
  532.             //Define shovel game prizes, here.
  533.             0,0,0,0,0,0,0,0,0,0,
  534.             2,2,2,2,2,2,2,2,2,2,
  535.             34,34,34,
  536.             1,1,1,1,1,
  537.             87,-999, //29
  538.             //30
  539.             -999,-999,-999,-999,-999,-999,-999,-999,-999,-999,
  540.             //40
  541.             -999,-999,-999,-999,-999,-999,-999,-999,-999,-999,
  542.             //50
  543.             -999,-999,-999,-999,-999,-999,-999,-999,-999,-999,
  544.             //60
  545.             -999,-999,-999,-999,-999,-999,-999,-999,-999,-999,
  546.             //70
  547.             -999,-999,-999,-999,-999,-999,-999,-999,-999,-999,
  548.             //80
  549.             -999,-999,-999,-999,-999,-999,-999,-999,-999,-999,
  550.             //90
  551.             -999,-999,-999,-999,-999,-999,-999,-999,-999,-999
  552.         };
  553.         int specialPrizeChances[100]=
  554.         {
  555.             //Define special prizes here.
  556.             0,0,0,0,0,0,0,0,0,0,
  557.             2,2,2,2,2,2,2,2,2,2,
  558.             34,34,34,
  559.             1,1,1,1,1,
  560.             87,-999, //29
  561.             //30
  562.             -999,-999,-999,-999,-999,-999,-999,-999,-999,-999,
  563.             //40
  564.             -999,-999,-999,-999,-999,-999,-999,-999,-999,-999,
  565.             //50
  566.             -999,-999,-999,-999,-999,-999,-999,-999,-999,-999,
  567.             //60
  568.             -999,-999,-999,-999,-999,-999,-999,-999,-999,-999,
  569.             //70
  570.             -999,-999,-999,-999,-999,-999,-999,-999,-999,-999,
  571.             //80
  572.             -999,-999,-999,-999,-999,-999,-999,-999,-999,-999,
  573.             //90
  574.             -999,-999,-999,-999,-999,-999,-999,-999,-999,-999
  575.         };
  576.         if ( !GetScreenDBit(SHOVELGAME_D, SHOVELGAME_BIT) )
  577.             return specialPrizeChances[Rand(0,99)];
  578.         else return prizeChances[Rand(0,99)];
  579.     }
  580. }
  581.  
  582. //Normal, non-digging-game, script. (Unchanged) -Z
  583. ffc script Shovel_Diggy{
  584.   void run(){
  585.     int chance;
  586.     int itemdrop;
  587.     int itemlocx;
  588.     int itemlocy;
  589.     // Link->Action=LA_ATTACKING;
  590.    
  591.     item ShovelLoot;
  592.    
  593.     bool DigSuccess = false;
  594.    
  595.     int DigComboX;
  596.     int DigComboY;
  597.     if(Link->Dir == 0){
  598.         DigComboX = Link->X + 8;
  599.         DigComboY = Link->Y - 2;
  600.     }
  601.     else if(Link->Dir == 1){
  602.         DigComboX = Link->X + 8;
  603.         DigComboY = Link->Y + 18;
  604.     }
  605.     else if(Link->Dir == 2){
  606.         DigComboX = Link->X - 2;
  607.         DigComboY = Link->Y + 8;
  608.     }
  609.     else if(Link->Dir == 3){
  610.         DigComboX = Link->X + 18;
  611.         DigComboY = Link->Y + 8;
  612.     }
  613.    
  614.     int DigComboX2 = ComboAt(DigComboX,DigComboY) % 16;
  615.     DigComboX2 = DigComboX2 * 16;
  616.     int DigComboY2 = ComboAt(DigComboX,DigComboY) / 16;
  617.     DigComboY2 = Floor(DigComboY2);
  618.     DigComboY2 = DigComboY2 * 16;
  619.    
  620.    
  621.     for(int i; i != 10; i ++){
  622.         Link->Invisible = true;
  623.        
  624.         Screen->FastCombo(2, Link->X, Link->Y, Shovel_Anima_Start + Link->Dir, 6, OP_OPAQUE);
  625.         NoAction();
  626.        
  627.         Waitframe();
  628.         Link->Invisible = false;
  629.     }
  630.  
  631.    
  632.     if(Screen->ComboT[ComboAt(DigComboX,DigComboY)] != Shovel_ComboType
  633.     && Screen->ComboI[ComboAt(DigComboX,DigComboY)] != Shovel_SecretFlag
  634.     && Screen->ComboF[ComboAt(DigComboX,DigComboY)] != Shovel_SecretFlag){
  635.        Game->PlaySound(Shovel_Fail);
  636.     }
  637.     else{
  638.        
  639.        Game->PlaySound(Shovel_Sound);
  640.        DigSuccess = true;
  641.        
  642.        chance=Rand(100)+1;
  643.        
  644.        if(Screen->ComboT[ComboAt(DigComboX,DigComboY)] == Shovel_ComboType && Screen->ComboI[ComboAt(DigComboX,DigComboY)] == Shovel_SecretFlag){
  645.            
  646.            Screen->ComboD[ComboAt(DigComboX,DigComboY)] = Screen->UnderCombo;
  647.            chance = 101;
  648.            
  649.        }
  650.        else if(Screen->ComboF[ComboAt(DigComboX,DigComboY)] == Shovel_SecretFlag || Screen->ComboI[ComboAt(DigComboX,DigComboY)] == Shovel_SecretFlag){
  651.            Game->PlaySound(Shovel_SecretSFX);
  652.            Screen->TriggerSecrets();
  653.            Screen->State[ST_SECRET] = true;
  654.            chance = 101;
  655.        }
  656.        else{
  657.            Screen->ComboD[ComboAt(DigComboX,DigComboY)] = Screen->UnderCombo;
  658.            
  659.            if(Shovel_DugCombo > 0){
  660.                Screen->ComboD[ComboAt(DigComboX,DigComboY)] = Shovel_DugCombo;
  661.            }
  662.        }
  663.        
  664.         //Drop ratio is the current number minus the last one.
  665.        if(chance<=10){      //10%
  666.            itemdrop = 0;    //1 rupee
  667.        }
  668.        else if(chance<=20){ //10%
  669.            itemdrop = 2;    //Recovery heart
  670.        }
  671.        else if(chance<=23){ //3%
  672.            itemdrop = 34;   //Fairy
  673.        }
  674.        else if(chance<=27){ //4%
  675.            itemdrop = 1;    //5 Rupee
  676.        }
  677.        else if(chance<=28){ //1%
  678.            itemdrop = 87;   //100 Rupee
  679.        }
  680.        else{
  681.            itemdrop = - 999;    //No item drop
  682.        }
  683.  
  684.        if(Link->Dir==0){    //Spawn location
  685.            itemlocx=Link->X;
  686.            itemlocy=Link->Y-16;
  687.        }
  688.        if(Link->Dir==1){
  689.            itemlocx=Link->X;
  690.            itemlocy=Link->Y+16;
  691.        }
  692.        if(Link->Dir==2){
  693.            itemlocx=Link->X-16;
  694.            itemlocy=Link->Y;
  695.        }
  696.        if(Link->Dir==3){
  697.            itemlocx=Link->X+16;
  698.            itemlocy=Link->Y;
  699.        }
  700.  
  701.        if(itemdrop != -999){
  702.            ShovelLoot=Screen->CreateItem(itemdrop);
  703.            ShovelLoot->X=itemlocx;
  704.            ShovelLoot->Y=itemlocy;
  705.            ShovelLoot->Z=2;
  706.            ShovelLoot->Jump = 2;
  707.            ShovelLoot->Pickup=IP_TIMEOUT;
  708.        }
  709.     }
  710.    
  711.     int shovel_item_dir = Link->Dir;
  712.     int DirtClutX = DigComboX2;
  713.     int DirtClutY = DigComboY2;
  714.    
  715.    
  716.     for(int i; i != 10; i ++){
  717.         Link->Invisible = true;
  718.        
  719.         Screen->FastCombo(2, Link->X, Link->Y, Shovel_Anima_Start + 4 + Link->Dir, 6, OP_OPAQUE);
  720.         NoAction();
  721.        
  722.         if(i < 5){
  723.            
  724.             if(shovel_item_dir == 0)DirtClutY --;
  725.             if(shovel_item_dir == 1 && i % 2 == 0)DirtClutY ++;
  726.            
  727.             //sideways
  728.             if(shovel_item_dir > 1)DirtClutY --;
  729.             if(shovel_item_dir == 3)DirtClutX = DigComboX + (i / 2);
  730.             if(shovel_item_dir == 2)DirtClutX = DigComboX - (i / 2);
  731.            
  732.         }
  733.         else{
  734.            
  735.             if(shovel_item_dir == 0 && i % 2 == 0)DirtClutY --;
  736.             if(shovel_item_dir == 1)DirtClutY ++;
  737.            
  738.             //sideways
  739.             if(shovel_item_dir > 1)DirtClutY ++;
  740.             if(shovel_item_dir == 3)DirtClutX = DigComboX + (i / 2);
  741.             if(shovel_item_dir == 2)DirtClutX = DigComboX - (i / 2);
  742.            
  743.         }
  744.         if(DigSuccess)Screen->FastCombo(2, DirtClutX, DirtClutY, Shovel_FlyingDirt + shovel_item_dir, 6, OP_OPAQUE);
  745.        
  746.        
  747.         if(Screen->ComboS[ComboAt(ShovelLoot->X + 8, ShovelLoot->Y + 8)] == 0){
  748.            
  749.             if(shovel_item_dir == 0)ShovelLoot->Y --;
  750.             else if(shovel_item_dir == 1)ShovelLoot->Y ++;
  751.             else if(shovel_item_dir == 2)ShovelLoot->X --;
  752.             else if(shovel_item_dir == 3)ShovelLoot->X ++;
  753.            
  754.         }
  755.        
  756.        
  757.         Waitframe();
  758.         Link->Invisible = false;
  759.     }
  760.    
  761.     while(ShovelLoot->Z > 0){
  762.        
  763.         if(Screen->ComboS[ComboAt(ShovelLoot->X + 8, ShovelLoot->Y + 8)] == 0){
  764.            
  765.             if(shovel_item_dir == 0)ShovelLoot->Y --;
  766.             else if(shovel_item_dir == 1)ShovelLoot->Y ++;
  767.             else if(shovel_item_dir == 2)ShovelLoot->X --;
  768.             else if(shovel_item_dir == 3)ShovelLoot->X ++;
  769.            
  770.         }
  771.        
  772.         Waitframe();
  773.        
  774.     }
  775.    
  776.   }
  777. }
  778.  
  779. ffc script Shovel_SP_DigPoint{
  780.     void run(int Replace_Combo, int Replace_CSet, int Secret_Item){
  781.        
  782.         //  just script a FFC as "dig point" that changes it's combo to something specific when dug
  783.         //  probably the best solution
  784.         //  since you could define on the fly what you'd want it to be
  785.        
  786.        
  787.         if(Screen->State[ST_SECRET] == false){
  788.            
  789.            
  790.         }
  791.         else{
  792.            
  793.            
  794.            
  795.         }
  796.        
  797.     }
  798. }
  799.  
  800. //Returns if the digging game is active. Used to communicate with other scripts.
  801. bool IsShovelGame()
  802. {
  803.     return (Link->Misc[MISC_GAMES]&GT_SHOVEL);
  804. }
  805.  
  806. //Sets a global condition via Link->Misc.
  807. void IsShovelGame(bool s)
  808. {
  809.     if ( s )
  810.     {
  811.         Link->Misc[MISC_GAMES] |= GT_SHOVEL;
  812.     }
  813.     else    Link->Misc[MISC_GAMES] |= ~GT_SHOVEL;
  814. }
  815.  
  816. //Clears all games from Link->Misc. Call after run() in the active script.
  817. void ClearLinkMiscGames()
  818. {
  819.     Link->Misc[MISC_GAMES] = 0;
  820. }
  821.  
  822. //global script active
  823. //  void run()
  824. //  {
  825. //      ClearLinkMiscGames(); //Put it here!
  826. //
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement