When an item is drawn above Link, I actually want to draw a Tile and not the actual Item itself (sometimes I will use an image that is different from the item, and I noticed the arguments specify an Item not a Tile).
There should be four different sets of X and Y values for where the Tile is drawn, depending on which of the four Hold Up Item Animations is being used.
//import ffcscript.zh
const int DRAW_ITEM_DURATION = 100; //Should be an even number, and evenly divisible by DRAW_ITEM_FLICKER.
const int DRAW_ITEM_32X32_HOLDUP_DURATION = 100; //Special duration for 32x32 hold-up animation drawing.
const int DRAW_ITEM_LAYER = 6;
const int DRAW_ITEM_FLICKER = 20;
const int DRAW_ITEM_CSET = 0;
const int DRAW_ITEM_TILEHEIGHT = 16;
const int DRAW_ITEM_TILEWIDTH = 16;
ffc script FFC_DrawItemoverLink{
void run(int item_id, int y_offset, int x_offset, int flicker){
item i = Screen->CreateItem(item_id);
i->Z = 214747;
i->X = 1;
i->Y = 1;
i->HitXOffset = -320;
i->HitYOffset = -320;
i->DrawXOffset = -320;
i->DrawYOffset = -320;
i->CollDetection = false;
int timer;
int gfx[10];
if ( !flicker ) timer = DRAW_ITEM_DURATION;
if ( !flicker ) timer = DRAW_ITEM_32X32_HOLDUP_DURATION;
if ( item_id > 0 ) { //Using an item ID for the tile.
gfx[0] = i->Tile; //The graphic value
gfx[1] = i->TileWidth;
gfx[2] = i->TileHeight;
gfx[3] = i->CSet;
}
if ( item_id < 0 ) { //A specific tile.
gfx[0] = item_id * -1; //Convert the negative value to positve.
gfx[1] = DRAW_ITEM_TILEWIDTH; //Tileheight
gfx[2] = DRAW_ITEM_TILEHEIGHT; //Tilewidth
gfx[3] = DRAW_ITEM_CSET; //CSet
}
while( --timer > 0 && flicker ) { //If we're flickering
//Do the drawing based on script inputs.
if ( timer > ( DRAW_ITEM_DURATION / 2 ) && timer % DRAW_ITEM_FLICKER == 0 ) Screen->DrawTile(DRAW_ITEM_LAYER,Link->X+x_offset,Link->Y+y_offset,gfx[0],gfx[1],gfx[2],gfx[3],-1,-1,0,0,0,0,true,64);
if ( timer > ( DRAW_ITEM_DURATION / 2 ) && timer % DRAW_ITEM_FLICKER != 0 ) Screen->DrawTile(DRAW_ITEM_LAYER,Link->X+x_offset,Link->Y+y_offset,gfx[0],gfx[1],gfx[2],gfx[3],-1,-1,0,0,0,0,true,128);
if ( timer < ( DRAW_ITEM_DURATION / 2 ) && timer > ( DRAW_ITEM_DURATION / 4 ) && timer % (DRAW_ITEM_FLICKER/2) == 0 ) Screen->DrawTile(DRAW_ITEM_LAYER,Link->X+x_offset,Link->Y+y_offset,gfx[0],gfx[1],gfx[2],v,-1,-1,0,0,0,0,true,64);
if ( timer < ( DRAW_ITEM_DURATION / 2 ) && timer > ( DRAW_ITEM_DURATION / 4 ) && timer % (DRAW_ITEM_FLICKER/2) != 0 ) Screen->DrawTile(DRAW_ITEM_LAYER,Link->X+x_offset,Link->Y+y_offset,gfx[0],gfx[1],gfx[2],gfx[3],-1,-1,0,0,0,0,true,128);
if ( timer < ( DRAW_ITEM_DURATION / 4 ) && timer % (DRAW_ITEM_FLICKER/4) == 0 ) Screen->DrawTile(DRAW_ITEM_LAYER,Link->X+x_offset,Link->Y+y_offset,gfx[0],gfx[1],gfx[2],gfx[3],-1,-1,0,0,0,0,true,64);
if ( timer < ( DRAW_ITEM_DURATION / 4 ) && timer % (DRAW_ITEM_FLICKER/4) != 0 ) Screen->DrawTile(DRAW_ITEM_LAYER,Link->X+x_offset,Link->Y+y_offset,gfx[0],gfx[1],gfx[2],gfx[3],-1,-1,0,0,0,0,true,128);
Waitframe();
}
while ( --timer && !flicker ) { //If not flickering
Screen->DrawTile(DRAW_ITEM_LAYER,Link->X+x_offset,Link->Y+y_offset,gfx[0],gfx[1],gfx[2],gfx[3],-1,-1,0,0,0,0,true,128);
Waitframe();
}
Remove(i); // Cleanup the item pointer...
this->Data = 0; //...clear the ffc combo...
this->Script = 0; //...clear the ffc script...
Quit(); //..and cleanly exit.
}
}
item script AllItemPickupDrawOverLink{
void run(int stringA, int stringB, int invisible_holdup, int item_id, int forcedraw_item_ID, int draw_Y_offset, int draw_X_offset, int holdupType){
int drawitem;
int args[4]={drawitem, draw_Y_offset, draw_X_offset,NULL};
int buffer[]="FFC_DrawItemoverLink";
if( !Link->Item[item_id] ) {
if(Link->Y > 96){
if ( stringA ) Screen->Message(stringA);
}
else {
if ( stringB ) Screen->Message(stringB);
}
}
if ( !invisible_holdup ){
if ( !Link->Item[item_id] && !forcedraw_item_ID ) drawitem = item_id;
if ( Link->Item[item_id] && !forcedraw_item_ID ) drawnitem = -1; //Not sure on this one. Might throw an error.
if ( forcedraw_item_ID ) drawnitem = forcedraw_item_ID;
if ( drawnitem > 0 && !holdupType ) RunFFCScript(GetFFCScript(buffer),args);
if ( drawnitem > 0 && holdupType ) {
int holdtype = holdupType += 3;
if ( Link->Action == LA_SWIMMING ) holdtype += 10;
Link->Action = holdtype;
Link->HeldItem = drawnitem;
}
}
if ( invisible_holdup ){
int holdtype = holdupType += 3;
if ( Link->Action = LA_SWIMMING ) holdtype += 10;
Link->Action = holdtype;
Link->HeldItem = -1;
RunFFCScript(GetFFCScript(buffer),args);
}
}
}
Added using a specific tile, by passing a
negative value for the arg to the
item_id param of the
ffc script.
I've no idea why you need multiple x/y positions: If you set up an item script to hold up the item, with the animation, just assign the values as needed based on the hold-up type that you specify.
If you want x/y positions hardcoded based on the hold-up type, that wouldn't be too terrible to add. They'd be defaults, overridden by the offset args.
Still entirely untested. Apparently, this is 'the way we roll' now.
Edited by ZoriaRPG, 11 March 2016 - 09:15 AM.