Files
aowow/setup/tools/filegen/enchants.func.php
Sarjuuk 51f2828f6f - moved shared setup functions from FileGen to new CLISetup
- removed web-setup
- new CLI parameters
  --account    : create initial account(s)
  --siteconfig : edit php/aowow config values
  --dbconfig   : set up db connection
  --sql        : create db content from world/dbc-tables
  --firstrun   : [NYI] step by step initial setup

- some fixes by the wayside
  * display required arena bracket for extendedCost
  * achievement chains are searchable again
  * category trees for factions should now be correct
  * trainer tab on spell detail page reapeared
  * userMenu item 'Settings' no longer breaks the page
  * display abilities of shapeshift in tab on spell detail page
  * corrected reading ?_sourcestrings for titles
  * fixed error on race detail page
  * added simple descriptions to skill detail page
  * fixed tab "reward from" (achievement) on title detail page
  * fixed alphabetical order of some filter-dropdowns
  * fixed skill colors for spells
  * fixed power display for rune-based spells, that also cost mana
  * added more information to zones
  * also check mail_loot_template for achivements
  * fixed bug, where loot_template-ids would be reused for multiple templates
  * display sourcemore for pvp-sources
2015-05-11 22:44:54 +02:00

225 lines
9.1 KiB
PHP

