Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const int MISC_GAMES = 5; //Link->Misc[]
- const int GT_SHOVEL = 1; //bit for Link->Misc[MISC_GAMES]
- bool IsShovelGame()
- {
- return (Link->Misc[MISC_GAMES]>_SHOVEL);
- }
- void IsShovelGame(bool s)
- {
- if ( s )
- {
- Link->Misc[MISC_GAMES] |= GT_SHOVEL;
- }
- else Link->Misc[MISC_GAMES] |= ~GT_SHOVEL;
- }
- const int SHOVEL_GAME_RUNNING = 0; //index for shovelgame[]
- const int SHOVEL_GAME_TIMER = 1; //index for shovelgame[]
- const int SHOVEL_GAME_ACTIVE = 2; //index for shovelgame[]
- const int SHOVEL_GAME_HAS_SHOVEL = 3; //index for shovelgame[]
- const int SHOVEL_GAME_LINE_Y = 50; //Y position of invisible line.
- const int SHOVEL_GAME_TIMER_X
- const int SHOVEL_GAME_TIMER_Y
- const int SHOVEL_GAME_TIMER_FONT
- const int SHOVEL_GAME_TIMER_COLOUR
- const int SHOVEL_GAME_TIMER_VALUE //DEFAULT
- const int SHOVEL_GAME_MESSAGE_GAMEOVER
- const int SHOVEL_GAME_GUY_DISTX = 10;
- const int SHOVEL_GAME_GUY_DISTY = 10;
- const int SHOVEL_GAME_COST = 60;
- const int SHOVEL_GAME_BUTTON_A = 1;
- const int SHOVEL_GAME_BUTTON_B = 1;
- const int SHOVEL_GAME_BUTTON_L = 1;
- const int SHOVEL_GAME_BUTTON_R = 1;
- const int SHOVEL_GAME_BUTTON_EX1 = 1;
- const int SHOVEL_GAME_BUTTON_EX2 = 1;
- const int SHOVEL_GAME_BUTTON_EX3 = 1;
- const int SHOVEL_GAME_BUTTON_EX4 = 1;
- //const int SHOVEL_GAME_
- //const int SHOVEL_GAME_
- //const int SHOVEL_GAME_
- //const int SHOVEL_GAME_
- ffc script ShovelGame
- {
- void run(int time, int cost)
- {
- int shovelgame[256];
- //0 == timer
- //1 == running
- item shovelgameitems[256];
- itemdata shovelgame id[256];
- shovelgame[SHOVEL_GAME_ACTIVE] = 1;
- shovelgame[SHOVEL_GAME_HAS_SHOVEL] = Link->Item[I_SHOVEL];
- while(shovelgame[SHOVEL_GAME_ACTIVE])
- {
- //Draw guy
- //and below or to the right of him
- if ( Below(this) || RightOf(this) )
- {
- //if Link is facing the guy
- if ( Facing(this) )
- {
- //and within a set distance
- if ( DistX(Link->X, this->X, SHOVEL_GAME_GUY_DISTX) )
- {
- if ( DistY(Link->Y, this->Y, SHOVEL_GAME_GUY_DISTX) )
- {
- //and presses the correct button
- if ( PressShovelGameButton() )
- {
- //create yes/no tango menu
- //if menu returns (1) then the game is running
- shovelgame[SHOVEL_GAME_RUNNING] = ShovelGameMenu();
- }
- }
- }
- }
- }
- //while runnning
- while(shovelgame[SHOVEL_GAME_RUNNING])
- {
- //if Link doesnt have the shovel, give it to him here:
- if ( !shovelgame[SHOVEL_GAME_HAS_SHOVEL] )
- {
- if ( !Link->Item[I_SHOVEL] ) Link->Item[I_SHOVEL] = true;
- //Set the shovel as the active B item.
- }
- while(Link->Y < SHOVEL_GAME_LINE_Y ) { Waitframe(); continue; }
- //wait for Link to cross the invisible line
- //once he does...
- shovelgame[SHOVEL_GAME_TIMER] = Cond(time > 0, time, SHOVEL_GAME_TIMER_VALUE); //set the timer
- while(shovelgame[SHOVEL_GAME_TIMER]-- > -1 )
- {
- //while the timer is above -1
- //set game running
- IsShovelGame(true);
- //display the game time.
- Waitframe(); continue;
- //if the timer expires, end the game.
- }
- Waitframe(); continue;
- }
- //Game is over.
- //Show a message
- Screen->Message(SHOVEL_GAME_MESSAGE_GAMEOVER);
- //set game off
- //take the shovel away if Link does not own one.
- if ( !shovelgame[SHOVEL_GAME_HAS_SHOVEL] )
- {
- if ( Link->Item[I_SHOVEL] ) Link->Item[I_SHOVEL] = false;
- //Set the shovel as the active B item.
- }
- IsShovelGame(false);
- Waitframe(); continue;
- }
- //if you want the guy to say something else, or if you want to offer a new game,
- //then, you could do that.
- }
- bool PressShovelGameButton()
- {
- if ( SHOVEL_GAME_BUTTON_A && Link->PressA )
- {
- Link->PressA = false; Link->InputA = false; return true;
- }
- if ( SHOVEL_GAME_BUTTON_B && Link->PressB )
- {
- Link->PressB = false; Link->InputB = false; return true;
- }
- if ( SHOVEL_GAME_BUTTON_L && Link->PressL )
- {
- Link->PressL = false; Link->InputL = false; return true;
- }
- if ( SHOVEL_GAME_BUTTON_R && Link->PressR )
- {
- Link->PressR = false; Link->InputR = false; return true;
- }
- if ( SHOVEL_GAME_BUTTON_EX1 && Link->PressEx1 )
- {
- Link->PressEx1 = false; Link->InputEx1 = false; return true;
- }
- if ( SHOVEL_GAME_BUTTON_EX2 && Link->PressEx2 )
- {
- Link->PressEx2 = false; Link->InputEx2 = false; return true;
- }
- if ( SHOVEL_GAME_BUTTON_EX3 && Link->PressEx3 )
- {
- Link->PressEx3 = false; Link->InputEx3 = false; return true;
- }
- if ( SHOVEL_GAME_BUTTON_EX4 && Link->PressEx4 )
- {
- Link->PressEx4 = false; Link->InputEx4 = false; return true;
- }
- return false;
- }
- }
- }
- //Huzzah, this script now uses a way more practical injection model for usage! ~Lunaria
- //The combo type for generic digging on overworld.
- const int Shovel_ComboType = 143; //Script 2 (143) is default for this.
- //The flag to dig on to trigger secrets. (Does not need to be on a digable combo type!)
- const int Shovel_SecretFlag = 99; //General Purpose 2 (99) is default for this.
- //Digging on proper combos will change the combo to this one:
- const int Shovel_DugCombo = 969; //Change to 0 to use the screens undercombo instead.
- //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)
- const int Shovel_Anima_Start = 3780;
- //Start of 4 combos for the dirt clut
- const int Shovel_FlyingDirt = 3788;
- //FFC slot for the shovel script. This now uses an FFC slot because fancier animation, woo!
- const int Shovel_FFC_Script = 168;
- // This is the sound to be played when you successfully dig.
- const int Shovel_Sound = 74;
- // The sound to be played when you attempt to dig an undiggable combo.
- const int Shovel_Fail = 101;
- // The secret sound to be played when you dig a secret.
- const int Shovel_SecretSFX = 27;
- item script Shovel{
- void run(){
- int s_dig[]="Shovel_Diggy";
- int s_dig_game="Shovel_Diggy_Game";
- int useScript = Cond(IsShovelGame(), s_dig_game, s_dig);
- if(Link->Z > 0) return;
- //int args[] = {103,0,0,0,0,0,0,0};
- RunFFCScript(useScript, NULL);
- }
- }
- ffc script Shovel_Diggy_Game{
- void run(){
- int chance;
- int itemdrop;
- int itemlocx;
- int itemlocy;
- // Link->Action=LA_ATTACKING;
- item ShovelLoot;
- bool DigSuccess = false;
- int DigComboX;
- int DigComboY;
- if(Link->Dir == 0){
- DigComboX = Link->X + 8;
- DigComboY = Link->Y - 2;
- }
- else if(Link->Dir == 1){
- DigComboX = Link->X + 8;
- DigComboY = Link->Y + 18;
- }
- else if(Link->Dir == 2){
- DigComboX = Link->X - 2;
- DigComboY = Link->Y + 8;
- }
- else if(Link->Dir == 3){
- DigComboX = Link->X + 18;
- DigComboY = Link->Y + 8;
- }
- int DigComboX2 = ComboAt(DigComboX,DigComboY) % 16;
- DigComboX2 = DigComboX2 * 16;
- int DigComboY2 = ComboAt(DigComboX,DigComboY) / 16;
- DigComboY2 = Floor(DigComboY2);
- DigComboY2 = DigComboY2 * 16;
- for(int i; i != 10; i ++){
- Link->Invisible = true;
- Screen->FastCombo(2, Link->X, Link->Y, Shovel_Anima_Start + Link->Dir, 6, OP_OPAQUE);
- NoAction();
- Waitframe();
- Link->Invisible = false;
- }
- if(Screen->ComboT[ComboAt(DigComboX,DigComboY)] != Shovel_ComboType
- && Screen->ComboI[ComboAt(DigComboX,DigComboY)] != Shovel_SecretFlag
- && Screen->ComboF[ComboAt(DigComboX,DigComboY)] != Shovel_SecretFlag){
- Game->PlaySound(Shovel_Fail);
- }
- else{
- Game->PlaySound(Shovel_Sound);
- DigSuccess = true;
- chance=Rand(100)+1;
- if(Screen->ComboT[ComboAt(DigComboX,DigComboY)] == Shovel_ComboType && Screen->ComboI[ComboAt(DigComboX,DigComboY)] == Shovel_SecretFlag){
- Screen->ComboD[ComboAt(DigComboX,DigComboY)] = Screen->UnderCombo;
- chance = 101;
- }
- else if(Screen->ComboF[ComboAt(DigComboX,DigComboY)] == Shovel_SecretFlag || Screen->ComboI[ComboAt(DigComboX,DigComboY)] == Shovel_SecretFlag){
- Game->PlaySound(Shovel_SecretSFX);
- Screen->TriggerSecrets();
- Screen->State[ST_SECRET] = true;
- chance = 101;
- }
- else{
- Screen->ComboD[ComboAt(DigComboX,DigComboY)] = Screen->UnderCombo;
- if(Shovel_DugCombo > 0){
- Screen->ComboD[ComboAt(DigComboX,DigComboY)] = Shovel_DugCombo;
- }
- }
- //Define special SHovel game Drops, here: -Z
- //Drop ratio is the current number minus the last one.
- itemdrop = ShovelDigItem();
- if(Link->Dir==0){ //Spawn location
- itemlocx=Link->X;
- itemlocy=Link->Y-16;
- }
- if(Link->Dir==1){
- itemlocx=Link->X;
- itemlocy=Link->Y+16;
- }
- if(Link->Dir==2){
- itemlocx=Link->X-16;
- itemlocy=Link->Y;
- }
- if(Link->Dir==3){
- itemlocx=Link->X+16;
- itemlocy=Link->Y;
- }
- if(itemdrop != -999){
- ShovelLoot=Screen->CreateItem(itemdrop);
- ShovelLoot->X=itemlocx;
- ShovelLoot->Y=itemlocy;
- ShovelLoot->Z=2;
- ShovelLoot->Jump = 2;
- ShovelLoot->Pickup=IP_TIMEOUT;
- }
- }
- int shovel_item_dir = Link->Dir;
- int DirtClutX = DigComboX2;
- int DirtClutY = DigComboY2;
- for(int i; i != 10; i ++){
- Link->Invisible = true;
- Screen->FastCombo(2, Link->X, Link->Y, Shovel_Anima_Start + 4 + Link->Dir, 6, OP_OPAQUE);
- NoAction();
- if(i < 5){
- if(shovel_item_dir == 0)DirtClutY --;
- if(shovel_item_dir == 1 && i % 2 == 0)DirtClutY ++;
- //sideways
- if(shovel_item_dir > 1)DirtClutY --;
- if(shovel_item_dir == 3)DirtClutX = DigComboX + (i / 2);
- if(shovel_item_dir == 2)DirtClutX = DigComboX - (i / 2);
- }
- else{
- if(shovel_item_dir == 0 && i % 2 == 0)DirtClutY --;
- if(shovel_item_dir == 1)DirtClutY ++;
- //sideways
- if(shovel_item_dir > 1)DirtClutY ++;
- if(shovel_item_dir == 3)DirtClutX = DigComboX + (i / 2);
- if(shovel_item_dir == 2)DirtClutX = DigComboX - (i / 2);
- }
- if(DigSuccess)Screen->FastCombo(2, DirtClutX, DirtClutY, Shovel_FlyingDirt + shovel_item_dir, 6, OP_OPAQUE);
- if(Screen->ComboS[ComboAt(ShovelLoot->X + 8, ShovelLoot->Y + 8)] == 0){
- if(shovel_item_dir == 0)ShovelLoot->Y --;
- else if(shovel_item_dir == 1)ShovelLoot->Y ++;
- else if(shovel_item_dir == 2)ShovelLoot->X --;
- else if(shovel_item_dir == 3)ShovelLoot->X ++;
- }
- Waitframe();
- Link->Invisible = false;
- }
- while(ShovelLoot->Z > 0){
- if(Screen->ComboS[ComboAt(ShovelLoot->X + 8, ShovelLoot->Y + 8)] == 0){
- if(shovel_item_dir == 0)ShovelLoot->Y --;
- else if(shovel_item_dir == 1)ShovelLoot->Y ++;
- else if(shovel_item_dir == 2)ShovelLoot->X --;
- else if(shovel_item_dir == 3)ShovelLoot->X ++;
- }
- Waitframe();
- }
- }
- int ShovelDigItem()
- {
- int prizeChances[100]=
- {
- //Define shovel game prizes, here.
- 0,0,0,0,0,0,0,0,0,0,
- 2,2,2,2,2,2,2,2,2,2,
- 34,34,34,
- 1,1,1,1,1,
- 87,-999, //29
- //30
- -999,-999,-999,-999,-999,-999,-999,-999,-999,-999,
- //40
- -999,-999,-999,-999,-999,-999,-999,-999,-999,-999,
- //50
- -999,-999,-999,-999,-999,-999,-999,-999,-999,-999,
- //60
- -999,-999,-999,-999,-999,-999,-999,-999,-999,-999,
- //70
- -999,-999,-999,-999,-999,-999,-999,-999,-999,-999,
- //80
- -999,-999,-999,-999,-999,-999,-999,-999,-999,-999,
- //90
- -999,-999,-999,-999,-999,-999,-999,-999,-999,-999,
- };
- int specialPrizeChances[100]=
- {
- //Define special prizes here.
- 0,0,0,0,0,0,0,0,0,0,
- 2,2,2,2,2,2,2,2,2,2,
- 34,34,34,
- 1,1,1,1,1,
- 87,-999, //29
- //30
- -999,-999,-999,-999,-999,-999,-999,-999,-999,-999,
- //40
- -999,-999,-999,-999,-999,-999,-999,-999,-999,-999,
- //50
- -999,-999,-999,-999,-999,-999,-999,-999,-999,-999,
- //60
- -999,-999,-999,-999,-999,-999,-999,-999,-999,-999,
- //70
- -999,-999,-999,-999,-999,-999,-999,-999,-999,-999,
- //80
- -999,-999,-999,-999,-999,-999,-999,-999,-999,-999,
- //90
- -999,-999,-999,-999,-999,-999,-999,-999,-999,-999,
- };
- if ( !GetScreenDBit(SHOVELGAME_D, SHOVELGAME_BIT) )
- return specialPrizeChances[Rand(0,99)];
- else return prizeChances[Rand(0,99)];
- }
- }
- ffc script Shovel_Diggy{
- void run(){
- int chance;
- int itemdrop;
- int itemlocx;
- int itemlocy;
- // Link->Action=LA_ATTACKING;
- item ShovelLoot;
- bool DigSuccess = false;
- int DigComboX;
- int DigComboY;
- if(Link->Dir == 0){
- DigComboX = Link->X + 8;
- DigComboY = Link->Y - 2;
- }
- else if(Link->Dir == 1){
- DigComboX = Link->X + 8;
- DigComboY = Link->Y + 18;
- }
- else if(Link->Dir == 2){
- DigComboX = Link->X - 2;
- DigComboY = Link->Y + 8;
- }
- else if(Link->Dir == 3){
- DigComboX = Link->X + 18;
- DigComboY = Link->Y + 8;
- }
- int DigComboX2 = ComboAt(DigComboX,DigComboY) % 16;
- DigComboX2 = DigComboX2 * 16;
- int DigComboY2 = ComboAt(DigComboX,DigComboY) / 16;
- DigComboY2 = Floor(DigComboY2);
- DigComboY2 = DigComboY2 * 16;
- for(int i; i != 10; i ++){
- Link->Invisible = true;
- Screen->FastCombo(2, Link->X, Link->Y, Shovel_Anima_Start + Link->Dir, 6, OP_OPAQUE);
- NoAction();
- Waitframe();
- Link->Invisible = false;
- }
- if(Screen->ComboT[ComboAt(DigComboX,DigComboY)] != Shovel_ComboType
- && Screen->ComboI[ComboAt(DigComboX,DigComboY)] != Shovel_SecretFlag
- && Screen->ComboF[ComboAt(DigComboX,DigComboY)] != Shovel_SecretFlag){
- Game->PlaySound(Shovel_Fail);
- }
- else{
- Game->PlaySound(Shovel_Sound);
- DigSuccess = true;
- chance=Rand(100)+1;
- if(Screen->ComboT[ComboAt(DigComboX,DigComboY)] == Shovel_ComboType && Screen->ComboI[ComboAt(DigComboX,DigComboY)] == Shovel_SecretFlag){
- Screen->ComboD[ComboAt(DigComboX,DigComboY)] = Screen->UnderCombo;
- chance = 101;
- }
- else if(Screen->ComboF[ComboAt(DigComboX,DigComboY)] == Shovel_SecretFlag || Screen->ComboI[ComboAt(DigComboX,DigComboY)] == Shovel_SecretFlag){
- Game->PlaySound(Shovel_SecretSFX);
- Screen->TriggerSecrets();
- Screen->State[ST_SECRET] = true;
- chance = 101;
- }
- else{
- Screen->ComboD[ComboAt(DigComboX,DigComboY)] = Screen->UnderCombo;
- if(Shovel_DugCombo > 0){
- Screen->ComboD[ComboAt(DigComboX,DigComboY)] = Shovel_DugCombo;
- }
- }
- //Drop ratio is the current number minus the last one.
- if(chance<=10){ //10%
- itemdrop = 0; //1 rupee
- }
- else if(chance<=20){ //10%
- itemdrop = 2; //Recovery heart
- }
- else if(chance<=23){ //3%
- itemdrop = 34; //Fairy
- }
- else if(chance<=27){ //4%
- itemdrop = 1; //5 Rupee
- }
- else if(chance<=28){ //1%
- itemdrop = 87; //100 Rupee
- }
- else{
- itemdrop = - 999; //No item drop
- }
- if(Link->Dir==0){ //Spawn location
- itemlocx=Link->X;
- itemlocy=Link->Y-16;
- }
- if(Link->Dir==1){
- itemlocx=Link->X;
- itemlocy=Link->Y+16;
- }
- if(Link->Dir==2){
- itemlocx=Link->X-16;
- itemlocy=Link->Y;
- }
- if(Link->Dir==3){
- itemlocx=Link->X+16;
- itemlocy=Link->Y;
- }
- if(itemdrop != -999){
- ShovelLoot=Screen->CreateItem(itemdrop);
- ShovelLoot->X=itemlocx;
- ShovelLoot->Y=itemlocy;
- ShovelLoot->Z=2;
- ShovelLoot->Jump = 2;
- ShovelLoot->Pickup=IP_TIMEOUT;
- }
- }
- int shovel_item_dir = Link->Dir;
- int DirtClutX = DigComboX2;
- int DirtClutY = DigComboY2;
- for(int i; i != 10; i ++){
- Link->Invisible = true;
- Screen->FastCombo(2, Link->X, Link->Y, Shovel_Anima_Start + 4 + Link->Dir, 6, OP_OPAQUE);
- NoAction();
- if(i < 5){
- if(shovel_item_dir == 0)DirtClutY --;
- if(shovel_item_dir == 1 && i % 2 == 0)DirtClutY ++;
- //sideways
- if(shovel_item_dir > 1)DirtClutY --;
- if(shovel_item_dir == 3)DirtClutX = DigComboX + (i / 2);
- if(shovel_item_dir == 2)DirtClutX = DigComboX - (i / 2);
- }
- else{
- if(shovel_item_dir == 0 && i % 2 == 0)DirtClutY --;
- if(shovel_item_dir == 1)DirtClutY ++;
- //sideways
- if(shovel_item_dir > 1)DirtClutY ++;
- if(shovel_item_dir == 3)DirtClutX = DigComboX + (i / 2);
- if(shovel_item_dir == 2)DirtClutX = DigComboX - (i / 2);
- }
- if(DigSuccess)Screen->FastCombo(2, DirtClutX, DirtClutY, Shovel_FlyingDirt + shovel_item_dir, 6, OP_OPAQUE);
- if(Screen->ComboS[ComboAt(ShovelLoot->X + 8, ShovelLoot->Y + 8)] == 0){
- if(shovel_item_dir == 0)ShovelLoot->Y --;
- else if(shovel_item_dir == 1)ShovelLoot->Y ++;
- else if(shovel_item_dir == 2)ShovelLoot->X --;
- else if(shovel_item_dir == 3)ShovelLoot->X ++;
- }
- Waitframe();
- Link->Invisible = false;
- }
- while(ShovelLoot->Z > 0){
- if(Screen->ComboS[ComboAt(ShovelLoot->X + 8, ShovelLoot->Y + 8)] == 0){
- if(shovel_item_dir == 0)ShovelLoot->Y --;
- else if(shovel_item_dir == 1)ShovelLoot->Y ++;
- else if(shovel_item_dir == 2)ShovelLoot->X --;
- else if(shovel_item_dir == 3)ShovelLoot->X ++;
- }
- Waitframe();
- }
- }
- }
- ffc script Shovel_SP_DigPoint{
- void run(int Replace_Combo, int Replace_CSet, int Secret_Item){
- // just script a FFC as "dig point" that changes it's combo to something specific when dug
- // probably the best solution
- // since you could define on the fly what you'd want it to be
- if(Screen->State[ST_SECRET] == false){
- }
- else{
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement