Example #1
0
function iteminfo2(&$Row, $level = 0)
{
    global $DB;
    global $allitems;
    global $spell_cols;
    global $object_cols;
    $item = array();
    // Номер вещи
    $item['entry'] = $Row['entry'];
    // Название вещи
    $item['name'] = localizedName($Row);
    // Тип вещи
    $item['type'] = $Row['InventoryType'];
    $item['displayid'] = $Row['displayid'];
    // Уровень вещи
    $item['level'] = $Row['ItemLevel'];
    // Качество вещи...
    $item['quality'] = $Row['quality'];
    $item['quality2'] = 7 - $Row['quality'];
    // Требуемый уровень вещи:
    $item['reqlevel'] = $Row['RequiredLevel'];
    // Класс и подкласс вещи
    // TODO: немного неверное определение
    $item['classs'] = $Row['class'];
    $item['subclass'] = $Row['subclass'];
    $item['rclass'] = $Row['AllowableClass'];
    // Иконка вещи
    $item['iconname'] = $Row['iconname'];
    // Кол-во вещей в пачке
    $item['stackable'] = $Row['stackable'];
    // Стоимость вещи для покупки
    // DPS
    $dps = 0;
    if ($Row['class'] == 2) {
        for ($i = 1; $i <= 2; $i++) {
            $d_type = $Row['dmg_type' . $i];
            $d_min = $Row['dmg_min' . $i];
            $d_max = $Row['dmg_max' . $i];
            if ($d_max > 0 and $Row['class'] != 6) {
                $delay = $Row['delay'] / 1000;
                if ($delay > 0) {
                    $dps = $dps + round(($d_max + $d_min) / (2 * $delay), 1);
                }
            }
        }
        $item['dps'] = $dps;
        $item['speed'] = $Row['delay'] / 1000;
        if (!$item['speed']) {
            $item['speed'] = -1;
        }
    }
    // Armor
    $item['armor'] = $Row['armor'];
    $item['slot'] = $Row['InventoryType'];
    // Bag
    if ($Row['class'] == 1) {
        $item['slots'] = $Row['ContainerSlots'];
    }
    // Добавляем в глобальный массив allitems
    allitemsinfo2($Row, 0);
    if ($level > 0) {
        $item['BuyPrice'] = $Row['BuyPrice'];
        //
        $item['BagFamily'] = $Row['BagFamily'];
        $item['ContainerSlots'] = $Row['ContainerSlots'];
        $item['DisenchantID'] = $Row['DisenchantID'];
        // Навык энчанта для разборки вещи
        if ($Row['RequiredDisenchantSkill'] != -1) {
            $item['disenchantskill'] = $Row['RequiredDisenchantSkill'];
        }
        // Цена на продажу
        $item['sellgold'] = floor($Row['SellPrice'] / 10000);
        $item['sellsilver'] = floor($Row['SellPrice'] % 10000 / 100);
        $item['sellcopper'] = floor($Row['SellPrice'] % 100);
        // Цена за покупку
        $item['buygold'] = floor($Row['BuyPrice'] / 10000);
        $item['buysilver'] = floor($Row['BuyPrice'] % 10000 / 100);
        $item['buycopper'] = floor($Row['BuyPrice'] % 100);
        // Начинает квест
        if ($Row['startquest']) {
            $item['starts'] = array(GetDBQuestInfo($Row['startquest'], 0xffffff));
        }
        // Информационное окно
        $item['info'] = render_item_tooltip($Row);
        // Обучает
        $teaches = array();
        for ($j = 1; $j <= 4; $j++) {
            if ($Row['spellid_' . $j] == 483) {
                $teaches[] = spellinfo($Row['spellid_' . ($j + 1)]);
            }
        }
        if ($teaches) {
            $item['teaches'] = $teaches;
            unset($teaches);
            unset($spellrow);
        }
        // Открывает:
        // Тип замков, для которых этот предмет является ключем:
        $locks_row = $DB->selectCol('
			SELECT lockID
			FROM ?_lock
			WHERE
				(type1=1 AND lockproperties1=?d) OR
				(type2=1 AND lockproperties2=?d) OR
				(type3=1 AND lockproperties3=?d) OR
				(type4=1 AND lockproperties4=?d) OR
				(type5=1 AND lockproperties5=?d)
			', $item['entry'], $item['entry'], $item['entry'], $item['entry'], $item['entry']);
        if ($locks_row) {
            // Игровые объекты с таким типом замка:
            $item['unlocks'] = $DB->select('
				SELECT ?#
				FROM gameobject_template
				WHERE
					(
						((type IN (?a)) AND (data0 IN (?a)))
					OR
						((type IN (?a)) AND (data0 IN (?a)))
					)
				', $object_cols[0], array(GAMEOBJECT_TYPE_QUESTGIVER, GAMEOBJECT_TYPE_CHEST, GAMEOBJECT_TYPE_TRAP, GAMEOBJECT_TYPE_GOOBER, GAMEOBJECT_TYPE_CAMERA, GAMEOBJECT_TYPE_FLAGSTAND, GAMEOBJECT_TYPE_FLAGDROP), $locks_row, array(GAMEOBJECT_TYPE_DOOR, GAMEOBJECT_TYPE_BUTTON), $locks_row);
            if (!$item['unlocks']) {
                unset($item['unlocks']);
            }
        }
        unset($locks_row);
    }
    return $item;
}
                }
            }
        }
        for ($j = 1; $j < 4; $j++) {
            $tmp2 = $DB->select('
				SELECT action?d_param1
				FROM ?_creature_ai_scripts
				WHERE
					creature_id=?d
					AND action?d_type=11
				', $j, $npc['entry'], $j);
            if ($tmp2) {
                foreach ($tmp2 as $i => $tmp3) {
                    if (!in_array($tmp2[$i]['action' . $j . '_param1'], $tmp)) {
                        $tmp[] = $tmp2[$i]['action' . $j . '_param1'];
                        if ($data = spellinfo($tmp2[$i]['action' . $j . '_param1'], 0)) {
                            if ($data['name']) {
                                $npc['abilities'][] = $data;
                            }
                        }
                    }
                }
            }
        }
        if (!$npc['ablities']) {
            unset($npc['ablities']);
        }
    }
    // Обучает:
    // Если это пет со способностью:
    $row = $DB->selectRow('