PDA

View Full Version : Bridge Extendor



Mega Link
01-01-2008, 05:15 PM
An item script that will place a bridge combo on flag 98 when Link uses it.

Joe123
01-01-2008, 05:24 PM
Can't you use the stepladder?

Mega Link
01-01-2008, 05:25 PM
That can only cross 1 combo.

Edit: This is what I want it to do.

Before:
http://i210.photobucket.com/albums/bb155/Mega_Link/zelda005-1.jpg

After:
http://i210.photobucket.com/albums/bb155/Mega_Link/zelda006-1.jpg

pkmnfrk
01-01-2008, 05:39 PM
//Places tiles down when item is used.

const int bridge_combo = 0; //change this to the bridge combo

const int bridge_flag = 98; //change this to the indicative flag

item script bridgeextender {
void run() {
int i;
bool found;
found = false;
for(i = 0; i < 176; i++) {
if(Screen->ComboF[i] == bridge_flag) {
Screen->ComboD[i] = bridge_combo;
Screen->ComboF[i] = 0;
found = true;
} else if (Screen->ComboI[i] == bridge_flag) {
Screen->ComboD[i] = bridge_combo;
// I think the inherent flag will change automatically?
found = true;
}
}
if (found) Game->PlaySound(SFX_SECRET);
}
}

Russ
01-01-2008, 05:55 PM
This is a pretty neat script. I could probably find a few uses for this. And by the way:


Post 800!!!

Mega Link
01-01-2008, 06:02 PM
I can't get to appear in the subscreen!

Edit: I have a question about the script. What does for(i = 0; i < 176; i++) do?

Joe123
01-01-2008, 07:42 PM
Wow.
Just wow.

Checking the screen for a flag. I really, really wanted to be able to do that, but I never worked out how.
That's probably one of the most useful applications I can imagine of 'for', and about the only reason I can think of for having the Screen->Combo[] commands read across the rows, instead of just having coordinates as default.

Make sure you have given it it's own itemclass, 'Custom Itemclass 1' is probably good, and make sure the current item on your subscreen has that itemclass also.

For is like a temporary while.

for(i = 0; i < 176; i++){}
reads:
'i is set to 0. For i to be equal to 176, i increases by one each time the code within the brackets is completed'
EDIT: I wanted to write the explanation using the word for, but it just made it a bit convoluted:
'while i is less than 176, keep looping this part of code. i starts at 0, and is increased by one each time the code completes'


So,

for(i = 0;
Here you set the starting value of the integer you're using for the loop

i < 176;
The code loops while i is less than 176

i ++){}
And i increases each time the chunk of script completes

beefster09
01-01-2008, 11:06 PM
Aww.. pkmnfrk beat me to it.

Here, now it uses parameters- use in latest beta:

//Places tiles down when item is used.

//D0- bridge combo number
//D1- flag number
//D2- Secret SFX
//D3- "No Secret" SFX

item script BridgeExtender {
void run(int bridge_combo, int bridge_flag, int sSFX, int fSFX) {
int i;
bool found;
found = false;
for(i = 0; i < 176; i++) {
if(Screen->ComboF[i] == bridge_flag) {
Screen->ComboD[i] = bridge_combo;
Screen->ComboF[i] = 0;
found = true;
} else if (Screen->ComboI[i] == bridge_flag) {
Screen->ComboD[i] = bridge_combo;
// I think the inherent flag will change automatically?
found = true;
}
}
if (found){ Game->PlaySound(sSFX); }else{ Game->PlaySound(fSFX);}
}
}

pkmnfrk
01-02-2008, 06:10 AM
I didn't use parameters since I thought it was simpler without them. "Just drop it in and roll" sorta thing. But, I can forsee multiple uses, so that's cool.

As for where the magic number "176" came from, here's a hint: 176 = 16 x 11

