So, here's another revised version. It includes items and anything with Flag 102. It still doesn't do enemies bigger than 1x1 though- it tries, but they are left-right flipped incorrectly (left side on the right and vice versa). And sometimes the hammer does weird things still.
ffc script Mirror_Effect{
void run(){
int LastX;
int LastY;
int Link_tile;
int Link_Flip;
int LReflect_Y;
int Reflect_YOffset = 22; //The offset, in pixels, to draw various things
while(true){
//Enemy Reflection
//Track all enemies in the room.
for (int i = 1; i <= Screen->NumNPCs(); i++){
npc enm = Screen->LoadNPC(i);
int tile; int EReflect_Y;
//Change tile base on enemy's direction. Currently set up for a enemy with 4 frames of animation.
if(enm->Dir == DIR_LEFT){tile = enm->Tile+4;}
else if (enm->Dir == DIR_RIGHT){tile = enm->Tile-4;}
else if (enm->Dir == DIR_DOWN){tile = enm->Tile-4;}
else{tile = enm->Tile+4;}
EReflect_Y = this->Y - (enm->Y - this->Y)+Reflect_YOffset;
Screen->DrawTile(1, enm->X, EReflect_Y, tile, enm->TileWidth, enm->TileHeight, enm->CSet, 16, 16, 0, 0, 0, 1, true, 64);
}
//LWeapon Reflection
//Track all Lweapons. Offset if Link is facing up or down.
for (int i = 1; i <= Screen->NumLWeapons(); i++){
lweapon wpn = Screen->LoadLWeapon(i);
int fl = wpn->Flip; int LWReflect_Y;
if (fl >1)fl = 0;
LWReflect_Y = this->Y - (wpn->Y - this->Y)+Reflect_YOffset;
//This is supposed to adjust the position of the lweapon based on whether you're facing up, down, left or right and whether you're moving.
//Stationary Lweapons like bombs are trickier to follow.
//The hookshot chain cannot be created this way.
if(Link->Dir == DIR_UP&& Link->Y == LastY)Screen->DrawTile(1, wpn->X, LWReflect_Y, wpn->Tile, 1, 1, wpn->CSet, 16, 16, 0, 0, 0, 3, true, 64);
else if(Link->Dir == DIR_DOWN && Link->Y == LastY)Screen->DrawTile(1, wpn->X, LWReflect_Y, wpn->Tile, 1, 1, wpn->CSet, 16, 16, 0, 0, 0, fl, true, 64);
else if(Link->Dir == DIR_UP && Link->Y != LastY)Screen->DrawTile(1, wpn->X,LWReflect_Y, wpn->Tile, 1, 1, wpn->CSet, 16, 16, 0, 0, 0, fl, true, 64);
else if(Link->Dir == DIR_DOWN && Link->Y != LastY)Screen->DrawTile(1, wpn->X, LWReflect_Y, wpn->Tile, 1, 1, wpn->CSet, 16, 16, 0, 0, 0, fl, true, 64);
//I've gotten this code to work for facing all directions before, but left and right seem to have decided to malfunction.
else{
Screen->DrawTile(1, wpn->X, LWReflect_Y+6, wpn->Tile, 1, 1, wpn->CSet, 16, 16, 0, 0, 0, fl, true, 64);
}
}
//EWeapon Reflection
//Track all Eweapons. This actually seems to work.
for (int i = 1; i <= Screen->NumEWeapons(); i++){
eweapon wpn = Screen->LoadEWeapon(i);
int fl = wpn->Flip; int EWReflect_Y;
if (fl >1)fl = 0;
EWReflect_Y = this->Y - (wpn->Y - this->Y)+Reflect_YOffset;
Screen->DrawTile(1, wpn->X, EWReflect_Y, wpn->Tile, 1, 1, wpn->CSet, 16, 16, 0, 0, 0, fl, true, 64);
}
//Flag Reflection
//Haven't figured this part out yet.
for (int i = 0; i <= 175; i++){
if (ComboFI(i, CF_SCRIPT4)){
int Flagtile = Screen->ComboD[i];
int FReflect_Y = this->Y - (ComboY(i) - this->Y)+Reflect_YOffset+8;
Screen->FastCombo(1, ComboX(i), FReflect_Y, Flagtile, 3, 128);
// Screen->DrawTile(1, ComboX(i), FReflect_Y, Flagtile, 1, 1, 3, 16, 16, 0, 0, 0, 0, true, 128);
}
}
//Item Reflection- none of these will be flipped, because few if any items have a direction. Yes, that means things like clocks will show the face in the mirror too.
for (int i = 1; i <= Screen->NumItems(); i++){
item itm = Screen->LoadItem(i);
int IReflect_Y = this->Y - (itm->Y - this->Y)+Reflect_YOffset+8;
Screen->DrawTile(1, itm->X, IReflect_Y, itm->Tile, 1, 1, itm->CSet, 16,16,0, 0, 0, 0, true, 128);
}
//Link's Reflection
//Match tiles with Link. Currently offset for the amount of frames in my animation of Link.
//Currently set up to use BSZelda-style Link movement.
//I moved this to the end so Link would be drawn last, above other tiles.
if(Link->Dir == DIR_LEFT){
Link_tile= Link->Tile+4; // Finds the Right tiles, because they can be different-
Link_Flip = 1; // and flips them horizontally, so they look face left.
if(Link->Action > 1) Link_tile=Link->Tile +1; // Finds the Right-attacking tile. Already flipped, above.
}else if(Link->Dir == DIR_RIGHT){
Link_tile= Link->Tile-4; // Finds the Left tiles, as above-
Link_Flip = 0; // but doesn't flip them, because the game engine does that for you.
if(Link->Action > 1) Link_tile=Link->Tile -1; // If Link is attacking, using the hammer, etc, it does this. This technically does stupid things
// if Link is swimming, so don't use in rooms where when Link would be swimming.
}else if(Link->Dir == DIR_DOWN){
Link_tile = Link->Tile+4;
Link_Flip = 1;
if(Link->Action > 1) Link_tile=Link->Tile +1;
}else{
Link_tile = Link->Tile-4;
Link_Flip = 1;
if(Link->Action > 1) Link_tile=Link->Tile -1;
}
// The vertical movement is currently set up to make it where the ffc is placed at the bottom edge of the mirror. Unlike ywkls
// version, the ffc itself does not move- all movements are calculated based on the ffc's fixed position.
LReflect_Y = this->Y - (Link->Y - this->Y)+Reflect_YOffset;
Screen->DrawTile(1, Link->X, LReflect_Y, Link_tile, 1, 1, 6, 16, 16, 0, 0, 0, Link_Flip, true, 64);
//Cleanup
LastX = Link->X;
LastY = Link->Y;
Waitframe();
}
}
}
Edited by symbiote01, 15 July 2015 - 09:39 PM.