Advertisement
ZoriaRPG

Combined Holes, Pits, Lava, Platforms, Barriers

Feb 2nd, 2018
321
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 19.83 KB | None | 0 0
  1. /// Tamamo's Holes, Lava, and Platforms
  2. /// Plus Barriers + Followers, for Nightmeres (on PZC)
  3. /// Combined together for ease of use, and streamlined for stack efficiency.
  4.  
  5. /// Global Constants, Arrays, and Variables
  6.  
  7. //Common Constant, only need to define once per script file.
  8. const int BIG_LINK                  = 0;   //Set this constant to 1 if using the Large Link Hit Box feature.
  9. const int DIAGONAL_MOVEMENT         = 1; //Enable the option and change this to 0 for nes movement.
  10.  
  11. //Constants used by Bottomless Pits & Lava.
  12. const int CT_HOLELAVA              = 128; //Combo type to use for pit holes and lava."No Ground Enemies by default"
  13. const int CF_PIT                   = 101;  //The combo flag to register combos as pits.
  14. const int CF_LAVA                  = 102;  //The combo flag to register combos as lava.
  15. const int WPS_LINK_FALL            = 89;  //The weapon sprite to display when Link falls into a pit. "Sprite 88 by default"
  16. const int WPS_LINK_LAVA            = 90;  //The weapon sprite to display when Link drowns in lava. "Sprite 89 by default"
  17. const int SFX_LINK_FALL            = 38;  //The sound to play when Link falls into a pit. "SFX_FALL by default"
  18. const int SFX_LINK_LAVA            = 55;  //The sound to play when Link drowns in Lava. "SFX_SPLASH by default.
  19. const int CMB_AUTOWARP             = 48;  //The first of your four transparent autowarp combos.
  20. const int HOLELAVA_DAMAGE          = 8;   //Damage in hit points to inflict on link. "One Heart Container is worth 16 hit points"
  21.  
  22. //Global variables used by Bottomless Pits & Lava.
  23.  
  24. float PitsLava[256];
  25. const int HL_FALLING            = 0;
  26. const int HL_WARPING            = 1;
  27. const int HL_ONPLATFORM         = 3;
  28.  
  29.  
  30. const int CMB_FFC_INVIS         = 1; //Combo higher than ID 0 with an invisible tile.
  31.  
  32. // ID's of barrier-related combos
  33. // Barriers in raised state
  34. const int BARRIER_A_RAISED              = 15036;
  35. const int BARRIER_B_RAISED              = 15038;
  36.  
  37. // Barriers in lowered state
  38. const int BARRIER_A_LOWERED             = 15037;
  39. const int BARRIER_B_LOWERED             = 15039;
  40.  
  41. // Barriers animating to raised state
  42. const int BARRIER_A_ANIMRAISE           = 15041;
  43. const int BARRIER_B_ANIMRAISE           = 15043;
  44.  
  45. // Barriers animating to lowered state
  46. const int BARRIER_A_ANIMLOWER           = 15040;
  47. const int BARRIER_B_ANIMLOWER           = 15042;
  48.  
  49. // Raised barriers that Link can walk on
  50. const int BARRIER_A_WALKABLE            = 15044;
  51. const int BARRIER_B_WALKABLE            = 15045;
  52.  
  53. // Barrier switches
  54. const int BARRIER_A_SWITCH              = 15046;
  55. const int BARRIER_B_SWITCH              = 15047;
  56.  
  57. const int BARRIER_SWITCH_DUMMY      = 191; // ID of a switch hit detection dummy enemy
  58. const int BARRIER_SWITCH_DUMMY_HP   = 32767;
  59.  
  60. // Global array to store the state of barriers per dmap
  61. // If you have more than 16 dmaps you can change the capacity in the []'s
  62. // You may change the states in other scripts, but the changes will not be visible
  63. // until there is a new screen, so set them before Barriers_NewScreen() is called.
  64. bool barriers[255]; // false = blue barriers raised, true = red barriers raised
  65.  
  66.  
  67. //Follower script constants.
  68. const int FOLLOWER_FFC_INDEX        = 32; //The number of the FFC used.  This script will "hijack" this one, so don't use it for anything else on screens when you expect the player to have a follower.
  69. const int FOLLOWER_FIRST_COMBO_ID   = 23568; //combo of the first combo.  In order, the concecutive combos must be "still up", "still down", "still left", "still right", "moving up", "moving down", "moving left", "moving right".
  70. const int FOLLOWER_CSET         = 11;
  71. const int FOLLOWER_REQUIRED_ITEM    = 158; //Item that makes the FFC follower follow you
  72.  
  73. //Barriers array indices.
  74. const int BAR_PASTX     = 14; //followerX[]
  75. const int BAR_PASTY     = 14; //followerY[] //why not one array? -Z
  76.  
  77. /// FFC Scripts
  78.  
  79. ffc script Holelava
  80. {
  81.     void run(int warp, bool position, int damage)
  82.     {
  83.         while(true)
  84.         {
  85.             while(!PitsLava[HL_WARPING] || OnPlatform()) Waitframe();
  86.             if(warp > 0)
  87.             {
  88.                 this->Data = CMB_AUTOWARP+warp-1;
  89.                 this->Flags[FFCF_CARRYOVER] = true;
  90.                 Waitframe();
  91.                 this->Data = FFCS_INVISIBLE_COMBO;
  92.                 this->Flags[FFCF_CARRYOVER] = false;
  93.                 Link->Z = Link->Y;
  94.                 PitsLava[HL_WARPING] = 0;
  95.                 Link->DrawXOffset -= Cond(Link->DrawXOffset < 0, -1000, 1000);
  96.                 Link->HitXOffset -= Cond(Link->HitXOffset < 0, -1000, 1000);
  97.                 Quit();
  98.             }
  99.             if(position)
  100.             {
  101.                 Link->X = this->X;
  102.                 Link->Y = this->Y;
  103.             }
  104.             else
  105.             {
  106.                 Link->X = this->InitD[6];
  107.                 Link->Y = this->InitD[7];
  108.             }
  109.             if(damage)
  110.             {
  111.                 Link->HP -= damage;
  112.                 Link->Action = LA_GOTHURTLAND;
  113.                 Link->HitDir = -1;
  114.                 Game->PlaySound(SFX_OUCH);
  115.             }
  116.             Link->DrawXOffset -= Cond(Link->DrawXOffset < 0, -1000, 1000);
  117.             Link->HitXOffset -= Cond(Link->HitXOffset < 0, -1000, 1000);
  118.             PitsLava[HL_WARPING] = 0;
  119.             Waitframe();
  120.         }
  121.     }
  122. }
  123.  
  124.  
  125. ffc script MovingPlatform {
  126.     void run(){
  127.         float oldx = this->X;
  128.         float oldy = this->Y;
  129.         float linkx;
  130.         float linky;
  131.         while(true){
  132.             if ( OnPlatform() == FFCNum(this) ){
  133.                 linkx += this->X - oldx;
  134.                 linky += this->Y - oldy;
  135.                 if ( linkx << 0 != 0 ) {
  136.                     Link->X += linkx << 0;
  137.                     linkx -= linkx << 0;
  138.                 }
  139.                 if ( linky << 0 != 0 ){
  140.                     Link->Y += linky << 0;
  141.                     linky -= linky << 0;
  142.                 }
  143.             }
  144.             else {
  145.                 linkx = 0;
  146.                 linky = 0;
  147.             }
  148.             oldx = this->X;
  149.             oldy = this->Y;
  150.             Waitframe();
  151.         }
  152.     }
  153. }
  154.  
  155.  
  156. /// Global Scripts
  157.  
  158. global script active{                          
  159.     void run(){
  160.         // Initialize variables used to listen on screen changes
  161.         int curscreen = -1;
  162.         bool firstCheck = false; //leave this alone
  163.         ffc follower;
  164.    
  165.         int followerX[15];
  166.         int followerY[15];
  167.  
  168.         int switch_index;
  169.         StartGhostZH();
  170.         while(true){
  171.             UpdateGhostZH1();
  172.             _Do_Barriers();
  173.             _Follower();
  174.             InitHoleLava();
  175.             NesMovementFix();
  176.             Waitdraw();
  177.             UpdateGhostZH2();
  178.             LREx1Ex2ItemSwitch();
  179.             MovingPlatforms();
  180.             RunHoleLava();
  181.             Waitframe();
  182.         }//end whileloop
  183.     }//end run
  184. }//end global slot2
  185.  
  186.  
  187. /// Global Functions
  188.  
  189. //Sets or returns if we are on a platform.
  190. int OnPlatform(){return PitsLava[HL_ONPLATFORM];}
  191. void OnPlatform(int a){ PitsLava[HL_ONPLATFORM] = a; }
  192.  
  193. //Used to determine if Link is on a Pit or Lava combo.
  194. int OnPitCombo()
  195. {
  196.     int comboLoc = ComboAt(Link->X+8, Link->Y + Cond(BIG_LINK==0, 12, 8));
  197.     if(Screen->ComboT[comboLoc] != CT_HOLELAVA)
  198.         return 0;
  199.     else if(Screen->ComboI[comboLoc] == CF_PIT || Screen->ComboI[comboLoc] == CF_LAVA)
  200.         return Screen->ComboI[comboLoc];
  201.     else if(Screen->ComboF[comboLoc] == CF_PIT || Screen->ComboF[comboLoc] == CF_LAVA)
  202.         return Screen->ComboF[comboLoc];
  203.     else
  204.         return 0;
  205. }
  206.  
  207.  
  208. //Snaps Link to the combo so he appears completely over pit and lava combos.
  209. void SnaptoGrid()
  210. {
  211.     int x = Link->X;
  212.     int y = Link->Y + Cond(BIG_LINK==0, 8, 0);
  213.     int comboLoc = ComboAt(x, y);
  214.  
  215.     //X Axis
  216.     if(Screen->ComboT[comboLoc] == CT_HOLELAVA && Cond(x % 16 == 0, true, Screen->ComboT[comboLoc+1] != CT_HOLELAVA))
  217.         Link->X = ComboX(comboLoc);
  218.     else if(Screen->ComboT[comboLoc+1] == CT_HOLELAVA && Cond(x % 16 == 0, true, Screen->ComboT[comboLoc] != CT_HOLELAVA))
  219.         Link->X = ComboX(comboLoc+1);
  220.     if(Cond(y % 16 == 0, false, Screen->ComboT[comboLoc+16] == CT_HOLELAVA) && Cond(x % 16 == 0, true, Screen->ComboT[comboLoc+17] != CT_HOLELAVA))
  221.         Link->X = ComboX(comboLoc+16);
  222.     else if(Cond(y % 16 == 0, false, Screen->ComboT[comboLoc+17] == CT_HOLELAVA) && Cond(x % 16 == 0, true, Screen->ComboT[comboLoc+16] != CT_HOLELAVA))
  223.         Link->X = ComboX(comboLoc+17);
  224.  
  225.     //Y Axis
  226.     if(Screen->ComboT[comboLoc] == CT_HOLELAVA && Cond(y % 16 == 0, true, Screen->ComboT[comboLoc+16] != CT_HOLELAVA))
  227.         Link->Y = ComboY(comboLoc);
  228.     else if(Screen->ComboT[comboLoc+16] == CT_HOLELAVA && Cond(y % 16 == 0, true, Screen->ComboT[comboLoc] != CT_HOLELAVA))
  229.         Link->Y = ComboY(comboLoc+16);
  230.     if(Cond(x % 16 == 0, false, Screen->ComboT[comboLoc+1] == CT_HOLELAVA) && Cond(y % 16 == 0, true, Screen->ComboT[comboLoc+17] != CT_HOLELAVA))
  231.         Link->Y = ComboY(comboLoc+1);
  232.     else if(Cond(x % 16 == 0, false, Screen->ComboT[comboLoc+17] == CT_HOLELAVA) && Cond(y % 16 == 0, true, Screen->ComboT[comboLoc+1] != CT_HOLELAVA))
  233.         Link->Y = ComboY(comboLoc+17);
  234. }
  235.  
  236. void LREx1Ex2ItemSwitch()
  237. {
  238.     if (Link->PressL && Link->Action != LA_SCROLLING)
  239.     {
  240.         Link->SelectBWeapon(DIR_LEFT);
  241.     }
  242.     if (Link->PressR && Link->Action != LA_SCROLLING)
  243.     {
  244.         Link->SelectBWeapon(DIR_RIGHT);
  245.     }
  246.     if (Link->PressEx1 && Link->Action != LA_SCROLLING)
  247.     {
  248.         Link->SelectAWeapon(DIR_LEFT);
  249.     }
  250.     if (Link->PressEx2 && Link->Action != LA_SCROLLING)
  251.     {
  252.         Link->SelectAWeapon(DIR_RIGHT);
  253.     }
  254. }
  255.  
  256. //Hole_Lava Init. Call before Waitdraw().
  257. void InitHoleLava(){
  258.     //Initialize variables used to store Link's strating position on Screen Init.
  259.             int olddmap = Game->GetCurDMap();
  260.             int oldscreen = Game->GetCurDMapScreen();
  261.             int startx = Link->X;
  262.             int starty = Link->Y;
  263.             int startdir = Link->Dir;
  264.  
  265.             //Clear global variables used by Bottomless pits.
  266.             PitsLava[HL_FALLING] = 0;
  267.             PitsLava[HL_WARPING] = 0;
  268. }
  269.  
  270. //Main Hole_Lava Rountine. Call after Waitdraw().
  271. void RunHoleLava(){
  272.     if(Link->Action != LA_SCROLLING)
  273.     {
  274.         Update_HoleLava(startx, starty, olddmap, oldscreen, startdir);
  275.         if(Link->Z==0 && !PitsLava[HL_FALLING] && (oldscreen != Game->GetCurDMapScreen() || olddmap != Game->GetCurDMap()))
  276.         {
  277.             olddmap = Game->GetCurDMap();
  278.             oldscreen = Game->GetCurDMapScreen();
  279.             startx = Link->X;
  280.             starty = Link->Y;
  281.             startdir = Link->Dir;
  282.         }
  283.     }
  284. }
  285.  
  286. //Handles Pit Combo Functionality.
  287. void Update_HoleLava(int x, int y, int dmap, int scr, int dir)
  288. {
  289.     lweapon hookshot = LoadLWeaponOf(LW_HOOKSHOT);
  290.     if(hookshot->isValid()) return;
  291.  
  292.     if(PitsLava[HL_FALLING])
  293.     {
  294.         if(IsSideview()) Link->Jump=0;
  295.         PitsLava[HL_FALLING]--;
  296.         if(PitsLava[HL_FALLING] == 1)
  297.         {
  298.             int buffer[] = "Holelava";
  299.             if(CountFFCsRunning(Game->GetFFCScript(buffer)))
  300.             {
  301.                 ffc f = Screen->LoadFFC(FindFFCRunning(Game->GetFFCScript(buffer)));
  302.                 PitsLava[HL_WARPING] = 1;
  303.                 if(f->InitD[1]==0)
  304.                 {
  305.                     f->InitD[6] = x;
  306.                     f->InitD[7] = y;
  307.                 }
  308.             }
  309.             else
  310.             {
  311.                 Link->X = x;
  312.                 Link->Y = y;
  313.                 Link->Dir = dir;
  314.                 Link->DrawXOffset -= Cond(Link->DrawXOffset < 0, -1000, 1000);
  315.                 Link->HitXOffset -= Cond(Link->HitXOffset < 0, -1000, 1000);
  316.                 Link->HP -= HOLELAVA_DAMAGE;
  317.                 Link->Action = LA_GOTHURTLAND;
  318.                 Link->HitDir = -1;
  319.                 Game->PlaySound(SFX_OUCH);
  320.                 if(Game->GetCurDMap()!=dmap || Game->GetCurDMapScreen()!=scr)
  321.                 Link->PitWarp(dmap, scr);
  322.             }
  323.             NoAction();
  324.             Link->Action = LA_NONE;
  325.         }
  326.     }
  327.     else if(Link->Z==0 && OnPitCombo() && !PitsLava[HL_WARPING] && !OnPlatform())
  328.     {
  329.         Link->DrawXOffset += Cond(Link->DrawXOffset < 0, -1000, 1000);
  330.         Link->HitXOffset += Cond(Link->HitXOffset < 0, -1000, 1000);
  331.         int comboflag = OnPitCombo();
  332.         SnaptoGrid();
  333.         Game->PlaySound(Cond(comboflag == CF_PIT, SFX_LINK_FALL, SFX_LINK_LAVA));
  334.         lweapon dummy = CreateLWeaponAt(LW_SCRIPT10, Link->X, Link->Y);
  335.         dummy->UseSprite(Cond(comboflag == CF_PIT, WPS_LINK_FALL, WPS_LINK_LAVA));
  336.         dummy->DeadState = dummy->NumFrames*dummy->ASpeed;
  337.         dummy->DrawXOffset = 0;
  338.         dummy->DrawYOffset = 0;
  339.         PitsLava[HL_FALLING] = dummy->DeadState;
  340.         NoAction();
  341.         Link->Action = LA_NONE;
  342.     }
  343. }
  344.  
  345. //Handles moving platforms
  346. void MovingPlatforms(){
  347.     OnPlatform(0);
  348.     if ( Link->Z == 0 ) {
  349.         int buffer[] = "MovingPlatform";
  350.         for(int i = 1; i <= 32; i++) {
  351.             ffc f = Screen->LoadFFC(i);
  352.             if(f->Script != Game->GetFFCScript(buffer)) continue;
  353.             if(Abs(Link->X + 8 - CenterX(f)) >= f->TileWidth*8) continue;
  354.             if(Abs(Link->Y + 12 - CenterY(f)) >= f->TileHeight*8) continue;
  355.             OnPlatform(FFCNum(f));
  356.             break;
  357.         }
  358.     }
  359. }
  360.  
  361. //Used if we are using NES movement
  362. void NesMovementFix(){
  363.     if(DIAGONAL_MOVEMENT==0 && (Link->InputUp || Link->InputDown)){
  364.         Link->InputLeft = false;
  365.         Link->InputRight = false;
  366.     }
  367. }
  368.  
  369. // Function that makes preparations for barriers on each screen and starts an FFC script
  370. void Barriers_NewScreen()
  371. {
  372.     int cd; int cd2; int i; int j;
  373.     // Search for a barrier-related combo
  374.     for (i = 0; i <= 175; ++i)
  375.     {
  376.         cd = Screen->ComboD[i];
  377.         if (cd == BARRIER_A_RAISED || cd == BARRIER_A_LOWERED || cd == BARRIER_A_SWITCH ||
  378.             cd == BARRIER_B_RAISED || cd == BARRIER_B_LOWERED || cd == BARRIER_B_SWITCH)
  379.         {
  380.             // A barrier-related combo was found
  381.  
  382.             // Make initial changes to combos
  383.             if (barriers[Game->GetCurLevel()])
  384.             {
  385.                 for (j = i; j <= 175; ++j)
  386.                 {
  387.                     cd2 = Screen->ComboD[j];
  388.                     if (cd2 == BARRIER_A_RAISED) Screen->ComboD[j] = BARRIER_A_LOWERED;
  389.                     else if (cd2 == BARRIER_B_LOWERED) Screen->ComboD[j] = BARRIER_B_RAISED;
  390.                     else if (cd2 == BARRIER_A_SWITCH) Screen->ComboD[j] = BARRIER_B_SWITCH;
  391.                 }
  392.             }
  393.             else
  394.             {
  395.                 for (j = i; j <= 175; ++j)
  396.                 {
  397.                     cd2 = Screen->ComboD[j];
  398.                     if (cd2 == BARRIER_B_RAISED) Screen->ComboD[j] = BARRIER_B_LOWERED;
  399.                     else if (cd2 == BARRIER_A_LOWERED) Screen->ComboD[j] = BARRIER_A_RAISED;
  400.                     else if (cd2 == BARRIER_B_SWITCH) Screen->ComboD[j] = BARRIER_A_SWITCH;
  401.                 }
  402.             }
  403.    
  404.             // So run FFCscript to control barriers
  405.             int fif[]="Barriers";
  406.             ffc f = Screen->LoadFFC(FOLLOWER_FFC_INDEX);
  407.             f->Script = Game->GetFFCScript(fif);
  408.             f->Data = CMB_FFC_INVIS;
  409.             f->X = -100;
  410.             f->Y = -100;
  411.             f->Flags[FFCF_PRELOAD] = true;
  412.             break;
  413.         }
  414.     }
  415. }
  416.  
  417. // This lets you toggle barriers on any dmap
  418. bool ToggleBarriers(int dmap)
  419. {
  420.     if (dmap == Game->GetCurLevel()) ToggleBarriers();
  421.     else barriers[dmap] = !barriers[dmap];
  422.     return barriers[dmap];
  423. }
  424.  
  425. // This toggles barriers on the current dmap
  426. bool ToggleBarriers()
  427. {
  428.     int cd;
  429.     int curdmap = Game->GetCurLevel();
  430.     if (!barriers[curdmap])
  431.     {
  432.         barriers[curdmap] = true;
  433.         for (int i = 0; i <= 175; ++i)
  434.         {
  435.             cd = Screen->ComboD[i];
  436.             if (cd == BARRIER_A_RAISED || cd == BARRIER_A_WALKABLE || cd == BARRIER_A_ANIMRAISE)
  437.             {
  438.                 Screen->ComboD[i] = BARRIER_A_ANIMLOWER;
  439.             }
  440.             else if (cd == BARRIER_B_LOWERED || cd == BARRIER_B_ANIMLOWER)
  441.             {
  442.                 Screen->ComboD[i] = BARRIER_B_ANIMRAISE;
  443.             }
  444.             else if (cd == BARRIER_A_SWITCH)
  445.             {
  446.                 Screen->ComboD[i] = BARRIER_B_SWITCH;
  447.             }
  448.         }
  449.     }
  450.     else
  451.     {
  452.         barriers[curdmap] = false;
  453.         for (int i = 0; i <= 175; ++i)
  454.         {
  455.             cd = Screen->ComboD[i];
  456.             if (cd == BARRIER_B_RAISED || cd == BARRIER_B_WALKABLE || cd == BARRIER_B_ANIMRAISE) #
  457.             {
  458.                 Screen->ComboD[i] = BARRIER_B_ANIMLOWER;
  459.             }
  460.             else if (cd == BARRIER_A_LOWERED || cd == BARRIER_A_ANIMLOWER)
  461.             {
  462.                 Screen->ComboD[i] = BARRIER_A_ANIMRAISE;
  463.             }
  464.             else if (cd == BARRIER_B_SWITCH)
  465.             {
  466.                 Screen->ComboD[i] = BARRIER_A_SWITCH;
  467.             }
  468.         }
  469.     }
  470.  
  471.     return barriers[curdmap];
  472. }
  473.  
  474. // This script controls barriers on the screen
  475. // The FFC is automatically created by Barriers_NewScreen()
  476. ffc script Barriers
  477. {
  478.     void run()
  479.     {
  480.  
  481.         // Initialize storage for bswitch hit dummies
  482.         int bswitch_count;
  483.         npc bswitch[8]; int i; int j;
  484.  
  485.         for (i = 0; i <= 175; ++i)
  486.         {
  487.             if (Screen->ComboD[i] == BARRIER_A_SWITCH || Screen->ComboD[i] == BARRIER_B_SWITCH)
  488.             {
  489.                 npc bs = CreateNPCAt(BARRIER_SWITCH_DUMMY, ComboX(i), ComboY(i));
  490.                 bs->HitWidth = 8; // Smaller hit box to avoid annoying collisions with Link
  491.                 bs->HitHeight = 8;
  492.                 bs->HP = BARRIER_SWITCH_DUMMY_HP;
  493.                 bswitch[bswitch_count++] = bs;
  494.             }
  495.         }
  496.  
  497.         // Change raised barriers to walkable ones if Link enters screen on a raised barrier
  498.         int lcombo = LinkOnComboD();
  499.         bool onbarrier = (lcombo == BARRIER_A_RAISED || lcombo == BARRIER_B_RAISED);
  500.         if (onbarrier)
  501.         {
  502.             for (i = 0; i < 176; ++i)
  503.             {
  504.                 if (Screen->ComboD[i] == BARRIER_A_RAISED)
  505.                 {
  506.                     Screen->ComboD[i] = BARRIER_A_WALKABLE;
  507.                 }
  508.                 else if (Screen->ComboD[i] == BARRIER_B_RAISED)
  509.                 {
  510.                     Screen->ComboD[i] = BARRIER_B_WALKABLE;
  511.                 }
  512.             }
  513.         }
  514.  
  515.  
  516.         while (true)
  517.         {
  518.  
  519.             // Detect hits on bswitches, and change combos accordingly
  520.             for (j = 0; j < bswitch_count; ++j)
  521.             {
  522.                 if (bswitch[j]->HP < BARRIER_SWITCH_DUMMY_HP)
  523.                 {
  524.                     bswitch[j]->HP = BARRIER_SWITCH_DUMMY_HP;
  525.                     ToggleBarriers();
  526.                     break; //break so that only one bswitch hit may register per frame
  527.                 }
  528.             }
  529.  
  530.  
  531.             // Make barriers walkable if Link is on raised barriers, or unwalkable if not
  532.             lcombo = LinkOnComboD();
  533.             if (!onbarrier && (lcombo == BARRIER_A_RAISED || lcombo == BARRIER_B_RAISED))
  534.             {
  535.                 onbarrier = true;
  536.                 for (i = 0; i <= 175; ++i)
  537.                 {
  538.                     if (Screen->ComboD[i] == BARRIER_A_RAISED)
  539.                     {
  540.                         Screen->ComboD[i] = BARRIER_A_WALKABLE;
  541.                     }
  542.                     else if (Screen->ComboD[i] == BARRIER_B_RAISED)
  543.                     {
  544.                         Screen->ComboD[i] = BARRIER_B_WALKABLE;
  545.                     }
  546.                 }
  547.             }
  548.             else if (onbarrier && !(lcombo == BARRIER_A_WALKABLE || lcombo == BARRIER_B_WALKABLE))
  549.             {
  550.                 onbarrier = false;
  551.                 for (i = 0; i <= 175; ++i)
  552.                 {
  553.                     if (Screen->ComboD[i] == BARRIER_A_WALKABLE)
  554.                     {
  555.                         Screen->ComboD[i] = BARRIER_A_RAISED;
  556.                     }
  557.                     else if (Screen->ComboD[i] == BARRIER_B_WALKABLE)
  558.                     {
  559.                         Screen->ComboD[i] = BARRIER_B_RAISED;
  560.                     }
  561.                 }
  562.             }
  563.  
  564.             Waitframe();
  565.         }
  566.     }
  567. }
  568.  
  569.  
  570.  
  571. // A utility function that returns the ID of the combo that Link appears to stand on
  572. int LinkOnComboD() {
  573.     return Screen->ComboD[ComboAt(Link->X+8, Link->Y+13)];
  574. }
  575.  
  576. void _Follower()
  577. {
  578.     if(Link->Item[FOLLOWER_REQUIRED_ITEM])
  579.     {
  580.         if(Link->Action != LA_SCROLLING && follower->Data==0)
  581.         {
  582.             follower = Screen->LoadFFC(FOLLOWER_FFC_INDEX);
  583.             follower->Data = FOLLOWER_FIRST_COMBO_ID;
  584.             follower->CSet = FOLLOWER_CSET;
  585.  
  586.             followerX[BAR_PASTX] = Link->X;
  587.             follower->X = Link->X;
  588.             followerY[BAR_PASTY] = Link->Y;
  589.             follower->Y = Link->Y;
  590.  
  591.             for ( int i = 0; i < 13; i++ )
  592.             {
  593.                 followerX[i] = Link->X;
  594.                 followerY[i] = Link->Y;
  595.             }
  596.  
  597.             firstCheck = true;
  598.         }
  599.         if(Link->Action != LA_SCROLLING)
  600.         {
  601.             if((Link->InputUp || Link->InputDown || Link->InputRight || Link->InputLeft)&&(!(Link->InputA || Link->InputB)))
  602.             {
  603.                 followerX[BAR_PASTX] = follower->X;
  604.                 follower->X = followerX[0];
  605.                 for(switch_index=0; switch_index<12; switch_index++)
  606.                 {
  607.                     followerX[switch_index] = followerX[switch_index + 1];
  608.                 }
  609.                 followerX[12] = Link->X;
  610.  
  611.                 followerY[BAR_PASTY] = follower->Y;
  612.                 follower->Y = followerY[0];
  613.                 for(switch_index=0; switch_index<12; switch_index++)
  614.                 {
  615.                     followerY[switch_index] = followerY[switch_index + 1];
  616.                 }
  617.                 followerY[12] = Link->Y;
  618.             }
  619.  
  620.             if(follower->Y > followerY[BAR_PASTY])
  621.             {
  622.                 follower->Data = FOLLOWER_FIRST_COMBO_ID + 5;
  623.             }
  624.             else if(follower->Y < followerY[BAR_PASTY])
  625.             {
  626.                 follower->Data = FOLLOWER_FIRST_COMBO_ID + 4;
  627.             }
  628.             else if(follower->X > followerX[BAR_PASTX])
  629.             {
  630.                 follower->Data = FOLLOWER_FIRST_COMBO_ID + 7;
  631.             }
  632.             else if(follower->X < followerX[BAR_PASTX])
  633.             {
  634.                 follower->Data = FOLLOWER_FIRST_COMBO_ID + 6;
  635.             }
  636.  
  637.             if(!(Link->InputUp || Link->InputDown || Link->InputRight || Link->InputLeft))
  638.             {
  639.                 if((follower->Data == (FOLLOWER_FIRST_COMBO_ID + 4))||(follower->Data == (FOLLOWER_FIRST_COMBO_ID + 5))||(follower->Data == (FOLLOWER_FIRST_COMBO_ID + 6))||(follower->Data == (FOLLOWER_FIRST_COMBO_ID + 7)))
  640.                 {
  641.                     follower->Data = follower->Data - 4;
  642.                 }
  643.                 else if((follower->Data == (FOLLOWER_FIRST_COMBO_ID + 3))||(follower->Data == (FOLLOWER_FIRST_COMBO_ID + 2))||(follower->Data == (FOLLOWER_FIRST_COMBO_ID + 1))||(follower->Data == (FOLLOWER_FIRST_COMBO_ID)))
  644.                 {
  645.                     //empty else if ??? -Z
  646.                 }
  647.                 else
  648.                 {
  649.                     follower->Data = FOLLOWER_FIRST_COMBO_ID;
  650.                 }
  651.             }
  652.         }
  653.         if(Link->Action == LA_SCROLLING)
  654.         {
  655.             firstCheck = false;
  656.         }
  657.     }
  658. }
  659.  
  660. void _Do_Barriers()
  661. {
  662.     // Keep track of screen changes
  663.     // Run a Barrier script on every screen change
  664.     if (Game->GetCurScreen() != curscreen)
  665.     {
  666.         curscreen = Game->GetCurScreen();
  667.         Barriers_NewScreen();
  668.     }
  669. }
  670.  
  671. //When will I be done editing/fixing these same three scripts as a courtesy for users?! I didn't even write the things! -Z
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement