const int WARPCHANGER_MAX_TRIFORCE_PIECES = 8;
// D0: Which warp to change. 0-3 = Side warps A-D. 4-7 = Tile warps A-D
// D1: Which DMap to redirect the warp to
// D2: Which screen to redirect the warp to
// D3: Which counter to check for. Certain negative values are used for special cases:
// -1: Check triforce count
// -2: Check screen state. Amount is the screen state to check.
// -3: Works as a fourth item check. Amount is the item to check.
// D4: How much to check the counter for. If negative, will check if the value is less than this amount.
// D5: First item to check for. Ignore if 0. If negative, check for not having this item.
// D6: Second item to check for. Ignore if 0. If negative, check for not having this item.
// D7: Third item to check for. Ignore if 0. If negative, check for not having this item.
// This metadata is for 2.55. If you're still on 2.53, delete it
@InitD0("Warp Number"),
@InitDHelp0("Which warp to change. 0-3 = Side warps A-D. 4-7 = Tile warps A-D"),
@InitD1("DMap"),
@InitDHelp1("Which DMap to redirect the warp to"),
@InitD2("Screen"),
@InitDHelp2("Which screen to redirect the warp to"),
@InitD3("Counter"),
@InitDHelp3("Which counter to check for. Certain negative values are used for special cases:\n-1: Check triforce count\n-2: Check screen state. Amount is the screen state to check.\n-3: Works as a fourth item check. Amount is the item to check."),
@InitD4("Amount"),
@InitDHelp4("How much to check the counter for. If negative, will check if the value is less than this amount."),
@InitD5("Item #1"),
@InitDHelp5("First item to check for. Ignore if 0. If negative, check for not having this item."),
@InitD6("Item #2"),
@InitDHelp6("Second item to check for. Ignore if 0. If negative, check for not having this item."),
@InitD7("Item #3"),
@InitDHelp7("Third item to check for. Ignore if 0. If negative, check for not having this item.")
// End of 2.55 metadata
ffc script ConditionalWarpChanger
{
void run(int whichWarp, int whichDMap, int whichScreen, int counter, int amount, int whichItem1, int whichItem2, int whichItem3)
{
while(!WarpActive(counter, amount, whichItem1, whichItem2, whichItem3))
{
Waitframe();
}
if(whichWarp>=4)
{
whichWarp -= 4;
Screen->SetTileWarp(whichWarp, whichScreen, whichDMap, Screen->GetTileWarpType(whichWarp));
}
else
{
Screen->SetSideWarp(whichWarp, whichScreen, whichDMap, Screen->GetSideWarpType(whichWarp));
}
}
bool WarpActive(int counter, int amount, int whichItem1, int whichItem2, int whichItem3)
{
if(counter==-3) // Extra item check
{
if(!ItemCheck(amount))
return false;
}
else if(counter==-2) // Screen state
{
if(amount<0)
{
if(Screen->State[Abs(amount)])
return false;
}
else
{
if(!Screen->State[amount])
return false;
}
}
else if(counter==-1) // Triforce check
{
if(amount<0)
{
if(NumTriforcePieces(WARPCHANGER_MAX_TRIFORCE_PIECES)>=Abs(amount))
return false;
}
else
{
if(NumTriforcePieces(WARPCHANGER_MAX_TRIFORCE_PIECES)<amount)
return false;
}
}
else if(counter>=0) // Regular counter
{
if(amount<0)
{
if(Game->Counter[counter]>=Abs(amount))
return false;
}
else if(amount>0)
{
if(Game->Counter[counter]<amount)
return false;
}
}
if(!ItemCheck(whichItem1))
return false;
if(!ItemCheck(whichItem2))
return false;
if(!ItemCheck(whichItem3))
return false;
return true;
}
bool ItemCheck(int id)
{
if(id==0)
return true;
if(id<0)
return !Link->Item[Abs(id)];
return Link->Item[id];
}
}