source: aowow/item.php

Last change on this file was 170, checked in by maron, 15 years ago
  • Property svn:executable set to *
File size: 15.4 KB
Line 
1<?php
2
3require_once('includes/game.php');
4require_once('includes/allspells.php');
5require_once('includes/allquests.php');
6require_once('includes/allitems.php');
7require_once('includes/allnpcs.php');
8require_once('includes/allobjects.php');
9require_once('includes/allcomments.php');
10
11// Загружаем файл перевода для smarty
12$smarty->config_load($conf_file,'item');
13
14$id = $podrazdel;
15if(!$item = load_cache(5, $id))
16{
17 unset($item);
18
19 global $DB;
20
21 global $allitems;
22 global $allspells;
23
24 global $item_cols;
25 global $spell_cols;
26
27 // Информация о вещи...
28 $item = iteminfo($podrazdel, 1);
29
30 // Поиск мобов с которых эта вещь лутится
31 $drops_cr = drop('creature_loot_template',$item['entry']);
32 if ($drops_cr)
33 {
34 $item['droppedby'] = array();
35 foreach($drops_cr as $lootid => $drop)
36 {
37 $rows = $DB->select('
38 SELECT c.?#, c.entry
39 {
40 , l.name_loc?d as `name_loc`
41 , l.subname_loc'.$_SESSION['locale'].' as `subname_loc`
42 }
43 FROM ?_factiontemplate, creature_template c
44 { LEFT JOIN (locales_creature l) ON l.entry=c.entry AND ? }
45 WHERE
46 lootid=?d
47 AND factiontemplateID=faction_A
48 ',
49 $npc_cols[0],
50 ($_SESSION['locale']>0)? $_SESSION['locale']: DBSIMPLE_SKIP,
51 ($_SESSION['locale']>0)? 1: DBSIMPLE_SKIP,
52 $lootid
53 );
54 foreach ($rows as $numRow=>$row)
55 $item['droppedby'][] = array_merge(creatureinfo2($row), $drop);
56 }
57 unset ($rows);
58 unset ($lootid);
59 unset ($drop);
60 }
61 unset ($drops_cr);
62
63 // Поиск объектов, из которых лутится эта вещь
64 $drops_go = drop('gameobject_loot_template',$item['entry']);
65 if ($drops_go)
66 {
67 $item['containedinobject'] = array();
68 $item['minedfromobject'] = array();
69 $item['gatheredfromobject'] = array();
70 foreach($drops_go as $lootid => $drop)
71 {
72 // Сундуки
73 $rows = $DB->select('
74 SELECT g.entry, g.name, g.type, a.lockproperties1
75 FROM gameobject_template g, ?_lock a
76 WHERE
77 g.data1=?d
78 AND g.type=?d
79 AND a.lockID=g.data0
80 ',
81 $lootid,
82 GAMEOBJECT_TYPE_CHEST,
83 LOCK_PROPERTIES_HERBALISM,
84 LOCK_PROPERTIES_MINING
85 );
86 foreach ($rows as $numRow=>$row)
87 {
88 if ($row['lockproperties1'] == LOCK_PROPERTIES_MINING)
89 {
90 // Залежи руды
91 $item['minedfromobject'][] = array_merge(objectinfo2($row), $drop);
92 } elseif ($row['lockproperties1'] == LOCK_PROPERTIES_HERBALISM)
93 {
94 // Собирается с трав
95 $item['gatheredfromobject'][] = array_merge(objectinfo2($row), $drop);
96 } else {
97 // Сундуки
98 $item['containedinobject'][] = array_merge(objectinfo2($row), $drop);
99 }
100 }
101 }
102
103 if (!($item['containedinobject']))
104 unset ($item['containedinobject']);
105 if (!($item['minedfromobject']))
106 unset ($item['minedfromobject']);
107 if (!($item['gatheredfromobject']))
108 unset ($item['gatheredfromobject']);
109
110 unset ($rows);
111 }
112 unset ($drops_go);
113
114 // Поиск вендеров, которые эту вещь продают
115 $rows_soldby = $DB->select('
116 SELECT ?#, c.entry, v.ExtendedCost, v.maxcount AS stock
117 {
118 , l.name_loc?d as `name_loc`
119 , l.subname_loc'.$_SESSION['locale'].' as `subname_loc`
120 }
121 FROM npc_vendor v, ?_factiontemplate, creature_template c
122 { LEFT JOIN (locales_creature l) ON l.entry=c.entry AND ? }
123 WHERE
124 v.item=?d
125 AND c.entry=v.entry
126 AND factiontemplateID=faction_A
127 ORDER BY 1 DESC, 2 DESC
128 ',
129 $npc_cols['0'],
130 ($_SESSION['locale']>0)? $_SESSION['locale']: DBSIMPLE_SKIP,
131 ($_SESSION['locale']>0)? 1: DBSIMPLE_SKIP,
132 $item['entry']
133 );
134 if ($rows_soldby)
135 {
136 $item['soldby'] = array();
137 foreach ($rows_soldby as $numRow=>$row)
138 {
139 $item['soldby'][$numRow] = array();
140 $item['soldby'][$numRow] = creatureinfo2($row);
141 $item['soldby'][$numRow]['stock'] = ($row['stock']==0)? -1 : $row['stock'];
142 if ($row['ExtendedCost'])
143 {
144 $item['soldby'][$numRow]['cost'] = array();
145 $extcost = $DB->selectRow('SELECT * FROM ?_item_extended_cost WHERE extendedcostID=?d LIMIT 1', $row['ExtendedCost']);
146 if ($extcost['reqhonorpoints']>0)
147 $item['soldby'][$numRow]['cost']['honor'] = (($row['A']==1)? 1: -1) * $extcost['reqhonorpoints'];
148 if ($extcost['reqarenapoints']>0)
149 $item['soldby'][$numRow]['cost']['arena'] = $extcost['reqarenapoints'];
150 $item['soldby'][$numRow]['cost']['items'] = array();
151 for ($j=1;$j<=5;$j++)
152 if (($extcost['reqitem'.$j]>0) and ($extcost['reqitemcount'.$j]>0))
153 {
154 allitemsinfo($extcost['reqitem'.$j], 0);
155 $item['soldby'][$numRow]['cost']['items'][] = array('item' => $extcost['reqitem'.$j], 'count' => $extcost['reqitemcount'.$j]);
156 }
157 } else {
158 $item['soldby'][$numRow]['cost']['money'] = $item['BuyPrice'];
159 }
160 }
161 unset($extcost);
162 unset($numRow);
163 unset($row);
164 }
165 unset($rows_soldby);
166
167 // Поиск квестов, для выполнения которых нужен этот предмет
168 $rows_qr = $DB->select('
169 SELECT ?#
170 FROM quest_template
171 WHERE
172 ReqItemId1=?d
173 OR ReqItemId2=?d
174 OR ReqItemId3=?d
175 OR ReqItemId4=?d
176 ',
177 $quest_cols[2],
178 $item['entry'], $item['entry'], $item['entry'], $item['entry']
179 );
180 if ($rows_qr)
181 {
182 $item['objectiveof'] = array();
183 foreach ($rows_qr as $numRow=>$row)
184 $item['objectiveof'][] = GetQuestInfo($row, 0xFFFFFF);
185 }
186 unset ($rows_qr);
187
188 // Поиск квестов, наградой за выполнение которых, является этот предмет
189 $rows_qrw = $DB->select('
190 SELECT ?#
191 FROM quest_template
192 WHERE
193 RewItemId1=?d
194 OR RewItemId2=?d
195 OR RewItemId3=?d
196 OR RewItemId4=?d
197 OR RewChoiceItemId1=?d
198 OR RewChoiceItemId2=?d
199 OR RewChoiceItemId3=?d
200 OR RewChoiceItemId4=?d
201 OR RewChoiceItemId5=?d
202 OR RewChoiceItemId6=?d
203 ',
204 $quest_cols[2],
205 $item['entry'], $item['entry'], $item['entry'], $item['entry'], $item['entry'],
206 $item['entry'], $item['entry'], $item['entry'], $item['entry'], $item['entry']
207 );
208 if ($rows_qrw)
209 {
210 $item['rewardof'] = array();
211 foreach ($rows_qrw as $numRow=>$row)
212 $item['rewardof'][] = GetQuestInfo($row, 0xFFFFFF);
213 }
214 unset ($rows_qrw);
215
216 // Поиск вещей, в которых находятся эти вещи
217 $drops_cii = drop('item_loot_template',$item['entry']);
218 if ($drops_cii)
219 {
220 $item['containedinitem'] = array();
221 foreach($drops_cii as $lootid => $drop)
222 {
223 $rows = $DB->select('
224 SELECT c.?#, c.entry, maxcount
225 { , l.name_loc?d AS `name_loc`}
226 FROM ?_icons, item_template c
227 { LEFT JOIN (locales_item l) ON l.entry=c.entry AND ? }
228 WHERE
229 c.entry=?d
230 AND id=displayid
231 ',
232 $item_cols[2],
233 ($_SESSION['locale']>0)? $_SESSION['locale']: DBSIMPLE_SKIP,
234 ($_SESSION['locale']>0)? 1: DBSIMPLE_SKIP,
235 $lootid
236 );
237 foreach ($rows as $numRow=>$row)
238 $item['containedinitem'][] = array_merge(iteminfo2($row, 0), $drop);
239 }
240 unset ($drops_cii);
241 unset ($rows);
242 unset ($lootid);
243 unset ($drop);
244 }
245
246 // Какие вещи содержатся в этой вещи
247 if (!($item['contains'] = loot('item_loot_template', $item['entry'])))
248 unset ($item['contains']);
249
250 // Поиск созданий, у которых воруется вещь
251 $drops_pp = drop('pickpocketing_loot_template',$item['entry']);
252 if ($drops_pp)
253 {
254 $item['pickpocketingloot'] = array();
255 foreach($drops_pp as $lootid => $drop)
256 {
257 $rows = $DB->select('
258 SELECT c.?#, c.entry
259 {
260 , l.name_loc?d as `name_loc`
261 , l.subname_loc'.$_SESSION['locale'].' as `subname_loc`
262 }
263 FROM ?_factiontemplate, creature_template c
264 { LEFT JOIN (locales_creature l) ON l.entry=c.entry AND ? }
265 WHERE
266 pickpocketloot=?d
267 AND factiontemplateID=faction_A
268 ',
269 $npc_cols[0],
270 ($_SESSION['locale']>0)? $_SESSION['locale']: DBSIMPLE_SKIP,
271 ($_SESSION['locale']>0)? 1: DBSIMPLE_SKIP,
272 $lootid
273 );
274 foreach ($rows as $numRow=>$row)
275 $item['pickpocketingloot'][] = array_merge(creatureinfo2($row), $drop);
276 }
277 unset ($rows);
278 unset ($lootid);
279 unset ($drop);
280 }
281 unset ($drops_pp);
282
283 // Поиск созданий, с которых сдираеццо эта шкура
284 $drops_sk = drop('skinning_loot_template',$item['entry']);
285 if ($drops_sk)
286 {
287 $item['skinnedfrom'] = array();
288 foreach($drops_sk as $lootid => $drop)
289 {
290 $rows = $DB->select('
291 SELECT c.?#, c.entry
292 {
293 , l.name_loc?d as `name_loc`
294 , l.subname_loc'.$_SESSION['locale'].' as `subname_loc`
295 }
296 FROM ?_factiontemplate, creature_template c
297 { LEFT JOIN (locales_creature l) ON l.entry=c.entry AND ? }
298 WHERE
299 skinloot=?d
300 AND factiontemplateID=faction_A
301 ',
302 $npc_cols[0],
303 ($_SESSION['locale']>0)? $_SESSION['locale']: DBSIMPLE_SKIP,
304 ($_SESSION['locale']>0)? 1: DBSIMPLE_SKIP,
305 $lootid
306 );
307 foreach ($rows as $numRow=>$row)
308 $item['skinnedfrom'][] = array_merge(creatureinfo2($row), $drop);
309 }
310 unset ($rows);
311 unset ($lootid);
312 unset ($drop);
313 }
314 unset ($drops_sk);
315
316 // Поиск вещей, из которых перерабатывается эта вещь
317 $drops_pr = drop('prospecting_loot_template',$item['entry']);
318 if ($drops_pr)
319 {
320 $item['prospectingloot'] = array();
321 foreach($drops_pr as $lootid => $drop)
322 {
323 $rows = $DB->select('
324 SELECT c.?#, c.entry, maxcount
325 {
326 , l.name_loc?d as `name_loc`
327 }
328 FROM ?_icons, item_template c
329 { LEFT JOIN (locales_items l) ON l.entry=c.entry AND ? }
330 WHERE
331 entry=?d
332 AND id=displayid
333 ',
334 $item_cols[2],
335 ($_SESSION['locale']>0)? $_SESSION['locale']: DBSIMPLE_SKIP,
336 ($_SESSION['locale']>0)? 1: DBSIMPLE_SKIP,
337 $lootid
338 );
339 foreach ($rows as $numRow=>$row)
340 $item['prospectingloot'][] = array_merge(iteminfo2($row, 0), $drop);
341 }
342 unset ($rows);
343 unset ($lootid);
344 unset ($drop);
345 }
346 unset ($drops_pr);
347
348 // Дизенчантитcя в:
349 if (!($item['disenchanting'] = loot('disenchant_loot_template', $item['DisenchantID'])))
350 unset ($item['disenchanting']);
351
352 // Получается дизэнчантом из..
353 $drops_de = drop('disenchant_loot_template',$item['entry']);
354 if ($drops_de)
355 {
356 $item['disenchantedfrom'] = array();
357 foreach($drops_de as $lootid => $drop)
358 {
359 $rows = $DB->select('
360 SELECT c.?#, c.entry, maxcount
361 {
362 , l.name_loc?d as `name_loc`
363 }
364 FROM ?_icons, item_template c
365 { LEFT JOIN (locales_item l) ON l.entry=c.entry AND ? }
366 WHERE
367 DisenchantID=?d
368 AND id=displayid
369 ',
370 $item_cols[2],
371 ($_SESSION['locale']>0)? $_SESSION['locale']: DBSIMPLE_SKIP,
372 ($_SESSION['locale']>0)? 1: DBSIMPLE_SKIP,
373 $lootid
374 );
375 foreach ($rows as $numRow=>$row)
376 $item['disenchantedfrom'][] = array_merge(iteminfo2($row, 0), $drop);
377 }
378 unset ($rows);
379 unset ($lootid);
380 unset ($drop);
381 }
382 unset ($drops_de);
383
384 // Поиск сумок в которые эту вещь можно положить
385 if ($item['BagFamily'] == 256)
386 {
387 // Если это ключ
388 $item['key'] = true;
389 } elseif ($item['BagFamily'] > 0 and $item['ContainerSlots'] == 0) {
390 $rows_cpi = $DB->select('
391 SELECT c.?#, c.entry, maxcount
392 {
393 , l.name_loc?d as `name_loc`
394 }
395 FROM ?_icons, item_template c
396 { LEFT JOIN (locales_item l) ON l.entry=c.entry AND ? }
397 WHERE
398 BagFamily=?d
399 AND ContainerSlots>0
400 AND id=displayid
401 ',
402 $item_cols[2],
403 ($_SESSION['locale']>0)? $_SESSION['locale']: DBSIMPLE_SKIP,
404 ($_SESSION['locale']>0)? 1: DBSIMPLE_SKIP,
405 $item['BagFamily']
406 );
407 if ($rows_cpi)
408 {
409 $item['canbeplacedin'] = array();
410 foreach ($rows_cpi as $numRow=>$row)
411 $item['canbeplacedin'][] = iteminfo2($row, 0);
412 }
413 unset ($rows_cpi);
414 }
415
416 // Реагент для...
417 $rows_r = $DB->select('
418 SELECT ?#, spellID
419 FROM ?_spell s, ?_spellicons i
420 WHERE
421 (( reagent1=?d
422 OR reagent2=?d
423 OR reagent3=?d
424 OR reagent4=?d
425 OR reagent5=?d
426 OR reagent6=?d
427 OR reagent7=?d
428 OR reagent8=?d
429 ) AND ( i.id=s.spellicon))
430 ',
431 $spell_cols[2],
432 $item['entry'], $item['entry'], $item['entry'], $item['entry'],
433 $item['entry'], $item['entry'], $item['entry'], $item['entry']
434 );
435 if ($rows_r)
436 {
437 $item['reagentfor'] = array();
438 $quality = 1;
439 foreach ($rows_r as $numRow=>$row)
440 {
441 $item['reagentfor'][$numRow] = array();
442 $item['reagentfor'][$numRow]['entry'] = $row['spellID'];
443 $item['reagentfor'][$numRow]['name'] = $row['spellname'];
444 $item['reagentfor'][$numRow]['school'] = $row['resistancesID'];
445 $item['reagentfor'][$numRow]['level'] = $row['levelspell'];
446 $item['reagentfor'][$numRow]['quality'] = '@';
447 for ($j=1;$j<=8;$j++)
448 if ($row['reagent'.$j])
449 {
450 $item['reagentfor'][$numRow]['reagents'][]['entry'] = $row['reagent'.$j];
451 $item['reagentfor'][$numRow]['reagents'][count($item['reagentfor'][$numRow]['reagents'])-1]['count'] = $row['reagentcount'.$j];
452 allitemsinfo($row['reagent'.$j], 0);
453 }
454 for ($j=1;$j<=3;$j++)
455 if ($row['effect'.$j.'itemtype'])
456 {
457 $item['reagentfor'][$numRow]['creates'][]['entry'] = $row['effect'.$j.'itemtype'];
458 $item['reagentfor'][$numRow]['creates'][count($item['reagentfor'][$numRow]['creates'])-1]['count'] = 1 + $row['effect'.$j.'BasePoints'];
459 allitemsinfo($row['effect'.$j.'itemtype'], 0);
460 @$item['reagentfor'][$numRow]['quality'] = 6 - $allitems[$row['effect'.$j.'itemtype']]['quality'];
461 }
462 // Добавляем в таблицу спеллов
463 allspellsinfo2($row);
464 }
465 unset ($quality);
466 }
467 unset ($rows_r);
468
469 // Создается из...
470 $rows_cf = $DB->select('
471 SELECT ?#, s.spellID
472 FROM ?_spell s, ?_spellicons i
473 WHERE
474 ((s.effect1itemtype=?d
475 OR s.effect2itemtype=?d
476 OR s.effect3itemtype=?)
477 AND (i.id = s.spellicon))
478 ',
479 $spell_cols[2],
480 $item['entry'], $item['entry'], $item['entry']
481 );
482 if ($rows_cf)
483 {
484 $item['createdfrom'] = array();
485 foreach ($rows_cf as $numRow=>$row)
486 {
487 $skillrow = $DB->selectRow('
488 SELECT skillID, min_value, max_value
489 FROM ?_skill_line_ability
490 WHERE spellID=?d
491 LIMIT 1',
492 $row['spellID']
493 );
494 $item['createdfrom'][] = spellinfo2(array_merge($row, $skillrow));
495 }
496 unset ($skillrow);
497 }
498 unset ($rows_cf);
499
500 // Ловится в ...
501 $drops_fi = drop('fishing_loot_template',$item['entry']);
502 if ($drops_fi)
503 {
504 $item['fishedin'] = array();
505 foreach($drops_fi as $lootid => $drop)
506 {
507 // Обычные локации
508 $row = $DB->selectRow('
509 SELECT name, areatableID as id
510 FROM ?_zones
511 WHERE
512 areatableID=?d
513 AND (x_min!=0 AND x_max!=0 AND y_min!=0 AND y_max!=0)
514 LIMIT 1
515 ',
516 $lootid
517 );
518 if ($row)
519 {
520 $item['fishedin'][] = array_merge($row, $drop);
521 } else {
522 // Инсты
523 $row = $DB->selectRow('
524 SELECT name, mapID as id
525 FROM ?_zones
526 WHERE
527 areatableID=?d
528 LIMIT 1
529 ',
530 $lootid
531 );
532 if ($row)
533 $item['fishedin'][] = array_merge($row, $drop);
534 }
535 }
536 unset ($row);
537 unset ($num);
538 }
539 unset ($drops_fi);
540
541 save_cache(5, $item['entry'], $item);
542}
543global $page;
544$page = array(
545 'Mapper' => false,
546 'Book' => false,
547 'Title' => $item['name'].' - '.$smarty->get_config_vars('Items'),
548 'tab' => 0,
549 'type' => 3,
550 'typeid' => $item['entry'],
551 'path' => '[0,0,'.$item['classs'].','.$item['subclass'].']',
552);
553$smarty->assign('page', $page);
554
555// Комментарии
556$smarty->assign('comments', getcomments($page['type'], $page['typeid']));
557
558// Количество MySQL запросов
559$smarty->assign('mysql', $DB->getStatistics());
560if (IsSet($allitems))
561 $smarty->assign('allitems', $allitems);
562if (IsSet($allspells))
563 $smarty->assign('allspells', $allspells);
564$smarty->assign('item', $item);
565$smarty->display('item.tpl');
566
567?>
Note: See TracBrowser for help on using the repository browser.