Jump to content

Photo

Only one lockblock??


  • Please log in to reply
50 replies to this topic

#31 AgentLym

AgentLym

    • Zelda and Pokémon Master •

  • Members
  • Location:Skyloft

Posted 22 January 2010 - 04:15 PM

That's what I thought, but if you change the bit number of Screen->D[d], wouldn't you change the entire thing?

Like, variable Screen->D[d] with a bit value of 10010100 doesn't equal Screen->D[d] with a bit value of 10110100, right? You'd be changing the entire Screen->D[d] variable to something totally different, quite possibly to something that's already been used (that wasn't meant to be).

Or am I just thinking too hard...

What determines Screen->D[d]'s bit value, anyhow? I was thinking that the 'd' part determined it's bit value. So if 'd' was 7, the bit number would be 00000111, but then, say, you '|=' 1<<3:

00000111 |= 00001000 == 00001111 (15)

But, I do understand now how the script is meant to work, just not how! ^^

#32 Joe123

Joe123

    Retired

  • Members

Posted 22 January 2010 - 04:26 PM

I think I get what you mean.
Yes, I am doing an operation which could potentially change the whole number, but because of how I'm doing it (in this instance), I'm actually only ever going to change one bit at a time.
Does that help?

#33 AgentLym

AgentLym

    • Zelda and Pokémon Master •

  • Members
  • Location:Skyloft

Posted 22 January 2010 - 05:55 PM

Yeah... but one bit in computer language is a major difference, right?

#34 Joe123

Joe123

    Retired

  • Members

Posted 22 January 2010 - 06:51 PM

I don't really get what you mean, that one bit that I'm changing is the one that I want to use.

#35 AgentLym

AgentLym

    • Zelda and Pokémon Master •

  • Members
  • Location:Skyloft

Posted 22 January 2010 - 08:01 PM

Doesn't the bit value determine what the decimal variable 'Screen->D[d]' is?

Or is the bit value a totally separate component to every decimal value in ZC?

#36 Joe123

Joe123

    Retired

  • Members

Posted 22 January 2010 - 08:06 PM

Yes it does, that's the whole point.
I'm dedicating that Screen->D[] register entirely to my bit string.

#37 cosmofield

cosmofield

    Magical Girl

  • Members
  • Location:Sweden

Posted 02 February 2010 - 03:16 PM

QUOTE(Joe123 @ Jan 22 2010, 01:32 AM) View Post

Ok, it is completed!

CODE
ffc script LockBlock{
    void run(int pushtime, int sfx, int perm, int d){
        if(pushtime == 0) pushtime = 10;
        int loc = ComboAt(this->X,this->Y);

        int pushclk = 0;
        while((Screen->D[d] & (1<<perm)) == 0){
            if(PushingCombo(loc) && Game->Counter[CR_KEYS] > 0) pushclk++;
            else pushclk = 0;
            Waitframe();
            if(pushclk == pushtime) Unlock(sfx,perm,d);
        }
        Screen->ComboD[loc]++;
    }
    void Unlock(int sfx, int perm, int d){
        if(sfx == 0) Game->PlaySound(SFX_SHUTTER);
        else if(sfx > 0) Game->PlaySound(sfx);
        Screen->D[d] |= (1<<perm);
        Game->Counter[CR_KEYS]--;
    }
    bool PushingCombo(int loc){
        int y = ComboY(loc); int x = ComboX(loc);
        return (Link->Dir == DIR_UP && Link->InputUp && Link->Y == y+8 && Abs(Link->X-x) < 8)
            || (Link->Dir == DIR_DOWN && Link->InputDown && Link->Y == y-16 && Abs(Link->X-x) < 8)
            || (Link->Dir == DIR_LEFT && Link->InputLeft && Link->X == x+16 && Abs(Link->Y-y) < 8)
            || (Link->Dir == DIR_RIGHT && Link->InputRight && Link->X == x-16 && Abs(Link->Y-y) < 8);
    }
}

ffc script Copycat{
    void run(int perm, int d){
        while((Screen->D[d] & (1<<perm)) == 0) Waitframe();
        Screen->ComboD[ComboAt(this->X,this->Y)]++;
    }
}

It now functions exactly like the built in lock-blocks, and allows a 18 different lock blocks per D register per screen =)


I want to try this script but I don't know how the setup process (noob), I have compiled it but how many FFC do I need and what D0-values assigned? I want 8 lockblocks for different keys on one screen that need to be unlocked one after another.

#38 AgentLym

AgentLym

    • Zelda and Pokémon Master •

  • Members
  • Location:Skyloft

Posted 02 February 2010 - 03:37 PM

Well, you only need one FFC per lockblock (set the FFC directly over the lockblock you want to create), so you're going to need 8 different FFCs. You set up the Dx arguments as follows:

D0 - Amount of frames you want Link to press against the lockblock to open it. Leave at 0 for the default time (which is the same as pre-programmed lockblocks), about 10 frames.
D1 - Sound effect to play when the lockblock is opened. Leave at 0 for the default sound effect played for pre-programmed lockblocks (the same sound as the shutter opening)
D2 - Bit used in your Screen->D register (you usually don't have to worry about this, but if you have the same D3 number for multiple lockblocks, you'll have to have, at least, a different number for the D2 arguments (so if two lockblocks have a D3 value of 1, one of the two lockblocks will need to have a different D2 number, unless you want them both to unlock at the same time. D2 has to be a number between 0 and 17, if I'm not mistaken)
D3 - The Screen->D register being used by the lockblock. Screen->D registers are permanent integers integrated into every single screen used in your quest. There are 8 per screen (so D3 can only be 0 through 7), and are saved with the quest. Used by scripters to make permanent changes to scripts. This number should probably be different for each lockblock you want to make, if D2 is the same for all. Also, be sure none of your other scripts being used on the screen uses any of the Screen->D registers as well. They probably aren't, but... if it doesn't work, check here first. icon_wink.gif

I hope that helps!

Edited by AgentLym, 02 February 2010 - 03:40 PM.


#39 cosmofield

cosmofield

    Magical Girl

  • Members
  • Location:Sweden

Posted 02 February 2010 - 04:48 PM

Thanks, I have one FFC there now but I got two scripts when compiled. LockBlock and Copycat, which script to use? I have no other options assigned to the FFC right now except for the "Lockblock-script"

Edited by cosmofield, 02 February 2010 - 04:49 PM.


#40 AgentLym

AgentLym

    • Zelda and Pokémon Master •

  • Members
  • Location:Skyloft

Posted 02 February 2010 - 04:58 PM

Just assign the Lockblock script to each different lock block you want separate from the rest. The copycat script is for blocks you want to unlock at the same time as the original lockblock script, but can't be unlocked themselves (they can only be unlocked if the original lockblock is unlocked, not vice versa; if you want copycats that are unlockable as well, just use the first 'LockBlock' script and set the D2/D3 arguments to be the same [as you also do to the copycat script assigned ffcs in relation to the lockblock you want them to copy] )

Sorry if that's a little hard to understand; I don't really know how to explain it.

=== EDIT ===
Well, here's another way of thinking about it. Each different lockblock has a different D2 (perm) and D3 (d) combination. If any two lockblocks, copycat or not, have the same 'perm' and 'd' arguments alike, they will be unlocked at the same time. Copycats just can't be unlocked by walking up to them; they are unlocked by triggering their normal Lockblock counterparts.

Does that help?

Edited by AgentLym, 02 February 2010 - 05:01 PM.


#41 cosmofield

cosmofield

    Magical Girl

  • Members
  • Location:Sweden

Posted 02 February 2010 - 05:08 PM

Nothing happens icon_frown.gif

Let's see if I got it right, I have two regular lockblocks on the screen, and also two FFC with Lockblock script selected, D2 and D3 for each FFC need to be unique integers, right? I think the problem is that the script doesn't run when Link enters the screen. I have no options selected in the F9/screen options menu, the DMap is Interior level ID 11. icon_unsettled.gif


#42 AgentLym

AgentLym

    • Zelda and Pokémon Master •

  • Members
  • Location:Skyloft

Posted 02 February 2010 - 05:44 PM

Nothing happens? Like, they don't unlock at all?

Well, firstly, they combos you want to be lockblocks technically should not be lockblock type. They should just be a combo that looks like a lockblock with the unlocked block directly to the right of it. (So in your combo pages, you should have a locked block with the <none> combo type, with a floor [or whatever you want to appear underneath the lockblock] right beside it, to the right, with the <none> combo type as well.)

Also, make sure your FFCs are transparent, but not Combo 0. So, they have to have a graphic of a combo greater than 0, but invisible. (I usually put a whole row of transparent combos at the top of my combo pages, just for this purpose; FFCs can not use scripts if their graphic is combo 0 for some reason)

Set the FFCs directly on top of the blocks you want to be lockblocks (the ones with the <none> combo type but still look like lockblocks). Set the arguments. Here, I'd set them like so: D0 = 0, D1 = 0, D2 = 0 (equal to 1 for the second <none> lockblock), D3 = 0.

Test it out; make sure you have a key or two as well. icon_wink.gif

Also, use this code instead:

CODE
ffc script LockBlock{
    void run(int pushtime, int sfx, int perm, int d){
        if(pushtime == 0) pushtime = 10;
        int loc = ComboAt(this->X,this->Y);

        int pushclk = 0;
        while((Screen->D[d] & (1<<perm)) == 0){
            if(PushingCombo(loc) && CheckKeys()) pushclk++;
            else pushclk = 0;
            Waitframe();
            if(pushclk == pushtime) Unlock(sfx,perm,d);
        }
        Screen->ComboD[loc]++;
    }
    void Unlock(int sfx, int perm, int d){
        if(sfx == 0) Game->PlaySound(SFX_SHUTTER);
        else if(sfx > 0) Game->PlaySound(sfx);
        Screen->D[d] |= (1<<perm);
        if(Game->LKeys[Game->GetCurLevel()] > 0) Game->LKeys[Game->GetCurLevel()]--;
        else Game->Counter[CR_KEYS]--;
    }
    bool CheckKeys(){
        return Game->Counter[CR_KEYS] > 0 || Game->LKeys[Game->GetCurLevel()] > 0;
    }
    bool PushingCombo(int loc){
        int y = ComboY(loc); int x = ComboX(loc);
        return (Link->Dir == DIR_UP && Link->InputUp && Link->Y == y+8 && Abs(Link->X-x) < 8)
            || (Link->Dir == DIR_DOWN && Link->InputDown && Link->Y == y-16 && Abs(Link->X-x) < 8)
            || (Link->Dir == DIR_LEFT && Link->InputLeft && Link->X == x+16 && Abs(Link->Y-y) < 8)
            || (Link->Dir == DIR_RIGHT && Link->InputRight && Link->X == x-16 && Abs(Link->Y-y) < 8);
    }
}

ffc script Copycat{
    void run(int perm, int d){
        while((Screen->D[d] & (1<<perm)) == 0) Waitframe();
        Screen->ComboD[ComboAt(this->X,this->Y)]++;
    }
}


It works even if you're using Level Keys (which you probably are).

Hope it works out for you!

#43 cosmofield

cosmofield

    Magical Girl

  • Members
  • Location:Sweden

Posted 02 February 2010 - 06:13 PM

Working exxellent. icon_biggrin.gif

Btw, Dmap-specific keys is neccesary for that level (otherwise it would be possible to cheat) icon_wink.gif

Good explanation. Thanks again ^_^


#44 AgentLym

AgentLym

    • Zelda and Pokémon Master •

  • Members
  • Location:Skyloft

Posted 02 February 2010 - 06:17 PM

QUOTE(cosmofield)
Btw, Dmap-specific keys is neccesary for that level...

Yep, I thought that might be the problem; sorry I didn't point it out earlier! icon_razz.gif

No problem! Just glad I could help! ^^ (<- just in case people didn't know, this is my smiling face! lol Not two arrows pointing upwards. icon_wink.gif )

Edited by AgentLym, 02 February 2010 - 06:20 PM.


#45 Joe123

Joe123

    Retired

  • Members

Posted 02 February 2010 - 06:41 PM

Once I get round to it, I'm going to edit the script so it works for ffcs larger than 1x1, and then I'm going to submit it to the database with a lil' tutorial, so it should be a lot easier for people to use in future =)


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users