Jump to content

Photo

Button-Item Shield


  • Please log in to reply
59 replies to this topic

#1 Jared

Jared

    Deified

  • Members
  • Real Name:Jared
  • Pronouns:He / Him
  • Location:New Hampshire

Posted 20 May 2012 - 05:46 PM

Hey all! I have a request.

Since I was planning on using these Link tiles (or something similar), I want the shield to be a button item. It must be able to be held up when the button is pressed down. And, I want it to appear on Link's arm when it's equipped (So when it's not on A or B, it's not there. Like a Game Boy Zelda games).
Also, I do NOT want it to strafe.

So,
  • Shield equippable
  • Held up when button is pressed
  • Disappear when not equipped, appear on his arm when it is

Can anyone do this for me?

Also, will it be okay with Link Tile Modifiers, and the push tiles, etc?

Thanks to whoever can do this. icon_smile.gif

#2 SUCCESSOR

SUCCESSOR

    Apprentice

  • Banned
  • Real Name:TJ

Posted 20 May 2012 - 07:59 PM

Is it possible to detect when an Item is equipped to A or B? I didn't think it was. I thought this was a limitation of Zscript.

I think it would be possible to have a shieldless link till the shield is acquired and have always equipped and then use the item buttons to use it.

#3 Jared

Jared

    Deified

  • Members
  • Real Name:Jared
  • Pronouns:He / Him
  • Location:New Hampshire

Posted 20 May 2012 - 08:09 PM

That would be fine too. I can live with that!
I just hope someone could do it...

#4 accela2me

accela2me

    Illustrious

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

Posted 20 May 2012 - 08:35 PM

I learned how to arrange the tiles for Link using or not the shield with this tutorial:
http://www.purezc.co...showtopic=37395

How to position the shield to defend yourself (using button A or B), I think I've seen scripts in the forum talking about it, but I'm not sure if they work...

#5 MoscowModder

MoscowModder

    Sometimes lurking. Rarely posting.

  • Members
  • Location:Wisconsin

Posted 20 May 2012 - 08:41 PM

It may (and in fact should) be possible to alter the GBShield script I have (hold R to use the shield) to work with an item.

Untested but should work...
Modified GBShield script

Edited by MoscowModder, 21 May 2012 - 07:35 AM.


#6 Jared

Jared

    Deified

  • Members
  • Real Name:Jared
  • Pronouns:He / Him
  • Location:New Hampshire

Posted 20 May 2012 - 08:44 PM

But I can't really change the script, since I don't know how to script. Wasn't that obvious? icon_razz.gif

Edit - Oh. Fail xD
How do I set it up?

Edited by Jared, 20 May 2012 - 08:45 PM.


#7 MoscowModder

MoscowModder

    Sometimes lurking. Rarely posting.

  • Members
  • Location:Wisconsin

Posted 20 May 2012 - 09:07 PM

1. Combine the global script with whatever scripts you have
2. Make up to three "dummy" shields - these are the items you equip
3. Set the GBS_* constants to the real and "dummy" shields
4. Try using the "dummy" shields and tell me how it goes

BTW, this script includes the fix that makes strafing work - I can turn off strafing if you don't want it.

#8 Jared

Jared

    Deified

  • Members
  • Real Name:Jared
  • Pronouns:He / Him
  • Location:New Hampshire

Posted 20 May 2012 - 09:13 PM

I'm just testing this for now. Since I'm waiting on my tileset atm.

Where's the global script? icon_confused2.gif

Are the dummy shields items, or "Custom Item"s? Do I attach a script to it too? You didn't make it very clear.

And yes, I want strafing off.

IPB Image

Edited by Jared, 20 May 2012 - 09:35 PM.


#9 MoscowModder

MoscowModder

    Sometimes lurking. Rarely posting.

  • Members
  • Location:Wisconsin

Posted 21 May 2012 - 07:39 AM

There's no mention of "TheFFC" in this script - the problem is in another script. See if line 755 ends with a semicolon and add it if there isn't (unless it's the beginning of an if, else, while, etc statement).

Updated the script; removed strafing code.

Everything from global script slot_2{ down is the global script.

The three dummy items should be a custom item class, and you need to add them to the subscreen manually. You don't attach a script to them - if this doesn't work, I might add one, but if this setup works you don't need an item script.

#10 tox_von

tox_von

    Zelda Addict

  • Members
  • Real Name:Redgor
  • Location:Toxicville , Simcity

Posted 21 May 2012 - 07:52 AM

the code above was wrong there was an extra } and an elseif which needed to be an if. It compiles like this i didnt try it.

edit also i dont know what this is doing.
//else if(Link->InputR && !shieldon){ //Enable shield when R is pressed

CODE
import "std.zh"

//Change these values to match your item setup
const int GBS_SMALL=93;
const int GBS_MAGIC=8;
const int GBS_MIRROR=37;
const int GBS_FAKESMALL=144;
const int GBS_FAKEMAGIC=145;
const int GBS_FAKEMIRROR=146;
const int SFX_GBSHIELD=17;

global script slot_2{
    void run(){
    //Initializations
    bool shieldon;
    int gbsound;
        
        while(true){
            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;
            }

            //else if(Link->InputR && !shieldon){ //Enable shield when R is pressed
            else if( !shieldon && ( UsingItem(GBS_FAKESMALL) || UsingItem(GBS_FAKEMAGIC) || UsingItem(GBS_FAKEMIRROR) ) ) //Enable shield when using dummy
                shieldon=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;
                }
                if(gbsound>0) Game->PlaySound(SFX_GBSHIELD);
            }
            if(!( UsingItem(GBS_FAKESMALL) || UsingItem(GBS_FAKEMAGIC) || UsingItem(GBS_FAKEMIRROR) ) && shieldon){ //Remove shield when item is released
                Link->Item[GBS_MIRROR]=false;
                Link->Item[GBS_MAGIC]=false;
                Link->Item[GBS_SMALL]=false;
                shieldon=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;
            }
            
            //Turn off inputs "L" and "R".
            Link->InputL=false;
            Link->InputR=false;

            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 tox_von, 21 May 2012 - 08:14 AM.


#11 MoscowModder

MoscowModder

    Sometimes lurking. Rarely posting.

  • Members
  • Location:Wisconsin

Posted 21 May 2012 - 08:48 AM

Thanks for fixing the error! That line used to activate the shield when R was pressed. I commented it out instead of deleting it (it doesn't do anything while commented) when I added the new item-based check.

#12 tox_von

tox_von

    Zelda Addict

  • Members
  • Real Name:Redgor
  • Location:Toxicville , Simcity

Posted 21 May 2012 - 10:38 AM

i ran the script and it froze it needs more done.

#13 Saffith

Saffith

    IPv7 user

  • Members

Posted 21 May 2012 - 11:21 AM

The problem wasn't an extra right brace or an extra else. It was a missing left brace.

Code


#14 Jared

Jared

    Deified

  • Members
  • Real Name:Jared
  • Pronouns:He / Him
  • Location:New Hampshire

Posted 21 May 2012 - 03:34 PM

I tried Saffith's edit, but nothing happens when i get it. It doesn't show up on my subscreen (When I put it there), and I can't equip it. It's an equipment item, by the way.

#15 MoscowModder

MoscowModder

    Sometimes lurking. Rarely posting.

  • Members
  • Location:Wisconsin

Posted 21 May 2012 - 03:35 PM

If the dummy shield doesn't show in your subscreen, that really shouldn't be a problem with the script. Or are you talking about the real shield?

Did you forget to set the position and selecting directions for the shield?


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users