Whenever I did a scripted lens, I had the enemy draw itself based on data stored ahead of time.
const int LENS_FFC_SCRIPT = 27;
//Scripted Lens Constants
const int INVISIBLE_MISC_INDEX = 0;//Used by scripted lens. Stores combo to draw.
const int DRAWN_MISC_INDEX = 1;//Used by scripted lens. Tells whether or not to draw enemy.
const int LENS_RADIUS = 60;//Width of scripted lens aperture.
item script LensReveal{
void run(int dummy, int LensCost){
if(Link->MP>=LensCost){
int args[8]={LensCost};
RunFFCScript(LENS_FFC_SCRIPT,args);
}
}
}
ffc script Lens_Shows_Enemies{
void run(int LensCost){
npc ghost;
int i;
while(Link->PressB ||Link->InputB){
if(Link->MP<LensCost)
break;
for(i=1;i<=Screen->NumNPCs();i++){
ghost = Screen->LoadNPC(i);
if(ghost->Defense[NPCD_BYRNA]==NPCDT_ONEHITKILL)
ghost->Misc[DRAWN_MISC_INDEX]= 1;
}
Waitframe();
}
ghost->Misc[DRAWN_MISC_INDEX]= 0;
this->Data = 0;
Quit();
}
}
//Draw an inverted circle (fill whole screen except circle)
//Also draws an enemy if it is invisible and ghosted.
void InvertedLensCircle(int bitmapID, int layer, int x, int y, int radius, int scale, int fillcolor,npc ghost){
Screen->SetRenderTarget(bitmapID); //Set the render target to the bitmap.
Screen->Rectangle(layer, 0, 0, 256, 176, fillcolor, 1, 0, 0, 0, true, 128); //Cover the screen
Screen->Circle(layer, x, y, radius, 0, scale, 0, 0, 0, true, 128); //Draw a transparent circle.
if(ghost->Dir==DIR_UP||ghost->Dir==DIR_LEFTUP)Screen->DrawCombo(layer, ghost->X, ghost->Y, ghost->Misc[INVISIBLE_MISC_INDEX], ghost->TileWidth, ghost->TileHeight, ghost->Attributes[8], -1, -1, 0, 0, 0, -1, 0, true, OP_OPAQUE);
else if(ghost->Dir==DIR_DOWN ||ghost->Dir== DIR_RIGHTDOWN)Screen->DrawCombo(layer, ghost->X, ghost->Y, ghost->Misc[INVISIBLE_MISC_INDEX]+1, ghost->TileWidth, ghost->TileHeight, ghost->Attributes[8], -1, -1, 0, 0, 0, -1, 0, true, OP_OPAQUE);
else if(ghost->Dir==DIR_LEFT||ghost->Dir== DIR_LEFTDOWN)Screen->DrawCombo(layer, ghost->X, ghost->Y, ghost->Misc[INVISIBLE_MISC_INDEX]+2, ghost->TileWidth, ghost->TileHeight, ghost->Attributes[8], -1, -1, 0, 0, 0, -1, 0, true, OP_OPAQUE);
else if(ghost->Dir==DIR_RIGHT||ghost->Dir== DIR_RIGHTUP)Screen->DrawCombo(layer, ghost->X, ghost->Y, ghost->Misc[INVISIBLE_MISC_INDEX]+3, ghost->TileWidth, ghost->TileHeight, ghost->Attributes[8], -1, -1, 0, 0, 0, -1, 0, true, OP_OPAQUE);
Screen->SetRenderTarget(RT_SCREEN); //Set the render target back to the screen.
Screen->DrawBitmap(layer, bitmapID, 0, 0, 256, 176, 0, 0, 256, 176, 0, true); //Draw the bitmap
}
//Draws scripted enemies with scripted lens.
void Drawn_Enemy_Waitframe(ffc this, npc ghost){
if(Ghost_Waitframe(this,ghost,false,false)){
if(ghost->Misc[DRAWN_MISC_INDEX]==1)InvertedLensCircle(4, 6, CenterLinkX(), CenterLinkY(), LENS_RADIUS, 1, 15,ghost);
}
else if(!Ghost_Waitframe(this, ghost, false, false)){
Ghost_DeathAnimation(this, ghost, 2);
Quit();
}
}
While this won't handle the explosion part; the other code that's been posted here should help with that.
Edited by ywkls, 10 September 2019 - 10:07 AM.