3rd attempt. It's untested.
Code:
// Cane of Somaria- Changes certain attributes of an FFC on the
// current screen "Player" is on. It modifies the combo used,
// combo type, flags, etc. In the end, it looks like a block.
// This item will also change the location of the FFC so it
// always "spawns" 2 tiles away from Link in the direction he
// is currently facing. Becuase of limited knowledge, this
// script currently does not prevent you from walking onto the
// block. Any mention of "SomariaBlock" in the script refers to
// the Freeform Combo. Have fun.
// Note: Due to limitations (and the SomariaBlock script (see below
// this script)), only FFC 1 can be used as the Somaria Block
// until the FFC script bug is destroyed.<-What is this bug you speak of?
import "std.zh"
item script CaneSomaria
{
void run()
{
ffc SomariaBlock = Screen->LoadFFC(1);//Set the coordinates to -16, -16
SomariaBlock->Data = 2123;
SomariaBlock->CSet = 10;
if(Link->Dir == 0)
{
SomariaBlock->X = Link->X;
SomariaBlock->Y = Link->Y - 32;
}
else if(Link->Dir == 1)
{
SomariaBlock->X = Link->X;
SomariaBlock->Y = Link->Y + 32;
}
else if(Link->Dir == 2)
{
SomariaBlock->X = Link->X - 32;
SomariaBlock->Y = Link->Y;
}
else if(Link->Dir == 3)
{
SomariaBlock->X = Link->X + 32;
SomariaBlock->Y = Link->Y;
}
float remainder = SomariaBlock->X % 16;
if ( remainder <= 8 )
{
SomariaBlock->X = SomariaBlock->X - remainder;
}
else
{
SomariaBlock->X = SomariaBlock->X + 16 - remainder;
}
float remainderY = SomariaBlock->Y % 16;
if ( remainderY <= 8 )
{
SomariaBlock->Y = SomariaBlock->Y - remainderY;
}
else
{
SomariaBlock->Y = SomariaBlock->Y + 16 - remainderY;
}
int ffcy = SomariaBlock->Y;
int ffcx = SomariaBlock->X;
int position = (ffcy & 240)+(ffcx>>4);
Screen->ComboS [position] = 15;
if (position != lastpos)
Screen->ComboS [laspos] = 0;
int laspos = postion;
}
}