PDA

View Full Version : Problem with giving an item....???



Nimono
11-04-2007, 03:49 PM
I'm having a problem with one of my scripts. I made a version of my Deep Water script that lets you drown in it if you don't have the Level 2 Flippers. It takes away the Flippers if you have them, then gives them back later. The only problem is, no matter how I try it, IT DOESN'T GIVE THEM BACK UNTIL YOU LEAVE AND RE-ENTER THE SCREEN! I can't figure out why. The flippers aren't taken away unless I use a while loop, though. Here's what I've got:


// Deep Water 2- When Link steps on a certain combo without a certain item in his inventory, he drowns. If he has the Level 1 Flippers, they are temporarily
// taken away from him so he will drown. If you want Lava, change the item to one you can never get.
// Constants/Variables:
// water1-water4- D0 through D3. Control what combos to make "Deep Water" combos.
// dive1-dive4- D4 through D7. Control what combos to make "Deep Water (Dive)" combos.
// level2flippers- What item ID will be used for the Level 2 Flippers. And please, remember to set the item in the Flippers Itemclass. It makes it better.
// warp1-warp4- Which Dive Warp the 4 "dive" variables will use. They don't even need to be Dive Warp. In case you want more than one Dive Warp per screen,
// or if you've used some other warps. Hey, better safe than sorry. I need to make sure of your ideas! :(

import "std.zh"

const int level2flippers = 255;
const int warp1 = 19;
const int warp2 = 19;
const int warp3 = 19;
const int warp4 = 19;
const int hold = 254;

ffc script deepwater2
{
void run(int water1, int water2, int water3, int water4, int dive1, int dive2, int dive3, int dive4)
{
while(true)
{
for (int cmbchk = 0; cmbchk < 176; cmbchk++)
{
if(Screen->ComboD[cmbchk] == water1 || Screen->ComboD[cmbchk] == water2 || Screen->ComboD[cmbchk] == water3 || Screen->ComboD[cmbchk] == water4)
{
Screen->ComboT[cmbchk] = 3;
if(!Link->Item[level2flippers])
{
int loc = ComboAt(Link->X, Link->Y);
if(Link->Item[51])
{
while(Screen->ComboD[loc] == water1 || Screen->ComboD[loc] == water2 || Screen->ComboD[loc] == water3 || Screen->ComboD[loc] == water4)
{
Link->Item[51] = false;
Link->Item[hold] = true;
Waitframe();
}
Link->Item[51] = true;
}
}
}
if(Screen->ComboD[cmbchk] == dive1)
{
Screen->ComboT[cmbchk] = warp1;
if(!Link->Item[level2flippers])
{
int loc = ComboAt(Link->X, Link->Y);
if(Link->Item[51])
{
while(Screen->ComboD[loc] == dive1)
{
Link->Item[51] = false;
Link->Item[hold] = true;
Waitframe();
}
Link->Item[51] = true;
}
}
}
if(Screen->ComboD[cmbchk] == dive2)
{
Screen->ComboT[cmbchk] = warp2;
if(!Link->Item[level2flippers])
{
int loc = ComboAt(Link->X, Link->Y);
if(Link->Item[51])
{
while(Screen->ComboD[loc] == dive2)
{
Link->Item[51] = false;
Link->Item[hold] = true;
Waitframe();
}
Link->Item[51] = true;
}
}
}
if(Screen->ComboD[cmbchk] == dive3)
{
Screen->ComboT[cmbchk] = warp3;
if(!Link->Item[level2flippers])
{
int loc = ComboAt(Link->X, Link->Y);
if(Link->Item[51])
{
while(Screen->ComboD[loc] == dive3)
{
Link->Item[51] = false;
Link->Item[hold] = true;
Waitframe();
}
Link->Item[51] = true;
}
}
}
if(Screen->ComboD[cmbchk] == dive4)
{
Screen->ComboT[cmbchk] = warp4;
if(!Link->Item[level2flippers])
{
int loc = ComboAt(Link->X, Link->Y);
if(Link->Item[51])
{
while(Screen->ComboD[loc] == dive4)
{
Link->Item[51] = false;
Link->Item[hold] = true;
Waitframe();
}
Link->Item[51] = true;
}
}
}
}
if(Link->Item[hold])
{
Link->Item[51] = true;
}
Waitframe();
}
}
}

Yes, I know I put the "Link->Item[51] = true;" a lot in the script. But that was in hopes that it'd help. But it doesn't. I can't figure out what's going on. It should be constantly looping, and thus, it'd HAVE to give the item again! I'm not gonna have it create the Flippers item and give that to you, since that'd play a sound effect, and I don't want that at all. Sooo..... Help, plz?

Edit: Nevermind, problem solved. Apparently, I needed to use Waitframes() so he wouldn't get it back instantly.