Joe123
01-02-2008, 06:57 AM
item script BridgeExtender {
void run(int bridge_combo, int bridge_flag, int sSFX, int fSFX) {
int i;
bool found;
found = false;
for(i = 0; i < 176; i++) {
if(Screen->ComboF[i] == bridge_flag || Screen->ComboI[i] == bridge_flag) {
Screen->ComboD[i] = bridge_combo;
Screen->ComboF[i] = 0; Screen->ComboI[i] = 0;
found = true;
}
if (found){ Game->PlaySound(sSFX); }else{ Game->PlaySound(fSFX);}
}
}

Couldn't you just have that?
Saves on code

pkmnfrk
01-02-2008, 08:23 AM
Well, I did it my way for three reasons:

1. The code is not much smaller compiled if you combine them, and,
2. I don't want to blindly reset the regular flag if it's triggered by the inherent flag, and,
3. Vice-versa for the inherent flag (which changes automatically, AFAIK).

My code is a little bit more "correct", so to speak, since it handles inherent flags properly, but the two snippets are effectively the same.

Joe123
01-02-2008, 08:35 AM
2. I don't want to blindly reset the regular flag if it's triggered by the inherent flag, and,
3. Vice-versa for the inherent flag (which changes automatically, AFAIK).


Ah, I didn't think of that.

Russ
01-02-2008, 01:47 PM
Is there a way to link this script with a freeform combo script, so that the combo that is created can be changed on a screen by screen basis? E.g. on one screen the item creates a bridge, on another it creates land where lava was, etc.

C-Dawg
01-02-2008, 04:07 PM
This is great. Simple script with powerful game mechanic applications.

I like the idea of making this script a consumable item that the player needs to collect and use. Just like keys in dungeons. Makes shops more important in the game, and gives you more things to stash away. Don't have to use game counters to keep track of the number of items left. Just use the item flags that potions use to let the player collect more and decrement when used.

Sort of off topic; some other simple scripts you could use to add flavorful utility items would include:
(1) Warp consumables that take the player to the last town visited;
(2) Weapon consumables - scripted weapons on consumable items (like bombs);
(3) Perhaps miniature versions of full items that are consumable, used until the player finds the real item - a rope that acts as a very short hookshot?
(4) Various potions - with short-term effects on the player. Like a power potion that adds a scripted weapon to the player's attack, a speed potion that increases walking speed, defense potion that surrounds player with block-all combos, etc.

beefster09
01-02-2008, 08:57 PM
Is there a way to link this script with a freeform combo script, so that the combo that is created can be changed on a screen by screen basis? E.g. on one screen the item creates a bridge, on another it creates land where lava was, etc.I was going to, but then I realized it can be done very easily with secret combos. We don't need scripts to replace already existing features.

Oh, wait, now I know what you mean- so each bridge is different for each screen which the item can be used on.


ffc script BridgeExtender {
void run(int bridge_combo, int bridge_flag, intSFX) {
bool found = false;
while((this->X-8 > Link->X) || (this->X+8 < Link->X) || (this->Y-15 > Link->Y) || (this->Y < Link->Y)) {
for(int i = 0; i < 176; i++) {
if(Screen->ComboF[i] == bridge_flag) {
Screen->ComboD[i] = bridge_combo;
Screen->ComboF[i] = 0;
found = true;
} else if (Screen->ComboI[i] == bridge_flag) {
Screen->ComboD[i] = bridge_combo;
// I think the inherent flag will change automatically?
found = true;
}
}
}
if (found) {
Game->PlaySound(SFX);
Screen->TriggerSecrets(); //<-I'm pretty sure that's not right. I couldn't find the proper notation in the ZScript documentation.
}
}
}

Joe123
01-02-2008, 09:10 PM
You can't just trigger secrets like that I'm afraid Beefster, you have to put trigger combos under Link's feet and all sorts of such nonsense, it's really rather round-about and not particularily simple.

What's so bad about the whistle, anyway?

The_Amaster
01-02-2008, 09:27 PM
Can't you just set it as a standard FFC that triggers off of an item activation?
And, looking into the future and reading Joe's post (oooh, spooky) can it be written using arguments like Beefster's so that the bridge combo can vary from screen to screen?

Joe123
01-02-2008, 09:36 PM
Why yes, yes you can.

bool bridge = false;

ffc script BridgeExtender {
void run(int bridge_combo, int bridge_flag, int sSFX, int fSFX) {
int i;
bool found = false;
while(!bridge){
Waitframe();
}
bridge = false;
for(i = 0; i < 176; i++) {
if(Screen->ComboF[i] == bridge_flag) {
Screen->ComboD[i] = bridge_combo;
Screen->ComboF[i] = 0;
found = true;
} else if (Screen->ComboI[i] == bridge_flag) {
Screen->ComboD[i] = bridge_combo;
// I think the inherent flag will change automatically?
found = true;
}
}
if (found){ Game->PlaySound(sSFX); }else{ Game->PlaySound(fSFX);}
}
}

item script brigeextender{
void run();
bridge = true;
}
}

EDIT: Damn you edited your post!
Edit it back it was fine! =P

pkmnfrk
01-03-2008, 05:56 AM
As an aside, a feature we need to bug the devs about is being able to set Screen->D[] in ZQuest. That way, this script would be trivial and generic and stuff:


//Places tiles down when item is used.

const int bridge_flag = 98; //change this to the indicative flag

item script bridgeextender {
void run() {
int i;
bool found;
found = false;
for(i = 0; i < 176; i++) {
if(Screen->ComboF[i] == bridge_flag) {
Screen->ComboD[i] = Screen->D[0];
Screen->ComboF[i] = 0;
found = true;
} else if (Screen->ComboI[i] == bridge_flag) {
Screen->ComboD[i] = Screen->D[0];
// I think the inherent flag will change automatically?
found = true;
}
}
if (found) Game->PlaySound(SFX_SECRET);
}
}

If you want to have this functionality, put down an FFC on the screen with this script:


//sets Screen->D[whatever] to something

ffc script setScreenD {
void run(int d, int v) {
Screen->D[d] = v;
}
}

Set D0 to 0, and D1 to the bridge combo. Then, place it on the bridge screen, and use my item script as above, and you can have any bridge combo you want on any screen.

Edit: I've added these script to my website (http://zctut.com).