const int IC_DISASSEMBLED_ITEM_PIECE = 70;//Item class used for disassembled item pieses
//Generic Disassembled item piece. Link must collect enough items to assemble whole item. 2.53.x
//1. Set up sequence of tiles showing item assembly progress.
//2. Copy 1st tile from sequence from step 1 into separate area.
//3. Subscreen. Set up 1x1 tile widget, a plain 1x1 tile, using copied tile from step 2.
//4. Global script combining: Put UpdateDisassembleProgress() function before main loop of Active global script. The Init script will be combined automatically on compilation.
//5. Set up as many consecutive strings to track item assembly progress, like 1/4, 2/4, 3/4 etc.
//6. Create item in Item editor. It`s ItemClass should be IC_DISASSEMBLED_ITEM_PIECE (Custom Item Class #4 by default). Assign script into Pickup script slot.
// D0 - Item to assemble.
// D1 - Number of pieces to form whole item.
// D2 - First string of the sequence from step 5.
// D3 - ID of tile used by subscreen widget to track progress from step 3. Check subscreen editor.
// D4 - ID of 1st tile of tile sequence from step 1.
int Disassemble[256];
item script ItemPiece{
void run (int Item, int numpieces, int string, int subscreentile, int tilesequence){
itemdata it;
for (int i=0;i<256;i++){
it = Game->LoadItemData(i);
if (it==this){
int msg = string+Disassemble[i];
if (string>0) Screen->Message(msg);
Disassemble[i]++;
if (Disassemble[i]>=numpieces){
item coll = Screen->CreateItem(Item);
coll->X = Link->X;
coll->Y = Link->Y;
Disassemble[i]=0;
}
CopyTile(tilesequence+Disassemble[i], subscreentile);
break;
}
}
}
}
global script Init{
void run(){
for (int i=0;i<256;i++){
Disassemble[1]=0;
}
}
}
global script DisassembleSubscreenUpdate{
void run(){
UpdateDisassembleProgress();
while(true){
//foo
Waitdraw();
//bar
Waitframe();
}
}
}
//The main global function to update subscreen widgets that track item assembly progress.
void UpdateDisassembleProgress(){
itemdata it;
for (int i=0; i<256;i++){
it = Game->LoadItemData(i);
if (it->Family!=IC_DISASSEMBLED_ITEM_PIECE)continue;
CopyTile(it->InitD[4]+Disassemble[i], it->InitD[3]);
}
}