ZoriaRPG

Streamlined: Tamamo's HoleLava in Container Functions

Nov 19th, 2016
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 7.75 KB | None | 0 0
  1. /// Global Constants, Arrays, and Variables
  2.  
  3. //Common Constant, only need to define once per script file.
  4. const int BIG_LINK                  = 0;   //Set this constant to 1 if using the Large Link Hit Box feature.
  5.  
  6. //Constants used by Bottomless Pits & Lava.
  7. const int CT_HOLELAVA              = 128; //Combo type to use for pit holes and lava."No Ground Enemies by default"
  8. const int CF_PIT                   = 101;  //The combo flag to register combos as pits.
  9. const int CF_LAVA                  = 102;  //The combo flag to register combos as lava.
  10. const int WPS_LINK_FALL            = 89;  //The weapon sprite to display when Link falls into a pit. "Sprite 88 by default"
  11. const int WPS_LINK_LAVA            = 90;  //The weapon sprite to display when Link drowns in lava. "Sprite 89 by default"
  12. const int SFX_LINK_FALL            = 38;  //The sound to play when Link falls into a pit. "SFX_FALL by default"
  13. const int SFX_LINK_LAVA            = 55;  //The sound to play when Link drowns in Lava. "SFX_SPLASH by default.
  14. const int CMB_AUTOWARP             = 48;  //The first of your four transparent autowarp combos.
  15. const int HOLELAVA_DAMAGE          = 8;   //Damage in hit points to inflict on link. "One Heart Container is worth 16 hit points"
  16.  
  17. //Global variables used by Bottomless Pits & Lava.
  18.  
  19. float PitsLava[2];
  20. const int HL_FALLING = 0;
  21. const int HL_WARPING = 1;
  22.  
  23.  
  24.  
  25.  
  26. /// FFC Scripts
  27.  
  28. ffc script Holelava
  29. {
  30.     void run(int warp, bool position, int damage)
  31.     {
  32.         while(true)
  33.         {
  34.             while(!PitsLava[HL_WARPING]) Waitframe();
  35.             if(warp > 0)
  36.             {
  37.                 this->Data = CMB_AUTOWARP+warp-1;
  38.                 this->Flags[FFCF_CARRYOVER] = true;
  39.                 Waitframe();
  40.                 this->Data = FFCS_INVISIBLE_COMBO;
  41.                 this->Flags[FFCF_CARRYOVER] = false;
  42.                 Link->Z = Link->Y;
  43.                 PitsLava[HL_WARPING] = 0;
  44.                 Link->DrawXOffset -= Cond(Link->DrawXOffset < 0, -1000, 1000);
  45.                 Link->HitXOffset -= Cond(Link->HitXOffset < 0, -1000, 1000);
  46.                 Quit();
  47.             }
  48.             if(position)
  49.             {
  50.                 Link->X = this->X;
  51.                 Link->Y = this->Y;
  52.             }
  53.             else
  54.             {
  55.                 Link->X = this->InitD[6];
  56.                 Link->Y = this->InitD[7];
  57.             }
  58.             if(damage)
  59.             {
  60.                 Link->HP -= damage;
  61.                 Link->Action = LA_GOTHURTLAND;
  62.                 Link->HitDir = -1;
  63.                 Game->PlaySound(SFX_OUCH);
  64.             }
  65.             Link->DrawXOffset -= Cond(Link->DrawXOffset < 0, -1000, 1000);
  66.             Link->HitXOffset -= Cond(Link->HitXOffset < 0, -1000, 1000);
  67.             PitsLava[HL_WARPING] = 0;
  68.             Waitframe();
  69.         }
  70.     }
  71. }
  72.  
  73.  
  74. /// Global Scripts
  75.  
  76. global script active{                          
  77.     void run(){
  78.         StartGhostZH();
  79.         while(true){
  80.             UpdateGhostZH1();
  81.             InitHoleLava();
  82.             Waitdraw();
  83.             UpdateGhostZH2();
  84.             LREx1Ex2ItemSwitch();
  85.             RunHoleLava();
  86.             Waitframe();
  87.         }//end whileloop
  88.     }//end run
  89. }//end global slot2
  90.  
  91.  
  92. /// Global Functions
  93.  
  94. //Used to determine if Link is on a Pit or Lava combo.
  95. int OnPitCombo()
  96. {
  97.     int comboLoc = ComboAt(Link->X+8, Link->Y + Cond(BIG_LINK==0, 12, 8));
  98.     if(Screen->ComboT[comboLoc] != CT_HOLELAVA)
  99.         return 0;
  100.     else if(Screen->ComboI[comboLoc] == CF_PIT || Screen->ComboI[comboLoc] == CF_LAVA)
  101.         return Screen->ComboI[comboLoc];
  102.     else if(Screen->ComboF[comboLoc] == CF_PIT || Screen->ComboF[comboLoc] == CF_LAVA)
  103.         return Screen->ComboF[comboLoc];
  104.     else
  105.         return 0;
  106. }
  107.  
  108.  
  109. //Snaps Link to the combo so he appears completely over pit and lava combos.
  110. void SnaptoGrid()
  111. {
  112.     int x = Link->X;
  113.     int y = Link->Y + Cond(BIG_LINK==0, 8, 0);
  114.     int comboLoc = ComboAt(x, y);
  115.  
  116.     //X Axis
  117.     if(Screen->ComboT[comboLoc] == CT_HOLELAVA && Cond(x % 16 == 0, true, Screen->ComboT[comboLoc+1] != CT_HOLELAVA))
  118.         Link->X = ComboX(comboLoc);
  119.     else if(Screen->ComboT[comboLoc+1] == CT_HOLELAVA && Cond(x % 16 == 0, true, Screen->ComboT[comboLoc] != CT_HOLELAVA))
  120.         Link->X = ComboX(comboLoc+1);
  121.     if(Cond(y % 16 == 0, false, Screen->ComboT[comboLoc+16] == CT_HOLELAVA) && Cond(x % 16 == 0, true, Screen->ComboT[comboLoc+17] != CT_HOLELAVA))
  122.         Link->X = ComboX(comboLoc+16);
  123.     else if(Cond(y % 16 == 0, false, Screen->ComboT[comboLoc+17] == CT_HOLELAVA) && Cond(x % 16 == 0, true, Screen->ComboT[comboLoc+16] != CT_HOLELAVA))
  124.         Link->X = ComboX(comboLoc+17);
  125.  
  126.     //Y Axis
  127.     if(Screen->ComboT[comboLoc] == CT_HOLELAVA && Cond(y % 16 == 0, true, Screen->ComboT[comboLoc+16] != CT_HOLELAVA))
  128.         Link->Y = ComboY(comboLoc);
  129.     else if(Screen->ComboT[comboLoc+16] == CT_HOLELAVA && Cond(y % 16 == 0, true, Screen->ComboT[comboLoc] != CT_HOLELAVA))
  130.         Link->Y = ComboY(comboLoc+16);
  131.     if(Cond(x % 16 == 0, false, Screen->ComboT[comboLoc+1] == CT_HOLELAVA) && Cond(y % 16 == 0, true, Screen->ComboT[comboLoc+17] != CT_HOLELAVA))
  132.         Link->Y = ComboY(comboLoc+1);
  133.     else if(Cond(x % 16 == 0, false, Screen->ComboT[comboLoc+17] == CT_HOLELAVA) && Cond(y % 16 == 0, true, Screen->ComboT[comboLoc+1] != CT_HOLELAVA))
  134.         Link->Y = ComboY(comboLoc+17);
  135. }
  136.  
  137. void LREx1Ex2ItemSwitch()
  138. {
  139.     if (Link->PressL && Link->Action != LA_SCROLLING)
  140.     {
  141.         Link->SelectBWeapon(DIR_LEFT);
  142.     }
  143.     if (Link->PressR && Link->Action != LA_SCROLLING)
  144.     {
  145.         Link->SelectBWeapon(DIR_RIGHT);
  146.     }
  147.     if (Link->PressEx1 && Link->Action != LA_SCROLLING)
  148.     {
  149.         Link->SelectAWeapon(DIR_LEFT);
  150.     }
  151.     if (Link->PressEx2 && Link->Action != LA_SCROLLING)
  152.     {
  153.         Link->SelectAWeapon(DIR_RIGHT);
  154.     }
  155. }
  156.  
  157. //Hole_Lava Init. Call before Waitdraw().
  158. void InitHoleLava(){
  159.     //Initialize variables used to store Link's strating position on Screen Init.
  160.             int olddmap = Game->GetCurDMap();
  161.             int oldscreen = Game->GetCurDMapScreen();
  162.             int startx = Link->X;
  163.             int starty = Link->Y;
  164.             int startdir = Link->Dir;
  165.  
  166.             //Clear global variables used by Bottomless pits.
  167.             PitsLava[HL_FALLING] = 0;
  168.             PitsLava[HL_WARPING] = 0;
  169. }
  170.  
  171. //Main Hole_Lava Rountine. Call after Waitdraw().
  172. void RunHoleLava(){
  173.     if(Link->Action != LA_SCROLLING)
  174.     {
  175.         Update_HoleLava(startx, starty, olddmap, oldscreen, startdir);
  176.         if(Link->Z==0 && !PitsLava[HL_FALLING] && (oldscreen != Game->GetCurDMapScreen() || olddmap != Game->GetCurDMap()))
  177.         {
  178.             olddmap = Game->GetCurDMap();
  179.             oldscreen = Game->GetCurDMapScreen();
  180.             startx = Link->X;
  181.             starty = Link->Y;
  182.             startdir = Link->Dir;
  183.         }
  184.     }
  185. }
  186.  
  187. //Handles Pit Combo Functionality.
  188. void Update_HoleLava(int x, int y, int dmap, int scr, int dir)
  189. {
  190.     lweapon hookshot = LoadLWeaponOf(LW_HOOKSHOT);
  191.     if(hookshot->isValid()) return;
  192.  
  193.     if(PitsLava[HL_FALLING])
  194.     {
  195.         if(IsSideview()) Link->Jump=0;
  196.         PitsLava[HL_FALLING]--;
  197.         if(PitsLava[HL_FALLING] == 1)
  198.         {
  199.             int buffer[] = "Holelava";
  200.             if(CountFFCsRunning(Game->GetFFCScript(buffer)))
  201.             {
  202.                 ffc f = Screen->LoadFFC(FindFFCRunning(Game->GetFFCScript(buffer)));
  203.                 PitsLava[HL_WARPING] = 1;
  204.                 if(f->InitD[1]==0)
  205.                 {
  206.                     f->InitD[6] = x;
  207.                     f->InitD[7] = y;
  208.                 }
  209.             }
  210.             else
  211.             {
  212.                 Link->X = x;
  213.                 Link->Y = y;
  214.                 Link->Dir = dir;
  215.                 Link->DrawXOffset -= Cond(Link->DrawXOffset < 0, -1000, 1000);
  216.                 Link->HitXOffset -= Cond(Link->HitXOffset < 0, -1000, 1000);
  217.                 Link->HP -= HOLELAVA_DAMAGE;
  218.                 Link->Action = LA_GOTHURTLAND;
  219.                 Link->HitDir = -1;
  220.                 Game->PlaySound(SFX_OUCH);
  221.                 if(Game->GetCurDMap()!=dmap || Game->GetCurDMapScreen()!=scr)
  222.                 Link->PitWarp(dmap, scr);
  223.             }
  224.             NoAction();
  225.             Link->Action = LA_NONE;
  226.         }
  227.     }
  228.     else if(Link->Z==0 && OnPitCombo() && !PitsLava[HL_WARPING])
  229.     {
  230.         Link->DrawXOffset += Cond(Link->DrawXOffset < 0, -1000, 1000);
  231.         Link->HitXOffset += Cond(Link->HitXOffset < 0, -1000, 1000);
  232.         int comboflag = OnPitCombo();
  233.         SnaptoGrid();
  234.         Game->PlaySound(Cond(comboflag == CF_PIT, SFX_LINK_FALL, SFX_LINK_LAVA));
  235.         lweapon dummy = CreateLWeaponAt(LW_SCRIPT10, Link->X, Link->Y);
  236.         dummy->UseSprite(Cond(comboflag == CF_PIT, WPS_LINK_FALL, WPS_LINK_LAVA));
  237.         dummy->DeadState = dummy->NumFrames*dummy->ASpeed;
  238.         dummy->DrawXOffset = 0;
  239.         dummy->DrawYOffset = 0;
  240.         PitsLava[HL_FALLING] = dummy->DeadState;
  241.         NoAction();
  242.         Link->Action = LA_NONE;
  243.     }
  244. }
Add Comment
Please, Sign In to add comment