function glyphs() { $success = true; $glyphList = DB::Aowow()->Select('SELECT i.id AS itemId, i.*, IF (g.typeFlags & 0x1, 2, 1) AS type, i.subclass AS classs, i.requiredLevel AS level, s1.Id AS glyphSpell, ic.iconString AS icon, s1.skillLine1 AS skillId, s2.Id AS glyphEffect, s2.Id AS ARRAY_KEY FROM ?_items i JOIN ?_spell s1 ON s1.Id = i.spellid1 JOIN ?_glyphproperties g ON g.Id = s1.effect1MiscValue JOIN ?_spell s2 ON s2.Id = g.spellId JOIN ?_icons ic ON ic.Id = s1.iconIdAlt WHERE i.classBak = 16'); // check directory-structure foreach (Util::$localeStrings as $dir) { if (!CLISetup::writeDir('datasets/' . $dir)) { $success = false; } } $glyphSpells = new SpellList(array(['s.id', array_keys($glyphList)], CFG_SQL_LIMIT_NONE)); foreach (CLISetup::$localeIds as $lId) { set_time_limit(30); User::useLocale($lId); Lang::load(Util::$localeStrings[$lId]); $glyphsOut = []; foreach ($glyphSpells->iterate() as $__) { $pop = $glyphList[$glyphSpells->id]; if (!$pop['glyphEffect']) { continue; } if ($glyphSpells->getField('effect1Id') != 6 && $glyphSpells->getField('effect2Id') != 6 && $glyphSpells->getField('effect3Id') != 6) { continue; } $glyphsOut[$pop['itemId']] = array('name' => Util::localizedString($pop, 'name'), 'description' => $glyphSpells->parseText()[0], 'icon' => $pop['icon'], 'type' => $pop['type'], 'classs' => $pop['classs'], 'skill' => $pop['skillId'], 'level' => $pop['level']); } $toFile = "var g_glyphs = " . Util::toJSON($glyphsOut) . ";"; $file = 'datasets/' . User::$localeString . '/glyphs'; if (!CLISetup::writeFile($file, $toFile)) { $success = false; } } return $success; }
private function _searchSpell($cndBase) { $result = []; $cnd = array_merge($cndBase, array(['OR', ['s.typeCat', [0, -9]], ['AND', ['s.cuFlags', SPELL_CU_TRIGGERED, '&'], ['s.typeCat', [7, -2]]]], $this->createLookup())); $misc = new SpellList($cnd); if ($data = $misc->getListviewData()) { if ($this->searchMask & SEARCH_TYPE_REGULAR) { $this->extendGlobalData($misc->getJSGlobals(GLOBALINFO_SELF | GLOBALINFO_RELATED)); } if ($this->searchMask & SEARCH_TYPE_OPEN) { foreach ($misc->iterate() as $__) { $data[$misc->id]['param1'] = strToLower($misc->getField('iconString')); } } $result = array('type' => TYPE_SPELL, 'appendix' => ' (Spell)', 'matches' => $misc->getMatches(), 'file' => SpellList::$brickFile, 'data' => $data, 'params' => ['name' => '$LANG.tab_uncategorizedspells', 'visibleCols' => "\$['level']", 'hiddenCols' => "\$['skill']"]); if ($misc->getMatches() > $this->maxResults) { $result['params']['note'] = sprintf(Util::$tryNarrowingString, 'LANG.lvnote_spellsfound', $misc->getMatches(), $this->maxResults); $result['params']['_truncated'] = 1; } if (isset($result['params']['note'])) { $result['params']['note'] .= ' + LANG.dash + $WH.sprintf(LANG.lvnote_filterresults, \'?spells=0&filter=na=' . urlencode($this->search) . '\')'; } else { $result['params']['note'] = '$$WH.sprintf(LANG.lvnote_filterresults, \'?spells=0&filter=na=' . urlencode($this->search) . '\')'; } } return $result; }
public function renderTooltip($interactive = false, $subOf = 0, $enhance = []) { if ($this->error) { return; } $_name = $this->getField('name', true); $_reqLvl = $this->curTpl['requiredLevel']; $_quality = $this->curTpl['quality']; $_flags = $this->curTpl['flags']; $_class = $this->curTpl['class']; $_subClass = $this->curTpl['subClass']; $_slot = $this->curTpl['slot']; $causesScaling = false; if (!empty($enhance['r'])) { if ($this->getRandEnchantForItem($enhance['r'])) { $_name .= ' ' . Util::localizedString($this->enhanceR, 'name'); $randEnchant = ''; for ($i = 1; $i < 6; $i++) { if ($this->enhanceR['enchantId' . $i] <= 0) { continue; } $enchant = DB::Aowow()->selectRow('SELECT * FROM ?_itemenchantment WHERE Id = ?d', $this->enhanceR['enchantId' . $i]); if ($this->enhanceR['allocationPct' . $i] > 0) { $amount = intVal($this->enhanceR['allocationPct' . $i] * $this->generateEnchSuffixFactor()); $randEnchant .= '<span>' . str_replace('$i', $amount, Util::localizedString($enchant, 'name')) . '</span><br />'; } else { $randEnchant .= '<span>' . Util::localizedString($enchant, 'name') . '</span><br />'; } } } else { unset($enhance['r']); } } if (isset($enhance['s']) && !in_array($_slot, [INVTYPE_WRISTS, INVTYPE_WAIST, INVTYPE_HANDS])) { unset($enhance['s']); } // IMPORTAT: DO NOT REMOVE THE HTML-COMMENTS! THEY ARE REQUIRED TO UPDATE THE TOOLTIP CLIENTSIDE $x = ''; // upper table: stats if (!$subOf) { $x .= '<table><tr><td>'; } // name; quality if ($subOf) { $x .= '<span class="q' . $_quality . '"><a href="?item=' . $this->id . '">' . $_name . '</a></span>'; } else { $x .= '<b class="q' . $_quality . '">' . $_name . '</b>'; } // heroic tag if ($_flags & ITEM_FLAG_HEROIC && $_quality == ITEM_QUALITY_EPIC) { $x .= '<br /><span class="q2">' . Lang::item('heroic') . '</span>'; } // requires map (todo: reparse ?_zones for non-conflicting data; generate Link to zone) if ($_ = $this->curTpl['map']) { $map = DB::Aowow()->selectRow('SELECT * FROM ?_zones WHERE mapId = ?d LIMIT 1', $_); $x .= '<br /><a href="?zone=' . $_ . '" class="q1">' . Util::localizedString($map, 'name') . '</a>'; } // requires area if ($this->curTpl['area']) { $area = DB::Aowow()->selectRow('SELECT * FROM ?_zones WHERE Id=?d LIMIT 1', $this->curTpl['area']); $x .= '<br />' . Util::localizedString($area, 'name'); } // conjured if ($_flags & ITEM_FLAG_CONJURED) { $x .= '<br />' . Lang::item('conjured'); } // bonding if ($_flags & ITEM_FLAG_ACCOUNTBOUND) { $x .= '<br /><!--bo-->' . Lang::item('bonding', 0); } else { if ($this->curTpl['bonding']) { $x .= '<br /><!--bo-->' . Lang::item('bonding', $this->curTpl['bonding']); } } // unique || unique-equipped || unique-limited if ($this->curTpl['maxCount'] > 0) { $x .= '<br />' . Lang::item('unique'); if ($this->curTpl['maxCount'] > 1) { $x .= ' (' . $this->curTpl['maxCount'] . ')'; } } else { if ($_flags & ITEM_FLAG_UNIQUEEQUIPPED) { $x .= '<br />' . Lang::item('uniqueEquipped'); } else { if ($this->curTpl['itemLimitCategory']) { $limit = DB::Aowow()->selectRow("SELECT * FROM ?_itemlimitcategory WHERE id = ?", $this->curTpl['itemLimitCategory']); $x .= '<br />' . ($limit['isGem'] ? Lang::item('uniqueEquipped') : Lang::item('unique')) . Lang::main('colon') . Util::localizedString($limit, 'name') . ' (' . $limit['count'] . ')'; } } } // max duration if ($dur = $this->curTpl['duration']) { $x .= "<br />" . Lang::game('duration') . Lang::main('colon') . Util::formatTime(abs($dur) * 1000) . ($this->curTpl['flagsCustom'] & 0x1 ? ' (' . Lang::item('realTime') . ')' : null); } // required holiday if ($eId = $this->curTpl['eventId']) { if ($hName = DB::Aowow()->selectRow('SELECT h.* FROM ?_holidays h JOIN ?_events e ON e.holidayId = h.id WHERE e.id = ?d', $eId)) { $x .= '<br />' . sprintf(Lang::game('requires'), '<a href="' . $eId . '" class="q1">' . Util::localizedString($hName, 'name') . '</a>'); } } // item begins a quest if ($this->curTpl['startQuest']) { $x .= '<br /><a class="q1" href="?quest=' . $this->curTpl['startQuest'] . '">' . Lang::item('startQuest') . '</a>'; } // containerType (slotCount) if ($this->curTpl['slots'] > 0) { $fam = $this->curTpl['bagFamily'] ? log($this->curTpl['bagFamily'], 2) + 1 : 0; // word order differs <_< if (in_array(User::$localeId, [LOCALE_FR, LOCALE_ES, LOCALE_RU])) { $x .= '<br />' . sprintf(Lang::item('bagSlotString'), Lang::item('bagFamily', $fam), $this->curTpl['slots']); } else { $x .= '<br />' . sprintf(Lang::item('bagSlotString'), $this->curTpl['slots'], Lang::item('bagFamily', $fam)); } } if (in_array($_class, [ITEM_CLASS_ARMOR, ITEM_CLASS_WEAPON, ITEM_CLASS_AMMUNITION])) { $x .= '<table width="100%"><tr>'; // Class if ($_slot) { $x .= '<td>' . Lang::item('inventoryType', $_slot) . '</td>'; } // Subclass if ($_class == ITEM_CLASS_ARMOR && $_subClass > 0) { $x .= '<th><!--asc' . $_subClass . '-->' . Lang::item('armorSubClass', $_subClass) . '</th>'; } else { if ($_class == ITEM_CLASS_WEAPON) { $x .= '<th>' . Lang::item('weaponSubClass', $_subClass) . '</th>'; } else { if ($_class == ITEM_CLASS_AMMUNITION) { $x .= '<th>' . Lang::item('projectileSubClass', $_subClass) . '</th>'; } } } $x .= '</tr></table>'; } else { if ($_slot && $_class != ITEM_CLASS_CONTAINER) { // yes, slot can occur on random items and is then also displayed <_< .. excluding Bags >_> $x .= '<br />' . Lang::item('inventoryType', $_slot) . '<br />'; } else { $x .= '<br />'; } } // Weapon/Ammunition Stats (not limited to weapons (see item:1700)) $speed = $this->curTpl['delay'] / 1000; $dmgmin1 = $this->curTpl['dmgMin1'] + $this->curTpl['dmgMin2']; $dmgmax1 = $this->curTpl['dmgMax1'] + $this->curTpl['dmgMax2']; $dps = $speed ? ($dmgmin1 + $dmgmax1) / (2 * $speed) : 0; if ($_class == ITEM_CLASS_AMMUNITION && $dmgmin1 && $dmgmax1) { $x .= Lang::item('addsDps') . ' ' . number_format(($dmgmin1 + $dmgmax1) / 2, 1) . ' ' . Lang::item('dps2') . '<br />'; } else { if ($dps) { if ($_class == ITEM_CLASS_WEAPON) { $x .= '<table width="100%"><tr>'; $x .= '<td><!--dmg-->' . sprintf($this->curTpl['dmgType1'] ? Lang::item('damageMagic') : Lang::item('damagePhys'), $this->curTpl['dmgMin1'] . ' - ' . $this->curTpl['dmgMax1'], Lang::game('sc', $this->curTpl['dmgType1'])) . '</td>'; $x .= '<th>' . Lang::item('speed') . ' <!--spd-->' . number_format($speed, 2) . '</th>'; // do not use localized format here! $x .= '</tr></table>'; } else { $x .= '<!--dmg-->' . sprintf($this->curTpl['dmgType1'] ? Lang::item('damageMagic') : Lang::item('damagePhys'), $this->curTpl['dmgMin1'] . ' - ' . $this->curTpl['dmgMax1'], Lang::game('sc', $this->curTpl['dmgType1'])) . '<br />'; } // secondary damage is set if ($this->curTpl['dmgMin2']) { $x .= '+' . sprintf($this->curTpl['dmgType2'] ? Lang::item('damageMagic') : Lang::item('damagePhys'), $this->curTpl['dmgMin2'] . ' - ' . $this->curTpl['dmgMax2'], Lang::game('sc', $this->curTpl['dmgType2'])) . '<br />'; } if ($_class == ITEM_CLASS_WEAPON) { $x .= '<!--dps-->(' . number_format($dps, 1) . ' ' . Lang::item('dps') . ')<br />'; } // do not use localized format here! // display FeralAttackPower if set if ($fap = $this->getFeralAP()) { $x .= '<span class="c11"><!--fap-->(' . $fap . ' ' . Lang::item('fap') . ')</span><br />'; } } } // Armor if ($_class == ITEM_CLASS_ARMOR && $this->curTpl['armorDamageModifier'] > 0) { $spanI = 'class="q2"'; if ($interactive) { $spanI = 'class="q2 tip" onmouseover="$WH.Tooltip.showAtCursor(event, $WH.sprintf(LANG.tooltip_armorbonus, ' . $this->curTpl['armorDamageModifier'] . '), 0, 0, \'q\')" onmousemove="$WH.Tooltip.cursorUpdate(event)" onmouseout="$WH.Tooltip.hide()"'; } $x .= '<span ' . $spanI . '><!--addamr' . $this->curTpl['armorDamageModifier'] . '--><span>' . sprintf(Lang::item('armor'), intVal($this->curTpl['armor'] + $this->curTpl['armorDamageModifier'])) . '</span></span><br />'; } else { if ($this->curTpl['armor'] + $this->curTpl['armorDamageModifier'] > 0) { $x .= '<span><!--amr-->' . sprintf(Lang::item('armor'), intVal($this->curTpl['armor'] + $this->curTpl['armorDamageModifier'])) . '</span><br />'; } } // Block if ($this->curTpl['block']) { $x .= '<span>' . sprintf(Lang::item('block'), $this->curTpl['block']) . '</span><br />'; } // Item is a gem (don't mix with sockets) if ($geId = $this->curTpl['gemEnchantmentId']) { $gemEnch = DB::Aowow()->selectRow('SELECT * FROM ?_itemenchantment WHERE id = ?d', $geId); $x .= '<span class="q1"><a href="?enchantment=' . $geId . '">' . Util::localizedString($gemEnch, 'name') . '</a></span><br />'; // activation conditions for meta gems if (!empty($gemEnch['conditionId'])) { if ($gemCnd = DB::Aowow()->selectRow('SELECT * FROM ?_itemenchantmentcondition WHERE id = ?d', $gemEnch['conditionId'])) { for ($i = 1; $i < 6; $i++) { if (!$gemCnd['color' . $i]) { continue; } switch ($gemCnd['comparator' . $i]) { case 2: // requires less <color> than (<value> || <comparecolor>) gems // requires less <color> than (<value> || <comparecolor>) gems case 5: // requires at least <color> than (<value> || <comparecolor>) gems $sp = (int) $gemCnd['value' . $i] > 1; $x .= '<span class="q0">' . Lang::achievement('reqNumCrt') . ' ' . sprintf(Lang::item('gemConditions', $gemCnd['comparator' . $i], $sp), $gemCnd['value' . $i], Lang::item('gemColors', $gemCnd['color' . $i] - 1)) . '</span><br />'; break; case 3: // requires more <color> than (<value> || <comparecolor>) gems $x .= '<span class="q0">' . Lang::achievement('reqNumCrt') . ' ' . sprintf(Lang::item('gemConditions', 3), Lang::item('gemColors', $gemCnd['color' . $i] - 1), Lang::item('gemColors', $gemCnd['cmpColor' . $i] - 1)) . '</span><br />'; break; } } } } } // Random Enchantment - if random enchantment is set, prepend stats from it if ($this->curTpl['randomEnchant'] && !isset($enhance['r'])) { $x .= '<span class="q2">' . Lang::item('randEnchant') . '</span><br />'; } else { if (isset($enhance['r'])) { $x .= $randEnchant; } } // itemMods (display stats and save ratings for later use) for ($j = 1; $j <= 10; $j++) { $type = $this->curTpl['statType' . $j]; $qty = $this->curTpl['statValue' . $j]; if (!$qty || $type <= 0) { continue; } // base stat if ($type >= ITEM_MOD_AGILITY && $type <= ITEM_MOD_STAMINA) { $x .= '<span><!--stat' . $type . '-->' . ($qty > 0 ? '+' : '-') . abs($qty) . ' ' . Lang::item('statType', $type) . '</span><br />'; } else { // rating with % for reqLevel $green[] = $this->parseRating($type, $qty, $interactive, $causesScaling); } } // magic resistances foreach (Util::$resistanceFields as $j => $rowName) { if ($rowName && $this->curTpl[$rowName] != 0) { $x .= '+' . $this->curTpl[$rowName] . ' ' . Lang::game('resistances', $j) . '<br />'; } } // Enchantment if (isset($enhance['e'])) { if ($enchText = DB::Aowow()->selectRow('SELECT * FROM ?_itemenchantment WHERE Id = ?', $enhance['e'])) { $x .= '<span class="q2"><!--e-->' . Util::localizedString($enchText, 'name') . '</span><br />'; } else { unset($enhance['e']); $x .= '<!--e-->'; } } else { // enchantment placeholder $x .= '<!--e-->'; } // Sockets w/ Gems if (!empty($enhance['g'])) { $gems = DB::Aowow()->select(' SELECT it.id AS ARRAY_KEY, ic.iconString, ae.*, it.gemColorMask AS colorMask FROM ?_items it JOIN ?_itemenchantment ae ON ae.id = it.gemEnchantmentId JOIN ?_icons ic ON ic.id = -it.displayId WHERE it.id IN (?a)', $enhance['g']); foreach ($enhance['g'] as $k => $v) { if ($v && !in_array($v, array_keys($gems))) { // 0 is valid unset($enhance['g'][$k]); } } } else { $enhance['g'] = []; } // zero fill empty sockets $sockCount = isset($enhance['s']) ? 1 : 0; if (!empty($this->json[$this->id]['nsockets'])) { $sockCount += $this->json[$this->id]['nsockets']; } while ($sockCount > count($enhance['g'])) { $enhance['g'][] = 0; } $enhance['g'] = array_reverse($enhance['g']); $hasMatch = 1; // fill native sockets for ($j = 1; $j <= 3; $j++) { if (!$this->curTpl['socketColor' . $j]) { continue; } for ($i = 0; $i < 4; $i++) { if ($this->curTpl['socketColor' . $j] & 1 << $i) { $colorId = $i; } } $pop = array_pop($enhance['g']); $col = $pop ? 1 : 0; $hasMatch &= $pop ? $gems[$pop]['colorMask'] & 1 << $colorId ? 1 : 0 : 0; $icon = $pop ? sprintf(Util::$bgImagePath['tiny'], STATIC_URL, strtolower($gems[$pop]['iconString'])) : null; $text = $pop ? Util::localizedString($gems[$pop], 'name') : Lang::item('socket', $colorId); if ($interactive) { $x .= '<a href="?items=3&filter=cr=81;crs=' . ($colorId + 1) . ';crv=0" class="socket-' . Util::$sockets[$colorId] . ' q' . $col . '" ' . $icon . '>' . $text . '</a><br />'; } else { $x .= '<span class="socket-' . Util::$sockets[$colorId] . ' q' . $col . '" ' . $icon . '>' . $text . '</span><br />'; } } // fill extra socket if (isset($enhance['s'])) { $pop = array_pop($enhance['g']); $col = $pop ? 1 : 0; $icon = $pop ? sprintf(Util::$bgImagePath['tiny'], STATIC_URL, strtolower($gems[$pop]['iconString'])) : null; $text = $pop ? Util::localizedString($gems[$pop], 'name') : Lang::item('socket', -1); if ($interactive) { $x .= '<a href="?items=3&filter=cr=81;crs=5;crv=0" class="socket-prismatic q' . $col . '" ' . $icon . '>' . $text . '</a><br />'; } else { $x .= '<span class="socket-prismatic q' . $col . '" ' . $icon . '>' . $text . '</span><br />'; } } else { // prismatic socket placeholder $x .= '<!--ps-->'; } if ($_ = $this->curTpl['socketBonus']) { $sbonus = DB::Aowow()->selectRow('SELECT * FROM ?_itemenchantment WHERE Id = ?d', $_); $x .= '<span class="q' . ($hasMatch ? '2' : '0') . '">' . Lang::item('socketBonus') . Lang::main('colon') . '<a href="?enchantment=' . $_ . '">' . Util::localizedString($sbonus, 'name') . '</a></span><br />'; } // durability if ($dur = $this->curTpl['durability']) { $x .= Lang::item('durability') . ' ' . $dur . ' / ' . $dur . '<br />'; } // required classes if ($classes = Lang::getClassString($this->curTpl['requiredClass'], $jsg, $__)) { foreach ($jsg as $js) { if (empty($this->jsGlobals[TYPE_CLASS][$js])) { $this->jsGlobals[TYPE_CLASS][$js] = $js; } } $x .= Lang::game('classes') . Lang::main('colon') . $classes . '<br />'; } // required races if ($races = Lang::getRaceString($this->curTpl['requiredRace'], $__, $jsg, $__)) { foreach ($jsg as $js) { if (empty($this->jsGlobals[TYPE_RACE][$js])) { $this->jsGlobals[TYPE_RACE][$js] = $js; } } if ($races != Lang::game('ra', 0)) { // not "both", but display combinations like: troll, dwarf $x .= Lang::game('races') . Lang::main('colon') . $races . '<br />'; } } // required honorRank (not used anymore) if ($rhr = $this->curTpl['requiredHonorRank']) { $x .= sprintf(Lang::game('requires'), Lang::game('pvpRank', $rhr)) . '<br />'; } // required CityRank..? // what the f.. // required level if ($_flags & ITEM_FLAG_ACCOUNTBOUND && $_quality == ITEM_QUALITY_HEIRLOOM) { $x .= sprintf(Lang::game('reqLevelHlm'), ' 1' . Lang::game('valueDelim') . MAX_LEVEL . ' (' . ($interactive ? sprintf(Util::$changeLevelString, MAX_LEVEL) : '<!--lvl-->' . MAX_LEVEL) . ')') . '<br />'; } else { if ($_reqLvl > 1) { $x .= sprintf(Lang::game('reqLevel'), $_reqLvl) . '<br />'; } } // required arena team rating / personal rating / todo (low): sort out what kind of rating if (!empty($this->getExtendedCost([], $reqRating)[$this->id]) && $reqRating) { $x .= sprintf(Lang::item('reqRating', $reqRating[1]), $reqRating[0]) . '<br />'; } // item level if (in_array($_class, [ITEM_CLASS_ARMOR, ITEM_CLASS_WEAPON])) { $x .= Lang::item('itemLevel') . ' ' . $this->curTpl['itemLevel'] . '<br />'; } // required skill if ($reqSkill = $this->curTpl['requiredSkill']) { $_ = '<a class="q1" href="?skill=' . $reqSkill . '">' . SkillList::getName($reqSkill) . '</a>'; if ($this->curTpl['requiredSkillRank'] > 0) { $_ .= ' (' . $this->curTpl['requiredSkillRank'] . ')'; } $x .= sprintf(Lang::game('requires'), $_) . '<br />'; } // required spell if ($reqSpell = $this->curTpl['requiredSpell']) { $x .= Lang::game('requires2') . ' <a class="q1" href="?spell=' . $reqSpell . '">' . SpellList::getName($reqSpell) . '</a><br />'; } // required reputation w/ faction if ($reqFac = $this->curTpl['requiredFaction']) { $x .= sprintf(Lang::game('requires'), '<a class="q1" href=?faction="' . $reqFac . '">' . FactionList::getName($reqFac) . '</a> - ' . Lang::game('rep', $this->curTpl['requiredFactionRank'])) . '<br />'; } // locked or openable if ($locks = Lang::getLocks($this->curTpl['lockId'], true)) { $x .= '<span class="q0">' . Lang::item('locked') . '<br />' . implode('<br />', $locks) . '</span><br />'; } else { if ($this->curTpl['flags'] & ITEM_FLAG_OPENABLE) { $x .= '<span class="q2">' . Lang::item('openClick') . '</span><br />'; } } // upper table: done if (!$subOf) { $x .= '</td></tr></table>'; } // spells on item if (!$this->canTeachSpell()) { $itemSpellsAndTrigger = []; for ($j = 1; $j <= 5; $j++) { if ($this->curTpl['spellId' . $j] > 0) { $cd = $this->curTpl['spellCooldown' . $j]; if ($cd < $this->curTpl['spellCategoryCooldown' . $j]) { $cd = $this->curTpl['spellCategoryCooldown' . $j]; } $cd = $cd < 5000 ? null : ' (' . sprintf(Lang::game('cooldown'), Util::formatTime($cd)) . ')'; $itemSpellsAndTrigger[$this->curTpl['spellId' . $j]] = [$this->curTpl['spellTrigger' . $j], $cd]; } } if ($itemSpellsAndTrigger) { $cooldown = ''; $itemSpells = new SpellList(array(['s.id', array_keys($itemSpellsAndTrigger)])); foreach ($itemSpells->iterate() as $__) { if ($parsed = $itemSpells->parseText('description', $_reqLvl > 1 ? $_reqLvl : MAX_LEVEL, false, $causesScaling)[0]) { if ($interactive) { $link = '<a href="?spell=' . $itemSpells->id . '">%s</a>'; $parsed = preg_replace_callback('/([^;]*)( <small>.*?<\\/small>)([^&]*)/i', function ($m) use($link) { $m[1] = $m[1] ? sprintf($link, $m[1]) : ''; $m[3] = $m[3] ? sprintf($link, $m[3]) : ''; return $m[1] . $m[2] . $m[3]; }, $parsed, -1, $nMatches); if (!$nMatches) { $parsed = sprintf($link, $parsed); } } $green[] = Lang::item('trigger', $itemSpellsAndTrigger[$itemSpells->id][0]) . $parsed . $itemSpellsAndTrigger[$itemSpells->id][1]; } } } } // lower table (ratings, spells, ect) if (!$subOf) { $x .= '<table><tr><td>'; } if (isset($green)) { foreach ($green as $j => $bonus) { if ($bonus) { $x .= '<span class="q2">' . $bonus . '</span><br />'; } } } // Item Set $pieces = []; if ($setId = $this->getField('itemset')) { // while Ids can technically be used multiple times the only difference in data are the items used. So it doesn't matter what we get $itemset = new ItemsetList(array(['id', $setId])); if (!$itemset->error && $itemset->pieceToSet) { $pieces = DB::Aowow()->select(' SELECT b.id AS ARRAY_KEY, b.name_loc0, b.name_loc2, b.name_loc3, b.name_loc6, b.name_loc8, GROUP_CONCAT(a.id SEPARATOR \':\') AS equiv FROM ?_items a, ?_items b WHERE a.slotBak = b.slotBak AND a.itemset = b.itemset AND b.id IN (?a) GROUP BY b.id;', array_keys($itemset->pieceToSet)); foreach ($pieces as $k => &$p) { $p = '<span><!--si' . $p['equiv'] . '--><a href="?item=' . $k . '">' . Util::localizedString($p, 'name') . '</a></span>'; } $xSet = '<br /><span class="q"><a href="?itemset=' . $itemset->id . '" class="q">' . $itemset->getField('name', true) . '</a> (0/' . count($pieces) . ')</span>'; if ($skId = $itemset->getField('skillId')) { $xSet .= '<br />' . sprintf(Lang::game('requires'), '<a href="?skills=' . $skId . '" class="q1">' . SkillList::getName($skId) . '</a>'); if ($_ = $itemset->getField('skillLevel')) { $xSet .= ' (' . $_ . ')'; } $xSet .= '<br />'; } // list pieces $xSet .= '<div class="q0 indent">' . implode('<br />', $pieces) . '</div><br />'; // get bonuses $setSpellsAndIdx = []; for ($j = 1; $j <= 8; $j++) { if ($_ = $itemset->getField('spell' . $j)) { $setSpellsAndIdx[$_] = $j; } } $setSpells = []; if ($setSpellsAndIdx) { $boni = new SpellList(array(['s.id', array_keys($setSpellsAndIdx)])); foreach ($boni->iterate() as $__) { $setSpells[] = array('tooltip' => $boni->parseText('description', $_reqLvl > 1 ? $_reqLvl : MAX_LEVEL, false, $causesScaling)[0], 'entry' => $itemset->getField('spell' . $setSpellsAndIdx[$boni->id]), 'bonus' => $itemset->getField('bonus' . $setSpellsAndIdx[$boni->id])); } } // sort and list bonuses $xSet .= '<span class="q0">'; for ($i = 0; $i < count($setSpells); $i++) { for ($j = $i; $j < count($setSpells); $j++) { if ($setSpells[$j]['bonus'] >= $setSpells[$i]['bonus']) { continue; } $tmp = $setSpells[$i]; $setSpells[$i] = $setSpells[$j]; $setSpells[$j] = $tmp; } $xSet .= '<span>(' . $setSpells[$i]['bonus'] . ') ' . Lang::item('set') . ': <a href="?spell=' . $setSpells[$i]['entry'] . '">' . $setSpells[$i]['tooltip'] . '</a></span>'; if ($i < count($setSpells) - 1) { $xSet .= '<br />'; } } $xSet .= '</span>'; } } // recipes, vanity pets, mounts if ($this->canTeachSpell()) { $craftSpell = new SpellList(array(['s.id', intVal($this->curTpl['spellId2'])])); if (!$craftSpell->error) { $xCraft = ''; if ($desc = $this->getField('description', true)) { $x .= '<span class="q2">' . Lang::item('trigger', 0) . ' <a href="?spell=' . $this->curTpl['spellId2'] . '">' . $desc . '</a></span><br />'; } // recipe handling (some stray Techniques have subclass == 0), place at bottom of tooltipp if ($_class == ITEM_CLASS_RECIPE || $this->curTpl['bagFamily'] == 16) { $craftItem = new ItemList(array(['i.id', (int) $craftSpell->curTpl['effect1CreateItemId']])); if (!$craftItem->error) { if ($itemTT = $craftItem->renderTooltip($interactive, $this->id)) { $xCraft .= '<div><br />' . $itemTT . '</div>'; } $reagentItems = []; for ($i = 1; $i <= 8; $i++) { if ($rId = $craftSpell->getField('reagent' . $i)) { $reagentItems[$rId] = $craftSpell->getField('reagentCount' . $i); } } if (isset($xCraft) && $reagentItems) { $reagents = new ItemList(array(['i.id', array_keys($reagentItems)])); $reqReag = []; foreach ($reagents->iterate() as $__) { $reqReag[] = '<a href="?item=' . $reagents->id . '">' . $reagents->getField('name', true) . '</a> (' . $reagentItems[$reagents->id] . ')'; } $xCraft .= '<div class="q1 whtt-reagents"><br />' . Lang::game('requires2') . ' ' . implode(', ', $reqReag) . '</div>'; } } } } } // misc (no idea, how to organize the <br /> better) $xMisc = []; // itemset: pieces and boni if (isset($xSet)) { $xMisc[] = $xSet; } // funny, yellow text at the bottom, omit if we have a recipe if ($this->curTpl['description_loc0'] && !$this->canTeachSpell()) { $xMisc[] = '<span class="q">"' . $this->getField('description', true) . '"</span>'; } // readable if ($this->curTpl['pageTextId']) { $xMisc[] = '<span class="q2">' . Lang::item('readClick') . '</span>'; } // charges (i guess checking first spell is enough (single charges not shown)) if ($this->curTpl['spellCharges1'] > 1 || $this->curTpl['spellCharges1'] < -1) { $xMisc[] = '<span class="q1">' . abs($this->curTpl['spellCharges1']) . ' ' . Lang::item('charges') . '</span>'; } // list required reagents if (isset($xCraft)) { $xMisc[] = $xCraft; } if ($xMisc) { $x .= implode('<br />', $xMisc); } if ($sp = $this->curTpl['sellPrice']) { $x .= '<div class="q1 whtt-sellprice">' . Lang::item('sellPrice') . Lang::main('colon') . Util::formatMoney($sp) . '</div>'; } if (!$subOf) { $x .= '</td></tr></table>'; } // tooltip scaling if (!isset($xCraft)) { $link = [$subOf ? $subOf : $this->id, 1]; // itemId, scaleMinLevel if (isset($this->ssd[$this->id])) { array_push($link, $this->ssd[$this->id]['maxLevel'], $this->ssd[$this->id]['maxLevel'], $this->curTpl['scalingStatDistribution'], $this->curTpl['scalingStatValue']); } else { array_push($link, $causesScaling ? MAX_LEVEL : 1, $_reqLvl > 1 ? $_reqLvl : MAX_LEVEL); } $x .= '<!--?' . implode(':', $link) . '-->'; } return $x; }
private function createEffects(&$infobox, &$redButtons) { // proc data .. maybe use more information..? $procData = DB::World()->selectRow('SELECT IF(ppmRate > 0, -ppmRate, customChance) AS chance, cooldown FROM spell_proc_event WHERE entry = ?d', $this->typeId); if (!isset($procData['cooldown'])) { $procData['cooldown'] = 0; } $effects = []; $spellIdx = array_unique(array_merge($this->subject->canTriggerSpell(), $this->subject->canTeachSpell())); $itemIdx = $this->subject->canCreateItem(); // Iterate through all effects: for ($i = 1; $i < 4; $i++) { if ($this->subject->getField('effect' . $i . 'Id') <= 0) { continue; } $effId = (int) $this->subject->getField('effect' . $i . 'Id'); $effMV = (int) $this->subject->getField('effect' . $i . 'MiscValue'); $effBP = (int) $this->subject->getField('effect' . $i . 'BasePoints'); $effDS = (int) $this->subject->getField('effect' . $i . 'DieSides'); $effRPPL = $this->subject->getField('effect' . $i . 'RealPointsPerLevel'); $effAura = (int) $this->subject->getField('effect' . $i . 'AuraId'); $foo =& $effects[]; // Icons: // .. from item if (in_array($i, $itemIdx)) { $_ = $this->subject->getField('effect' . $i . 'CreateItemId'); foreach ($this->subject->relItems->iterate() as $itemId => $__) { if ($itemId != $_) { continue; } $foo['icon'] = array('id' => $this->subject->relItems->id, 'name' => $this->subject->relItems->getField('name', true), 'quality' => $this->subject->relItems->getField('quality'), 'count' => $effDS + $effBP, 'icon' => $this->subject->relItems->getField('iconString')); break; } if ($effDS > 1) { $foo['icon']['count'] = "'" . ($effBP + 1) . '-' . $foo['icon']['count'] . "'"; } } else { if (in_array($i, $spellIdx) || $effId == 133) { $_ = $this->subject->getField('effect' . $i . 'TriggerSpell'); if (!$_) { $_ = $this->subject->getField('effect' . $i . 'MiscValue'); } $trig = new SpellList(array(['s.id', (int) $_])); $foo['icon'] = array('id' => $_, 'name' => $trig->error ? Util::ucFirst(Lang::game('spell')) . ' #' . $_ : $trig->getField('name', true), 'count' => 0); $this->extendGlobalData($trig->getJSGlobals(GLOBALINFO_SELF | GLOBALINFO_RELATED)); } } // Effect Name $foo['name'] = (User::isInGroup(U_GROUP_EMPLOYEE) ? sprintf(Util::$dfnString, 'EffectId: ' . $effId, Util::$spellEffectStrings[$effId]) : Util::$spellEffectStrings[$effId]) . Lang::main('colon'); if ($this->subject->getField('effect' . $i . 'RadiusMax') > 0) { $foo['radius'] = $this->subject->getField('effect' . $i . 'RadiusMax'); } if (!in_array($i, $itemIdx) && !in_array($i, $spellIdx) && !in_array($effAura, [225, 227])) { $foo['value'] = ($effDS && $effDS != 1 ? $effBP + 1 . Lang::game('valueDelim') : null) . ($effBP + $effDS); } if ($effRPPL != 0) { $foo['value'] = (isset($foo['value']) ? $foo['value'] : '0') . sprintf(Lang::spell('costPerLevel'), $effRPPL); } if ($this->subject->getField('effect' . $i . 'Periode') > 0) { $foo['interval'] = Util::formatTime($this->subject->getField('effect' . $i . 'Periode')); } if ($_ = $this->subject->getField('effect' . $i . 'Mechanic')) { $foo['mechanic'] = Lang::game('me', $_); } if (!empty($procData['chance'])) { $foo['procData'] = array($procData['chance'], $procData['cooldown'] ? Util::formatTime($procData['cooldown'] * 1000, true) : null); } else { if (in_array($i, $this->subject->canTriggerSpell()) && $this->subject->getField('procChance')) { $foo['procData'] = array($this->subject->getField('procChance'), $procData['cooldown'] ? Util::formatTime($procData['cooldown'] * 1000, true) : null); } } // parse masks and indizes switch ($effId) { case 8: // Power Drain // Power Drain case 30: // Energize // Energize case 137: // Energize Pct $_ = Lang::spell('powerTypes', $effMV); if ($_ && User::isInGroup(U_GROUP_EMPLOYEE)) { $_ = sprintf(Util::$dfnString, Lang::spell('_value') . Lang::main('colon') . $effMV, $_); } else { if (!$_) { $_ = $effMV; } } if ($effMV == POWER_RAGE || $effMV == POWER_RUNIC_POWER) { $foo['value'] = ($effDS && $effDS != 1 ? ($effBP + 1) / 10 . Lang::game('valueDelim') : null) . ($effBP + $effDS) / 10; } $foo['name'] .= ' (' . $_ . ')'; break; case 16: // QuestComplete if ($_ = QuestList::getName($effMV)) { $foo['name'] .= '(<a href="?quest=' . $effMV . '">' . $_ . '</a>)'; } else { $foo['name'] .= Util::ucFirst(Lang::game('quest')) . ' #' . $effMV; } break; case 28: // Summon // Summon case 90: // Kill Credit // Kill Credit case 134: // Kill Credit2 $_ = Lang::game('npc') . ' #' . $effMV; if ($summon = $this->subject->getModelInfo($this->typeId, $i)) { $_ = $summon['typeId'] ? ' (<a href="?npc=' . $summon['typeId'] . '">' . $summon['displayName'] . '</a>)' : ' (#0)'; $redButtons[BUTTON_VIEW3D] = ['type' => TYPE_NPC, 'displayId' => $summon['displayId']]; } $foo['name'] .= $_; break; case 33: // Open Lock $_ = $effMV ? Lang::spell('lockType', $effMV) : $effMV; if ($_ && User::isInGroup(U_GROUP_EMPLOYEE)) { $_ = sprintf(Util::$dfnString, Lang::spell('_value') . Lang::main('colon') . $effMV, $_); } else { if (!$_) { $_ = $effMV; } } $foo['name'] .= ' (' . $_ . ')'; break; case 53: // Enchant Item Perm // Enchant Item Perm case 54: // Enchant Item Temp // Enchant Item Temp case 92: // Enchant Held Item // Enchant Held Item case 156: // Enchant Item Prismatic if ($_ = DB::Aowow()->selectRow('SELECT * FROM ?_itemenchantment WHERE id = ?d', $effMV)) { $foo['name'] .= ' (<a href="?enchantment=' . $effMV . '" class="q2">' . Util::localizedString($_, 'name') . '</a>)'; } else { $foo['name'] .= ' #' . $effMV; } break; case 38: // Dispel [miscValue => Types] // Dispel [miscValue => Types] case 126: // Steal Aura $_ = Lang::game('dt', $effMV); if ($_ && User::isInGroup(U_GROUP_EMPLOYEE)) { $_ = sprintf(Util::$dfnString, Lang::spell('_value') . Lang::main('colon') . $effMV, $_); } else { if (!$_) { $_ = $effMV; } } $foo['name'] .= ' (' . $_ . ')'; break; case 39: // Learn Language $_ = Lang::game('languages', $effMV); if ($_ && User::isInGroup(U_GROUP_EMPLOYEE)) { $_ = sprintf(Util::$dfnString, Lang::spell('_value') . Lang::main('colon') . $effMV, $_); } else { if (!$_) { $_ = $effMV; } } $foo['name'] .= ' (' . $_ . ')'; break; case 50: // Trans Door // Trans Door case 76: // Summon Object (Wild) // case 86: // Activate Object // Summon Object (Wild) // case 86: // Activate Object case 104: // Summon Object (slot 1) // Summon Object (slot 1) case 105: // Summon Object (slot 2) // Summon Object (slot 2) case 106: // Summon Object (slot 3) // Summon Object (slot 3) case 107: // Summon Object (slot 4) $_ = Util::ucFirst(Lang::game('object')) . ' #' . $effMV; if ($summon = $this->subject->getModelInfo($this->typeId, $i)) { $_ = $summon['typeId'] ? ' (<a href="?object=' . $summon['typeId'] . '">' . $summon['displayName'] . '</a>)' : ' (#0)'; $redButtons[BUTTON_VIEW3D] = ['type' => TYPE_OBJECT, 'displayId' => $summon['displayId']]; } $foo['name'] .= $_; break; case 74: // Apply Glyph if ($_ = DB::Aowow()->selectCell('SELECT spellId FROM ?_glyphproperties WHERE id = ?d', $effMV)) { if ($n = SpellList::getName($_)) { $foo['name'] .= '(<a href="?spell=' . $_ . '">' . $n . '</a>)'; } else { $foo['name'] .= Util::ucFirst(Lang::game('spell')) . ' #' . $effMV; } } else { $foo['name'] .= ' #' . $effMV; } break; case 95: // Skinning switch ($effMV) { case 0: $_ = Lang::game('ct', 1) . ', ' . Lang::game('ct', 2); break; // Beast, Dragonkin // Beast, Dragonkin case 1: case 2: $_ = Lang::game('ct', 4); break; // Elemental (nature based, earth based) // Elemental (nature based, earth based) case 3: $_ = Lang::game('ct', 9); break; // Mechanic // Mechanic default: $_ = ''; } if (User::isInGroup(U_GROUP_EMPLOYEE)) { $_ = sprintf(Util::$dfnString, Lang::spell('_value') . Lang::main('colon') . $effMV, $_); } else { $_ = $effMV; } $foo['name'] .= ' (' . $_ . ')'; break; case 108: // Dispel Mechanic $_ = Lang::game('me', $effMV); if ($_ && User::isInGroup(U_GROUP_EMPLOYEE)) { $_ = sprintf(Util::$dfnString, Lang::spell('_value') . Lang::main('colon') . $effMV, $_); } else { if (!$_) { $_ = $effMV; } } $foo['name'] .= ' (' . $_ . ')'; break; case 118: // Require Skill if ($_ = SkillList::getName($effMV)) { $foo['name'] .= '(<a href="?skill=' . $effMV . '">' . $_ . '</a>)'; } else { $foo['name'] .= Util::ucFirst(Lang::game('skill')) . ' #' . $effMV; } break; case 146: // Activate Rune $_ = Lang::spell('powerRunes', $effMV); if ($_ && User::isInGroup(U_GROUP_EMPLOYEE)) { $_ = sprintf(Util::$dfnString, Lang::spell('_value') . Lang::main('colon') . $effMV, $_); } else { if (!$_) { $_ = $effMV; } } $foo['name'] .= ' (' . $_ . ')'; break; case 123: // Send Taxi - effMV is taxiPathId. We only use paths for flightmasters for now, so spell-triggered paths are not in the table // Send Taxi - effMV is taxiPathId. We only use paths for flightmasters for now, so spell-triggered paths are not in the table default: if (($effMV || $effId == 97) && $effId != 155) { $foo['name'] .= ' (' . $effMV . ')'; } // Aura // Aura case 6: // Simple // Simple case 27: // AA Persistent // AA Persistent case 35: // AA Party // AA Party case 65: // AA Raid // AA Raid case 119: // AA Pet // AA Pet case 128: // AA Friend // AA Friend case 129: // AA Enemy // AA Enemy case 143: if ($effAura > 0 && isset(Util::$spellAuraStrings[$effAura])) { $foo['name'] .= User::isInGroup(U_GROUP_EMPLOYEE) ? sprintf(Util::$dfnString, 'AuraId: ' . $effAura, Util::$spellAuraStrings[$effAura]) : Util::$spellAuraStrings[$effAura]; $bar = $effMV; switch ($effAura) { case 17: // Mod Stealth Detection if ($_ = Lang::spell('stealthType', $effMV)) { $bar = User::isInGroup(U_GROUP_EMPLOYEE) ? sprintf(Util::$dfnString, Lang::spell('_value') . Lang::main('colon') . $effMV, $_) : $_; } break; case 19: // Mod Invisibility Detection if ($_ = Lang::spell('invisibilityType', $effMV)) { $bar = User::isInGroup(U_GROUP_EMPLOYEE) ? sprintf(Util::$dfnString, Lang::spell('_value') . Lang::main('colon') . $effMV, $_) : $_; } break; case 24: // Periodic Energize // Periodic Energize case 21: // Obsolete Mod Power // Obsolete Mod Power case 35: // Mod Increase Power // Mod Increase Power case 85: // Mod Power Regeneration // Mod Power Regeneration case 110: // Mod Power Regeneration Pct if ($_ = Lang::spell('powerTypes', $effMV)) { $bar = User::isInGroup(U_GROUP_EMPLOYEE) ? sprintf(Util::$dfnString, Lang::spell('_value') . Lang::main('colon') . $effMV, $_) : $_; } break; case 29: // Mod Stat // Mod Stat case 80: // Mod Stat % // Mod Stat % case 137: // Mod Total Stat % // Mod Total Stat % case 175: // Mod Spell Healing Of Stat Percent // Mod Spell Healing Of Stat Percent case 212: // Mod Ranged Attack Power Of Stat Percent // Mod Ranged Attack Power Of Stat Percent case 219: // Mod Mana Regeneration from Stat // Mod Mana Regeneration from Stat case 268: // Mod Attack Power Of Stat Percent $mask = $effMV == -1 ? 0x1f : 1 << $effMV; $_ = []; for ($j = 0; $j < 5; $j++) { if ($mask & 1 << $j) { $_[] = Lang::game('stats', $j); } } if ($_ = implode(', ', $_)) { } $bar = User::isInGroup(U_GROUP_EMPLOYEE) ? sprintf(Util::$dfnString, Lang::spell('_value') . Lang::main('colon') . $effMV, $_) : $_; break; case 36: // Shapeshift if ($st = $this->subject->getModelInfo($this->typeId, $i)) { $redButtons[BUTTON_VIEW3D] = array('type' => TYPE_NPC, 'displayId' => $st['displayId']); if ($st['creatureType'] > 0) { $infobox[] = Lang::game('type') . Lang::main('colon') . Lang::game('ct', $st['creatureType']); } if ($_ = $st['displayName']) { $bar = User::isInGroup(U_GROUP_EMPLOYEE) ? sprintf(Util::$dfnString, Lang::spell('_value') . Lang::main('colon') . $effMV, $_) : $_; } } break; case 37: // Effect immunity if (isset(Util::$spellEffectStrings[$effMV])) { $_ = Util::$spellEffectStrings[$effMV]; $bar = User::isInGroup(U_GROUP_EMPLOYEE) ? sprintf(Util::$dfnString, Lang::spell('_value') . Lang::main('colon') . $effMV, $_) : $_; } break; case 38: // Aura immunity if (isset(Util::$spellAuraStrings[$effMV])) { $_ = Util::$spellAuraStrings[$effMV]; $bar = User::isInGroup(U_GROUP_EMPLOYEE) ? sprintf(Util::$dfnString, Lang::spell('_value') . Lang::main('colon') . $effMV, $_) : $_; } break; case 41: // Dispel Immunity // Dispel Immunity case 178: // Mod Debuff Resistance // Mod Debuff Resistance case 245: // Mod Aura Duration By Dispel if ($_ = Lang::game('dt', $effMV)) { $bar = User::isInGroup(U_GROUP_EMPLOYEE) ? sprintf(Util::$dfnString, Lang::spell('_value') . Lang::main('colon') . $effMV, $_) : $_; } break; case 44: // Track Creature if ($_ = Lang::game('ct', $effMV)) { $bar = User::isInGroup(U_GROUP_EMPLOYEE) ? sprintf(Util::$dfnString, Lang::spell('_value') . Lang::main('colon') . $effMV, $_) : $_; } break; case 45: // Track Resource if ($_ = Lang::spell('lockType', $effMV)) { $bar = User::isInGroup(U_GROUP_EMPLOYEE) ? sprintf(Util::$dfnString, Lang::spell('_value') . Lang::main('colon') . $effMV, $_) : $_; } break; case 75: // Language if ($_ = Lang::game('languages', $effMV)) { $bar = User::isInGroup(U_GROUP_EMPLOYEE) ? sprintf(Util::$dfnString, Lang::spell('_value') . Lang::main('colon') . $effMV, $_) : $_; } break; case 77: // Mechanic Immunity // Mechanic Immunity case 117: // Mod Mechanic Resistance // Mod Mechanic Resistance case 232: // Mod Mechanic Duration // Mod Mechanic Duration case 234: // Mod Mechanic Duration (no stack) // Mod Mechanic Duration (no stack) case 255: // Mod Mechanic Damage Taken Pct // Mod Mechanic Damage Taken Pct case 276: // Mod Mechanic Damage Done Percent if ($_ = Lang::game('me', $effMV)) { $bar = User::isInGroup(U_GROUP_EMPLOYEE) ? sprintf(Util::$dfnString, Lang::spell('_value') . Lang::main('colon') . Util::asHex($effMV), $_) : $_; } break; case 147: // Mechanic Immunity Mask $_ = []; foreach (Lang::game('me') as $k => $str) { if ($effMV & 1 << $k - 1) { $_[] = $str; } } if ($_ = implode(', ', $_)) { $bar = User::isInGroup(U_GROUP_EMPLOYEE) ? sprintf(Util::$dfnString, Lang::spell('_value') . Lang::main('colon') . Util::asHex($effMV), $_) : $_; } break; case 10: // Mod Threat // Mod Threat case 13: // Mod Damage Done // Mod Damage Done case 14: // Mod Damage Taken // Mod Damage Taken case 22: // Mod Resistance // Mod Resistance case 39: // School Immunity // School Immunity case 40: // Damage Immunity // Damage Immunity case 50: // Mod Critical Healing Amount // Mod Critical Healing Amount case 57: // Mod Spell Crit Chance // Mod Spell Crit Chance case 69: // School Absorb // School Absorb case 71: // Mod Spell Crit Chance School // Mod Spell Crit Chance School case 72: // Mod Power Cost School Percent // Mod Power Cost School Percent case 73: // Mod Power Cost School Flat // Mod Power Cost School Flat case 74: // Reflect Spell School // Reflect Spell School case 79: // Mod Damage Done Pct // Mod Damage Done Pct case 81: // Split Damage Pct // Split Damage Pct case 83: // Mod Base Resistance // Mod Base Resistance case 87: // Mod Damage Taken Pct // Mod Damage Taken Pct case 97: // Mana Shield // Mana Shield case 101: // Mod Resistance Pct // Mod Resistance Pct case 115: // Mod Healing Taken // Mod Healing Taken case 118: // Mod Healing Taken Pct // Mod Healing Taken Pct case 123: // Mod Target Resistance // Mod Target Resistance case 135: // Mod Healing Done // Mod Healing Done case 136: // Mod Healing Done Pct // Mod Healing Done Pct case 142: // Mod Base Resistance Pct // Mod Base Resistance Pct case 143: // Mod Resistance Exclusive // Mod Resistance Exclusive case 149: // Reduce Pushback // Reduce Pushback case 163: // Mod Crit Damage Bonus // Mod Crit Damage Bonus case 174: // Mod Spell Damage Of Stat Percent // Mod Spell Damage Of Stat Percent case 182: // Mod Resistance Of Stat Percent // Mod Resistance Of Stat Percent case 186: // Mod Attacker Spell Hit Chance // Mod Attacker Spell Hit Chance case 194: // Mod Target Absorb School // Mod Target Absorb School case 195: // Mod Target Ability Absorb School // Mod Target Ability Absorb School case 199: // Mod Increases Spell Percent to Hit // Mod Increases Spell Percent to Hit case 229: // Mod AoE Damage Avoidance // Mod AoE Damage Avoidance case 271: // Mod Damage Percent Taken Form Caster // Mod Damage Percent Taken Form Caster case 310: // Mod Creature AoE Damage Avoidance if ($_ = Lang::getMagicSchools($effMV)) { $bar = User::isInGroup(U_GROUP_EMPLOYEE) ? sprintf(Util::$dfnString, Lang::spell('_value') . Lang::main('colon') . Util::asHex($effMV), $_) : $_; } break; case 30: // Mod Skill // Mod Skill case 98: // Mod Skill Value if ($_ = SkillList::getName($effMV)) { $bar = ' (<a href="?skill=' . $effMV . '">' . SkillList::getName($effMV) . '</a>)'; } else { $bar = Lang::main('colon') . Util::ucFirst(Lang::game('skill')) . ' #' . $effMV; } break; case 107: // Flat Modifier // Flat Modifier case 108: // Pct Modifier if ($_ = Lang::spell('spellModOp', $effMV)) { $bar = User::isInGroup(U_GROUP_EMPLOYEE) ? sprintf(Util::$dfnString, Lang::spell('_value') . Lang::main('colon') . $effMV, $_) : $_; } break; case 189: // Mod Rating // Mod Rating case 220: // Combat Rating From Stat $_ = []; foreach (Lang::spell('combatRating') as $k => $str) { if (1 << $k & $effMV) { $_[] = $str; } } if ($_ = implode(', ', $_)) { $bar = User::isInGroup(U_GROUP_EMPLOYEE) ? sprintf(Util::$dfnString, Lang::spell('_value') . Lang::main('colon') . Util::asHex($effMV), $_) : $_; } break; case 168: // Mod Damage Done Versus // Mod Damage Done Versus case 59: // Mod Damage Done Versus Creature // Mod Damage Done Versus Creature case 102: // Mod Melee Attack Power Versus // Mod Melee Attack Power Versus case 131: // Mod Ranged Attack Power Versus // Mod Ranged Attack Power Versus case 180: // Mod Spell Damage Versus $_ = []; foreach (Lang::game('ct') as $k => $str) { if ($effMV & 1 << $k - 1) { $_[] = $str; } } if ($_ = implode(', ', $_)) { $bar = User::isInGroup(U_GROUP_EMPLOYEE) ? sprintf(Util::$dfnString, Lang::spell('_value') . Lang::main('colon') . Util::asHex($effMV), $_) : $_; } break; case 249: // Convert Rune $x = $this->subject->getField('effect' . $i . 'MiscValueB'); if ($_ = Lang::spell('powerRunes', $x)) { $bar = User::isInGroup(U_GROUP_EMPLOYEE) ? sprintf(Util::$dfnString, Lang::spell('_value') . Lang::main('colon') . $x, $_) : $_; } break; case 78: // Mounted // Mounted case 56: // Transform if ($transform = $this->subject->getModelInfo($this->typeId, $i)) { $redButtons[BUTTON_VIEW3D] = ['type' => TYPE_NPC, 'displayId' => $transform['displayId']]; $bar = $transform['typeId'] ? ' (<a href="?npc=' . $transform['typeId'] . '">' . $transform['displayName'] . '</a>)' : ' (#0)'; } else { $bar = Lang::main('colon') . Lang::game('npc') . ' #' . $effMV; } break; case 139: // Force Reaction $foo['value'] = sprintf(Util::$dfnString, $foo['value'], Lang::game('rep', $foo['value'])); // DO NOT BREAK // DO NOT BREAK case 190: // Mod Faction Reputation Gain $bar = ' (<a href="?faction=' . $effMV . '">' . FactionList::getName($effMV) . '</a>)'; break; // also breaks for 139 } $foo['name'] .= strstr($bar, 'href') || strstr($bar, '#') ? $bar : ($bar ? ' (' . $bar . ')' : null); if (in_array($effAura, [174, 220, 182])) { $foo['name'] .= ' [' . sprintf(Util::$dfnString, Lang::game('stats', $this->subject->getField('effect' . $i . 'MiscValueB')), $this->subject->getField('effect' . $i . 'MiscValueB')) . ']'; } else { if ($this->subject->getField('effect' . $i . 'MiscValueB') > 0) { $foo['name'] .= ' [' . $this->subject->getField('effect' . $i . 'MiscValueB') . ']'; } } } else { if ($effAura > 0) { $foo['name'] .= Lang::main('colon') . 'Unknown Aura (' . $effAura . ')'; } } break; } // cases where we dont want 'Value' to be displayed if (in_array($effAura, [11, 12, 36, 77]) || in_array($effId, []) || empty($foo['value'])) { unset($foo['value']); } } unset($foo); // clear reference return $effects; }
protected function generateContent() { /****************/ /* Main Content */ /****************/ $this->headIcons = [$this->subject->getField('iconString')]; $this->redButtons = array(BUTTON_WOWHEAD => true, BUTTON_LINKS => true); if ($_ = $this->subject->getField('description', true)) { $this->extraText = $_; } /**************/ /* Extra Tabs */ /**************/ if (in_array($this->cat, [-5, 9, 11])) { // tab: recipes [spells] (crafted) $condition = array(['OR', ['s.reagent1', 0, '>'], ['s.reagent2', 0, '>'], ['s.reagent3', 0, '>'], ['s.reagent4', 0, '>'], ['s.reagent5', 0, '>'], ['s.reagent6', 0, '>'], ['s.reagent7', 0, '>'], ['s.reagent8', 0, '>']], ['OR', ['s.skillLine1', $this->typeId], ['AND', ['s.skillLine1', 0, '>'], ['s.skillLine2OrMask', $this->typeId]]], CFG_SQL_LIMIT_NONE); $recipes = new SpellList($condition); // also relevant for 3 if (!$recipes->error) { $this->extendGlobalData($recipes->getJSGlobals(GLOBALINFO_SELF | GLOBALINFO_RELATED)); $this->lvTabs[] = array('file' => 'spell', 'data' => $recipes->getListviewData(), 'params' => array('id' => 'recipes', 'name' => '$LANG.tab_recipes', 'visibleCols' => "\$['reagents', 'source']", 'note' => sprintf(Util::$filterResultString, '?spells=' . $this->cat . '.' . $this->typeId . '&filter=cr=20;crs=1;crv=0'))); } // tab: recipe Items [items] (Books) $filterRecipe = [null, 165, 197, 202, 164, 185, 171, 129, 333, 356, 755, 773, 186, 182]; $conditions = array(['requiredSkill', $this->typeId], ['class', ITEM_CLASS_RECIPE], CFG_SQL_LIMIT_NONE); $recipeItems = new ItemList($conditions); if (!$recipeItems->error) { $this->extendGlobalData($recipeItems->getJSGlobals(GLOBALINFO_SELF)); if ($_ = array_search($this->typeId, $filterRecipe)) { $_ = sprintf(Util::$filterResultString, "?items=9." . $_); } $this->lvTabs[] = array('file' => 'item', 'data' => $recipeItems->getListviewData(), 'params' => array('id' => 'recipe-items', 'name' => '$LANG.tab_recipeitems', 'note' => $_)); } // tab: crafted items [items] $filterItem = [null, 171, 164, 185, 333, 202, 129, 755, 165, 186, 197, null, null, 356, 182, 773]; $created = []; foreach ($recipes->iterate() as $__) { if ($idx = $recipes->canCreateItem()) { foreach ($idx as $i) { $created[] = $recipes->getField('effect' . $i . 'CreateItemId'); } } } if ($created) { $created = new ItemList(array(['i.id', $created], CFG_SQL_LIMIT_NONE)); if (!$created->error) { $this->extendGlobalData($created->getJSGlobals(GLOBALINFO_SELF)); if ($_ = array_search($this->typeId, $filterItem)) { $_ = sprintf(Util::$filterResultString, "?items&filter=cr=86;crs=" . $_ . ";crv=0"); } $this->lvTabs[] = array('file' => 'item', 'data' => $created->getListviewData(), 'params' => array('id' => 'crafted-items', 'name' => '$LANG.tab_crafteditems', 'note' => $_)); } } // tab: required by [item] $conditions = array(['requiredSkill', $this->typeId], ['class', ITEM_CLASS_RECIPE, '!'], CFG_SQL_LIMIT_NONE); $reqBy = new ItemList($conditions); if (!$reqBy->error) { $this->extendGlobalData($reqBy->getJSGlobals(GLOBALINFO_SELF)); if ($_ = array_search($this->typeId, $filterItem)) { $_ = sprintf(Util::$filterResultString, "?items&filter=cr=99:168;crs=" . $_ . ":2;crv=0:0"); } $this->lvTabs[] = array('file' => 'item', 'data' => $reqBy->getListviewData(), 'params' => array('id' => 'required-by', 'name' => '$LANG.tab_requiredby', 'note' => $_)); } // tab: required by [itemset] $conditions = array(['skillId', $this->typeId], CFG_SQL_LIMIT_NONE); $reqBy = new ItemsetList($conditions); if (!$reqBy->error) { $this->extendGlobalData($reqBy->getJSGlobals(GLOBALINFO_SELF)); $this->lvTabs[] = array('file' => 'itemset', 'data' => $reqBy->getListviewData(), 'params' => array('id' => 'required-by-set', 'name' => '$LANG.tab_requiredby')); } } // tab: spells [spells] (exclude first tab) $reqClass = 0x0; $reqRace = 0x0; $condition = array(['AND', ['s.reagent1', 0], ['s.reagent2', 0], ['s.reagent3', 0], ['s.reagent4', 0], ['s.reagent5', 0], ['s.reagent6', 0], ['s.reagent7', 0], ['s.reagent8', 0]], ['OR', ['s.skillLine1', $this->typeId], ['AND', ['s.skillLine1', 0, '>'], ['s.skillLine2OrMask', $this->typeId]]], CFG_SQL_LIMIT_NONE); foreach (Util::$skillLineMask as $line1 => $sets) { foreach ($sets as $idx => $set) { if ($set[1] == $this->typeId) { $condition[1][] = array('AND', ['s.skillLine1', $line1], ['s.skillLine2OrMask', 1 << $idx, '&']); break 2; } } } $spells = new SpellList($condition); if (!$spells->error) { foreach ($spells->iterate() as $__) { $reqClass |= $spells->getField('reqClassMask'); $reqRace |= $spells->getField('reqRaceMask'); } $this->extendGlobalData($spells->getJSGlobals(GLOBALINFO_SELF)); $lv = array('file' => 'spell', 'data' => $spells->getListviewData(), 'params' => ['visibleCols' => "\$['source']"]); switch ($this->cat) { case -4: $lv['params']['note'] = sprintf(Util::$filterResultString, '?spells=-4'); break; case 7: if ($this->typeId != 769) { // Internal $lv['params']['note'] = sprintf(Util::$filterResultString, '?spells=' . $this->cat . '.' . (log($reqClass, 2) + 1) . '.' . $this->typeId); } // doesn't matter what spell; reqClass should be identical for all Class Spells break; case 9: case 11: $lv['params']['note'] = sprintf(Util::$filterResultString, '?spells=' . $this->cat . '.' . $this->typeId); break; } $this->lvTabs[] = $lv; } // tab: trainers [npcs] if (in_array($this->cat, [-5, 6, 7, 8, 9, 11])) { $list = []; if (!empty(Util::$trainerTemplates[TYPE_SKILL][$this->typeId])) { $list = DB::World()->selectCol('SELECT DISTINCT entry FROM npc_trainer WHERE spell IN (?a) AND entry < 200000', Util::$trainerTemplates[TYPE_SKILL][$this->typeId]); } else { $mask = 0; foreach (Util::$skillLineMask[-3] as $idx => $pair) { if ($pair[1] == $this->typeId) { $mask |= 1 << $idx; } } $spellIds = DB::Aowow()->selectCol('SELECT id FROM ?_spell WHERE typeCat IN (-11, 9) AND (skillLine1 = ?d OR (skillLine1 > 0 AND skillLine2OrMask = ?d) {OR (skillLine1 = -3 AND skillLine2OrMask = ?d)})', $this->typeId, $this->typeId, $mask ?: DBSIMPLE_SKIP); $list = $spellIds ? DB::World()->selectCol(' SELECT IF(t1.entry > 200000, t2.entry, t1.entry) FROM npc_trainer t1 LEFT JOIN npc_trainer t2 ON t2.spell = -t1.entry WHERE t1.spell IN (?a)', $spellIds) : []; } if ($list) { $this->addJS('?data=zones&locale=' . User::$localeId . '&t=' . $_SESSION['dataKey']); $trainer = new CreatureList(array(CFG_SQL_LIMIT_NONE, ['ct.id', $list], ['s.guid', NULL, '!'], ['ct.npcflag', 0x10, '&'])); if (!$trainer->error) { $this->extendGlobalData($trainer->getJSGlobals()); $this->lvTabs[] = array('file' => 'creature', 'data' => $trainer->getListviewData(), 'params' => array('id' => 'trainer', 'name' => '$LANG.tab_trainers')); } } } // tab: quests [quests] if (in_array($this->cat, [9, 11])) { $sort = 0; switch ($this->typeId) { case 182: $sort = 24; break; // Herbalism // Herbalism case 356: $sort = 101; break; // Fishing // Fishing case 164: $sort = 121; break; // Blacksmithing // Blacksmithing case 171: $sort = 181; break; // Alchemy // Alchemy case 165: $sort = 182; break; // Leatherworking // Leatherworking case 202: $sort = 201; break; // Engineering // Engineering case 197: $sort = 264; break; // Tailoring // Tailoring case 185: $sort = 304; break; // Cooking // Cooking case 129: $sort = 324; break; // First Aid // First Aid case 773: $sort = 371; break; // Inscription // Inscription case 755: $sort = 373; break; // Jewelcrafting } if ($sort) { $quests = new QuestList(array(['zoneOrSort', -$sort], CFG_SQL_LIMIT_NONE)); if (!$quests->error) { $this->extendGlobalData($quests->getJSGlobals()); $this->lvTabs[] = array('file' => 'quest', 'data' => $quests->getListviewData(), 'params' => []); } } } // tab: related classes (apply classes from [spells]) $class = []; for ($i = 0; $i < 11; $i++) { if ($reqClass & 1 << $i) { $class[] = $i + 1; } } if ($class) { $classes = new CharClassList(array(['id', $class])); if (!$classes->error) { $this->lvTabs[] = array('file' => 'class', 'data' => $classes->getListviewData(), 'params' => []); } } // tab: related races (apply races from [spells]) $race = []; for ($i = 0; $i < 12; $i++) { if ($reqRace & 1 << $i) { $race[] = $i + 1; } } if ($race) { $races = new CharRaceList(array(['id', $race])); if (!$races->error) { $this->lvTabs[] = array('file' => 'race', 'data' => $races->getListviewData(), 'params' => []); } } }
private function createRewards() { $rewards = []; // moneyReward / maxLevelCompensation $comp = $this->subject->getField('rewardMoneyMaxLevel'); $questMoney = $this->subject->getField('rewardOrReqMoney'); if ($questMoney > 0) { $rewards['money'] = Util::formatMoney($questMoney); if ($comp > 0) { $rewards['money'] .= ' ' . sprintf(Lang::quest('expConvert'), Util::formatMoney($questMoney + $comp), MAX_LEVEL); } } else { if ($questMoney <= 0 && $questMoney + $comp > 0) { $rewards['money'] = sprintf(Lang::quest('expConvert2'), Util::formatMoney($questMoney + $comp), MAX_LEVEL); } } // itemChoices if (!empty($this->subject->choices[$this->typeId][TYPE_ITEM])) { $c = $this->subject->choices[$this->typeId][TYPE_ITEM]; $choiceItems = new ItemList(array(['id', array_keys($c)])); if (!$choiceItems->error) { $this->extendGlobalData($choiceItems->getJSGlobals()); foreach ($choiceItems->Iterate() as $id => $__) { $rewards['choice'][] = array('typeStr' => Util::$typeStrings[TYPE_ITEM], 'id' => $id, 'name' => $choiceItems->getField('name', true), 'quality' => $choiceItems->getField('quality'), 'qty' => $c[$id], 'globalStr' => 'g_items'); } } } // itemRewards if (!empty($this->subject->rewards[$this->typeId][TYPE_ITEM])) { $ri = $this->subject->rewards[$this->typeId][TYPE_ITEM]; $rewItems = new ItemList(array(['id', array_keys($ri)])); if (!$rewItems->error) { $this->extendGlobalData($rewItems->getJSGlobals()); foreach ($rewItems->Iterate() as $id => $__) { $rewards['items'][] = array('typeStr' => Util::$typeStrings[TYPE_ITEM], 'id' => $id, 'name' => $rewItems->getField('name', true), 'quality' => $rewItems->getField('quality'), 'qty' => $ri[$id], 'globalStr' => 'g_items'); } } } if (!empty($this->subject->rewards[$this->typeId][TYPE_ITEM][TYPE_CURRENCY])) { $rc = $this->subject->rewards[$this->typeId][TYPE_ITEM][TYPE_CURRENCY]; $rewCurr = new CurrencyList(array(['id', array_keys($rc)])); if (!$rewCurr->error) { $this->extendGlobalData($rewCurr->getJSGlobals()); foreach ($rewCurr->Iterate() as $id => $__) { $rewards['items'][] = array('typeStr' => Util::$typeStrings[TYPE_CURRENCY], 'id' => $id, 'name' => $rewCurr->getField('name', true), 'quality' => 1, 'qty' => $rc[$id] * ($_side == 2 ? -1 : 1), 'globalStr' => 'g_gatheredcurrencies'); } } } // spellRewards $displ = $this->subject->getField('rewardSpell'); $cast = $this->subject->getField('rewardSpellCast'); if (!$cast && $displ) { $cast = $displ; $displ = 0; } if ($cast || $displ) { $rewSpells = new SpellList(array(['id', [$displ, $cast]])); $this->extendGlobalData($rewSpells->getJSGlobals()); if (User::isInGroup(U_GROUP_EMPLOYEE)) { $extra = null; if ($_ = $rewSpells->getEntry($displ)) { $extra = sprintf(Lang::quest('spellDisplayed'), $displ, Util::localizedString($_, 'name')); } if ($_ = $rewSpells->getEntry($cast)) { $rewards['spells']['extra'] = $extra; $rewards['spells']['cast'][] = array('typeStr' => Util::$typeStrings[TYPE_SPELL], 'id' => $cast, 'name' => Util::localizedString($_, 'name'), 'globalStr' => 'g_spells'); } } else { $teach = []; foreach ($rewSpells->iterate() as $id => $__) { if ($_ = $rewSpells->canTeachSpell()) { foreach ($_ as $idx) { $teach[$rewSpells->getField('effect' . $idx . 'TriggerSpell')] = $id; } } } if ($_ = $rewSpells->getEntry($displ)) { $rewards['spells']['extra'] = null; $rewards['spells'][$teach ? 'learn' : 'cast'][] = array('typeStr' => Util::$typeStrings[TYPE_SPELL], 'id' => $displ, 'name' => Util::localizedString($_, 'name'), 'globalStr' => 'g_spells'); } else { if (($_ = $rewSpells->getEntry($cast)) && !$teach) { $rewards['spells']['extra'] = null; $rewards['spells']['cast'][] = array('typeStr' => Util::$typeStrings[TYPE_SPELL], 'id' => $cast, 'name' => Util::localizedString($_, 'name'), 'globalStr' => 'g_spells'); } else { $taught = new SpellList(array(['id', array_keys($teach)])); if (!$taught->error) { $this->extendGlobalData($taught->getJSGlobals()); $rewards['spells']['extra'] = null; foreach ($taught->iterate() as $id => $__) { $rewards['spells']['learn'][] = array('typeStr' => Util::$typeStrings[TYPE_SPELL], 'id' => $id, 'name' => $taught->getField('name', true), 'globalStr' => 'g_spells'); } } } } } } return $rewards; }
protected function generateContent() { /***********/ /* Infobox */ /***********/ $infobox = Lang::getInfoBoxForFlags($this->subject->getField('cuFlags')); // reqLevel if ($_ = $this->subject->getField('requiredLevel')) { $infobox[] = sprintf(Lang::game('reqLevel'), $_); } // reqskill if ($_ = $this->subject->getField('skillLine')) { $this->extendGlobalIds(TYPE_SKILL, $_); $foo = sprintf(Lang::game('requires'), ' [skill=' . $_ . ']'); if ($_ = $this->subject->getField('skillLevel')) { $foo .= ' (' . $_ . ')'; } $infobox[] = $foo; } /****************/ /* Main Content */ /****************/ $this->infobox = $infobox ? '[ul][li]' . implode('[/li][li]', $infobox) . '[/li][/ul]' : null; $this->effects = []; // 3 effects for ($i = 1; $i < 4; $i++) { $_ty = $this->subject->getField('type' . $i); $_qty = $this->subject->getField('amount' . $i); $_obj = $this->subject->getField('object' . $i); switch ($_ty) { case 1: case 3: case 7: $sArr = $this->subject->getField('spells')[$i]; $spl = $this->subject->getRelSpell($sArr[0]); $this->effects[$i]['name'] = User::isInGroup(U_GROUP_EMPLOYEE) ? sprintf(Util::$dfnString, 'Type: ' . $_ty, Lang::item('trigger', $sArr[1])) : Lang::item('trigger', $sArr[1]); $this->effects[$i]['proc'] = $sArr[3]; $this->effects[$i]['value'] = $_qty ?: null; $this->effects[$i]['icon'] = array('name' => !$spl ? Util::ucFirst(Lang::game('spell')) . ' #' . $sArr[0] : Util::localizedString($spl, 'name'), 'id' => $sArr[0], 'count' => $sArr[2]); break; case 5: if ($_obj < 2) { // [mana, health] are on [0, 1] respectively and are expected on [1, 2] .. $_obj++; } // 0 is weaponDmg .. ehh .. i messed up somewhere $this->effects[$i]['tip'] = [$_obj, Util::$itemMods[$_obj]]; // DO NOT BREAK! // DO NOT BREAK! case 2: case 6: case 8: case 4: $this->effects[$i]['name'] = User::isInGroup(U_GROUP_EMPLOYEE) ? sprintf(Util::$dfnString, 'Type: ' . $_ty, Lang::enchantment('types', $_ty)) : Lang::enchantment('types', $_ty); $this->effects[$i]['value'] = $_qty; if ($_ty == 4) { $this->effects[$i]['name'] .= Lang::main('colon') . '(' . (User::isInGroup(U_GROUP_EMPLOYEE) ? sprintf(Util::$dfnString, 'Object: ' . $_obj, Lang::getMagicSchools(1 << $_obj)) : Lang::getMagicSchools(1 << $_obj)) . ')'; } } } // activation conditions if ($_ = $this->subject->getField('conditionId')) { $x = ''; if ($gemCnd = DB::Aowow()->selectRow('SELECT * FROM ?_itemenchantmentcondition WHERE id = ?d', $_)) { for ($i = 1; $i < 6; $i++) { if (!$gemCnd['color' . $i]) { continue; } $fiColors = function ($idx) { $foo = ''; switch ($idx) { case 2: $foo = '0:3:5'; break; // red // red case 3: $foo = '2:4:5'; break; // yellow // yellow case 4: $foo = '1:3:4'; break; // blue } return $foo; }; $bLink = $gemCnd['color' . $i] ? '<a href="?items=3&filter=ty=' . $fiColors($gemCnd['color' . $i]) . '">' . Lang::item('gemColors', $gemCnd['color' . $i] - 1) . '</a>' : ''; $cLink = $gemCnd['cmpColor' . $i] ? '<a href="?items=3&filter=ty=' . $fiColors($gemCnd['cmpColor' . $i]) . '">' . Lang::item('gemColors', $gemCnd['cmpColor' . $i] - 1) . '</a>' : ''; switch ($gemCnd['comparator' . $i]) { case 2: // requires less <color> than (<value> || <comparecolor>) gems // requires less <color> than (<value> || <comparecolor>) gems case 5: // requires at least <color> than (<value> || <comparecolor>) gems $sp = (int) $gemCnd['value' . $i] > 1; $x .= '<span class="q0">' . Lang::achievement('reqNumCrt') . ' ' . sprintf(Lang::item('gemConditions', $gemCnd['comparator' . $i], $sp), $gemCnd['value' . $i], $bLink) . '</span><br />'; break; case 3: // requires more <color> than (<value> || <comparecolor>) gems $link = '<a href="?items=3&filter=ty=' . $fiColors($gemCnd['cmpColor' . $i]) . '">' . Lang::item('gemColors', $gemCnd['cmpColor' . $i] - 1) . '</a>'; $x .= '<span class="q0">' . Lang::achievement('reqNumCrt') . ' ' . sprintf(Lang::item('gemConditions', 3), $bLink, $cLink) . '</span><br />'; break; } } } $this->activateCondition = $x; } /**************/ /* Extra Tabs */ /**************/ // used by gem $gemList = new ItemList(array(['gemEnchantmentId', $this->typeId])); if (!$gemList->error) { $this->lvTabs[] = ['item', array('data' => array_values($gemList->getListviewData()), 'name' => '$LANG.tab_usedby + \' \' + LANG.gems', 'id' => 'used-by-gem')]; $this->extendGlobalData($gemList->getJsGlobals()); } // used by socket bonus $socketsList = new ItemList(array(['socketBonus', $this->typeId])); if (!$socketsList->error) { $this->lvTabs[] = ['item', array('data' => array_values($socketsList->getListviewData()), 'name' => '$LANG.tab_usedby + \' \' + \'' . Lang::item('socketBonus') . '\'', 'id' => 'used-by-socketbonus')]; $this->extendGlobalData($socketsList->getJsGlobals()); } // used by spell // used by useItem $cnd = array('OR', ['AND', ['effect1Id', [53, 54, 156, 92]], ['effect1MiscValue', $this->typeId]], ['AND', ['effect2Id', [53, 54, 156, 92]], ['effect2MiscValue', $this->typeId]], ['AND', ['effect3Id', [53, 54, 156, 92]], ['effect3MiscValue', $this->typeId]]); $spellList = new SpellList($cnd); if (!$spellList->error) { $spellData = $spellList->getListviewData(); $this->extendGlobalData($spellList->getJsGlobals()); $spellIds = $spellList->getFoundIDs(); $conditions = array('OR', ['AND', ['spellTrigger1', [0, 5]], ['spellId1', $spellIds]], ['AND', ['spellTrigger2', [0, 5]], ['spellId2', $spellIds]], ['AND', ['spellTrigger3', [0, 5]], ['spellId3', $spellIds]], ['AND', ['spellTrigger4', [0, 5]], ['spellId4', $spellIds]], ['AND', ['spellTrigger5', [0, 5]], ['spellId5', $spellIds]]); $ubItems = new ItemList($conditions); if (!$ubItems->error) { $this->lvTabs[] = ['item', array('data' => array_values($ubItems->getListviewData()), 'name' => '$LANG.tab_usedby + \' \' + LANG.types[3][0]', 'id' => 'used-by-item')]; $this->extendGlobalData($ubItems->getJSGlobals(GLOBALINFO_SELF)); } // remove found spells if they are used by an item if (!$ubItems->error) { foreach ($spellList->iterate() as $sId => $__) { // if Perm. Enchantment has a createItem its a Scroll of Enchantment (display both) for ($i = 1; $i < 4; $i++) { if ($spellList->getField('effect' . $i . 'Id') == 53 && $spellList->getField('effect' . $i . 'CreateItemId')) { continue 2; } } foreach ($ubItems->iterate() as $__) { for ($i = 1; $i < 6; $i++) { if ($ubItems->getField('spellId' . $i) == $sId) { unset($spellData[$sId]); break 2; } } } } } $this->lvTabs[] = ['spell', array('data' => array_values($spellData), 'name' => '$LANG.tab_usedby + \' \' + LANG.types[6][0]', 'id' => 'used-by-spell')]; } // used by randomAttrItem $ire = DB::Aowow()->select('SELECT *, ABS(id) AS ARRAY_KEY FROM ?_itemrandomenchant WHERE enchantId1 = ?d OR enchantId2 = ?d OR enchantId3 = ?d OR enchantId4 = ?d OR enchantId5 = ?d', $this->typeId, $this->typeId, $this->typeId, $this->typeId, $this->typeId); if ($ire) { if ($iet = DB::World()->select('SELECT entry AS ARRAY_KEY, ench, chance FROM item_enchantment_template WHERE ench IN (?a)', array_keys($ire))) { $randIds = []; // transform back to signed format foreach ($iet as $tplId => $data) { $randIds[$ire[$data['ench']]['id'] > 0 ? $tplId : -$tplId] = $ire[$data['ench']]['id']; } $randItems = new ItemList(array(CFG_SQL_LIMIT_NONE, ['randomEnchant', array_keys($randIds)])); if (!$randItems->error) { $data = $randItems->getListviewData(); foreach ($randItems->iterate() as $iId => $__) { $re = $randItems->getField('randomEnchant'); $data[$iId]['percent'] = $iet[abs($re)]['chance']; $data[$iId]['count'] = 1; // expected by js or the pct-col becomes unsortable $data[$iId]['rel'] = 'rand=' . $ire[$iet[abs($re)]['ench']]['id']; $data[$iId]['name'] .= ' ' . Util::localizedString($ire[$iet[abs($re)]['ench']], 'name'); } $this->lvTabs[] = ['item', array('data' => array_values($data), 'id' => 'used-by-rand', 'name' => '$LANG.tab_usedby + \' \' + \'' . Lang::item('_rndEnchants') . '\'', 'extraCols' => ['$Listview.extraCols.percent'])]; $this->extendGlobalData($randItems->getJSGlobals(GLOBALINFO_SELF)); } } } }
function profiler() { $success = true; $scripts = []; /**********/ /* Quests */ /**********/ $scripts[] = function () { $success = true; $condition = [CFG_SQL_LIMIT_NONE, 'AND', [['cuFlags', CUSTOM_EXCLUDE_FOR_LISTVIEW], 0], [['flags', QUEST_FLAG_DAILY | QUEST_FLAG_WEEKLY | QUEST_FLAG_REPEATABLE | QUEST_FLAG_AUTO_REWARDED, '&'], 0], [['specialFlags', QUEST_FLAG_SPECIAL_REPEATABLE | QUEST_FLAG_SPECIAL_DUNGEON_FINDER | QUEST_FLAG_SPECIAL_MONTHLY, '&'], 0]]; $questz = new QuestList($condition); $_ = []; $currencies = array_column($questz->rewards, TYPE_CURRENCY); foreach ($currencies as $curr) { foreach ($curr as $cId => $qty) { $_[] = $cId; } } $relCurr = new CurrencyList(array(['id', $_])); foreach (CLISetup::$localeIds as $l) { set_time_limit(20); User::useLocale($l); Lang::load(Util::$localeStrings[$l]); $buff = "var _ = g_gatheredcurrencies;\n"; foreach ($relCurr->getListviewData() as $id => $data) { $buff .= '_[' . $id . '] = ' . Util::toJSON($data) . ";\n"; } $buff .= "\n\nvar _ = g_quests;\n"; foreach ($questz->getListviewData() as $id => $data) { $buff .= '_[' . $id . '] = ' . Util::toJSON($data) . ";\n"; } $buff .= "\ng_quest_catorder = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10];\n"; if (!CLISetup::writeFile('datasets/' . User::$localeString . '/p-quests', $buff)) { $success = false; } } return $success; }; /****************/ /* Achievements */ /****************/ $scripts[] = function () { $success = true; $condition = array(CFG_SQL_LIMIT_NONE, [['cuFlags', CUSTOM_EXCLUDE_FOR_LISTVIEW, '&'], 0], [['flags', 1, '&'], 0]); $achievez = new AchievementList($condition); foreach (CLISetup::$localeIds as $l) { set_time_limit(5); User::useLocale($l); Lang::load(Util::$localeStrings[$l]); $sumPoints = 0; $buff = "var _ = g_achievements;\n"; foreach ($achievez->getListviewData(ACHIEVEMENTINFO_PROFILE) as $id => $data) { $sumPoints += $data['points']; $buff .= '_[' . $id . '] = ' . Util::toJSON($data) . ";\n"; } // categories to sort by $buff .= "\ng_achievement_catorder = [92, 14863, 97, 169, 170, 171, 172, 14802, 14804, 14803, 14801, 95, 161, 156, 165, 14806, 14921, 96, 201, 160, 14923, 14808, 14805, 14778, 14865, 14777, 14779, 155, 14862, 14861, 14864, 14866, 158, 162, 14780, 168, 14881, 187, 14901, 163, 14922, 159, 14941, 14961, 14962, 14981, 15003, 15002, 15001, 15041, 15042, 81]"; // sum points $buff .= "\ng_achievement_points = [" . $sumPoints . "];\n"; if (!CLISetup::writeFile('datasets/' . User::$localeString . '/p-achievements', $buff)) { $success = false; } } return $success; }; /**********/ /* Titles */ /**********/ $scripts[] = function () { $success = true; $condition = array(CFG_SQL_LIMIT_NONE, [['cuFlags', CUSTOM_EXCLUDE_FOR_LISTVIEW, '&'], 0]); $titlez = new TitleList($condition); foreach (CLISetup::$localeIds as $l) { set_time_limit(5); User::useLocale($l); Lang::load(Util::$localeStrings[$l]); foreach ([0, 1] as $g) { $buff = "var _ = g_titles;\n"; foreach ($titlez->getListviewData() as $id => $data) { $data['name'] = Util::localizedString($titlez->getEntry($id), $g ? 'female' : 'male'); unset($data['namefemale']); $buff .= '_[' . $id . '] = ' . Util::toJSON($data) . ";\n"; } if (!CLISetup::writeFile('datasets/' . User::$localeString . '/p-titles-' . $g, $buff)) { $success = false; } } } return $success; }; /**********/ /* Mounts */ /**********/ $scripts[] = function () { $success = true; $condition = array(CFG_SQL_LIMIT_NONE, [['cuFlags', CUSTOM_EXCLUDE_FOR_LISTVIEW, '&'], 0], ['typeCat', -5]); $mountz = new SpellList($condition); foreach (CLISetup::$localeIds as $l) { set_time_limit(5); User::useLocale($l); Lang::load(Util::$localeStrings[$l]); $buff = "var _ = g_spells;\n"; foreach ($mountz->getListviewData(ITEMINFO_MODEL) as $id => $data) { $data['quality'] = $data['name'][0]; $data['name'] = mb_substr($data['name'], 1); $buff .= '_[' . $id . '] = ' . Util::toJSON($data) . ";\n"; } if (!CLISetup::writeFile('datasets/' . User::$localeString . '/p-mounts', $buff)) { $success = false; } } return $success; }; /**************/ /* Companions */ /**************/ $scripts[] = function () { $success = true; $condition = array(CFG_SQL_LIMIT_NONE, [['cuFlags', CUSTOM_EXCLUDE_FOR_LISTVIEW, '&'], 0], ['typeCat', -6]); $companionz = new SpellList($condition); foreach (CLISetup::$localeIds as $l) { set_time_limit(5); User::useLocale($l); Lang::load(Util::$localeStrings[$l]); $buff = "var _ = g_spells;\n"; foreach ($companionz->getListviewData(ITEMINFO_MODEL) as $id => $data) { $data['quality'] = $data['name'][0]; $data['name'] = mb_substr($data['name'], 1); $buff .= '_[' . $id . '] = ' . Util::toJSON($data) . ";\n"; } if (!CLISetup::writeFile('datasets/' . User::$localeString . '/p-companions', $buff)) { $success = false; } } return $success; }; /************/ /* Factions */ /************/ $scripts[] = function () { $success = true; $condition = array(CFG_SQL_LIMIT_NONE, [['cuFlags', CUSTOM_EXCLUDE_FOR_LISTVIEW, '&'], 0]); $factionz = new FactionList($condition); foreach (CLISetup::$localeIds as $l) { set_time_limit(5); User::useLocale($l); Lang::load(Util::$localeStrings[$l]); $buff = "var _ = g_factions;\n"; foreach ($factionz->getListviewData() as $id => $data) { $buff .= '_[' . $id . '] = ' . Util::toJSON($data) . ";\n"; } $buff .= "\ng_faction_order = [0, 469, 891, 1037, 1118, 67, 1052, 892, 936, 1117, 169, 980, 1097];\n"; if (!CLISetup::writeFile('datasets/' . User::$localeString . '/p-factions', $buff)) { $success = false; } } return $success; }; /***********/ /* Recipes */ /***********/ $scripts[] = function () { // special case: secondary skills are always requested, so put them in one single file (185, 129, 356); it also contains g_skill_order $skills = [171, 164, 333, 202, 182, 773, 755, 165, 186, 393, 197, [185, 129, 356]]; $success = true; $baseCnd = array(CFG_SQL_LIMIT_NONE, [['cuFlags', CUSTOM_EXCLUDE_FOR_LISTVIEW, '&'], 0], ['effect1Id', [6, 45, 57, 127, 33, 158, 99, 28, 95], '!'], ['effect2Id', [118, 60], '!'], ['OR', ['typeCat', 9], ['typeCat', 11]]); foreach ($skills as $s) { $file = is_array($s) ? 'sec' : (string) $s; $cnd = array_merge($baseCnd, [['skillLine1', $s]]); $recipez = new SpellList($cnd); $created = ''; foreach ($recipez->iterate() as $__) { foreach ($recipez->canCreateItem() as $idx) { $id = $recipez->getField('effect' . $idx . 'CreateItemId'); $created .= "g_items.add(" . $id . ", {'icon':'" . $recipez->relItems->getEntry($id)['iconString'] . "'});\n"; } } foreach (CLISetup::$localeIds as $l) { set_time_limit(10); User::useLocale($l); Lang::load(Util::$localeStrings[$l]); $buff = ''; foreach ($recipez->getListviewData() as $id => $data) { $buff .= '_[' . $id . '] = ' . Util::toJSON($data) . ";\n"; } if (!$buff) { // this behaviour is intended, do not create an error CLISetup::log('profiler - file datasets/' . User::$localeString . '/p-recipes-' . $file . ' has no content => skipping', CLISetup::LOG_WARN); continue; } $buff = $created . "\nvar _ = g_spells;\n" . $buff; if (is_array($s)) { $buff .= "\ng_skill_order = [171, 164, 333, 202, 182, 773, 755, 165, 186, 393, 197, 185, 129, 356];\n"; } if (!CLISetup::writeFile('datasets/' . User::$localeString . '/p-recipes-' . $file, $buff)) { $success = false; } } } return $success; }; // check directory-structure foreach (Util::$localeStrings as $dir) { if (!CLISetup::writeDir('datasets/' . $dir)) { $success = false; } } // run scripts foreach ($scripts as $func) { if (!$func()) { $success = false; } } return $success; }
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) { 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) { 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' => [], 'quality' => -1, 'icon' => strToLower($enchantSpells->getField('iconString')), 'source' => [], 'skill' => -1, 'slots' => [], 'enchantment' => Util::localizedString($enchMisc[$eId]['text'], 'text'), 'jsonequip' => @$enchJSON[$eId] ?: [], 'temp' => 0, 'classes' => 0); 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])) { foreach ($enchantsOut[$eId] as $k => $v) { if (is_array($v)) { while ($pop = array_pop($ench[$k])) { $enchantsOut[$eId][$k][] = $pop; } } else { if ($k == 'quality') { 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; }
protected function generateXML($asError = false) { $root = new SimpleXML('<aowow />'); if ($asError) { $root->addChild('error', 'Item not found!'); } else { // item root $xml = $root->addChild('item'); $xml->addAttribute('id', $this->subject->id); // name $xml->addChild('name')->addCData($this->subject->getField('name', true)); // itemlevel $xml->addChild('level', $this->subject->getField('itemLevel')); // quality $xml->addChild('quality', Lang::item('quality', $this->subject->getField('quality')))->addAttribute('id', $this->subject->getField('quality')); // class $x = Lang::item('cat', $this->subject->getField('class')); $xml->addChild('class')->addCData(is_array($x) ? $x[0] : $x)->addAttribute('id', $this->subject->getField('class')); // subclass $x = $this->subject->getField('class') == 2 ? Lang::spell('weaponSubClass') : Lang::item('cat', $this->subject->getField('class'), 1); $xml->addChild('subclass')->addCData(is_array($x) ? is_array($x[$this->subject->getField('subClass')]) ? $x[$this->subject->getField('subClass')][0] : $x[$this->subject->getField('subClass')] : null)->addAttribute('id', $this->subject->getField('subClass')); // icon + displayId $xml->addChild('icon', $this->subject->getField('iconString'))->addAttribute('displayId', $this->subject->getField('displayId')); // inventorySlot $xml->addChild('inventorySlot', Lang::item('inventoryType', $this->subject->getField('slot')))->addAttribute('id', $this->subject->getField('slot')); // tooltip $xml->addChild('htmlTooltip')->addCData($this->subject->renderTooltip()); $this->subject->extendJsonStats(); // json $fields = ["classs", "displayid", "dps", "id", "level", "name", "reqlevel", "slot", "slotbak", "source", "sourcemore", "speed", "subclass"]; $json = ''; foreach ($fields as $f) { if (isset($this->subject->json[$this->subject->id][$f])) { $_ = $this->subject->json[$this->subject->id][$f]; if ($f == 'name') { $_ = 7 - $this->subject->getField('quality') . $_; } $json .= ',"' . $f . '":' . $_; } } $xml->addChild('json')->addCData(substr($json, 1)); // jsonEquip missing: avgbuyout, cooldown, source, sourcemore $json = ''; if ($_ = $this->subject->getField('sellPrice')) { // sellprice $json .= ',"sellprice":' . $_; } if ($_ = $this->subject->getField('requiredLevel')) { // reqlevel $json .= ',"reqlevel":' . $_; } if ($_ = $this->subject->getField('requiredSkill')) { // reqskill $json .= ',"reqskill":' . $_; } if ($_ = $this->subject->getField('requiredSkillRank')) { // reqskillrank $json .= ',"reqskillrank":' . $_; } foreach ($this->subject->itemMods[$this->subject->id] as $mod => $qty) { $json .= ',"' . $mod . '":' . $qty; } foreach ($_ = $this->subject->json[$this->subject->id] as $name => $qty) { if (in_array($name, Util::$itemFilter)) { $json .= ',"' . $name . '":' . $qty; } } $xml->addChild('jsonEquip')->addCData(substr($json, 1)); // jsonUse if ($onUse = $this->subject->getOnUseStats()) { $j = ''; foreach ($onUse as $idx => $qty) { $j .= ',"' . Util::$itemMods[$idx] . '":' . $qty; } $xml->addChild('jsonUse')->addCData(substr($j, 1)); } // reagents $cnd = array('OR', ['AND', ['effect1CreateItemId', $this->subject->id], ['OR', ['effect1Id', SpellList::$effects['itemCreate']], ['effect1AuraId', SpellList::$auras['itemCreate']]]], ['AND', ['effect2CreateItemId', $this->subject->id], ['OR', ['effect2Id', SpellList::$effects['itemCreate']], ['effect2AuraId', SpellList::$auras['itemCreate']]]], ['AND', ['effect3CreateItemId', $this->subject->id], ['OR', ['effect3Id', SpellList::$effects['itemCreate']], ['effect3AuraId', SpellList::$auras['itemCreate']]]]); $spellSource = new SpellList($cnd); if (!$spellSource->error) { $cbNode = $xml->addChild('createdBy'); foreach ($spellSource->iterate() as $sId => $__) { foreach ($spellSource->canCreateItem() as $idx) { if ($spellSource->getField('effect' . $idx . 'CreateItemId') != $this->subject->id) { continue; } $splNode = $cbNode->addChild('spell'); $splNode->addAttribute('id', $sId); $splNode->addAttribute('name', $spellSource->getField('name', true)); $splNode->addAttribute('icon', $this->subject->getField('iconString')); $splNode->addAttribute('minCount', $spellSource->getField('effect' . $idx . 'BasePoints') + 1); $splNode->addAttribute('maxCount', $spellSource->getField('effect' . $idx . 'BasePoints') + $spellSource->getField('effect' . $idx . 'DieSides')); foreach ($spellSource->getReagentsForCurrent() as $rId => $qty) { if ($reagent = $spellSource->relItems->getEntry($rId)) { $rgtNode = $splNode->addChild('reagent'); $rgtNode->addAttribute('id', $rId); $rgtNode->addAttribute('name', Util::localizedString($reagent, 'name')); $rgtNode->addAttribute('quality', $reagent['quality']); $rgtNode->addAttribute('icon', $reagent['iconString']); $rgtNode->addAttribute('count', $qty[1]); } } break; } } } // link $xml->addChild('link', HOST_URL . '?item=' . $this->subject->id); } return $root->asXML(); }