Ejemplo n.º 1
0
function iteminfo($id, $level = 0)
{
    global $item_cols;
    global $DB;
    $row = $DB->selectRow('
		SELECT i.?#, i.entry
		{
			, l.name_loc?d AS name_loc
			, l.description_loc?d AS description_loc
		}
		FROM ?_icons, item_template i
		{ LEFT JOIN (locales_item l) ON l.entry=i.entry AND ? }
		WHERE
			(i.entry=?d and id=displayid)
		LIMIT 1
		', $item_cols[2 + $level], $_SESSION['locale'] > 0 ? $_SESSION['locale'] : DBSIMPLE_SKIP, $_SESSION['locale'] > 0 ? $_SESSION['locale'] : DBSIMPLE_SKIP, $_SESSION['locale'] > 0 ? 1 : DBSIMPLE_SKIP, $id);
    return iteminfo2($row, $level);
}
Ejemplo n.º 2
0
function loot_table($table, $lootid, $max_percent = 100)
{
    // Все элементы
    global $DB;
    global $loot_groups;
    global $item_cols;
    $loot = array();
    $groups = array();
    // Мего запрос :)
    $rows = $DB->select('
		SELECT l.Chance, l.MinCount, l.MaxCount as `d-max`, l.groupid, ?#, i.Entry, i.MaxCount
			{, loc.name_loc?d AS `name_loc`}
		FROM ?# l
			LEFT JOIN (?_icons a, item_template i) ON l.item=i.entry AND a.id=i.displayid
			{LEFT JOIN (locales_item loc) ON loc.entry=i.entry AND ?d}
		WHERE
			l.entry=?d
		{LIMIT ?d}
		', $item_cols[2], $_SESSION['locale'] ? $_SESSION['locale'] : DBSIMPLE_SKIP, $table, $_SESSION['locale'] ? 1 : DBSIMPLE_SKIP, $lootid, $AoWoWconf['limit'] != 0 ? $AoWoWconf['limit'] : DBSIMPLE_SKIP);
    // Перебираем
    foreach ($rows as $i => $row) {
        if ($row['mincountOrRef'] > 0) {
            // Не ссылка!
            if ($row['groupid'] > 0) {
                // Групповой лут!
                $groups[$row['groupid']][] = array('mincount' => $row['mincountOrRef'], 'maxcount' => $row['d-max'], 'percent' => $row['ChanceOrQuestChance'] * $max_percent / 100, 'item' => iteminfo2($row, 0));
                // Общее число элементов группы с равнозначным шансом
                if (!isset($group_idx[$row['groupid']]['num-equal'])) {
                    $group_idx[$row['groupid']]['num-equal'] = 0;
                }
                // Общий шанс дропа для группового лута
                if (!isset($group_idx[$row['groupid']]['percent'])) {
                    $group_idx[$row['groupid']]['percent'] = 0;
                }
                // Если шанс дропа=0, значит это равнозначный лут в группе
                // Иначе, увеличиваем зарезервированный шанс для элементов лута с четко определенным шансом дропа
                if ($row['ChanceOrQuestChance'] == 0) {
                    $group_idx[$row['groupid']]['num-equal']++;
                } else {
                    $group_idx[$row['groupid']]['percent'] += abs($row['ChanceOrQuestChance']);
                }
            } else {
                // Старый добрый обычный лут :)
                $loot[] = array_merge(array('percent' => $max_percent != 100 ? $max_percent : $row['ChanceOrQuestChance'], 'mincount' => $row['mincountOrRef'], 'maxcount' => $row['d-max'], 'group' => 0), iteminfo2($row, 0));
            }
        } else {
            // Ссылка!
            // Вот если это ссылка, то ######
            // Наша задача - вызвать эту же функцию, но с предопределенным значением percent и maxcount
            for ($j = 1; $j <= $row['d-max']; $j++) {
                $loot = array_merge($loot, loot_table($table, -$row['mincountOrRef'], $row['ChanceOrQuestChance']));
            }
        }
    }
    // Перебираем группы лута
    foreach ($groups as $groupid => $group) {
        foreach ($group as $field => $group_item) {
            if (isset($group_item['item'])) {
                $loot[] = array_merge(array('mincount' => $group_item['mincount'], 'maxcount' => $group_item['maxcount'], 'percent' => $group_item['percent'] == 0 ? ($max_percent - $group_idx[$groupid]['percent']) / $group_idx[$groupid]['num-equal'] : $group_item['percent'], 'group' => $loot_groups, 'grouppercent' => $group_idx[$groupid]['num-equal'] > 0 ? $max_percent : $group_idx[$groupid]['percent']), $group_item['item']);
            }
        }
        $loot_groups++;
    }
    return $loot;
}
Ejemplo n.º 3
0
    }
}
$rows = $DB->select('
		SELECT i.?#
			{, l.name_loc?d AS `name_loc`}
		FROM ?_icons a, item_template i
			{LEFT JOIN (locales_item l) ON l.entry=i.entry AND ?d}
		WHERE
			(i.name LIKE ? {OR i.entry IN (?a)})
			AND a.id = i.displayid;
	', $item_cols[3], $m ? $_SESSION['locale'] : DBSIMPLE_SKIP, $m ? 1 : DBSIMPLE_SKIP, $nsearch, $m ? $m : DBSIMPLE_SKIP);
unset($m);
unset($t);
unset($tmp);
foreach ($rows as $numRow => $row) {
    $found['item'][] = iteminfo2($row);
}
// Ищем NPC:
if ($_SESSION['locale'] > 0) {
    $tmp = $DB->select('
			SELECT entry
			FROM locales_creature
			WHERE
				name_loc?d LIKE ?
				OR subname_loc?d LIKE ?
		', $_SESSION['locale'], $nsearch, $_SESSION['locale'], $nsearch);
    foreach ($tmp as $t) {
        $m[] = $t['entry'];
    }
}
$rows = $DB->select('
Ejemplo n.º 4
0
        // Альянс(1)/Орда(2)
        if ($row['side'] != 0) {
            $faction['side'] = $row['side'];
        }
        // Итемы с requiredreputationfaction
        $item_rows = $DB->select('
			SELECT ?#, entry
			FROM item_template i, ?_icons a
			WHERE
				i.RequiredReputationFaction=?d
				AND a.id=i.displayid
			', $item_cols[2], $id);
        if ($item_rows) {
            $faction['items'] = array();
            foreach ($item_rows as $i => $row) {
                $faction['items'][] = iteminfo2($row, 0);
            }
            unset($faction['items']);
        }
        // Персонажи, состоящие во фракции
        $creature_rows = $DB->select('
			SELECT ?#, entry
			FROM creature_template, ?_factiontemplate
			WHERE
				faction_A IN (SELECT factiontemplateID FROM ?_factiontemplate WHERE factionID=?d)
				AND factiontemplateID=faction_A
			', $npc_cols[0], $id);
        if ($creature_rows) {
            $faction['creatures'] = array();
            foreach ($creature_rows as $i => $row) {
                $faction['creatures'][] = creatureinfo2($row);
    // Продает:
    $rows_s = $DB->select('
		SELECT ?#, i.entry, i.maxcount, n.`maxcount` as `drop-maxcount`
			{, l.name_loc?d AS `name_loc`}
		FROM ?_npc_vendor n, ?_aowow_icons, ?_item_template i
			{LEFT JOIN (?_locales_item l) ON l.entry=i.entry AND ?d}
		WHERE
			n.entry=?
			AND i.entry=n.item
			AND id=i.displayid
		', $item_cols[2], $_SESSION['locale'] ? $_SESSION['locale'] : DBSIMPLE_SKIP, $_SESSION['locale'] ? 1 : DBSIMPLE_SKIP, $id);
    if ($rows_s) {
        $npc['sells'] = array();
        foreach ($rows_s as $numRow => $row) {
            $npc['sells'][$numRow] = array();
            $npc['sells'][$numRow] = iteminfo2($row);
            $npc['sells'][$numRow]['maxcount'] = $row['drop-maxcount'];
            $npc['sells'][$numRow]['cost'] = array();
            /* if ($row['ExtendedCost']) [NOTE] overwrite with honor points? 
               {
               $extcost = $DB->selectRow('SELECT * FROM ?_aowow_item_extended_cost WHERE extendedcostID=?d LIMIT 1', $row['ExtendedCost']);
               if ($extcost['reqhonorpoints']>0)
               $npc['sells'][$numRow]['cost']['honor'] = (($npc['A']==1)? 1: -1) * $extcost['reqhonorpoints'];
               if ($extcost['reqarenapoints']>0)
               $npc['sells'][$numRow]['cost']['arena'] = $extcost['reqarenapoints'];
               $npc['sells'][$numRow]['cost']['items'] = array();
               for ($j=1;$j<=5;$j++)
               if (($extcost['reqitem'.$j]>0) and ($extcost['reqitemcount'.$j]>0))
               {
               allitemsinfo($extcost['reqitem'.$j], 0);
               $npc['sells'][$numRow]['cost']['items'][] = array('item' => $extcost['reqitem'.$j], 'count' => $extcost['reqitemcount'.$j]);
Ejemplo n.º 6
0
if (!($items = load_cache(7, $cache_key))) {
    unset($items);
    // Составляем запрос к БД, выполняющий поиск по заданным классу и подклассу
    $rows = $DB->select('
		SELECT ?#, i.entry, maxcount
			{, l.name_loc?d AS name_loc}
		FROM ?_icons, item_template i
			{LEFT JOIN (locales_item l) ON l.entry=i.entry AND ?d}
		WHERE
			id=displayid
			{ AND class = ? }
			{ AND subclass = ? }
			{ AND InventoryType = ? }
		ORDER BY quality DESC, name
		{ LIMIT ?d }
		', $item_cols[2], $_SESSION['locale'] ? $_SESSION['locale'] : DBSIMPLE_SKIP, $_SESSION['locale'] ? 1 : DBSIMPLE_SKIP, isset($class) ? $class : DBSIMPLE_SKIP, isset($subclass) ? $subclass : DBSIMPLE_SKIP, isset($type) ? $type : DBSIMPLE_SKIP, $AoWoWconf['limit'] != 0 ? $AoWoWconf['limit'] : DBSIMPLE_SKIP);
    $items = array();
    foreach ($rows as $row) {
        $items[] = iteminfo2($row);
    }
    save_cache(7, $cache_key, $items);
}
global $page;
$page = array('Mapper' => false, 'Book' => false, 'Title' => $smarty->get_config_vars('Items'), 'tab' => 0, 'type' => 0, 'typeid' => 0, 'path' => path(0, 0, $type, $subclass, $class));
$smarty->assign('page', $page);
// Статистика выполнения mysql запросов
$smarty->assign('mysql', $DB->getStatistics());
$smarty->assign('allitems', $allitems);
$smarty->assign('items', $items);
// Загружаем страницу
$smarty->display('items.tpl');
Ejemplo n.º 7
0
        $rows_cpi = $DB->select('
			SELECT c.?#, c.entry, maxcount
			{
				, l.name_loc?d as `name_loc`
			}
			FROM ?_udwbase_icons, ?_item_template c
			{ LEFT JOIN (?_locales_item l) ON l.entry=c.entry AND ? }
			WHERE
				BagFamily=?d
				AND ContainerSlots>0
				AND id=displayid
			', $item_cols[2], $_SESSION['locale'] > 0 ? $_SESSION['locale'] : DBSIMPLE_SKIP, $_SESSION['locale'] > 0 ? 1 : DBSIMPLE_SKIP, $item['BagFamily']);
        if ($rows_cpi) {
            $item['canbeplacedin'] = array();
            foreach ($rows_cpi as $numRow => $row) {
                $item['canbeplacedin'][] = iteminfo2($row, 0);
            }
        }
        unset($rows_cpi);
    }
    // Реагент для...
    $rows_r = $DB->select('
		SELECT ?#, spellID
		FROM ?_udwbase_spell s, ?_udwbase_spellicons i
		WHERE
			(( reagent1=?d
			OR reagent2=?d
			OR reagent3=?d
			OR reagent4=?d
			OR reagent5=?d
			OR reagent6=?d
Ejemplo n.º 8
0
			{LEFT JOIN (locales_item l) ON l.entry=i.entry AND ?d}
		WHERE (iec.reqitem1=?
		   OR iec.reqitem2=?
		   OR iec.reqitem3=?
		   OR iec.reqitem4=?
		   OR iec.reqitem5=?)
		  AND iec.extendedcostID=ABS(n.ExtendedCost)
		  AND i.entry=n.item
		  AND id=i.displayid
		', $item_cols[2], $_SESSION['locale'] ? $_SESSION['locale'] : DBSIMPLE_SKIP, $_SESSION['locale'] ? 1 : DBSIMPLE_SKIP, $item['entry'], $item['entry'], $item['entry'], $item['entry'], $item['entry']);
    if ($rows_cf) {
        $item['currencyfor'] = array();
        foreach ($rows_cf as $row) {
            $id = $row['entry'];
            $item['currencyfor'][$id] = array();
            $item['currencyfor'][$id] = iteminfo2($row);
            $item['currencyfor'][$id]['maxcount'] = $row['drop-maxcount'];
            $item['currencyfor'][$id]['cost'] = array();
            if ($row['BuyPrice'] > 0) {
                $npc['sells'][$id]['cost']['money'] = $row['BuyPrice'];
            }
            if ($row['reqhonorpoints'] > 0) {
                $item['currencyfor'][$id]['cost']['honor'] = $row['reqhonorpoints'];
            }
            //FIXME_BUG
            if ($row['reqarenapoints'] > 0) {
                $item['currencyfor'][$id]['cost']['arena'] = $row['reqarenapoints'];
            }
            $item['currencyfor'][$id]['cost']['items'] = array();
            for ($j = 1; $j <= 5; $j++) {
                if ($row['reqitem' . $j] > 0 and $row['reqitemcount' . $j] > 0) {
Ejemplo n.º 9
0
Archivo: item.php Proyecto: Reved/aowow
    if ($drops_mi) {
        $item['milledfrom'] = array();
        foreach ($drops_mi as $lootid => $drop) {
            $rows = $DB->select('
					SELECT c.?#, c.entry, maxcount
					{
						, l.name_loc?d AS name_loc
					}
					FROM ?_icons, item_template c
					{ LEFT JOIN (locales_item l) ON l.entry=c.entry AND ? }
					WHERE
						c.entry=?d
						AND id=displayid
				', $item_cols[2], $_SESSION['locale'] > 0 ? $_SESSION['locale'] : DBSIMPLE_SKIP, $_SESSION['locale'] > 0 ? 1 : DBSIMPLE_SKIP, $lootid);
            foreach ($rows as $row) {
                $item['milledfrom'][] = array_merge(iteminfo2($row, 0), $drop);
            }
        }
        unset($rows);
        unset($lootid);
        unset($drop);
    }
    unset($drops_mi);
    // Цель критерии
    $rows = $DB->select('
			SELECT a.id, a.faction, a.name_loc?d AS name, a.description_loc?d AS description, a.category, a.points, s.iconname, z.areatableID
			FROM ?_spellicons s, ?_achievementcriteria c, ?_achievement a
			LEFT JOIN (?_zones z) ON a.map != -1 AND a.map = z.mapID
			WHERE
				a.icon = s.id
				AND a.id = c.refAchievement
Ejemplo n.º 10
0
            unset($usedbynpc);
        }
        // Используется вещями:
        $usedbyitem = $DB->select('
			SELECT ?#, c.entry
			{ , name_loc?d AS name_loc }
			FROM ?_icons, item_template c
			{ LEFT JOIN (locales_item l) ON c.entry = l.entry AND ? }
			WHERE
				(spellid_1 = ?d OR (spellid_2 = ?d AND spelltrigger_2!=6) OR spellid_3 = ?d OR spellid_4 = ?d OR spellid_5 = ?d)
				AND id=displayID
			', $item_cols[2], $_SESSION['locale'] > 0 ? $_SESSION['locale'] : DBSIMPLE_SKIP, $_SESSION['locale'] > 0 ? 1 : DBSIMPLE_SKIP, $spell['entry'], $spell['entry'], $spell['entry'], $spell['entry'], $spell['entry']);
        if ($usedbyitem) {
            $spell['usedbyitem'] = array();
            foreach ($usedbyitem as $i => $row) {
                $spell['usedbyitem'][] = iteminfo2($row, 0);
            }
            unset($usedbyitem);
        }
        // Используется наборами вещей:
        $usedbyitemset = $DB->select('
			SELECT *
			FROM ?_itemset
			WHERE spell1 = ?d OR spell2 = ?d OR spell3 = ?d OR spell4 = ?d OR spell5 = ?d OR spell6 = ?d OR spell7 = ?d OR spell8 = ?d
			', $spell['entry'], $spell['entry'], $spell['entry'], $spell['entry'], $spell['entry'], $spell['entry'], $spell['entry'], $spell['entry']);
        if ($usedbyitemset) {
            $spell['usedbyitemset'] = array();
            foreach ($usedbyitemset as $i => $row) {
                $spell['usedbyitemset'][] = itemsetinfo2($row);
            }
            unset($usedbyitemset);
Ejemplo n.º 11
0
function loot($table, $lootid, $group = 0)
{
    global $DB, $item_cols;
    // Мего запрос :)
    $rows = $DB->select('
		SELECT l.ChanceOrQuestChance, l.mincountOrRef, l.maxcount as `d-max`, l.groupid, ?#, i.entry, i.maxcount
			{, loc.name_loc?d AS name_loc}
		FROM ?# l
			LEFT JOIN (?_icons a, item_template i) ON l.item=i.entry AND a.id=i.displayid
			{LEFT JOIN (locales_item loc) ON loc.entry=i.entry AND ?d}
		WHERE
			l.entry=?d
			AND l.entry <> 0
			{ AND l.groupid = ?d }
		{LIMIT ?d}
		', $item_cols[2], $_SESSION['locale'] ? $_SESSION['locale'] : DBSIMPLE_SKIP, $table, $_SESSION['locale'] ? 1 : DBSIMPLE_SKIP, $lootid, $group ? $group : DBSIMPLE_SKIP, $AoWoWconf['limit'] != 0 ? $AoWoWconf['limit'] : DBSIMPLE_SKIP);
    // Подсчитываем нужную информацию о группах
    $groupchance = array();
    $groupzero = array();
    foreach ($rows as $row) {
        if ($row['mincountOrRef'] >= 0) {
            $gid = $row['groupid'];
            if (!isset($groupchance[$gid])) {
                $groupchance[$gid] = 0;
            }
            if (!isset($groupzero[$gid])) {
                $groupzero[$gid] = 0;
            }
            if ($row['ChanceOrQuestChance'] == 0) {
                $groupzero[$gid]++;
            } else {
                $groupchance[$gid] += abs($row['ChanceOrQuestChance']);
            }
        }
    }
    // Присваиваем каждой группе номер от 1
    $maxgroup = 0;
    $groupnum = array();
    foreach ($groupchance as $id => $group) {
        if ($id) {
            $groupnum[$id] = ++$maxgroup;
        } else {
            $groupnum[$id] = "";
        }
    }
    // Cохраняем весь нессылочный лут
    $loot = array();
    foreach ($rows as $row) {
        if ($row['mincountOrRef'] > 0) {
            $chance = $row['ChanceOrQuestChance'];
            if ($chance == 0) {
                $chance = (100 - $groupchance[$row['groupid']]) / $groupzero[$row['groupid']];
                if ($chance < 0) {
                    $chance = 0;
                }
                if ($chance > 100) {
                    $chance = 100;
                }
            }
            $item = $row['entry'] . '.' . $row['groupid'];
            // Это чтобы отделить предметы в разных группах
            if (isset($loot[$item])) {
                $loot[$item]['mincount'] = min($row['mincountOrRef'], $loot[$item]['mincount']);
                if ($row['groupid']) {
                    $loot[$item]['maxcount'] = max($loot[$item]['maxcount'], $row['d-max']);
                } else {
                    $loot[$item]['maxcount'] = $loot[$item]['maxcount'] + $row['d-max'];
                }
                $loot[$item]['percent'] = 1 - (1 - abs($chance)) * (1 - abs($loot[$item]['percent']));
            } else {
                $loot[$item] = iteminfo2($row, 0);
                $loot[$item]['mincount'] = $row['mincountOrRef'];
                $loot[$item]['maxcount'] = $row['d-max'];
                $loot[$item]['percent'] = $chance;
                $loot[$item]['group'] = $groupnum[$row['groupid']];
                $loot[$item]['groupcount'] = 1;
            }
        }
    }
    // И наконец, добавляем весь лут со ссылок
    foreach ($rows as $row) {
        if ($row['mincountOrRef'] < 0) {
            $newmax = $maxgroup;
            $tmploots = loot('reference_loot_template', -$row['mincountOrRef'], $row['groupid']);
            foreach ($tmploots as $tmploot) {
                if ($tmploot['group']) {
                    $tmploot['group'] += $maxgroup;
                    if ($newmax < $tmploot['group']) {
                        $newmax = $tmploot['group'];
                    }
                    $tmploot['groupcount'] = $tmploot['groupcount'] * $row['d-max'];
                } else {
                    $tmploot['maxcount'] *= $row['d-max'];
                }
                $tmploot['percent'] *= abs($row['ChanceOrQuestChance']) / 100;
                $loot[] = $tmploot;
            }
            $maxgroup = $newmax;
        }
    }
    return $loot;
}
		SELECT ?#, i.entry, maxcount
			{, l.name_loc?d AS `name_loc`}
		FROM ?_aowow_icons, ?_item_template i
			{LEFT JOIN (?_locales_item l) ON l.entry=i.entry AND ?d}
		WHERE
			id=displayid
			{ AND class=? }
			{ AND subclass=? }
			ORDER BY quality DESC, name
			LIMIT 200
		', $item_cols[2], $_SESSION['locale'] ? $_SESSION['locale'] : DBSIMPLE_SKIP, $_SESSION['locale'] ? 1 : DBSIMPLE_SKIP, $class != '' ? $class : DBSIMPLE_SKIP, $subclass != '' ? $subclass : DBSIMPLE_SKIP);
    $i = 0;
    $items = array();
    foreach ($rows as $numRow => $row) {
        $items[$i] = array();
        $items[$i] = iteminfo2($row);
        $i++;
    }
    save_cache(7, $cache_str, $items);
}
global $page;
$page = array('Mapper' => false, 'Book' => false, 'Title' => $smarty->get_config_vars('Items'), 'tab' => 0, 'type' => 0, 'typeid' => 0, 'path' => "[0, 0, " . $class . ", " . $subclass . "]");
$smarty->assign('page', $page);
// Статистика выполнения mysql запросов
$smarty->assign('mysql', $DB->getStatistics());
// Если хоть одна информация о вещи найдена - передаём массив с информацией о вещях шаблонизатору
if (count($allitems) >= 0) {
    $smarty->assign('allitems', $allitems);
}
if (count($items >= 0)) {
    $smarty->assign('items', $items);
Ejemplo n.º 13
0
function loot($table, $lootid, $mod = 1)
{
    // Все элементы
    global $DB, $item_cols;
    $loot = array();
    $groups = array();
    // Мего запрос :)
    $rows = $DB->select('
		SELECT l.ChanceOrQuestChance, l.mincountOrRef, l.maxcount, l.groupid, ?#, i.entry
			{, loc.name_loc?d AS name_loc}
		FROM ?# l
			LEFT JOIN (?_icons a, item_template i) ON l.item=i.entry AND a.id=i.displayid
			{LEFT JOIN (locales_item loc) ON loc.entry=i.entry AND ?d}
		WHERE
			l.entry=?d
		ORDER BY groupid ASC, ChanceOrQuestChance DESC
		{LIMIT ?d}
		', $item_cols[2], $_SESSION['locale'] ? $_SESSION['locale'] : DBSIMPLE_SKIP, $table, $_SESSION['locale'] ? 1 : DBSIMPLE_SKIP, $lootid, $AoWoWconf['limit'] != 0 ? $AoWoWconf['limit'] : DBSIMPLE_SKIP);
    $last_group = 0;
    $last_group_equal_chance = 100;
    // Перебираем
    foreach ($rows as $row) {
        // Не группа
        if ($row['groupid'] == 0) {
            // Ссылка
            if ($row['mincountOrRef'] < 0) {
                add_loot($loot, loot('reference_loot_template', -$row['mincountOrRef'], abs($row['ChanceOrQuestChance']) / 100 * $row['maxcount'] * $mod));
            } else {
                // Обыкновенный дроп
                add_loot($loot, array(array_merge(array('percent' => max(abs($row['ChanceOrQuestChance']) * $mod, 0) * sign($row['ChanceOrQuestChance']), 'mincount' => $row['mincountOrRef'], 'maxcount' => $row['maxcount']), iteminfo2($row, 0))));
            }
        } else {
            $chance = abs($row['ChanceOrQuestChance']);
            // Новая группа?
            if ($row['groupid'] != $last_group) {
                $last_group = $row['groupid'];
                $last_group_equal_chance = 100;
            }
            // Шанс лута задан
            if ($chance > 0) {
                $last_group_equal_chance -= $chance;
                $last_group_equal_chance = max($last_group_equal_chance, 0);
                // Ссылка
                if ($row['mincountOrRef'] < 0) {
                    add_loot($loot, loot('reference_loot_template', -$row['mincountOrRef'], $chance / 100 * $row['maxcount'] * $mod));
                } else {
                    add_loot($loot, array(array_merge(array('percent' => $chance * $mod, 'mincount' => $row['mincountOrRef'], 'maxcount' => $row['maxcount']), iteminfo2($row, 0))));
                }
            } else {
                $groups[$last_group][] = array_merge(array('mincount' => $row['mincountOrRef'], 'maxcount' => $row['maxcount'], 'groupchance' => $last_group_equal_chance * $mod), iteminfo2($row, 0));
            }
        }
    }
    // Перебираем и добавляем группы
    foreach ($groups as $group) {
        $num = count($group);
        foreach ($group as $item) {
            $item['percent'] = $item['groupchance'] / $num;
            add_loot($loot, array($item));
        }
    }
    return $loot;
}
/**
 *
 * @param type $id
 * @param type $level
 * @return type 
 */
function iteminfo($id, $level = 0)
{
    global $item_cols;
    global $DB;
    $row = $DB->selectRow('
		SELECT i.?#, i.entry, maxcount
		{
			, l.name_loc' . $_SESSION['locale'] . ' as `name_loc`
			, l.description_loc' . $_SESSION['locale'] . ' as `description_loc`
			, ?
		}
		FROM ?_aowow_icons, ?_item_template i
		{ LEFT JOIN (?_locales_item l) ON l.entry=i.entry AND ? }
		WHERE
			(i.entry=?d and id=displayid)
		LIMIT 1
		', $item_cols[2 + $level], $_SESSION['locale'] > 0 ? 1 : DBSIMPLE_SKIP, $_SESSION['locale'] > 0 ? 1 : DBSIMPLE_SKIP, $id);
    return iteminfo2($row, $level);
}