Jump to content

Photo

Scripting Help: Press L to Use Shield


  • Please log in to reply
2 replies to this topic

#1 RephireZeKasual217

RephireZeKasual217

    Initiate

  • Members

Posted 08 November 2017 - 06:44 PM

I'm currently in the making of a quest and i really want to have you use the shield only when you hold the button, the same as to the Simple GB Shield Script, but by pressing L, R, or any of the EX buttons, just not the A and B buttons.

 

Edit: I finally found one!!!! yay.

 

import "std.zh"
 
//Change these values to match your item setup
const int GBS_SMALL=8;
const int GBS_MAGIC=37;
const int GBS_MIRROR=93;
const int GBS_FAKESMALL=132;
const int GBS_FAKEMAGIC=133;
const int GBS_FAKEMIRROR=134;
const int SFX_GBSHIELD=17;
 
global script slot_2{
    void run(){
    //Initializations
    bool shieldon;
    int lastdir;
    int gbsound;
    bool setdir = false;
        
        while(true){
            //GBShield strafe setup
            //if( (!(Link->Action==LA_ATTACKING))
            //&& (!(Link->Action==LA_CHARGING))
            //&& (!(Link->Action==LA_SPINNING))) {lastdir=Link->Dir;}
 
 
             
            int nw = ComboAt(Link->X + 8, Link->Y + 12);
 
            if(nowalkshield(nw)){          
                Link->Item[GBS_MIRROR]=false;
                Link->Item[GBS_MAGIC]=false;
                Link->Item[GBS_SMALL]=false;
                shieldon=false;
                setdir=false;
            }
 
            else if(Link->InputEx1 && !shieldon){ //Enable shield when R is pressed
                shieldon=true;
                if(!setdir)
                {
                    lastdir=Link->Dir;
                    setdir=true;
                }
                gbsound=SFX_GBSHIELD;
                if(Link->Item[GBS_FAKEMIRROR]) Link->Item[GBS_MIRROR]=true;
                else if(Link->Item[GBS_FAKEMAGIC]) Link->Item[GBS_MAGIC]=true;
                else if(Link->Item[GBS_FAKESMALL]) Link->Item[GBS_SMALL]=true;
                else{
                    gbsound=0;
                    shieldon=false;
                    setdir=false;
                }
                if(gbsound>0) Game->PlaySound(SFX_GBSHIELD);
            }
            else if(!Link->InputEx1 && shieldon){ //Remove shield when R is released
                Link->Item[GBS_MIRROR]=false;
                Link->Item[GBS_MAGIC]=false;
                Link->Item[GBS_SMALL]=false;
                shieldon=false;
                setdir=false;
            }
 
            //check if the hookshot is on screen
            bool nohookshotonscreen = true;
 
            for(int i=1;i<=Screen->NumLWeapons();i++){
                lweapon testedlw = Screen->LoadLWeapon(i);
                if(testedlw->ID == LW_HOOKSHOT){nohookshotonscreen=false;}
            }
 
 
            
            Waitdraw();  
 
            //Strafe while R is held down
            if(Link->InputEx1
            && shieldon
            && (!(Link->Action==LA_ATTACKING))
            && (!(Link->Action==LA_CHARGING))
            && (!(Link->Action==LA_SPINNING))
            && nohookshotonscreen) {Link->Dir=lastdir;}
 
 
 
            Waitframe();
            }                 // end while
        }                  //end void run
 
    bool nowalkshield(int underlink){
        underlink = ComboAt(Link->X, Link->Y + 8);
        return (Screen->ComboT[underlink] == 31) || (Screen->ComboT[underlink] == 32) || (Screen->ComboT[underlink] == 33) || (Screen->ComboT[underlink] == 34)
         || (Screen->ComboT[underlink] == 120) || (Screen->ComboT[underlink] == 121) || (Screen->ComboT[underlink] == 122) || (Screen->ComboT[underlink] == 19)
         || (Screen->ComboT[underlink] == 89) || (Screen->ComboT[underlink] == 90) || (Screen->ComboT[underlink] == 91) || (Screen->ComboT[underlink] == 6)
         || (Screen->ComboT[underlink] == 18) || (Screen->ComboT[underlink] == 86) || (Screen->ComboT[underlink] == 87) || (Screen->ComboT[underlink] == 88)
         || (Screen->ComboT[underlink] == 38) || (Screen->ComboT[underlink] == 36) || (Screen->ComboT[underlink] == 39) || (Screen->ComboT[underlink] == 40)
         || (Screen->ComboT[underlink] == 37) || (Screen->ComboT[underlink] == 3);
    }
 
}

Edited by RephireZeKasual217, 20 November 2017 - 12:43 AM.


#2 Timelord

Timelord

    The Timelord

  • Banned
  • Location:Prydon Academy

Posted 09 November 2017 - 03:50 AM

There are at least three scripts for this. Try a search for 'shield button'.

#3 RephireZeKasual217

RephireZeKasual217

    Initiate

  • Members

Posted 20 November 2017 - 12:44 AM

Is it possible to implement slow walking to this script when you use it?


Edited by RephireZeKasual217, 20 November 2017 - 12:44 AM.



0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users