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, At Front Y
#1
Posted 02 June 2017 - 01:07 AM
#2
Posted 02 June 2017 - 04:49 AM
#3
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
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
Posted 02 June 2017 - 07:39 PM
#6
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
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
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
Posted 04 June 2017 - 02:50 PM
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users