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);
}
}