Jump to content

Photo

AtFrontX, At Front Y


  • Please log in to reply
8 replies to this topic

#1 idontknow8

idontknow8

    Senior

  • Members

Posted 02 June 2017 - 01:07 AM

I'm using these two functions plus "IsSolid" to check that combos in front of Link are NOT solid.  It works for 3 out of the 4 directions Link is facing - every one EXCEPT for facing left.  I have a FFC script that only activates if Link is facing a combo that is not solid.  When standing next to and facing left towards a solid combo, this script activates anyways.  Is AtfrontX buggy or something?/Does it only work for 3 out of the four directions???



#2 Gleeok

Gleeok

    It's dangerous to dough alone, bake this.

  • Members
  • Real Name:Pillsbury
  • Location:Magical Land of Dough

Posted 02 June 2017 - 04:49 AM

Can you post the script? I don't think AtFront is wrong since people use it without problems.

#3 Timelord

Timelord

    The Timelord

  • Banned
  • Location:Prydon Academy

Posted 02 June 2017 - 04:58 AM

I'm using these two functions plus "IsSolid" to check that combos in front of Link are NOT solid.  It works for 3 out of the 4 directions Link is facing - every one EXCEPT for facing left.  I have a FFC script that only activates if Link is facing a combo that is not solid.  When standing next to and facing left towards a solid combo, this script activates anyways.  Is AtfrontX buggy or something?/Does it only work for 3 out of the four directions???

 
AtFrontX and AtFrontY are usually used to place weapons in the correct place and orientation for weapons based on the sprites holding them.
 
You might try this, instead:
 
 

//Returns true if Link is facing a solid, on-screen combo. 
bool IsLinkFacingSolid(){
	int a; int dir = Link->Dir; int cmb = ComboAt(Link->X, Link->Y); 
	int combooffsets[13]={-0x10, 0x10, -1, 1, -0x11, -0x0F, 0x0F, 0x11};
	if ( cmb % 16 == 0 ) combooffsets[9] = 1;
	if ( (cmb & 15) == 1 ) combooffsets[10] = 1; 
	if ( cmb < 0x10 ) combooffsets[11] = 1; //if it's the top row
	if ( cmb > 0x9F ) combooffsets[12] = 1; //if it's on the bottom row
	if ( combooffsets[9] && ( dir == CMB_LEFT || dir == CMB_UPLEFT || dir == CMB_DOWNLEFT || dir == CMB_LEFTUP ) ) return false; //if the left columb
	if ( combooffsets[10] && ( dir == CMB_RIGHT || dir == CMB_UPRIGHT || dir == CMB_DOWNRIGHT ) ) return false; //if the right column
	if ( combooffsets[11] && ( dir == CMB_UP || dir == CMB_UPRIGHT || dir == CMB_UPLEFT || dir == CMB_LEFTUP ) ) return false; //if the top row
	if ( combooffsets[12] && ( dir == CMB_DOWN || dir == CMB_DOWNRIGHT || dir == CMB_DOWNLEFT ) ) return false; //if the bottom row
	if ( cmb >= 0 && cmb <= 176 ) a = cmb + combooffsets[dir];
	else a = -1;
	if ( a != -1 ) {
		return ( Screen->isSolid(ComboX(a), ComboY(a)));
	}
	return false;
}

//Returns true if Link is facing a solid, on-screen combo, but allows specifying a default return. 
bool IsLinkFacingSolid(bool default_return){
	int a; int dir = Link->Dir; int cmb = ComboAt(Link->X, Link->Y); 
	int combooffsets[13]={-0x10, 0x10, -1, 1, -0x11, -0x0F, 0x0F, 0x11};
	if ( cmb % 16 == 0 ) combooffsets[9] = 1;
	if ( (cmb & 15) == 1 ) combooffsets[10] = 1; 
	if ( cmb < 0x10 ) combooffsets[11] = 1; //if it's the top row
	if ( cmb > 0x9F ) combooffsets[12] = 1; //if it's on the bottom row
	if ( combooffsets[9] && ( dir == CMB_LEFT || dir == CMB_UPLEFT || dir == CMB_DOWNLEFT || dir == CMB_LEFTUP ) ) return default_return; //if the left columb
	if ( combooffsets[10] && ( dir == CMB_RIGHT || dir == CMB_UPRIGHT || dir == CMB_DOWNRIGHT ) ) return default_return; //if the right column
	if ( combooffsets[11] && ( dir == CMB_UP || dir == CMB_UPRIGHT || dir == CMB_UPLEFT || dir == CMB_LEFTUP ) ) return default_return; //if the top row
	if ( combooffsets[12] && ( dir == CMB_DOWN || dir == CMB_DOWNRIGHT || dir == CMB_DOWNLEFT ) ) return default_return; //if the bottom row
	if ( cmb >= 0 && cmb <= 176 ) a = cmb + combooffsets[dir];
	else a = -1;
	if ( a != -1 ) {
		return ( Screen->isSolid(ComboX(a), ComboY(a)) );
	}
	return default_return;
}

 
If you need off-screen combos to always read as solid, use IsLinkFacingSolid(true); if you want the default behaviour for Screen->isSolid() for off-screen locations, use IsLinkFacingSolid() or IsLinkFacingSolid(false).

 

