// Check if main slots are used
ParseItem($skin);
ParseItem(10000 + $skin);
ParseItem(20000 + $face);
ParseItem(30000 + $hair);
// Sort equipment by ID
asort($options['slots']);
// Fix stand
foreach ($options['slots'] as $slot => $itemid) {
    $data = GetItemWZInfo($itemid, CURRENT_LOCALE);
    CheckStand(GetItemType($itemid), $data);
}
// Parse items..
foreach ($options['slots'] as $slot => $itemid) {
    if (floor($itemid / 100000) == 5) {
        RenderCashItem($itemid);
    } else {
        ParseItem($itemid);
    }
}
FindAndAddSetEffect();
FindAndAddItemEffect();
// --------------------------------------------------------------------------------------------------------------------------------
// Render items
krsort($data_buffer['zlayers']);
$im = imagecreatetruecolor($imageoptions['width'], $imageoptions['height']);
imagesavealpha($im, true);
$trans = imagecolorallocatealpha($im, 0, 0, 0, 127);
imagefill($im, 0, 0, $trans);
foreach ($data_buffer['zlayers'] as $zname => $objects) {
    foreach ($objects as $object) {
        if (DEBUGGING) {
            echo 'found xy' . "\r\n";
        }
        $x -= $block['origin']['X'];
        $y -= $block['origin']['Y'];
    }
    $img_location = GetItemDataLocation($main_dir, $itemid) . 'effect.' . $block['..']->name . '.' . $block->name . '.png';
    $layer = $block['..']['z'];
    $extra_layers[$layer][] = array($img_location, $x, $y);
}
//RenderCashItem(5010065);
//RenderCashItem(5010073);
if ($jobid == 6000 || $jobid == 6100 || $jobid == 6110 || $jobid == 6111 || $jobid == 6112) {
    RenderCashItem(5010087);
    // wings
    RenderCashItem(5010090);
    // tail
    /*
    // Gauge half?
    RenderCashItem(5010088); // wings
    RenderCashItem(5010091); // tail
    // Gauge full?
    RenderCashItem(5010089); // wings
    RenderCashItem(5010092); // tail
    */
}
if (DEBUGGING) {
    var_export($extra_layers);
}
if (true || !DEBUGGING) {
    $w = imagesx($im);