-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathwow_alpha_spells.php
521 lines (403 loc) · 15.5 KB
/
wow_alpha_spells.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
<?php
/*
Author: X'Genesis Qhulut <XGenesis-Qhulut@protonmail.com>
Date: August 2022
See LICENSE for license details.
*/
// SPELLS
// Interesting info: https://tswow.github.io/tswow-wiki/introduction/05-custom-spell/
function showSpellIcon ($row)
{
global $documentRoot, $executionDir;
comment ('SPELL ICON');
// fallback icon: INV_Misc_QuestionMark.png
$imageRow = dbQueryOneParam ("SELECT * FROM ".SPELLICON." WHERE ID = ?", array ('i', &$row ['SpellIconID']));
if ($imageRow)
{
$TextureFilename = $imageRow ['TextureFilename'] ;
if (preg_match ("|([^\\\\]+)$|i", $TextureFilename, $matches))
$TextureFilename = $matches [1];
$TextureFilename .= '.png';
if (file_exists ("$documentRoot$executionDir/icons/$TextureFilename"))
echo "<img src='icons/$TextureFilename' alt='Spell icon' title='" . fixHTML ($imageRow ['TextureFilename']) . "'>\n";
else
echo "<img src='icons/INV_Misc_QuestionMark.png' alt='Item icon' title='INV_Misc_QuestionMark'>\n";
}
else
echo "<img src='icons/INV_Misc_QuestionMark.png' alt='Item icon' title='INV_Misc_QuestionMark'>\n";
} // end of showSpellIcon
function simulateSpell ($row)
{
global $id, $spells, $items, $creatures;
comment ('SPELL SIMULATION');
boxTitle ('In-game view');
echo "<div class='simulate_box spell'>\n";
echo "<h3 style='color:yellow;'>" . fixHTML ($row ['Name_enUS'] );
if ($row ['NameSubtext_enUS'])
echo " — " . fixHTML ($row ['NameSubtext_enUS']);
echo "</h3>\n";
// spell icon
showSpellIcon ($row);
// spell type (left) and mana cost (right)
echo "<div>\n";
echo "<p class='item_lh'>" . expandSimple (SPELL_SCHOOLS, $row ['School'], false) . " Magic </p>\n";
if ($row ['ManaCost'] )
echo "<p class='item_rh'>" . $row ['ManaCost'] . ' ' . expandSimple (POWER_TYPES, $row ['PowerType'], false) . " </p>\n";
echo "</div>\n";
// clear float
echo "<div style='clear: both;'></div>\n";
// look up the cast time in another table
$spellCastTimeRow = dbQueryOneParam ("SELECT * FROM ".SPELLCASTTIMES." WHERE ID = ?", array ('i', &$row ['CastingTimeIndex']));
// cast time (left) and cooldown time (right)
echo "<div>\n";
echo "<span class='item_lh'>";
if ($spellCastTimeRow ['Base'] == 0)
echo "Instant cast\n";
else
echo convertTimeSeconds ($spellCastTimeRow ['Base']) . " sec cast\n";
echo "</span><span class='item_rh'>";
if ($row ['CategoryRecoveryTime'])
if ($row ['CategoryRecoveryTime'] >= 60000)
echo convertTimeMinutes($row ['CategoryRecoveryTime']) . " min cooldown\n";
else
echo convertTimeSeconds($row ['CategoryRecoveryTime']) . " sec cooldown\n";
echo "</span></div>\n";
// clear float
echo "<div style='clear: both;'></div>\n";
// look up the range in yet another table
$spellRangeRow = dbQueryOneParam ("SELECT * FROM ".SPELLRANGE." WHERE ID = ?", array ('i', &$row ['RangeIndex']));
if ($spellRangeRow ['RangeMax'] > 0)
echo '<br>' . $spellRangeRow ['RangeMax'] . ' yd range';
// look up the duration in yet another table again
$spellDurationRow = dbQueryOneParam ("SELECT * FROM ".SPELLDURATION." WHERE ID = ?", array ('i', &$row ['DurationIndex']));
if ($spellDurationRow)
$duration = $spellDurationRow ['Duration'];
else
$duration = 0;
// show what it casts
if (getCount ($row, 'EffectTriggerSpell_', SPELL_EFFECT_TRIGGER_SPELLS))
{
echo "<p><b>Effect trigger spells:</b><br>\n";
for ($i = 1; $i <= SPELL_EFFECT_TRIGGER_SPELLS; $i++)
if ($row ["EffectTriggerSpell_$i"])
echo '<br>' . lookupThing ($spells, $row ["EffectTriggerSpell_$i"], 'show_spell');
}
// show effects
if (getCount ($row, 'Effect_', SPELL_EFFECTS_COUNT))
{
echo "<p><b>Effects:</b>\n";
for ($i = 1; $i <= SPELL_EFFECTS_COUNT; $i++)
if ($row ["Effect_$i"])
echo '<br>' . expandSimple (SPELL_EFFECTS, $row ["Effect_$i"], false);
}
// show effect auras
if (getCount ($row, 'EffectAura_', SPELL_EFFECT_AURAS))
{
echo "<p><b>Auras:</b>\n";
for ($i = 1; $i <= SPELL_EFFECT_AURAS; $i++)
if ($row ["EffectAura_$i"])
echo '<br>' . expandSimple (SPELL_AURAS, $row ["EffectAura_$i"]);
} // end if any auras
// reagents
if (getCount ($row, 'Reagent_', SPELL_REAGENTS))
{
echo "<p><b>Reagents:</b><br>\n";
for ($i = 1; $i <= SPELL_REAGENTS; $i++)
{
$reagents [] = "Reagent_$i";
$reagentCounts [] = "ReagentCount_$i";
}
echo (lookupItems ($row,$reagents, $reagentCounts));
}
// show effect items
if (getCount ($row, 'EffectItemType_', SPELL_EFFECT_ITEM_TYPES))
{
echo "<p><b>Effect items:</b><br>\n";
$effectTypes = array ();
$effectMiscValues = array ();
for ($i = 1; $i <= SPELL_EFFECT_ITEM_TYPES; $i++)
{
$effectTypes [] = "EffectItemType_$i";
$effectMiscValues [] = "EffectMiscValue_$i";
}
tdh (lookupItems ($row, $effectTypes, $effectMiscValues));
}
// description
$description = $row ['Description_enUS'];
if ($description)
{
echo "<hr>\n";
// calculate spell roll ranges for all three effect die
for ($i = 1; $i <= SPELL_EFFECT_DICE; $i++)
$description = str_replace ('$s' . $i,
spellRoll ($row ["EffectDieSides_$i"], $row ["EffectBaseDice_$i"], $row ["EffectDicePerLevel_$i"],
$row ["EffectBasePoints_$i"]),
$description);
// calculate aura amounts for all three effect auras
for ($i = 1; $i <= SPELL_EFFECT_AURAS; $i++)
if ($row ["EffectAura_$i"] > 0 && $row ["EffectAuraPeriod_$i"] > 0)
{
$description = str_replace ('$o' . $i,
spellRoll ($row ["EffectDieSides_$i"], $row ["EffectBaseDice_$i"], $row ["EffectDicePerLevel_$i"],
$row ["EffectBasePoints_$i"], true) * $duration / $row ["EffectAuraPeriod_$i"],
$description);
}
echo "<span style='color:yellow;'>" . fixSpellText ($description, $duration) . "</span>\n";
} // end of having a description
// spell visuals
$SpellVisualID = $row ['SpellVisualID'];
if ($SpellVisualID)
{
echo "<hr><b style='color:deepskyblue;'>Visual effects</b>\n";
$visualRow = dbQueryOneParam ("SELECT * FROM ".SPELLVISUAL." WHERE ID = ?", array ('i', &$SpellVisualID ));
if (!$visualRow)
echo "Visual ID $SpellVisualID not on file\n";
else
{
$kits = array ('PrecastKit', 'CastKit', 'ImpactKit', 'StateKit', 'ChannelKit', 'AreaKit');
foreach ($kits as $kit)
{
$kitID = $visualRow [$kit];
if ($kitID)
{
echo "<br><b>" . fixHTML (str_replace ('Kit', ' Kit', $kit)) . "</b>: $kitID\n";
// now look up the animation for this kit
$animRow = dbQueryOneParam ("SELECT T1.Anim, T1.KitType, T2.Name FROM ".SPELLVISUALKIT." AS T1
LEFT JOIN ".SPELLVISUALANIMNAME." AS T2
ON (T2.AnimID = T1.Anim)
WHERE T1.ID = ?", array ('i', &$kitID ));
$animID = $animRow ['Anim'] . " (" . $animRow ['KitType'] . ") " . $animRow ['Name'];
echo " - animation: $animID";
} // end of this kit in use
} // end of each possible kit
$AreaModel = $visualRow ['AreaModel'];
if ($AreaModel)
{
echo "<br><b>Area model:</b>\n";
$areaRow = dbQueryOneParam ("SELECT * FROM ".SPELLVISUALEFFECTNAME." WHERE ID = ?", array ('i', &$AreaModel ));
if ($areaRow)
echo fixHTML ($areaRow ['FileName']);
else
echo "Not found.";
}
} // end of spell visual on file
} // end of having a visual ID
echo "</div>\n"; // end of simulation box
} // end of simulateSpell
function spellTrainers ()
{
global $id, $creatures;
comment ('WHO TRAINS THIS');
// what they train
$trainer_template = TRAINER_TEMPLATE;
$creature_template = CREATURE_TEMPLATE;
$results = dbQueryParam ("SELECT * FROM $trainer_template
LEFT JOIN $creature_template ON $trainer_template.template_entry = $creature_template.trainer_id
WHERE $trainer_template.playerspell = ? AND entry <= ".MAX_CREATURE." ORDER BY name, subname",
array ('i', &$id));
listItems ('NPCs that train this spell', TRAINER_TEMPLATE, count ($results), $results,
function ($row) use ($creatures)
{
listThing ($creatures, $row ['entry'], 'show_creature');
});
} // end of spellTrainers
function spellItemCasters ()
{
global $id, $items;
comment ('WHAT ITEMS CAST THIS');
$results = dbQueryParam ("SELECT * FROM ".ITEM_TEMPLATE.
" WHERE (spellid_1 = ? OR spellid_2 = ? OR spellid_3 = ? OR spellid_4 = ? OR spellid_5 = ?)
AND ignored = 0 ORDER BY name",
array ('iiiii', &$id, &$id, &$id, &$id, &$id));
listItems ('Items that cast this spell', ITEM_TEMPLATE, count ($results), $results,
function ($row) use ($items)
{
listThing ($items, $row ['entry'], 'show_item');
});
} // end of spellItemCasters
function spellCasters ()
{
global $id, $creatures;
$creature_template = CREATURE_TEMPLATE;
comment ('WHAT CREATURES CAST THIS');
// build a list of all 8 possible spell slots in CREATURE_SPELLS
$where = '';
$params = array ('');
for ($i = 1; $i <= CREATURE_SPELLS_COUNT; $i++)
{
$where .= " spellId_$i = ?";
if ($i < CREATURE_SPELLS_COUNT)
$where .= ' OR ';
$params [0] .= 'i';
$params [] = &$id;
}
// find entries in CREATURE_SPELLS which refer to this spell (in one of the CREATURE_SPELLS_COUNT (8) spots)
$creature_spells = CREATURE_SPELLS;
$results = dbQueryParam ("SELECT $creature_template.entry AS npc FROM $creature_spells
INNER JOIN $creature_template ON ($creature_template.spell_list_id = $creature_spells.entry)
WHERE ($where) AND $creature_template.entry <= " . MAX_CREATURE, $params);
listItems ('NPCs that cast this spell', CREATURE_SPELLS, count ($results), $results,
function ($row) use ($creatures)
{
listThing ($creatures, $row ['npc'], 'show_creature');
});
} // end of spellCasters
function spellTopLeft ($info)
{
global $id;
global $documentRoot, $executionDir;
$row = $info ['row'];
$extras = $info ['extras'];
$limit = $info ['limit'];
comment ('ICON');
showSpellIcon ($row);
echo "<p></p>\n";
comment ('SHORT LISTING OF FIELDS');
showOneThing (SPELL, 'ID', $id, "", "Name_enUS", $extras, $limit);
} // end of spellTopLeft
function spellTopMiddle ($info)
{
global $id;
global $documentRoot, $executionDir;
$row = $info ['row'];
$extras = $info ['extras'];
$limit = $info ['limit'];
simulateSpell ($row);
} // end of spellTopMiddle
function spellDetails ($info)
{
global $id;
$row = $info ['row'];
topSection ($info, function ($info) use ($id, $row)
{
topLeft ($info, 'spellTopLeft');
topMiddle ($info, 'spellTopMiddle');
});
middleSection ($info, function ($info) use ($id, $row)
{
spellTrainers ();
spellItemCasters ();
spellCasters ();
});
bottomSection ($info, function ($info) use ($id)
{
$extras = $info ['extras'];
comment ('SPELL DETAILS');
showOneThing (SPELL, 'ID', $id, "Spell details", "Name_enUS", $extras);
});
} // end of spellDetails
function showOneSpell ()
{
global $id;
comment ('SHOWING ONE SPELL');
if (($id === false && !repositionSearch()) || !checkID ())
return;
// we need the item info in this function
$row = dbQueryOneParam ("SELECT * FROM ".SPELL." WHERE ID = ?", array ('i', &$id));
if (!$row)
{
ShowWarning ("Spell $id is not on the database");
return;
} // end of not finding it
$extras = array (
'PowerType' => 'power_type',
'School' => 'spell_school',
'Targets' => 'spell_target_type_mask',
'Attributes' => 'spell_attributes_mask',
'AttributesEx' => 'spell_attributes_ex_mask',
'EquippedItemClass' => 'item_class',
'EquippedItemSubclass' => 'item_subclass_mask',
'InterruptFlags' => 'spell_interrupt_flags',
'Name_Mask' => 'mask',
'NameSubtext_Mask' => 'mask',
'Description_Mask' => 'mask',
'SpellVisualID' => 'spell_visual',
);
for ($i = 1; $i <= SPELL_REAGENTS; $i++)
$extras ["Reagent_$i"] = 'item';
for ($i = 1; $i <= SPELL_EFFECT_ITEM_TYPES; $i++)
$extras ["EffectItemType_$i"] = 'item';
for ($i = 1; $i <= SPELL_EFFECT_TRIGGER_SPELLS; $i++)
$extras ["EffectTriggerSpell_$i"] = 'spell';
for ($i = 1; $i <= SPELL_EFFECTS_COUNT; $i++)
$extras ["Effect_$i"] = 'spell_effect';
for ($i = 1; $i <= SPELL_EFFECT_AURAS; $i++)
$extras ["EffectAura_$i"] = 'spell_aura';
for ($i = 1; $i <= SPELL_IMPLICIT_TARGETS; $i++)
{
$extras ["ImplicitTargetA_$i"] = 'spell_implicit_target';
$extras ["ImplicitTargetB_$i"] = 'spell_implicit_target';
}
$name = $row ['Name_enUS'];
if ($row ['NameSubtext_enUS'])
$name .= ' <' . $row ['NameSubtext_enUS'] . '>';
setTitle ("Spell $name");
$limit = array (
'ID',
'School',
'ImplicitTargetA_1',
'StartRecoveryTime',
'SpellPriority',
'SpellIconId',
);
// we pass this stuff around to the helper functions
$info = array ('row' => $row, 'extras' => $extras, 'limit' => $limit);
// ready to go! show the page info and work our way down into the sub-functions
pageContent ($info, 'Spell', $name, 'spells', 'spellDetails', SPELL);
} // end of showOneSpell
function showSpells ()
{
global $where, $params, $sort_order, $matches;
setTitle ('Spells listing');
$sortFields = array (
'ID',
'Name_enUS',
'NameSubtext_enUS',
'School',
'Category',
'PowerType',
'Description_enUS',
);
if (!in_array ($sort_order, $sortFields))
$sort_order = 'Name_enUS';
$td = function ($s) use (&$row) { tdx ($row [$s]); };
$headings = array ('ID', 'Name', 'Subtext', 'School',
'Power Type', 'Reagents', 'Effect Item', 'Description');
$results = setUpSearch ('Spells', $sortFields, $headings);
if (!$results)
return;
$searchURI = makeSearchURI (true);
$pos = 0;
foreach ($results as $row)
{
$pos++;
echo "<tr>\n";
$id = $row ['ID'];
tdhr ("<a href='?action=show_spell&id=$id$searchURI&pos=$pos&max=$matches'>$id</a>");
tdhr ("<a href='?action=show_spell&id=$id$searchURI&pos=$pos&max=$matches'>" . $row ['Name_enUS'] . "</a>");
$td ('NameSubtext_enUS');
tdx (expandSimple (SPELL_SCHOOLS, $row ['School'], false));
tdx (expandSimple (POWER_TYPES, $row ['PowerType'], false));
$reagents = array ();
$reagentCounts = array ();
for ($i = 1; $i <= SPELL_REAGENTS; $i++)
{
$reagents [] = "Reagent_$i";
$reagentCounts [] = "ReagentCount_$i";
}
tdh (lookupItems ($row, $reagents, $reagentCounts));
$effectTypes = array ();
$effectMiscValues = array ();
for ($i = 1; $i <= SPELL_EFFECT_ITEM_TYPES; $i++)
{
$effectTypes [] = "EffectItemType_$i";
$effectMiscValues [] = "EffectMiscValue_$i";
}
tdh (lookupItems ($row, $effectTypes, $effectMiscValues));
$td ('Description_enUS');
showFilterColumn ($row);
echo "</tr>\n";
}
wrapUpSearch ();
} // end of showSpells
?>