This function should be fully automated to do what you want, and is copied from IsFacingSolid() from the revised std.zh.


Edited by ZoriaRPG, 02 June 2017 - 05:05 AM.


#4 idontknow8

idontknow8

    Senior

  • Members

Posted 02 June 2017 - 08:37 AM

Getting error:

Unexpected LParen, Expecting Assign, On Token (

for this line:  

bool IsLinkFacingSolid(){


Edited by idontknow8, 02 June 2017 - 08:37 AM.


#5 Gleeok

Gleeok

    It's dangerous to dough alone, bake this.

  • Members
  • Real Name:Pillsbury
  • Location:Magical Land of Dough

Posted 02 June 2017 - 07:39 PM

Oh right, I was thinking of InFrontX(), InFrontY(), which might be what you wanted to use... Sorry.

#6 Timelord

Timelord

    The Timelord

  • Banned
  • Location:Prydon Academy

Posted 03 June 2017 - 06:50 AM

Getting error:
Unexpected LParen, Expecting Assign, On Token (
for this line:  
bool IsLinkFacingSolid(){


Where did you put them in your script file?

They should be either at the file scope, or inside the scrito scope and outside of the run() function.

import "std.zh"

//File scope

//Returns true if Link is facing a solid, on-screen combo. 
bool IsLinkFacingSolid(){
	int a; int dir = Link->Dir; int cmb = ComboAt(Link->X, Link->Y); 
	int combooffsets[13]={-0x10, 0x10, -1, 1, -0x11, -0x0F, 0x0F, 0x11};
	if ( cmb % 16 == 0 ) combooffsets[9] = 1;
	if ( (cmb & 15) == 1 ) combooffsets[10] = 1; 
	if ( cmb < 0x10 ) combooffsets[11] = 1; //if it's the top row
	if ( cmb > 0x9F ) combooffsets[12] = 1; //if it's on the bottom row
	if ( combooffsets[9] && ( dir == CMB_LEFT || dir == CMB_UPLEFT || dir == CMB_DOWNLEFT || dir == CMB_LEFTUP ) ) return false; //if the left columb
	if ( combooffsets[10] && ( dir == CMB_RIGHT || dir == CMB_UPRIGHT || dir == CMB_DOWNRIGHT ) ) return false; //if the right column
	if ( combooffsets[11] && ( dir == CMB_UP || dir == CMB_UPRIGHT || dir == CMB_UPLEFT || dir == CMB_LEFTUP ) ) return false; //if the top row
	if ( combooffsets[12] && ( dir == CMB_DOWN || dir == CMB_DOWNRIGHT || dir == CMB_DOWNLEFT ) ) return false; //if the bottom row
	if ( cmb >= 0 && cmb <= 176 ) a = cmb + combooffsets[dir];
	else a = -1;
	if ( a != -1 ) {
		return ( Screen->isSolid(ComboX(a), ComboY(a)));
	}
	return false;
}

//Returns true if Link is facing a solid, on-screen combo, but allows specifying a default return. 
bool IsLinkFacingSolid(bool default_return){
	int a; int dir = Link->Dir; int cmb = ComboAt(Link->X, Link->Y); 
	int combooffsets[13]={-0x10, 0x10, -1, 1, -0x11, -0x0F, 0x0F, 0x11};
	if ( cmb % 16 == 0 ) combooffsets[9] = 1;
	if ( (cmb & 15) == 1 ) combooffsets[10] = 1; 
	if ( cmb < 0x10 ) combooffsets[11] = 1; //if it's the top row
	if ( cmb > 0x9F ) combooffsets[12] = 1; //if it's on the bottom row
	if ( combooffsets[9] && ( dir == CMB_LEFT || dir == CMB_UPLEFT || dir == CMB_DOWNLEFT || dir == CMB_LEFTUP ) ) return default_return; //if the left columb
	if ( combooffsets[10] && ( dir == CMB_RIGHT || dir == CMB_UPRIGHT || dir == CMB_DOWNRIGHT ) ) return default_return; //if the right column
	if ( combooffsets[11] && ( dir == CMB_UP || dir == CMB_UPRIGHT || dir == CMB_UPLEFT || dir == CMB_LEFTUP ) ) return default_return; //if the top row
	if ( combooffsets[12] && ( dir == CMB_DOWN || dir == CMB_DOWNRIGHT || dir == CMB_DOWNLEFT ) ) return default_return; //if the bottom row
	if ( cmb >= 0 && cmb <= 176 ) a = cmb + combooffsets[dir];
	else a = -1;
	if ( a != -1 ) {
		return ( Screen->isSolid(ComboX(a), ComboY(a)) );
	}
	return default_return;
}

ffc script foo{
    void run(){
        
    }
    //script scoope
    //Returns true if Link is facing a solid, on-screen combo. 
bool IsLinkFacingSolid(){
	int a; int dir = Link->Dir; int cmb = ComboAt(Link->X, Link->Y); 
	int combooffsets[13]={-0x10, 0x10, -1, 1, -0x11, -0x0F, 0x0F, 0x11};
	if ( cmb % 16 == 0 ) combooffsets[9] = 1;
	if ( (cmb & 15) == 1 ) combooffsets[10] = 1; 
	if ( cmb < 0x10 ) combooffsets[11] = 1; //if it's the top row
	if ( cmb > 0x9F ) combooffsets[12] = 1; //if it's on the bottom row
	if ( combooffsets[9] && ( dir == CMB_LEFT || dir == CMB_UPLEFT || dir == CMB_DOWNLEFT || dir == CMB_LEFTUP ) ) return false; //if the left columb
	if ( combooffsets[10] && ( dir == CMB_RIGHT || dir == CMB_UPRIGHT || dir == CMB_DOWNRIGHT ) ) return false; //if the right column
	if ( combooffsets[11] && ( dir == CMB_UP || dir == CMB_UPRIGHT || dir == CMB_UPLEFT || dir == CMB_LEFTUP ) ) return false; //if the top row
	if ( combooffsets[12] && ( dir == CMB_DOWN || dir == CMB_DOWNRIGHT || dir == CMB_DOWNLEFT ) ) return false; //if the bottom row
	if ( cmb >= 0 && cmb <= 176 ) a = cmb + combooffsets[dir];
	else a = -1;
	if ( a != -1 ) {
		return ( Screen->isSolid(ComboX(a), ComboY(a)));
	}
	return false;
}

//Returns true if Link is facing a solid, on-screen combo, but allows specifying a default return. 
bool IsLinkFacingSolid(bool default_return){
	int a; int dir = Link->Dir; int cmb = ComboAt(Link->X, Link->Y); 
	int combooffsets[13]={-0x10, 0x10, -1, 1, -0x11, -0x0F, 0x0F, 0x11};
	if ( cmb % 16 == 0 ) combooffsets[9] = 1;
	if ( (cmb & 15) == 1 ) combooffsets[10] = 1; 
	if ( cmb < 0x10 ) combooffsets[11] = 1; //if it's the top row
	if ( cmb > 0x9F ) combooffsets[12] = 1; //if it's on the bottom row
	if ( combooffsets[9] && ( dir == CMB_LEFT || dir == CMB_UPLEFT || dir == CMB_DOWNLEFT || dir == CMB_LEFTUP ) ) return default_return; //if the left columb
	if ( combooffsets[10] && ( dir == CMB_RIGHT || dir == CMB_UPRIGHT || dir == CMB_DOWNRIGHT ) ) return default_return; //if the right column
	if ( combooffsets[11] && ( dir == CMB_UP || dir == CMB_UPRIGHT || dir == CMB_UPLEFT || dir == CMB_LEFTUP ) ) return default_return; //if the top row
	if ( combooffsets[12] && ( dir == CMB_DOWN || dir == CMB_DOWNRIGHT || dir == CMB_DOWNLEFT ) ) return default_return; //if the bottom row
	if ( cmb >= 0 && cmb <= 176 ) a = cmb + combooffsets[dir];
	else a = -1;
	if ( a != -1 ) {
		return ( Screen->isSolid(ComboX(a), ComboY(a)) );
	}
	return default_return;
}
Here is a small Tutorial on File and Script Scope Functions using this function as an example.

#7 idontknow8

idontknow8

    Senior

  • Members

Posted 03 June 2017 - 10:40 AM

Ok, moved this to the top of my script & now i'm getting the errors:

cmb_left undeclared

cmb_upleft undeclared

cmb_downleft undeclared… 

 

…and so on for all the cmb directions.  I'm a missing a header that these should be declared in?  If so, which one?

 


#8 Timelord

Timelord

    The Timelord

  • Banned
  • Location:Prydon Academy

Posted 03 June 2017 - 02:09 PM

Ok, moved this to the top of my script & now i'm getting the errors:
cmb_left undeclared
cmb_upleft undeclared

cmb_downleft undeclared… 
 
…and so on for all the cmb directions.  I'm a missing a header that these should be declared in?  If so, which one?


Oh, right, you need the constants.

Just use these instead.

//Returns true if Link is facing a solid, on-screen combo. 
bool IsLinkFacingSolid(){
	int a; int dir = Link->Dir; int cmb = ComboAt(Link->X, Link->Y); 
	int combooffsets[13]={-0x10, 0x10, -1, 1, -0x11, -0x0F, 0x0F, 0x11};
	if ( cmb % 16 == 0 ) combooffsets[9] = 1;
	if ( (cmb & 15) == 1 ) combooffsets[10] = 1; 
	if ( cmb < 0x10 ) combooffsets[11] = 1; //if it's the top row
	if ( cmb > 0x9F ) combooffsets[12] = 1; //if it's on the bottom row
	if ( combooffsets[9] && ( dir == DIR_LEFT || dir == DIR_LEFTUP || dir == DIR_LEFTDOWN ) return false; //if the left columb
	if ( combooffsets[10] && ( dir == DIR_RIGHT || dir == DIR_RIGHTUP || dir == DIR_RIGHTDOWN ) ) return false; //if the right column
	if ( combooffsets[11] && ( dir == DIR_UP || dir == DIR_RIGHTUP || dir == DIR_LEFTUP ) ) return false; //if the top row
	if ( combooffsets[12] && ( dir == DIR_DOWN || dir == DIR_RIGHTDOWN || dir == DIR_LEFTDOWN ) ) return false; //if the bottom row
	if ( cmb >= 0 && cmb <= 176 ) a = cmb + combooffsets[dir];
	else a = -1;
	if ( a != -1 ) {
		return ( Screen->isSolid(ComboX(a), ComboY(a)));
	}
	return false;
}

//Returns true if Link is facing a solid, on-screen combo, but allows specifying a default return. 
bool IsLinkFacingSolid(bool default_return){
	int a; int dir = Link->Dir; int cmb = ComboAt(Link->X, Link->Y); 
	int combooffsets[13]={-0x10, 0x10, -1, 1, -0x11, -0x0F, 0x0F, 0x11};
	if ( cmb % 16 == 0 ) combooffsets[9] = 1;
	if ( (cmb & 15) == 1 ) combooffsets[10] = 1; 
	if ( cmb < 0x10 ) combooffsets[11] = 1; //if it's the top row
	if ( cmb > 0x9F ) combooffsets[12] = 1; //if it's on the bottom row
	if ( combooffsets[9] && ( dir == DIR_LEFT || dir == DIR_LEFTUP || dir == DIR_LEFTDOWN ) return default_return; //if the left columb
	if ( combooffsets[10] && ( dir == DIR_RIGHT || dir == DIR_RIGHTUP || dir == DIR_RIGHTDOWN ) ) return default_return; //if the right column
	if ( combooffsets[11] && ( dir == DIR_UP || dir == DIR_RIGHTUP || dir == DIR_LEFTUP ) )  return default_return; //if the top row
	if ( combooffsets[12] && ( dir == DIR_DOWN || dir == DIR_RIGHTDOWN || dir == DIR_LEFTDOWN ) ) return default_return; //if the bottom row
	if ( cmb >= 0 && cmb <= 176 ) a = cmb + combooffsets[dir];
	else a = -1;
	if ( a != -1 ) {
		return ( Screen->isSolid(ComboX(a), ComboY(a)) );
	}
	return default_return;
}


#9 idontknow8

idontknow8

    Senior

  • Members

Posted 04 June 2017 - 02:50 PM

You were missing a right parenthesis but I quickly found where. Other than that, it works flawlessly now. Thank you.


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users