Jump to content

Photo

sideview water

sideview water swim

  • Please log in to reply
17 replies to this topic

#16 ZeldaPlayer

ZeldaPlayer

    What's up my playas

  • Members
  • Location:USA

Posted 06 September 2014 - 06:31 PM

I never even knew this was possible. I guess I will use this. This looks like an amazing script!  :D



#17 accela2me

accela2me

    Illustrious

  • Members
  • Real Name:Juliano
  • Location:Minas Gerais, Brazil

Posted 08 September 2014 - 07:32 PM

Leges, I removed this "bug" during the screen scrolling using an item with LTM while Link is under water.

if ((Screen->ComboF[ComboAt(Link->X + 8, Link->Y + 15)] == CF_SCRIPT5 || Screen->ComboI[ComboAt(Link->X + 8, Link->Y + 15)] == CF_SCRIPT5)){
    Link->Item[184] = true;            
    }
else{
    Link->Item[184] = false;
    }

But it's something temporary, of course. When the script is updated, I will use again the animated combo drawn over the invisible Link.
It's 1000x better the correct animation for Link under water than a limited LTM :/



#18 justin

justin

    Adept

  • Members

Posted 07 January 2015 - 10:31 PM

Lejes, i hope you don't mind but I "finished" the script.  Added the drawing while screen scrolling.  And now it requires Flippers to be able to swim, if you don't have them it turns the combo you're jumping in to an actual water combo which you drown in.

 

here's the script

 

import "std.zh"
 
// set your the combos for your swimming animation.
const int SWIM_LEFT_COMBO = 901;
const int SWIM_RIGHT_COMBO = 900;
const int SWIM_COMBO_CSET = 6;
 
const int OUT_OF_WATER_JUMP = 2; // How high Link jumps when leaving the water. 3 is the standard Roc's Feather height.
 
const int CF_SV_SWIM = 102;   // CF_SCRIPT5
                              // put this flag (placed or inherent) on any combo you want sideview swimable
                              // !!!!!!!!!!!!!!  watch for conflicts with other scripts!
 
bool underwater = false;
 
// to draw while Scrolling
int scrollDir;
int scrollCounter;
int drawX;
int drawY;
 
 
global script Slot_2{
   void run(){
 
      while(true){
 
         // keep this at the top of your while loop.
         ScrollFix(); 
  
         // does the drawing of the swim animation, before waitdraw
         Sideview_Swim();
 
 
         Waitdraw();
 
         Waitframe();
 
      }//end whileloop
   }//end run
}//end global slot2
 
 
 
// If you're sideview swimming it'll draws swimming tiles on top of Link even while scrolling
void Sideview_Swim(){
   if(underwater){
      Link->Invisible = true;
 
      if (Link->Dir == DIR_UP || Link->Dir == DIR_LEFT)
         Screen->FastCombo(4, drawX, drawY, SWIM_LEFT_COMBO, SWIM_COMBO_CSET, OP_OPAQUE);
      else
         Screen->FastCombo(4, drawX, drawY, SWIM_RIGHT_COMBO, SWIM_COMBO_CSET, OP_OPAQUE);
   }
   else Link->Invisible = false;  // if other scripts are making Link invisible this will negate that.  
                                  // you'll want to add more conditions here in that case
}
 
 
// Attach this script to an ffc on any sideview screen with your swim flag.
// The script won't run on non-sideview screens.
// DON'T check "run script on screen init"
// D0 = wave effect.  0 off. 1 on.
 
ffc script Swimming{
   void run(int wave){
      if(!IsSideview()) Quit();
 
      this->Vy = 0;
      float accel = 0.16;
      float holddown = 0;
      float jump = 0; // This variable makes Link sink a little faster after hitting the water.
      float max_sink = 0.5;
      int timerJump = 0;
      int cType;
 
      // A little upward velocity at the bottom of the screen to start, so you don't get scrolled off immediately.
      if(Link->Y > 156){
         Link->Jump = 2; // Change this to a higher number if you think it's still too little time before sinking off the bottom of the screen.
         Waitframes(10);
      }
 
      this->X = Link->X;
      this->Y = Link->Y;
 
      int loc = ComboAt(Link->X+8, Link->Y+8);
 
      // Checks for underwater status on new screen, so water-to-water screen transitions avoid surface jump mechanics.
      if(ComboFI(loc,CF_SV_SWIM) ) underwater = true;
 
      while(true){
         loc = ComboAt(Link->X+8, Link->Y+8);
 
         if(!Link->Item[I_FLIPPERS] && ComboFI(loc, CF_SV_SWIM) ){
 
            int type = Screen->ComboT[loc];
 
            Screen->ComboT[loc] = CT_WATER;     // quick and dirty way to fake drowning
            while(LA_DROWNING) Waitframe();
            Screen->ComboT[loc] = type;
         }
 
         if(!underwater && ComboFI(loc,CF_SV_SWIM) ){
            //onLadder = false;
            underwater = true;
            jump = 0.3;
            timerJump = 20;
         }
 
         if(underwater){
            if(wave) Screen->Wavy = 5;
            holddown = 0;
 
            if(timerJump <= 0) jump = 0;
 
            cType = Screen->ComboT[loc];
            if(cType == CT_CVUP){     
               if( !isSolid(Link->X+1, Link->Y-1) && !isSolid(Link->X+8, Link->Y-1) && !isSolid(Link->X+14, Link->Y-1) )
                  this->Y--;
            }
            else if(cType == CT_CVDOWN){    
               // if( !isSolid(Link->X+1, Link->Y+16) && !isSolid(Link->X+8, Link->Y+16) && !isSolid(Link->X+14, Link->Y+16) )
                  holddown = 0.16;
            }
            else if(cType == CT_CVLEFT){
               if( !isSolid(Link->X-1, Link->Y+15) && !isSolid(Link->X-1, Link->Y+1) )
                  Link->X--;
            }
            else if(cType == CT_CVRIGHT){
               if( !isSolid(Link->X+16, Link->Y+15) && !isSolid(Link->X+16, Link->Y+1) )
                  Link->X++;
            }
 
            this->X = Link->X;
            Link->Y = this->Y;
 
            if(Link->InputDown) holddown = 0.16;
 
            if(timerJump > 0) jump = 0.3;
 
            if (holddown > 0) max_sink = 1.2;
            else max_sink = 0.8;
 
            this->Vy = Min(max_sink, this->Vy + accel + holddown + jump);
 
            if(Screen->isSolid(Link->X+8,Link->Y+16) && this->Vy > 0)
               this->Vy = 0;
 
            if(Link->PressA){
               Game->PlaySound(SFX_SPLASH);
               this->Vy = -1.8;
 
               if(Link->InputUp) this->Vy = -2.5;
            }
 
            if(Screen->isSolid(Link->X+8,Link->Y) && this->Vy < 0)
               this->Vy = 0;
 
            Link->InputA = false;
            Link->InputB = false; 
            Link->InputUp = false;
            Link->InputDown = false;
 
            timerJump--;
         }//end if underwater
 
 
         loc = ComboAt(Link->X+8, Link->Y+12);
 
         if(underwater && !ComboFI(loc,CF_SV_SWIM) ){
               if(timerJump <= 0){  
                  Link->Jump = OUT_OF_WATER_JUMP;
                  Game->PlaySound(SFX_JUMP);
               }
 
               underwater = false;
         }
 
         // reset the FFC's data
         if(!underwater){
            this->X = Link->X;          
            this->Y = Link->Y;
            this->Vx = 0;
            this->Vy = 0;
         }
 
         Waitframe();
 
      }//end whileloop
   }//end run
}//end ffc script Swimming 
 
// Activates secrets permanently when stepped on. Meant for sideview swimming sections. Shifts to next combo in list, so set FFC properties to run this at screen init.
ffc script SideviewButton{
   void run(){
      if(Screen->State[ST_SECRET]) this->Data++;
 
      while(true){
         if(Abs(Link->X - this->X) < 4 && Abs(Link->Y - this->Y) < 3){
            this->Data++;
            Screen->TriggerSecrets();
            Game->PlaySound(SFX_SECRET);
            Screen->State[ST_SECRET] = true;
            Quit();
         }
 
         Waitframe();
      }
   }
}
 
// Allows drawing tiles to correct position on Link when scrolling
// Sets drawX/drawY either to Link X/Y when not scrolling, or the visual position when scrolling.
// currently only used by Pegasus Boots (which is also setting drawX/drawY to Link's new x/y as he dashes)
 
void ScrollFix(){
   //function by Saffith
 
   if(Link->Action==LA_SCROLLING){
       if(scrollDir==-1)
       {
           if(Link->Y>160)
           {
               scrollDir=DIR_UP;
               scrollCounter=45;
           }
           else if(Link->Y<0)
           {
               scrollDir=DIR_DOWN;
               scrollCounter=45;
           }
           else if(Link->X>240)
           {
               scrollDir=DIR_LEFT;
               scrollCounter=65;
           }
           else
           {
               scrollDir=DIR_RIGHT;
               scrollCounter=65;
           }
       }
    
       if(scrollDir==DIR_UP && scrollCounter<45 && scrollCounter>4)
           drawY+=4;
       else if(scrollDir==DIR_DOWN && scrollCounter<45 && scrollCounter>4)
           drawY-=4;
       else if(scrollDir==DIR_LEFT && scrollCounter<65 && scrollCounter>4)
           drawX+=4;
       else if(scrollDir==DIR_RIGHT && scrollCounter<65 && scrollCounter>4)
           drawX-=4;
    
       scrollCounter--;
   }
   else
   {
       drawX=Link->X;
       drawY=Link->Y;
       if(scrollDir!=-1)
           scrollDir=-1;
   }
}
 
// !!!!!!!!! This function is used by a lot of scripts.  Only need it once.
//returns true if the combo is solid at x/y
bool isSolid(int x, int y){
    if(x<0 || x>255 || y<0 || y>175) return false;
    int mask=1111b;
        if(x%16<8) mask&=0011b;
        else mask&=1100b;
            if(y%16<8) mask&=0101b;
            else mask&=1010b;
            return (!(Screen->ComboS[ComboAt(x, y)]&mask)==0);
}
 

 

edited: the previous version wouldn't have compiled on its own.  and this one adds the conveyor type combos.


Edited by justin, 09 January 2015 - 05:11 PM.



1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users