Re: Lttp style 'pickup rock' script
I see a bug in his script. Find this line:
Code:
if (can_lift(xx,yy) == 3) {this_dam = dam_3;)
and replace it with this one:
Code:
if (can_lift(xx,yy) == 3) {this_dam = dam_3;}
(the brace at the end wasn't curly)
You need to re-import it to re-compile it.
Re: Lttp style 'pickup rock' script
Now it says:
line 117: syntax error, unexpected RBrace
expecting $ end, on token }
Is this script working or not?
Re: Lttp style 'pickup rock' script
I don't know, I didn't write it, nor have I tried to use it.
I just tried to, though, and it's severely broken. It's missing a whole function! So, I'll say no.
Tips to ShadowMancer:
- Pick one style of indenting and braces, and use it.
- Try to compile your own scripts before posting them
Re: Lttp style 'pickup rock' script
thanks for trying, I was hoping ShadowMancer would view this and fix it
I never expected anyone else to step in to try. I know nothing of code, so
I tried fixing a few things, but my problem is in the end and I have copied
all the code right down to the last } as well as added the "import std.zh",
and still get errors. I did all this first before posting, which is why I got stumped.
so hopefully Shadow will respond, as there is no other way to make contact
with him.
Re: Lttp style 'pickup rock' script
I haven't seen him around for ages :(
You could try PM'ing him, if he has the 'get email about PM' thing on, he might notice it.
Shame really, he used to help out a lot around here.
Re: Lttp style 'pickup rock' script
In case anyone wants to pick it up in his absence, here's the script, as cleaned up by me:
Code:
import "std.zh"
ffc script liftRock{
void run(int under, int dam_1, int dam_2, int dam_3) {
int xx = 0;
int yy = 0;
int this_dam = 0;
bool is_hit = false;
bool is_hold = false;
while (true) {
is_hit = false;
if (Link->Dir == 0) {
xx = Link->X;
yy = Link->Y-8;
}
if (Link->Dir == 1) {
xx = Link->X;
yy = Link->Y+16;
}
if (Link->Dir == 2) {
xx = Link->X-16;
yy = Link->Y;
}
if (Link->Dir == 3) {
xx = Link->X+16;
yy = Link->Y;
}
if (Link->InputR && can_lift(xx,yy) > 0 && is_hold == false) {
//Main Action Loop
if (can_lift(xx,yy) == 1) {this_dam = dam_1;}
if (can_lift(xx,yy) == 2) {this_dam = dam_2;}
if (can_lift(xx,yy) == 3) {this_dam = dam_3;}
//assumes the shape of the rock
this->Data = Screen->ComboD[ComboAt(xx,yy)] + 20;
this->CSet = Screen->ComboC[ComboAt(xx,yy)];
//Changes Rock to undercombo
Screen->ComboD[ComboAt(xx,yy)] = under;
//moves ffc to position of rock
this->X = xx;
this->Y = yy;
//Sets flag to tell Link is holding rock
is_hold = true;
while(Link->InputR) { Waitframe(); }
}
if (is_hold == true) {
//moves rock to above Link's head
this->X = Link->X;
this->Y = Link->Y-12;
}
if (Link->InputR && is_hold == true) {
//Throwing routine
is_hold = false;
if (Link->Dir == 0) {
while (is_hit == false)
{
this->Y-=12;
if (ene_damage(this_dam,this->X,this->Y) == true) { is_hit = true; }
Waitframe();
}
this->Data = 0;
this->X = 0;
this->Y = 0;
}
if (Link->Dir == 1) {
while (is_hit == false) {
this->Y+=12;
if (ene_damage(this_dam,this->X,this->Y) == true) { is_hit = true; }
Waitframe();
}
this->Data = 0;
this->X = 0;
this->Y = 0;
}
if (Link->Dir == 2) {
while (is_hit == false) {
this->X-=12;
if (ene_damage(this_dam,this->X,this->Y) == true) { is_hit = true; }
Waitframe();
}
this->Data = 0;
this->X = 0;
this->Y = 0;
}
if (Link->Dir == 3) {
while (is_hit == false) {
this->X+=12;
if (ene_damage(this_dam,this->X,this->Y) == true) { is_hit = true; }
Waitframe();
}
this->Data = 0;
this->X = 0;
this->Y = 0;
}
}
Waitframe();
}
}
}
int can_lift(int xn, int yn) {
int result = 0;
if(xn<0 || xn>240 || yn<0 || yn>160){
return 0;
}
if (Link->Item[107] && Screen->ComboD[ComboAt(xn,yn)] >= 6400 && Screen->ComboD[ComboAt(xn,yn)] <= 6419) { result = 1;}
if (Link->Item[19] && Screen->ComboD[ComboAt(xn,yn)] >= 6440 && Screen->ComboD[ComboAt(xn,yn)] <= 6459) { result = 2 ;}
if (Link->Item[56] && Screen->ComboD[ComboAt(xn,yn)] >= 6480 && Screen->ComboD[ComboAt(xn,yn)] <= 6499) { result = 3;}
return result;
}
bool ene_damage(int damage,int xn, int yn) {
int ene_chk = 1;
bool result = false;
if (xn<0 || xn>240 || yn<0 || yn>160) result = true;
while (ene_chk <= Screen->NumNPCs()) {
npc trg_ene = Screen->LoadNPC(ene_chk);
if (trg_ene->X+8 >= xn-8 && trg_ene->X+8 <= xn+24 && trg_ene->Y+8 >= yn-8 && trg_ene->Y+8 <= yn+24) {
//Enemy is Hit
result = true;
int timer = 10;
trg_ene->HP -= damage;
while(timer > 0) {
//Flash CSet
int def_cset = trg_ene->CSet;
if (trg_ene->CSet == def_cset) {
trg_ene->CSet = 5;}
else {
trg_ene->CSet = def_cset;}
//Push enemy back
//0,1,2,3, - Up,Dn,Lt,Rt
if (trg_ene->Dir == 0) {
if (is_walkable(trg_ene->X,trg_ene->Y+4)) trg_ene->Y+=4;
}
if (trg_ene->Dir == 1) {
if (is_walkable(trg_ene->X,trg_ene->Y-4)) trg_ene->Y-=4;
}
if (trg_ene->Dir == 2) {
if (is_walkable(trg_ene->X+4,trg_ene->Y)) trg_ene->X+=4;
}
if (trg_ene->Dir == 3) {
if (is_walkable(trg_ene->X-4,trg_ene->Y)) trg_ene->X-=4;
}
timer -= 1;
}
}
ene_chk += 1;
Waitframe();
}
return result;
}
Re: Lttp style 'pickup rock' script
It gives me this:
pass 1 : parsing
pass 2 : preprocessing
pass 3 : building symbol tables
TMP , line140 : error S10 : Function is_walkable is undeclared
TMP , line143 : error S10 : Function is_walkable is undeclared
TMP , line146 : error S10 : Function is_walkable is undeclared
TMP , line149 : error S10 : Function is_walkable is undeclared
Re: Lttp style 'pickup rock' script
Right, as I previously discussed, the script is broken. If I knew exactly what "is_walkable" does, then I could probably fix it. For all I know, it could add health to Link, since it can be named anything >_>
Yes, yes, I know that it probable checks to see if that spot is solid or not. Fine, here you go. I added "is_walkable", based on the "isSolid" function found in my Ladder script:
Code:
import "std.zh"
ffc script liftRock{
void run(int under, int dam_1, int dam_2, int dam_3) {
int xx = 0;
int yy = 0;
int this_dam = 0;
bool is_hit = false;
bool is_hold = false;
while (true) {
is_hit = false;
if (Link->Dir == 0) {
xx = Link->X;
yy = Link->Y-8;
}
if (Link->Dir == 1) {
xx = Link->X;
yy = Link->Y+16;
}
if (Link->Dir == 2) {
xx = Link->X-16;
yy = Link->Y;
}
if (Link->Dir == 3) {
xx = Link->X+16;
yy = Link->Y;
}
if (Link->InputR && can_lift(xx,yy) > 0 && is_hold == false) {
//Main Action Loop
if (can_lift(xx,yy) == 1) {this_dam = dam_1;}
if (can_lift(xx,yy) == 2) {this_dam = dam_2;}
if (can_lift(xx,yy) == 3) {this_dam = dam_3;}
//assumes the shape of the rock
this->Data = Screen->ComboD[ComboAt(xx,yy)] + 20;
this->CSet = Screen->ComboC[ComboAt(xx,yy)];
//Changes Rock to undercombo
Screen->ComboD[ComboAt(xx,yy)] = under;
//moves ffc to position of rock
this->X = xx;
this->Y = yy;
//Sets flag to tell Link is holding rock
is_hold = true;
while(Link->InputR) { Waitframe(); }
}
if (is_hold == true) {
//moves rock to above Link's head
this->X = Link->X;
this->Y = Link->Y-12;
}
if (Link->InputR && is_hold == true) {
//Throwing routine
is_hold = false;
if (Link->Dir == 0) {
while (is_hit == false)
{
this->Y-=12;
if (ene_damage(this_dam,this->X,this->Y) == true) { is_hit = true; }
Waitframe();
}
this->Data = 0;
this->X = 0;
this->Y = 0;
}
if (Link->Dir == 1) {
while (is_hit == false) {
this->Y+=12;
if (ene_damage(this_dam,this->X,this->Y) == true) { is_hit = true; }
Waitframe();
}
this->Data = 0;
this->X = 0;
this->Y = 0;
}
if (Link->Dir == 2) {
while (is_hit == false) {
this->X-=12;
if (ene_damage(this_dam,this->X,this->Y) == true) { is_hit = true; }
Waitframe();
}
this->Data = 0;
this->X = 0;
this->Y = 0;
}
if (Link->Dir == 3) {
while (is_hit == false) {
this->X+=12;
if (ene_damage(this_dam,this->X,this->Y) == true) { is_hit = true; }
Waitframe();
}
this->Data = 0;
this->X = 0;
this->Y = 0;
}
}
Waitframe();
}
}
int can_lift(int xn, int yn) {
int result = 0;
if(xn<0 || xn>240 || yn<0 || yn>160){
return 0;
}
if (Link->Item[107] && Screen->ComboD[ComboAt(xn,yn)] >= 6400 && Screen->ComboD[ComboAt(xn,yn)] <= 6419) { result = 1;}
if (Link->Item[19] && Screen->ComboD[ComboAt(xn,yn)] >= 6440 && Screen->ComboD[ComboAt(xn,yn)] <= 6459) { result = 2 ;}
if (Link->Item[56] && Screen->ComboD[ComboAt(xn,yn)] >= 6480 && Screen->ComboD[ComboAt(xn,yn)] <= 6499) { result = 3;}
return result;
}
bool ene_damage(int damage,int xn, int yn) {
int ene_chk = 1;
bool result = false;
if (xn<0 || xn>240 || yn<0 || yn>160) result = true;
while (ene_chk <= Screen->NumNPCs()) {
npc trg_ene = Screen->LoadNPC(ene_chk);
if (trg_ene->X+8 >= xn-8 && trg_ene->X+8 <= xn+24 && trg_ene->Y+8 >= yn-8 && trg_ene->Y+8 <= yn+24) {
//Enemy is Hit
result = true;
int timer = 10;
trg_ene->HP -= damage;
while(timer > 0) {
//Flash CSet
int def_cset = trg_ene->CSet;
if (trg_ene->CSet == def_cset) {
trg_ene->CSet = 5;}
else {
trg_ene->CSet = def_cset;}
//Push enemy back
//0,1,2,3, - Up,Dn,Lt,Rt
if (trg_ene->Dir == 0) {
if (is_walkable(trg_ene->X,trg_ene->Y+4)) trg_ene->Y+=4;
}
if (trg_ene->Dir == 1) {
if (is_walkable(trg_ene->X,trg_ene->Y-4)) trg_ene->Y-=4;
}
if (trg_ene->Dir == 2) {
if (is_walkable(trg_ene->X+4,trg_ene->Y)) trg_ene->X+=4;
}
if (trg_ene->Dir == 3) {
if (is_walkable(trg_ene->X-4,trg_ene->Y)) trg_ene->X-=4;
}
timer -= 1;
}
}
ene_chk += 1;
Waitframe();
}
return result;
}
bool is_walkable(int x, int y) {
if(x<0 || x>255 || y<0 || y>175) return false;
int mask=1111b;
if(x % 16 < 8)
mask &= 0011b;
else
mask &= 1100b;
if(y % 16 < 8)
mask &= 0101b;
else
mask &= 1010b;
int ret = Screen->ComboS[ComboAt(x, y)] & mask;
return (ret==0);
}
}
Re: Lttp style 'pickup rock' script
Yup, it works. Nice work! :)
Can't wait to try it. :)
Re: Lttp style 'pickup rock' script
I must point out that I have not actually tried it, and have no idea if it actually does what i promises, etc etc. No refunds, as is, caveat scriptor, etc.