void Ghost_WaitframeLight(ffc this, npc ghost)
{
// Remember all the global variables
// Initializing the array is faster than setting it up afterward...
// but the difference is probably negligible, realistically
float tempGhostData[24] = {
Ghost_X, // 0
Ghost_Y, // 1
Ghost_Z, // 2
Ghost_Jump, // 3
Ghost_Vx, // 4
Ghost_Vy, // 5
Ghost_Ax, // 6
Ghost_Ay, // 7
__Ghost_PrevX, // 8
__Ghost_PrevY, // 9
Ghost_CSet, // 10
Ghost_Dir, // 11
Ghost_Data, // 12
Ghost_TileWidth, // 13
Ghost_TileHeight, // 14
__Ghost_Flags, // 15
__Ghost_Flags2, // 16
__Ghost_InternalFlags, // 17
__Ghost_FlashCounter, // 18
__Ghost_KnockbackCounter, // 19
Ghost_HP, // 20
__Ghost_XOffsets, // 21
__Ghost_YOffsets // 22
// 23 is for either drawingData or tempGhostAdditionalCombos;
// update DrawGhostFFCs if that changes
};
int tempGhostAdditionalCombos[21]; // Same size as __Ghost_AdditionalCombos
// Change it in the loop below, too
if(__Ghost_AdditionalCombos[0]>0)
{
for(int i=0; i<21; i++)
tempGhostAdditionalCombos[i]=__Ghost_AdditionalCombos[i];
}
// Give ghost an array pointer so its data can be found by other scripts
if(ghost->isValid())
ghost->Misc[__GHI_NPC_DATA]=0x10000|tempGhostData;
// Position additional FFCs, set draw data, make FFCs invisible if flickering.
do
{
if(ghost->isValid())
{
// Set up drawing array if needed. The array size depends on what
// might need drawn. If only ZScript had malloc...
if(__GH_USE_DRAWCOMBO!=0)
{
// DrawCombo and additional combos
if(__Ghost_AdditionalCombos[__GHI_AC_COUNT]>0)
{
// Array size is 4 + (__GH_AC_MAX_ADDITIONAL_COMBOS + 1) * __GHCD_DATA_SIZE
int drawData[34];
__SetUpDrawingArray(this, ghost, drawData);
tempGhostData[23]=drawData;
__HideFFCAndWait(this);
}
// DrawCombo and no additional combos
else
{
// 4 + __GHCD_DATA_SIZE
int drawData[10];
__SetUpDrawingArray(this, ghost, drawData);
tempGhostData[23]=drawData;
__HideFFCAndWait(this);
}
}
else // __GH_USE_DRAWCOMBO==0
{
// Additional combos, no DrawCombo
if(__Ghost_AdditionalCombos[__GHI_AC_COUNT]>0)
{
// 4 + __GH_AC_MAX_ADDITIONAL_COMBOS * __GHCD_DATA_SIZE
int drawData[28];
__SetUpDrawingArray(this, ghost, drawData);
tempGhostData[23]=drawData;
// Hide the FFC if the enemy is flickering.
if(__Ghost_IsFlickering(ghost) &&
(__ghzhData[__GHI_GLOBAL_FLAGS]&__GHGF_FLICKER)!=0)
__HideFFCAndWait(this);
else
Waitframe();
}
// No DrawCombo or additional combos
else
{
if(__Ghost_IsFlickering(ghost) &&
(__ghzhData[__GHI_GLOBAL_FLAGS]&__GHGF_FLICKER)==0)
__HideFFCAndWait(this);
else
Waitframe();
}
}
}
else // ghost is not valid
__HideFFCAndWait(this);
// Restore the global variables
Ghost_X=tempGhostData[0];
Ghost_Y=tempGhostData[1];
Ghost_Z=tempGhostData[2];
Ghost_Jump=tempGhostData[3];
Ghost_Vx=tempGhostData[4];
Ghost_Vy=tempGhostData[5];
Ghost_Ax=tempGhostData[6];
Ghost_Ay=tempGhostData[7];
__Ghost_PrevX=tempGhostData[8];
__Ghost_PrevY=tempGhostData[9];
Ghost_CSet=tempGhostData[10];
Ghost_Dir=tempGhostData[11];
Ghost_Data=tempGhostData[12];
Ghost_TileWidth=tempGhostData[13];
Ghost_TileHeight=tempGhostData[14];
__Ghost_Flags=tempGhostData[15];
__Ghost_Flags2=tempGhostData[16];
__Ghost_InternalFlags=tempGhostData[17];
__Ghost_FlashCounter=tempGhostData[18];
__Ghost_KnockbackCounter=tempGhostData[19];
Ghost_HP=tempGhostData[20];
__Ghost_XOffsets=tempGhostData[21];
__Ghost_YOffsets=tempGhostData[22];
if(tempGhostAdditionalCombos[0]>0)
{
for(int i=0; i<21; i++)
__Ghost_AdditionalCombos[i]=tempGhostAdditionalCombos[i];
}
else
__Ghost_AdditionalCombos[0]=0; //this is all I added
} while((__ghzhData[__GHI_GLOBAL_FLAGS]&__GHGF_SUSPEND)!=0);
if(ghost->isValid())
ghost->Misc[__GHI_NPC_DATA]=0x10000;
}