Advertisement
ZoriaRPG

Shovel Game for JudasRising (Preliminary) v2

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