Advertisement
ZoriaRPG

a30502355 Global Temppatch for Alpha 17

Apr 13th, 2019
395
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 47.20 KB | None | 0 0
  1. namespace tempPatches
  2. {
  3.     const int BASE_LINK_Z = 1;
  4. }
  5.  
  6. // ghost.zh
  7. // Version 2.8.0
  8.  
  9. const int SCRIPT_BARRIERS = 7;
  10. const int BARRIER_A_RAISED           = 4656;
  11. const int BARRIER_B_RAISED           = 4657;
  12. const int BARRIER_A_LOWERED          = 4658;
  13. const int BARRIER_B_LOWERED          = 4659;
  14. const int BARRIER_A_ANIMRAISE        = 4660;
  15. const int BARRIER_B_ANIMRAISE        = 4661;
  16. const int BARRIER_A_ANIMLOWER        = 4662;
  17. const int BARRIER_B_ANIMLOWER        = 4663;
  18. const int BARRIER_A_WALKABLE         = 4664;
  19. const int BARRIER_B_WALKABLE         = 4665;
  20. const int BARRIER_A_SWITCH           = 4666;
  21. const int BARRIER_B_SWITCH           = 4667;
  22. const int BARRIER_SWITCH_DUMMY = 177;
  23. const int BARRIER_SWITCH_DUMMY_HP = 32767;
  24.  
  25. const int BIG_LINK                  = 0;    
  26.  
  27. // Pegasus Boots Constants
  28. const int CF_DASH                   = 102;                                                    
  29. const int INV_COMBO_ID          = 4669;
  30. const int DashSFXLength             = 9;        
  31. const int SFX_DASH                  = 79;      
  32. const int SFX_HITWALL               = 3;      
  33. const int SFX_PEGASUSBREAK          = 74;      
  34. const int T_DUST                    = 660;    
  35. const int DustAFrames               = 4;        
  36. const int DustASpeed                = 4;        
  37. const int DustCSet                  = 8;        
  38. const int I_ROCSFEATHER_INCREASER   = 124;  
  39. const int DASH_SWORD_DMG            = 8;        
  40. const int DASH_SWORD_MULT           = 2;        
  41. const int SPRITE_SWORD1         = 0;        
  42. const int SPRITE_SWORD2         = 1;
  43. const int SPRITE_SWORD3         = 2;
  44. const int SPRITE_SWORD4         = 3;
  45. const int NPC_ITEMSET               = 178;      
  46. const int SPRITE_BUSH_CUT           = 54;      
  47. const int SPRITE_FLOWER_CUT         = 54;      
  48. const int SPRITE_GRASS_CUT          = 54;
  49. const int CanDrown                  = 1;    
  50.  
  51.  
  52. bool barriers[511]; // false = blue barriers raised, true = red barriers raised
  53. // to draw while Scrolling
  54. int scrollDir;
  55. int scrollCounter;
  56. int drawX;
  57. int drawY;
  58.  
  59. //Pegasus Boots Global variables
  60. int PegasusDash = -1;
  61. bool PegasusCollision;
  62. int DashCounter;
  63. int StoreInput;
  64. int StoreHP;
  65.  
  66. int dashSwordTile = 0; // for drawing dashsword while scrolling, script sets these.
  67. int dashSwordCSet = 0;
  68.  
  69.                               //!!!!!!!!!!!!! this array size needs to be set, the number inside the []
  70. int Dust_Array[2];            // Array size should be max number of dust animations active at one time
  71.                               // Formula is ( (DustAFrames*DustASpeed) / 4 )
  72.  
  73. //END Pegasus Boots global variables
  74.  
  75.  
  76. // Function that makes preparations for barriers on each screen and starts an FFC script
  77. void Barriers_NewScreen()
  78. {
  79.    
  80.     // Search for a barrier-related combo
  81.     for (int i = 0; i <= 175; ++i)
  82.     {
  83.         int cd = Screen->ComboD[i];
  84.         if (cd == BARRIER_A_RAISED || cd == BARRIER_A_LOWERED || cd == BARRIER_A_SWITCH ||
  85.             cd == BARRIER_B_RAISED || cd == BARRIER_B_LOWERED || cd == BARRIER_B_SWITCH)
  86.         {
  87.             // A barrier-related combo was found
  88.            
  89.             // Make initial changes to combos
  90.             if (barriers[Game->GetCurDMap()])
  91.             {
  92.                 for (int j = i; j <= 175; ++j)
  93.                 {
  94.                     int cd = Screen->ComboD[j];
  95.                     if (cd == BARRIER_A_RAISED) Screen->ComboD[j] = BARRIER_A_LOWERED;
  96.                     else if (cd == BARRIER_B_LOWERED) Screen->ComboD[j] = BARRIER_B_RAISED;
  97.                     else if (cd == BARRIER_A_SWITCH) Screen->ComboD[j] = BARRIER_B_SWITCH;}}
  98.                 else {
  99.                     for (int j = i; j <= 175; j++) {
  100.                         int cd = Screen->ComboD[j];
  101.                         if (cd == BARRIER_B_RAISED) Screen->ComboD[j] = BARRIER_B_LOWERED;
  102.                         else if (cd == BARRIER_A_LOWERED) Screen->ComboD[j] = BARRIER_A_RAISED;
  103.                         else if (cd == BARRIER_B_SWITCH) Screen->ComboD[j] = BARRIER_A_SWITCH;}}
  104.                    
  105.                     // So run FFCscript to control barriers
  106.                     int args[] = {0,0,0,0,0,0,0,0};
  107.                     RunFFCScript(SCRIPT_BARRIERS, args);
  108.                     break;}
  109.             }}
  110.            
  111.             // This lets you toggle barriers on any dmap
  112.             bool ToggleBarriers(int dmap) {
  113.                 if (dmap == Game->GetCurDMap()) ToggleBarriers();
  114.                 else barriers[dmap] = !barriers[dmap];
  115.                 return barriers[dmap];}
  116.            
  117.             // This toggles barriers on the current dmap
  118.             bool ToggleBarriers() {
  119.                
  120.                 int curdmap = Game->GetCurDMap();
  121.                 if (!barriers[curdmap]) {
  122.                     barriers[curdmap] = true;
  123.                     for (int i = 0; i <= 175; i++) {
  124.                         int cd = Screen->ComboD[i];
  125.                         if (cd == BARRIER_A_RAISED || cd == BARRIER_A_WALKABLE || cd == BARRIER_A_ANIMRAISE) {
  126.                             Screen->ComboD[i] = BARRIER_A_ANIMLOWER;}
  127.                         else if (cd == BARRIER_B_LOWERED || cd == BARRIER_B_ANIMLOWER) {
  128.                             Screen->ComboD[i] = BARRIER_B_ANIMRAISE;}
  129.                         else if (cd == BARRIER_A_SWITCH) {Screen->ComboD[i] = BARRIER_B_SWITCH;}}}
  130.                         else {
  131.                             barriers[curdmap] = false;
  132.                             for (int i = 0; i <= 175; i++) {
  133.                                 int cd = Screen->ComboD[i];
  134.                                 if (cd == BARRIER_B_RAISED || cd == BARRIER_B_WALKABLE || cd == BARRIER_B_ANIMRAISE) {
  135.                                     Screen->ComboD[i] = BARRIER_B_ANIMLOWER;}
  136.                                 else if (cd == BARRIER_A_LOWERED || cd == BARRIER_A_ANIMLOWER) {
  137.                                     Screen->ComboD[i] = BARRIER_A_ANIMRAISE;}
  138.                                 else if (cd == BARRIER_B_SWITCH) {Screen->ComboD[i] = BARRIER_A_SWITCH;}}}
  139.                                
  140.                                 return barriers[curdmap];
  141.                             }
  142.                            
  143.                             ffc script Barriers {
  144.                                 void run() {
  145.                                    
  146.                                     // Initialize storage for bswitch hit dummies
  147.                                     int bswitch_count;
  148.                                     npc bswitch[8];
  149.                                    
  150.                                     for (int i = 0; i <= 175; i++) {
  151.                                         if (Screen->ComboD[i] == BARRIER_A_SWITCH || Screen->ComboD[i] == BARRIER_B_SWITCH) {
  152.                                             npc bs = CreateNPCAt(BARRIER_SWITCH_DUMMY, ComboX(i), ComboY(i));
  153.                                             bs->HitWidth = 8; // Smaller hit box to avoid annoying collisions with Link
  154.                                             bs->HitHeight = 8;
  155.                                             bs->HP = BARRIER_SWITCH_DUMMY_HP;
  156.                                             bswitch[bswitch_count++] = bs;}}
  157.                                        
  158.                                         // Change raised barriers to walkable ones if Link enters screen on a raised barrier
  159.                                         int lcombo = LinkOnComboD();
  160.                                         bool onbarrier = (lcombo == BARRIER_A_RAISED || lcombo == BARRIER_B_RAISED);
  161.                                         if (onbarrier) for (int i = 0; i < 176; i++) {
  162.                                             if (Screen->ComboD[i] == BARRIER_A_RAISED) {Screen->ComboD[i] = BARRIER_A_WALKABLE;}
  163.                                             else if (Screen->ComboD[i] == BARRIER_B_RAISED) {Screen->ComboD[i] = BARRIER_B_WALKABLE;}}
  164.                                            
  165.                                             while (true) {
  166.                                                
  167.                                                 // Detect hits on bswitches, and change combos accordingly
  168.                                                 for (int j = 0; j < bswitch_count; j++) {
  169.                                                     if (bswitch[j]->HP < BARRIER_SWITCH_DUMMY_HP) {
  170.                                                         bswitch[j]->HP = BARRIER_SWITCH_DUMMY_HP;
  171.                                                         ToggleBarriers();
  172.                                                         break;}} //break so that only one bswitch hit may register per frame
  173.                                                    
  174.                                                    
  175.                                                     // Make barriers walkable if Link is on raised barriers, or unwalkable if not
  176.                                                     lcombo = LinkOnComboD();
  177.                                                     if (!onbarrier && (lcombo == BARRIER_A_RAISED || lcombo == BARRIER_B_RAISED)) {
  178.                                                         onbarrier = true;
  179.                                                         for (int i = 0; i <= 175; i++) {
  180.                                                             if (Screen->ComboD[i] == BARRIER_A_RAISED) {Screen->ComboD[i] = BARRIER_A_WALKABLE;}
  181.                                                             else if (Screen->ComboD[i] == BARRIER_B_RAISED) {Screen->ComboD[i] = BARRIER_B_WALKABLE;}}}
  182.                                                             else if (onbarrier && !(lcombo == BARRIER_A_WALKABLE || lcombo == BARRIER_B_WALKABLE)) {
  183.                                                                 onbarrier = false;
  184.                                                                 for (int i = 0; i <= 175; i++) {
  185.                                                                     if (Screen->ComboD[i] == BARRIER_A_WALKABLE) {Screen->ComboD[i] = BARRIER_A_RAISED;}
  186.                                                                     else if (Screen->ComboD[i] == BARRIER_B_WALKABLE) {Screen->ComboD[i] = BARRIER_B_RAISED;}}}
  187.                                                                    
  188.                                                                     Waitframe();}
  189.                                                                
  190.                                                                
  191.                                                             }}
  192.                                                            
  193.                                                            
  194.                                                            
  195.                                                             item script PegasusBoots{
  196.                                                                 void run(){
  197.                                                                    
  198.                                                                     if(ComboFI(Link->X+8,Link->Y + Cond(BIG_LINK==0, 12, 8),CF_DASH)) Quit();  // can't dash on non-solid dash combos
  199.                                                                    
  200.                                                                     if(CanDrown == 0 && IsWater(TouchedComboLoc()) ) Quit();  // stop beside non-drownable water
  201.                                                                    
  202.                                                                     if(Link->Action == LA_SWIMMING || Link->Action == LA_DROWNING) Quit();  // can't use dash when in water
  203.                                                                    
  204.                                                                     if(IsJumping()) Quit();  // can't initiate dash while jumping
  205.                                                                    
  206.                                                                     // Link won't dash if facing up or down in sideview
  207.                                                                     if(IsSideview()){
  208.                                                                         if(Link->Dir == DIR_UP || Link->Dir == DIR_DOWN) Quit();
  209.                                                                     }
  210.                                                                    
  211.                                                                     PegasusDash = Link->Dir;
  212.                                                                    
  213.                                                                     if(Link->InputB && !Link->InputA) StoreInput = 2;
  214.                                                                     else if(Link->InputA && !Link->InputB) StoreInput = 1;
  215.                                                                    
  216.                                                                 }
  217.                                                             }
  218.                                                            
  219.                                                            
  220.                                                             // Stops dashing, no collision.  Easy for other scripts to call.
  221.                                                             void StopDash(){
  222.                                                                 PegasusDash = -1;
  223.                                                                 DashCounter = 0;
  224.                                                             }
  225.                                                            
  226.                                                            
  227.                                                             // takes care of all the PegasusBoots functions
  228.                                                             // call it in your global while loop, above the waitdraw and waitframe.
  229.                                                             void PegasusBoots(){
  230.                                                                 lweapon mysword;
  231.                                                                
  232.                                                                 int loc = ComboAt(Link->X+8,Link->Y + Cond(BIG_LINK==0, 12, 8));
  233.                                                                
  234.                                                                 // this fixes the bug that makes Link dive immediately after dashing into water with flippers
  235.                                                                 if(DashCounter < 0){
  236.                                                                     DashCounter++;
  237.                                                                    
  238.                                                                     if(Link->Action == LA_SWIMMING){
  239.                                                                         Link->InputA = false;
  240.                                                                     }else if(Link->Action == LA_DIVING){
  241.                                                                     Link->Action == LA_SWIMMING;
  242.                                                                     Link->InputA = false;
  243.                                                                 }else{
  244.                                                                 DashCounter = 0;
  245.                                                             }
  246.                                                         }
  247.                                                        
  248.                                                         // fixs a bug with drownable water and diagonal movement off
  249.                                                         if(CanDrown == 1 && IsWater(loc)
  250.                                                         && Link->Action != LA_SWIMMING && Link->Action != LA_DROWNING && Link->Action != LA_DIVING){
  251.                                                            
  252.                                                             if(Link->Dir == DIR_UP) Link->InputUp = true;
  253.                                                             else if(Link->Dir == DIR_DOWN) Link->InputDown = true;
  254.                                                             else if(Link->Dir == DIR_LEFT) Link->InputLeft = true;
  255.                                                             else if(Link->Dir == DIR_RIGHT) Link->InputRight = true;
  256.                                                         }
  257.                                                        
  258.                                                        
  259.                                                         if(PegasusDash >= 0){
  260.                                                             if(!PegasusCollision){
  261.                                                                 if( (Link->Action != LA_SCROLLING && ((StoreInput == 1 && !Link->InputA) || (StoreInput == 2 && !Link->InputB)))
  262.                                                                 || StoreHP > Link->HP || Link->Action == LA_RAFTING
  263.                                                                 || Link->Action == LA_DROWNING || Link->Action == LA_SWIMMING || Link->Action == LA_DIVING
  264.                                                                 || (CanDrown == 0 && IsWater(TouchedComboLoc())) || (CanDrown == 1 && IsWater(loc)) ){
  265.                                                                    
  266.                                                                     StopDash();
  267.                                                                    
  268.                                                                     if(Link->Action == LA_SWIMMING) DashCounter = -20;
  269.                                                                 }
  270.                                                                
  271.                                                                 if(!UsingItem(I_ROCSFEATHER_INCREASER))
  272.                                                                 NoAction();
  273.                                                                
  274.                                                                 if(Link->Item[I_ROCSFEATHER] && !Link->Item[I_ROCSFEATHER_INCREASER]){
  275.                                                                     Link->Item[I_ROCSFEATHER_INCREASER]=true;
  276.                                                                 }
  277.                                                                
  278.                                                                 // Link runs on spot for 10 frames before dash happens
  279.                                                                 if(Link->Action != LA_SCROLLING && DashCounter > 10){
  280.                                                                     if(PegasusDash == DIR_UP && DashCheck(Link->X+8,Link->Y+6,true) != 2){
  281.                                                                         Link->Y--;
  282.                                                                         drawY--;
  283.                                                                         Link->InputUp = true;
  284.                                                                     }
  285.                                                                     else if(PegasusDash == DIR_DOWN && DashCheck(Link->X+8,Link->Y+17,true) != 2){
  286.                                                                         Link->Y++;
  287.                                                                         drawY++;
  288.                                                                         Link->InputDown = true;
  289.                                                                     }
  290.                                                                     else if(PegasusDash == DIR_LEFT && DashCheck(Link->X,Link->Y+12,false) != 2){
  291.                                                                         Link->X--;
  292.                                                                         drawX--;
  293.                                                                         Link->InputLeft = true;
  294.                                                                     }
  295.                                                                     else if(PegasusDash == DIR_RIGHT && DashCheck(Link->X+16,Link->Y+12,false) != 2){
  296.                                                                         Link->X++;
  297.                                                                         drawX++;
  298.                                                                         Link->InputRight = true;
  299.                                                                     }
  300.                                                                     else{
  301.                                                                         PegasusCollision = true;
  302.                                                                         DashCounter = 0;
  303.                                                                     }
  304.                                                                 }//end DashCounter if
  305.                                                                
  306.                                                                 // do stuff if not jumping
  307.                                                                 if( !IsJumping() ){
  308.                                                                    
  309.                                                                     // handles breaking of solid Pegasus combos
  310.                                                                     if(ComboFI(loc,CF_DASH) && Screen->ComboS[loc] == 1111b){
  311.                                                                         Screen->ComboD[loc]=INV_COMBO_ID;
  312.                                                                         if(Screen->ComboF[loc] == CF_DASH) Screen->ComboF[loc] = 0;
  313.                                                                         Game->PlaySound(SFX_PEGASUSBREAK);
  314.                                                                     }
  315.                                                                    
  316.                                                                     DustDrawTile();  // use new dust draw code that works while scrolling
  317.                                                                     // DustDrawLW(); // use old dust draw code that doesn't work while scrolling (quest rule "no screen scrolling" on)
  318.                                                                    
  319.                                                                     if(DashCounter%DashSFXLength == 0) Game->PlaySound(SFX_DASH);
  320.                                                                 }
  321.                                                                
  322.                                                                 // draws dashSword when scrolling
  323.                                                                 if(Link->Action == LA_SCROLLING && dashSwordTile > 0){
  324.                                                                    
  325.                                                                     if(PegasusDash == DIR_UP)
  326.                                                                     Screen->DrawTile(0,drawX+InFrontX(DIR_UP,6),drawY+InFrontY(DIR_UP,6),
  327.                                                                     dashSwordTile,1,1,dashSwordCSet,-1,-1,0,0,0,0,true,128);
  328.                                                                     else if(PegasusDash == DIR_DOWN)
  329.                                                                     Screen->DrawTile(0,drawX+InFrontX(DIR_DOWN,6),drawY+InFrontY(DIR_DOWN,6),
  330.                                                                     dashSwordTile,1,1,dashSwordCSet,-1,-1,0,0,0,3,true,128);
  331.                                                                     else if(PegasusDash == DIR_LEFT)
  332.                                                                     Screen->DrawTile(0,drawX+InFrontX(DIR_LEFT,6),drawY+InFrontY(DIR_LEFT,6)+3,
  333.                                                                     dashSwordTile,1,1,dashSwordCSet,-1,-1,0,0,0,1,true,128);
  334.                                                                     else if(PegasusDash == DIR_RIGHT)
  335.                                                                     Screen->DrawTile(0,drawX+InFrontX(DIR_RIGHT,6),drawY+InFrontY(DIR_RIGHT,6)+3,
  336.                                                                     dashSwordTile,1,1,dashSwordCSet,-1,-1,0,0,0,0,true,128);
  337.                                                                 }
  338.                                                                
  339.                                                                 int swordEquip = LinkSwordEquip();
  340.                                                                
  341.                                                                 if(swordEquip > -1 && DashCounter>10){
  342.                                                                     // draws dashSword when not scrolling
  343.                                                                    
  344.                                                                     mysword = LoadLWeaponOf(LW_SCRIPT3);
  345.                                                                     if(!mysword->isValid()) mysword = Screen->CreateLWeapon(LW_SCRIPT3);
  346.                                                                    
  347.                                                                     if(swordEquip==I_SWORD4){
  348.                                                                         mysword->UseSprite(SPRITE_SWORD4);
  349.                                                                     }else if(swordEquip==I_SWORD3){
  350.                                                                     mysword->UseSprite(SPRITE_SWORD3);
  351.                                                                 }else if(swordEquip==I_SWORD2){
  352.                                                                 mysword->UseSprite(SPRITE_SWORD2);
  353.                                                             }else{
  354.                                                             mysword->UseSprite(SPRITE_SWORD1);
  355.                                                         }//end sprite if
  356.                                                        
  357.                                                         if(DASH_SWORD_MULT > 0){
  358.                                                             itemdata itm = Game->LoadItemData(swordEquip);
  359.                                                             mysword->Damage = itm->Power * DASH_SWORD_MULT;
  360.                                                         }
  361.                                                         else mysword->Damage = DASH_SWORD_DMG;
  362.                                                        
  363.                                                         mysword->X = Link->X+InFrontX(PegasusDash, 6);
  364.                                                         mysword->Y = Link->Y+InFrontY(PegasusDash, 6);
  365.                                                        
  366.                                                         mysword->Dir = PegasusDash;
  367.                                                         if(mysword->Dir < 2){ //dir is up or down
  368.                                                             if(mysword->Dir == DIR_DOWN) mysword->Flip = 3;
  369.                                                         }
  370.                                                         else{ //dir is left or right
  371.                                                             mysword->OriginalTile += 1;
  372.                                                             mysword->Tile = mysword->OriginalTile;
  373.                                                             if(mysword->Dir == DIR_LEFT) mysword->Flip = 1;
  374.                                                             mysword->Y += 3;
  375.                                                         }//end dir if
  376.                                                        
  377.                                                         // save our sword sprite for when scrolling
  378.                                                         dashSwordTile = mysword->Tile;
  379.                                                         dashSwordCSet = mysword->OriginalCSet;
  380.                                                        
  381.                                                         // slash stuff while dashing with sword
  382.                                                         DoDashSlash(ComboAt(TouchedX()+InFrontX(mysword->Dir,4),TouchedY()+InFrontY(mysword->Dir,4)));
  383.                                                     }
  384.                                                     else{ // we don't have dashSword
  385.                                                        
  386.                                                         mysword = LoadLWeaponOf(LW_SCRIPT3);
  387.                                                         Remove(mysword);
  388.                                                        
  389.                                                         dashSwordTile = 0;
  390.                                                         dashSwordCSet = 0;
  391.                                                     }//end mysword if
  392.                                                    
  393.                                                 }//end !PegasusCollision if
  394.                                                
  395.                                                 else{ //is PegasusCollision, DashCounter has been reset to 0.
  396.                                                     NoAction();
  397.                                                    
  398.                                                     // knockback code
  399.                                                     if(PegasusDash == DIR_UP && DashCheck(Link->X+8,Link->Y+18,true) == 0) Link->Y++;
  400.                                                     else if(PegasusDash == DIR_DOWN && DashCheck(Link->X+8,Link->Y+6,true) == 0) Link->Y--;
  401.                                                     else if(PegasusDash == DIR_LEFT && DashCheck(Link->X+18,Link->Y+8,false) == 0) Link->X++;
  402.                                                     else if(PegasusDash == DIR_RIGHT && DashCheck(Link->X-2,Link->Y+8,false) == 0) Link->X--;
  403.                                                    
  404.                                                     if(DashCounter == 1){
  405.                                                         Screen->ClearSprites(SL_LWPNS);
  406.                                                         Game->PlaySound(SFX_HITWALL);
  407.                                                         Screen->Quake = 10;
  408.                                                     }
  409.                                                     else if(DashCounter == 10){
  410.                                                         StopDash();
  411.                                                         PegasusCollision = false;
  412.                                                     }
  413.                                                    
  414.                                                     if(DashCounter < 5) Link->Z++;
  415.                                                 }// end PegasusCollision if/else
  416.                                                
  417.                                                 DashCounter++;
  418.                                             }// end PegasusDash if
  419.                                            
  420.                                             else{ // !PegasusDash
  421.                                                 mysword = LoadLWeaponOf(LW_SCRIPT3);
  422.                                                 Remove(mysword);
  423.                                                
  424.                                                 dashSwordTile = 0;
  425.                                                 dashSwordCSet = 0;
  426.                                                
  427.                                                 if(Link->Item[I_ROCSFEATHER_INCREASER]) Link->Item[I_ROCSFEATHER_INCREASER]=false;
  428.                                             }//end PegasusDash if/else
  429.                                            
  430.                                             StoreHP = Link->HP;
  431.                                         }//end function
  432.                                        
  433.                                        
  434.                                         // next two functions draw dust when dashing.  first one allows drawing during scrolling. the second is the old code, and currently unused.
  435.                                         void DustDrawTile(){
  436.                                             if(PegasusDash < 0) return;
  437.                                            
  438.                                             int dX;
  439.                                             int dY;
  440.                                            
  441.                                             if(DashCounter%4 == 0){
  442.                                                 for(int i = 0; i < SizeOfArray(Dust_Array); i++){
  443.                                                     if(Dust_Array[i] == 0){
  444.                                                         Dust_Array[i] = 1;
  445.                                                         break;  
  446.                                                     }
  447.                                                 }
  448.                                             }
  449.                                            
  450.                                             for(int i = 0; i < SizeOfArray(Dust_Array); i++){
  451.                                                 if(Dust_Array[i]==0) continue;
  452.                                                
  453.                                                 if(PegasusDash == DIR_UP){                        
  454.                                                     dX = drawX;
  455.                                                     if(Dust_Array[i] < 4) dY = drawY+8;
  456.                                                     else dY = drawY+8+3+(Dust_Array[i]-1);
  457.                                                    
  458.                                                 }else if(PegasusDash == DIR_DOWN){
  459.                                                 dX = drawX;
  460.                                                
  461.                                                 if(Dust_Array[i] < 4) dY = drawY;
  462.                                                 else dY = drawY-3-(Dust_Array[i]-1);
  463.                                                
  464.                                             }else if(PegasusDash == DIR_LEFT){
  465.                                            
  466.                                             if(Dust_Array[i] < 4) dX = drawX;
  467.                                             else dX = drawX+3+(Dust_Array[i]-1);
  468.                                            
  469.                                             dY = drawY+8;
  470.                                            
  471.                                         }else if(PegasusDash == DIR_RIGHT){
  472.                                        
  473.                                         if(Dust_Array[i] < 4) dX = drawX;
  474.                                         else dX = drawX-3-(Dust_Array[i]-1);
  475.                                        
  476.                                         dY = drawY+8;
  477.                                     }
  478.                                    
  479.                                     Screen->FastTile(1, dX, dY, T_DUST+ Floor(Dust_Array[i]/DustASpeed), DustCSet, 128);
  480.                                    
  481.                                     if(Dust_Array[i] == DustAFrames*DustASpeed) Dust_Array[i] = 0;
  482.                                     else Dust_Array[i]++;
  483.                                 }
  484.                             }
  485.                            
  486.                             void DustDrawLW(){
  487.                                 if(PegasusDash < 0) return;
  488.                                
  489.                                 lweapon Dust;
  490.                                 if(DashCounter%4 == 0){
  491.                                     for(int j=1;j<=Screen->NumLWeapons();j++){
  492.                                         Dust = Screen->LoadLWeapon(j);
  493.                                         if(Dust->ID != LW_SCRIPT10) continue;
  494.                                         if(PegasusDash < 1) Dust->Y-=3;
  495.                                         else if(PegasusDash < 2) Dust->Y+=3;
  496.                                         else if(PegasusDash < 3) Dust->X-=3;
  497.                                         else if(PegasusDash < 4) Dust->X+=3;
  498.                                     }//end for loop
  499.                                    
  500.                                     Dust = Screen->CreateLWeapon(LW_SCRIPT10);
  501.                                     Dust->OriginalTile = T_DUST;
  502.                                     Dust->CSet = DustCSet;
  503.                                     Dust->Y = Link->Y+8;
  504.                                     Dust->X = Link->X;
  505.                                     Dust->NumFrames = DustAFrames;
  506.                                     Dust->ASpeed = DustASpeed;
  507.                                     Dust->DeadState = DustAFrames*DustASpeed;
  508.                                 }//end dust if
  509.                             }
  510.                            
  511.                            
  512.                             // Check whether Link can dash onto a combo
  513.                             int DashCheck(int x, int y, bool xy){
  514.                                 int xoffset; int yoffset;
  515.                                 bool Solid;
  516.                                
  517.                                 if(xy) xoffset = 4;
  518.                                 else yoffset = 3;
  519.                                
  520.                                 if(Screen->isSolid(x-xoffset,y-yoffset) || Screen->isSolid(x+xoffset,y+yoffset)) Solid = true;
  521.                                
  522.                                 if(Solid && CanDashSlash(x,y) ) Solid = false;
  523.                                
  524.                                 //Not solid and not a Dash combo return 0
  525.                                 if(!Solid && !ComboFI(x-xoffset,y-yoffset,CF_DASH) && !ComboFI(x+xoffset,y+yoffset,CF_DASH)) return 0;
  526.                                
  527.                                 //Is solid and is a Dash combo return 1
  528.                                 else if(Solid && (ComboFI(x-xoffset,y-yoffset,CF_DASH) || ComboFI(x+xoffset,y+yoffset,CF_DASH))) return 1;
  529.                                
  530.                                 //Is either solid without a Dash combo, or not solid with a Dash combo
  531.                                 else return 2;
  532.                             }
  533.                            
  534.                            
  535.                             //fixes a bug where you can't initiate a dash next to a slashable solid combo
  536.                             bool CanDashSlash(int x, int y){
  537.                                 if(LinkSwordEquip() == -1) return false;
  538.                                
  539.                                 int loc;
  540.                                 loc = ComboAt(x, y);
  541.                                
  542.                                 // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  543.                                 // can add more combo types here by adding     || Screen->ComboT[loc] == CT_
  544.                                 // CT_ types you might consider CT_SLASH, CT_SLASHNEXT, CT_SLASHNEXTITEM if those are solid in your quest
  545.                                
  546.                                 if(Screen->ComboT[loc] == CT_BUSH || Screen->ComboT[loc] == CT_BUSHNEXT )
  547.                                 return true;
  548.                                
  549.                                 return false;
  550.                             }
  551.                            
  552.                             // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  553.                             // replaces the code in old Pegasus boots function for dash cutting through slashable combos.
  554.                             // allows easier customization to suit your needs.
  555.                            
  556.                             void DoDashSlash(int loc){
  557.                                 int ctype = Screen->ComboT[loc];
  558.                                 int sprite;
  559.                                 int itmset = IS_COMBOS; // item set 12 (tall grass by default)
  560.                                
  561.                                 bool playsound = false;
  562.                                
  563.                                 // add sprites to certain types
  564.                                 if(ctype == CT_BUSH || ctype == CT_BUSHNEXT) sprite = SPRITE_BUSH_CUT;
  565.                                 else if(ctype == CT_TALLGRASS || ctype == CT_TALLGRASSNEXT) sprite = SPRITE_GRASS_CUT;
  566.                                 else if(ctype == CT_FLOWERS) sprite = SPRITE_FLOWER_CUT;
  567.                                
  568.                                 // no sprite is typically associated with Slash type combos, but it could be added.
  569.                                
  570.                                 // itemset is changed here to the default for these types.  could add more item sets based on type
  571.                                 if(ctype == CT_SLASHITEM || ctype == CT_SLASHNEXTITEM) itmset = 10; // default for these combo types
  572.                                
  573.                                 //these types default to undercombo
  574.                                 if(ctype == CT_BUSH || ctype == CT_TALLGRASS || ctype == CT_FLOWERS || ctype == CT_SLASH || ctype == CT_SLASHITEM){
  575.                                     Screen->ComboD[loc] = Screen->UnderCombo;
  576.                                     playsound = true;
  577.                                 }
  578.                                
  579.                                 //these types default to next combo
  580.                                 if(ctype == CT_BUSHNEXT || ctype == CT_TALLGRASSNEXT || ctype == CT_FLOWERS || ctype == CT_SLASHNEXT || ctype == CT_SLASHNEXTITEM){
  581.                                     Screen->ComboD[loc] += 1;
  582.                                     playsound = true;
  583.                                 }
  584.                                
  585.                                 //no functionality added for Continuous type combos.
  586.                                
  587.                                 if(playsound){
  588.                                     CreateGraphicAt(sprite,ComboX(loc),ComboY(loc));
  589.                                    
  590.                                     Game->PlaySound(SFX_GRASSCUT); // could have different sounds for different types too by modifyng above.
  591.                                     ItemSetAt(itmset,loc);
  592.                                 }//end playsound if
  593.                             }
  594.                            
  595.                            
  596.                             //returns the item# of an equipped sword.  checks and returns A button first, then B button.  returns -1 if no sword equipped.
  597.                             int LinkSwordEquip(){
  598.                                 itemdata itm = Game->LoadItemData( GetEquipmentA() );
  599.                                
  600.                                 if(itm->Family==IC_SWORD) return GetEquipmentA();
  601.                                
  602.                                 itm = Game->LoadItemData(GetEquipmentB());
  603.                                
  604.                                 if(itm->Family==IC_SWORD) return GetEquipmentB();
  605.                                
  606.                                 return -1;
  607.                             }
  608.                            
  609.                             // the combo that link is touching in the direction he's facing
  610.                             int TouchedComboLoc(){
  611.                                 int loc;
  612.                                 loc = ComboAt( TouchedX(), TouchedY() );
  613.                                 return loc;
  614.                             }
  615.                            
  616.                             // the x coord that link is touching in the direction he's facing
  617.                             int TouchedX(){
  618.                                 int x = 0;
  619.                                 if(Link->Dir == DIR_UP || Link->Dir == DIR_DOWN) x = Link->X+8;
  620.                                 else if(Link->Dir == DIR_LEFT)  x = Link->X-1;
  621.                                 else if(Link->Dir == DIR_RIGHT) x = Link->X+17;
  622.                                 return x;
  623.                             }
  624.                            
  625.                             // the y coord that link is touching in the direction he's facing
  626.                             int TouchedY(){
  627.                                 int y = 0;
  628.                                 if(Link->Dir == DIR_UP)         y = Link->Y+7;
  629.                                 else if(Link->Dir == DIR_DOWN)  y = Link->Y+17;
  630.                                 else if(Link->Dir == DIR_LEFT || Link->Dir == DIR_RIGHT)  y = Link->Y+8;
  631.                                 return y;
  632.                             }
  633.                            
  634.                             // draws a sprite as a non-damaging eweapon
  635.                             int CreateGraphicAt(int sprite, int x, int y){
  636.                                 eweapon e = Screen->CreateEWeapon(EW_SCRIPT1);
  637.                                 e->HitXOffset = 500;
  638.                                 e->UseSprite(sprite);
  639.                                 e->DeadState = Max(1,e->NumFrames*e->ASpeed);
  640.                                 e->X = x;
  641.                                 e->Y = y;
  642.                                 return e->DeadState;
  643.                             }
  644.                            
  645.                             //creates and kills an enemy of type NPC_ITEMSET to fake an itemdropset.
  646.                             void ItemSetAt(int itemset,int loc){
  647.                                 npc e = Screen->CreateNPC(NPC_ITEMSET);
  648.                                 e->ItemSet = itemset;
  649.                                 if(e->isValid()){
  650.                                     e->X = loc%16*16;
  651.                                     e->Y = loc-loc%16;
  652.                                 }
  653.                                 e->HP = HP_SILENT;
  654.                             }
  655.                            
  656.                            
  657.                             // utility function returns true if Link is jumping, necessary because SideView gravity sucks
  658.                             // might need tweaking depending on other SideView scripts you use.
  659.                            
  660.                             bool IsJumping(){
  661.                                 if(IsSideview()){
  662.                                     if(Link->Action == LA_SWIMMING || Link->Action == LA_DIVING || Link->Action == LA_DROWNING) return false;
  663.                                     if(Link->Jump != 0) return true;
  664.                                     if(!OnSidePlatform(Link->X,Link->Y)) return true;
  665.                                 }
  666.                                 else{
  667.                                     if(Link->Z > tempPatches::BASE_LINK_Z) return true;
  668.                                 }
  669.                                
  670.                                 return false;
  671.                             }
  672.                            
  673.                            
  674.                             // Allows drawing tiles to correct position on Link when scrolling
  675.                             // Sets drawX/drawY either to Link X/Y when not scrolling, or the visual position when scrolling.
  676.                             // currently only used by Pegasus Boots (which is also setting drawX/drawY to Link's new x/y as he dashes)
  677.                            
  678.                             void ScrollFix(){
  679.                                 //function by Saffith
  680.                                
  681.                                 if(Link->Action==LA_SCROLLING){
  682.                                     if(scrollDir==-1)
  683.                                     {
  684.                                         if(Link->Y>160)
  685.                                         {
  686.                                             scrollDir=DIR_UP;
  687.                                             scrollCounter=45;
  688.                                         }
  689.                                         else if(Link->Y<0)
  690.                                         {
  691.                                             scrollDir=DIR_DOWN;
  692.                                             scrollCounter=45;
  693.                                         }
  694.                                         else if(Link->X>240)
  695.                                         {
  696.                                             scrollDir=DIR_LEFT;
  697.                                             scrollCounter=65;
  698.                                         }
  699.                                         else
  700.                                         {
  701.                                             scrollDir=DIR_RIGHT;
  702.                                             scrollCounter=65;
  703.                                         }
  704.                                     }
  705.                                    
  706.                                     if(scrollDir==DIR_UP && scrollCounter<45 && scrollCounter>4)
  707.                                     drawY+=4;
  708.                                     else if(scrollDir==DIR_DOWN && scrollCounter<45 && scrollCounter>4)
  709.                                     drawY-=4;
  710.                                     else if(scrollDir==DIR_LEFT && scrollCounter<65 && scrollCounter>4)
  711.                                     drawX+=4;
  712.                                     else if(scrollDir==DIR_RIGHT && scrollCounter<65 && scrollCounter>4)
  713.                                     drawX-=4;
  714.                                    
  715.                                     scrollCounter--;
  716.                                 }
  717.                                 else
  718.                                 {
  719.                                     drawX=Link->X;
  720.                                     drawY=Link->Y;
  721.                                     if(scrollDir!=-1)
  722.                                     scrollDir=-1;
  723.                                 }
  724.                             }
  725.                            
  726.                             void LREx1Ex2ItemSwitch()
  727.                             {
  728.                                 if (Link->PressL && Link->Action != LA_SCROLLING)
  729.                                 {
  730.                                     Link->SelectBWeapon(DIR_LEFT);
  731.                                 }
  732.                                 if (Link->PressR && Link->Action != LA_SCROLLING)
  733.                                 {
  734.                                     Link->SelectBWeapon(DIR_RIGHT);
  735.                                 }
  736.                                 if (Link->PressEx1 && Link->Action != LA_SCROLLING)
  737.                                 {
  738.                                     Link->SelectAWeapon(DIR_LEFT);
  739.                                 }
  740.                                 if (Link->PressEx2 && Link->Action != LA_SCROLLING)
  741.                                 {
  742.                                     Link->SelectAWeapon(DIR_RIGHT);
  743.                                 }
  744.                             }
  745.                            
  746.                            
  747.                            
  748.                             int LinkOnComboD() {
  749.                                 return Screen->ComboD[ComboAt(Link->X+8, Link->Y+13)];
  750.                             }
  751.                            
  752.                            
  753.                             item script GhostZHClockScript
  754.                             {
  755.                                 void run(int duration)
  756.                                 {
  757.                                     if(duration<=0)
  758.                                     __ghzhData[__GHI_CLOCK_TIMER]=-1;
  759.                                     else
  760.                                     __ghzhData[__GHI_CLOCK_TIMER]=duration;
  761.                                 }
  762.                             }
  763.                            
  764.                            
  765.                            
  766.                             //Constants used by Ice Combos
  767.                             const int CT_ICECOMBO = 142; //The combo type "Script1 by default"
  768.                             const int ICE_ACCELERATION = 1;
  769.                             const int ICE_DECELERATION = 1;
  770.                             const int ICE_MAXSTEP     = 150;
  771.                            
  772.                             //Declare global variables used by Ice Combos.
  773.                             bool isScrolling;
  774.                             bool onice;
  775.                             float Ice_X;
  776.                             float Ice_Y;
  777.                             int Ice_XStep;
  778.                             int Ice_YStep;
  779.                             //End declaration
  780.                            
  781.                             //Active Script
  782.                            
  783.                            
  784.                             //Initializes global variables used for ice combos.
  785.                             void Setup_IceCombos()
  786.                             {
  787.                                 isScrolling = false;
  788.                                 onice = false;
  789.                                 Ice_X = 0;
  790.                                 Ice_Y = 0;
  791.                                 Ice_XStep = 0;
  792.                                 Ice_YStep = 0;
  793.                             }
  794.                            
  795.                             //Adds Ice Combo functionally to CT_ICECOMBO;
  796.                             void Update_IceCombos(int oldscreen)
  797.                             {
  798.                                 //Update Variables
  799.                                 if(Link->Action != LA_SCROLLING)
  800.                                 {
  801.                                     if(isScrolling || oldscreen != Game->GetCurScreen() || (!onice && OnIce()))
  802.                                     {
  803.                                         Ice_X = Link->X;
  804.                                         Ice_Y = Link->Y;
  805.                                         if(isScrolling)
  806.                                         isScrolling = false;
  807.                                         else
  808.                                         {
  809.                                             Ice_XStep = 0;
  810.                                             Ice_YStep = 0;
  811.                                         }
  812.                                     }
  813.                                     onice = OnIce();
  814.                                 }
  815.                                 else
  816.                                 {
  817.                                     isScrolling = true;
  818.                                     return;
  819.                                 }
  820.                                
  821.                                 //Ice Physics
  822.                                 if(onice)
  823.                                 {
  824.                                     //Y Adjustment
  825.                                     if(Link_Walking() && (Link->InputUp || Link->InputDown))
  826.                                     {
  827.                                         if(Link->InputUp && !Link->InputDown)
  828.                                         Ice_YStep -= ICE_ACCELERATION;
  829.                                         else if(!Link->InputUp && Link->InputDown)
  830.                                         Ice_YStep += ICE_ACCELERATION;
  831.                                     }
  832.                                     else if(Ice_YStep != 0)
  833.                                     Ice_YStep = Cond(Abs(Ice_YStep) - ICE_DECELERATION > 0, Ice_YStep - Sign(Ice_YStep)*ICE_DECELERATION, 0);
  834.                                     Ice_YStep = Clamp(Ice_YStep, -ICE_MAXSTEP, ICE_MAXSTEP);
  835.                                    
  836.                                     //X Adjustment
  837.                                     if(Link_Walking() && (Link->InputLeft || Link->InputRight))
  838.                                     {
  839.                                         if(Link->InputLeft && !Link->InputRight)
  840.                                         Ice_XStep -= ICE_ACCELERATION;
  841.                                         else if(!Link->InputLeft && Link->InputRight)
  842.                                         Ice_XStep += ICE_ACCELERATION;
  843.                                     }
  844.                                     else if(Ice_XStep != 0)
  845.                                     Ice_XStep = Cond(Abs(Ice_XStep) - ICE_DECELERATION > 0, Ice_XStep -Sign(Ice_XStep)*ICE_DECELERATION, 0);
  846.                                     Ice_XStep = Clamp(Ice_XStep, -ICE_MAXSTEP, ICE_MAXSTEP);
  847.                                    
  848.                                     //Reset the Ice Position to Link's Actual Position if he's hurt or hopping out of water.
  849.                                     if(Link->Action == LA_GOTHURTLAND || Link->Action == LA_HOPPING)
  850.                                     {
  851.                                         Ice_X = Link->X;
  852.                                         Ice_Y = Link->Y;
  853.                                     }
  854.                                    
  855.                                     //Initialize variables for solidity checking.
  856.                                     int newx = (Ice_X + Ice_XStep/100)<<0;
  857.                                     int newy = (Ice_Y + Ice_YStep/100)<<0;
  858.                                    
  859.                                     //Vertical Edge
  860.                                     if(newx < Ice_X<<0)
  861.                                     {
  862.                                         for(int y = Ice_Y+Cond(BIG_LINK, 0, 8); y < (Ice_Y<<0) + 16 && Ice_XStep != 0; y++)
  863.                                         {
  864.                                             if(Screen->isSolid(newx, y))
  865.                                             Ice_XStep = 0;
  866.                                         }
  867.                                     }
  868.                                     else if(newx > Ice_X<<0)
  869.                                     {
  870.                                         for(int y = Ice_Y+8; y < (Ice_Y<<0) + 16 && Ice_XStep != 0; y++)
  871.                                         {
  872.                                             if(Screen->isSolid(newx+15, y))
  873.                                             Ice_XStep = 0;
  874.                                         }
  875.                                     }
  876.                                    
  877.                                     //Horizontal Edge
  878.                                     if(newy < Ice_Y<<0)
  879.                                     {
  880.                                         for(int x = Ice_X; x < (Ice_X<<0) + 16 && Ice_YStep != 0; x++)
  881.                                         {
  882.                                             if(Screen->isSolid(x, newy+Cond(BIG_LINK, 0, 8)))
  883.                                             {
  884.                                                 Ice_YStep = 0;
  885.                                             }
  886.                                         }
  887.                                     }
  888.                                     else if(newy > Ice_Y<<0)
  889.                                     {
  890.                                         for(int x = Ice_X; x < (Ice_X<<0) + 16 && Ice_YStep != 0; x++)
  891.                                         {
  892.                                             if(Screen->isSolid(x, newy+15))
  893.                                             {
  894.                                                 Ice_YStep = 0;
  895.                                             }
  896.                                         }
  897.                                     }
  898.                                    
  899.                                     Ice_X += Ice_XStep/100;
  900.                                     Ice_Y += Ice_YStep/100;
  901.                                     Link->X = Ice_X;
  902.                                     Link->Y = Ice_Y;
  903.                                 }
  904.                                 else
  905.                                 {
  906.                                     Ice_XStep = 0;
  907.                                     Ice_YStep = 0;
  908.                                 }
  909.                             }
  910.                            
  911.                             //Function used to check if Link is over a ice combo.
  912.                             bool OnIce()
  913.                             {
  914.                                 if(Link->Z != tempPatches::BASE_LINK_Z)
  915.                                 return false;
  916.                                 else
  917.                                 {
  918.                                     int comboLoc = ComboAt(Link->X + 8, Link->Y + 12);
  919.                                     if(Screen->ComboT[comboLoc] == CT_ICECOMBO)
  920.                                     return true;
  921.                                     else if(Screen->LayerScreen(1) != -1 && GetLayerComboT(1, comboLoc) == CT_ICECOMBO)
  922.                                     return true;
  923.                                     else if(Screen->LayerScreen(2) != -1 && GetLayerComboT(2, comboLoc) == CT_ICECOMBO)
  924.                                     return true;
  925.                                     else
  926.                                     return false;
  927.                                 }
  928.                             }
  929.                            
  930.                             //Returns true, if keyboard input is moving Link.
  931.                             bool Link_Walking()
  932.                             {
  933.                                 if(UsingItem(I_HAMMER)) return false;
  934.                                 else return (Link->Action == LA_WALKING || Link->Action == LA_CHARGING || Link->Action == LA_SPINNING);
  935.                             }
  936.                            
  937.                            
  938.                            
  939.                             int MooshPit[16];
  940.                             const int MP_LASTX = 0;
  941.                             const int MP_LASTY = 1;
  942.                             const int MP_LASTDMAP = 2;
  943.                             const int MP_LASTSCREEN = 3;
  944.                             const int MP_ENTRYX = 4;
  945.                             const int MP_ENTRYY = 5;
  946.                             const int MP_ENTRYDMAP = 6;
  947.                             const int MP_ENTRYSCREEN = 7;
  948.                             const int MP_FALLX = 8;
  949.                             const int MP_FALLY = 9;
  950.                             const int MP_FALLTIMER = 10;
  951.                             const int MP_FALLSTATE = 11;
  952.                             const int MP_DAMAGETYPE = 12;
  953.                            
  954.                             const int CT_HOLELAVA = 128; //Combo type for pits (No Ground Enemies by default)
  955.                             const int CF_LAVA = 98; //Combo flag marking pits as lava (Script 1 by default)
  956.                            
  957.                             const int SPR_FALLHOLE = 89; //Sprite for Link falling in a hole
  958.                             const int SPR_FALLLAVA = 90; //Sprite for Link falling in lava
  959.                            
  960.                             const int SFX_FALLHOLE = 87; //Sound for falling in a hole
  961.                             const int SFX_FALLLAVA = 13; //Sound for falling in lava
  962.                            
  963.                             const int DAMAGE_FALLHOLE = 8; //How much damage pits deal (1/2 heart default)
  964.                             const int DAMAGE_FALLLAVA = 16; //How much damage lava deals (1 heart default)
  965.                            
  966.                             const int FFC_MOOSHPIT_AUTOWARPA = 32; //FFC that turns into an auto side warp combo when you fall in a pit
  967.                             const int CMB_MOOSHPIT_AUTOWARPA = 6391; //Combo number of an invisible Auto Side Warp A combo
  968.                             const int SF_MISC_MOOSHPITWARP = 2; //Number of the screen flag under the Misc. section that makes pits warp (Script 1 by default)
  969.                             //All pit warps use Side Warp A
  970.                            
  971.                             const int MOOSHPIT_MIN_FALL_TIME = 60; //Minimum time for the pit's fall animation, to prevent repeated falling in pits
  972.                             const int MOOSHPIT_EXTRA_FALL_TIME = 0; //Extra frames at the end of the falling animation before Link respawns
  973.                            
  974.                             //Width and height of Link's hitbox for colliding with pits
  975.                             const int MOOSHPIT_LINKHITBOXWIDTH = 2;
  976.                             const int MOOSHPIT_LINKHITBOXHEIGHT = 2;
  977.                            
  978.                             //Width and height of Link's hitbox for colliding with pits/lava in sideview
  979.                             const int MOOSHPIT_SIDEVIEW_LINKHITBOXWIDTH = 2;
  980.                             const int MOOSHPIT_SIDEVIEW_LINKHITBOXHEIGHT = 2;
  981.                            
  982.                             const int MOOSHPIT_NO_GRID_SNAP = 0; //Set to 1 to prevent Link's falling sprite from snapping to the combo grid.
  983.                            
  984.                             bool MooshPit_OnPit(int LinkX, int LinkY, bool countFFCs){
  985.                                 if(Link->Action==LA_FROZEN)
  986.                                 return false;
  987.                                
  988.                                 if(countFFCs){
  989.                                     if(MooshPit_OnFFC(LinkX, LinkY))
  990.                                     return false;
  991.                                 }
  992.                                
  993.                                 bool sideview;
  994.                                 if(Screen->Flags[SF_ROOMTYPE]&100b)
  995.                                 sideview = true;
  996.                                 //wew lad
  997.                                 int width = MOOSHPIT_LINKHITBOXWIDTH;
  998.                                 int height = MOOSHPIT_LINKHITBOXHEIGHT;
  999.                                 for(int x=0; x<=1; x++){
  1000.                                     for(int y=0; y<=1; y++){
  1001.                                         int X; int Y;
  1002.                                         if(sideview){ //Hitbox functions differently in sideview
  1003.                                             width = MOOSHPIT_SIDEVIEW_LINKHITBOXWIDTH;
  1004.                                             height = MOOSHPIT_SIDEVIEW_LINKHITBOXHEIGHT;
  1005.                                             X = LinkX+7-width/2+width;
  1006.                                             Y = LinkY+7-height/2+height;
  1007.                                         }
  1008.                                         else{
  1009.                                             X = LinkX+7-width/2+width;
  1010.                                             Y = LinkY+11-height/2+height;
  1011.                                         }
  1012.                                        
  1013.                                         //If one corner of Link's hitbox isn't on a pit, return false
  1014.                                         if(Screen->ComboT[ComboAt(X, Y)]!=CT_HOLELAVA){
  1015.                                             return false;
  1016.                                         }
  1017.                                     }
  1018.                                 }
  1019.                                 return true;
  1020.                             }
  1021.                            
  1022.                             bool MooshPit_OnFFC(int LinkX, int LinkY){
  1023.                                 for(int i=1; i<=32; i++){ //Cycle through every FFC
  1024.                                     ffc f = Screen->LoadFFC(i);
  1025.                                     //Check if the FFC is solid
  1026.                                     if(f->Data>0&&!f->Flags[FFCF_CHANGER]&&!f->Flags[FFCF_ETHEREAL]){
  1027.                                         //Check if Link collides with the FFC
  1028.                                         if(RectCollision(LinkX+4, LinkY+9, LinkX+11, LinkY+14, f->X, f->Y, f->X+f->EffectWidth-1, f->Y+f->EffectHeight-1)){
  1029.                                             return true;
  1030.                                         }
  1031.                                     }
  1032.                                 }
  1033.                                 //If Link doesn't collide with any FFC, return false
  1034.                                 return false;
  1035.                             }
  1036.                            
  1037.                             void MooshPit_Init(){
  1038.                                 MooshPit[MP_LASTX] = Link->X;
  1039.                                 MooshPit[MP_LASTY] = Link->Y;
  1040.                                 MooshPit[MP_LASTDMAP] = Game->GetCurDMap();
  1041.                                 MooshPit[MP_LASTSCREEN] = Game->GetCurDMapScreen();
  1042.                                 MooshPit[MP_ENTRYX] = Link->X;
  1043.                                 MooshPit[MP_ENTRYY] = Link->Y;
  1044.                                 MooshPit[MP_ENTRYDMAP] = Game->GetCurDMap();
  1045.                                 MooshPit[MP_ENTRYSCREEN] = Game->GetCurDMapScreen();
  1046.                                 MooshPit[MP_FALLSTATE] = 0;
  1047.                                 MooshPit[MP_FALLTIMER] = 0;
  1048.                                 Link->CollDetection = true;
  1049.                                 Link->Invisible = false;
  1050.                             }
  1051.                            
  1052. void MooshPit_Update()
  1053. {
  1054.     bool isWarp;
  1055.     if(Screen->Flags[SF_MISC]&(1<<SF_MISC_MOOSHPITWARP))
  1056.     isWarp = true;
  1057.    
  1058.     bool sideview;
  1059.     if(Screen->Flags[SF_ROOMTYPE]&100b)
  1060.     sideview = true;
  1061.    
  1062.     if(Link->Action!=LA_SCROLLING){
  1063.         //Update the entry point whenever the screen changes
  1064.         if(MooshPit[MP_ENTRYDMAP]!=Game->GetCurDMap()||MooshPit[MP_ENTRYSCREEN]!=Game->GetCurDMapScreen()){
  1065.             MooshPit[MP_ENTRYX] = Link->X;
  1066.             MooshPit[MP_ENTRYY] = Link->Y;
  1067.             MooshPit[MP_ENTRYDMAP] = Game->GetCurDMap();
  1068.             MooshPit[MP_ENTRYSCREEN] = Game->GetCurDMapScreen();
  1069.         }
  1070.        
  1071.         if(MooshPit[MP_FALLSTATE]==0)
  1072.         { //Not falling in pit
  1073.             LogPrint("FallState == 0 %s \n", "checking if over a pit");
  1074.             LogPrint("Link is over a pit 2? %s \n", ( (MooshPit_OnPit(Link->X, Link->Y, true)) ? "true" : "false"));
  1075.            
  1076.             if(Link->Z<=tempPatches::BASE_LINK_Z&&MooshPit_OnPit(Link->X, Link->Y, true))
  1077.             {
  1078.                 LogPrint("Link is over a pit 3? %s \n", ( (MooshPit_OnPit(Link->X, Link->Y, true)) ? "true" : "false"));
  1079.            
  1080.                 //If Link steps on a pit
  1081.                 int underLink;
  1082.                 if(!sideview)
  1083.                 underLink = ComboAt(Link->X+8, Link->Y+12);
  1084.                 else
  1085.                 underLink = ComboAt(Link->X+8, Link->Y+8);
  1086.                 StopDash();
  1087.                
  1088.                 lweapon fall;
  1089.                
  1090.                 //Check if the combo is lava
  1091.                 if(ComboFI(underLink, CF_LAVA))
  1092.                 {
  1093.                     LogPrint("We should be %s \n", "playing a sound for Lava");
  1094.                     //Play sound and display animation
  1095.                     Game->PlaySound(SFX_FALLLAVA);
  1096.                     fall = CreateLWeaponAt(LW_SCRIPT10, Link->X, Link->Y);
  1097.                     if(!MOOSHPIT_NO_GRID_SNAP){
  1098.                         fall->X = ComboX(underLink);
  1099.                         fall->Y = ComboY(underLink);
  1100.                     }
  1101.                     fall->UseSprite(SPR_FALLLAVA);
  1102.                     fall->CollDetection = false;
  1103.                     fall->DeadState = fall->ASpeed*fall->NumFrames;
  1104.                    
  1105.                     //Mark as lava damage
  1106.                     MooshPit[MP_DAMAGETYPE] = 1;
  1107.                 }
  1108.                 //Otherwise it's a pit
  1109.                 else
  1110.                 {
  1111.                     LogPrint("We should be %s \n", "playing a sound for a pit");
  1112.                     //Play sound and display animation
  1113.                     Game->PlaySound(SFX_FALLHOLE);
  1114.                     fall = CreateLWeaponAt(LW_SCRIPT10, Link->X, Link->Y);
  1115.                     if(!MOOSHPIT_NO_GRID_SNAP){
  1116.                         fall->X = ComboX(underLink);
  1117.                         fall->Y = ComboY(underLink);
  1118.                     }
  1119.                     fall->UseSprite(SPR_FALLHOLE);
  1120.                     fall->CollDetection = false;
  1121.                     fall->DeadState = fall->ASpeed*fall->NumFrames;
  1122.                    
  1123.                     //Mark as hole damage
  1124.                     MooshPit[MP_DAMAGETYPE] = 0;
  1125.                 }
  1126.                
  1127.                 MooshPit[MP_FALLX] = Link->X;
  1128.                 MooshPit[MP_FALLY] = Link->Y;
  1129.                
  1130.                 //Cooldown should last as long as the fall animation
  1131.                 MooshPit[MP_FALLSTATE] = 1;
  1132.                 MooshPit[MP_FALLTIMER] = Max(MOOSHPIT_MIN_FALL_TIME, fall->DeadState+MOOSHPIT_EXTRA_FALL_TIME);
  1133.                
  1134.                 //Render Link invisible and intangible
  1135.                 Link->Invisible = true;
  1136.                 Link->CollDetection = false;
  1137.                
  1138.                 NoAction();
  1139.                 StopDash();
  1140.             }
  1141.             else if(!MooshPit_OnPit(Link->X, Link->Y, false)&&Link->Action!=LA_FROZEN){ //All other times, while Link is on solid ground, record Link's last position
  1142.                 if(sideview){
  1143.                     //Link has no Z value in sideview, so we check if he's on a platform instead
  1144.                     if(OnSidePlatform(Link->X, Link->Y)){
  1145.                         MooshPit[MP_LASTDMAP] = Game->GetCurDMap();
  1146.                         MooshPit[MP_LASTSCREEN] = Game->GetCurDMapScreen();
  1147.                         MooshPit[MP_LASTX] = Link->X;
  1148.                         MooshPit[MP_LASTY] = Link->Y;
  1149.                     }
  1150.                 }
  1151.                 else{
  1152.                     if(Link->Z<=tempPatches::BASE_LINK_Z){
  1153.                         MooshPit[MP_LASTDMAP] = Game->GetCurDMap();
  1154.                         MooshPit[MP_LASTSCREEN] = Game->GetCurDMapScreen();
  1155.                         MooshPit[MP_LASTX] = Link->X;
  1156.                         MooshPit[MP_LASTY] = Link->Y;
  1157.                     }
  1158.                 }
  1159.             }
  1160.         }
  1161.         else if(MooshPit[MP_FALLSTATE]==1){ //Falling animation
  1162.             if(MooshPit[MP_FALLTIMER]>0)
  1163.             MooshPit[MP_FALLTIMER]--;
  1164.            
  1165.             Link->Jump = 0;
  1166.             Link->Z = 0;
  1167.            
  1168.             //Keep Link invisible just in case
  1169.             Link->Invisible = true;
  1170.             Link->CollDetection = false;
  1171.             NoAction();
  1172.             StopDash();
  1173.             if(MooshPit[MP_FALLTIMER]==0){
  1174.                 if(!isWarp||MooshPit[MP_DAMAGETYPE]==1){ //If the pit isn't a warp, deal damage and move Link back to the return point
  1175.                     //If the entry would dump Link back in the pit, dump him out at the failsafe position
  1176.                     if(MooshPit_OnPit(MooshPit[MP_ENTRYX], MooshPit[MP_ENTRYY], false)){
  1177.                         Link->X = MooshPit[MP_LASTX];
  1178.                         Link->Y = MooshPit[MP_LASTY];
  1179.                         //If the failsafe position was on a different screen, warp there
  1180.                         if(Game->GetCurDMap()!=MooshPit[MP_LASTDMAP]||Game->GetCurDMapScreen()!=MooshPit[MP_LASTSCREEN]){
  1181.                             Link->PitWarp(MooshPit[MP_LASTDMAP], MooshPit[MP_LASTSCREEN]);
  1182.                         }
  1183.                        
  1184.                         Link->Invisible = false;
  1185.                         Link->CollDetection = true;
  1186.                     }
  1187.                     else{
  1188.                         //Move Link to the start and make him visible
  1189.                         Link->X = MooshPit[MP_ENTRYX];
  1190.                         Link->Y = MooshPit[MP_ENTRYY];
  1191.                        
  1192.                         Link->Invisible = false;
  1193.                         Link->CollDetection = true;
  1194.                     }
  1195.                    
  1196.                     //Subtract HP based on damage type
  1197.                     if(MooshPit[MP_DAMAGETYPE]==1)
  1198.                     Link->HP -= DAMAGE_FALLLAVA;
  1199.                     else
  1200.                     Link->HP -= DAMAGE_FALLHOLE;
  1201.                     //Play hurt sound and animation
  1202.                     Link->Action = LA_GOTHURTLAND;
  1203.                     Link->HitDir = -1;
  1204.                     Game->PlaySound(SFX_OUCH);
  1205.                    
  1206.                     MooshPit[MP_FALLSTATE] = 0;
  1207.                 }
  1208.                 else{
  1209.                     MooshPit[MP_FALLSTATE] = 2;
  1210.                     MooshPit[MP_FALLTIMER] = 1;
  1211.                     ffc warp = Screen->LoadFFC(FFC_MOOSHPIT_AUTOWARPA);
  1212.                     warp->Data = CMB_MOOSHPIT_AUTOWARPA;
  1213.                     warp->Flags[FFCF_CARRYOVER] = false;
  1214.                 }
  1215.             }
  1216.         }
  1217.         else if(MooshPit[MP_FALLSTATE]==2){ //Just warped
  1218.             if(sideview){
  1219.                 Link->X = MooshPit[MP_FALLX];
  1220.                 Link->Y = 0;
  1221.             }
  1222.             else{
  1223.                 Link->X = MooshPit[MP_FALLX];
  1224.                 Link->Y = MooshPit[MP_FALLY];
  1225.                 Link->Z = 176;
  1226.             }
  1227.             Link->Invisible = false;
  1228.             Link->CollDetection = true;
  1229.            
  1230.             MooshPit[MP_FALLSTATE] = 0;
  1231.             MooshPit[MP_FALLTIMER] = 0;
  1232.         }
  1233.     }
  1234. }
  1235.                            
  1236.                             void MooshPit_ResetEntry(){
  1237.                                 MooshPit[MP_ENTRYX] = Link->X;
  1238.                                 MooshPit[MP_ENTRYY] = Link->Y;
  1239.                                 MooshPit[MP_ENTRYDMAP] = Game->GetCurDMap();
  1240.                                 MooshPit[MP_ENTRYSCREEN] = Game->GetCurDMapScreen();
  1241.                             }
  1242.                            
  1243.                             //Set this to the item's ID.
  1244.                             const int POTION_ID = 146;
  1245.                            
  1246.                             //Set this to the number of the sound effect to be played when the medicine takes effect.
  1247.                             const int POTION_SFX = 22;
  1248.                            
  1249.                             //Set to 1 if you want a message to be displayed when the medicine takes effect.
  1250.                             //Set to 0 if you don't want a message to be displayed.
  1251.                             const int DISPLAY_MESSAGE = 1;
  1252.                            
  1253.                             //Set this to the number of the message that will be displayed when the medicine takes effect.
  1254.                             const int MESSAGE = 1;
  1255.  
  1256.                    
  1257.                            
  1258.                             void onScreenChange()
  1259. {
  1260.     Game->SkipF6 = false;
  1261. }
  1262.  
  1263.  
  1264. global script slot2
  1265. {
  1266.     void run()
  1267.     {
  1268.         TraceS("@Running globl");
  1269.         // Initialize variables used to listen on screen changes
  1270.         int curscreen = -1; int lastScreen = Game->GetCurScreen();
  1271.         int lastMap = Game->GetCurMap();
  1272.         int oldscreen = Game->GetCurScreen();
  1273.         StartGhostZH();
  1274.        
  1275.         while (true)
  1276.         {
  1277.             ScrollFix();
  1278.             UpdateGhostZH1();
  1279.             PegasusBoots();
  1280.             PushAnimation();
  1281.             LogPrint("Link->Z is %d \n ", Link->Z);
  1282.             LogPrint("DashCounter is %d \n ", DashCounter);
  1283.             LogPrint("Link is over a pit? %s \n", ( (MooshPit_OnPit(Link->X, Link->Y, true)) ? "true" : "false"));
  1284.             MooshPit_Update();
  1285.            
  1286.             if (Link->HP <= 0 && Link->Item[POTION_ID])
  1287.             {
  1288.                 Link->HP = Link->MaxHP;
  1289.                 Link->Item[POTION_ID] = false;
  1290.                 Game->PlaySound(POTION_SFX);
  1291.                
  1292.                 if (DISPLAY_MESSAGE > 0) {
  1293.                     Screen->Message(MESSAGE);
  1294.                 }
  1295.             }
  1296.             if(lastScreen != Game->GetCurScreen() || lastMap != Game->GetCurMap())
  1297.             {
  1298.                 onScreenChange();
  1299.                 lastScreen = Game->GetCurScreen();
  1300.                 lastMap = Game->GetCurMap();
  1301.             }
  1302.             Waitdraw();
  1303.             UpdateGhostZH2();
  1304.             // Keep track of screen changes
  1305.             // Run a Barrier script on every screen change
  1306.             if (Game->GetCurScreen() != curscreen)
  1307.             {
  1308.                 curscreen = Game->GetCurScreen();
  1309.                 Barriers_NewScreen();
  1310.             }
  1311.             LREx1Ex2ItemSwitch();
  1312.            
  1313.            
  1314.             Update_IceCombos(oldscreen);
  1315.             oldscreen = Game->GetCurScreen();
  1316.            
  1317.            
  1318.  
  1319.             Waitframe();
  1320.                
  1321.         }
  1322.            
  1323.     }
  1324. }
  1325.  
  1326. global script Init
  1327. {
  1328.     void run()
  1329.     {
  1330.         MooshPit_Init();
  1331.     }
  1332. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement