Advertisement
ZoriaRPG

Digging Game for JudasRising v0.2

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