Jump to content

Photo

Only one lockblock??


  • Please log in to reply
50 replies to this topic

#1 AgentLym

AgentLym

    • Zelda and Pokémon Master •

  • Members
  • Location:Skyloft

Posted 20 January 2010 - 03:40 PM

I learned just now that you can only have one lockblock per screen! Why did the devs make lockblocks behave like that? I just assumed that 'Lockblock (copycat)' are the blocks that should unlock at the same time another lockblock is unlocked, but it turns out that every single lockblock on the screen is unlocked if you unlock any! You just can't unlock a copycat block first is the difference.

I'm asking: is there any way around this? Is there any way to make a more than two lockblocks on a screen at any one time??

... *breathes* ... I'm just awestruck that that's how it's been this whole time, and I've never even noticed it! It also seems unprecedented to code something like that, since almost everything else is separate beings, like chests-- oh wait, they're unlocked at the same time, too!

Well... I guess I gotta scrap my mirror dungeon ideas. >.<

If any of the devs read this, could you think about making new Combo types for Lockblocks A, B, C, and D like you did for warps? And make copycats A, B, C, and D. And Chests A, B, C, and D, for that matter... Just my thought on the subject!

</vent>

Sorry, I had to get that out of my system. ^^'

Edited by AgentLym, 20 January 2010 - 03:54 PM.


#2 InsanityForce

InsanityForce

    Initiate

  • Members
  • Location:France

Posted 20 January 2010 - 05:48 PM

I never noticed that either icon_confused.gif
I tried using different layers, it didn't work. Singular flags don't work either.

If Link has to open the locks in a set order, you can make several combos with the Lock Block type and tile (make them solid !), one after each other in the combo page, and finally a "unlocked block" combo, so when Link activates the first Lock Block, every Lock Block combo on the screen shift to the next combo. The first block combo Link has to open would be the one directly left of the "unlocked" combo, the second one would be the combo on the left of the previous one, etc.

If you want the player to open the lock blocks in any order, I don't know what to do. icon_sorry.gif
Beside scripts. They are a good solution when you don't know a trick ...

Edited by InsanityForce, 20 January 2010 - 05:49 PM.


#3 Christian

Christian

    Summoner

  • Members
  • Real Name:Chris
  • Location:New Jersey

Posted 20 January 2010 - 05:54 PM

I think there is a script in the database that can control that. Matthew wrote it.

#4 AgentLym

AgentLym

    • Zelda and Pokémon Master •

  • Members
  • Location:Skyloft

Posted 20 January 2010 - 08:11 PM

Well, his wasn't exactly what I was looking for, so I made my own. It's only flaw is (and it's no minor flaw)...

... it's not permanent. icon_sweat.gif So, you basically have to re-unlock every door/block you unlock using this script... unless you make the script warp you to similar room but without the lock blocks there. ^^'

Here's the script, anyhow. icon_razz.gif

CODE
//Place the constant integers somewhere at the beginning of the file so the global script can call on them
const int floorcombo = 1;     //Combo ID of the combo you want to appear once the lock block is unlocked
const int newblock = 5812;     //Combo ID of the lockblock in question
const int lbnsfx = 9;     //Used when block is unlocked (9 is the same sound as the shutter opening or closing)

//Go to your Global Script 2 section and insert the rest of the code somewhere after the 'While(true){' snippet
int blockup = ComboAt(Link->X + 8, Link->Y + 7);
int blockdown = ComboAt(Link->X + 8, Link->Y + 16);
int blockleft = ComboAt(Link->X - 1, Link->Y + 8);
int blockright = ComboAt(Link->X + 16, Link->Y + 8);

if(Link->Dir == 0 && Link->InputUp && Link->Action == 1 && Screen->ComboD[blockup] == newblock && Game->Counter[CR_KEYS] >= 1){
Waitframes(10);
    Game->PlaySound(lbnsfx);
    Screen->ComboD[blockup] = floorcombo;
    Game->Counter[CR_KEYS] --;
}
if(Link->Dir == 1 && Link->InputDown && Link->Action == 1 && Screen->ComboD[blockdown] == newblock && Game->Counter[CR_KEYS] >= 1){
Waitframes(10);
    Game->PlaySound(lbnsfx);
    Screen->ComboD[blockdown] = floorcombo;
    Game->Counter[CR_KEYS] --;
}
if(Link->Dir == 2 && Link->InputLeft && Link->Action == 1 && Screen->ComboD[blockleft] == newblock && Game->Counter[CR_KEYS] >= 1){
Waitframes(10);
    Game->PlaySound(lbnsfx);
    Screen->ComboD[blockleft] = floorcombo;
    Game->Counter[CR_KEYS] --;
}
if(Link->Dir == 3 && Link->InputRight && Link->Action == 1 && Screen->ComboD[blockright] == newblock && Game->Counter[CR_KEYS] >= 1){
Waitframes(10);
    Game->PlaySound(lbnsfx);
    Screen->ComboD[blockright] = floorcombo;
    Game->Counter[CR_KEYS] --;
}


Though, this could probably be attached to an FFC somehow, if someone were willing to convert it... I've already wasted a couple hours of my life on this, though. (and only about 25 lines of code resulted! Boy, I'm good! ^^' )

If anyone has any ideas, though, feel free to let me hear 'em! Hope this finds a use!

=== • EDIT • ===

Well, I ended up converting it to an FFC script anyways, thinking that it might be permanent with any luck... but, alas, no. Here it is, anyhow.

CODE
ffc script LockBlockNew{
    void run(){

    bool unlocked = false;     //Place this line of code at the beginning of the file to have the lock block permanent (will only work for one or all)

        while(true){

int blockup = ComboAt(Link->X + 8, Link->Y + 7);
int blockdown = ComboAt(Link->X + 8, Link->Y + 16);
int blockleft = ComboAt(Link->X - 1, Link->Y + 8);
int blockright = ComboAt(Link->X + 16, Link->Y + 8);

int block = ComboAt(this->X, this->Y);

if(Link->Dir == 0 && Link->InputUp && Link->Action == 1 && Screen->ComboD[block] == newblock && Game->Counter[CR_KEYS] >= 1 && unlocked == false && Link->X >= this->X - 8 && Link->X <= this->X + 8 && Link->Y == this->Y + 8){
Waitframes(10);
    Game->Counter[CR_KEYS] --;
    unlocked = true;
}
else if(Link->Dir == 1 && Link->InputDown && Link->Action == 1 && Screen->ComboD[block] == newblock && Game->Counter[CR_KEYS] >= 1 && unlocked == false && Link->X >= this->X - 8 && Link->X <= this->X + 8 && Link->Y == this->Y - 16){
Waitframes(10);
    Game->Counter[CR_KEYS] --;
    unlocked = true;
}
else if(Link->Dir == 2 && Link->InputLeft && Link->Action == 1 && Screen->ComboD[block] == newblock && Game->Counter[CR_KEYS] >= 1 && unlocked == false && Link->X == this->X + 16 && Link->Y <= this->Y + 2 && Link->Y >= this->Y - 2){
Waitframes(10);
    Game->Counter[CR_KEYS] --;
    unlocked = true;
}
else if(Link->Dir == 3 && Link->InputRight && Link->Action == 1 && Screen->ComboD[block] == newblock && Game->Counter[CR_KEYS] >= 1 && unlocked == false && Link->X == this->X - 16 && Link->Y <= this->Y + 2 && Link->Y >= this->Y - 2){
Waitframes(10);
    Game->Counter[CR_KEYS] --;
    unlocked = true;
}

else if(unlocked == true){
      Game->PlaySound(lbnsfx);
    Screen->ComboD[block] = floorcombo;
}

        Waitframe();
        }
    }
}


It's probably a bit easier to use, just set the FFC directly on top of the locked block you want. icon_razz.gif

Edited by AgentLym, 20 January 2010 - 09:09 PM.


#5 Joe123

Joe123

    Retired

  • Members

Posted 20 January 2010 - 08:33 PM

Yeah, sorry but the way things are currently coded that's just how it works. You can only have one secret, you can only have one lock-block, you can only have one chest etc.
It's because ZC looks a bit (kinda not very, but you get the idea) like this:
CODE
typedef struct screen{
     int combos[176];
     int somecrap,someothercrap,whatever;
     bool yadayada;
     bool secrets;
     bool lockblocks;
     bool chests;
     int whateverelse;
};
So there's only one of each thing attributed to the screen.

If the code we re-written from the bottom up, it'd be better to do things on a kind of object-basis, where you make a new object and then tell it whether it's a secret or a chest or whatever, and what it does when you do certain things to it. Kind of like very much improved ffcs. But that's not how it works, so you gotta live with it.

#6 AgentLym

AgentLym

    • Zelda and Pokémon Master •

  • Members
  • Location:Skyloft

Posted 20 January 2010 - 08:47 PM

*sigh*

Well, I guess theoretically you could make my FFC script work... you'd just have to make multiple scripts for multiple lock blocks, and give a different global bool to each... but I'd rather not do that...

I guess using my script you could have at least 2 lock blocks on screen at a time. ^^'

Edited by AgentLym, 20 January 2010 - 08:48 PM.


#7 Joe123

Joe123

    Retired

  • Members

Posted 20 January 2010 - 09:17 PM

CODE
ffc script LockBlock{
    void run(int d,int pushtime, int sfx){
        this->Misc[0] = ComboAt(this->X,this->Y);
        this->Misc[1] = d;
        this->Misc[2] = sfx;
        if(pushtime == 0) pushtime = 5;
        
        if(Screen->D[d] != 0) unlock(this);
        while(Screen->D[d] == 0){
            while(!unlocking(this->Misc[0])) Waitframe();
            int pushcounter = 0;
            while(unlocking(this->Misc[0]) && pushcounter++ < pushtime) Waitframe();
            if(pushcounter == pushtime) unlock(this);
        }
    }
    void unlock(ffc data){
        if(data->Misc[2] != 0 && Screen->D[data->Misc[1]] == 0){
            Game->PlaySound(data->Misc[2]);
            Game->Counter[CR_KEYS]--;
        }
        Screen->D[data->Misc[1]] = 1;
        Screen->ComboD[data->Misc[0]]++;
    }
    bool unlocking(int loc){
        return Game->Counter[CR_KEYS] > 0 && inputdir() && pressing(loc);
    }
    bool inputdir(){
        return (Link->Dir == DIR_UP && Link->InputUp) || (Link->Dir == DIR_DOWN && Link->InputDown)
            || (Link->Dir == DIR_LEFT && Link->InputLeft) || (Link->Dir == DIR_RIGHT && Link->InputRight);
    }
    bool pressing(int loc){
        int loc2 = ComboAt(Link->X,Link->Y);
        return (Link->Dir == DIR_UP && loc2 == loc+16) || (Link->Dir == DIR_DOWN && loc2 == loc-16)
            || (Link->Dir == DIR_LEFT && loc2 == loc+1) || (Link->Dir == DIR_RIGHT && loc2 == loc-1);
    }
}


Give that a go and let me know what happens.

#8 AgentLym

AgentLym

    • Zelda and Pokémon Master •

  • Members
  • Location:Skyloft

Posted 20 January 2010 - 10:29 PM

...! Well, it's permanent! But, it places combo 0 where the lock block goes, and can only work on one at a time. (Like, you can unlock one, but not the other, and when you enter the screen again, both are unlocked). But, I honestly can't really follow your script. (I probably could if I really just sat down and looked, but I'm so tired of looking at my computer screen, I'm hardly alive posting this reply right now! icon_heh.gif ) Your script also had a bit of trouble compiling, as it said that variable sfx was undeclared (in the unlock function you made, but I declared it myself, so no worries). But I'm sure you could fix up those problems relatively quickly!

... Heh, but I've done way too much work to just have the script I've been writing sit on my computer! ^^'

Your script did remind me about the Screen->D variables, which are saved with the game! icon_biggrin.gif So, I used my idea, coupled with your Screen->D variables, and expanded it (literally... probably a bit too much).

CODE
ffc script LockBlockNew{
    void run(int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4){

        while(true){

int block0 = ComboAt(this->X, this->Y);
int block1 = ComboAt(x1, y1);
int block2 = ComboAt(x2, y2);
int block3 = ComboAt(x3, y3);
int block4 = ComboAt(x4, y4);

if(this->X != 0 && this->Y != 0 && Link->Dir == 0 && Link->InputUp && Link->Action == 1 && Screen->ComboD[block0] == newblock && Game->Counter[CR_KEYS] >= 1 && Screen->D[0] == 0 && Link->X >= this->X - 8 && Link->X <= this->X + 8 && Link->Y == this->Y + 8){
Waitframes(10);
      Game->PlaySound(lbnsfx);
    Game->Counter[CR_KEYS] --;
    Screen->D[0] = 1;
}
else if(this->X != 0 && this->Y != 0 && Link->Dir == 1 && Link->InputDown && Link->Action == 1 && Screen->ComboD[block0] == newblock && Game->Counter[CR_KEYS] >= 1 && Screen->D[0] == 0 && Link->X >= this->X - 8 && Link->X <= this->X + 8 && Link->Y == this->Y - 16){
Waitframes(10);
      Game->PlaySound(lbnsfx);
    Game->Counter[CR_KEYS] --;
    Screen->D[0] = 1;
}
else if(this->X != 0 && this->Y != 0 && Link->Dir == 2 && Link->InputLeft && Link->Action == 1 && Screen->ComboD[block0] == newblock && Game->Counter[CR_KEYS] >= 1 && Screen->D[0] == 0 && Link->X == this->X + 16 && Link->Y <= this->Y + 2 && Link->Y >= this->Y - 2){
Waitframes(10);
      Game->PlaySound(lbnsfx);
    Game->Counter[CR_KEYS] --;
    Screen->D[0] = 1;
}
else if(this->X != 0 && this->Y != 0 && Link->Dir == 3 && Link->InputRight && Link->Action == 1 && Screen->ComboD[block0] == newblock && Game->Counter[CR_KEYS] >= 1 && Screen->D[0] == 0 && Link->X == this->X - 16 && Link->Y <= this->Y + 2 && Link->Y >= this->Y - 2){
Waitframes(10);
      Game->PlaySound(lbnsfx);
    Game->Counter[CR_KEYS] --;
    Screen->D[0] = 1;
}

else if(Screen->D[0] == 1){
    Screen->ComboD[block0] = floorcombo;
}
//==============================================================

if(x1 != 0 && y1 != 0 && Link->Dir == 0 && Link->InputUp && Link->Action == 1 && Screen->ComboD[block1] == newblock && Game->Counter[CR_KEYS] >= 1 && Screen->D[1] == 0 && Link->X >= x1 - 8 && Link->X <= x1 + 8 && Link->Y == y1 + 8){
Waitframes(10);
      Game->PlaySound(lbnsfx);
    Game->Counter[CR_KEYS] --;
    Screen->D[1] = 1;
}
else if(x1 != 0 && y1 != 0 && Link->Dir == 1 && Link->InputDown && Link->Action == 1 && Screen->ComboD[block1] == newblock && Game->Counter[CR_KEYS] >= 1 && Screen->D[1] == 0 && Link->X >= x1 - 8 && Link->X <= x1 + 8 && Link->Y == y1 - 16){
Waitframes(10);
      Game->PlaySound(lbnsfx);
    Game->Counter[CR_KEYS] --;
    Screen->D[1] = 1;
}
else if(x1 != 0 && y1 != 0 && Link->Dir == 2 && Link->InputLeft && Link->Action == 1 && Screen->ComboD[block1] == newblock && Game->Counter[CR_KEYS] >= 1 && Screen->D[1] == 0 && Link->X == x1 + 16 && Link->Y <= y1 + 2 && Link->Y >= y1 - 2){
Waitframes(10);
      Game->PlaySound(lbnsfx);
    Game->Counter[CR_KEYS] --;
    Screen->D[1] = 1;
}
else if(x1 != 0 && y1 != 0 && Link->Dir == 3 && Link->InputRight && Link->Action == 1 && Screen->ComboD[block1] == newblock && Game->Counter[CR_KEYS] >= 1 && Screen->D[1] == 0 && Link->X == x1 - 16 && Link->Y <= y1 + 2 && Link->Y >= y1 - 2){
Waitframes(10);
      Game->PlaySound(lbnsfx);
    Game->Counter[CR_KEYS] --;
    Screen->D[1] = 1;
}

else if(Screen->D[1] == 1){
    Screen->ComboD[block1] = floorcombo;
}
//==============================================================

if(x2 != 0 && y2 != 0 && Link->Dir == 0 && Link->InputUp && Link->Action == 1 && Screen->ComboD[block2] == newblock && Game->Counter[CR_KEYS] >= 1 && Screen->D[2] == 0 && Link->X >= x2 - 8 && Link->X <= x2 + 8 && Link->Y == y2 + 8){
Waitframes(10);
      Game->PlaySound(lbnsfx);
    Game->Counter[CR_KEYS] --;
    Screen->D[2] = 1;
}
else if(x2 != 0 && y2 != 0 && Link->Dir == 1 && Link->InputDown && Link->Action == 1 && Screen->ComboD[block2] == newblock && Game->Counter[CR_KEYS] >= 1 && Screen->D[2] == 0 && Link->X >= x2 - 8 && Link->X <= x2 + 8 && Link->Y == y2 - 16){
Waitframes(10);
      Game->PlaySound(lbnsfx);
    Game->Counter[CR_KEYS] --;
    Screen->D[2] = 1;
}
else if(x2 != 0 && y2 != 0 && Link->Dir == 2 && Link->InputLeft && Link->Action == 1 && Screen->ComboD[block2] == newblock && Game->Counter[CR_KEYS] >= 1 && Screen->D[2] == 0 && Link->X == x2 + 16 && Link->Y <= y2 + 2 && Link->Y >= y2 - 2){
Waitframes(10);
      Game->PlaySound(lbnsfx);
    Game->Counter[CR_KEYS] --;
    Screen->D[2] = 1;
}
else if(x2 != 0 && y2 != 0 && Link->Dir == 3 && Link->InputRight && Link->Action == 1 && Screen->ComboD[block2] == newblock && Game->Counter[CR_KEYS] >= 1 && Screen->D[2] == 0 && Link->X == x2 - 16 && Link->Y <= y2 + 2 && Link->Y >= y2 - 2){
Waitframes(10);
      Game->PlaySound(lbnsfx);
    Game->Counter[CR_KEYS] --;
    Screen->D[2] = 1;
}

else if(Screen->D[2] == 1){
    Screen->ComboD[block2] = floorcombo;
}
//==============================================================

if(x3 != 0 && y3 != 0 && Link->Dir == 0 && Link->InputUp && Link->Action == 1 && Screen->ComboD[block3] == newblock && Game->Counter[CR_KEYS] >= 1 && Screen->D[3] == 0 && Link->X >= x3 - 8 && Link->X <= x3 + 8 && Link->Y == y3 + 8){
Waitframes(10);
      Game->PlaySound(lbnsfx);
    Game->Counter[CR_KEYS] --;
    Screen->D[3] = 1;
}
else if(x3 != 0 && y3 != 0 && Link->Dir == 1 && Link->InputDown && Link->Action == 1 && Screen->ComboD[block3] == newblock && Game->Counter[CR_KEYS] >= 1 && Screen->D[3] == 0 && Link->X >= x3 - 8 && Link->X <= x3 + 8 && Link->Y == y3 - 16){
Waitframes(10);
      Game->PlaySound(lbnsfx);
    Game->Counter[CR_KEYS] --;
    Screen->D[3] = 1;
}
else if(x3 != 0 && y3 != 0 && Link->Dir == 2 && Link->InputLeft && Link->Action == 1 && Screen->ComboD[block3] == newblock && Game->Counter[CR_KEYS] >= 1 && Screen->D[3] == 0 && Link->X == x3 + 16 && Link->Y <= y3 + 2 && Link->Y >= y3 - 2){
Waitframes(10);
      Game->PlaySound(lbnsfx);
    Game->Counter[CR_KEYS] --;
    Screen->D[3] = 1;
}
else if(x3 != 0 && y3 != 0 && Link->Dir == 3 && Link->InputRight && Link->Action == 1 && Screen->ComboD[block3] == newblock && Game->Counter[CR_KEYS] >= 1 && Screen->D[3] == 0 && Link->X == x3 - 16 && Link->Y <= y3 + 2 && Link->Y >= y3 - 2){
Waitframes(10);
      Game->PlaySound(lbnsfx);
    Game->Counter[CR_KEYS] --;
    Screen->D[3] = 1;
}

else if(Screen->D[3] == 1){
    Screen->ComboD[block3] = floorcombo;
}
//==============================================================

if(x4 != 0 && y4 != 0 && Link->Dir == 0 && Link->InputUp && Link->Action == 1 && Screen->ComboD[block4] == newblock && Game->Counter[CR_KEYS] >= 1 && Screen->D[4] == 0 && Link->X >= x4 - 8 && Link->X <= x4 + 8 && Link->Y == y4 + 8){
Waitframes(10);
      Game->PlaySound(lbnsfx);
    Game->Counter[CR_KEYS] --;
    Screen->D[4] = 1;
}
else if(x4 != 0 && y4 != 0 && Link->Dir == 1 && Link->InputDown && Link->Action == 1 && Screen->ComboD[block4] == newblock && Game->Counter[CR_KEYS] >= 1 && Screen->D[4] == 0 && Link->X >= x4 - 8 && Link->X <= x4 + 8 && Link->Y == y4 - 16){
Waitframes(10);
      Game->PlaySound(lbnsfx);
    Game->Counter[CR_KEYS] --;
    Screen->D[4] = 1;
}
else if(x4 != 0 && y4 != 0 && Link->Dir == 2 && Link->InputLeft && Link->Action == 1 && Screen->ComboD[block4] == newblock && Game->Counter[CR_KEYS] >= 1 && Screen->D[4] == 0 && Link->X == x4 + 16 && Link->Y <= y4 + 2 && Link->Y >= y4 - 2){
Waitframes(10);
      Game->PlaySound(lbnsfx);
    Game->Counter[CR_KEYS] --;
    Screen->D[4] = 1;
}
else if(x4 != 0 && y4 != 0 && Link->Dir == 3 && Link->InputRight && Link->Action == 1 && Screen->ComboD[block4] == newblock && Game->Counter[CR_KEYS] >= 1 && Screen->D[4] == 0 && Link->X == x4 - 16 && Link->Y <= y4 + 2 && Link->Y >= y4 - 2){
Waitframes(10);
      Game->PlaySound(lbnsfx);
    Game->Counter[CR_KEYS] --;
    Screen->D[4] = 1;
}

else if(Screen->D[4] == 1){
    Screen->ComboD[block4] = floorcombo;
}

        Waitframe();
        }
    }
}


Now I know there has got to be a simpler way of writing that, but I couldn't think of any then, so I just left it the long way.

But, here's how you work it. (and it works correctly, as far as I can tell) You first place the FFC on any block you want to be your lockblock. Then you set the arguments.
D0 and D1 - the X and Y values for the second lock block.
D2 and D3 - the X and Y values for the third lock block.
D4 and D5 - the X and Y values for the fourth.
D6 and D7 - the X and Y values for the fifth.

And there you go! Now just assign the script and an invisible FFC, and you can potentially have five lockblocks on one screen, activated in any order you choose!

Oh, and Joe, don't feel like I was trying to 1-up your script or anything! I just wrote so much, I didn't want to discard it all! If you want to fix mine up (and I know it could use some fixing up), then feel free! I'd know I'd appreciate it, as well as all the other people who don't want to have to scroll through 200+ lines of code! icon_razz.gif

And thanks for the help!

Edited by AgentLym, 20 January 2010 - 10:31 PM.


#9 Theryan

Theryan

    Burrito

  • Members

Posted 20 January 2010 - 10:32 PM

You could just make the 2nd lockblock a copycat with its "open" combo being another lockblock. The only problems with this are that you have to open the lockblocks a certain order and that you can only have a max of two that way.

#10 AgentLym

AgentLym

    • Zelda and Pokémon Master •

  • Members
  • Location:Skyloft

Posted 20 January 2010 - 10:49 PM

@ Theryan
Yeah, I was thinking about that. But it wouldn't work with, say, a room with two locked doors, which would be fairly common if possible. icon_razz.gif But, that idea would work with a room with a 'path' of locked blocks, that led to an item or something. icon_wink.gif

=== • EDIT • ===

And, unrelatedly, I hope you don't mind, but... I took your idea of your name in your sig, with the fading colors and stuff! It was just so cool! ^^'

Edited by AgentLym, 20 January 2010 - 10:57 PM.


#11 Joe123

Joe123

    Retired

  • Members

Posted 21 January 2010 - 05:39 AM

QUOTE(AgentLym @ Jan 21 2010, 03:29 AM) View Post
...! Well, it's permanent! But, it places combo 0 where the lock block goes, and can only work on one at a time. (Like, you can unlock one, but not the other, and when you enter the screen again, both are unlocked). But, I honestly can't really follow your script. (I probably could if I really just sat down and looked, but I'm so tired of looking at my computer screen, I'm hardly alive posting this reply right now! icon_heh.gif ) Your script also had a bit of trouble compiling, as it said that variable sfx was undeclared (in the unlock function you made, but I declared it myself, so no worries). But I'm sure you could fix up those problems relatively quickly!
No you can have 8, you just have to set D0 to access a different Screen->D variable for each block. I didn't explain that, sorry. D1 is the amount of time to wait while Link pushes against the block before it opening, and D2 is the sound effect to play when it does open.
I fixed that sfx problem, the 'placing combo 1 when I meant to increment the combo' and the fact that it wasn't actually taking any keys away from Link, a slight oversight on my part there =P
It should work as it's mean to now.

QUOTE(AgentLym @ Jan 21 2010, 03:29 AM) View Post
Your script did remind me about the Screen->D variables, which are saved with the game! icon_biggrin.gif So, I used my idea, coupled with your Screen->D variables, and expanded it (literally... probably a bit too much).
Mm, they're a very good way of making things permanent.

QUOTE(AgentLym @ Jan 21 2010, 03:29 AM) View Post
Oh, and Joe, don't feel like I was trying to 1-up your script or anything! I just wrote so much, I didn't want to discard it all! If you want to fix mine up (and I know it could use some fixing up), then feel free! I'd know I'd appreciate it, as well as all the other people who don't want to have to scroll through 200+ lines of code! icon_razz.gif
Oh yeah sorry, don't feel like I was trying to one-up you either.
I wrote it again because your script didn't have any part which meant you had to push against the block for a certain number of frames before it opened, and because it was a bit convoluted. I used it as reference when I wrote mine though.

If you want to make your code tidier you need to put it inside a for loop, and allow access to different Screen->D variables rather than just the first 4. I'd advise you made it so that each script handles just one lock block, and then you can place more than one script per screen if you want more lock blocks. It'd make it a lot easier to use.

#12 Joe123

Joe123

    Retired

  • Members

Posted 21 January 2010 - 06:32 PM

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 =)

#13 AgentLym

AgentLym

    • Zelda and Pokémon Master •

  • Members
  • Location:Skyloft

Posted 21 January 2010 - 07:28 PM

Awesome!

... except it doesn't remove the lock block. ^^' lol

PS: And, by "18 different lock blocks per D register per screen", you mean... 18 x 8... 144 lock blocks per screen?! Or just 18 (because 18 is plenty).

=== • EDIT • ===

Ok, now it does. I just had to set 'perm' to 1. Um... what does perm do, exactly?

Well, more like, what does 'while((Screen->D[d] & (1<<perm)) == 0){' do? (I just don't understand the terminology, yet. icon_razz.gif )

Edited by AgentLym, 21 January 2010 - 07:39 PM.


#14 Joe123

Joe123

    Retired

  • Members

Posted 21 January 2010 - 07:36 PM

That's funny it works for me =S
Try this one, if you're using level keys rather than normal keys this one will work but that one won't.
Thinking about it, the most you could have is 32 'cause that's how many ffcs we have, but I doubt you'd need more than about 4 anyway.

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)]++;
    }
}


#15 AgentLym

AgentLym

    • Zelda and Pokémon Master •

  • Members
  • Location:Skyloft

Posted 21 January 2010 - 07:40 PM

QUOTE(AgentLym)
=== • EDIT • ===

Ok, now it does. I just had to set 'perm' to 1. Um... what does perm do, exactly?

Well, more like, what does 'while((Screen->D[d] & (1<<perm)) == 0){' do? (I just don't understand the terminology, yet. )

Heh, I update too not-often. icon_razz.gif


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users