-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathwow_alpha_quests.php
627 lines (470 loc) · 19 KB
/
wow_alpha_quests.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
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
<?php
/*
Author: X'Genesis Qhulut <[email protected]>
Date: August 2022
See LICENSE for license details.
*/
// QUESTS
// See: https://mangoszero-docs.readthedocs.io/en/latest/database/world/quest-template.html
function simulateQuest ($row)
{
global $id, $game_objects, $creatures, $zones, $quests, $spells, $items;
// simulate quest
echo "<div class='simulate_box quest'>\n";
echo "<h2>" . fixHTML ($row ['Title']) . "</h2>\n";
echo "<p>" . fixQuestText ($row ['Details'] ). "</h2>\n";
comment ('OBJECTIVES');
echo "<h3>Objectives</h3>\n";
echo "<p>" . fixQuestText ($row ['Objectives']) . "</h2>\n";
comment ('REQUIREMENTS');
echo "<h3>Requirements</h3>\n";
for ($n = 1; $n <= QUEST_REQUIRED_ITEMS; $n++)
if ($row ["ReqItemId$n"])
echo (lookupItemHelper ($row ["ReqItemId$n"], $row ["ReqItemCount$n"]) . "<br>");
comment ('REQUIRED CREATURES OR GAME OBJECTS');
// creatures or game objects
for ($n = 1; $n <= QUEST_REQUIRED_CREATURES; $n++)
{
$value = $row ["ReqCreatureOrGOId$n"];
if ($value)
{
if ($value < 0)
echo (lookupThing ($game_objects, -$value, 'show_go'));
else
echo (lookupThing ($creatures, $value, 'show_creature'));
echo (showItemCount ($row ["ReqCreatureOrGOCount$n"]));
echo "<br>";
}
} // end of for each creature or game object objective
echo "<p>\n";
comment ('REQUIRED SPELLS');
// spells
for ($n = 1; $n <= QUEST_REQUIRED_SPELLS; $n++)
if ($row ["ReqSpellCast$n"])
echo ('Cast: ' . lookupThing ($spells, $row ["ReqSpellCast$n"], 'show_spell'). "<br>\n");
comment ('PROGRESS');
echo "<h3>Progress</h3>\n";
echo "<p>" . fixQuestText ($row ['RequestItemsText']) . "\n";
comment ('COMPLETION');
echo "<hr><h3>Completion</h3>\n";
echo "<p>" . fixQuestText ($row ['OfferRewardText']) . "\n";
comment ('REWARDS');
echo "<h3>Reward</h3>\n";
// non-choice item rewards
for ($n = 1; $n <= QUEST_REWARD_ITEMS; $n++)
if ($row ["RewItemId$n"])
echo (lookupItemHelper ($row ["RewItemId$n"], $row ["RewItemCount$n"]) . "<br>");
// choose an item from these six
$count = getCount ($row, 'RewChoiceItemId', QUEST_REWARD_ITEM_CHOICES);
if ($count > 1)
echo "<h4>Choice of:</h4><ul>\n";
for ($n = 1; $n <= QUEST_REWARD_ITEM_CHOICES; $n++)
if ($row ["RewChoiceItemId$n"])
echo ('<li>' . lookupItemHelper ($row ["RewChoiceItemId$n"], $row ["RewChoiceItemCount$n"]) . "<br>");
if ($count > 1)
echo "</ul>\n";
if ($row ['RewXP'])
echo "<p>" . $row ['RewXP'] . " XP<br>";
if ($row ['RewOrReqMoney'])
echo "<p>You will receive: " . convertGold ($row ['RewOrReqMoney']) . " <br>";
if ($row ['RewSpellCast'])
echo "<p>" . lookupThing ($spells, $row ["RewSpellCast"], 'show_spell') . " will be cast on you<br>";
if ($row ['RewSpell'])
echo "<p>" . lookupThing ($spells, $row ["RewSpell"], 'show_spell') . " will be cast on you<br>";
comment ('REPUTATION');
// reputation
$count = getCount ($row, 'RewRepValue', QUEST_REWARD_REPUTATION);
if ($count > 0)
{
echo "<h4>Reputation adjustment</h4><ul>\n";
for ($n = 1; $n <= QUEST_REWARD_REPUTATION; $n++)
if ($row ["RewRepValue$n"])
echo ('<li>' . addSign ($row ["RewRepValue$n"]) . ' with ' . getFaction ($row ["RewRepFaction$n"], false));
echo "</ul>\n";
} // end of any reputation adjustment
comment ('OTHER INFO');
echo "<hr>\n";
$quest_type = $row ['Type'];
if ($quest_type > 0) // quest type
{
echo "\n<br><b>Type</b>: " . expandSimple (QUEST_TYPE, $quest_type, false);
}
$zone = $row ['ZoneOrSort'];
if ($zone > 0) // quest zone
{
echo "\n<br><b>Zone</b>: " . expandSimple ($zones, $zone, false);
}
echo "\n<br><b>Minimum level</b>: " . $row ['MinLevel'];
echo "\n<br><b>Quest level</b>: " . $row ['QuestLevel'];
if ($row ['LimitTime'])
echo "\n<br><b>Time limit</b>: " . convertTimeGeneral ($row ['LimitTime'] * 1000);
$PrevQuestId = $row ['PrevQuestId'];
if ($PrevQuestId > 0)
echo "\n<br><b>Requires completion of</b>: " . lookupThing ($quests, $row ['PrevQuestId'], 'show_quest');
if ($PrevQuestId < 0)
echo "\n<br><b>This quest must be active</b>: " . lookupThing ($quests, abs ($row ['PrevQuestId']), 'show_quest');
if ($row ['NextQuestId'])
echo "\n<br><b>Next quest</b>: " . lookupThing ($quests, abs ($row ['NextQuestId']), 'show_quest');
if ($row ['NextQuestInChain'])
echo "\n<br><b>Next quest in chain</b>: " . lookupThing ($quests, $row ['NextQuestInChain'], 'show_quest');
endDiv ('simulate_box quest');
// ===============================================================================================================
} // end of simulateQuest
function showQuestGivers ()
{
global $id, $creatures, $items, $game_objects;
// who gives this quest
$results = dbQueryParam ("SELECT * FROM ".CREATURE_QUEST_STARTER." WHERE quest = ? AND entry <= " . MAX_CREATURE, array ('i', &$id));
listItems ('NPCs that start this quest', CREATURE_QUEST_STARTER, count ($results) , $results,
function ($row) use ($creatures)
{
listThing ($creatures, $row ['entry'], 'show_creature');
});
$results = dbQueryParam ("SELECT * FROM ".ITEM_TEMPLATE." WHERE start_quest = ? AND ignored = 0", array ('i', &$id));
listItems ('Items that start this quest', ITEM_TEMPLATE, count ($results) , $results,
function ($row) use ($items)
{
listThing ($items, $row ['entry'], 'show_item');
});
$results = dbQueryParam ("SELECT * FROM ".GAMEOBJECT_QUEST_STARTER." WHERE quest = ?", array ('i', &$id));
listItems ('Game objects that start this quest', GAMEOBJECT_QUEST_STARTER, count ($results) , $results,
function ($row) use ($game_objects)
{
listThing ($game_objects, $row ['entry'], 'show_go');
});
} // end of showQuestGivers
function showQuestFinishers ()
{
global $id, $creatures, $items, $game_objects;
// who finishes this quest
$results = dbQueryParam ("SELECT * FROM ".CREATURE_QUEST_FINISHER." WHERE quest = ? AND entry <= " . MAX_CREATURE, array ('i', &$id));
listItems ('NPCs that finish this quest', CREATURE_QUEST_FINISHER, count ($results) , $results,
function ($row) use ($creatures)
{
listThing ($creatures, $row ['entry'], 'show_creature');
});
$results = dbQueryParam ("SELECT * FROM ".GAMEOBJECT_QUEST_FINISHER." WHERE quest = ?", array ('i', &$id));
listItems ('Game objects that finish this quest', GAMEOBJECT_QUEST_FINISHER, count ($results) , $results,
function ($row) use ($game_objects)
{
listThing ($game_objects, $row ['entry'], 'show_go');
});
} // end of showQuestFinishers
function showQuestAreaTriggers ()
{
global $id, $area_triggers;
// who finishes this quest
$results = dbQueryParam ("SELECT * FROM ".AREATRIGGER_QUEST_RELATION." WHERE quest = ?", array ('i', &$id));
listItems ('Area triggers used by this quest', AREATRIGGER_QUEST_RELATION, count ($results) , $results,
function ($row) use ($area_triggers)
{
listThing ($area_triggers, $row ['id'], 'show_area_trigger');
});
} // end of showQuestAreaTriggers
function showQuestChain ()
{
global $id, $quests;
// we need the item info in this function
$row = dbQueryOneParam ("SELECT * FROM ".QUEST_TEMPLATE." WHERE entry = ?", array ('i', &$id));
// find previous quests in the chain
$foundQuests = array ($id); // stop looping
while ($row ['PrevQuestId'])
{
$PrevQuestId = abs ($row ['PrevQuestId']);
if (in_array ($PrevQuestId, $foundQuests))
break; // avoid going into a loop
$foundQuests [] = $PrevQuestId; // add this one to the chain
// get the previous one
$row = dbQueryOneParam ("SELECT entry, PrevQuestId FROM ".QUEST_TEMPLATE." WHERE entry = ? AND ignored = 0",
array ('i', &$PrevQuestId));
if (!$row) // not on file?
break;
} // while we still have previous quest IDs
$foundQuests = array_reverse ($foundQuests); // get into ascending order
// now get the next quests in the chain
// get this quest back
$row = dbQueryOneParam ("SELECT entry, NextQuestId, NextQuestInChain FROM ".QUEST_TEMPLATE." WHERE entry = ?",
array ('i', &$id));
while ($row ['NextQuestInChain'] || $row ['NextQuestId'] )
{
$NextQuest = $row ['NextQuestInChain'];
if (!$NextQuest)
$NextQuest = abs ($row ['NextQuestId']);
if (in_array ($NextQuest, $foundQuests))
break; // avoid going into a loop
$foundQuests [] = $NextQuest; // add this one to the chain
// get the next one
$row = dbQueryOneParam ("SELECT entry, NextQuestId, NextQuestInChain FROM ".QUEST_TEMPLATE." WHERE entry = ? AND ignored = 0",
array ('i', &$NextQuest));
if (!$row) // not on file?
break;
} // while we still have previous quest IDs
if (count ($foundQuests) > 1)
{
listItems ('Quest chain', QUEST_TEMPLATE, count ($foundQuests) , $foundQuests,
function ($quest) use ($quests, $id)
{
listThing ($quests, $quest, 'show_quest', $quest == $id ? '<- This' : '');
});
} // end of other quests in the chain
} // end of showQuestChain
function questTopMiddle ($info)
{
$row = $info ['row'];
boxTitle ("Quest simulation");
simulateQuest ($row);
} // end of questTopMiddle
function addCreatureToMapPoints ($which, $color)
{
global $questMapPoints;
global $creatures;
$where = '(spawn_entry1 = ? OR spawn_entry2 = ? OR spawn_entry3 = ? OR spawn_entry4 = ?)' .
' AND ignored = 0 ';
$param = array ('iiii', &$which, &$which, &$which, &$which);
$spawnPoints = dbQueryParam ("SELECT * FROM ".SPAWNS_CREATURES." WHERE $where", $param) ;
foreach ($spawnPoints as $spawnRow)
$questMapPoints [] = array (
'id' => $spawnRow ['spawn_id'],
'X' => $spawnRow ['position_x'],
'Y' => $spawnRow ['position_y'],
'Z' => $spawnRow ['position_z'],
'map' => $spawnRow ['map'],
'color' => $color,
'name' => $creatures [$which],
);
} // end of addCreatureToMapPoints
function gameObjectToMapPoints ($which, $color)
{
global $questMapPoints;
global $game_objects;
$spawnPoints = dbQueryParam ("SELECT * FROM ".SPAWNS_GAMEOBJECTS." WHERE spawn_entry = ? AND ignored = 0 ", array ('i', &$which)) ;
foreach ($spawnPoints as $spawnRow)
$questMapPoints [] = array (
'id' => $spawnRow ['spawn_id'],
'X' => $spawnRow ['spawn_positionX'],
'Y' => $spawnRow ['spawn_positionY'],
'Z' => $spawnRow ['spawn_positionZ'],
'map' => $spawnRow ['spawn_map'],
'color' => $color,
'name' => $game_objects [$which],
);
} // end of gameObjectToMapPoints
function areaTriggerToMapPoints ($which, $color)
{
global $questMapPoints;
$spawnPoints = dbQueryParam ("SELECT * FROM ".AREATRIGGER." WHERE ID = ?", array ('i', &$which)) ;
foreach ($spawnPoints as $spawnRow)
$questMapPoints [] = array (
'id' => $spawnRow ['ID'],
'X' => $spawnRow ['X'],
'Y' => $spawnRow ['Y'],
'Z' => $spawnRow ['Z'],
'map' => $spawnRow ['ContinentID'],
'color' => $color,
'name' => 'Area trigger',
);
} // end of areaTriggerToMapPoints
function questTopRight ($info)
{
global $id;
global $questMapPoints;
// ------------------------------------------------------------------------------------
// find where the quest giver NPC is spawned
$results = dbQueryParam ("SELECT * FROM ".CREATURE_QUEST_STARTER." WHERE quest = ? AND entry <= " . MAX_CREATURE, array ('i', &$id));
foreach ($results as $row)
{
addCreatureToMapPoints ($row ['entry'], 'lightgreen');
} // end of quest givers
// ------------------------------------------------------------------------------------
// find where the quest giver game object is spawned
$results = dbQueryParam ("SELECT * FROM ".GAMEOBJECT_QUEST_STARTER." WHERE quest = ?", array ('i', &$id));
foreach ($results as $row)
{
gameObjectToMapPoints ($row ['entry'], 'lightgreen');
} // end of quest giver game objects
// ------------------------------------------------------------------------------------
// who finishes this quest
$results = dbQueryParam ("SELECT * FROM ".CREATURE_QUEST_FINISHER." WHERE quest = ? AND entry <= " . MAX_CREATURE, array ('i', &$id));
foreach ($results as $row)
{
addCreatureToMapPoints ($row ['entry'], 'cyan');
} // end of quest finishers
// ------------------------------------------------------------------------------------
// game objects that finish this quest
$results = dbQueryParam ("SELECT * FROM ".GAMEOBJECT_QUEST_FINISHER." WHERE quest = ?", array ('i', &$id));
foreach ($results as $row)
{
gameObjectToMapPoints ($row ['entry'], 'cyan');
} // end of quest finisher game objects
// ------------------------------------------------------------------------------------
// creatures or game objects
$row = $info ['row'];
// creatures we have to kill
for ($n = 1; $n <= QUEST_REQUIRED_CREATURES; $n++)
{
$value = $row ["ReqCreatureOrGOId$n"];
if ($value)
{
if ($value < 0)
gameObjectToMapPoints (-$value, 'red');
else
addCreatureToMapPoints ($value, 'red');
}
} // end of for each creature or game object objective
// ------------------------------------------------------------------------------------
// items we have to obtain
// first get the items
$npcList = array (); // this will be a list of the NPCs that drop items
for ($i = 1; $i <= QUEST_REQUIRED_ITEMS; $i++)
{
$item = $row ["ReqItemId$i"]; // which item
// now lookup who drops those items
$lootResults = dbQueryParam ("SELECT * FROM ".CREATURE_LOOT_TEMPLATE." WHERE item = ?",
array ('i', &$item));
foreach ($lootResults as $lootRow)
if (!in_array ($lootRow ['entry'], $npcList)) // don't add the same NPC twice
$npcList [] = $lootRow ['entry'];
} // for each required item
// now add those NPCs to the map
foreach ($npcList as $npc)
{
addCreatureToMapPoints ($npc, 'red');
} // end of quest item droppers
// ------------------------------------------------------------------------------------
// area triggers
$results = dbQueryParam ("SELECT id FROM ".AREATRIGGER_QUEST_RELATION." WHERE quest = ?", array ('i', &$id));
foreach ($results as $row)
{
areaTriggerToMapPoints ($row ['id'], 'white');
} // end of area triggers
comment ('QUEST INFORMATION ON MAP');
$mapPoints_0 = array ();
$mapPoints_1 = array ();
foreach ($questMapPoints as $mapPoint)
{
if ($mapPoint ['map'] == 0)
$mapPoints_0 [] = $mapPoint;
elseif ($mapPoint ['map'] == 1)
$mapPoints_1 [] = $mapPoint;
}
echo "<div class='caroussel__maps'>\n";
comment ('ARROWS');
comment ('KALIMDOR');
showSpawnPoints ($mapPoints_1, 'Quest information- Kalimdor', 'Multiple tables',
'id', 'X', 'Y', 'Z', 'map');
comment ('EASTERN KINGDOMS');
showSpawnPoints ($mapPoints_0, 'Quest information - Eastern Kingdoms', 'Multiple tables',
'id', 'X', 'Y', 'Z', 'map');
comment ('QUEST INFORMATION ON MAP');
endDiv ('caroussel__maps');
} // end of questTopRight
function questDetails ($info)
{
global $id;
global $questMapPoints;
// for the quest starter, finisher, mobs, game objects and area triggers
$questMapPoints = array ();
$row = $info ['row'];
topSection ($info, function ($info) use ($id)
{
topMiddle ($info, 'questTopMiddle');
topRight ($info, 'questTopRight');
});
middleSection ($info, function ($info) use ($id, $row)
{
showQuestGivers ();
showQuestFinishers ();
showQuestChain ();
showQuestAreaTriggers ();
});
bottomSection ($info, function ($info) use ($id)
{
$extras = $info ['extras'];
showOneThing (QUEST_TEMPLATE, 'entry', $id,
"Database entry for quest", "Title", $extras);
});
} // end of questDetails
function showOneQuest ()
{
global $id;
global $quests, $creatures, $items, $game_objects, $spells;
if (($id === false && !repositionSearch()) || !checkID ())
return;
// we need the item info in this function
$row = dbQueryOneParam ("SELECT * FROM ".QUEST_TEMPLATE." WHERE entry = ?", array ('i', &$id));
if (!$row)
{
ShowWarning ("Quest $id is not on the database");
return;
} // end of not finding it
$name = $row ['Title'];
setTitle ("Quest $name");
$extras = array (
'SrcItemId' => 'item',
'PrevQuestId' => 'quest',
'NextQuestId' => 'quest',
'NextQuestInChain' => 'quest',
'ExclusiveGroup' => 'quest',
'RewSpellCast' => 'spell',
'RewSpell' => 'spell',
'RequiredRaces' => 'race_mask',
'RequiredClasses' => 'class_mask',
'RequiredSkill' => 'skill',
'RewOrReqMoney' => 'gold',
'LimitTime' => 'time_secs',
'QuestFlags' => 'quest_flags',
'SpecialFlags' => 'quest_special_flags',
'Type' => 'quest_type',
);
for ($i = 1; $i <= QUEST_REQUIRED_ITEMS; $i++)
$extras ["ReqItemId$i"] = 'item';
for ($i = 1; $i <= QUEST_REWARD_ITEMS; $i++)
$extras ["RewItemId$i"] = 'item';
for ($i = 1; $i <= QUEST_REWARD_ITEM_CHOICES; $i++)
$extras ["RewChoiceItemId$i"] = 'item';
for ($i = 1; $i <= QUEST_REQUIRED_CREATURES; $i++)
$extras ["ReqCreatureOrGOId$i"] = 'creature_or_go';
for ($i = 1; $i <= QUEST_REQUIRED_SPELLS; $i++)
$extras ["ReqSpellCast$i"] = 'spell';
for ($i = 1; $i <= QUEST_REWARD_REPUTATION; $i++)
$extras ["RewRepFaction$i"] = 'faction';
// we pass this stuff around to the helper functions
$info = array ('row' => $row, 'extras' => $extras, 'limit' => array ());
// ready to go! show the page info and work our way down into the sub-functions
pageContent ($info, 'Quest', $name, 'quests', 'questDetails', QUEST_TEMPLATE);
} // end of showOneQuest
function showQuests ()
{
global $where, $params, $sort_order, $matches;
$sortFields = array (
'entry',
'Title',
'MinLevel',
);
if (!in_array ($sort_order, $sortFields))
$sort_order = 'Title';
setTitle ("Quests listing");
$td = function ($s) use (&$row) { tdx ($row [$s]); };
$headings = array ('Entry', 'Title' ,'Level');
$results = setUpSearch ('Quests', $sortFields, $headings);
if (!$results)
return;
$searchURI = makeSearchURI (true);
$pos = 0;
foreach ($results as $row)
{
$pos++;
echo "<tr>\n";
$id = $row ['entry'];
tdh ("<a href='?action=show_quest&id=$id$searchURI&pos=$pos&max=$matches'>$id</a>");
tdh ("<a href='?action=show_quest&id=$id$searchURI&pos=$pos&max=$matches'>" . fixHTML ($row ['Title']) . "</a>");
if ($row ['MinLevel'] != $row ['MaxLevel'] && $row ['MaxLevel'] > 0)
td ($row ['MinLevel'] . '-' . $row ['MaxLevel'] );
else
$td ('MinLevel');
showFilterColumn ($row);
echo "</tr>\n";
}
wrapUpSearch ();
} // end of showQuests
?>