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