function creatureinfo($id) { global $DB; global $npc_cols; $row = $DB->selectRow(' SELECT ?#, c.entry { , l.name_loc' . $_SESSION['locale'] . ' as `name_loc` , l.subname_loc' . $_SESSION['locale'] . ' as `subname_loc` , ? } FROM ?_factiontemplate, creature_template c { LEFT JOIN (locales_creature l) ON l.entry=c.entry AND ? } WHERE c.entry = ?d AND factiontemplateID = faction_A LIMIT 1 ', $npc_cols[0], $_SESSION['locale'] > 0 ? 1 : DBSIMPLE_SKIP, $_SESSION['locale'] > 0 ? 1 : DBSIMPLE_SKIP, $id); return creatureinfo2($row); }
SELECT ?#, c.entry {, l.name_loc?d AS `name_loc`, l.subname_loc' . $_SESSION['locale'] . ' AS `subname_loc`} FROM ?_factiontemplate, creature_template c {LEFT JOIN (locales_creature l) ON l.entry=c.entry AND ?d} WHERE (name LIKE ? OR subname LIKE ? {OR c.entry IN (?a)}) AND factiontemplateID=faction_A ', $npc_cols[0], $m ? $_SESSION['locale'] : DBSIMPLE_SKIP, $m ? 1 : DBSIMPLE_SKIP, $nsearch, $nsearch, $m ? $m : DBSIMPLE_SKIP); unset($m); unset($t); unset($tmp); foreach ($rows as $numRow => $row) { $found['npc'][] = creatureinfo2($row); } // Ищем объекты if ($_SESSION['locale'] > 0) { $tmp = $DB->select(' SELECT entry FROM locales_gameobject WHERE name_loc?d LIKE ? ', $_SESSION['locale'], $nsearch); foreach ($tmp as $t) { $m[] = $t['entry']; } } $rows = $DB->select(' SELECT g.?#
SELECT c.?#, c.entry { , l.name_loc?d AS name_loc , l.subname_loc?d AS subname_loc } FROM ?_factiontemplate, creature_template c { LEFT JOIN (locales_creature l) ON l.entry=c.entry AND ? } WHERE factiontemplateID=faction_A {AND type=?} ORDER BY minlevel DESC, name {LIMIT ?d} ', $npc_cols[0], $_SESSION['locale'] > 0 ? $_SESSION['locale'] : DBSIMPLE_SKIP, $_SESSION['locale'] > 0 ? $_SESSION['locale'] : DBSIMPLE_SKIP, $_SESSION['locale'] > 0 ? 1 : DBSIMPLE_SKIP, $type != '' ? $type : DBSIMPLE_SKIP, $AoWoWconf['limit'] != 0 ? $AoWoWconf['limit'] : DBSIMPLE_SKIP); $npcs = array(); foreach ($rows as $row) { $npcs[] = creatureinfo2($row); } save_cache(NPC_LISTING, $cache_key, $npcs); } if (!($npc_tot = load_cache(NPC_TOT, 'npc_tot'))) { unset($npc_tot); $npc_tot = $DB->select(' SELECT COUNT(entry) as npc_tot FROM creature_template c '); save_cache(NPC_TOT, 'npc_tot', $npc_tot); } global $page; $page = array('Mapper' => false, 'Book' => false, 'Title' => $smarty->get_config_vars('NPCs'), 'tab' => 0, 'type' => 0, 'typeid' => 0, 'username' => $_SESSION['username'], 'path' => path(0, 4, $type)); $smarty->assign('page', $page); $smarty->assign('npcs', $npcs);
SELECT c.?#, c.entry { , l.name_loc?d as `name_loc` , l.subname_loc' . $_SESSION['locale'] . ' as `subname_loc` } FROM ?_factiontemplate, creature_template c { LEFT JOIN (locales_creature l) ON l.entry=c.entry AND ? } WHERE 1=1 {AND type=?} {AND family=?} AND factiontemplateID=faction_A ORDER BY minlevel DESC, name {LIMIT ?d} ', $npc_cols[0], $_SESSION['locale'] > 0 ? $_SESSION['locale'] : DBSIMPLE_SKIP, $_SESSION['locale'] > 0 ? 1 : DBSIMPLE_SKIP, $type != '' ? $type : DBSIMPLE_SKIP, isset($family) ? $family : DBSIMPLE_SKIP, $AoWoWconf['limit'] != 0 ? $AoWoWconf['limit'] : DBSIMPLE_SKIP); $npcs = array(); foreach ($rows as $numRow => $row) { $npcs[$numRow] = array(); $npcs[$numRow] = creatureinfo2($row); } save_cache(5, $cache_str, $npcs); } global $page; $page = array('Mapper' => false, 'Book' => false, 'Title' => $smarty->get_config_vars('NPCs'), 'tab' => 0, 'type' => 0, 'typeid' => 0, 'path' => '[0, 4,' . $type . ',' . $family . ']'); $smarty->assign('page', $page); if (count($npcs >= 0)) { $smarty->assign('npcs', $npcs); } // Количество MySQL запросов $smarty->assign('mysql', $DB->getStatistics()); // Загружаем страницу $smarty->display('npcs.tpl');
$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); } unset($creature_rows); } // Квесты для этой фракции $quests_rows = $DB->select(' SELECT ?# FROM quest_template WHERE RewRepFaction1=?d OR RewRepFaction2=?d OR RewRepFaction3=?d OR RewRepFaction4=?d ', $quest_cols[2], $id, $id, $id, $id); if ($quests_rows) { $faction['quests'] = array();
$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['npcs'] = array(); foreach ($creature_rows as $i => $row) { $faction['npcs'][] = creatureinfo2($row); } unset($creature_rows); } // Квесты для этой фракции $quests_rows = $DB->select(' SELECT ?# FROM quest_template WHERE RewRepFaction1=?d OR RewRepFaction2=?d OR RewRepFaction3=?d OR RewRepFaction4=?d ', $quest_cols[2], $id, $id, $id, $id); if ($quests_rows) { $faction['quests'] = array();
$item['skinnedfrom'] = array(); foreach ($drops_sk as $lootid => $drop) { $rows = $DB->select(' SELECT c.?#, c.entry { , l.name_loc?d as `name_loc` , l.subname_loc' . $_SESSION['locale'] . ' as `subname_loc` } FROM ?_udwbase_factiontemplate, ?_creature_template c { LEFT JOIN (?_locales_creature l) ON l.entry=c.entry AND ? } WHERE skinloot=?d AND factiontemplateID=faction_A ', $npc_cols[0], $_SESSION['locale'] > 0 ? $_SESSION['locale'] : DBSIMPLE_SKIP, $_SESSION['locale'] > 0 ? 1 : DBSIMPLE_SKIP, $lootid); foreach ($rows as $numRow => $row) { $item['skinnedfrom'][] = array_merge(creatureinfo2($row), $drop); } } unset($rows); unset($lootid); unset($drop); } unset($drops_sk); // Дизенчантитcя в: if (!($item['disenchanting'] = loot('?_disenchant_loot_template', $item['DisenchantID']))) { unset($item['disenchanting']); } // Получается дизэнчантом из.. $drops_de = drop('?_disenchant_loot_template', $item['entry']); if ($drops_de) { $item['disenchantedfrom'] = array();
$usedbynpc = $DB->select(' SELECT ?#, c.entry { , name_loc?d AS name_loc, subname_loc' . $_SESSION['locale'] . ' AS subname_loc } FROM ?_factiontemplate, creature_template c { LEFT JOIN (locales_creature l) ON c.entry = l.entry AND ? } WHERE (spell1 = ?d OR spell2 = ?d OR spell3 = ?d OR spell4 = ?d) AND factiontemplateID=faction_A ', $npc_cols[0], $_SESSION['locale'] > 0 ? $_SESSION['locale'] : DBSIMPLE_SKIP, $_SESSION['locale'] > 0 ? 1 : DBSIMPLE_SKIP, $spell['entry'], $spell['entry'], $spell['entry'], $spell['entry']); if ($usedbynpc) { $spell['usedbynpc'] = array(); foreach ($usedbynpc as $i => $row) { $spell['usedbynpc'][] = creatureinfo2($row); } 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();
} unset($taughtbyquest); } // Список НПЦ, кастующих нужный спелл, бла-бла-бла $taughtbytrainers = $DB->select(' SELECT ?#, c.entry { , name_loc?d AS name_loc, subname_loc' . $_SESSION['locale'] . ' AS subname_loc } FROM ?_factiontemplate, creature_template c { LEFT JOIN (locales_creature l) ON c.entry = l.entry AND ? } WHERE c.entry IN (SELECT entry FROM npc_trainer WHERE spell in (?a)) AND factiontemplateID=faction_A ', $npc_cols[0], $_SESSION['locale'] > 0 ? $_SESSION['locale'] : DBSIMPLE_SKIP, $_SESSION['locale'] > 0 ? 1 : DBSIMPLE_SKIP, $taughtbyspells); if ($taughtbytrainers) { foreach ($taughtbytrainers as $i => $npcrow) { $spell['taughtbynpc'][] = creatureinfo2($npcrow); } unset($taughtbytrainers); } // Список книг, кастующих спелл, обучающий нужному спеллу $taughtbyitem = $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 IN (?a)) OR (spellid_2 IN (?a)) OR (spellid_3 IN (?a)) OR (spellid_4 IN (?a)) OR (spellid_5 IN (?a)))