Advertisement
ZoriaRPG

Mitsukara's Shield Code Converted into Functions

Nov 18th, 2016
196
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 20.56 KB | None | 0 0
  1. /// Global Constants, Arrays, and Variables
  2. int FrozenLink = 0; //Increase this variable when Link is hit by something that would freeze him.
  3.  
  4. void FreezeLinkUpdate(){ //The function handling the freezing of Link.
  5.  if(FrozenLink > 0){ //Should Link be frozen?
  6.   NoAction(); //Kill his inputs
  7.   FrozenLink --; //Decrement the counter
  8.  }
  9. }
  10. //Arrays
  11. float PitsLava[256]; //Array for Holelava. Set to an arbitrarily large size. Min [2]
  12. float GB_Shield[256]; //Array to hold shield values. Set to an arbitrarily large size. Min [3]
  13. bool isScrolling;
  14. bool onice;
  15. float Ice_X;
  16. float Ice_Y;
  17.  
  18. //Common Constant, only need to define once per script file.
  19. const int BIG_LINK                  = 0;   //Set this constant to 1 if using the Large Link Hit Box feature.
  20.  
  21. //Constants used by Bottomless Pits & Lava.
  22. const int CT_HOLELAVA              = 128; //Combo type to use for pit holes and lava."No Ground Enemies by default"
  23. const int CF_PIT                   = 101;  //The combo flag to register combos as pits.
  24. const int CF_LAVA                  = 102;  //The combo flag to register combos as lava.
  25. const int WPS_LINK_FALL            = 88;  //The weapon sprite to display when Link falls into a pit. "Sprite 88 by default"
  26. const int WPS_LINK_LAVA            = 92;  //The weapon sprite to display when Link drowns in lava. "Sprite 89 by default"
  27. const int SFX_LINK_FALL            = 61;  //The sound to play when Link falls into a pit. "SFX_FALL by default"
  28. const int SFX_LINK_LAVA            = 55;  //The sound to play when Link drowns in Lava. "SFX_SPLASH by default.
  29. const int CMB_AUTOWARP             = 44;  //The first of your four transparent autowarp combos.
  30. const int HOLELAVA_DAMAGE          = 8;   //Damage in hit points to inflict on link. "One Heart Container is worth 16 hit points"
  31.  
  32.  
  33. //Constants for Mitsukara's Code
  34. const int SFX_FALL = 38;
  35. const int SPRITE_ENEMY_FALL = 98;
  36. const int SPRITE_ENEMY_LAVA = 91;
  37.  
  38. //Shield Sound Effects
  39.  
  40.  
  41.  
  42. //Constants for Array Accessors
  43.  
  44.  
  45. //Array Indices of PitsLava[]
  46. const int HL_FALLING               = 0;
  47. const int HL_WARPING               = 1;
  48. const int HL_OLDDMAP               = 2;
  49. const int HL_OLDSCREEN             = 3;
  50. const int HL_STARTX                = 4;
  51. const int HL_STARTY                = 5;
  52. const int HL_STARTDIR              = 6;
  53.  
  54. float GlobalRAM[214747];
  55.  
  56. //GlobalRAM[] Indices:
  57. const int STORE_LINK_X          = 1000;
  58. const int STORE_LINK_Y          = 1001;
  59. const int STORE_LINK_Z          = 1002;
  60. const int STORE_LINK_JUMP       = 1003;
  61. const int MAP_OPEN              = 1004;
  62. const int MAP_DISPLAY_TIMER     = 1005;
  63.  
  64. const int TRACE_FIRST_MAP_USE   = 4000;
  65. //common variables
  66.  
  67.  
  68. //////////////////////
  69. /// Global Scripts ///
  70. //////////////////////
  71.  
  72. global script active{                          
  73.     void run(){
  74.           //Setup variables for ice combos.
  75.         Setup_IceCombos();
  76.  
  77.         //Variable that stores Game->GetCurScreen() the previous frame.
  78.         int oldscreen = Game->GetCurScreen();
  79.  
  80.         int s_version_id[]="Script Version 8.2, 28th feb, 2016 GMT";
  81.         TraceNL();
  82.         TraceS(s_version_id);
  83.         TraceNL();
  84.         Is(MAP_OPEN,0);
  85.         StartGhostZH(); //! Enable if using ghost.zh
  86.         InitHoleLava(); //Inits Tamamo's holes and lava.
  87.         npc e;
  88.         int q;
  89.         bool Blocking;
  90.         Game->LKeys[400] = 0;
  91.         while(true){
  92.            
  93.             ScrollFix();
  94.             PegasusBoots();
  95.            
  96.             UpdateGhostZH1();//! Enable if using ghost.z
  97.             FreezeLinkUpdate();
  98.             GLB_Sideview_Ladder();      
  99.             if ( Link->PressEx4 && Link->Action != LA_SCROLLING ) Map();
  100.             if ( Link->PressEx4 && !Is(MAP_OPEN) ) {
  101.                 Is(MAP_OPEN,1);
  102.                 Is(MAP_DISPLAY_TIMER,1);
  103.             }
  104.             if ( Is(MAP_OPEN) ) {
  105.                 if ( !Is(MAP_DISPLAY_TIMER) ) Map(); //Run a one frame timer to ensure that we save Link's coordinates.
  106.                 else if ( Is(MAP_DISPLAY_TIMER) ) Is(MAP_DISPLAY_TIMER,0);
  107.             }
  108.             Secret_Medicine();
  109.            
  110.             //Mitsukara Things
  111.            
  112.             MitsukaraNPCs();
  113.             MitsukaraShieldPush();
  114.            
  115.             Waitdraw();
  116.            
  117.             Update_IceCombos(oldscreen);
  118.             oldscreen = Game->GetCurScreen();
  119.            
  120.             Update_HoleLava2();
  121.            
  122.             if (Link->Action != LA_SCROLLING){
  123.                 RunHoleLava(); //Main Tamamo Holes and Lava function.
  124.             }
  125.             UpdateGhostZH2(); //! Enable if using ghost.zh
  126.             //LREx1Ex2ItemSwitch(); //! Enable if you want to allow A+B item switchign with Ex1/Ex2
  127.             if ( Link->PressEx4 ){
  128.                 Link->PressEx4 = false;
  129.                 freezeScreen();
  130.                 showMap();
  131.                 Link->Jump=0;
  132.                 unfreezeScreen();
  133.             }
  134.             if(Link->Item[LTM_HOLDING]){
  135.                 if(CountFFCsRunning(SCRIPT_POWERBRACELET)==0 && holding_block>0){
  136.                     holding_block = 0;
  137.                     Link->Item[LTM_HOLDING] = false;
  138.                     Link->Item[LTM_CATCHING] = false;
  139.                     Link->Item[LTM_PULLING] = false;
  140.                     if (onLadder) Link->Dir = DIR_UP;
  141.                 }
  142.             }
  143.             Waitframe();
  144.         }//end whileloop
  145.     }//end run
  146. }//end global active script (slot2)(); //Main Tamamo Holes and Lava function.
  147.            
  148.            
  149.            
  150.            
  151.            
  152. void MitsukaraNPCs(){
  153.     //!NPCs Loop
  154.     for(q = Screen->NumNPCs(); q > 0; q-- ){
  155.         e = Screen->LoadNPC(q);
  156.         if(!e->isValid()) continue;
  157.         if (e->isValid()){
  158.            
  159.             // Enemy falls in pits and water
  160.             if (Screen->ComboI[ComboAt(e->X+2,e->Y+2)] == CF_PIT && Screen->ComboI[ComboAt(e->X+14,e->Y+14)] == CF_PIT){
  161.                 if (e->Type == NPCT_WALK || e->Type == NPCT_LEEVER){
  162.                     lweapon EFall = CreateLWeaponAt(LW_SPARKLE,e->X+((e->TileWidth - 1) * 8),e->Y+4+((e->TileHeight - 1) * 16));
  163.                     if (EFall->isValid()) EFall->UseSprite(SPRITE_ENEMY_FALL);
  164.                     Remove(e);
  165.                     Game->PlaySound(SFX_FALL); // Default falling noise
  166.                 }
  167.             }
  168.             if (e->Type == NPCT_WALK || e->Type == NPCT_LEEVER){
  169.                 if (Screen->ComboI[ComboAt(e->X+2,e->Y+2)] == CF_LAVA && Screen->ComboI[ComboAt(e->X+14,e->Y+14)] == CF_LAVA || Screen->ComboT[ComboAt(e->X+2,e->Y+2)] == CT_WATER && Screen->ComboT[ComboAt(e->X+14,e->Y+14)] == CT_WATER){
  170.                     lweapon ESploosh = CreateLWeaponAt(LW_SPARKLE,e->X,e->Y+4);
  171.                     if (IsSideview()) ESploosh->Y = e->Y+8+(e->HitHeight-16);
  172.                     if (ESploosh->isValid()) ESploosh->UseSprite(SPRITE_ENEMY_LAVA);
  173.                     Remove(e);
  174.                     Game->PlaySound(SFX_FALL);
  175.                 }
  176.             }
  177.            
  178.             //Shield pushes an enemy
  179.             // Attributes[10] means:
  180.             // 1 - Push Link and enemy
  181.             // 2 - Push only Link
  182.             // 3 - Push only enemy
  183.             // 4 - Magic shield to push both
  184.             // 5 - Urchin
  185.             // 6 - Magic Shield urchin
  186.             // 7 - Killed by shield
  187.             if (e->isValid() && Blocking == true && LinkCollision(e) && e->CollDetection != 0){
  188.                 if (e->Attributes[10] == 5 || e->Attributes[10] == 6 && Link->Item[8] == true || e->Attributes[10] == 6 && Link->Item[159] == true){
  189.                     if (Link->Dir == DIR_UP && e->Y < Link->Y){
  190.                         e->Y --;
  191.                         Link->Y = Link->Y +2;
  192.                     }
  193.                     if (Link->Dir == DIR_DOWN && e->Y > Link->Y + 12){
  194.                         e->Y ++;
  195.                         Link->Y = Link->Y -2;
  196.                     }
  197.                     if (Link->Dir == DIR_LEFT && e->X < Link->X){
  198.                         e->X --;
  199.                         Link->X = Link->X +2;
  200.                     }
  201.                     if (Link->Dir == DIR_RIGHT && e->X > Link->X + 12){
  202.                         e->X ++;
  203.                         Link->X = Link->X -2;
  204.                     }
  205.  
  206.                 }
  207.                 if (e->Attributes[10] == 1 || e->Attributes[10] == 2 || e->Attributes[10] == 3 || e->Attributes[10] == 4 || e->Attributes[10] == 11 || e->Attributes[10] == 7 || e->Attributes[10] == 12 || e->Hunger == 3){
  208.                     if (e->Attributes[10] != 4 || Link->Item[174] == true || Link->Item[175] == true || e->Hunger == 3){
  209.                         if (Link->Dir == DIR_UP && e->Y < Link->Y){
  210.                             if (e->Attributes[10] == 7) e->HP = 0;
  211.                             if (e->Attributes[10] != 7 && Game->LKeys[400] < 16 && e->Hunger != 3) Game->LKeys[400] = Game->LKeys[400] + 8;
  212.                             if (e->Attributes[10] != 2 && e->Attributes[10] != 12){
  213.                                 e->Dir = DIR_DOWN;
  214.                                 if (e->Stun == 0) e->Stun = 16;
  215.                                 e->Misc[1] = 8;
  216.                             }
  217.                             Game->PlaySound(21);
  218.                         }
  219.                         if (Link->Dir == DIR_DOWN && e->Y > Link->Y+4){
  220.                             if (e->Attributes[10] == 7) e->HP = 0;
  221.                             if (e->Attributes[10] != 7 && Game->LKeys[400] < 16) Game->LKeys[400] = Game->LKeys[400] + 8;
  222.                             if (e->Attributes[10] != 2 && e->Attributes[10] != 12){
  223.                                 e->Dir = DIR_UP;
  224.                                 if (e->Stun == 0) e->Stun = 16;
  225.                                 e->Misc[1] = 8;
  226.                             }
  227.                             Game->PlaySound(21);
  228.                         }
  229.                         if (Link->Dir == DIR_LEFT && e->X < Link->X){
  230.                             if (e->Attributes[10] == 7) e->HP = 0;
  231.                             if (e->Attributes[10] != 7 && Game->LKeys[400] < 16) Game->LKeys[400] = Game->LKeys[400] + 8;
  232.                             if (e->Attributes[10] != 2 && e->Attributes[10] != 12){
  233.                                 e->Dir = DIR_RIGHT;
  234.                                 if (e->Stun == 0) e->Stun = 16;
  235.                                 e->Misc[1] = 8;
  236.                             }
  237.                             Game->PlaySound(21);
  238.                         }
  239.                         if (Link->Dir == DIR_RIGHT && e->X > Link->X + 4){
  240.                             if (e->Attributes[10] == 7) e->HP = 0;
  241.                             if (e->Attributes[10] != 7 && Game->LKeys[400] < 16) Game->LKeys[400] = Game->LKeys[400] + 8;
  242.                             if (e->Attributes[10] != 2 && e->Attributes[10] != 12){
  243.                                 e->Dir = DIR_LEFT;
  244.                                 if (e->Stun == 0) e->Stun = 16;
  245.                                 e->Misc[1] = 8;
  246.                             }
  247.                             Game->PlaySound(21);
  248.                         }
  249.                         if (e->Attributes[10] == 3) e->Stun = 240;
  250.                     }
  251.                 }  
  252.             }
  253.             // Enemy gets recoiled
  254.             if (e->Misc[1] > 0){ //! !Z! No idea what this is supposed to do.
  255.                 e->Misc[1] --;
  256.                 if (e->OriginalTile == 2616) e->Misc[1] = 0;
  257.                 else if (e->HP > 0){
  258.                     if (e->Dir == DIR_DOWN && e->Y > 3){
  259.                         if (Screen->ComboS[ComboAt(e->X+8, e->Y-4)] == 0 || Screen->ComboT[ComboAt(e->X+8, e->Y-4)] == CT_WATER || e->Type == NPCT_KEESE) e->Y = e->Y -4;
  260.                     }
  261.                     if (e->Dir == DIR_UP && e->Y < 159){
  262.                         if (Screen->ComboS[ComboAt(e->X+8, e->Y+20)] == 0 || Screen->ComboT[ComboAt(e->X+8, e->Y+20)] == CT_WATER || e->Type == NPCT_KEESE) e->Y = e->Y +4;
  263.                     }
  264.                     if (e->Dir == DIR_LEFT && e->X < 253){
  265.                         if (Screen->ComboS[ComboAt(e->X+20, e->Y+8)] == 0 || Screen->ComboT[ComboAt(e->X+20, e->Y+8)] == CT_WATER || e->Type == NPCT_KEESE) e->X = e->X +4;
  266.                     }
  267.                     if (e->Dir == DIR_RIGHT && e->X > 3){
  268.                         if (Screen->ComboS[ComboAt(e->X-4, e->Y+8)] == 0 || Screen->ComboT[ComboAt(e->X-4, e->Y+8)] == CT_WATER || e->Type == NPCT_KEESE) e->X = e->X -4;
  269.                    
  270.                     }
  271.                 }
  272.             }
  273.         }
  274.     }
  275. }
  276.  
  277. // ----- Shield pushing
  278. // (see also: for loop of NPCs)
  279.  
  280.  
  281. void MitsukaraShieldPush(){
  282.    
  283.     //I have no idea what these hardcoded item values are.
  284.     if (Link->Item[173] == true){
  285.         if (Link->Item[8] == true || Link->Item[37] == true || Link->Item[93] == false){
  286.             Link->Item[173] = false;
  287.             Blocking = false;
  288.         }
  289.     }
  290.     if (Link->Item[174] == true){
  291.         if (Link->Item[37] == true || Link->Item[8] == false){
  292.             Link->Item[174] = false;
  293.             Blocking = false;
  294.         }
  295.     }
  296.     if (Link->Item[175] == true && Link->Item[37] == false){
  297.         Link->Item[175] = false;
  298.         Blocking = false;
  299.     }
  300.  
  301.     if (GetEquipmentA() == 93 && Link->PressA || GetEquipmentB() == 93 && Link->PressB || GetEquipmentA() == 8 && Link->PressA || GetEquipmentB() == 8 && Link->PressB || GetEquipmentA() == 37 && Link->PressA || GetEquipmentB() == 37 && Link->PressB || Game->LItems[401] == LI_MAP && Link->PressR && Link->Item[93] == true) Game->PlaySound(91);
  302.  
  303.     if (Link->Action < 2 || Link->Action == LA_CHARGING){
  304.         if (GetEquipmentA() == 93 && Link->InputA || GetEquipmentB() == 93 && Link->InputB || Game->LItems[401] == LI_MAP && Link->InputR && Link->Item[93] == true && Link->Item[37] == false && Link->Item[8] == false){
  305.             if (Link->Item[173] == false){
  306.                 Link->Item[173] = true;
  307.                 Blocking = true;
  308.             }
  309.         }
  310.         if (GetEquipmentA() == 8 && Link->InputA || GetEquipmentB() == 8 && Link->InputB || Game->LItems[401] == LI_MAP && Link->InputR && Link->Item[8] == true && Link->Item[37] == false){
  311.             if (Link->Item[174] == false){
  312.                 Link->Item[174] = true;
  313.                 Blocking = true;
  314.             }
  315.         }
  316.         if (GetEquipmentA() == 37 && Link->InputA || GetEquipmentB() == 37 && Link->InputB || Game->LItems[401] == LI_MAP && Link->InputR && Link->Item[37] == true){
  317.             if (Link->Item[175] == false){
  318.                 Link->Item[175] = true;
  319.                 Blocking = true;
  320.             }
  321.         }
  322.     }
  323.     if (GetEquipmentA() == 93 && Link->InputA == false || GetEquipmentB() == 93 && Link->InputB == false || GetEquipmentA() == 8 && Link->InputA == false || GetEquipmentB() == 8 && Link->InputB == false || GetEquipmentA() == 37 && Link->InputA == false || GetEquipmentB() == 37 && Link->InputB == false || GetEquipmentA() != 93 && GetEquipmentB() != 93 && GetEquipmentA() != 8 && GetEquipmentB() != 8 && GetEquipmentA() != 37 && GetEquipmentB() != 37 || Link->Action > 2 && Link->Action != LA_CHARGING){
  324.         if (Game->LItems[401] !=  LI_MAP || !Link->InputR || Link->Action > 2 && Link->Action != LA_CHARGING){
  325.             if (Link->Item[173] == true) Link->Item[173] = false;
  326.             if (Link->Item[174] == true) Link->Item[174] = false;
  327.             if (Link->Item[175] == true) Link->Item[175] = false;
  328.             if (Blocking == true) Blocking = false;
  329.         }
  330.     }
  331. }
  332.  
  333.  
  334.  
  335.  
  336.  
  337.  
  338.  
  339.  
  340.  
  341. ////////////////////////
  342. /// GLOBAL FUNCTIONS ///
  343. ////////////////////////
  344.  
  345. void FixLinkOnLaddersForMap(){
  346.     if ( Is(MAP_OPEN) && !Is(MAP_DISPLAY_TIMER) ){
  347.        MaintainLinkCoordinates();
  348.     }
  349. }
  350.  
  351.            
  352. //Used to determine if Link is on a Pit or Lava combo.
  353. int OnPitCombo()
  354. {
  355.     int comboLoc = ComboAt(Link->X+8, Link->Y + Cond(BIG_LINK==0, 12, 8));
  356.     if(Screen->ComboT[comboLoc] != CT_HOLELAVA)
  357.         return 0;
  358.     else if(Screen->ComboI[comboLoc] == CF_PIT || Screen->ComboI[comboLoc] == CF_LAVA)
  359.         return Screen->ComboI[comboLoc];
  360.     else if(Screen->ComboF[comboLoc] == CF_PIT || Screen->ComboF[comboLoc] == CF_LAVA)
  361.         return Screen->ComboF[comboLoc];
  362.     else
  363.         return 0;
  364. }
  365.  
  366.  
  367. //Snaps Link to the combo so he appears completely over pit and lava combos.
  368. void SnaptoGrid()
  369. {
  370.     int x = Link->X;
  371.     int y = Link->Y + Cond(BIG_LINK==0, 8, 0);
  372.     int comboLoc = ComboAt(x, y);
  373.  
  374.     //X Axis
  375.     if(Screen->ComboT[comboLoc] == CT_HOLELAVA && Cond(x % 16 == 0, true, Screen->ComboT[comboLoc+1] != CT_HOLELAVA))
  376.         Link->X = ComboX(comboLoc);
  377.     else if(Screen->ComboT[comboLoc+1] == CT_HOLELAVA && Cond(x % 16 == 0, true, Screen->ComboT[comboLoc] != CT_HOLELAVA))
  378.         Link->X = ComboX(comboLoc+1);
  379.     if(Cond(y % 16 == 0, false, Screen->ComboT[comboLoc+16] == CT_HOLELAVA) && Cond(x % 16 == 0, true, Screen->ComboT[comboLoc+17] != CT_HOLELAVA))
  380.         Link->X = ComboX(comboLoc+16);
  381.     else if(Cond(y % 16 == 0, false, Screen->ComboT[comboLoc+17] == CT_HOLELAVA) && Cond(x % 16 == 0, true, Screen->ComboT[comboLoc+16] != CT_HOLELAVA))
  382.         Link->X = ComboX(comboLoc+17);
  383.  
  384.     //Y Axis
  385.     if(Screen->ComboT[comboLoc] == CT_HOLELAVA && Cond(y % 16 == 0, true, Screen->ComboT[comboLoc+16] != CT_HOLELAVA))
  386.         Link->Y = ComboY(comboLoc);
  387.     else if(Screen->ComboT[comboLoc+16] == CT_HOLELAVA && Cond(y % 16 == 0, true, Screen->ComboT[comboLoc] != CT_HOLELAVA))
  388.         Link->Y = ComboY(comboLoc+16);
  389.     if(Cond(x % 16 == 0, false, Screen->ComboT[comboLoc+1] == CT_HOLELAVA) && Cond(y % 16 == 0, true, Screen->ComboT[comboLoc+17] != CT_HOLELAVA))
  390.         Link->Y = ComboY(comboLoc+1);
  391.     else if(Cond(x % 16 == 0, false, Screen->ComboT[comboLoc+17] == CT_HOLELAVA) && Cond(y % 16 == 0, true, Screen->ComboT[comboLoc+1] != CT_HOLELAVA))
  392.         Link->Y = ComboY(comboLoc+17);
  393. }
  394.  
  395. //Used to make Ex1/Ex2 switch items like L&R for A+B subscreens.
  396. void LREx1Ex2ItemSwitch()
  397. {
  398.     if (Link->PressL && Link->Action != LA_SCROLLING)
  399.     {
  400.         Link->SelectBWeapon(DIR_LEFT);
  401.     }
  402.     if (Link->PressR && Link->Action != LA_SCROLLING)
  403.     {
  404.         Link->SelectBWeapon(DIR_RIGHT);
  405.     }
  406.     if (Link->PressEx1 && Link->Action != LA_SCROLLING)
  407.     {
  408.         Link->SelectAWeapon(DIR_LEFT);
  409.     }
  410.     if (Link->PressEx2 && Link->Action != LA_SCROLLING)
  411.     {
  412.         Link->SelectAWeapon(DIR_RIGHT);
  413.     }
  414. }
  415.  
  416. //Hole_Lava Init. Call before Waitdraw().
  417. void InitHoleLava(){
  418.     //Initialize variables used to store Link's strating position on Screen Init.
  419.             PitsLava[HL_OLDDMAP] = Game->GetCurDMap();
  420.             PitsLava[HL_OLDSCREEN] = Game->GetCurDMapScreen();
  421.             PitsLava[HL_STARTX] = Link->X;
  422.             PitsLava[HL_STARTY] = Link->Y;
  423.             PitsLava[HL_STARTDIR] = Link->Dir;
  424.  
  425.             //Clear global variables used by Bottomless pits.
  426.             PitsLava[HL_FALLING] = 0;
  427.             PitsLava[HL_WARPING] = 0;
  428. }
  429.  
  430. //Main Hole_Lava Rountine. Call after Waitdraw().
  431. void RunHoleLava(){
  432.     Update_HoleLava(PitsLava[HL_STARTX], PitsLava[HL_STARTY], PitsLava[HL_OLDDMAP], PitsLava[HL_OLDSCREEN], PitsLava[HL_STARTDIR]);
  433.     if(Link->Z==0 && !PitsLava[HL_FALLING] && ( PitsLava[HL_OLDSCREEN] != Game->GetCurDMapScreen() || PitsLava[HL_OLDDMAP] != Game->GetCurDMap() ) && !OnPitCombo() )
  434.     {
  435.         PitsLava[HL_OLDDMAP] = Game->GetCurDMap();
  436.         PitsLava[HL_OLDSCREEN] = Game->GetCurDMapScreen();
  437.         PitsLava[HL_STARTX] = Link->X;
  438.         PitsLava[HL_STARTY] = Link->Y;
  439.         PitsLava[HL_STARTDIR] = Link->Dir;
  440.     }
  441. }
  442.  
  443. //Handles Pit Combo Functionality.
  444. void Update_HoleLava2(){
  445.     if(PitsLava[HL_FALLING])
  446.         NoAction();
  447. }
  448. void Update_HoleLava(int x, int y, int dmap, int scr, int dir)
  449. {
  450.     lweapon hookshot = LoadLWeaponOf(LW_HOOKSHOT);
  451.     if(hookshot->isValid()) return;
  452.  
  453.     if(PitsLava[HL_FALLING])
  454.     {
  455.        
  456.         if(IsSideview()) Link->Jump=0;
  457.         PitsLava[HL_FALLING]--;
  458.         if(PitsLava[HL_FALLING] == 1)
  459.         {
  460.             int buffer[] = "Holelava";
  461.             if(CountFFCsRunning(Game->GetFFCScript(buffer)))
  462.             {
  463.                 ffc f = Screen->LoadFFC(FindFFCRunning(Game->GetFFCScript(buffer)));
  464.                 PitsLava[HL_WARPING] = 1;
  465.                 if(f->InitD[1]==0)
  466.                 {
  467.                     f->InitD[6] = x;
  468.                     f->InitD[7] = y;
  469.                 }
  470.             }
  471.             else
  472.             {
  473.                 Link->X = x;
  474.                 Link->Y = y;
  475.                 Link->Dir = dir;
  476.                 Link->DrawXOffset -= Cond(Link->DrawXOffset < 0, -1000, 1000);
  477.                 Link->HitXOffset -= Cond(Link->HitXOffset < 0, -1000, 1000);
  478.                 Link->HP -= HOLELAVA_DAMAGE;
  479.                 Link->Action = LA_GOTHURTLAND;
  480.                 Link->HitDir = -1;
  481.                 Game->PlaySound(SFX_OUCH);
  482.                 if(Game->GetCurDMap()!=dmap || Game->GetCurDMapScreen()!=scr)
  483.                 Link->PitWarp(dmap, scr);
  484.             }
  485.             NoAction();
  486.             Link->Action = LA_NONE;
  487.         }
  488.     }
  489.     else if(Link->Z==0 && OnPitCombo() && !PitsLava[HL_WARPING])
  490.     {
  491.         Link->DrawXOffset += Cond(Link->DrawXOffset < 0, -1000, 1000);
  492.         Link->HitXOffset += Cond(Link->HitXOffset < 0, -1000, 1000);
  493.         int comboflag = OnPitCombo();
  494.         SnaptoGrid();
  495.         Game->PlaySound(Cond(comboflag == CF_PIT, SFX_LINK_FALL, SFX_LINK_LAVA));
  496.         lweapon dummy = CreateLWeaponAt(LW_SCRIPT10, Link->X, Link->Y);
  497.         dummy->UseSprite(Cond(comboflag == CF_PIT, WPS_LINK_FALL, WPS_LINK_LAVA));
  498.         dummy->DeadState = dummy->NumFrames*dummy->ASpeed;
  499.         dummy->DrawXOffset = 0;
  500.         dummy->DrawYOffset = 0;
  501.         PitsLava[HL_FALLING] = dummy->DeadState;
  502.         NoAction();
  503.         Link->Action = LA_NONE;
  504.     }
  505. }
  506.  
  507. /////////////////////////////////////
  508. /// Global Accessors  ///////////////
  509. /// Setter and Getters for Arrays ///
  510. /////////////////////////////////////
  511. int Ice_XStep;
  512. int Ice_YStep;
  513. //GlobalRAM Array
  514.  
  515. void Is(int index, int val){
  516.     GlobalRAM[index] = val;
  517. }
  518.  
  519. void Mod(int index, int val){
  520.     GlobalRAM[index] += val;
  521. }
  522.  
  523. int Is(int index){
  524.     return GlobalRAM[index];
  525. }
  526.  
  527. void Inc(int index){
  528.     GlobalRAM[index]++;
  529. }
  530.  
  531. void Dec(int index){
  532.     GlobalRAM[index]--;
  533. }
  534.  
  535. //Global setter/getter functions for shield script.
  536.  
  537.  
  538.  
  539. ///////////////////////////
  540. // Misc Global Functions //
  541. ///////////////////////////
  542.  
  543. //Preserves Link's coordinates for map/ladder issues..
  544. void StoreLinkCoordinates(){
  545.     Is(STORE_LINK_X, Link->X);
  546.     Is(STORE_LINK_Y, Link->Y);
  547.     Is(STORE_LINK_Z, Link->Z);
  548.     Is(STORE_LINK_JUMP, Link->Jump);
  549. }
  550.  
  551. //Maintains Link's coordinates in Map()
  552. void MaintainLinkCoordinates(){
  553.     if ( Link->X != Is(STORE_LINK_X) ) Link->X = Is(STORE_LINK_X);
  554.     if ( Link->Y != Is(STORE_LINK_Y) ) Link->Y = Is(STORE_LINK_Y);
  555.     if ( Link->Z != Is(STORE_LINK_Z) ) Link->Z = Is(STORE_LINK_Z);
  556.     Link->Jump = 0;
  557.  Trace(Link->X);
  558.  Trace(Link->Y);
  559.  Trace(Link->Z);
  560.  Trace(Link->Jump);
  561.  TraceNL();
  562. }
  563.  
  564. ////////////////////
  565. /// Item Scripts ///
  566. ////////////////////
  567.  
  568.  
  569.  
  570. ///////////////////
  571. /// FFC Scripts ///
  572. ///////////////////
  573.  
  574. //Holes and Lava Main ffc
  575.  
  576. ffc script Holelava
  577. {
  578.     void run(int warp, bool position, int damage)
  579.     {
  580.         while(true)
  581.         {
  582.             while(!PitsLava[HL_WARPING]) Waitframe();
  583.             if(warp > 0)
  584.             {
  585.                 this->Data = CMB_AUTOWARP+warp-1;
  586.                 this->Flags[FFCF_CARRYOVER] = true;
  587.                 Waitframe();
  588.                 this->Data = FFCS_INVISIBLE_COMBO;
  589.                 this->Flags[FFCF_CARRYOVER] = false;
  590.                 Link->Z = Link->Y;
  591.                 PitsLava[HL_WARPING] = 0;
  592.                 Link->DrawXOffset -= Cond(Link->DrawXOffset < 0, -1000, 1000);
  593.                 Link->HitXOffset -= Cond(Link->HitXOffset < 0, -1000, 1000);
  594.                 Quit();
  595.             }
  596.             if(position)
  597.             {
  598.                 Link->X = this->X;
  599.                 Link->Y = this->Y;
  600.             }
  601.             else
  602.             {
  603.                 Link->X = this->InitD[6];
  604.                 Link->Y = this->InitD[7];
  605.             }
  606.             if(damage)
  607.             {
  608.                 Link->HP -= damage;
  609.                 Link->Action = LA_GOTHURTLAND;
  610.                 Link->HitDir = -1;
  611.                 Game->PlaySound(SFX_OUCH);
  612.             }
  613.             Link->DrawXOffset -= Cond(Link->DrawXOffset < 0, -1000, 1000);
  614.             Link->HitXOffset -= Cond(Link->HitXOffset < 0, -1000, 1000);
  615.             PitsLava[HL_WARPING] = 0;
  616.             Waitframe();
  617.         }
  618.     }
  619. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement