Only one lockblock??
#31
Posted 22 January 2010 - 04:15 PM
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
Posted 22 January 2010 - 04:26 PM
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
Posted 22 January 2010 - 05:55 PM
#34
Posted 22 January 2010 - 06:51 PM
#35
Posted 22 January 2010 - 08:01 PM
Or is the bit value a totally separate component to every decimal value in ZC?
#36
Posted 22 January 2010 - 08:06 PM
I'm dedicating that Screen->D[] register entirely to my bit string.
#37
Posted 02 February 2010 - 03:16 PM
Ok, it is completed!
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
Posted 02 February 2010 - 03:37 PM
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.
I hope that helps!
Edited by AgentLym, 02 February 2010 - 03:40 PM.
#39
Posted 02 February 2010 - 04:48 PM
Edited by cosmofield, 02 February 2010 - 04:49 PM.
#40
Posted 02 February 2010 - 04:58 PM
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
Posted 02 February 2010 - 05:08 PM
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.
#42
Posted 02 February 2010 - 05:44 PM
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.
Also, use this code instead:
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
Posted 02 February 2010 - 06:13 PM
Btw, Dmap-specific keys is neccesary for that level (otherwise it would be possible to cheat)
Good explanation. Thanks again ^_^
#44
Posted 02 February 2010 - 06:17 PM
Yep, I thought that might be the problem; sorry I didn't point it out earlier!
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. )
Edited by AgentLym, 02 February 2010 - 06:20 PM.
#45
Posted 02 February 2010 - 06:41 PM
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users