<?php
if (!defined('AOWOW_REVISION'))
die('illegal access');
if (!CLI)
die('not in cli mode');
// Create 'enchants'-file for available locales
// this script requires the following dbc-files to be parsed and available
// Spells, SkillLineAbility, SpellItemEnchantment
// todo (high): restructure to work more efficiently (outer loop: spells, inner loop: locales)
/* Examples
15: {
name:'Leichtes Rüstungsset',
quality:1,
icon:'INV_Misc_ArmorKit_17',
source:-2304,
skill:-1,
slots:525008,
enchantment:'Verstärkt (+8 Rüstung)',
jsonequip:{"armor":8,"reqlevel":1},
temp:0,
classes:0,
gearscore:1
},
2928: {
name:'Ring - Zaubermacht',
quality:-1,
icon:'INV_Misc_Note_01',
source:27924,
skill:333,
slots:1024,
enchantment:'+12 Zaubermacht',
jsonequip:{"splpwr":12},
temp:0,
classes:0,
gearscore:15
},
3231: {
name:['Handschuhe - Waffenkunde','Armschiene - Waffenkunde'],
quality:-1,
icon:'spell_holy_greaterheal',
source:[44484,44598],
skill:333,
slots:[512,256],
enchantment:'+15 Waffenkundewertung',
jsonequip:{reqlevel:60,"exprtng":15},
temp:0,
classes:0,
gearscore:20 // nope, i'm not doing this
},
*/
function enchants()
{
// from g_item_slots: 13:"One-Hand", 26:"Ranged", 17:"Two-Hand",
$slotPointer = [13, 17, 26, 26, 13, 17, 17, 13, 17, null, 17, null, null, 13, null, 13, null, null, null, null, 17];
$castItems = [];
$successs = true;
$enchantSpells = new SpellList([['effect1Id', 53], ['name_loc0', 'QA%', '!'], CFG_SQL_LIMIT_NONE]); // enchantItemPermanent && !qualityAssurance
// check directory-structure
foreach (Util::$localeStrings as $dir)
if (!CLISetup::writeDir('datasets/'.$dir))
$success = false;
$enchIds = [];
foreach ($enchantSpells->iterate() as $__)
$enchIds[] = $enchantSpells->getField('effect1MiscValue');
$enchMisc = [];
$enchJSON = Util::parseItemEnchantment($enchIds, false, $enchMisc);
foreach (CLISetup::$localeIds as $lId)
{
set_time_limit(120);
User::useLocale($lId);
Lang::load(Util::$localeStrings[$lId]);
$enchantsOut = [];
foreach ($enchantSpells->iterate() as $__)
{
// slots have to be recalculated
$slot = 0;
if ($enchantSpells->getField('equippedItemClass') == 4) // armor
{
if ($invType = $enchantSpells->getField('equippedItemInventoryTypeMask'))
$slot = $invType >> 1;
else /* if (equippedItemSubClassMask == 64) */ // shields have it their own way <_<
$slot = (1 << (14 - 1));
}
else if ($enchantSpells->getField('equippedItemClass') == 2) // weapon
{
foreach ($slotPointer as $i => $sp)
{
if (!$sp)
continue;
if ((1 << $i) & $enchantSpells->getField('equippedItemSubClassMask'))
{
if ($sp == 13) // also mainHand & offHand *siiigh*
$slot |= ((1 << (21 - 1)) | (1 << (22 - 1)));
$slot |= (1 << ($sp - 1));
}
}
}
$eId = $enchantSpells->getField('effect1MiscValue');
// defaults
$ench = array(
'name' => [], // set by skill or item
'quality' => -1, // modified if item
'icon' => strToLower($enchantSpells->getField('iconString')), // item over spell
'source' => [], // <0: item; >0:spell
'skill' => -1, // modified if skill
'slots' => [], // determined per spell but set per item
'enchantment' => Util::localizedString($enchMisc[$eId]['text'], 'text'),
'jsonequip' => @$enchJSON[$eId] ?: [],
'temp' => 0, // always 0
'classes' => 0, // modified by item
);
if (isset($enchMisc[$eId]['reqskill']))
$ench['jsonequip']['reqskill'] = $enchMisc[$eId]['reqskill'];
if (isset($enchMisc[$eId]['reqskillrank']))
$ench['jsonequip']['reqskill'] = $enchMisc[$eId]['reqskillrank'];
if (isset($enchMisc[$eId]['requiredLevel']))
$ench['jsonequip']['requiredLevel'] = $enchMisc[$eId]['requiredLevel'];
// check if the spell has an entry in skill_line_ability -> Source:Profession
if ($skills = $enchantSpells->getField('skillLines'))
{
$ench['name'][] = $enchantSpells->getField('name', true);
$ench['source'][] = $enchantSpells->id;
$ench['skill'] = $skills[0];
$ench['slots'][] = $slot;
}
// check if this spell can be cast via item -> Source:Item
if (!isset($castItems[$enchantSpells->id]))
$castItems[$enchantSpells->id] = new ItemList([['spellId1', $enchantSpells->id], ['name_loc0', 'Scroll of Enchant%', '!']]); // do not reuse enchantment scrolls
$cI = &$castItems[$enchantSpells->id]; // this construct is a bit .. unwieldy
foreach ($cI->iterate() as $__)
{
$ench['name'][] = $cI->getField('name', true);
$ench['source'][] = -$cI->id;
$ench['icon'] = strTolower($cI->getField('iconString'));
$ench['slots'][] = $slot;
if ($cI->getField('quality') > $ench['quality'])
$ench['quality'] = $cI->getField('quality');
if ($cI->getField('requiredClass') > 0)
{
$ench['classes'] = $cI->getField('requiredClass');
$ench['jsonequip']['classes'] = $cI->getField('requiredClass');
}
if (!isset($ench['jsonequip']['reqlevel']))
if ($cI->getField('requiredLevel') > 0)
$ench['jsonequip']['reqlevel'] = $cI->getField('requiredLevel');
}
// enchant spell not in use
if (empty($ench['source']))
continue;
// everything gathered
if (isset($enchantsOut[$eId])) // already found, append data
{
foreach ($enchantsOut[$eId] as $k => $v)
{
if (is_array($v))
{
while ($pop = array_pop($ench[$k]))
$enchantsOut[$eId][$k][] = $pop;
}
else
{
if ($k == 'quality') // quality:-1 if spells and items are mixed
{
if ($enchantsOut[$eId]['source'][0] > 0 && $ench['source'][0] < 0)
$enchantsOut[$eId][$k] = -1;
else if ($enchantsOut[$eId]['source'][0] < 0 && $ench['source'][0] > 0)
$enchantsOut[$eId][$k] = -1;
else
$enchantsOut[$eId][$k] = $ench[$k];
}
else if ($enchantsOut[$eId][$k] <= 0)
$enchantsOut[$eId][$k] = $ench[$k];
}
}
}
else // nothing yet, create new
$enchantsOut[$eId] = $ench;
}
// walk over each entry and strip single-item arrays
foreach ($enchantsOut as &$ench)
foreach ($ench as $k => $v)
if (is_array($v) && count($v) == 1 && $k != 'jsonequip')
$ench[$k] = $v[0];
$toFile = "var g_enchants = ".Util::toJSON($enchantsOut).";";
$file = 'datasets/'.User::$localeString.'/enchants';
if (!CLISetup::writeFile($file, $toFile))
$success = false;
}
return $successs;
}
?>