| 1 | <?php
|
|---|
| 2 |
|
|---|
| 3 | require_once('includes/allspells.php');
|
|---|
| 4 | require_once('includes/allquests.php');
|
|---|
| 5 | require_once('includes/allnpcs.php');
|
|---|
| 6 | require_once('includes/allcomments.php');
|
|---|
| 7 |
|
|---|
| 8 | // Настраиваем Smarty ;)
|
|---|
| 9 | $smarty->config_load($conf_file, 'npc');
|
|---|
| 10 |
|
|---|
| 11 | global $DB;
|
|---|
| 12 | global $spell_cols;
|
|---|
| 13 | global $npc_cols;
|
|---|
| 14 |
|
|---|
| 15 | // Заголовок страницы
|
|---|
| 16 | $id = $podrazdel;
|
|---|
| 17 | if(!$npc = load_cache(1, intval($id)))
|
|---|
| 18 | {
|
|---|
| 19 | unset($npc);
|
|---|
| 20 | // Ищем NPC:
|
|---|
| 21 | $npc = array();
|
|---|
| 22 | $row = $DB->selectRow('
|
|---|
| 23 | SELECT
|
|---|
| 24 | ?#, c.entry, c.name,
|
|---|
| 25 | {
|
|---|
| 26 | l.name_loc'.$_SESSION['locale'].' as `name_loc`,
|
|---|
| 27 | l.subname_loc'.$_SESSION['locale'].' as `subname_loc`,
|
|---|
| 28 | ?,
|
|---|
| 29 | }
|
|---|
| 30 | f.name as `faction-name`, ft.factionID as `factionID`
|
|---|
| 31 | FROM ?_factiontemplate ft, ?_factions f, creature_template c
|
|---|
| 32 | {
|
|---|
| 33 | LEFT JOIN (locales_creature l)
|
|---|
| 34 | ON l.entry=c.entry AND ?
|
|---|
| 35 | }
|
|---|
| 36 | WHERE
|
|---|
| 37 | c.entry=?
|
|---|
| 38 | AND ft.factiontemplateID=c.faction_A
|
|---|
| 39 | AND f.factionID=ft.factionID
|
|---|
| 40 | LIMIT 1
|
|---|
| 41 | ',
|
|---|
| 42 | $npc_cols[1],
|
|---|
| 43 | ($_SESSION['locale']>0)? 1: DBSIMPLE_SKIP,
|
|---|
| 44 | ($_SESSION['locale']>0)? 1: DBSIMPLE_SKIP,
|
|---|
| 45 | $id
|
|---|
| 46 | );
|
|---|
| 47 |
|
|---|
| 48 | if ($row)
|
|---|
| 49 | {
|
|---|
| 50 | $npc = $row;
|
|---|
| 51 | $npc['name'] = $row['name_loc']?$row['name_loc']:$row['name'];
|
|---|
| 52 | $npc['subname'] = $row['subname_loc']?$row['subname_loc']:$row['subname'];
|
|---|
| 53 | if($npc['rank'] == 3)
|
|---|
| 54 | {
|
|---|
| 55 | $npc['minlevel'] = '??';
|
|---|
| 56 | $npc['maxlevel'] = '??';
|
|---|
| 57 | }
|
|---|
| 58 | $npc['mindmg'] = round($row['mindmg']+$row['attackpower']/7);
|
|---|
| 59 | $npc['maxdmg'] = round($row['maxdmg']+$row['attackpower']/7);
|
|---|
| 60 |
|
|---|
| 61 | $toDiv = array('minhealth', 'maxmana', 'minmana', 'maxhealth', 'armor', 'mindmg', 'maxdmg');
|
|---|
| 62 | // Разделяем на тысячи (ххххххххх => ххх,ххх,ххх)
|
|---|
| 63 | foreach($toDiv as $element)
|
|---|
| 64 | {
|
|---|
| 65 | $current = array();
|
|---|
| 66 | $length = strlen($npc[$element]);
|
|---|
| 67 | if($length<=3)
|
|---|
| 68 | continue;
|
|---|
| 69 | $cell1 = $length%3>0?$length%3:3;
|
|---|
| 70 | $cell = $cell1;
|
|---|
| 71 | for($i=0;$i<$length/3;$i++)
|
|---|
| 72 | {
|
|---|
| 73 | $pos = $i>0?$cell1+($i>1?($i-1)*3:0):0;
|
|---|
| 74 | $current[] = substr($npc[$element], $pos, $cell);
|
|---|
| 75 | $cell=3;
|
|---|
| 76 | }
|
|---|
| 77 | $npc[$element] = implode(",", $current);
|
|---|
| 78 | }
|
|---|
| 79 |
|
|---|
| 80 | $npc['rank'] = $smarty->get_config_vars('rank'.$npc['rank']);
|
|---|
| 81 | // faction_A = faction_H
|
|---|
| 82 | $npc['faction_num'] = $row['factionID'];
|
|---|
| 83 | $npc['faction'] = $row['faction-name'];
|
|---|
| 84 | // Деньги
|
|---|
| 85 | $money = ($row['mingold']+$row['maxgold']) / 2;
|
|---|
| 86 | $npc['moneygold'] = floor($money/10000);
|
|---|
| 87 | $npc['moneysilver'] = floor(($money - ($npc['moneygold']*10000))/100);
|
|---|
| 88 | $npc['moneycopper'] = floor($money - ($npc['moneygold']*10000) - ($npc['moneysilver']*100));
|
|---|
| 89 | // Дроп
|
|---|
| 90 | $lootid=$row['lootid'];
|
|---|
| 91 | // Используемые спеллы
|
|---|
| 92 | $npc['ablities'] = array();
|
|---|
| 93 | $i=0;
|
|---|
| 94 | for($j=0;$j<=4;++$j)
|
|---|
| 95 | if(isset($row['spell'.$j]) && $row['spell'.$j] > 0)
|
|---|
| 96 | $npc['abilities'][] = spellinfo($row['spell'.$j], 0);
|
|---|
| 97 | if (!($npc['ablities']))
|
|---|
| 98 | unset ($npc['ablities']);
|
|---|
| 99 | }
|
|---|
| 100 |
|
|---|
| 101 | // Обучает:
|
|---|
| 102 | // Если это пет со способностью:
|
|---|
| 103 | $row = $DB->selectRow('
|
|---|
| 104 | SELECT Spell1, Spell2, Spell3, Spell4
|
|---|
| 105 | FROM petcreateinfo_spell
|
|---|
| 106 | WHERE
|
|---|
| 107 | entry=?d
|
|---|
| 108 | ',
|
|---|
| 109 | $npc['entry']
|
|---|
| 110 | );
|
|---|
| 111 | if ($row)
|
|---|
| 112 | {
|
|---|
| 113 | $npc['teaches'] = array();
|
|---|
| 114 | for ($j=1;$j<=4;$j++)
|
|---|
| 115 | if ($row['Spell'.$j])
|
|---|
| 116 | for ($k=1;$k<=3;$k++)
|
|---|
| 117 | {
|
|---|
| 118 | $spellrow = $DB->selectRow('
|
|---|
| 119 | SELECT ?#, spellID
|
|---|
| 120 | FROM ?_spell, ?_spellicons
|
|---|
| 121 | WHERE
|
|---|
| 122 | spellID=(SELECT effect'.$k.'triggerspell FROM ?_spell WHERE spellID=?d AND (effect'.$k.'id IN (36,57)))
|
|---|
| 123 | AND id=spellicon
|
|---|
| 124 | LIMIT 1
|
|---|
| 125 | ',
|
|---|
| 126 | $spell_cols[2],
|
|---|
| 127 | $row['Spell'.$j]
|
|---|
| 128 | );
|
|---|
| 129 | if ($spellrow)
|
|---|
| 130 | {
|
|---|
| 131 | $num = count($npc['teaches']);
|
|---|
| 132 | $npc['teaches'][$num] = array();
|
|---|
| 133 | $npc['teaches'][$num] = spellinfo2($spellrow);
|
|---|
| 134 | }
|
|---|
| 135 | }
|
|---|
| 136 | }
|
|---|
| 137 | unset ($row);
|
|---|
| 138 |
|
|---|
| 139 | // Если это просто тренер
|
|---|
| 140 | $teachspells = $DB->select('
|
|---|
| 141 | SELECT ?#, spellID
|
|---|
| 142 | FROM npc_trainer, ?_spell, ?_spellicons
|
|---|
| 143 | WHERE
|
|---|
| 144 | entry=?d
|
|---|
| 145 | AND spellID=Spell
|
|---|
| 146 | AND id=spellicon
|
|---|
| 147 | ',
|
|---|
| 148 | $spell_cols[2],
|
|---|
| 149 | $npc['entry']
|
|---|
| 150 | );
|
|---|
| 151 | if ($teachspells)
|
|---|
| 152 | {
|
|---|
| 153 | if (!(IsSet($npc['teaches'])))
|
|---|
| 154 | $npc['teaches'] = array();
|
|---|
| 155 | foreach ($teachspells as $teachspell)
|
|---|
| 156 | {
|
|---|
| 157 | $num = count($npc['teaches']);
|
|---|
| 158 | $npc['teaches'][$num] = array();
|
|---|
| 159 | $npc['teaches'][$num] = spellinfo2($teachspell);
|
|---|
| 160 | }
|
|---|
| 161 | }
|
|---|
| 162 | unset ($teachspells);
|
|---|
| 163 |
|
|---|
| 164 | // Продает:
|
|---|
| 165 | $rows_s = $DB->select('
|
|---|
| 166 | SELECT ?#, i.entry, i.maxcount, n.`maxcount` as `drop-maxcount`, n.ExtendedCost
|
|---|
| 167 | {, l.name_loc?d AS `name_loc`}
|
|---|
| 168 | FROM npc_vendor n, ?_icons, item_template i
|
|---|
| 169 | {LEFT JOIN (locales_item l) ON l.entry=i.entry AND ?d}
|
|---|
| 170 | WHERE
|
|---|
| 171 | n.entry=?
|
|---|
| 172 | AND i.entry=n.item
|
|---|
| 173 | AND id=i.displayid
|
|---|
| 174 | ',
|
|---|
| 175 | $item_cols[2],
|
|---|
| 176 | ($_SESSION['locale'])? $_SESSION['locale']: DBSIMPLE_SKIP,
|
|---|
| 177 | ($_SESSION['locale'])? 1: DBSIMPLE_SKIP,
|
|---|
| 178 | $id
|
|---|
| 179 | );
|
|---|
| 180 | if ($rows_s)
|
|---|
| 181 | {
|
|---|
| 182 | $npc['sells'] = array();
|
|---|
| 183 | foreach ($rows_s as $numRow=>$row)
|
|---|
| 184 | {
|
|---|
| 185 | $npc['sells'][$numRow] = array();
|
|---|
| 186 | $npc['sells'][$numRow] = iteminfo2($row);
|
|---|
| 187 | $npc['sells'][$numRow]['maxcount'] = $row['drop-maxcount'];
|
|---|
| 188 | $npc['sells'][$numRow]['cost'] = array();
|
|---|
| 189 | if ($row['ExtendedCost'])
|
|---|
| 190 | {
|
|---|
| 191 | $extcost = $DB->selectRow('SELECT * FROM ?_item_extended_cost WHERE extendedcostID=?d LIMIT 1', $row['ExtendedCost']);
|
|---|
| 192 | if ($extcost['reqhonorpoints']>0)
|
|---|
| 193 | $npc['sells'][$numRow]['cost']['honor'] = (($npc['A']==1)? 1: -1) * $extcost['reqhonorpoints'];
|
|---|
| 194 | if ($extcost['reqarenapoints']>0)
|
|---|
| 195 | $npc['sells'][$numRow]['cost']['arena'] = $extcost['reqarenapoints'];
|
|---|
| 196 | $npc['sells'][$numRow]['cost']['items'] = array();
|
|---|
| 197 | for ($j=1;$j<=5;$j++)
|
|---|
| 198 | if (($extcost['reqitem'.$j]>0) and ($extcost['reqitemcount'.$j]>0))
|
|---|
| 199 | {
|
|---|
| 200 | allitemsinfo($extcost['reqitem'.$j], 0);
|
|---|
| 201 | $npc['sells'][$numRow]['cost']['items'][] = array('item' => $extcost['reqitem'.$j], 'count' => $extcost['reqitemcount'.$j]);
|
|---|
| 202 | }
|
|---|
| 203 | }
|
|---|
| 204 | if ($row['BuyPrice']>0)
|
|---|
| 205 | $npc['sells'][$numRow]['cost']['money'] = $row['BuyPrice'];
|
|---|
| 206 | }
|
|---|
| 207 | unset ($row);
|
|---|
| 208 | unset ($numRow);
|
|---|
| 209 | unset ($extcost);
|
|---|
| 210 | }
|
|---|
| 211 | unset ($rows_s);
|
|---|
| 212 |
|
|---|
| 213 | // Дроп
|
|---|
| 214 | if (!($npc['drop'] = loot('creature_loot_template', $lootid)))
|
|---|
| 215 | unset ($npc['drop']);
|
|---|
| 216 |
|
|---|
| 217 | // Кожа
|
|---|
| 218 | if (!($npc['skinning'] = loot('skinning_loot_template', $lootid)))
|
|---|
| 219 | unset ($npc['skinning']);
|
|---|
| 220 |
|
|---|
| 221 | // Воруеццо
|
|---|
| 222 | if (!($npc['pickpocketing'] = loot('pickpocketing_loot_template', $lootid)))
|
|---|
| 223 | unset ($npc['pickpocketing']);
|
|---|
| 224 |
|
|---|
| 225 | // Начиниают квесты...
|
|---|
| 226 | $rows_qs = $DB->select('
|
|---|
| 227 | SELECT ?#
|
|---|
| 228 | FROM creature_questrelation c, quest_template q
|
|---|
| 229 | WHERE
|
|---|
| 230 | c.id=?
|
|---|
| 231 | AND q.entry=c.quest
|
|---|
| 232 | ',
|
|---|
| 233 | $quest_cols[2],
|
|---|
| 234 | $id
|
|---|
| 235 | );
|
|---|
| 236 | if ($rows_qs)
|
|---|
| 237 | {
|
|---|
| 238 | $npc['starts'] = array();
|
|---|
| 239 | foreach ($rows_qs as $numRow=>$row) {
|
|---|
| 240 | $npc['starts'][] = GetQuestInfo($row, 0xFFFFFF);
|
|---|
| 241 | }
|
|---|
| 242 | }
|
|---|
| 243 | unset ($rows_qs);
|
|---|
| 244 |
|
|---|
| 245 | // Заканчивают квесты...
|
|---|
| 246 | $rows_qe = $DB->select('
|
|---|
| 247 | SELECT ?#
|
|---|
| 248 | FROM creature_involvedrelation c, quest_template q
|
|---|
| 249 | WHERE
|
|---|
| 250 | c.id=?
|
|---|
| 251 | AND q.entry=c.quest
|
|---|
| 252 | ',
|
|---|
| 253 | $quest_cols[2],
|
|---|
| 254 | $id
|
|---|
| 255 | );
|
|---|
| 256 | if ($rows_qe)
|
|---|
| 257 | {
|
|---|
| 258 | $npc['ends'] = array();
|
|---|
| 259 | foreach ($rows_qe as $numRow=>$row) {
|
|---|
| 260 | $npc['ends'][] = GetQuestInfo($row, 0xFFFFFF);
|
|---|
| 261 | }
|
|---|
| 262 | }
|
|---|
| 263 | unset ($rows_qe);
|
|---|
| 264 |
|
|---|
| 265 | // Необходимы для квеста..
|
|---|
| 266 | $rows_qo = $DB->select('
|
|---|
| 267 | SELECT ?#
|
|---|
| 268 | FROM quest_template
|
|---|
| 269 | WHERE
|
|---|
| 270 | ReqCreatureOrGOId1=?
|
|---|
| 271 | OR ReqCreatureOrGOId2=?
|
|---|
| 272 | OR ReqCreatureOrGOId3=?
|
|---|
| 273 | OR ReqCreatureOrGOId4=?
|
|---|
| 274 | ',
|
|---|
| 275 | $quest_cols[2],
|
|---|
| 276 | $id, $id, $id, $id
|
|---|
| 277 | );
|
|---|
| 278 | if ($rows_qo)
|
|---|
| 279 | {
|
|---|
| 280 | $npc['objectiveof'] = array();
|
|---|
| 281 | foreach ($rows_qo as $numRow=>$row) {
|
|---|
| 282 | $npc['objectiveof'][] = GetQuestInfo($row, 0xFFFFFF);
|
|---|
| 283 | }
|
|---|
| 284 | }
|
|---|
| 285 | unset ($rows_qo);
|
|---|
| 286 |
|
|---|
| 287 | // Положения созданий божих:
|
|---|
| 288 | $data = $DB->select('SELECT map AS m, position_x AS x, position_y AS y, spawntimesecs FROM creature WHERE id=?d', $id);
|
|---|
| 289 | position($data);
|
|---|
| 290 |
|
|---|
| 291 | save_cache(1, intval($id), $npc);
|
|---|
| 292 | }
|
|---|
| 293 |
|
|---|
| 294 | global $page;
|
|---|
| 295 | $page = array(
|
|---|
| 296 | 'Mapper' => true,
|
|---|
| 297 | 'Book' => false,
|
|---|
| 298 | 'Title' => $npc['name'].' - '.$smarty->get_config_vars('NPCs'),
|
|---|
| 299 | 'tab' => 0,
|
|---|
| 300 | 'type' => 1,
|
|---|
| 301 | 'typeid' => $npc['entry'],
|
|---|
| 302 | 'path' => '[0,4,'.$npc['type'].']'
|
|---|
| 303 | );
|
|---|
| 304 |
|
|---|
| 305 | $smarty->assign('page', $page);
|
|---|
| 306 |
|
|---|
| 307 | // Комментарии
|
|---|
| 308 | $smarty->assign('comments', getcomments($page['type'], $page['typeid']));
|
|---|
| 309 |
|
|---|
| 310 | // Если хоть одна информация о вещи найдена - передаём массив с информацией о вещях шаблонизатору
|
|---|
| 311 | if (IsSet($allitems))
|
|---|
| 312 | $smarty->assign('allitems',$allitems);
|
|---|
| 313 | if (IsSet($allspells))
|
|---|
| 314 | $smarty->assign('allspells',$allspells);
|
|---|
| 315 |
|
|---|
| 316 | $smarty->assign('npc',$npc);
|
|---|
| 317 |
|
|---|
| 318 | // Количество MySQL запросов
|
|---|
| 319 | $smarty->assign('mysql', $DB->getStatistics());
|
|---|
| 320 |
|
|---|
| 321 | // Запускаем шаблонизатор
|
|---|
| 322 | $smarty->display('npc.tpl');
|
|---|
| 323 |
|
|---|
| 324 | ?>
|
|---|