Oh, and to make sure it doesn't count as a beatable enemy. If the enemy isn't cleaned up after the itemset is spawned, you should also do that.
the enemy is killed right away. that's what generates the item set.
here's the updated code with the changes you requested. keeps the usage of Screen->D[] variables to a minimum for that they are available for other scripts. i did away with the option for using screen secrets to designate that the "pots" have been broken, it just uses the D variables now. again it compiles, but is untested. if it works, i'll submit to the database.
import "std.zh" // only need this once
// 1. set the following constants.
// 2. scroll down to the bottom of this script, and make sure you don't already have the utility function at the bottom in your script file.
// 3. import, put the FFC script(s) you want to use in empty slots. Put the global script onExit into the onExit slot (or combine this onExit script with your existing)
// 4. place the FFCs on the slashable. They don't have to be lined up to the grid, just the X/Y coords need to be on that combo location.
// 5. set your D0/D1/D2 values.
const int NPC_ITEMSET = 177; // ID of a dummy enemy with type different from "none", hp0, itemset overridden by script, instant spawn animation
// Screen->D[] register indexes. Set to a number between 0-7 that is unused by any other scripts on the screen.
// These are only used if D1 for either script is >0.
const int SCREEN_D_ITEM1 = 0; // A binary index of FFCs 1-16, the bit for each FFC will be true if that item has been taken.
const int SCREEN_D_ITEM2 = 1; // As above, FFCS 17-32
const int SCREEN_D_ITEM_RESET = 2; // Tracks either #deaths or #continues to see if we should be reseting the bit above. Only used if D2>0.
// Watches for the combo under the FFC to change, and generates an item on the slashable from the dropset that you specify.
// D0 = the itemset #
// D1 = should it only happen once?
// 0 = will happen everytime you revisit the screen.
// 1 = happen once, sets a bit representing this FFC to a Screen->D register to track
// D2 = once reset. If using D1>0, do you want to reset it on death or continue?
// 0 = no
// 1 = reset on death
// 2 = reset on continue
ffc script Slash_ItemSet
{
void run(int itemset, int once, int reset)
{
int thisNum = FFCNum(this);
if(once != 0)
{
if( (reset == 1 && Screen->D[SCREEN_D_ITEM_RESET] != Game->NumDeaths)
||(reset == 2 && Screen->D[SCREEN_D_ITEM_RESET] != continueCount) )
{
if (thisNum > 16) SetScreenDBit(SCREEN_D_ITEM2,thisNum-17,false);
else SetScreenDBit(SCREEN_D_ITEM1,thisNum-1,false);
}
else if ( GetScreenDBit( Cond(thisNum > 16, SCREEN_D_ITEM2, SCREEN_D_ITEM1), Cond(thisNum > 16, thisNum-17, thisNum-1) ) ) Quit();
}
int loc = ComboAt(this->X,this->Y);
int c = Screen->ComboD[loc];
while(true)
{
if(Screen->ComboD[loc] != c)
{
ItemSetAt(itemset,loc);
if (once != 0)
{
if (thisNum > 16) SetScreenDBit(SCREEN_D_ITEM2,thisNum-17,true);
else SetScreenDBit(SCREEN_D_ITEM1,thisNum-1,true);
if (reset==1) Screen->D[SCREEN_D_ITEM_RESET] = Game->NumDeaths;
else if (reset==2) Screen->D[SCREEN_D_ITEM_RESET] = continueCount;
}
Quit();
}
Waitframe();
}
}
}
// Watches for the combo under the FFC to change, and generates an item on the slashable.
// D0 = the item #
// D1 = should it only happen once?
// 0 = will happen everytime you revisit the screen.
// 1 = happen once, sets a bit representing this FFC to a Screen->D register to track
// D2 = once reset. If using D1>0, do you want to reset it on death or continue?
// 0 = no
// 1 = reset on death
// 2 = reset on continue
ffc script Slash_Item
{
void run(int itemnum, int once, int reset)
{
int thisNum = FFCNum(this);
if(once != 0)
{
if( (reset == 1 && Screen->D[SCREEN_D_ITEM_RESET] != Game->NumDeaths)
||(reset == 2 && Screen->D[SCREEN_D_ITEM_RESET] != continueCount) )
{
if (thisNum > 16) SetScreenDBit(SCREEN_D_ITEM2,thisNum-17,false);
else SetScreenDBit(SCREEN_D_ITEM1,thisNum-1,false);
}
else if ( GetScreenDBit( Cond(thisNum > 16, SCREEN_D_ITEM2, SCREEN_D_ITEM1), Cond(thisNum > 16, thisNum-17, thisNum-1) ) ) Quit();
}
int loc = ComboAt(this->X,this->Y);
int c = Screen->ComboD[loc];
while(true)
{
if(Screen->ComboD[loc] != c)
{
item itm = CreateItemAt(itemnum, ComboX(loc), ComboY(loc));
if (once != 0)
{
if (thisNum > 16) SetScreenDBit(SCREEN_D_ITEM2,thisNum-17,true);
else SetScreenDBit(SCREEN_D_ITEM1,thisNum-1,true);
if (reset==1) Screen->D[SCREEN_D_ITEM_RESET] = Game->NumDeaths;
else if (reset==2) Screen->D[SCREEN_D_ITEM_RESET] = continueCount;
}
Quit();
}
Waitframe();
}
}
}
int continueCount = 0;
global script onExit
{
void run()
{
continueCount++;
}
}
//!!!!!!!! this function may already exist in your script file, as it is used by other database scripts.
//creates and kills an enemy of type NPC_ITEMSET to fake an itemdropset.
void ItemSetAt(int itemset,int loc){
npc e = Screen->CreateNPC(NPC_ITEMSET);
e->ItemSet = itemset;
if(e->isValid()){
e->X = loc%16*16;
e->Y = loc-loc%16;
}
e->HP = HP_SILENT;
}