PDA

View Full Version : Still having trouble



Beta Link
02-20-2008, 06:58 PM
Ok, I tried to edit this script:

ffc script gopongaswampplant{
void run(int cmb, int sfx){
if(cmb == 0){cmb = 1;}
if(sfx == 0){sfx = 1;}
int itm = 1;
Screen->ComboD[ComboAt(this->X,this->Y)] = cmb;
while(true){
if((Abs(this->X+8-Link->X) < 32) && (Abs(this->Y+8-Link->Y) < 32) && Link->Item[itm]){
Screen->ComboD[ComboAt(this->X, this->Y)] = cmb+1;
Game->PlaySound(sfx);
Quit();
}
Waitframe();
}
}
}

And the outcome was this:


ffc script gopongaswampplant{
void run(int cmb, int sfx, int iid, int mag){
if(cmb == 0){cmb = 1;}
if(sfx == 0){sfx = 1;}
int itm = iid;
int MP = mag;
Screen->ComboD[ComboAt(this->X,this->Y)] = cmb;
while(true){
if((Abs(this->X+8-Link->X) < 32) && (Abs(this->Y+8-Link->Y) < 32) && Link->Item[itm] && Link->InputR){
Link->MP{
Screen->ComboD[ComboAt(this->X, this->Y)] = cmb+1;
Game->PlaySound(sfx);
Quit();
}
Waitframe();
}
}
}
}

Now this is actually the second time I edited it. The problem I'm having now, is getting it to take away a certain amount of magic when the script is activated. I thought I put everything in correctly, but it still won't compile correctly. What am I doing wrong?

ScaryBinary
02-20-2008, 07:25 PM
The line containing
Link->MP{ doesn't make sense to the compiler. Think of Link->MP as a built-in variable...you have to set it to something or do something to it (like subtract a number). Something like

Link->MP = Link->MP - 1
would take away one magic point. You don't need the curly braces after Link->MP.

Also, since Link->MP is "built-in", you don't need to declare a seperate MP variable.

The following compiles, but tweak it a bit for the magic values. I set it up to subract the argument "mag".

ffc script gopongaswampplant{
void run(int cmb, int sfx, int iid, int mag){
if(cmb == 0){cmb = 1;}
if(sfx == 0){sfx = 1;}
int itm = iid;

Screen->ComboD[ComboAt(this->X,this->Y)] = cmb;
while(true){
if((Abs(this->X+8-Link->X) < 32) && (Abs(this->Y+8-Link->Y) < 32) && Link->Item[itm] && Link->InputR){
Link->MP = Link->MP - mag;
Screen->ComboD[ComboAt(this->X, this->Y)] = cmb+1;
Game->PlaySound(sfx);
Quit();
}
Waitframe();
}
}
}

Beta Link
02-20-2008, 07:38 PM
Oh, ok. I never would have thought it worked like that... Link's Magic Power is equal to Link's Magic Power minus x. At least I understand it. Thanks. :)

Joe123
02-20-2008, 08:44 PM
ffc script gopongaswampplant{
void run(int cmb, int sfx, int itm, int mag){
if(cmb == 0){cmb = 1;}
if(sfx == 0){sfx = 1;}

Screen->ComboD[ComboAt(this->X,this->Y)] = cmb;
while(true){
if((Abs(this->X+8-Link->X) < 32) && (Abs(this->Y+8-Link->Y) < 32) && Link->Item[itm] && Link->InputR){
Link->MP -= mag;
Screen->ComboD[ComboAt(this->X, this->Y)] = cmb+1;
Game->PlaySound(sfx);
Quit();
}
Waitframe();
}
}
}

There's no need for that 'iid' integer, you can just move the declartion of 'itm' into a D- slot.

There's also no need for all that 'x = x - 1' stuff either, you just put 'x -= 1', it's equivalent and easier.

Gleeok
02-20-2008, 09:46 PM
What if two instances of Link->MP = Link->MP-1; are running in different ffcs. Does it reduce his MP by 1 or 2? Does the change trigger at Waitframe(); of every script, or at the next frame of gameplay?

Sure, sure, easy to test yeah. But I want to reduce Link's MP a set amount no matter what. Especially if you have more than one way to reduce his MP in a singe frame of a single script. So I find Link->MP -= 2; is the way to go. Although I don't think it matters much. lol.

DarkDragon
02-21-2008, 12:13 AM
Scripts are executed one after the other. So if two scripts subtract 2 MP from Link during one frame, he'll lose 4 MP total.