Example #1
0
 public static function MakeItem($row, $locale)
 {
     if ($row['inventory'] == 0) {
         $item = new ItemEquip($row);
     } elseif (GetItemType($row['itemid']) == 500) {
         $item = new ItemPet($row, $locale);
     } else {
         $item = new ItemBase($row);
     }
     return $item;
 }
function ParseItem($id)
{
    global $options, $imageoptions, $data_buffer, $foundHidingCap, $zmap;
    $iteminfo = GetItemWZInfo($id, CURRENT_LOCALE);
    $itemtype = GetItemType($id);
    $item_raw_type = floor($id / 1000);
    $item_section_id = $id % 1000;
    $zvalue = '';
    $foundinfo = false;
    if (DEBUGGING) {
        echo 'Item: ' . $id . "\r\n";
        echo 'Item type: ' . $itemtype . "\r\n";
        echo 'Item raw type: ' . $item_raw_type . "\r\n";
        echo 'Item section id: ' . $item_section_id . "\r\n";
        echo 'Item image at: ' . GetItemDataLocation($data_buffer['main-dir'], $id) . "\r\n";
    }
    if (isset($iteminfo[$options['weapongroup']])) {
        $weapongroup = $options['weapongroup'];
        $iteminfo = $iteminfo[$weapongroup];
        $iteminfo['ITEMID'] = $id;
        if (DEBUGGING) {
            echo 'NX wep Item: ' . $weapongroup . "\r\n";
        }
    }
    $isface = isset($iteminfo[$options['face']]);
    foreach ($iteminfo as $key => $value) {
        if (DEBUGGING) {
            echo '> ' . $key . "\r\n";
        }
        $tmp = null;
        if ($key == 'ITEMID' || $key == 'info' || !$value instanceof TreeNode) {
            continue;
        }
        if ($isface) {
            if ($key == 'default') {
                $tmp = $value;
            } else {
                $tmp = $value->offsetGet('0');
            }
        } else {
            $tmp = $value[$options['stance_frame']];
        }
        if ($tmp === null) {
            if (DEBUGGING) {
                echo 'No info found for ' . $key . "\r\n";
                //var_export($iteminfo);
            }
            continue;
        }
        $imgkey = $key;
        if (!$tmp instanceof TreeNode) {
            if (DEBUGGING) {
                echo 'Prolly uol->' . $tmp . "\r\n";
            }
            $tmp = $iteminfo[$key];
        }
        if ($tmp === null) {
            if (DEBUGGING) {
                echo 'No info found for ' . $key . "\r\n";
            }
            continue;
        }
        $tmp->ksort();
        foreach ($tmp as $category => $block) {
            if (DEBUGGING) {
                echo '>> ' . $category . "\r\n";
            }
            if ($category == 'delay') {
                continue;
            }
            if (!$block instanceof TreeNode) {
                // Prolly UOL
                $block = $tmp[$category];
                if ($block === null) {
                    if (DEBUGGING) {
                        echo 'UOL not found for ' . $key . ' -> ' . $category . "\r\n";
                    }
                    continue;
                }
            }
            if (!$block instanceof TreeNode) {
                if (DEBUGGING) {
                    echo 'Thats not a TreeNode! ' . $key . ' -> ' . $category . "\r\n";
                }
                continue;
            }
            if ($block === null) {
                if (DEBUGGING) {
                    echo 'thing not found for ' . $key . ' -> ' . $category . "\r\n";
                }
                continue;
            }
            $tmptmp = $block;
            $imgkey = '';
            $blockname = '';
            while (true) {
                $imgkey = $tmptmp->name . ($imgkey == '' ? '' : '.' . $imgkey);
                $blockname = $tmptmp->name;
                if (!isset($tmptmp['..'])) {
                    break;
                }
                if ($tmptmp['..']->isroot) {
                    break;
                }
                if ($tmptmp['..']->name == 'main') {
                    break;
                }
                $tmptmp = $tmptmp['..'];
            }
            $imgkey = str_replace('.origin', '', $imgkey);
            if (!isset($block['z'], $zmap[$block['z']])) {
                if (DEBUGGING) {
                    echo 'No Z key found for ' . $key . ' -> ' . $category . ' -> ' . $block->name . ' (' . $item_raw_type . ') -- ' . $block->ToAbsoluteURI() . ' - ' . "\r\n";
                }
                if ($item_raw_type == 21) {
                    if (DEBUGGING) {
                        echo 'Fixing Z index for face. Its face.' . "\r\n";
                    }
                    $zval = $zmap['face'];
                } else {
                    continue;
                }
            } else {
                $zval = $zmap[$block['z']];
            }
            if (DEBUGGING) {
                echo $id . ' - ' . $itemtype . ' - ' . $key . ' - ' . $category . ' - ' . $zval . "\r\n";
            }
            if ($itemtype == 2 && $key != $options['face'] && $options['stance'] != 'rope') {
                if (DEBUGGING) {
                    echo "nope1" . $key . " : " . $options['face'] . "\r\n";
                }
                continue 2;
            }
            if ($itemtype == 1 && $category == 'ear' && !$options['elven_ears']) {
                // Android / Merc!
                if (DEBUGGING) {
                    echo "nope2\r\n";
                }
                continue;
            }
            if ($itemtype != 2 && $key != $options['stance'] && $key != $options['face']) {
                if (DEBUGGING) {
                    echo "nope3:" . $key . " : " . $options['stance'] . " : " . $options['face'] . "\r\n";
                }
                continue 2;
            }
            if ($itemtype == 121 && $category != 'weapon') {
                if (DEBUGGING) {
                    echo "nope4\r\n";
                }
                continue 2;
            }
            if ($itemtype == 190) {
                if (DEBUGGING) {
                    echo "nope5\r\n";
                }
                continue 2;
            }
            $objectdata = array('info' => $block, 'type' => $itemtype, 'itemid' => $iteminfo['ITEMID'], 'stance' => $blockname, 'category' => $category, 'vslot' => isset($iteminfo['info']['vslot']) ? $iteminfo['info']['vslot'] : array(), 'islot' => isset($iteminfo['info']['islot']) ? $iteminfo['info']['islot'] : 'characterStart');
            $x = $imageoptions['mainx'];
            $y = $imageoptions['mainy'];
            $mappings = $objectdata['info']['map'];
            if (!isset($mappings)) {
                continue;
            }
            $copy = $mappings->getArrayCopy();
            krsort($copy);
            foreach ($copy as $mapname => $mapping) {
                if (!isset($data_buffer['body_map'][$mapname])) {
                    $data_buffer['body_map'][$mapname][0] = $x + $mapping['X'];
                    $data_buffer['body_map'][$mapname][1] = $y + $mapping['Y'];
                } else {
                    $x = $data_buffer['body_map'][$mapname][0] - $mapping['X'];
                    $y = $data_buffer['body_map'][$mapname][1] - $mapping['Y'];
                }
            }
            if (DEBUGGING) {
                echo 'Final map ' . $x . ', ' . $y . "\r\n";
            }
            $objectdata['x'] = $x;
            $objectdata['y'] = $y;
            $objectdata['image'] = $imgkey . '.png';
            if (DEBUGGING) {
                echo 'Image ' . $objectdata['image'] . "\r\n";
            }
            $foundinfo = true;
            $data_buffer['zlayers'][$zval][] = $objectdata;
            if (strpos($objectdata['islot'], 'Cp') !== false && in_array('H1', $objectdata['vslot'])) {
                $foundHidingCap = true;
            }
        }
    }
    if ($foundinfo) {
        $data_buffer['item_locations'][$id] = GetItemDataLocation($data_buffer['main-dir'], $id);
    }
}
function GetID($var, $adm = true)
{
    $de = bindechex($var, 3);
    $num = strlen($de);
    $num2 = $num - 2;
    $num3 = $num2 - 2;
    $type = substr($de, $num2 - 2, $num2);
    $type = GetItemType(substr($type, 0, 2));
    $item = substr($de, 0, $num2 - 2);
    $code = bindechex($item, 5);
    if ($type == '') {
        return lang('off_emptyslot');
    } else {
        return GetItemID(GetTableName($type), $code, $adm);
    }
}
    } elseif ($row2['slot'] == -105) {
        // Cash Shirt
        if (GetItemType($itemid) == 105 && isset($shown_items[6])) {
            // Is a cash overall and has pants
            unset($shown_items[6]);
        }
        // Unset pants
    }
}
if (!isset($shown_items[5])) {
    if (DEBUGGING) {
        echo 'Missing slot 5 equip, setting shirt.' . "\r\n";
    }
    $shown_items[5] = $gender == 0 ? 1060026 : 1061039;
}
if (!isset($shown_items[6]) && GetItemType($shown_items[5]) != 105) {
    if (DEBUGGING) {
        echo 'Missing slot 6 equip, setting pants.' . "\r\n";
    }
    $shown_items[6] = $gender == 0 ? 1040036 : 1041046;
}
$character_equipment->free();
if ($char_stance == 'stand' || $char_stance == 'walk') {
    $char_stance .= $stand;
}
if (DEBUGGING) {
    //print_r($shown_items);
}
$request_info = array();
$request_info['slots'] = array();
$request_info['slots'][] = $skin;
Example #5
0
function GetItemDataLocation($location, $id)
{
    $inv = GetItemInventory($id);
    $type = GetItemType($id);
    if ($type == 996) {
        $url = $location . 'Character/Familiar/' . str_pad($id, 7, '0', STR_PAD_LEFT) . '.img/';
    } elseif ($type < 5) {
        switch ($type) {
            case 0:
            case 1:
                $url = $location . 'Character/' . str_pad($id, 8, '0', STR_PAD_LEFT) . '.img/';
                break;
            case 2:
                $url = $location . 'Character/Face/' . str_pad($id, 8, '0', STR_PAD_LEFT) . '.img/';
                break;
            case 3:
                $url = $location . 'Character/Hair/' . str_pad($id, 8, '0', STR_PAD_LEFT) . '.img/';
                break;
        }
    } elseif ($inv == 1) {
        $name = GetWZItemTypeName($id);
        $url = $location . 'Character/' . $name . '/' . str_pad($id, 8, '0', STR_PAD_LEFT) . '.img/';
    } else {
        if ($type == 500) {
            $url = $location . 'Inventory/Pet/' . $id . '.img/';
        } else {
            $typeid = str_pad($type, 4, '0', STR_PAD_LEFT) . '.img';
            $typename = '';
            switch (floor($type / 100)) {
                case 2:
                    $typename = 'Consume';
                    break;
                case 3:
                    $typename = 'Install';
                    break;
                case 4:
                    $typename = 'Etc';
                    break;
                case 5:
                    $typename = 'Cash';
                    break;
            }
            $url = $location . 'Inventory/' . $typename . '/' . $typeid . '/' . str_pad($id, 8, '0', STR_PAD_LEFT) . '/';
        }
    }
    return $url;
}