protected function generateContent() { // add conditional js $this->addJS('?data=weight-presets.gems.enchants.itemsets&locale=' . User::$localeId . '&t=' . $_SESSION['dataKey']); if (!$this->compareString) { return; } $sets = explode(';', $this->compareString); $items = $outSet = []; foreach ($sets as $set) { $itemSting = explode(':', $set); $outString = []; foreach ($itemSting as $substring) { $params = explode('.', $substring); $items[] = (int) $params[0]; while (sizeof($params) < 7) { $params[] = 0; } $outString[] = $params; } $outSet[] = $outString; } $this->summary = $outSet; $iList = new ItemList(array(['i.id', $items])); $data = $iList->getListviewData(ITEMINFO_SUBITEMS | ITEMINFO_JSON); foreach ($iList->iterate() as $itemId => $__) { if (empty($data[$itemId])) { continue; } $this->cmpItems[] = [$itemId, $iList->getField('name', true), $iList->getField('quality'), $iList->getField('iconString'), $data[$itemId]]; } }
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' => []); } } }
protected function generateContent() { $this->addJS('?data=zones&locale=' . User::$localeId . '&t=' . $_SESSION['dataKey']); $_itemId = $this->subject->getField('itemId'); /***********/ /* Infobox */ /**********/ $infobox = Lang::getInfoBoxForFlags($this->subject->getField('cuFlags')); if ($this->typeId == 103) { // Arena Points $infobox[] = Lang::currency('cap') . Lang::main('colon') . '10\'000'; } else { if ($this->typeId == 104) { // Honor $infobox[] = Lang::currency('cap') . Lang::main('colon') . '75\'000'; } } /****************/ /* Main Content */ /****************/ $this->infobox = $infobox ? '[ul][li]' . implode('[/li][li]', $infobox) . '[/li][/ul]' : null; $this->name = $this->subject->getField('name', true); $this->headIcons = $this->typeId == 104 ? ['inv_bannerpvp_02', 'inv_bannerpvp_01'] : [$this->subject->getField('iconString')]; $this->redButtons = array(BUTTON_WOWHEAD => true, BUTTON_LINKS => true); /**************/ /* Extra Tabs */ /**************/ if ($this->typeId != 103 && $this->typeId != 104) { // tabs: this currency is contained in.. $lootTabs = new Loot(); if ($lootTabs->getByItem($_itemId)) { $this->extendGlobalData($lootTabs->jsGlobals); foreach ($lootTabs->iterate() as $tab) { $this->lvTabs[] = array('file' => $tab[0], 'data' => $tab[1], 'params' => ['name' => $tab[2], 'id' => $tab[3], 'extraCols' => $tab[4] ? '$[' . implode(', ', array_unique($tab[4])) . ']' : null, 'hiddenCols' => $tab[5] ? '$[' . implode(', ', array_unique($tab[5])) . ']' : null, 'visibleCols' => $tab[6] ? '$' . Util::toJSON(array_unique($tab[6])) : null]); } } // tab: sold by $itemObj = new ItemList(array(['id', $_itemId])); if (!empty($itemObj->getExtendedCost()[$_itemId])) { $vendors = $itemObj->getExtendedCost()[$_itemId]; $this->extendGlobalData($itemObj->getJSGlobals(GLOBALINFO_SELF | GLOBALINFO_RELATED)); $soldBy = new CreatureList(array(['id', array_keys($vendors)])); if (!$soldBy->error) { $sbData = $soldBy->getListviewData(); $extraCols = ['Listview.extraCols.stock', "Listview.funcBox.createSimpleCol('stack', 'stack', '10%', 'stack')", 'Listview.extraCols.cost']; $holidays = []; foreach ($sbData as $k => &$row) { $items = []; $tokens = []; foreach ($vendors[$k] as $id => $qty) { if (is_string($id)) { continue; } if ($id > 0) { $tokens[] = [$id, $qty]; } else { if ($id < 0) { $items[] = [-$id, $qty]; } } } if ($vendors[$k]['event']) { if (count($extraCols) == 3) { // not already pushed $extraCols[] = 'Listview.extraCols.condition'; } $this->extendGlobalIds(TYPE_WORLDEVENT, $vendors[$k]['event']); $row['condition'][0][$this->typeId][] = [[CND_ACTIVE_EVENT, $vendors[$k]['event']]]; } $row['stock'] = $vendors[$k]['stock']; $row['stack'] = $itemObj->getField('buyCount'); $row['cost'] = array($itemObj->getField('buyPrice'), $items ? $items : null, $tokens ? $tokens : null); } $this->lvTabs[] = array('file' => 'creature', 'data' => $sbData, 'params' => ['name' => '$LANG.tab_soldby', 'id' => 'sold-by-npc', 'extraCols' => '$[' . implode(', ', $extraCols) . ']', 'hiddenCols' => "\$['level', 'type']"]); } } } // tab: created by (spell) [for items its handled in Loot::getByContainer()] if ($this->typeId == 104) { $createdBy = new SpellList(array(['effect1Id', 45], ['effect2Id', 45], ['effect3Id', 45], 'OR')); if (!$createdBy->error) { $this->extendGlobalData($createdBy->getJSGlobals(GLOBALINFO_SELF | GLOBALINFO_RELATED)); if ($createdBy->hasSetFields(['reagent1'])) { $visCols = ['reagents']; } $this->lvTabs[] = array('file' => 'spell', 'data' => $createdBy->getListviewData(), 'params' => ['name' => '$LANG.tab_createdby', 'id' => 'created-by', 'visibleCols' => isset($visCols) ? '$' . Util::toJSON($visCols) : null]); } } // tab: currency for if ($this->typeId == 103) { $n = '?items&filter=cr=145;crs=1;crv=0'; $w = 'reqArenaPoints > 0'; } else { if ($this->typeId == 104) { $n = '?items&filter=cr=144;crs=1;crv=0'; $w = 'reqHonorPoints > 0'; } else { $n = in_array($this->typeId, [42, 61, 81, 241, 121, 122, 123, 125, 126, 161, 201, 101, 102, 221, 301, 341]) ? '?items&filter=cr=158;crs=' . $_itemId . ';crv=0' : null; $w = 'reqItemId1 = ' . $_itemId . ' OR reqItemId2 = ' . $_itemId . ' OR reqItemId3 = ' . $_itemId . ' OR reqItemId4 = ' . $_itemId . ' OR reqItemId5 = ' . $_itemId; } } $xCosts = DB::Aowow()->selectCol('SELECT id FROM ?_itemextendedcost WHERE ' . $w); $boughtBy = $xCosts ? DB::World()->selectCol('SELECT item FROM npc_vendor WHERE extendedCost IN (?a) UNION SELECT item FROM game_event_npc_vendor WHERE extendedCost IN (?a)', $xCosts, $xCosts) : []; if ($boughtBy) { $boughtBy = new ItemList(array(['id', $boughtBy])); if (!$boughtBy->error) { if ($boughtBy->getMatches() <= CFG_SQL_LIMIT_DEFAULT) { $n = null; } $this->lvTabs[] = array('file' => 'item', 'data' => $boughtBy->getListviewData(ITEMINFO_VENDOR, [TYPE_CURRENCY => $this->typeId]), 'params' => ['name' => '$LANG.tab_currencyfor', 'id' => 'currency-for', 'extraCols' => "\$[Listview.funcBox.createSimpleCol('stack', 'stack', '10%', 'stack')]", 'note' => $n ? sprintf(Util::$filterResultString, $n) : null]); $this->extendGlobalData($boughtBy->getJSGlobals(GLOBALINFO_SELF | GLOBALINFO_RELATED)); } } }
protected function generateContent() { $_ta = $this->subject->getField('contentGroup'); $_ty = $this->subject->getField('type'); $_cnt = count($this->subject->getField('pieces')); /***********/ /* Infobox */ /***********/ $infobox = Lang::getInfoBoxForFlags($this->subject->getField('cuFlags')); // unavailable (todo (low): set data) if ($this->subject->getField('cuFlags') & CUSTOM_UNAVAILABLE) { $infobox[] = Lang::main('unavailable'); } // worldevent if ($e = $this->subject->getField('eventId')) { $infobox[] = Lang::game('eventShort') . Lang::main('colon') . '[event=' . $e . ']'; $this->extendGlobalIds(TYPE_WORLDEVENT, $e); } // itemLevel if ($min = $this->subject->getField('minLevel')) { $foo = Lang::game('level') . Lang::main('colon') . $min; $max = $this->subject->getField('maxLevel'); if ($min < $max) { $foo .= ' - ' . $max; } $infobox[] = $foo; } // class if ($cl = Lang::getClassString($this->subject->getField('classMask'), $jsg, $qty, false)) { $this->extendGlobalIds(TYPE_CLASS, $jsg); $t = $qty == 1 ? Lang::game('class') : Lang::game('classes'); $infobox[] = Util::ucFirst($t) . Lang::main('colon') . $cl; } // required level if ($lvl = $this->subject->getField('reqLevel')) { $infobox[] = sprintf(Lang::game('reqLevel'), $lvl); } // type if ($_ty) { $infobox[] = Lang::game('type') . Lang::main('colon') . Lang::itemset('types', $_ty); } // tag if ($_ta) { $infobox[] = Lang::itemset('_tag') . Lang::main('colon') . '[url=?itemsets&filter=ta=' . $_ta . ']' . Lang::itemset('notes', $_ta) . '[/url]'; } /****************/ /* Main Content */ /****************/ // pieces + Summary $pieces = []; $eqList = []; $compare = []; if (!$this->subject->pieceToSet) { $cnd = [0]; } else { $cnd = ['i.id', array_keys($this->subject->pieceToSet)]; } $iList = new ItemList(array($cnd)); $data = $iList->getListviewData(ITEMINFO_SUBITEMS | ITEMINFO_JSON); foreach ($iList->iterate() as $itemId => $__) { if (empty($data[$itemId])) { continue; } $slot = $iList->getField('slot'); $disp = $iList->getField('displayId'); if ($slot && $disp) { $eqList[] = [$slot, $disp]; } $compare[] = $itemId; $pieces[] = array('id' => $itemId, 'name' => $iList->getField('name', true), 'quality' => $iList->getField('quality'), 'icon' => $iList->getField('iconString'), 'json' => $data[$itemId]); } $skill = ''; if ($_sk = $this->subject->getField('skillId')) { $spellLink = sprintf('<a href="?spells=11.%s">%s</a> (%s)', $_sk, Lang::spell('cat', 11, $_sk, 0), $this->subject->getField('skillLevel')); $skill = ' – <small><b>' . sprintf(Lang::game('requires'), $spellLink) . '</b></small>'; } $this->bonusExt = $skill; $this->description = $_ta ? sprintf(Lang::itemset('_desc'), $this->name, Lang::itemset('notes', $_ta), $_cnt) : sprintf(Lang::itemset('_descTagless'), $this->name, $_cnt); $this->unavailable = $this->subject->getField('cuFlags') & CUSTOM_UNAVAILABLE; $this->infobox = $infobox ? '[ul][li]' . implode('[/li][li]', $infobox) . '[/li][/ul]' : null; $this->pieces = $pieces; $this->spells = $this->subject->getBonuses(); $this->expansion = 0; $this->redButtons = array(BUTTON_WOWHEAD => $this->typeId > 0, BUTTON_LINKS => ['color' => '', 'linkId' => ''], BUTTON_VIEW3D => ['type' => TYPE_ITEMSET, 'typeId' => $this->typeId, 'equipList' => $eqList], BUTTON_COMPARE => ['eqList' => implode(':', $compare), 'qty' => $_cnt]); $this->compare = array('level' => $this->subject->getField('reqLevel'), 'items' => array_map(function ($v) { return [[$v]]; }, $compare)); /**************/ /* Extra Tabs */ /**************/ // related sets (priority: 1: similar tag + class; 2: has event; 3: no tag + similar type, 4: similar type + profession) $rel = []; if ($_ta && count($this->path) == 3) { $rel[] = ['id', $this->typeId, '!']; $rel[] = ['classMask', 1 << end($this->path) - 1, '&']; $rel[] = ['contentGroup', (int) $_ta]; } else { if ($this->subject->getField('eventId')) { $rel[] = ['id', $this->typeId, '!']; $rel[] = ['eventId', 0, '!']; } else { if ($this->subject->getField('skillId')) { $rel[] = ['id', $this->typeId, '!']; $rel[] = ['contentGroup', 0]; $rel[] = ['skillId', 0, '!']; $rel[] = ['type', $_ty]; } else { if (!$_ta && $_ty) { $rel[] = ['id', $this->typeId, '!']; $rel[] = ['contentGroup', 0]; $rel[] = ['type', $_ty]; $rel[] = ['skillId', 0]; } } } } if ($rel) { $relSets = new ItemsetList($rel); if (!$relSets->error) { $lv = array('file' => 'itemset', 'data' => $relSets->getListviewData(), 'params' => array('id' => 'see-also', 'name' => '$LANG.tab_seealso')); if (!$relSets->hasDiffFields(['classMask'])) { $lv['params']['hiddenCols'] = "\$['classes']"; } $this->lvTabs[] = $lv; $this->extendGlobalData($relSets->getJSGlobals()); } } }
protected function generateContent() { $this->addJS('?data=zones&locale=' . User::$localeId . '&t=' . $_SESSION['dataKey']); /***********/ /* Infobox */ /***********/ $infobox = Lang::getInfoBoxForFlags($this->subject->getField('cuFlags')); // Quartermaster if any if ($ids = $this->subject->getField('qmNpcIds')) { $this->extendGlobalIds(TYPE_NPC, $ids); $qmStr = Lang::faction('quartermaster') . Lang::main('colon'); if (count($ids) == 1) { $qmStr .= '[npc=' . $ids[0] . ']'; } else { if (count($ids) > 1) { $qmStr .= '[ul]'; foreach ($ids as $id) { $qmStr .= '[li][npc=' . $id . '][/li]'; } $qmStr .= '[/ul]'; } } $infobox[] = $qmStr; } // side if any if ($_ = $this->subject->getField('side')) { $infobox[] = Lang::main('side') . Lang::main('colon') . '[span class=icon-' . ($_ == 1 ? 'alliance' : 'horde') . ']' . Lang::game('si', $_) . '[/span]'; } /****************/ /* Main Content */ /****************/ $this->extraText = ''; $this->infobox = $infobox ? '[ul][li]' . implode('[/li][li]', $infobox) . '[/li][/ul]' : null; $this->redButtons = array(BUTTON_WOWHEAD => true, BUTTON_LINKS => true); // Spillover Effects /* todo (low): also check on reputation_spillover_template (but its data is identical to calculation below $rst = DB::World()->selectRow('SELECT CONCAT_WS(" ", faction1, faction2, faction3, faction4) AS faction, CONCAT_WS(" ", rate_1, rate_2, rate_3, rate_4) AS rate, CONCAT_WS(" ", rank_1, rank_2, rank_3, rank_4) AS rank FROM reputation_spillover_template WHERE faction = ?d', $this->typeId); */ $conditions = array(['id', $this->typeId, '!'], ['repIdx', -1, '!']); if ($p = $this->subject->getField('parentFactionId')) { // linked via parent $conditions[] = ['OR', ['id', $p], ['parentFactionId', $p]]; } else { // self as parent $conditions[] = ['parentFactionId', $this->typeId]; } $spillover = new FactionList($conditions); $this->extendGlobalData($spillover->getJSGlobals()); $buff = ''; foreach ($spillover->iterate() as $spillId => $__) { if ($val = $spillover->getField('spilloverRateIn') * $this->subject->getField('spilloverRateOut') * 100) { $buff .= '[tr][td][faction=' . $spillId . '][/td][td][span class=q' . ($val > 0 ? '2]+' : '10]') . $val . '%[/span][/td][td]' . Lang::game('rep', $spillover->getField('spilloverMaxRank')) . '[/td][/tr]'; } } if ($buff) { $this->extraText .= '[h3 class=clear]' . Lang::faction('spillover') . '[/h3][div margin=15px]' . Lang::faction('spilloverDesc') . '[/div][table class=grid width=400px][tr][td width=150px][b]' . Util::ucFirst(Lang::game('faction')) . '[/b][/td][td width=100px][b]' . Lang::spell('_value') . '[/b][/td][td width=150px][b]' . Lang::faction('maxStanding') . '[/b][/td][/tr]' . $buff . '[/table]'; } // reward rates (ultimately this should be calculated into each reward display) if ($rates = DB::World()->selectRow('SELECT * FROM reputation_reward_rate WHERE faction = ?d', $this->typeId)) { $buff = ''; foreach ($rates as $k => $v) { if ($v == 1) { continue; } switch ($k) { case 'quest_rate': $buff .= '[tr][td]' . Lang::game('quests') . Lang::main('colon') . '[/td]'; break; case 'quest_daily_rate': $buff .= '[tr][td]' . Lang::game('quests') . ' (' . Lang::quest('daily') . ')' . Lang::main('colon') . '[/td]'; break; case 'quest_weekly_rate': $buff .= '[tr][td]' . Lang::game('quests') . ' (' . Lang::quest('weekly') . ')' . Lang::main('colon') . '[/td]'; break; case 'quest_monthly_rate': $buff .= '[tr][td]' . Lang::game('quests') . ' (' . Lang::quest('monthly') . ')' . Lang::main('colon') . '[/td]'; break; case 'creature_rate': $buff .= '[tr][td]' . Lang::game('npcs') . Lang::main('colon') . '[/td]'; break; case 'spell_rate': $buff .= '[tr][td]' . Lang::game('spells') . Lang::main('colon') . '[/td]'; break; } $buff .= '[td width=35px align=right][span class=q' . ($v < 1 ? '10]' : '2]+') . intVal(($v - 1) * 100) . '%[/span][/td][/tr]'; } if ($buff) { $this->extraText .= '[h3 class=clear]' . Lang::faction('customRewRate') . '[/h3][table]' . $buff . '[/table]'; } } // factionchange-equivalent if ($pendant = DB::World()->selectCell('SELECT IF(horde_id = ?d, alliance_id, -horde_id) FROM player_factionchange_reputations WHERE alliance_id = ?d OR horde_id = ?d', $this->typeId, $this->typeId, $this->typeId)) { $altFac = new FactionList(array(['id', abs($pendant)])); if (!$altFac->error) { $this->transfer = sprintf(Lang::faction('_transfer'), $altFac->id, $altFac->getField('name', true), $pendant > 0 ? 'alliance' : 'horde', $pendant > 0 ? Lang::game('si', 1) : Lang::game('si', 2)); } } /**************/ /* Extra Tabs */ /**************/ // tab: items $items = new ItemList(array(['requiredFaction', $this->typeId])); if (!$items->error) { $this->extendGlobalData($items->getJSGlobals(GLOBALINFO_SELF)); $tabData = array('data' => array_values($items->getListviewData()), 'extraCols' => '$_', 'sort' => ['standing', 'name']); if ($items->getMatches() > CFG_SQL_LIMIT_DEFAULT) { $tabData['note'] = sprintf(Util::$filterResultString, '?items&filter=cr=17;crs=' . $this->typeId . ';crv=0'); } $this->lvTabs[] = ['item', $tabData, 'itemStandingCol']; } // tab: creatures with onKill reputation if ($this->subject->getField('reputationIndex') != -1) { // inherit siblings/children from $spillover $cRep = DB::World()->selectCol('SELECT DISTINCT creature_id AS ARRAY_KEY, qty FROM ( SELECT creature_id, RewOnKillRepValue1 as qty FROM creature_onkill_reputation WHERE RewOnKillRepValue1 > 0 AND (RewOnKillRepFaction1 = ?d{ OR (RewOnKillRepFaction1 IN (?a) AND IsTeamAward1 <> 0)}) UNION SELECT creature_id, RewOnKillRepValue2 as qty FROM creature_onkill_reputation WHERE RewOnKillRepValue2 > 0 AND (RewOnKillRepFaction2 = ?d{ OR (RewOnKillRepFaction2 IN (?a) AND IsTeamAward2 <> 0)}) ) x', $this->typeId, $spillover->getFoundIDs() ?: DBSIMPLE_SKIP, $this->typeId, $spillover->getFoundIDs() ?: DBSIMPLE_SKIP); if ($cRep) { $killCreatures = new CreatureList(array(['id', array_keys($cRep)])); if (!$killCreatures->error) { $data = $killCreatures->getListviewData(); foreach ($data as $id => &$d) { $d['reputation'] = $cRep[$id]; } $tabData = array('data' => array_values($data), 'extraCols' => '$_', 'sort' => ['-reputation', 'name']); if ($killCreatures->getMatches() > CFG_SQL_LIMIT_DEFAULT) { $tabData['note'] = sprintf(Util::$filterResultString, '?npcs&filter=cr=42;crs=' . $this->typeId . ';crv=0'); } $this->lvTabs[] = ['creature', $tabData, 'npcRepCol']; } } } // tab: members if ($_ = $this->subject->getField('templateIds')) { $members = new CreatureList(array(['faction', $_])); if (!$members->error) { $tabData = array('data' => array_values($members->getListviewData()), 'id' => 'member', 'name' => '$LANG.tab_members'); if ($members->getMatches() > CFG_SQL_LIMIT_DEFAULT) { $tabData['note'] = sprintf(Util::$filterResultString, '?npcs&filter=cr=3;crs=' . $this->typeId . ';crv=0'); } $this->lvTabs[] = ['creature', $tabData]; } } // tab: objects if ($_ = $this->subject->getField('templateIds')) { $objects = new GameObjectList(array(['faction', $_])); if (!$objects->error) { $this->lvTabs[] = ['object', ['data' => array_values($objects->getListviewData())]]; } } // tab: quests $conditions = array(['AND', ['rewardFactionId1', $this->typeId], ['rewardFactionValue1', 0, '>']], ['AND', ['rewardFactionId2', $this->typeId], ['rewardFactionValue2', 0, '>']], ['AND', ['rewardFactionId3', $this->typeId], ['rewardFactionValue3', 0, '>']], ['AND', ['rewardFactionId4', $this->typeId], ['rewardFactionValue4', 0, '>']], ['AND', ['rewardFactionId5', $this->typeId], ['rewardFactionValue5', 0, '>']], 'OR'); $quests = new QuestList($conditions); if (!$quests->error) { $this->extendGlobalData($quests->getJSGlobals(GLOBALINFO_ANY)); $tabData = array('data' => array_values($quests->getListviewData($this->typeId)), 'extraCols' => '$_'); if ($quests->getMatches() > CFG_SQL_LIMIT_DEFAULT) { $tabData['note'] = sprintf(Util::$filterResultString, '?quests&filter=cr=1;crs=' . $this->typeId . ';crv=0'); } $this->lvTabs[] = ['quest', $tabData, 'questRepCol']; } // tab: achievements $conditions = array(['ac.type', ACHIEVEMENT_CRITERIA_TYPE_GAIN_REPUTATION], ['ac.value1', $this->typeId]); $acvs = new AchievementList($conditions); if (!$acvs->error) { $this->extendGlobalData($acvs->getJSGlobals(GLOBALINFO_ANY)); $this->lvTabs[] = ['achievement', array('data' => array_values($acvs->getListviewData()), 'id' => 'criteria-of', 'name' => '$LANG.tab_criteriaof', 'visibleCols' => ['category'])]; } }
protected function generateContent() { $infobox = []; $_mask = 1 << $this->typeId - 1; $mountVendors = array(null, [384, 33307], [3362, 33553], [1261, 33310], [4730, 33653], [4731, 33555], [3685, 33556], [7955, 33650], [7952, 33554], null, [16264, 33557], [17584, 33657]); /***********/ /* Infobox */ /***********/ $infobox = Lang::getInfoBoxForFlags($this->subject->getField('cuFlags')); // side if ($_ = $this->subject->getField('side')) { $infobox[] = Lang::main('side') . Lang::main('colon') . '[span class=icon-' . ($_ == 2 ? 'horde' : 'alliance') . ']' . Lang::game('si', $_) . '[/span]'; } // faction if ($_ = $this->subject->getField('factionId')) { $fac = new FactionList(array(['f.id', $_])); $this->extendGlobalData($fac->getJSGlobals()); $infobox[] = Util::ucFirst(Lang::game('faction')) . Lang::main('colon') . '[faction=' . $fac->id . ']'; } // leader if ($_ = $this->subject->getField('leader')) { $this->extendGlobalIds(TYPE_NPC, $_); $infobox[] = Lang::race('racialLeader') . Lang::main('colon') . '[npc=' . $_ . ']'; } // start area if ($_ = $this->subject->getField('startAreaId')) { $this->extendGlobalIds(TYPE_ZONE, $_); $infobox[] = Lang::race('startZone') . Lang::main('colon') . '[zone=' . $_ . ']'; } /****************/ /* Main Content */ /****************/ $this->infobox = '[ul][li]' . implode('[/li][li]', $infobox) . '[/li][/ul]'; $this->expansion = Util::$expansionString[$this->subject->getField('expansion')]; $this->headIcons = array('race_' . strtolower($this->subject->getField('fileString')) . '_male', 'race_' . strtolower($this->subject->getField('fileString')) . '_female'); $this->redButtons = array(BUTTON_WOWHEAD => true, BUTTON_LINKS => true); /**************/ /* Extra Tabs */ /**************/ // Classes $classes = new CharClassList(array(['racemask', $_mask, '&'])); if (!$classes->error) { $this->extendGlobalData($classes->getJSGlobals()); $this->lvTabs[] = ['class', ['data' => array_values($classes->getListviewData())]]; } // Tongues $conditions = array(['typeCat', -11], ['reqRaceMask', $_mask, '&']); $tongues = new SpellList($conditions); if (!$tongues->error) { $this->extendGlobalData($tongues->getJSGlobals()); $this->lvTabs[] = ['spell', array('data' => array_values($tongues->getListviewData()), 'id' => 'languages', 'name' => '$LANG.tab_languages', 'hiddenCols' => ['reagents'])]; } // Racials $conditions = array(['typeCat', -4], ['reqRaceMask', $_mask, '&']); $racials = new SpellList($conditions); if (!$racials->error) { $this->extendGlobalData($racials->getJSGlobals()); $this->lvTabs[] = ['spell', array('data' => array_values($racials->getListviewData()), 'id' => 'racial-traits', 'name' => '$LANG.tab_racialtraits', 'hiddenCols' => ['reagents'])]; } // Quests $conditions = array(['reqRaceMask', $_mask, '&'], [['reqRaceMask', RACE_MASK_HORDE, '&'], RACE_MASK_HORDE, '!'], [['reqRaceMask', RACE_MASK_ALLIANCE, '&'], RACE_MASK_ALLIANCE, '!']); $quests = new QuestList($conditions); if (!$quests->error) { $this->extendGlobalData($quests->getJSGlobals()); $this->lvTabs[] = ['quest', ['data' => array_values($quests->getListviewData())]]; } // Mounts // ok, this sucks, but i rather hardcode the trainer, than fetch items by namepart $items = isset($mountVendors[$this->typeId]) ? DB::World()->selectCol('SELECT item FROM npc_vendor WHERE entry IN (?a)', $mountVendors[$this->typeId]) : 0; $conditions = array(['i.id', $items], ['i.class', ITEM_CLASS_MISC], ['i.subClass', 5]); $mounts = new ItemList($conditions); if (!$mounts->error) { $this->extendGlobalData($mounts->getJSGlobals()); $this->lvTabs[] = ['item', array('data' => array_values($mounts->getListviewData()), 'id' => 'mounts', 'name' => '$LANG.tab_mounts', 'hiddenCols' => ['slot', 'type'])]; } }
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)); } } } }
protected function generateContent() { $this->addJS('?data=zones&locale=' . User::$localeId . '&t=' . $_SESSION['dataKey']); $_typeFlags = $this->subject->getField('typeFlags'); $_altIds = []; $_altNPCs = null; $placeholder = null; $accessory = []; // difficulty entries of self if ($this->subject->getField('cuFlags') & NPC_CU_DIFFICULTY_DUMMY) { $placeholder = [$this->subject->getField('parentId'), $this->subject->getField('parent', true)]; } else { for ($i = 1; $i < 4; $i++) { if ($_ = $this->subject->getField('difficultyEntry' . $i)) { $_altIds[$_] = $i; } } if ($_altIds) { $_altNPCs = new CreatureList(array(['id', array_keys($_altIds)])); } } if ($_ = DB::World()->selectCol('SELECT DISTINCT entry FROM vehicle_template_accessory WHERE accessory_entry = ?d', $this->typeId)) { $vehicles = new CreatureList(array(['id', $_])); foreach ($vehicles->iterate() as $id => $__) { $accessory[] = [$id, $vehicles->getField('name', true)]; } } // try to determine, if it's spawned in a dungeon or raid (shaky at best, if spawned by script) $mapType = 0; if ($maps = DB::Aowow()->selectCol('SELECT DISTINCT areaId from ?_spawns WHERE type = ?d AND typeId = ?d', TYPE_NPC, $this->typeId)) { if (count($maps) == 1) { switch (DB::Aowow()->selectCell('SELECT `type` FROM ?_zones WHERE id = ?d', $maps[0])) { case 2: case 5: $mapType = 1; break; case 3: case 7: case 8: $mapType = 2; break; } } } else { if ($_altIds) { if (count($_altIds) > 1) { // 3 or more version -> definitly raid (10/25 + hc) $mapType = 2; } else { // 2 versions; may be Heroic (use this), but may also be 10/25-raid $mapType = 1; } } } /***********/ /* Infobox */ /***********/ $infobox = Lang::getInfoBoxForFlags($this->subject->getField('cuFlags')); // Event (ignore events, where the object only gets removed) if ($_ = DB::World()->selectCol('SELECT DISTINCT ge.eventEntry FROM game_event ge, game_event_creature gec, creature c WHERE ge.eventEntry = gec.eventEntry AND c.guid = gec.guid AND c.id = ?d', $this->typeId)) { $this->extendGlobalIds(TYPE_WORLDEVENT, $_); $ev = []; foreach ($_ as $i => $e) { $ev[] = ($i % 2 ? '[br]' : ' ') . '[event=' . $e . ']'; } $infobox[] = Util::ucFirst(Lang::game('eventShort')) . Lang::main('colon') . implode(',', $ev); } // Level if ($this->subject->getField('rank') != NPC_RANK_BOSS) { $level = $this->subject->getField('minLevel'); $maxLvl = $this->subject->getField('maxLevel'); if ($level < $maxLvl) { $level .= ' - ' . $maxLvl; } } else { // Boss Level $level = '??'; } $infobox[] = Lang::game('level') . Lang::main('colon') . $level; // Classification if ($_ = $this->subject->getField('rank')) { $str = $_typeFlags & 0x4 ? '[span class=icon-boss]' . Lang::npc('rank', $_) . '[/span]' : Lang::npc('rank', $_); $infobox[] = Lang::npc('classification') . Lang::main('colon') . $str; } // Reaction $_ = function ($r) { if ($r == 1) { return 2; } if ($r == -1) { return 10; } return; }; $infobox[] = Lang::npc('react') . Lang::main('colon') . '[color=q' . $_($this->subject->getField('A')) . ']A[/color] [color=q' . $_($this->subject->getField('H')) . ']H[/color]'; // Faction $this->extendGlobalIds(TYPE_FACTION, $this->subject->getField('factionId')); $infobox[] = Util::ucFirst(Lang::game('faction')) . Lang::main('colon') . '[faction=' . $this->subject->getField('factionId') . ']'; // Tameable if ($_typeFlags & 0x1) { if ($_ = $this->subject->getField('family')) { $infobox[] = sprintf(Lang::npc('tameable'), '[url=pet=' . $_ . ']' . Lang::game('fa', $_) . '[/url]'); } } // Wealth if ($_ = intVal(($this->subject->getField('minGold') + $this->subject->getField('maxGold')) / 2)) { $infobox[] = Lang::npc('worth') . Lang::main('colon') . '[tooltip=tooltip_avgmoneydropped][money=' . $_ . '][/tooltip]'; } // is Vehicle if ($this->subject->getField('vehicleId')) { $infobox[] = Lang::npc('vehicle'); } // AI if (User::isInGroup(U_GROUP_EMPLOYEE)) { if ($_ = $this->subject->getField('scriptName')) { $infobox[] = 'Script' . Lang::main('colon') . $_; } else { if ($_ = $this->subject->getField('aiName')) { $infobox[] = 'AI' . Lang::main('colon') . $_; } } } if (User::isInGroup(U_GROUP_STAFF)) { // Mechanic immune if ($immuneMask = $this->subject->getField('mechanicImmuneMask')) { $buff = []; for ($i = 0; $i < 31; $i++) { if ($immuneMask & 1 << $i) { $buff[] = (!fMod(count($buff), 3) ? "\n" : null) . '[url=?spells&filter=me=' . ($i + 1) . ']' . Lang::game('me', $i + 1) . '[/url]'; } } $infobox[] = 'Not affected by mechanic' . Lang::main('colon') . implode(', ', $buff); } // extra flags if ($flagsExtra = $this->subject->getField('flagsExtra')) { $buff = []; if ($flagsExtra & 0x1) { $buff[] = 'Binds attacker to instance on death'; } if ($flagsExtra & 0x2) { $buff[] = "[tooltip name=civilian]- does not aggro\n- death costs Honor[/tooltip][span class=tip tooltip=civilian]Civilian[/span]"; } if ($flagsExtra & 0x4) { $buff[] = 'Cannot parry'; } if ($flagsExtra & 0x8) { $buff[] = 'Has no parry haste'; } if ($flagsExtra & 0x10) { $buff[] = 'Cannot block'; } if ($flagsExtra & 0x20) { $buff[] = 'Cannot deal Crushing Blows'; } if ($flagsExtra & 0x40) { $buff[] = 'Rewards no experience'; } if ($flagsExtra & 0x80) { $buff[] = 'Trigger-Creature'; } if ($flagsExtra & 0x100) { $buff[] = 'Immune to Taunt'; } if ($flagsExtra & 0x8000) { $buff[] = "[tooltip name=guard]- engages PvP-Attacker\n- ignores enemy stealth, invisibility and Feign Death[/tooltip][span class=tip tooltip=guard]Guard[/span]"; } if ($flagsExtra & 0x20000) { $buff[] = 'Cannot deal Critical Hits'; } if ($flagsExtra & 0x40000) { $buff[] = 'Attacker does not gain weapon skill'; } if ($flagsExtra & 0x80000) { $buff[] = 'Taunt has diminishing returns'; } if ($flagsExtra & 0x100000) { $buff[] = 'Is subject to diminishing returns'; } if ($buff) { $infobox[] = 'Extra Flags' . Lang::main('colon') . '[ul][li]' . implode('[/li][li]', $buff) . '[/li][/ul]'; } } } // > Stats $stats = []; $modes = []; // get difficulty versions if set $hint = '[tooltip name=%3$s][table cellspacing=10][tr]%1s[/tr][/table][/tooltip][span class=tip tooltip=%3$s]%2s[/span]'; $modeRow = '[tr][td]%s [/td][td]%s[/td][/tr]'; // Health $health = $this->subject->getBaseStats('health'); $stats['health'] = Util::ucFirst(Lang::spell('powerTypes', -2)) . Lang::main('colon') . ($health[0] < $health[1] ? Lang::nf($health[0]) . ' - ' . Lang::nf($health[1]) : Lang::nf($health[0])); // Mana (may be 0) $mana = $this->subject->getBaseStats('power'); $stats['mana'] = $mana[0] ? Lang::spell('powerTypes', 0) . Lang::main('colon') . ($mana[0] < $mana[1] ? Lang::nf($mana[0]) . ' - ' . Lang::nf($mana[1]) : Lang::nf($mana[0])) : null; // Armor $armor = $this->subject->getBaseStats('armor'); $stats['armor'] = Lang::npc('armor') . Lang::main('colon') . ($armor[0] < $armor[1] ? Lang::nf($armor[0]) . ' - ' . Lang::nf($armor[1]) : Lang::nf($armor[0])); // Melee Damage $melee = $this->subject->getBaseStats('melee'); if ($_ = $this->subject->getField('dmgSchool')) { // magic damage $stats['melee'] = Lang::npc('melee') . Lang::main('colon') . Lang::nf($melee[0]) . ' - ' . Lang::nf($melee[1]) . ' (' . Lang::game('sc', $_) . ')'; } else { // phys. damage $stats['melee'] = Lang::npc('melee') . Lang::main('colon') . Lang::nf($melee[0]) . ' - ' . Lang::nf($melee[1]); } // Ranged Damage $ranged = $this->subject->getBaseStats('ranged'); $stats['ranged'] = Lang::npc('ranged') . Lang::main('colon') . Lang::nf($ranged[0]) . ' - ' . Lang::nf($ranged[1]); if (in_array($mapType, [1, 2])) { foreach ($_altIds as $id => $mode) { foreach ($_altNPCs->iterate() as $dId => $__) { if ($dId != $id) { continue; } $m = Lang::npc('modes', $mapType, $mode); // Health $health = $_altNPCs->getBaseStats('health'); $modes['health'][] = sprintf($modeRow, $m, $health[0] < $health[1] ? Lang::nf($health[0]) . ' - ' . Lang::nf($health[1]) : Lang::nf($health[0])); // Mana (may be 0) $mana = $_altNPCs->getBaseStats('power'); $modes['mana'][] = $mana[0] ? sprintf($modeRow, $m, $mana[0] < $mana[1] ? Lang::nf($mana[0]) . ' - ' . Lang::nf($mana[1]) : Lang::nf($mana[0])) : null; // Armor $armor = $_altNPCs->getBaseStats('armor'); $modes['armor'][] = sprintf($modeRow, $m, $armor[0] < $armor[1] ? Lang::nf($armor[0]) . ' - ' . Lang::nf($armor[1]) : Lang::nf($armor[0])); // Melee Damage $melee = $_altNPCs->getBaseStats('melee'); if ($_ = $_altNPCs->getField('dmgSchool')) { // magic damage $modes['melee'][] = sprintf($modeRow, $m, Lang::nf($melee[0]) . ' - ' . Lang::nf($melee[1]) . ' (' . Lang::game('sc', $_) . ')'); } else { // phys. damage $modes['melee'][] = sprintf($modeRow, $m, Lang::nf($melee[0]) . ' - ' . Lang::nf($melee[1])); } // Ranged Damage $ranged = $_altNPCs->getBaseStats('ranged'); $modes['ranged'][] = sprintf($modeRow, $m, Lang::nf($ranged[0]) . ' - ' . Lang::nf($ranged[1])); } } } if ($modes) { foreach ($stats as $k => $v) { if ($v) { $stats[$k] = sprintf($hint, implode('[/tr][tr]', $modes[$k]), $v, $k); } } } // < Stats if ($stats) { $infobox[] = Lang::npc('stats') . ($modes ? ' (' . Lang::npc('modes', $mapType, 0) . ')' : null) . Lang::main('colon') . '[ul][li]' . implode('[/li][li]', $stats) . '[/li][/ul]'; } /****************/ /* Main Content */ /****************/ // get spawns and path $map = null; if ($spawns = $this->subject->getSpawns(SPAWNINFO_FULL)) { $map = ['data' => ['parent' => 'mapper-generic'], 'mapperData' => &$spawns]; foreach ($spawns as $areaId => &$areaData) { $map['extra'][$areaId] = ZoneList::getName($areaId); } } // consider pooled spawns $this->map = $map; $this->infobox = '[ul][li]' . implode('[/li][li]', $infobox) . '[/li][/ul]'; $this->placeholder = $placeholder; $this->accessory = $accessory; $this->quotes = $this->getQuotes(); $this->reputation = $this->getOnKillRep($_altIds, $mapType); $this->redButtons = array(BUTTON_WOWHEAD => true, BUTTON_LINKS => true, BUTTON_VIEW3D => ['type' => TYPE_NPC, 'typeId' => $this->typeId, 'displayId' => $this->subject->getRandomModelId()]); /**************/ /* Extra Tabs */ /**************/ // tab: SAI // hmm, how should this look like // tab: abilities / tab_controlledabilities (dep: VehicleId) // SMART_SCRIPT_TYPE_CREATURE = 0; SMART_ACTION_CAST = 11; SMART_ACTION_ADD_AURA = 75; SMART_ACTION_INVOKER_CAST = 85; SMART_ACTION_CROSS_CAST = 86 $smartSpells = DB::World()->selectCol('SELECT action_param1 FROM smart_scripts WHERE source_type = 0 AND action_type IN (11, 75, 85, 86) AND entryOrGUID = ?d', $this->typeId); $tplSpells = []; $conditions = ['OR']; for ($i = 1; $i < 9; $i++) { if ($_ = $this->subject->getField('spell' . $i)) { $tplSpells[] = $_; } } if ($tplSpells) { $conditions[] = ['id', $tplSpells]; } if ($smartSpells) { $conditions[] = ['id', $smartSpells]; } // Pet-Abilities if ($_typeFlags & 0x1 && ($_ = $this->subject->getField('family'))) { $skill = 0; $mask = 0x0; foreach (Util::$skillLineMask[-1] as $idx => $pair) { if ($pair[0] != $_) { continue; } $skill = $pair[1]; $mask = 1 << $idx; break; } $conditions[] = ['AND', ['s.typeCat', -3], ['OR', ['skillLine1', $skill], ['AND', ['skillLine1', 0, '>'], ['skillLine2OrMask', $skill]], ['AND', ['skillLine1', -1], ['skillLine2OrMask', $mask, '&']]]]; } if (count($conditions) > 1) { $abilities = new SpellList($conditions); if (!$abilities->error) { $this->extendGlobalData($abilities->getJSGlobals(GLOBALINFO_SELF | GLOBALINFO_RELATED)); $controled = $abilities->getListviewData(); $normal = []; foreach ($controled as $id => $values) { if (in_array($id, $smartSpells)) { $normal[$id] = $values; unset($controled[$id]); continue; } // not quite right. All seats should be checked for allowed-to-cast-flag-something if (!$this->subject->getField('vehicleId') && in_array($id, $tplSpells)) { $normal[$id] = $values; unset($controled[$id]); } } if ($normal) { $this->lvTabs[] = array('file' => 'spell', 'data' => $normal, 'params' => array('name' => '$LANG.tab_abilities', 'id' => 'abilities')); } if ($controled) { $this->lvTabs[] = array('file' => 'spell', 'data' => $controled, 'params' => array('name' => '$LANG.tab_controlledabilities', 'id' => 'controlled-abilities')); } } } // tab: summoned by $conditions = array('OR', ['AND', ['effect1Id', 28], ['effect1MiscValue', $this->typeId]], ['AND', ['effect2Id', 28], ['effect2MiscValue', $this->typeId]], ['AND', ['effect3Id', 28], ['effect3MiscValue', $this->typeId]]); $summoned = new SpellList($conditions); if (!$summoned->error) { $this->extendGlobalData($summoned->getJSGlobals()); $this->lvTabs[] = array('file' => 'spell', 'data' => $summoned->getListviewData(), 'params' => array('name' => '$LANG.tab_summonedby', 'id' => 'summoned-by')); } // tab: teaches if ($this->subject->getField('npcflag') & NPC_FLAG_TRAINER) { $teachQuery = ' SELECT IFNULL(t2.SpellID, t1.SpellID) AS ARRAY_KEY, IFNULL(t2.MoneyCost, t1.MoneyCost) AS cost, IFNULL(t2.ReqSkillLine, t1.ReqSkillLine) AS reqSkillId, IFNULL(t2.ReqSkillRank, t1.ReqSkillRank) AS reqSkillValue, IFNULL(t2.ReqLevel, t1.ReqLevel) AS reqLevel FROM npc_trainer t1 LEFT JOIN npc_trainer t2 ON t2.ID = IF(t1.SpellID < 0, -t1.SpellID, null) WHERE t1.ID = ?d '; if ($tSpells = DB::World()->select($teachQuery, $this->typeId)) { $teaches = new SpellList(array(['id', array_keys($tSpells)])); if (!$teaches->error) { $this->extendGlobalData($teaches->getJSGlobals(GLOBALINFO_SELF | GLOBALINFO_RELATED)); $data = $teaches->getListviewData(); $extra = []; foreach ($tSpells as $sId => $train) { if (empty($data[$sId])) { continue; } if ($_ = $train['reqSkillId']) { $this->extendGlobalIds(TYPE_SKILL, $_); if (!isset($extra[0])) { $extra[0] = 'Listview.extraCols.condition'; } $data[$sId]['condition'][0][$this->typeId][] = [[CND_SKILL, $_, $train['reqSkillValue']]]; } if ($_ = $train['reqLevel']) { if (!isset($extra[1])) { $extra[1] = "Listview.funcBox.createSimpleCol('reqLevel', LANG.tooltip_reqlevel, '7%', 'reqLevel')"; } $data[$sId]['reqLevel'] = $_; } if ($_ = $train['cost']) { $data[$sId]['trainingcost'] = $_; } } $this->lvTabs[] = array('file' => 'spell', 'data' => $data, 'params' => array('name' => '$LANG.tab_teaches', 'id' => 'teaches', 'visibleCols' => "\$['trainingcost']", 'extraCols' => $extra ? '$[' . implode(', ', $extra) . ']' : null)); } } else { trigger_error('NPC ' . $this->typeId . ' is flagged as trainer, but doesn\'t have any spells set', E_USER_WARNING); } } // tab: sells if ($sells = DB::World()->selectCol('SELECT item FROM npc_vendor nv WHERE entry = ?d UNION SELECT item FROM game_event_npc_vendor genv JOIN creature c ON genv.guid = c.guid WHERE c.id = ?d', $this->typeId, $this->typeId)) { $soldItems = new ItemList(array(['id', $sells])); if (!$soldItems->error) { $extraCols = ["Listview.funcBox.createSimpleCol('stack', 'stack', '10%', 'stack')", 'Listview.extraCols.cost']; if ($soldItems->hasSetFields(['condition'])) { $extraCols[] = 'Listview.extraCols.condition'; } $lvData = $soldItems->getListviewData(ITEMINFO_VENDOR, [TYPE_NPC => [$this->typeId]]); $sc = Util::getServerConditions(CND_SRC_NPC_VENDOR, $this->typeId); if (!empty($sc[0])) { $this->extendGlobalData($sc[1]); if (!array_search('Listview.extraCols.condition', $extraCols)) { $extraCols[] = 'Listview.extraCols.condition'; } foreach ($lvData as $id => &$row) { foreach ($sc[0] as $srcType => $cndData) { if (!empty($cndData[$id . ':' . $this->typeId])) { $row['condition'][0][$id . ':' . $this->typeId] = $cndData[$id . ':' . $this->typeId]; } } } } $this->lvTabs[] = array('file' => 'item', 'data' => $lvData, 'params' => array('name' => '$LANG.tab_sells', 'id' => 'currency-for', 'extraCols' => '$[' . implode(', ', $extraCols) . ']')); $this->extendGlobalData($soldItems->getJSGlobals(GLOBALINFO_SELF | GLOBALINFO_RELATED)); } } // tabs: this creature contains.. $skinTab = ['tab_skinning', 'skinning']; if ($_typeFlags & NPC_TYPEFLAG_HERBLOOT) { $skinTab = ['tab_herbalism', 'herbalism']; } else { if ($_typeFlags & NPC_TYPEFLAG_MININGLOOT) { $skinTab = ['tab_mining', 'mining']; } else { if ($_typeFlags & NPC_TYPEFLAG_ENGINEERLOOT) { $skinTab = ['tab_engineering', 'engineering']; } } } /* extraCols: [Listview.extraCols.count, Listview.extraCols.percent, Listview.extraCols.mode], _totalCount: 22531, computeDataFunc: Listview.funcBox.initLootTable, onAfterCreate: Listview.funcBox.addModeIndicator, modes:{"mode":1,"1":{"count":4408,"outof":16013},"4":{"count":4408,"outof":22531}} */ $sourceFor = array([LOOT_CREATURE, $this->subject->getField('lootId'), '$LANG.tab_drops', 'drops', []], [LOOT_PICKPOCKET, $this->subject->getField('pickpocketLootId'), '$LANG.tab_pickpocketing', 'pickpocketing', ['side', 'slot', 'reqlevel']], [LOOT_SKINNING, $this->subject->getField('skinLootId'), '$LANG.' . $skinTab[0], $skinTab[1], ['side', 'slot', 'reqlevel']]); // temp: manually add loot for difficulty-versions $langref = array("-2" => '$LANG.tab_heroic', "-1" => '$LANG.tab_normal', 1 => '$$WH.sprintf(LANG.tab_normalX, 10)', 2 => '$$WH.sprintf(LANG.tab_normalX, 25)', 3 => '$$WH.sprintf(LANG.tab_heroicX, 10)', 4 => '$$WH.sprintf(LANG.tab_heroicX, 25)'); if ($_altIds) { $sourceFor[0][2] = $mapType == 1 ? $langref[-1] : $langref[1]; foreach ($_altNPCs->iterate() as $id => $__) { $mode = ($_altIds[$id] + 1) * ($mapType == 1 ? -1 : 1); if ($lootGO = DB::Aowow()->selectRow('SELECT o.id, o.lootId, o.name_loc0, o.name_loc2, o.name_loc3, o.name_loc6, o.name_loc8 FROM ?_loot_link l JOIN ?_objects o ON o.id = l.objectId WHERE l.npcId = ?d', $id)) { array_splice($sourceFor, 1, 0, [[LOOT_GAMEOBJECT, $lootGO['lootId'], $langref[$mode], 'drops-object-' . abs($mode), [], 'note' => '$$WH.sprintf(LANG.lvnote_npcobjectsource, ' . $lootGO['id'] . ', \'' . Util::jsEscape(Util::localizedString($lootGO, 'name')) . '\')']]); } if ($lootId = $_altNPCs->getField('lootId')) { array_splice($sourceFor, 1, 0, [[LOOT_CREATURE, $lootId, $langref[$mode], 'drops-' . abs($mode), []]]); } } } if ($lootGOs = DB::Aowow()->select('SELECT o.id, IF(npcId < 0, 1, 0) AS modeDummy, o.lootId, o.name_loc0, o.name_loc2, o.name_loc3, o.name_loc6, o.name_loc8 FROM ?_loot_link l JOIN ?_objects o ON o.id = l.objectId WHERE ABS(l.npcId) = ?d', $this->typeId)) { foreach ($lootGOs as $idx => $lgo) { array_splice($sourceFor, 1, 0, [[LOOT_GAMEOBJECT, $lgo['lootId'], $mapType ? $langref[($mapType == 1 ? -1 : 1) + ($lgo['modeDummy'] ? 1 : 0)] : '$LANG.tab_drops', 'drops-object-' . $idx, [], 'note' => '$$WH.sprintf(LANG.lvnote_npcobjectsource, ' . $lgo['id'] . ', \'' . Util::jsEscape(Util::localizedString($lgo, 'name')) . '\')']]); } } $reqQuest = []; foreach ($sourceFor as $sf) { $creatureLoot = new Loot(); if ($creatureLoot->getByContainer($sf[0], $sf[1])) { $extraCols = $creatureLoot->extraCols; $extraCols[] = 'Listview.extraCols.percent'; $this->extendGlobalData($creatureLoot->jsGlobals); foreach ($creatureLoot->iterate() as &$lv) { if (!$lv['quest']) { continue; } $extraCols[] = 'Listview.extraCols.condition'; $reqQuest[$lv['id']] = 0; $lv['condition'][0][$this->typeId][] = [[CND_QUESTTAKEN, &$reqQuest[$lv['id']]]]; } $lootTab = array('file' => 'item', 'data' => $creatureLoot->getResult(), 'params' => array('name' => $sf[2], 'id' => $sf[3], 'extraCols' => "\$[" . implode(', ', array_unique($extraCols)) . "]", 'hiddenCols' => $sf[4] ? "\$" . Util::toJSON($sf[4]) : null, 'sort' => "\$['-percent', 'name']")); if (!empty($sf['note'])) { $lootTab['params']['note'] = $sf['note']; } $this->lvTabs[] = $lootTab; } } if ($reqIds = array_keys($reqQuest)) { $conditions = array('OR', ['reqSourceItemId1', $reqIds], ['reqSourceItemId2', $reqIds], ['reqSourceItemId3', $reqIds], ['reqSourceItemId4', $reqIds], ['reqItemId1', $reqIds], ['reqItemId2', $reqIds], ['reqItemId3', $reqIds], ['reqItemId4', $reqIds], ['reqItemId5', $reqIds], ['reqItemId6', $reqIds]); $reqQuests = new QuestList($conditions); $this->extendGlobalData($reqQuests->getJSGlobals()); foreach ($reqQuests->iterate() as $qId => $__) { if (empty($reqQuests->requires[$qId][TYPE_ITEM])) { continue; } foreach ($reqIds as $rId) { if (in_array($rId, $reqQuests->requires[$qId][TYPE_ITEM])) { $reqQuest[$rId] = $reqQuests->id; } } } } // tab: starts quest // tab: ends quest $startEnd = new QuestList(array(['qse.type', TYPE_NPC], ['qse.typeId', $this->typeId])); if (!$startEnd->error) { $this->extendGlobalData($startEnd->getJSGlobals()); $lvData = $startEnd->getListviewData(); $_ = [[], []]; foreach ($startEnd->iterate() as $id => $__) { $m = $startEnd->getField('method'); if ($m & 0x1) { $_[0][] = $lvData[$id]; } if ($m & 0x2) { $_[1][] = $lvData[$id]; } } if ($_[0]) { $this->lvTabs[] = array('file' => 'quest', 'data' => $_[0], 'params' => array('name' => '$LANG.tab_starts', 'id' => 'starts')); } if ($_[1]) { $this->lvTabs[] = array('file' => 'quest', 'data' => $_[1], 'params' => array('name' => '$LANG.tab_ends', 'id' => 'ends')); } } // tab: objective of quest $conditions = array('OR', ['AND', ['reqNpcOrGo1', $this->typeId], ['reqNpcOrGoCount1', 0, '>']], ['AND', ['reqNpcOrGo2', $this->typeId], ['reqNpcOrGoCount2', 0, '>']], ['AND', ['reqNpcOrGo3', $this->typeId], ['reqNpcOrGoCount3', 0, '>']], ['AND', ['reqNpcOrGo4', $this->typeId], ['reqNpcOrGoCount4', 0, '>']]); $objectiveOf = new QuestList($conditions); if (!$objectiveOf->error) { $this->extendGlobalData($objectiveOf->getJSGlobals()); $this->lvTabs[] = array('file' => 'quest', 'data' => $objectiveOf->getListviewData(), 'params' => array('name' => '$LANG.tab_objectiveof', 'id' => 'objective-of')); } // tab: criteria of [ACHIEVEMENT_CRITERIA_TYPE_KILL_CREATURE_TYPE have no data set to check for] $conditions = array(['ac.type', [ACHIEVEMENT_CRITERIA_TYPE_KILL_CREATURE, ACHIEVEMENT_CRITERIA_TYPE_KILLED_BY_CREATURE]], ['ac.value1', $this->typeId]); $crtOf = new AchievementList($conditions); if (!$crtOf->error) { $this->extendGlobalData($crtOf->getJSGlobals()); $this->lvTabs[] = array('file' => 'achievement', 'data' => $crtOf->getListviewData(), 'params' => array('name' => '$LANG.tab_criteriaof', 'id' => 'criteria-of')); } // tab: passengers if ($_ = DB::World()->selectCol('SELECT accessory_entry AS ARRAY_KEY, GROUP_CONCAT(seat_id) FROM vehicle_template_accessory WHERE entry = ?d GROUP BY accessory_entry', $this->typeId)) { $passengers = new CreatureList(array(['id', array_keys($_)])); if (!$passengers->error) { $data = $passengers->getListviewData(); $xCols = null; if (User::isInGroup(U_GROUP_STAFF)) { foreach ($data as $id => &$d) { $d['seat'] = str_replace(',', ', ', $_[$id]); } $xCols = "\$[Listview.funcBox.createSimpleCol('seat', '" . Lang::npc('seat') . "', '10%', 'seat')]"; } $this->extendGlobalData($passengers->getJSGlobals(GLOBALINFO_SELF)); $this->lvTabs[] = array('file' => 'creature', 'data' => $data, 'params' => array('extraCols' => $xCols, 'name' => Lang::npc('accessory'), 'id' => 'accessory')); } } }
protected function generateContent() { $this->addJS('?data=zones&locale=' . User::$localeId . '&t=' . $_SESSION['dataKey']); $infobox = Lang::getInfoBoxForFlags($this->subject->getField('cuFlags')); $_mask = 1 << $this->typeId - 1; $tcClassId = [null, 8, 3, 1, 5, 4, 9, 6, 2, 7, null, 0]; // see TalentCalc.js /***********/ /* Infobox */ /***********/ // hero class if ($this->subject->getField('flags') & 0x40) { $infobox[] = '[tooltip=tooltip_heroclass]' . Lang::game('heroClass') . '[/tooltip]'; } // resource if ($this->typeId == 11) { // special Druid case $infobox[] = Lang::game('resources') . Lang::main('colon') . '[tooltip name=powertype1]' . Lang::game('st', 0) . ', ' . Lang::game('st', 31) . ', ' . Lang::game('st', 2) . '[/tooltip][span class=tip tooltip=powertype1]' . Util::ucFirst(Lang::spell('powerTypes', 0)) . '[/span], ' . '[tooltip name=powertype2]' . Lang::game('st', 5) . ', ' . Lang::game('st', 8) . '[/tooltip][span class=tip tooltip=powertype2]' . Util::ucFirst(Lang::spell('powerTypes', 1)) . '[/span], ' . '[tooltip name=powertype8]' . Lang::game('st', 1) . '[/tooltip][span class=tip tooltip=powertype8]' . Util::ucFirst(Lang::spell('powerTypes', 3)) . '[/span]'; } else { if ($this->typeId == 6) { // special DK case $infobox[] = Lang::game('resources') . Lang::main('colon') . '[span]' . Util::ucFirst(Lang::spell('powerTypes', 5)) . ', ' . Util::ucFirst(Lang::spell('powerTypes', $this->subject->getField('powerType'))) . '[/span]'; } else { // regular case $infobox[] = Lang::game('resource') . Lang::main('colon') . '[span]' . Util::ucFirst(Lang::spell('powerTypes', $this->subject->getField('powerType'))) . '[/span]'; } } // roles $roles = []; for ($i = 0; $i < 4; $i++) { if ($this->subject->getField('roles') & 1 << $i) { $roles[] = (count($roles) == 2 ? "\n" : '') . Lang::game('_roles', $i); } } if ($roles) { $infobox[] = (count($roles) > 1 ? Lang::game('roles') : Lang::game('role')) . Lang::main('colon') . implode(', ', $roles); } // specs $specList = []; $skills = new SkillList(array(['id', $this->subject->getField('skills')])); foreach ($skills->iterate() as $k => $__) { $specList[$k] = '[icon name=' . $skills->getField('iconString') . '][url=?spells=7.' . $this->typeId . '.' . $k . ']' . $skills->getField('name', true) . '[/url][/icon]'; } if ($specList) { $infobox[] = Lang::game('specs') . Lang::main('colon') . '[ul][li]' . implode('[/li][li]', $specList) . '[/li][/ul]'; } /****************/ /* Main Content */ /****************/ $this->infobox = '[ul][li]' . implode('[/li][li]', $infobox) . '[/li][/ul]'; $this->expansion = Util::$expansionString[$this->subject->getField('expansion')]; $this->headIcons = ['class_' . strtolower($this->subject->getField('fileString'))]; $this->redButtons = array(BUTTON_LINKS => ['color' => '', 'linkId' => ''], BUTTON_WOWHEAD => true, BUTTON_TALENT => ['href' => '?talent#' . Util::$tcEncoding[$tcClassId[$this->typeId] * 3], 'pet' => false], BUTTON_FORUM => false); /**************/ /* Extra Tabs */ /**************/ // Tab: Spells (grouped) // '$LANG.tab_armorproficiencies', // '$LANG.tab_weaponskills', // '$LANG.tab_glyphs', // '$LANG.tab_abilities', // '$LANG.tab_talents', $conditions = array(['s.typeCat', [-13, -11, -2, 7]], [['s.cuFlags', SPELL_CU_TRIGGERED | CUSTOM_EXCLUDE_FOR_LISTVIEW, '&'], 0], ['OR', ['s.reqClassMask', $_mask, '&'], ['s.skillLine1', $this->subject->getField('skills')], ['AND', ['s.skillLine1', 0, '>'], ['s.skillLine2OrMask', $this->subject->getField('skills')]]], ['OR', ['s.cuFlags', SPELL_CU_LAST_RANK, '&'], ['s.rankNo', 0]]); $genSpells = new SpellList($conditions); if (!$genSpells->error) { $this->extendGlobalData($genSpells->getJSGlobals(GLOBALINFO_SELF)); $this->lvTabs[] = array('file' => 'spell', 'data' => $genSpells->getListviewData(), 'params' => array('id' => 'spells', 'name' => '$LANG.tab_spells', 'visibleCols' => "\$['level', 'schools', 'type', 'classes']", 'hiddenCols' => "\$['reagents', 'skill']", 'sort' => "\$['-level', 'type', 'name']", 'computeDataFunc' => '$Listview.funcBox.initSpellFilter', 'onAfterCreate' => '$Listview.funcBox.addSpellIndicator')); } // Tab: Items (grouped) $conditions = array(['requiredClass', 0, '>'], ['requiredClass', $_mask, '&'], [['requiredClass', CLASS_MASK_ALL, '&'], CLASS_MASK_ALL, '!'], ['itemset', 0], 0); $items = new ItemList($conditions); if (!$items->error) { $this->extendGlobalData($items->getJSGlobals()); if (!$items->hasDiffFields(['requiredRace'])) { $hidden = "\$['side']"; } $this->lvTabs[] = array('file' => 'item', 'data' => $items->getListviewData(), 'params' => array('id' => 'items', 'name' => '$LANG.tab_items', 'visibleCols' => "\$['dps', 'armor', 'slot']", 'hiddenCols' => isset($hidden) ? $hidden : null, 'computeDataFunc' => '$Listview.funcBox.initSubclassFilter', 'onAfterCreate' => '$Listview.funcBox.addSubclassIndicator', 'note' => sprintf(Util::$filterResultString, '?items&filter=cr=152;crs=' . $this->typeId . ';crv=0'), '_truncated' => 1)); } // Tab: Quests $conditions = array(['reqClassMask', $_mask, '&'], [['reqClassMask', CLASS_MASK_ALL, '&'], CLASS_MASK_ALL, '!']); $quests = new QuestList($conditions); if (!$quests->error) { $this->extendGlobalData($quests->getJSGlobals()); $this->lvTabs[] = array('file' => 'quest', 'data' => $quests->getListviewData(), 'params' => ['sort' => "\$['reqlevel', 'name']"]); } // Tab: Itemsets $sets = new ItemsetList(array(['classMask', $_mask, '&'])); if (!$sets->error) { $this->extendGlobalData($sets->getJSGlobals(GLOBALINFO_SELF)); $this->lvTabs[] = array('file' => 'itemset', 'data' => $sets->getListviewData(), 'params' => array('note' => sprintf(Util::$filterResultString, '?itemsets&filter=cl=' . $this->typeId), 'hiddenCols' => "\$['classes']", 'sort' => "\$['-level', 'name']")); } // Tab: Trainer $conditions = array(['npcflag', 0x30, '&'], ['trainerType', 0], ['trainerClass', $this->typeId]); $trainer = new CreatureList($conditions); if (!$trainer->error) { $this->lvTabs[] = array('file' => 'creature', 'data' => $trainer->getListviewData(), 'params' => array('id' => 'trainers', 'name' => '$LANG.tab_trainers')); } // Tab: Races $races = new CharRaceList(array(['classMask', $_mask, '&'])); if (!$races->error) { $this->lvTabs[] = array('file' => 'race', 'data' => $races->getListviewData(), 'params' => []); } }
protected function generateContent() { $this->addJS('?data=zones&locale=' . User::$localeId . '&t=' . $_SESSION['dataKey']); /***********/ /* Infobox */ /***********/ $this->infobox = Lang::getInfoBoxForFlags($this->subject->getField('cuFlags')); // boss if ($_ = $this->subject->getField('bossCreature')) { $this->extendGlobalIds(TYPE_NPC, $_); $this->infobox[] = Lang::npc('rank', 3) . Lang::main('colon') . '[npc=' . $_ . ']'; } // display internal id to staff if (User::isInGroup(U_GROUP_STAFF)) { $this->infobox[] = 'Event-Id' . Lang::main('colon') . $this->eId; } /****************/ /* Main Content */ /****************/ // no entry in ?_articles? use default HolidayDescription if ($this->hId && empty($this->article)) { $this->article = ['text' => Util::jsEscape($this->subject->getField('description', true)), 'params' => []]; } $this->headIcons = [$this->subject->getField('iconString')]; $this->redButtons = array(BUTTON_WOWHEAD => $this->hId > 0, BUTTON_LINKS => true); /**************/ /* Extra Tabs */ /**************/ $hasFilter = in_array($this->hId, [372, 283, 285, 353, 420, 400, 284, 201, 374, 409, 141, 324, 321, 424, 335, 327, 341, 181, 404, 398, 301]); // tab: npcs if ($npcIds = DB::World()->selectCol('SELECT id AS ARRAY_KEY, IF(ec.eventEntry > 0, 1, 0) AS added FROM creature c, game_event_creature ec WHERE ec.guid = c.guid AND ABS(ec.eventEntry) = ?d', $this->eId)) { $creatures = new CreatureList(array(['id', array_keys($npcIds)])); if (!$creatures->error) { $data = $creatures->getListviewData(); foreach ($data as &$d) { $d['method'] = $npcIds[$d['id']]; } $tabData = ['data' => array_values($data)]; if ($hasFilter) { $tabData['note'] = sprintf(Util::$filterResultString, '?npcs&filter=cr=38;crs=' . $this->hId . ';crv=0'); } $this->lvTabs[] = ['creature', $tabData]; } } // tab: objects if ($objectIds = DB::World()->selectCol('SELECT id AS ARRAY_KEY, IF(eg.eventEntry > 0, 1, 0) AS added FROM gameobject g, game_event_gameobject eg WHERE eg.guid = g.guid AND ABS(eg.eventEntry) = ?d', $this->eId)) { $objects = new GameObjectList(array(['id', array_keys($objectIds)])); if (!$objects->error) { $data = $objects->getListviewData(); foreach ($data as &$d) { $d['method'] = $objectIds[$d['id']]; } $tabData = ['data' => array_values($data)]; if ($hasFilter) { $tabData['note'] = sprintf(Util::$filterResultString, '?objects&filter=cr=16;crs=' . $this->hId . ';crv=0'); } $this->lvTabs[] = ['object', $tabData]; } } // tab: achievements if ($_ = $this->subject->getField('achievementCatOrId')) { $condition = $_ > 0 ? [['category', $_]] : [['id', -$_]]; $acvs = new AchievementList($condition); if (!$acvs->error) { $this->extendGlobalData($acvs->getJSGlobals(GLOBALINFO_SELF | GLOBALINFO_RELATED)); $tabData = array('data' => array_values($acvs->getListviewData()), 'visibleCols' => ['category']); if ($hasFilter) { $tabData['note'] = sprintf(Util::$filterResultString, '?achievements&filter=cr=11;crs=' . $this->hId . ';crv=0'); } $this->lvTabs[] = ['achievement', $tabData]; } } $itemCnd = []; if ($this->hId) { $itemCnd = array('OR', ['eventId', $this->eId]); // tab: quests (by table, go & creature) $quests = new QuestList(array(['eventId', $this->eId])); if (!$quests->error) { $this->extendGlobalData($quests->getJSGlobals(GLOBALINFO_SELF | GLOBALINFO_REWARDS)); $tabData = ['data' => array_values($quests->getListviewData())]; if ($hasFilter) { $tabData['note'] = sprintf(Util::$filterResultString, '?quests&filter=cr=33;crs=' . $this->hId . ';crv=0'); } $this->lvTabs[] = ['quest', $tabData]; $questItems = []; foreach (array_column($quests->rewards, TYPE_ITEM) as $arr) { $questItems = array_merge($questItems, $arr); } foreach (array_column($quests->requires, TYPE_ITEM) as $arr) { $questItems = array_merge($questItems, $arr); } if ($questItems) { $itemCnd[] = ['id', $questItems]; } } } // items from creature if ($npcIds && !$creatures->error) { // vendor $cIds = $creatures->getFoundIDs(); if ($sells = DB::World()->selectCol('SELECT item FROM npc_vendor nv WHERE entry IN (?a) UNION SELECT item FROM game_event_npc_vendor genv JOIN creature c ON genv.guid = c.guid WHERE c.id IN (?a)', $cIds, $cIds)) { $itemCnd[] = ['id', $sells]; } } // tab: items // not checking for loot ... cant distinguish between eventLoot and fillerCrapLoot if ($itemCnd) { $eventItems = new ItemList($itemCnd); if (!$eventItems->error) { $this->extendGlobalData($eventItems->getJSGlobals(GLOBALINFO_SELF)); $tabData = ['data' => array_values($eventItems->getListviewData())]; if ($hasFilter) { $tabData['note'] = sprintf(Util::$filterResultString, '?items&filter=cr=160;crs=' . $this->hId . ';crv=0'); } $this->lvTabs[] = ['item', $tabData]; } } // tab: see also (event conditions) if ($rel = DB::World()->selectCol('SELECT IF(eventEntry = prerequisite_event, NULL, IF(eventEntry = ?d, prerequisite_event, -eventEntry)) FROM game_event_prerequisite WHERE prerequisite_event = ?d OR eventEntry = ?d', $this->eId, $this->eId, $this->eId)) { $list = []; array_walk($rel, function ($v, $k) use(&$list) { if ($v > 0) { $list[] = $v; } else { if ($v === null) { trigger_error('game_event_prerequisite: this event has itself as prerequisite', E_USER_WARNING); } } }); if ($list) { $relEvents = new WorldEventList(array(['id', $list])); $this->extendGlobalData($relEvents->getJSGlobals()); $relData = $relEvents->getListviewData(); foreach ($relEvents->getFoundIDs() as $id) { $relData[$id]['condition'][0][$this->typeId][] = [[-CND_ACTIVE_EVENT, $this->eId]]; } $this->extendGlobalData($this->subject->getJSGlobals()); foreach ($rel as $r) { if ($r <= 0) { continue; } $this->extendGlobalIds(TYPE_WORLDEVENT, $r); $d = $this->subject->getListviewData(); $d[$this->eId]['condition'][0][$this->typeId][] = [[-CND_ACTIVE_EVENT, $r]]; $relData = array_merge($relData, $d); } $this->lvTabs[] = ['event', array('data' => array_values($relData), 'id' => 'see-also', 'name' => '$LANG.tab_seealso', 'hiddenCols' => ['date'], 'extraCols' => ['$Listview.extraCols.condition'])]; } } }
public function getByContainer($table, $entry) { $this->entry = intVal($entry); if (!in_array($table, $this->lootTemplates) || !$this->entry) { return null; } /* todo (high): implement conditions on loot (and conditions in general) also // if (is_array($this->entry) && in_array($table, [LOOT_CREATURE, LOOT_GAMEOBJECT]) // iterate over the 4 available difficulties and assign modes modes:{"mode":1,"1":{"count":4408,"outof":16013},"4":{"count":4408,"outof":22531}} */ $handledRefs = []; $struct = self::getByContainerRecursive($table, $this->entry, $handledRefs); if (!$struct) { return false; } $items = new ItemList(array(['i.id', $struct[1]], CFG_SQL_LIMIT_NONE)); $this->jsGlobals = $items->getJSGlobals(GLOBALINFO_SELF | GLOBALINFO_RELATED); $foo = $items->getListviewData(); // assign listview LV rows to loot rows, not the other way round! The same item may be contained multiple times foreach ($struct[0] as $loot) { $base = array('percent' => round($loot['groupChance'] * $loot['realChanceMod'], 3), 'group' => $loot['group'], 'quest' => $loot['quest'], 'count' => 1); if ($_ = $loot['mode']) { $base['mode'] = $_; } if ($_ = $loot['parentRef']) { $base['reference'] = $_; } if ($_ = self::createStack($loot)) { $base['pctstack'] = $_; } if (empty($loot['reference'])) { if (!User::isInGroup(U_GROUP_EMPLOYEE)) { if (!isset($this->results[$loot['content']])) { $this->results[$loot['content']] = array_merge($foo[$loot['content']], $base, ['stack' => [$loot['min'], $loot['max']]]); } else { $this->results[$loot['content']]['percent'] += $base['percent']; } } else { // in case of limited trash loot, check if $foo[<itemId>] exists $this->results[] = array_merge($foo[$loot['content']], $base, ['stack' => [$loot['min'], $loot['max']]]); } } else { if (User::isInGroup(U_GROUP_EMPLOYEE)) { $data = array('id' => $loot['reference'], 'name' => '@REFERENCE: ' . $loot['reference'], 'icon' => 'trade_engineering', 'stack' => [$loot['multiplier'], $loot['multiplier']]); $this->results[] = array_merge($base, $data); $this->jsGlobals[TYPE_ITEM][$loot['reference']] = $data; } } } // move excessive % to extra loot if (!User::isInGroup(U_GROUP_EMPLOYEE)) { foreach ($this->results as &$_) { if ($_['percent'] <= 100) { continue; } while ($_['percent'] > 200) { $_['stack'][0]++; $_['stack'][1]++; $_['percent'] -= 100; } $_['stack'][1]++; $_['percent'] = 100; } } else { $fields = ['mode', 'reference']; $base = []; $set = 0; foreach ($this->results as $foo) { foreach ($fields as $idx => $field) { $val = isset($foo[$field]) ? $foo[$field] : 0; if (!isset($base[$idx])) { $base[$idx] = $val; } else { if ($base[$idx] != $val) { $set |= 1 << $idx; } } } if ($set == pow(2, count($fields)) - 1) { break; } } $this->extraCols[] = "Listview.funcBox.createSimpleCol('group', 'Group', '7%', 'group')"; foreach ($fields as $idx => $field) { if ($set & 1 << $idx) { $this->extraCols[] = "Listview.funcBox.createSimpleCol('" . $field . "', '" . Util::ucFirst($field) . "', '7%', '" . $field . "')"; } } } return true; }
protected function generateContent() { $this->addJS('?data=zones&locale=' . User::$localeId . '&t=' . $_SESSION['dataKey']); /***********/ /* Infobox */ /***********/ $infobox = Lang::getInfoBoxForFlags($this->subject->getField('cuFlags')); // level range $infobox[] = Lang::game('level') . Lang::main('colon') . $this->subject->getField('minLevel') . ' - ' . $this->subject->getField('maxLevel'); // exotic if ($this->subject->getField('exotic')) { $infobox[] = '[url=?spell=53270]' . Lang::pet('exotic') . '[/url]'; } /****************/ /* Main Content */ /****************/ $this->infobox = '[ul][li]' . implode('[/li][li]', $infobox) . '[/li][/ul]'; $this->headIcons = [$this->subject->getField('iconString')]; $this->expansion = Util::$expansionString[$this->subject->getField('expansion')]; $this->redButtons = array(BUTTON_WOWHEAD => true, BUTTON_LINKS => true, BUTTON_TALENT => ['href' => '?petcalc#' . Util::$tcEncoding[(int) ($this->typeId / 10)] . Util::$tcEncoding[2 * ($this->typeId % 10) + ($this->subject->getField('exotic') ? 1 : 0)], 'pet' => true]); /**************/ /* Extra Tabs */ /**************/ // tab: tameable & gallery $condition = array(['ct.type', 1], ['ct.typeFlags', 0x1, '&'], ['ct.family', $this->typeId], ['OR', ['ft.A', 1, '<'], ['ft.H', 1, '<']]); $tng = new CreatureList($condition); $this->lvTabs[] = array('file' => 'creature', 'data' => $tng->getListviewData(NPCINFO_TAMEABLE), 'params' => array('name' => '$LANG.tab_tameable', 'hiddenCols' => "\$['type']", 'visibleCols' => "\$['skin']", 'note' => sprintf(Util::$filterResultString, '?npcs=1&filter=fa=38'), 'id' => 'tameable')); $this->lvTabs[] = array('file' => 'model', 'data' => $tng->getListviewData(NPCINFO_MODEL), 'params' => []); // tab: diet $list = []; $mask = $this->subject->getField('foodMask'); for ($i = 1; $i < 7; $i++) { if ($mask & 1 << $i - 1) { $list[] = $i; } } $food = new ItemList(array(['i.subClass', [5, 8]], ['i.FoodType', $list], CFG_SQL_LIMIT_NONE)); $this->extendGlobalData($food->getJSGlobals()); $this->lvTabs[] = array('file' => 'item', 'data' => $food->getListviewData(), 'params' => array('name' => '$LANG.diet', 'hiddenCols' => "\$['source', 'slot', 'side']", 'sort' => "\$['level']", 'id' => 'diet')); // tab: spells $mask = 0x0; foreach (Util::$skillLineMask[-1] as $idx => $pair) { if ($pair[0] == $this->typeId) { $mask = 1 << $idx; break; } } $conditions = [['s.typeCat', -3], ['OR', ['skillLine1', $this->subject->getField('skillLineId')], ['AND', ['skillLine1', 0, '>'], ['skillLine2OrMask', $this->subject->getField('skillLineId')]], ['AND', ['skillLine1', -1], ['skillLine2OrMask', $mask, '&']]]]; $spells = new SpellList($conditions); $this->extendGlobalData($spells->getJSGlobals(GLOBALINFO_SELF)); $this->lvTabs[] = array('file' => 'spell', 'data' => $spells->getListviewData(), 'params' => array('name' => '$LANG.tab_abilities', 'visibleCols' => "\$['schools', 'level']", 'id' => 'abilities')); // tab: talents $conditions = array(['s.typeCat', -7], ['OR', ['s.cuFlags', SPELL_CU_LAST_RANK, '&'], ['s.rankNo', 0]]); switch ($this->subject->getField('type')) { case 0: $conditions[] = ['s.cuFlags', SPELL_CU_PET_TALENT_TYPE0, '&']; break; case 1: $conditions[] = ['s.cuFlags', SPELL_CU_PET_TALENT_TYPE1, '&']; break; case 2: $conditions[] = ['s.cuFlags', SPELL_CU_PET_TALENT_TYPE2, '&']; break; } $talents = new SpellList($conditions); $this->extendGlobalData($talents->getJSGlobals(GLOBALINFO_SELF)); $this->lvTabs[] = array('file' => 'spell', 'data' => $talents->getListviewData(), 'params' => array('visibleCols' => "\$['tier', 'level']", 'name' => '$LANG.tab_talents', 'id' => 'talents', 'sort' => "\$['tier', 'name']", '_petTalents' => 1)); }
protected function generateContent() { $this->addJS('?data=weight-presets.zones&locale=' . User::$localeId . '&t=' . $_SESSION['dataKey']); $_flags = $this->subject->getField('flags'); $_slot = $this->subject->getField('slot'); $_class = $this->subject->getField('class'); $_subClass = $this->subject->getField('subClass'); $_bagFamily = $this->subject->getField('bagFamily'); $_model = $this->subject->getField('displayId'); $_visSlots = array(INVTYPE_HEAD, INVTYPE_SHOULDERS, INVTYPE_BODY, INVTYPE_CHEST, INVTYPE_WAIST, INVTYPE_LEGS, INVTYPE_FEET, INVTYPE_WRISTS, INVTYPE_HANDS, INVTYPE_WEAPON, INVTYPE_SHIELD, INVTYPE_RANGED, INVTYPE_CLOAK, INVTYPE_2HWEAPON, INVTYPE_TABARD, INVTYPE_ROBE, INVTYPE_WEAPONMAINHAND, INVTYPE_WEAPONOFFHAND, INVTYPE_HOLDABLE, INVTYPE_THROWN, INVTYPE_RANGEDRIGHT); /***********/ /* Infobox */ /***********/ $infobox = Lang::getInfoBoxForFlags($this->subject->getField('cuFlags')); // itemlevel if (in_array($_class, [ITEM_CLASS_ARMOR, ITEM_CLASS_WEAPON, ITEM_CLASS_AMMUNITION]) || $this->subject->getField('gemEnchantmentId')) { $infobox[] = Lang::game('level') . Lang::main('colon') . $this->subject->getField('itemLevel'); } // account-wide if ($_flags & ITEM_FLAG_ACCOUNTBOUND) { $infobox[] = Lang::item('accountWide'); } // side if ($si = $this->subject->json[$this->typeId]['side']) { if ($si != 3) { $infobox[] = Lang::main('side') . Lang::main('colon') . '[span class=icon-' . ($si == 1 ? 'alliance' : 'horde') . ']' . Lang::game('si', $si) . '[/span]'; } } // consumable / not consumable if (!$_slot) { $hasUse = false; for ($i = 1; $i < 6; $i++) { if ($this->subject->getField('spellId' . $i) <= 0 || in_array($this->subject->getField('spellTrigger' . $i), [1, 2])) { continue; } $hasUse = true; if ($this->subject->getField('spellCharges' . $i) >= 0) { continue; } $tt = '[tooltip=tooltip_consumedonuse]' . Lang::item('consumable') . '[/tooltip]'; break; } if ($hasUse) { $infobox[] = isset($tt) ? $tt : '[tooltip=tooltip_notconsumedonuse]' . Lang::item('nonConsumable') . '[/tooltip]'; } } // related holiday if ($hId = $this->subject->getField('holidayId')) { if ($hName = DB::Aowow()->selectRow('SELECT * FROM ?_holidays WHERE id = ?d', $hId)) { $infobox[] = Lang::game('eventShort') . Lang::main('colon') . '[url=?event=' . $hId . ']' . Util::localizedString($hName, 'name') . '[/url]'; } } // tool if ($tId = $this->subject->getField('totemCategory')) { if ($tName = DB::Aowow()->selectRow('SELECT * FROM ?_totemcategory WHERE id = ?d', $tId)) { $infobox[] = Lang::item('tool') . Lang::main('colon') . '[url=?items&filter=cr=91;crs=' . $tId . ';crv=0]' . Util::localizedString($tName, 'name') . '[/url]'; } } // extendedCost if (!empty($this->subject->getExtendedCost([], $_reqRating)[$this->subject->id])) { $vendors = $this->subject->getExtendedCost()[$this->subject->id]; $each = $this->subject->getField('stackable') > 1 ? '[color=q0] (' . Lang::item('each') . ')[/color]' : null; $handled = []; $costList = []; foreach ($vendors as $npcId => $data) { $tokens = []; $currency = []; if (!is_array($data)) { continue; } foreach ($data as $c => $qty) { if (is_string($c)) { unset($data[$c]); // unset miscData to prevent having two vendors /w the same cost being cached, because of different stock or rating-requirements continue; } if ($c < 0) { // currency items (and honor or arena) $currency[] = -$c . ',' . $qty; } else { if ($c > 0) { // plain items (item1,count1,item2,count2,...) $tokens[$c] = $c . ',' . $qty; } } } // display every cost-combination only once if (in_array(md5(serialize($data)), $handled)) { continue; } $handled[] = md5(serialize($data)); $cost = isset($data[0]) ? '[money=' . $data[0] : '[money'; if ($tokens) { $cost .= ' items=' . implode(',', $tokens); } if ($currency) { $cost .= ' currency=' . implode(',', $currency); } $cost .= ']'; $costList[] = $cost; } if (count($costList) == 1) { $infobox[] = Lang::item('cost') . Lang::main('colon') . $costList[0] . $each; } else { if (count($costList) > 1) { $infobox[] = Lang::item('cost') . $each . Lang::main('colon') . '[ul][li]' . implode('[/li][li]', $costList) . '[/li][/ul]'; } } if ($_reqRating) { $res = []; $i = 0; $len = 0; $parts = explode(' ', str_replace('<br>', ' ', sprintf(Lang::item('reqRating', $_reqRating[1]), $_reqRating[0]))); foreach ($parts as $p) { $res[$i][] = $p; $len += mb_strlen($p) + 1; if ($len < 30) { continue; } $len = 0; $i++; } foreach ($res as &$r) { $r = implode(' ', $r); } $infobox[] = implode('[br]', $res); } } // repair cost if ($_ = $this->subject->getField('repairPrice')) { $infobox[] = Lang::item('repairCost') . Lang::main('colon') . '[money=' . $_ . ']'; } // avg auction buyout if (in_array($this->subject->getField('bonding'), [0, 2, 3])) { if ($_ = Util::getBuyoutForItem($this->typeId)) { $infobox[] = '[tooltip=tooltip_buyoutprice]' . Lang::item('buyout.') . '[/tooltip]' . Lang::main('colon') . '[money=' . $_ . ']' . $each; } } // avg money contained if ($_flags & ITEM_FLAG_OPENABLE) { if ($_ = intVal(($this->subject->getField('minMoneyLoot') + $this->subject->getField('maxMoneyLoot')) / 2)) { $infobox[] = Lang::item('worth') . Lang::main('colon') . '[tooltip=tooltip_avgmoneycontained][money=' . $_ . '][/tooltip]'; } } // if it goes into a slot it may be disenchanted if ($_slot && $_class != ITEM_CLASS_CONTAINER) { if ($this->subject->getField('disenchantId')) { $_ = $this->subject->getField('requiredDisenchantSkill'); if ($_ < 1) { // these are some items, that never went live .. extremely rough emulation here $_ = intVal($this->subject->getField('itemLevel') / 7.5) * 25; } $infobox[] = Lang::item('disenchantable') . ' ([tooltip=tooltip_reqenchanting]' . $_ . '[/tooltip])'; } else { $infobox[] = Lang::item('cantDisenchant'); } } if ($_flags & ITEM_FLAG_MILLABLE && $this->subject->getField('requiredSkill') == 773) { $infobox[] = Lang::item('millable') . ' ([tooltip=tooltip_reqinscription]' . $this->subject->getField('requiredSkillRank') . '[/tooltip])'; } if ($_flags & ITEM_FLAG_PROSPECTABLE && $this->subject->getField('requiredSkill') == 755) { $infobox[] = Lang::item('prospectable') . ' ([tooltip=tooltip_reqjewelcrafting]' . $this->subject->getField('requiredSkillRank') . '[/tooltip])'; } if ($_flags & ITEM_FLAG_DEPRECATED) { $infobox[] = '[tooltip=tooltip_deprecated]' . Lang::item('deprecated') . '[/tooltip]'; } if ($_flags & ITEM_FLAG_NO_EQUIPCD) { $infobox[] = '[tooltip=tooltip_noequipcooldown]' . Lang::item('noEquipCD') . '[/tooltip]'; } if ($_flags & ITEM_FLAG_PARTYLOOT) { $infobox[] = '[tooltip=tooltip_partyloot]' . Lang::item('partyLoot') . '[/tooltip]'; } if ($_flags & ITEM_FLAG_REFUNDABLE) { $infobox[] = '[tooltip=tooltip_refundable]' . Lang::item('refundable') . '[/tooltip]'; } if ($_flags & ITEM_FLAG_SMARTLOOT) { $infobox[] = '[tooltip=tooltip_smartloot]' . Lang::item('smartLoot') . '[/tooltip]'; } if ($_flags & ITEM_FLAG_INDESTRUCTIBLE) { $infobox[] = Lang::item('indestructible'); } if ($_flags & ITEM_FLAG_USABLE_ARENA) { $infobox[] = Lang::item('useInArena'); } if ($_flags & ITEM_FLAG_USABLE_SHAPED) { $infobox[] = Lang::item('useInShape'); } // cant roll need if ($this->subject->getField('flagsExtra') & 0x100) { $infobox[] = '[tooltip=tooltip_cannotrollneed]' . Lang::item('noNeedRoll') . '[/tooltip]'; } // fits into keyring if ($_bagFamily & 0x100) { $infobox[] = Lang::item('atKeyring'); } /****************/ /* Main Content */ /****************/ $_cu = in_array($_class, [ITEM_CLASS_WEAPON, ITEM_CLASS_ARMOR]) || $this->subject->getField('gemEnchantmentId'); $this->headIcons = [$this->subject->getField('iconString'), $this->subject->getField('stackable')]; $this->infobox = $infobox ? '[ul][li]' . implode('[/li][li]', $infobox) . '[/li][/ul]' : null; $this->tooltip = $this->subject->renderTooltip(true); $this->redButtons = array(BUTTON_WOWHEAD => true, BUTTON_LINKS => ['color' => 'ff' . Util::$rarityColorStings[$this->subject->getField('quality')], 'linkId' => 'item:' . $this->typeId . ':0:0:0:0:0:0:0:0'], BUTTON_VIEW3D => in_array($_slot, $_visSlots) && $_model ? ['displayId' => $this->subject->getField('displayId'), 'slot' => $_slot, 'type' => TYPE_ITEM, 'typeId' => $this->typeId] : false, BUTTON_COMPARE => $_cu, BUTTON_EQUIP => in_array($_class, [ITEM_CLASS_WEAPON, ITEM_CLASS_ARMOR]), BUTTON_UPGRADE => $_cu ? ['class' => $_class, 'slot' => $_slot] : false); // availablility $this->disabled = false; // todo (med): get itemSources (which are not yet in DB :x) or // pageText if ($next = $this->subject->getField('pageTextId')) { $this->addJS('Book.js'); $this->addCSS(['path' => 'Book.css']); while ($next) { $row = DB::World()->selectRow('SELECT *, text as Text_loc0 FROM page_text pt LEFT JOIN locales_page_text lpt ON pt.entry = lpt.entry WHERE pt.entry = ?d', $next); $next = $row['next_page']; $this->pageText[] = Util::parseHtmlText(Util::localizedString($row, 'Text')); } } // subItems $this->subject->initSubItems(); if (!empty($this->subject->subItems[$this->typeId])) { uaSort($this->subject->subItems[$this->typeId], function ($a, $b) { return strcmp($a['name'], $b['name']); }); $this->subItems = array('data' => array_values($this->subject->subItems[$this->typeId]), 'quality' => $this->subject->getField('quality')); // merge identical stats and names for normal users (e.g. spellPower of a specific school became generel spellPower with 3.0) if (!User::isInGroup(U_GROUP_EMPLOYEE)) { for ($i = 1; $i < count($this->subItems['data']); $i++) { $prev =& $this->subItems['data'][$i - 1]; $cur =& $this->subItems['data'][$i]; if ($prev['jsonequip'] == $cur['jsonequip'] && $prev['name'] == $cur['name']) { $prev['chance'] += $cur['chance']; array_splice($this->subItems['data'], $i, 1); $i = 1; } } } } // factionchange-equivalent if ($pendant = DB::World()->selectCell('SELECT IF(horde_id = ?d, alliance_id, -horde_id) FROM player_factionchange_items WHERE alliance_id = ?d OR horde_id = ?d', $this->typeId, $this->typeId, $this->typeId)) { $altItem = new ItemList(array(['id', abs($pendant)])); if (!$altItem->error) { $this->transfer = sprintf(Lang::item('_transfer'), $altItem->id, $altItem->getField('quality'), $altItem->getField('iconString'), $altItem->getField('name', true), $pendant > 0 ? 'alliance' : 'horde', $pendant > 0 ? Lang::game('si', 1) : Lang::game('si', 2)); } } /**************/ /* Extra Tabs */ /**************/ // tabs: this item is contained in.. $lootTabs = new Loot(); $createdBy = []; if ($lootTabs->getByItem($this->typeId)) { $this->extendGlobalData($lootTabs->jsGlobals); foreach ($lootTabs->iterate() as $idx => $tab) { if (!$tab[1]) { continue; } if ($idx == 16) { $createdBy = array_column($tab[1], 'id'); } $this->lvTabs[] = array('file' => $tab[0], 'data' => $tab[1], 'params' => ['name' => $tab[2], 'id' => $tab[3], 'extraCols' => $tab[4] ? '$[' . implode(', ', array_unique($tab[4])) . ']' : null, 'hiddenCols' => $tab[5] ? '$ ' . Util::toJSON(array_unique($tab[5])) : null, 'visibleCols' => $tab[6] ? '$' . Util::toJSON(array_unique($tab[6])) : null]); } } // tabs: this item contains.. $sourceFor = array([LOOT_ITEM, $this->subject->id, '$LANG.tab_contains', 'contains', ['Listview.extraCols.percent'], [], []], [LOOT_PROSPECTING, $this->subject->id, '$LANG.tab_prospecting', 'prospecting', ['Listview.extraCols.percent'], ['side', 'slot', 'reqlevel'], []], [LOOT_MILLING, $this->subject->id, '$LANG.tab_milling', 'milling', ['Listview.extraCols.percent'], ['side', 'slot', 'reqlevel'], []], [LOOT_DISENCHANT, $this->subject->getField('disenchantId'), '$LANG.tab_disenchanting', 'disenchanting', ['Listview.extraCols.percent'], ['side', 'slot', 'reqlevel'], []]); $reqQuest = []; foreach ($sourceFor as $sf) { $lootTab = new Loot(); if ($lootTab->getByContainer($sf[0], $sf[1])) { $this->extendGlobalData($lootTab->jsGlobals); $sf[4] = array_merge($sf[4], $lootTab->extraCols); foreach ($lootTab->iterate() as $lv) { if (!$lv['quest']) { continue; } $sf[4] = array_merge($sf[4], ['Listview.extraCols.condition']); $reqQuest[$lv['id']] = 0; $lv['condition'][0][$this->typeId][] = [[CND_QUESTTAKEN, &$reqQuest[$lv['id']]]]; } $this->lvTabs[] = array('file' => 'item', 'data' => $lootTab->getResult(), 'params' => ['name' => $sf[2], 'id' => $sf[3], 'extraCols' => $sf[4] ? "\$[" . implode(', ', array_unique($sf[4])) . "]" : null, 'hiddenCols' => $sf[5] ? "\$" . Util::toJSON($sf[5]) : null, 'visibleCols' => $sf[6] ? '$' . Util::toJSON($sf[6]) : null]); } } if ($reqIds = array_keys($reqQuest)) { $conditions = array('OR', ['reqSourceItemId1', $reqIds], ['reqSourceItemId2', $reqIds], ['reqSourceItemId3', $reqIds], ['reqSourceItemId4', $reqIds], ['reqItemId1', $reqIds], ['reqItemId2', $reqIds], ['reqItemId3', $reqIds], ['reqItemId4', $reqIds], ['reqItemId5', $reqIds], ['reqItemId6', $reqIds]); $reqQuests = new QuestList($conditions); $reqQuests->getJSGlobals(GLOBALINFO_SELF); foreach ($reqQuests->iterate() as $qId => $__) { if (empty($reqQuests->requires[$qId][TYPE_ITEM])) { continue; } foreach ($reqIds as $rId) { if (in_array($rId, $reqQuests->requires[$qId][TYPE_ITEM])) { $reqQuest[$rId] = $reqQuests->id; } } } } // tab: container can contain if ($this->subject->getField('slots') > 0) { $contains = new ItemList(array(['bagFamily', $_bagFamily, '&'], ['slots', 1, '<'], CFG_SQL_LIMIT_NONE)); if (!$contains->error) { $this->extendGlobalData($contains->getJSGlobals(GLOBALINFO_SELF)); $hCols = ['side']; if (!$contains->hasSetFields(['slot'])) { $hCols[] = 'slot'; } $this->lvTabs[] = array('file' => 'item', 'data' => $contains->getListviewData(), 'params' => ['name' => '$LANG.tab_cancontain', 'id' => 'can-contain', 'hiddenCols' => '$' . Util::toJSON($hCols)]); } } else { if ($_bagFamily != 0x100) { $contains = new ItemList(array(['bagFamily', $_bagFamily, '&'], ['slots', 0, '>'], CFG_SQL_LIMIT_NONE)); if (!$contains->error) { $this->extendGlobalData($contains->getJSGlobals(GLOBALINFO_SELF)); $this->lvTabs[] = array('file' => 'item', 'data' => $contains->getListviewData(), 'params' => ['name' => '$LANG.tab_canbeplacedin', 'id' => 'can-be-placed-in', 'hiddenCols' => "\$['side']"]); } } } // tab: criteria of $conditions = array(['ac.type', [ACHIEVEMENT_CRITERIA_TYPE_OWN_ITEM, ACHIEVEMENT_CRITERIA_TYPE_USE_ITEM, ACHIEVEMENT_CRITERIA_TYPE_LOOT_ITEM, ACHIEVEMENT_CRITERIA_TYPE_EQUIP_ITEM]], ['ac.value1', $this->typeId]); $criteriaOf = new AchievementList($conditions); if (!$criteriaOf->error) { $this->extendGlobalData($criteriaOf->getJSGlobals(GLOBALINFO_SELF | GLOBALINFO_REWARDS)); $hCols = []; if (!$criteriaOf->hasSetFields(['reward_loc0'])) { $hCols = ['rewards']; } $this->lvTabs[] = array('file' => 'achievement', 'data' => $criteriaOf->getListviewData(), 'params' => ['name' => '$LANG.tab_criteriaof', 'id' => 'criteria-of', 'visibleCols' => "\$['category']", 'hiddenCols' => '$' . Util::toJSON($hCols)]); } // tab: reagent for $conditions = array('OR', ['reagent1', $this->typeId], ['reagent2', $this->typeId], ['reagent3', $this->typeId], ['reagent4', $this->typeId], ['reagent5', $this->typeId], ['reagent6', $this->typeId], ['reagent7', $this->typeId], ['reagent8', $this->typeId]); $reagent = new SpellList($conditions); if (!$reagent->error) { $this->extendGlobalData($reagent->getJSGlobals(GLOBALINFO_SELF | GLOBALINFO_RELATED)); $this->lvTabs[] = array('file' => 'spell', 'data' => $reagent->getListviewData(), 'params' => ['name' => '$LANG.tab_reagentfor', 'id' => 'reagent-for', 'visibleCols' => "\$['reagents']"]); } // tab: unlocks (object or item) $lockIds = DB::Aowow()->selectCol('SELECT id FROM ?_lock WHERE (type1 = 1 AND properties1 = ?d) OR (type2 = 1 AND properties2 = ?d) OR (type3 = 1 AND properties3 = ?d) OR (type4 = 1 AND properties4 = ?d) OR (type5 = 1 AND properties5 = ?d)', $this->typeId, $this->typeId, $this->typeId, $this->typeId, $this->typeId); if ($lockIds) { // objects $lockedObj = new GameObjectList(array(['lockId', $lockIds])); if (!$lockedObj->error) { $this->lvTabs[] = array('file' => 'object', 'data' => $lockedObj->getListviewData(), 'params' => ['name' => '$LANG.tab_unlocks', 'id' => 'unlocks-object']); } // items (generally unused. It's the spell on the item, that unlocks stuff) $lockedItm = new ItemList(array(['lockId', $lockIds])); if (!$lockedItm->error) { $this->extendGlobalData($lockedItm->getJSGlobals(GLOBALINFO_SELF)); $this->lvTabs[] = array('file' => 'item', 'data' => $lockedItm->getListviewData(), 'params' => ['name' => '$LANG.tab_unlocks', 'id' => 'unlocks-item']); } } // tab: see also $conditions = array(['id', $this->typeId, '!'], ['OR', ['name_loc' . User::$localeId, $this->subject->getField('name', true)], ['AND', ['class', $_class], ['subClass', $_subClass], ['slot', $_slot], ['itemLevel', $this->subject->getField('itemLevel') - 15, '>'], ['itemLevel', $this->subject->getField('itemLevel') + 15, '<'], ['quality', $this->subject->getField('quality')], ['requiredClass', $this->subject->getField('requiredClass')]]]); $saItems = new ItemList($conditions); if (!$saItems->error) { $this->extendGlobalData($saItems->getJSGlobals(GLOBALINFO_SELF)); $this->lvTabs[] = array('file' => 'item', 'data' => $saItems->getListviewData(), 'params' => ['name' => '$LANG.tab_seealso', 'id' => 'see-also']); } // tab: starts (quest) if ($qId = $this->subject->getField('startQuest')) { $starts = new QuestList(array(['id', $qId])); if (!$starts->error) { $this->extendGlobalData($starts->getJSGlobals(GLOBALINFO_SELF | GLOBALINFO_REWARDS)); $this->lvTabs[] = array('file' => 'quest', 'data' => $starts->getListviewData(), 'params' => ['name' => '$LANG.tab_starts', 'id' => 'starts-quest']); } } // tab: objective of (quest) $conditions = array('OR', ['reqItemId1', $this->typeId], ['reqItemId2', $this->typeId], ['reqItemId3', $this->typeId], ['reqItemId4', $this->typeId], ['reqItemId5', $this->typeId], ['reqItemId6', $this->typeId]); $objective = new QuestList($conditions); if (!$objective->error) { $this->extendGlobalData($objective->getJSGlobals(GLOBALINFO_SELF | GLOBALINFO_REWARDS)); $this->lvTabs[] = array('file' => 'quest', 'data' => $objective->getListviewData(), 'params' => ['name' => '$LANG.tab_objectiveof', 'id' => 'objective-of-quest']); } // tab: provided for (quest) $conditions = array('OR', ['sourceItemId', $this->typeId], ['reqSourceItemId1', $this->typeId], ['reqSourceItemId2', $this->typeId], ['reqSourceItemId3', $this->typeId], ['reqSourceItemId4', $this->typeId]); $provided = new QuestList($conditions); if (!$provided->error) { $this->extendGlobalData($provided->getJSGlobals(GLOBALINFO_SELF | GLOBALINFO_REWARDS)); $this->lvTabs[] = array('file' => 'quest', 'data' => $provided->getListviewData(), 'params' => ['name' => '$LANG.tab_providedfor', 'id' => 'provided-for-quest']); } // tab: same model as // todo (low): should also work for creatures summoned by item if (($model = $this->subject->getField('model')) && $_slot) { $sameModel = new ItemList(array(['model', $model], ['id', $this->typeId, '!'], ['slot', $_slot])); if (!$sameModel->error) { $this->extendGlobalData($sameModel->getJSGlobals(GLOBALINFO_SELF)); $this->lvTabs[] = array('file' => 'genericmodel', 'data' => $sameModel->getListviewData(ITEMINFO_MODEL), 'params' => ['name' => '$LANG.tab_samemodelas', 'id' => 'same-model-as', 'genericlinktype' => 'item']); } } // tab: sold by if (!empty($this->subject->getExtendedCost()[$this->subject->id])) { $vendors = $this->subject->getExtendedCost()[$this->subject->id]; $soldBy = new CreatureList(array(['id', array_keys($vendors)])); if (!$soldBy->error) { $sbData = $soldBy->getListviewData(); $this->extendGlobalData($soldBy->getJSGlobals(GLOBALINFO_SELF)); $extraCols = ['Listview.extraCols.stock', "Listview.funcBox.createSimpleCol('stack', 'stack', '10%', 'stack')", 'Listview.extraCols.cost']; $holidays = []; foreach ($sbData as $k => &$row) { $currency = []; $tokens = []; foreach ($vendors[$k] as $id => $qty) { if (is_string($id)) { continue; } if ($id > 0) { $tokens[] = [$id, $qty]; } else { if ($id < 0) { $currency[] = [-$id, $qty]; } } } if ($currency) { $this->extendGlobalIds(TYPE_CURRENCY, array_column($currency, 0)); } if ($tokens) { $this->extendGlobalIds(TYPE_ITEM, array_column($tokens, 0)); } $row['stock'] = $vendors[$k]['stock']; $row['cost'] = [empty($vendors[$k][0]) ? 0 : $vendors[$k][0]]; if ($e = $vendors[$k]['event']) { if (count($extraCols) == 3) { $extraCols[] = 'Listview.extraCols.condition'; } $this->extendGlobalIds(TYPE_WORLDEVENT, $e); $row['condition'][0][$this->typeId][] = [[CND_ACTIVE_EVENT, $e]]; } if ($currency || $tokens) { // fill idx:3 if required $row['cost'][] = $currency; } if ($tokens) { $row['cost'][] = $tokens; } if ($x = $this->subject->getField('buyPrice')) { $row['buyprice'] = $x; } if ($x = $this->subject->getField('sellPrice')) { $row['sellprice'] = $x; } if ($x = $this->subject->getField('buyCount')) { $row['stack'] = $x; } } $this->lvTabs[] = array('file' => 'creature', 'data' => $sbData, 'params' => ['name' => '$LANG.tab_soldby', 'id' => 'sold-by-npc', 'extraCols' => '$[' . implode(', ', $extraCols) . ']', 'hiddenCols' => "\$['level', 'type']"]); } } // tab: currency for // some minor trickery: get arenaPoints(43307) and honorPoints(43308) directly if ($this->typeId == 43307) { $n = '?items&filter=cr=145;crs=1;crv=0'; $w = 'reqArenaPoints > 0'; } else { if ($this->typeId == 43308) { $n = '?items&filter=cr=144;crs=1;crv=0'; $w = 'reqHonorPoints > 0'; } else { $n = in_array($this->typeId, [42, 61, 81, 241, 121, 122, 123, 125, 126, 161, 201, 101, 102, 221, 301, 341]) ? '?items&filter=cr=158;crs=' . $this->typeId . ';crv=0' : null; $w = 'reqItemId1 = ' . $this->typeId . ' OR reqItemId2 = ' . $this->typeId . ' OR reqItemId3 = ' . $this->typeId . ' OR reqItemId4 = ' . $this->typeId . ' OR reqItemId5 = ' . $this->typeId; } } $xCosts = DB::Aowow()->selectCol('SELECT id FROM ?_itemextendedcost WHERE ' . $w); $boughtBy = $xCosts ? DB::World()->selectCol('SELECT item FROM npc_vendor WHERE extendedCost IN (?a) UNION SELECT item FROM game_event_npc_vendor WHERE extendedCost IN (?a)', $xCosts, $xCosts) : null; if ($boughtBy) { $boughtBy = new ItemList(array(['id', $boughtBy])); if (!$boughtBy->error) { if ($boughtBy->getMatches() <= CFG_SQL_LIMIT_DEFAULT) { $n = null; } $iCur = new CurrencyList(array(['itemId', $this->typeId])); $filter = $iCur->error ? [TYPE_ITEM => $this->typeId] : [TYPE_CURRENCY => $iCur->id]; $this->lvTabs[] = array('file' => 'item', 'data' => $boughtBy->getListviewData(ITEMINFO_VENDOR, $filter), 'params' => ['name' => '$LANG.tab_currencyfor', 'id' => 'currency-for', 'extraCols' => "\$[Listview.funcBox.createSimpleCol('stack', 'stack', '10%', 'stack'), Listview.extraCols.cost]", 'note' => $n ? sprintf(Util::$filterResultString, $n) : null]); $this->extendGlobalData($boughtBy->getJSGlobals(GLOBALINFO_ANY)); } } // tab: teaches $ids = $indirect = []; for ($i = 1; $i < 6; $i++) { if ($this->subject->getField('spellTrigger' . $i) == 6) { $ids[] = $this->subject->getField('spellId' . $i); } else { if ($this->subject->getField('spellTrigger' . $i) == 0 && $this->subject->getField('spellId' . $i) > 0) { $indirect[] = $this->subject->getField('spellId' . $i); } } } // taught indirectly if ($indirect) { $indirectSpells = new SpellList(array(['id', $indirect])); foreach ($indirectSpells->iterate() as $__) { if ($_ = $indirectSpells->canTeachSpell()) { foreach ($_ as $idx) { $ids[] = $indirectSpells->getField('effect' . $idx . 'TriggerSpell'); } } } $ids = array_merge($ids, Util::getTaughtSpells($indirect)); } if ($ids) { $taughtSpells = new SpellList(array(['id', $ids])); if (!$taughtSpells->error) { $this->extendGlobalData($taughtSpells->getJSGlobals(GLOBALINFO_SELF | GLOBALINFO_RELATED)); $visCols = ['level', 'schools']; if ($taughtSpells->hasSetFields(['reagent1'])) { $visCols[] = 'reagents'; } $this->lvTabs[] = array('file' => 'spell', 'data' => $taughtSpells->getListviewData(), 'params' => ['name' => '$LANG.tab_teaches', 'id' => 'teaches', 'visibleCols' => '$' . Util::toJSON($visCols)]); } } // tab: Shared cooldown $cdCats = []; for ($i = 1; $i < 6; $i++) { if ($this->subject->getField('spellId' . $i) > 0 && $this->subject->getField('spellCategory' . $i) > 0) { $cdCats[] = $this->subject->getField('spellCategory' . $i); } } if ($cdCats) { $conditions = array('OR', ['spellCategory1', $cdCats], ['spellCategory2', $cdCats], ['spellCategory3', $cdCats], ['spellCategory4', $cdCats], ['spellCategory5', $cdCats]); $cdItems = new ItemList($conditions); if (!$cdItems->error) { $this->lvTabs[] = array('file' => 'item', 'data' => $cdItems->getListviewData(), 'params' => ['name' => '$LANG.tab_sharedcooldown', 'id' => 'shared-cooldown']); $this->extendGlobalData($cdItems->getJSGlobals(GLOBALINFO_SELF)); } } // // todo - tab: taught by // use var $createdBy to find source of this spell // id: 'taught-by-X', // name: LANG.tab_taughtby }
protected function generateContent() { $this->addJS('?data=zones&locale=' . User::$localeId . '&t=' . $_SESSION['dataKey']); /***********/ /* Infobox */ /***********/ $infobox = Lang::getInfoBoxForFlags($this->subject->getField('cuFlags')); // City if ($this->subject->getField('flags') & 0x8 && !$this->subject->getField('parentArea')) { $infobox[] = Lang::zone('city'); } // Auto repop if ($this->subject->getField('flags') & 0x1000 && !$this->subject->getField('parentArea')) { $infobox[] = Lang::zone('autoRez'); } // Level if ($_ = $this->subject->getField('levelMin')) { if ($_ < $this->subject->getField('levelMax')) { $_ .= ' - ' . $this->subject->getField('levelMax'); } $infobox[] = Lang::game('level') . Lang::main('colon') . $_; } // required Level if ($_ = $this->subject->getField('levelReq')) { if ($__ = $this->subject->getField('levelReqLFG')) { $buff = sprintf(Lang::zone('reqLevels'), $_, $__); } else { $buff = Lang::main('_reqLevel') . Lang::main('colon') . $_; } $infobox[] = $buff; } // Territory $_ = $this->subject->getField('faction'); $__ = '%s'; if ($_ == 0) { $__ = '[span class=icon-alliance]%s[/span]'; } else { if ($_ == 1) { $__ = '[span class=icon-horde]%s[/span]'; } else { if ($_ == 4) { $__ = '[span class=icon-ffa]%s[/span]'; } } } $infobox[] = Lang::zone('territory') . Lang::main('colon') . sprintf($__, Lang::zone('territories', $_)); // Instance Type $infobox[] = Lang::zone('instanceType') . Lang::main('colon') . '[span class=icon-instance' . $this->subject->getField('type') . ']' . Lang::zone('instanceTypes', $this->subject->getField('type')) . '[/span]'; // Heroic mode if ($_ = $this->subject->getField('levelHeroic')) { $infobox[] = '[icon preset=heroic]' . sprintf(Lang::zone('hcAvailable'), $_) . '[/icon]'; } // number of players if ($_ = $this->subject->getField('maxPlayer')) { $infobox[] = Lang::zone('numPlayers') . Lang::main('colon') . ($_ == -2 ? '10/25' : $_); } // Attunement Quest/Achievements & Keys if ($attmnt = $this->subject->getField('attunes')) { foreach ($attmnt as $type => $ids) { $this->extendGlobalIds($type, array_map('abs', $ids)); foreach ($ids as $id) { if ($type == TYPE_ITEM) { $infobox[] = Lang::zone('key', (int) ($id < 0)) . Lang::main('colon') . '[item=' . abs($id) . ']'; } else { $infobox[] = Lang::zone('attunement', (int) ($id < 0)) . Lang::main('colon') . '[' . Util::$typeStrings[$type] . '=' . abs($id) . ']'; } } } } // Instances if ($_ = DB::Aowow()->selectCol('SELECT id FROM ?_zones WHERE parentAreaId = ?d AND (flags & ?d) = 0', $this->typeId, CUSTOM_EXCLUDE_FOR_LISTVIEW)) { $this->extendGlobalIds(TYPE_ZONE, $_); $infobox[] = Lang::maps('Instances') . Lang::main('colon') . "\n[zone=" . implode("], \n[zone=", $_) . ']'; } // location (if instance) if ($pa = $this->subject->getField('parentAreaId')) { $paO = new ZoneList(array(['id', $pa])); if (!$paO->error) { $pins = str_pad($this->subject->getField('parentX') * 10, 3, '0', STR_PAD_LEFT) . str_pad($this->subject->getField('parentY') * 10, 3, '0', STR_PAD_LEFT); $infobox[] = Lang::zone('location') . Lang::main('colon') . '[lightbox=map zone=' . $pa . ' pins=' . $pins . ']' . $paO->getField('name', true) . '[/lightbox]'; } } /* has to be defined in an article, i think // faction(s) / Reputation Hub / Raid Faction // [li]Raid faction: [faction=1156][/li] || [li]Factions: [faction=1156]/[faction=1156][/li] // final boss // [li]Final boss: [icon preset=boss][npc=37226][/icon][/li] */ /****************/ /* Main Content */ /****************/ $addToMap = function ($what, $entry) use(&$som) { // entry always contains: type, id, name, level, coords[] if (!isset($som[$what][$entry['name']])) { // not found yet $som[$what][$entry['name']][] = $entry; } else { // check for identical floors foreach ($som[$what][$entry['name']] as &$byFloor) { if ($byFloor['level'] != $entry['level']) { continue; } // found existing floor, ammending coords $byFloor['coords'][] = $entry['coords'][0]; break; } // floor not used yet, create it $som[$what][$entry['name']][] = $entry; } }; if ($_ = $this->subject->getField('parentArea')) { $this->extraText = sprintf(Lang::zone('zonePartOf'), $_); $this->extendGlobalIds(TYPE_ZONE, $_); } // we cannot fetch spawns via lists. lists are grouped by entry $oSpawns = DB::Aowow()->select('SELECT * FROM ?_spawns WHERE areaId = ?d AND type = ?d', $this->typeId, TYPE_OBJECT); $cSpawns = DB::Aowow()->select('SELECT * FROM ?_spawns WHERE areaId = ?d AND type = ?d', $this->typeId, TYPE_NPC); $conditions = [CFG_SQL_LIMIT_NONE, ['s.areaId', $this->typeId]]; if (!User::isInGroup(U_GROUP_STAFF)) { $conditions[] = [['cuFlags', CUSTOM_EXCLUDE_FOR_LISTVIEW, '&'], 0]; } $objectSpawns = new GameObjectList($conditions); $creatureSpawns = new CreatureList($conditions); $questsLV = $rewardsLV = []; // see if we can actually display a map $hasMap = file_exists('static/images/wow/maps/' . Util::$localeStrings[User::$localeId] . '/normal/' . $this->typeId . '.jpg'); if (!$hasMap) { // try multilayered $hasMap = file_exists('static/images/wow/maps/' . Util::$localeStrings[User::$localeId] . '/normal/' . $this->typeId . '-1.jpg'); } if (!$hasMap) { // try english fallback $hasMap = file_exists('static/images/wow/maps/enus/normal/' . $this->typeId . '.jpg'); } if (!$hasMap) { // try english fallback, multilayered $hasMap = file_exists('static/images/wow/maps/enus/normal/' . $this->typeId . '-1.jpg'); } if ($hasMap) { $som = []; foreach ($oSpawns as $spawn) { $tpl = $objectSpawns->getEntry($spawn['typeId']); if (!$tpl) { continue; } $n = Util::localizedString($tpl, 'name'); $what = ''; switch ($tpl['typeCat']) { case -3: $what = 'herb'; break; case -4: $what = 'vein'; break; case 9: $what = 'book'; break; case -6: if ($tpl['spellFocusId'] == 1) { $what = 'anvil'; } else { if ($tpl['spellFocusId'] == 3) { $what = 'forge'; } } break; } if ($what) { $addToMap($what, array('coords' => [[$spawn['posX'], $spawn['posY']]], 'level' => $spawn['floor'], 'name' => $n, 'type' => TYPE_OBJECT, 'id' => $tpl['id'])); } if ($tpl['startsQuests']) { $started = new QuestList(array(['qse.method', 1, '&'], ['qse.type', TYPE_OBJECT], ['qse.typeId', $tpl['id']])); if ($started->error) { continue; } // store data for misc tabs foreach ($started->getListviewData() as $id => $data) { if (!empty($started->rewards[$id][TYPE_ITEM])) { $rewardsLV = array_merge($rewardsLV, array_keys($started->rewards[$id][TYPE_ITEM])); } if (!empty($started->choices[$id][TYPE_ITEM])) { $rewardsLV = array_merge($rewardsLV, array_keys($started->choices[$id][TYPE_ITEM])); } $questsLV[$id] = $data; } $this->extendGlobalData($started->getJSGlobals(GLOBALINFO_SELF | GLOBALINFO_REWARDS)); if ($tpl['A'] != -1 & ($_ = $started->getSOMData(SIDE_ALLIANCE))) { $addToMap('alliancequests', array('coords' => [[$spawn['posX'], $spawn['posY']]], 'level' => $spawn['floor'], 'name' => $n, 'type' => TYPE_OBJECT, 'id' => $tpl['id'], 'side' => ($tpl['A'] < 0 ? 0 : 0x1) | ($tpl['H'] < 0 ? 0 : 0x2), 'quests' => array_values($_))); } if ($tpl['H'] != -1 & ($_ = $started->getSOMData(SIDE_HORDE))) { $addToMap('hordequests', array('coords' => [[$spawn['posX'], $spawn['posY']]], 'level' => $spawn['floor'], 'name' => $n, 'type' => TYPE_OBJECT, 'id' => $tpl['id'], 'side' => ($tpl['A'] < 0 ? 0 : 0x1) | ($tpl['H'] < 0 ? 0 : 0x2), 'quests' => array_values($_))); } } } $flightNodes = []; foreach ($cSpawns as $spawn) { $tpl = $creatureSpawns->getEntry($spawn['typeId']); if (!$tpl) { continue; } $n = Util::localizedString($tpl, 'name'); $sn = Util::localizedString($tpl, 'subname'); $what = ''; if ($tpl['npcflag'] & NPC_FLAG_REPAIRER) { $what = 'repair'; } else { if ($tpl['npcflag'] & NPC_FLAG_AUCTIONEER) { $what = 'auctioneer'; } else { if ($tpl['npcflag'] & NPC_FLAG_BANKER) { $what = 'banker'; } else { if ($tpl['npcflag'] & NPC_FLAG_BATTLEMASTER) { $what = 'battlemaster'; } else { if ($tpl['npcflag'] & NPC_FLAG_INNKEEPER) { $what = 'innkeeper'; } else { if ($tpl['npcflag'] & NPC_FLAG_TRAINER) { $what = 'trainer'; } else { if ($tpl['npcflag'] & NPC_FLAG_VENDOR) { $what = 'vendor'; } else { if ($tpl['npcflag'] & NPC_FLAG_FLIGHT_MASTER) { $flightNodes[$tpl['id']] = [$spawn['posX'], $spawn['posY']]; $what = 'flightmaster'; } else { if ($tpl['npcflag'] & NPC_FLAG_STABLE_MASTER) { $what = 'stablemaster'; } else { if ($tpl['npcflag'] & NPC_FLAG_GUILD_MASTER) { $what = 'guildmaster'; } else { if ($tpl['npcflag'] & (NPC_FLAG_SPIRIT_HEALER | NPC_FLAG_SPIRIT_GUIDE)) { $what = 'spirithealer'; } else { if ($creatureSpawns->isBoss()) { $what = 'boss'; } else { if ($tpl['rank'] == 2 || $tpl['rank'] == 4) { $what = 'rare'; } } } } } } } } } } } } } if ($what) { $addToMap($what, array('coords' => [[$spawn['posX'], $spawn['posY']]], 'level' => $spawn['floor'], 'name' => $n, 'type' => TYPE_NPC, 'id' => $tpl['id'], 'reacthorde' => $tpl['H'] ?: 1, 'reactalliance' => $tpl['A'] ?: 1, 'description' => $sn)); } if ($tpl['startsQuests']) { $started = new QuestList(array(['qse.method', 1, '&'], ['qse.type', TYPE_NPC], ['qse.typeId', $tpl['id']])); if ($started->error) { continue; } // store data for misc tabs foreach ($started->getListviewData() as $id => $data) { if (!empty($started->rewards[$id][TYPE_ITEM])) { $rewardsLV = array_merge($rewardsLV, array_keys($started->rewards[$id][TYPE_ITEM])); } if (!empty($started->choices[$id][TYPE_ITEM])) { $rewardsLV = array_merge($rewardsLV, array_keys($started->choices[$id][TYPE_ITEM])); } $questsLV[$id] = $data; } if ($tpl['A'] != -1 & ($_ = $started->getSOMData(SIDE_ALLIANCE))) { $addToMap('alliancequests', array('coords' => [[$spawn['posX'], $spawn['posY']]], 'level' => $spawn['floor'], 'name' => $n, 'type' => TYPE_NPC, 'id' => $tpl['id'], 'reacthorde' => $tpl['H'], 'reactalliance' => $tpl['A'], 'side' => ($tpl['A'] < 0 ? 0 : SIDE_ALLIANCE) | ($tpl['H'] < 0 ? 0 : SIDE_HORDE), 'quests' => array_values($_))); } if ($tpl['H'] != -1 & ($_ = $started->getSOMData(SIDE_HORDE))) { $addToMap('hordequests', array('coords' => [[$spawn['posX'], $spawn['posY']]], 'level' => $spawn['floor'], 'name' => $n, 'type' => TYPE_NPC, 'id' => $tpl['id'], 'reacthorde' => $tpl['H'], 'reactalliance' => $tpl['A'], 'side' => ($tpl['A'] < 0 ? 0 : SIDE_ALLIANCE) | ($tpl['H'] < 0 ? 0 : SIDE_HORDE), 'quests' => array_values($_))); } } } // remove unwanted indizes foreach ($som as $what => &$dataz) { if (empty($som[$what])) { continue; } foreach ($dataz as &$data) { $data = array_values($data); } if (!in_array($what, ['vein', 'herb', 'rare'])) { $foo = []; foreach ($dataz as $d) { foreach ($d as $_) { $foo[] = $_; } } $dataz = $foo; } } // append paths between nodes if ($flightNodes) { // neutral nodes come last as the line is colored by the node it's attached to usort($som['flightmaster'], function ($a, $b) { $n1 = $a['reactalliance'] == $a['reacthorde']; $n2 = $b['reactalliance'] == $b['reacthorde']; if ($n1 && !$n2) { return 1; } if (!$n1 && $n2) { return -1; } return 0; }); $paths = DB::Aowow()->select('SELECT n1.typeId AS "0", n2.typeId AS "1" FROM ?_taxipath p JOIN ?_taxinodes n1 ON n1.id = p.startNodeId JOIN ?_taxinodes n2 ON n2.id = p.endNodeId WHERE n1.typeId IN (?a) AND n2.typeId IN (?a)', array_keys($flightNodes), array_keys($flightNodes)); foreach ($paths as $k => $path) { foreach ($som['flightmaster'] as &$fm) { if ($fm['id'] != $path[0] && $fm['id'] != $path[1]) { continue; } if ($fm['id'] == $path[0]) { $fm['paths'][] = $flightNodes[$path[1]]; } if ($fm['id'] == $path[1]) { $fm['paths'][] = $flightNodes[$path[0]]; } unset($paths[$k]); break; } } } // preselect bosses for raids/dungeons if (in_array($this->subject->getField('type'), [2, 3, 4, 5, 7, 8])) { $som['instance'] = true; } $this->map = array('data' => ['parent' => 'mapper-generic', 'zone' => $this->typeId], 'som' => $som); } else { $this->map = false; } $this->infobox = $infobox ? '[ul][li]' . implode('[/li][li]', $infobox) . '[/li][/ul]' : null; $this->expansion = Util::$expansionString[$this->subject->getField('expansion')]; $this->redButtons = array(BUTTON_WOWHEAD => true, BUTTON_LINKS => true); /* - associated with holiday? */ /**************/ /* Extra Tabs */ /**************/ // tab: NPCs if ($cSpawns && !$creatureSpawns->error) { $lvData = array('file' => 'creature', 'data' => $creatureSpawns->getListviewData(), 'params' => ['note' => sprintf(Util::$filterResultString, '?npcs&filter=cr=6;crs=' . $this->typeId . ';crv=0')]); if ($creatureSpawns->getMatches() > CFG_SQL_LIMIT_DEFAULT) { $lvData['params']['_truncated'] = 1; } $this->extendGlobalData($creatureSpawns->getJSGlobals(GLOBALINFO_SELF)); $this->lvTabs[] = $lvData; } // tab: Objects if ($oSpawns && !$objectSpawns->error) { $lvData = array('file' => 'object', 'data' => $objectSpawns->getListviewData(), 'params' => ['note' => sprintf(Util::$filterResultString, '?objects&filter=cr=1;crs=' . $this->typeId . ';crv=0')]); if ($objectSpawns->getMatches() > CFG_SQL_LIMIT_DEFAULT) { $lvData['params']['_truncated'] = 1; } $this->extendGlobalData($objectSpawns->getJSGlobals(GLOBALINFO_SELF)); $this->lvTabs[] = $lvData; } // tab: Quests [data collected by SOM-routine] if ($questsLV) { $this->lvTabs[] = array('file' => 'quest', 'data' => $questsLV, 'params' => ['note' => '$$WH.sprintf(LANG.lvnote_zonequests, ' . $this->subject->getField('mapId') . ', ' . $this->typeId . ', \'' . Util::jsEscape($this->subject->getField('name', true)) . '\', ' . $this->typeId . ')']); } // tab: item-quest starter // select every quest starter, that is a drop $questStartItem = DB::Aowow()->select(' SELECT qse.typeId AS ARRAY_KEY, moreType, moreTypeId, moreZoneId FROM ?_quests_startend qse JOIN ?_source src ON src.type = qse.type AND src.typeId = qse.typeId WHERE src.src2 IS NOT NULL AND qse.type = ?d AND (moreZoneId = ?d OR (moreType = ?d AND moreTypeId IN (?a)) OR (moreType = ?d AND moreTypeId IN (?a)))', TYPE_ITEM, $this->typeId, TYPE_NPC, array_unique(array_column($cSpawns, 'typeId')) ?: [0], TYPE_OBJECT, array_unique(array_column($oSpawns, 'typeId')) ?: [0]); if ($questStartItem) { $qsiList = new ItemList(array(['id', array_keys($questStartItem)])); if (!$qsiList->error) { $this->lvTabs[] = array('file' => 'item', 'data' => $qsiList->getListviewData(), 'params' => ['name' => '$LANG.tab_startsquest', 'id' => 'starts-quest']); $this->extendGlobalData($qsiList->getJSGlobals(GLOBALINFO_SELF)); } } // tab: Quest Rewards [ids collected by SOM-routine] if ($rewardsLV) { $rewards = new ItemList(array(['id', array_unique($rewardsLV)])); if (!$rewards->error) { $this->lvTabs[] = array('file' => 'item', 'data' => $rewards->getListviewData(), 'params' => ['name' => '$LANG.tab_questrewards', 'id' => 'quest-rewards', 'note' => sprintf(Util::$filterResultString, '?items&filter=cr=126;crs=' . $this->typeId . ';crv=0')]); $this->extendGlobalData($rewards->getJSGlobals(GLOBALINFO_SELF)); } } // tab: achievements // tab: fished in zone $fish = new Loot(); if ($fish->getByContainer(LOOT_FISHING, $this->typeId)) { $this->extendGlobalData($fish->jsGlobals); $xCols = array_merge(['Listview.extraCols.percent'], $fish->extraCols); foreach ($fish->iterate() as $lv) { if (!$lv['quest']) { continue; } $xCols = array_merge($xCols, ['Listview.extraCols.condition']); $reqQuest[$lv['id']] = 0; $lv['condition'][0][$this->typeId][] = [[CND_QUESTTAKEN, &$reqQuest[$lv['id']]]]; } $this->lvTabs[] = array('file' => 'item', 'data' => $fish->getResult(), 'params' => ['name' => '$LANG.tab_fishing', 'id' => 'fishing', 'extraCols' => $xCols ? "\$[" . implode(', ', array_unique($xCols)) . "]" : null, 'hiddenCols' => "\$['side']"]); } // tab: spells if ($saData = DB::World()->select('SELECT * FROM spell_area WHERE area = ?d', $this->typeId)) { $spells = new SpellList(array(['id', array_column($saData, 'spell')])); if (!$spells->error) { $lvSpells = $spells->getListviewData(); $this->extendGlobalData($spells->getJSGlobals()); $extra = false; foreach ($saData as $a) { if (empty($lvSpells[$a['spell']])) { continue; } $condition = []; if ($a['aura_spell']) { $this->extendGlobalIds(TYPE_SPELL, abs($a['aura_spell'])); $condition[0][$this->typeId][] = [[$a['aura_spell'] > 0 ? CND_AURA : -CND_AURA, abs($a['aura_spell'])]]; } if ($a['quest_start']) { $this->extendGlobalIds(TYPE_QUEST, $a['quest_start']); $group = []; for ($i = 0; $i < 7; $i++) { if (!($a['quest_start_status'] & 1 << $i)) { continue; } if ($i == 0) { $group[] = [CND_QUEST_NONE, $a['quest_start']]; } else { if ($i == 1) { $group[] = [CND_QUEST_COMPLETE, $a['quest_start']]; } else { if ($i == 3) { $group[] = [CND_QUESTTAKEN, $a['quest_start']]; } else { if ($i == 6) { $group[] = [CND_QUESTREWARDED, $a['quest_start']]; } } } } } if ($group) { $condition[0][$this->typeId][] = $group; } } if ($a['quest_end'] && $a['quest_end'] != $a['quest_start']) { $this->extendGlobalIds(TYPE_QUEST, $a['quest_end']); $group = []; for ($i = 0; $i < 7; $i++) { if (!($a['quest_end_status'] & 1 << $i)) { continue; } if ($i == 0) { $group[] = [-CND_QUEST_NONE, $a['quest_end']]; } else { if ($i == 1) { $group[] = [-CND_QUEST_COMPLETE, $a['quest_end']]; } else { if ($i == 3) { $group[] = [-CND_QUESTTAKEN, $a['quest_end']]; } else { if ($i == 6) { $group[] = [-CND_QUESTREWARDED, $a['quest_end']]; } } } } } if ($group) { $condition[0][$this->typeId][] = $group; } } if ($a['racemask']) { $foo = []; for ($i = 0; $i < 11; $i++) { if ($a['racemask'] & 1 << $i) { $foo[] = $i + 1; } } $this->extendGlobalIds(TYPE_RACE, $foo); $condition[0][$this->typeId][] = [[CND_RACE, $a['racemask']]]; } if ($a['gender'] != 2) { // 2: both $condition[0][$this->typeId][] = [[CND_GENDER, $a['gender'] + 1]]; } if ($condition) { $extra = true; $lvSpells[$a['spell']] = array_merge($lvSpells[$a['spell']], ['condition' => $condition]); } } $this->lvTabs[] = array('file' => 'spell', 'data' => $lvSpells, 'params' => array('extraCols' => $extra ? '$[Listview.extraCols.condition]' : null, 'hiddenCols' => "\$['skill']")); } } // tab: subzones $subZones = new ZoneList(array(['parentArea', $this->typeId])); if (!$subZones->error) { $this->lvTabs[] = array('file' => 'zone', 'data' => $subZones->getListviewData(), 'params' => ['name' => '$LANG.tab_zones', 'id' => 'subzones', 'hiddenCols' => "\$['territory', 'instancetype']"]); $this->extendGlobalData($subZones->getJSGlobals(GLOBALINFO_SELF)); } }
protected function generateContent() { $this->addJS('?data=zones&locale=' . User::$localeId . '&t=' . $_SESSION['dataKey']); $_cat = $this->subject->getField('typeCat'); $redButtons = array(BUTTON_LINKS => ['color' => 'ff71d5ff', 'linkId' => Util::$typeStrings[TYPE_SPELL] . ':' . $this->typeId], BUTTON_VIEW3D => false, BUTTON_WOWHEAD => true); /***********/ /* Infobox */ /***********/ $infobox = Lang::getInfoBoxForFlags($this->subject->getField('cuFlags')); // level if (!in_array($_cat, [-5, -6])) { if ($_ = $this->subject->getField('talentLevel')) { $infobox[] = in_array($_cat, [-2, 7, -13]) ? sprintf(Lang::game('reqLevel'), $_) : Lang::game('level') . Lang::main('colon') . $_; } else { if ($_ = $this->subject->getField('spellLevel')) { $infobox[] = in_array($_cat, [-2, 7, -13]) ? sprintf(Lang::game('reqLevel'), $_) : Lang::game('level') . Lang::main('colon') . $_; } } } // races if ($_ = Lang::getRaceString($this->subject->getField('reqRaceMask'), $__, $jsg, $n, false)) { if ($_ != Lang::game('ra', 0)) { $this->extendGlobalIds(TYPE_RACE, $jsg); $t = $n == 1 ? Lang::game('race') : Lang::game('races'); $infobox[] = Util::ucFirst($t) . Lang::main('colon') . $_; } } // classes if ($_ = Lang::getClassString($this->subject->getField('reqClassMask'), $jsg, $n, false)) { $this->extendGlobalIds(TYPE_CLASS, $jsg); $t = $n == 1 ? Lang::game('class') : Lang::game('classes'); $infobox[] = Util::ucFirst($t) . Lang::main('colon') . $_; } // spell focus if ($_ = $this->subject->getField('spellFocusObject')) { $bar = DB::Aowow()->selectRow('SELECT * FROM ?_spellfocusobject WHERE id = ?d', $_); $focus = new GameObjectList(array(['spellFocusId', $_], 1)); $infobox[] = Lang::game('requires2') . ' ' . ($focus->error ? Util::localizedString($bar, 'name') : '[url=?object=' . $focus->id . ']' . Util::localizedString($bar, 'name') . '[/url]'); } // primary & secondary trades if (in_array($_cat, [9, 11])) { // skill if ($_ = $this->subject->getField('skillLines')[0]) { $rSkill = new SkillList(array(['id', $_])); if (!$rSkill->error) { $this->extendGlobalData($rSkill->getJSGlobals()); $bar = sprintf(Lang::game('requires'), ' [skill=' . $rSkill->id . ']'); if ($_ = $this->subject->getField('learnedAt')) { $bar .= ' (' . $_ . ')'; } $infobox[] = $bar; } } // specialization if ($_ = $this->subject->getField('reqSpellId')) { $rSpell = new SpellList(array(['id', $_])); if (!$rSpell->error) { $this->extendGlobalData($rSpell->getJSGlobals()); $infobox[] = Lang::game('requires2') . ' [spell=' . $rSpell->id . '][/li]'; } } // difficulty if ($_ = $this->subject->getColorsForCurrent()) { $bar = []; for ($i = 0; $i < 4; $i++) { if ($_[$i]) { $bar[] = '[color=r' . ($i + 1) . ']' . $_[$i] . '[/color]'; } } $infobox[] = Lang::game('difficulty') . Lang::main('colon') . implode(' ', $bar); } } // accquisition.. 10: starter spell; 7: discovery if (isset($this->subject->sources[$this->subject->id][10])) { $infobox[] = Lang::spell('starter'); } else { if (isset($this->subject->sources[$this->subject->id][7])) { $infobox[] = Lang::spell('discovered'); } } // training cost if ($cost = $this->subject->getField('trainingCost')) { $infobox[] = Lang::spell('trainingCost') . Lang::main('colon') . '[money=' . $cost . '][/li]'; } // used in mode foreach ($this->difficulties as $n => $id) { if ($id == $this->typeId) { // "Mode" seems to be multilingual acceptable $infobox[] = 'Mode' . Lang::main('colon') . Lang::game('modes', $n); } } $effects = $this->createEffects($infobox, $redButtons); // spell script if (User::isInGroup(U_GROUP_STAFF)) { if ($_ = DB::World()->selectCell('SELECT ScriptName FROM spell_script_names WHERE ABS(spell_id) = ?d', $this->firstRank)) { $infobox[] = 'Script' . Lang::main('colon') . $_; } } $infobox = $infobox ? '[ul][li]' . implode('[/li][li]', $infobox) . '[/li][/ul]' : ''; // append glyph symbol if available $glyphId = 0; for ($i = 1; $i < 4; $i++) { if ($this->subject->getField('effect' . $i . 'Id') == 74) { $glyphId = $this->subject->getField('effect' . $i . 'MiscValue'); } } if ($_ = DB::Aowow()->selectCell('SELECT si.iconString FROM ?_glyphproperties gp JOIN ?_icons si ON gp.iconId = si.id WHERE gp.spellId = ?d { OR gp.id = ?d }', $this->typeId, $glyphId ?: DBSIMPLE_SKIP)) { if (file_exists('static/images/wow/Interface/Spellbook/' . $_ . '.png')) { $infobox .= '[img src=' . STATIC_URL . '/images/wow/Interface/Spellbook/' . $_ . '.png border=0 float=center margin=15]'; } } /****************/ /* Main Content */ /****************/ $this->reagents = $this->createReagentList(); $this->scaling = $this->createScalingData(); $this->items = $this->createRequiredItems(); $this->tools = $this->createTools(); $this->effects = $effects; $this->infobox = $infobox; $this->powerCost = $this->subject->createPowerCostForCurrent(); $this->castTime = $this->subject->createCastTimeForCurrent(false, false); $this->name = $this->subject->getField('name', true); $this->headIcons = [$this->subject->getField('iconString'), $this->subject->getField('stackAmount')]; $this->level = $this->subject->getField('spellLevel'); $this->rangeName = $this->subject->getField('rangeText', true); $this->range = $this->subject->getField('rangeMaxHostile'); $this->gcd = Util::formatTime($this->subject->getField('startRecoveryTime')); $this->gcdCat = null; // todo (low): nyi; find out how this works [n/a; normal; ..] $this->school = [Util::asHex($this->subject->getField('schoolMask')), Lang::getMagicSchools($this->subject->getField('schoolMask'))]; $this->dispel = $this->subject->getField('dispelType') ? Lang::game('dt', $this->subject->getField('dispelType')) : null; $this->mechanic = $this->subject->getField('mechanic') ? Lang::game('me', $this->subject->getField('mechanic')) : null; $this->unavailable = $this->subject->getField('cuFlags') & CUSTOM_UNAVAILABLE; $this->redButtons = $redButtons; // minRange exists.. prepend if ($_ = $this->subject->getField('rangeMinHostile')) { $this->range = $_ . ' - ' . $this->range; } if ($this->subject->getField('attributes2') & 0x80000) { $this->stances = Lang::getStances($this->subject->getField('stanceMask')); } if (($_ = $this->subject->getField('recoveryTime')) && $_ > 0) { $this->cooldown = Util::formatTime($_); } if (($_ = $this->subject->getField('duration')) && $_ > 0) { $this->duration = Util::formatTime($_); } // factionchange-equivalent if ($pendant = DB::World()->selectCell('SELECT IF(horde_id = ?d, alliance_id, -horde_id) FROM player_factionchange_spells WHERE alliance_id = ?d OR horde_id = ?d', $this->typeId, $this->typeId, $this->typeId)) { $altSpell = new SpellList(array(['id', abs($pendant)])); if (!$altSpell->error) { $this->transfer = sprintf(Lang::spell('_transfer'), $altSpell->id, 1, $altSpell->getField('iconString'), $altSpell->getField('name', true), $pendant > 0 ? 'alliance' : 'horde', $pendant > 0 ? Lang::game('si', 1) : Lang::game('si', 2)); } } /**************/ /* Extra Tabs */ /**************/ $j = [null, 'A', 'B', 'C']; // tab: abilities [of shapeshift form] for ($i = 1; $i < 4; $i++) { if ($this->subject->getField('effect' . $i . 'AuraId') != 36) { continue; } $formSpells = DB::Aowow()->selectRow('SELECT spellId1, spellId2, spellId3, spellId4, spellId5, spellId6, spellId7, spellId8 FROM ?_shapeshiftforms WHERE id = ?d', $this->subject->getField('effect' . $i . 'MiscValue')); if (!$formSpells) { continue; } $abilities = new SpellList(array(['id', $formSpells])); if (!$abilities->error) { if (!$abilities->hasSetFields(['skillLines'])) { $abH = "\$['skill']"; } $this->lvTabs[] = array('file' => 'spell', 'data' => $abilities->getListviewData(), 'params' => array('id' => 'controlledabilities', 'name' => '$LANG.tab_controlledabilities', 'visibleCols' => "\$['level']", 'hiddenCols' => isset($abH) ? $abH : null)); $this->extendGlobalData($abilities->getJSGlobals(GLOBALINFO_SELF)); } } // tab: modifies $this $sub = ['OR']; $conditions = [['s.typeCat', [0, -9, -8], '!'], ['s.spellFamilyId', $this->subject->getField('spellFamilyId')], &$sub]; for ($i = 1; $i < 4; $i++) { // Flat Mods (107), Pct Mods (108), No Reagent Use (256) .. include dummy..? (4) if (!in_array($this->subject->getField('effect' . $i . 'AuraId'), [107, 108, 256, 286])) { continue; } $m1 = $this->subject->getField('effect1SpellClassMask' . $j[$i]); $m2 = $this->subject->getField('effect2SpellClassMask' . $j[$i]); $m3 = $this->subject->getField('effect3SpellClassMask' . $j[$i]); if (!$m1 && !$m2 && !$m3) { continue; } $sub[] = ['s.spellFamilyFlags1', $m1, '&']; $sub[] = ['s.spellFamilyFlags2', $m2, '&']; $sub[] = ['s.spellFamilyFlags3', $m3, '&']; } if (count($sub) > 1) { $modSpells = new SpellList($conditions); if (!$modSpells->error) { if (!$modSpells->hasSetFields(['skillLines'])) { $msH = "\$['skill']"; } $this->lvTabs[] = array('file' => 'spell', 'data' => $modSpells->getListviewData(), 'params' => array('id' => 'modifies', 'name' => '$LANG.tab_modifies', 'visibleCols' => "\$['level']", 'hiddenCols' => isset($msH) ? $msH : null)); $this->extendGlobalData($modSpells->getJSGlobals(GLOBALINFO_SELF | GLOBALINFO_RELATED)); } } // tab: modified by $this $sub = ['OR']; $conditions = [['s.spellFamilyId', $this->subject->getField('spellFamilyId')], &$sub]; for ($i = 1; $i < 4; $i++) { $m1 = $this->subject->getField('spellFamilyFlags1'); $m2 = $this->subject->getField('spellFamilyFlags2'); $m3 = $this->subject->getField('spellFamilyFlags3'); if (!$m1 && !$m2 && !$m3) { continue; } $sub[] = array('AND', ['s.effect' . $i . 'AuraId', [107, 108, 256, 286]], ['OR', ['s.effect1SpellClassMask' . $j[$i], $m1, '&'], ['s.effect2SpellClassMask' . $j[$i], $m2, '&'], ['s.effect3SpellClassMask' . $j[$i], $m3, '&']]); } if (count($sub) > 1) { $modsSpell = new SpellList($conditions); if (!$modsSpell->error) { if (!$modsSpell->hasSetFields(['skillLines'])) { $mbH = "\$['skill']"; } $this->lvTabs[] = array('file' => 'spell', 'data' => $modsSpell->getListviewData(), 'params' => array('id' => 'modified-by', 'name' => '$LANG.tab_modifiedby', 'visibleCols' => "\$['level']", 'hiddenCols' => isset($mbH) ? $mbH : null)); $this->extendGlobalData($modsSpell->getJSGlobals(GLOBALINFO_SELF | GLOBALINFO_RELATED)); } } // tab: see also $conditions = array(['s.schoolMask', $this->subject->getField('schoolMask')], ['s.effect1Id', $this->subject->getField('effect1Id')], ['s.effect2Id', $this->subject->getField('effect2Id')], ['s.effect3Id', $this->subject->getField('effect3Id')], ['s.id', $this->subject->id, '!'], ['s.name_loc' . User::$localeId, $this->subject->getField('name', true)]); $saSpells = new SpellList($conditions); if (!$saSpells->error) { $data = $saSpells->getListviewData(); if ($this->difficulties) { $saE = '$[Listview.extraCols.mode]'; foreach ($data as $id => &$d) { $d['modes'] = ['mode' => 0]; if ($this->difficulties[0] == $id) { if (!$this->difficulties[2] && !$this->difficulties[3]) { $d['modes']['mode'] |= 0x2; } else { $d['modes']['mode'] |= 0x8; } } if ($this->difficulties[1] == $id) { if (!$this->difficulties[2] && !$this->difficulties[3]) { $d['modes']['mode'] |= 0x1; } else { $d['modes']['mode'] |= 0x10; } } if ($this->difficulties[2] == $id) { // b0100000 $d['modes']['mode'] |= 0x20; } if ($this->difficulties[3] == $id) { // b1000000 $d['modes']['mode'] |= 0x40; } } } if (!$saSpells->hasSetFields(['skillLines'])) { $saH = "\$['skill']"; } $this->lvTabs[] = array('file' => 'spell', 'data' => $data, 'params' => array('id' => 'see-also', 'name' => '$LANG.tab_seealso', 'visibleCols' => "\$['level']", 'extraCols' => isset($saE) ? $saE : null, 'hiddenCols' => isset($saH) ? $saH : null)); $this->extendGlobalData($saSpells->getJSGlobals(GLOBALINFO_SELF | GLOBALINFO_RELATED)); } // tab: used by - itemset $conditions = array('OR', ['spell1', $this->subject->id], ['spell2', $this->subject->id], ['spell3', $this->subject->id], ['spell4', $this->subject->id], ['spell5', $this->subject->id], ['spell6', $this->subject->id], ['spell7', $this->subject->id], ['spell8', $this->subject->id]); $ubSets = new ItemsetList($conditions); if (!$ubSets->error) { $this->lvTabs[] = array('file' => 'itemset', 'data' => $ubSets->getListviewData(), 'params' => array('id' => 'used-by-itemset', 'name' => '$LANG.tab_usedby')); $this->extendGlobalData($ubSets->getJSGlobals(GLOBALINFO_SELF | GLOBALINFO_RELATED)); } // tab: used by - item $conditions = array('OR', ['AND', ['spellTrigger1', 6, '!'], ['spellId1', $this->subject->id]], ['AND', ['spellTrigger2', 6, '!'], ['spellId2', $this->subject->id]], ['AND', ['spellTrigger3', 6, '!'], ['spellId3', $this->subject->id]], ['AND', ['spellTrigger4', 6, '!'], ['spellId4', $this->subject->id]], ['AND', ['spellTrigger5', 6, '!'], ['spellId5', $this->subject->id]]); $ubItems = new ItemList($conditions); if (!$ubItems->error) { $this->lvTabs[] = array('file' => 'item', 'data' => $ubItems->getListviewData(), 'params' => array('id' => 'used-by-item', 'name' => '$LANG.tab_usedby')); $this->extendGlobalData($ubItems->getJSGlobals(GLOBALINFO_SELF)); } // tab: used by - object $conditions = array('OR', ['onUseSpell', $this->subject->id], ['onSuccessSpell', $this->subject->id], ['auraSpell', $this->subject->id], ['triggeredSpell', $this->subject->id]); $ubObjects = new GameObjectList($conditions); if (!$ubObjects->error) { $this->lvTabs[] = array('file' => 'object', 'data' => $ubObjects->getListviewData(), 'params' => array('id' => 'used-by-object', 'name' => '$LANG.tab_usedby')); $this->extendGlobalData($ubObjects->getJSGlobals()); } // tab: criteria of $conditions = array(['ac.type', [ACHIEVEMENT_CRITERIA_TYPE_BE_SPELL_TARGET, ACHIEVEMENT_CRITERIA_TYPE_BE_SPELL_TARGET2, ACHIEVEMENT_CRITERIA_TYPE_CAST_SPELL, ACHIEVEMENT_CRITERIA_TYPE_CAST_SPELL2, ACHIEVEMENT_CRITERIA_TYPE_LEARN_SPELL]], ['ac.value1', $this->typeId]); $coAchievemnts = new AchievementList($conditions); if (!$coAchievemnts->error) { $this->lvTabs[] = array('file' => 'achievement', 'data' => $coAchievemnts->getListviewData(), 'params' => array('id' => 'criteria-of', 'name' => '$LANG.tab_criteriaof')); $this->extendGlobalData($coAchievemnts->getJSGlobals(GLOBALINFO_SELF | GLOBALINFO_RELATED)); } // tab: contains // spell_loot_template & skill_extra_item_template $extraItem = DB::World()->selectRow('SELECT * FROM skill_extra_item_template WHERE spellid = ?d', $this->subject->id); $spellLoot = new Loot(); if ($spellLoot->getByContainer(LOOT_SPELL, $this->subject->id) || $extraItem) { $this->extendGlobalData($spellLoot->jsGlobals); $lv = $spellLoot->getResult(); $extraCols = $spellLoot->extraCols; $extraCols[] = 'Listview.extraCols.percent'; if ($extraItem && $this->subject->canCreateItem()) { $foo = $this->subject->relItems->getListviewData(); for ($i = 1; $i < 4; $i++) { if (($bar = $this->subject->getField('effect' . $i . 'CreateItemId')) && isset($foo[$bar])) { $lv[$bar] = $foo[$bar]; $lv[$bar]['percent'] = $extraItem['additionalCreateChance']; $lv[$bar]['condition'][0][$this->typeId][] = [[CND_SPELL, $extraItem['requiredSpecialization']]]; $this->extendGlobalIds(TYPE_SPELL, $extraItem['requiredSpecialization']); $extraCols[] = 'Listview.extraCols.condition'; if ($max = $extraItem['additionalMaxNum']) { $lv[$bar]['mincount'] = 1; $lv[$bar]['maxcount'] = $max; } break; // skill_extra_item_template can only contain 1 item } } } $this->lvTabs[] = array('file' => 'item', 'data' => $lv, 'params' => array('name' => '$LANG.tab_contains', 'id' => 'contains', 'hiddenCols' => "\$['side', 'slot', 'source', 'reqlevel']", 'extraCols' => '$[' . implode(', ', $extraCols) . ']')); } // tab: exclusive with if ($this->firstRank) { $linkedSpells = DB::World()->selectCol('SELECT IF(sg2.spell_id < 0, sg2.id, sg2.spell_id) AS ARRAY_KEY, IF(sg2.spell_id < 0, sg2.spell_id, sr.stack_rule) FROM spell_group sg1 JOIN spell_group sg2 ON (sg1.id = sg2.id OR sg1.id = -sg2.spell_id) AND sg1.spell_id != sg2.spell_id LEFT JOIN spell_group_stack_rules sr ON sg1.id = sr.group_id WHERE sg1.spell_id = ?d', $this->firstRank); if ($linkedSpells) { $extraSpells = []; foreach ($linkedSpells as $k => $v) { if ($v > 0) { continue; } $extraSpells += DB::World()->selectCol('SELECT sg2.spell_id AS ARRAY_KEY, sr.stack_rule FROM spell_group sg1 JOIN spell_group sg2 ON sg2.id = -sg1.spell_id AND sg2.spell_id != ?d LEFT JOIN spell_group_stack_rules sr ON sg1.id = sr.group_id WHERE sg1.id = ?d', $this->firstRank, $k); unset($linkedSpells[$k]); } $groups = $linkedSpells + $extraSpells; $stacks = new SpellList(array(['s.id', array_keys($groups)])); if (!$stacks->error) { $data = $stacks->getListviewData(); foreach ($data as $k => $d) { $data[$k]['stackRule'] = $groups[$k]; } if (!$stacks->hasSetFields(['skillLines'])) { $sH = "\$['skill']"; } $this->lvTabs[] = array('file' => 'spell', 'data' => $data, 'params' => array('id' => 'spell-group-stack', 'name' => 'Stack Group', 'visibleCols' => "\$['stackRules']", 'hiddenCols' => isset($sH) ? $sH : null)); $this->extendGlobalData($stacks->getJSGlobals(GLOBALINFO_SELF | GLOBALINFO_RELATED)); } } } // tab: linked with $rows = DB::World()->select(' SELECT spell_trigger AS `trigger`, spell_effect AS effect, type, IF(ABS(spell_effect) = ?d, ABS(spell_trigger), ABS(spell_effect)) AS related FROM spell_linked_spell WHERE ABS(spell_effect) = ?d OR ABS(spell_trigger) = ?d', $this->typeId, $this->typeId, $this->typeId); $related = []; foreach ($rows as $row) { $related[] = $row['related']; } if ($related) { $linked = new SpellList(array(['s.id', $related])); } if (isset($linked) && !$linked->error) { $lv = $linked->getListviewData(); $data = []; foreach ($rows as $r) { foreach ($lv as $dk => $d) { if ($r['related'] != $dk) { continue; } $lv[$dk]['linked'] = [$r['trigger'], $r['effect'], $r['type']]; $data[] = $lv[$dk]; break; } } $this->lvTabs[] = array('file' => 'spell', 'data' => $data, 'params' => array('id' => 'spell-link', 'name' => 'Linked with', 'hiddenCols' => "\$['skill', 'name']", 'visibleCols' => "\$['linkedTrigger', 'linkedEffect']")); $this->extendGlobalData($linked->getJSGlobals(GLOBALINFO_SELF | GLOBALINFO_RELATED)); } // tab: triggered by $conditions = array('OR', ['AND', ['OR', ['effect1Id', SpellList::$effects['trigger']], ['effect1AuraId', SpellList::$auras['trigger']]], ['effect1TriggerSpell', $this->subject->id]], ['AND', ['OR', ['effect2Id', SpellList::$effects['trigger']], ['effect2AuraId', SpellList::$auras['trigger']]], ['effect2TriggerSpell', $this->subject->id]], ['AND', ['OR', ['effect3Id', SpellList::$effects['trigger']], ['effect3AuraId', SpellList::$auras['trigger']]], ['effect3TriggerSpell', $this->subject->id]]); $trigger = new SpellList($conditions); if (!$trigger->error) { $this->lvTabs[] = array('file' => 'spell', 'data' => $trigger->getListviewData(), 'params' => array('id' => 'triggered-by', 'name' => '$LANG.tab_triggeredby')); $this->extendGlobalData($trigger->getJSGlobals(GLOBALINFO_SELF)); } // tab: used by - creature // SMART_SCRIPT_TYPE_CREATURE = 0; SMART_ACTION_CAST = 11; SMART_ACTION_ADD_AURA = 75; SMART_ACTION_INVOKER_CAST = 85; SMART_ACTION_CROSS_CAST = 86 $conditions = array('OR', ['spell1', $this->typeId], ['spell2', $this->typeId], ['spell3', $this->typeId], ['spell4', $this->typeId], ['spell5', $this->typeId], ['spell6', $this->typeId], ['spell7', $this->typeId], ['spell8', $this->typeId]); if ($_ = DB::World()->selectCol('SELECT entryOrGUID FROM smart_scripts WHERE entryorguid > 0 AND source_type = 0 AND action_type IN (11, 75, 85, 86) AND action_param1 = ?d', $this->typeId)) { $conditions[] = ['id', $_]; } $ubCreature = new CreatureList($conditions); if (!$ubCreature->error) { $this->lvTabs[] = array('file' => 'creature', 'data' => $ubCreature->getListviewData(), 'params' => array('id' => 'used-by-npc', 'name' => '$LANG.tab_usedby')); $this->extendGlobalData($ubCreature->getJSGlobals(GLOBALINFO_SELF)); } // tab: zone if ($areas = DB::World()->select('SELECT * FROM spell_area WHERE spell = ?d', $this->typeId)) { $zones = new ZoneList(array(['id', array_column($areas, 'area')])); if (!$zones->error) { $lvZones = $zones->getListviewData(); $this->extendGlobalData($zones->getJSGlobals()); $lv = []; $parents = []; $extra = false; foreach ($areas as $a) { if (empty($lvZones[$a['area']])) { continue; } $condition = []; if ($a['aura_spell']) { $this->extendGlobalIds(TYPE_SPELL, abs($a['aura_spell'])); $condition[0][$this->typeId][] = [[$a['aura_spell'] > 0 ? CND_AURA : -CND_AURA, abs($a['aura_spell'])]]; } if ($a['quest_start']) { $this->extendGlobalIds(TYPE_QUEST, $a['quest_start']); $group = []; for ($i = 0; $i < 7; $i++) { if (!($a['quest_start_status'] & 1 << $i)) { continue; } if ($i == 0) { $group[] = [CND_QUEST_NONE, $a['quest_start']]; } else { if ($i == 1) { $group[] = [CND_QUEST_COMPLETE, $a['quest_start']]; } else { if ($i == 3) { $group[] = [CND_QUESTTAKEN, $a['quest_start']]; } else { if ($i == 6) { $group[] = [CND_QUESTREWARDED, $a['quest_start']]; } } } } } if ($group) { $condition[0][$this->typeId][] = $group; } } if ($a['quest_end'] && $a['quest_end'] != $a['quest_start']) { $this->extendGlobalIds(TYPE_QUEST, $a['quest_end']); $group = []; for ($i = 0; $i < 7; $i++) { if (!($a['quest_end_status'] & 1 << $i)) { continue; } if ($i == 0) { $group[] = [-CND_QUEST_NONE, $a['quest_end']]; } else { if ($i == 1) { $group[] = [-CND_QUEST_COMPLETE, $a['quest_end']]; } else { if ($i == 3) { $group[] = [-CND_QUESTTAKEN, $a['quest_end']]; } else { if ($i == 6) { $group[] = [-CND_QUESTREWARDED, $a['quest_end']]; } } } } } if ($group) { $condition[0][$this->typeId][] = $group; } } if ($a['racemask']) { $foo = []; for ($i = 0; $i < 11; $i++) { if ($a['racemask'] & 1 << $i) { $foo[] = $i + 1; } } $this->extendGlobalIds(TYPE_RACE, $foo); $condition[0][$this->typeId][] = [[CND_RACE, $a['racemask']]]; } if ($a['gender'] != 2) { // 2: both $condition[0][$this->typeId][] = [[CND_GENDER, $a['gender'] + 1]]; } $row = $lvZones[$a['area']]; if ($condition) { $extra = true; $row = array_merge($row, ['condition' => $condition]); } // merge subzones, into one row, if: conditions match && parentZone is shared if ($p = $zones->getEntry($a['area'])['parentArea']) { $parents[] = $p; $row['parentArea'] = $p; $row['subzones'] = [$a['area']]; } else { $row['parentArea'] = 0; } $set = false; foreach ($lv as &$v) { if ($v['parentArea'] != $row['parentArea'] && $v['id'] != $row['parentArea']) { continue; } if (empty($v['condition']) xor empty($row['condition'])) { continue; } if (!empty($row['condition']) && !empty($v['condition']) && $v['condition'] != $row['condition']) { continue; } if (!$row['parentArea'] && $v['id'] != $row['parentArea']) { continue; } $set = true; $v['subzones'][] = $row['id']; break; } // add self as potential subzone; IF we are a parentZone without added children, we get filtered in JScript if (!$set) { $row['subzones'] = [$row['id']]; $lv[] = $row; } } // overwrite lvData with parent-lvData (condition and subzones are kept) if ($parents) { $parents = (new ZoneList(array(['id', $parents])))->getListviewData(); foreach ($lv as &$_) { if (isset($parents[$_['parentArea']])) { $_ = array_merge($_, $parents[$_['parentArea']]); } } } $this->lvTabs[] = array('file' => 'zone', 'data' => $lv, 'params' => array('extraCols' => $extra ? '$[Listview.extraCols.condition]' : null, 'hiddenCols' => $extra ? "\$['instancetype']" : null)); } } // tab: teaches if ($ids = Util::getTaughtSpells($this->subject)) { $teaches = new SpellList(array(['id', $ids])); if (!$teaches->error) { $this->extendGlobalData($teaches->getJSGlobals(GLOBALINFO_SELF | GLOBALINFO_RELATED)); $vis = ['level', 'schools']; $hid = []; if (!$teaches->hasSetFields(['skillLines'])) { $hid[] = 'skill'; } foreach ($teaches->iterate() as $__) { if (!$teaches->canCreateItem()) { continue; } $vis[] = 'reagents'; break; } $this->lvTabs[] = array('file' => 'spell', 'data' => $teaches->getListviewData(), 'params' => array('id' => 'teaches-spell', 'name' => '$LANG.tab_teaches', 'visibleCols' => '$' . Util::toJSON($vis), 'hiddenCols' => $hid ? '$' . Util::toJSON($hid) : null)); } } // tab: taught by npc (source:6 => trainer) if (!empty($this->subject->sources[$this->typeId][6])) { $src = $this->subject->sources[$this->typeId][6]; $list = []; if (count($src) == 1 && $src[0] == 1) { $tt = null; // Professions if (in_array($_cat, [9, 11]) && isset(Util::$trainerTemplates[TYPE_SKILL][$this->subject->getField('skillLines')[0]])) { $tt = Util::$trainerTemplates[TYPE_SKILL][$this->subject->getField('skillLines')[0]]; } else { if ($_cat == 7 && $this->subject->getField('reqClassMask')) { $clId = log($this->subject->getField('reqClassMask'), 2) + 1; if (intVal($clId) == $clId) { // only one class was set, so float == int if (isset(Util::$trainerTemplates[TYPE_CLASS][$clId])) { $tt = Util::$trainerTemplates[TYPE_CLASS][$clId]; } } } } if ($tt) { $list = DB::World()->selectCol('SELECT DISTINCT ID FROM npc_trainer WHERE SpellID IN (?a) AND ID < 200000', $tt); } else { $mask = 0; foreach (Util::$skillLineMask[-3] as $idx => $pair) { if ($pair[1] == $this->typeId) { $mask |= 1 << $idx; } } $list = DB::World()->selectCol(' SELECT IF(t1.ID > 200000, t2.ID, t1.ID) FROM npc_trainer t1 LEFT JOIN npc_trainer t2 ON t2.SpellID = -t1.ID WHERE t1.SpellID = ?d', $this->typeId); } } else { if ($src) { $list = array_values($src); } } if ($list) { $tbTrainer = new CreatureList(array(CFG_SQL_LIMIT_NONE, ['ct.id', $list], ['s.guid', NULL, '!'], ['ct.npcflag', 0x10, '&'])); if (!$tbTrainer->error) { $this->extendGlobalData($tbTrainer->getJSGlobals()); $this->lvTabs[] = array('file' => 'creature', 'data' => $tbTrainer->getListviewData(), 'params' => array('id' => 'taught-by-npc', 'name' => '$LANG.tab_taughtby')); } } } // tab: taught by spell $conditions = array('OR', ['AND', ['effect1Id', SpellList::$effects['teach']], ['effect1TriggerSpell', $this->subject->id]], ['AND', ['effect2Id', SpellList::$effects['teach']], ['effect2TriggerSpell', $this->subject->id]], ['AND', ['effect3Id', SpellList::$effects['teach']], ['effect3TriggerSpell', $this->subject->id]]); $tbSpell = new SpellList($conditions); $tbsData = []; if (!$tbSpell->error) { $tbsData = $tbSpell->getListviewData(); $this->lvTabs[] = array('file' => 'spell', 'data' => $tbsData, 'params' => array('id' => 'taught-by-spell', 'name' => '$LANG.tab_taughtby')); $this->extendGlobalData($tbSpell->getJSGlobals(GLOBALINFO_SELF)); } // tab: taught by quest $conditions = ['OR', ['sourceSpellId', $this->typeId], ['rewardSpell', $this->typeId]]; if ($tbsData) { $conditions[] = ['rewardSpell', array_keys($tbsData)]; if (User::isInGroup(U_GROUP_EMPLOYEE)) { $conditions[] = ['rewardSpellCast', array_keys($tbsData)]; } } if (User::isInGroup(U_GROUP_EMPLOYEE)) { $conditions[] = ['rewardSpellCast', $this->typeId]; } $tbQuest = new QuestList($conditions); if (!$tbQuest->error) { $this->lvTabs[] = array('file' => 'quest', 'data' => $tbQuest->getListviewData(), 'params' => array('id' => 'reward-from-quest', 'name' => '$LANG.tab_rewardfrom')); $this->extendGlobalData($tbQuest->getJSGlobals()); } // tab: taught by item (i'd like to precheck $this->subject->sources, but there is no source:item only complicated crap like "drop" and "vendor") $conditions = array('OR', ['AND', ['spellTrigger1', 6], ['spellId1', $this->subject->id]], ['AND', ['spellTrigger2', 6], ['spellId2', $this->subject->id]], ['AND', ['spellTrigger3', 6], ['spellId3', $this->subject->id]], ['AND', ['spellTrigger4', 6], ['spellId4', $this->subject->id]], ['AND', ['spellTrigger5', 6], ['spellId5', $this->subject->id]]); $tbItem = new ItemList($conditions); if (!$tbItem->error) { $this->lvTabs[] = array('file' => 'item', 'data' => $tbItem->getListviewData(), 'params' => array('id' => 'taught-by-item', 'name' => '$LANG.tab_taughtby')); $this->extendGlobalData($tbItem->getJSGlobals(GLOBALINFO_SELF)); } // tab: enchantments $conditions = array('OR', ['AND', ['type1', [1, 3, 7]], ['object1', $this->typeId]], ['AND', ['type2', [1, 3, 7]], ['object2', $this->typeId]], ['AND', ['type3', [1, 3, 7]], ['object3', $this->typeId]]); $enchList = new EnchantmentList($conditions); if (!$enchList->error) { $this->lvTabs[] = array('file' => 'enchantment', 'data' => $enchList->getListviewData(), 'params' => []); $this->extendGlobalData($enchList->getJSGlobals()); } // find associated NPC, Item and merge results // taughtbypets (unused..?) // taughtbyquest (usually the spell casted as quest reward teaches something; exclude those seplls from taughtBySpell) // taughtbytrainers // taughtbyitem // tab: conditions $sc = Util::getServerConditions([CND_SRC_SPELL_LOOT_TEMPLATE, CND_SRC_SPELL_IMPLICIT_TARGET, CND_SRC_SPELL, CND_SRC_SPELL_CLICK_EVENT, CND_SRC_VEHICLE_SPELL, CND_SRC_SPELL_PROC], null, $this->typeId); if (!empty($sc[0])) { $this->extendGlobalData($sc[1]); $tab = "<script type=\"text/javascript\">\n" . "var markup = ConditionList.createTab(" . Util::toJSON($sc[0]) . ");\n" . "Markup.printHtml(markup, 'tab-conditions', { allow: Markup.CLASS_STAFF })" . "</script>"; $this->lvTabs[] = array('file' => null, 'data' => $tab, 'params' => array('id' => 'conditions', 'name' => '$LANG.requires')); } }
private function createGemScores() { $gemScores = []; if (empty($this->filter['fi']['setWeights'])) { return []; } if (!empty($this->filter['gm'])) { $this->sharedLV['computeDataFunc'] = '$fi_scoreSockets'; $q = intVal($this->filter['gm']); $mask = 14; $cnd = [10, ['class', ITEM_CLASS_GEM], ['gemColorMask', &$mask, '&'], ['quality', &$q]]; if (!isset($this->filter['jc'])) { $cnd[] = ['itemLimitCategory', 0]; } // Jeweler's Gems if ($this->filterObj->wtCnd) { $cnd[] = $this->filterObj->wtCnd; } $anyColor = new ItemList($cnd, ['extraOpts' => $this->filterObj->extraOpts]); if (!$anyColor->error) { $this->extendGlobalData($anyColor->getJSGlobals()); $gemScores[0] = array_values($anyColor->getListviewData(ITEMINFO_GEM)); } for ($i = 0; $i < 4; $i++) { $mask = 1 << $i; $q = !$i ? 3 : intVal($this->filter['gm']); // meta gems are always included.. ($q is backReferenced) $byColor = new ItemList($cnd, ['extraOpts' => $this->filterObj->extraOpts]); if (!$byColor->error) { $this->extendGlobalData($byColor->getJSGlobals()); $gemScores[$mask] = array_values($byColor->getListviewData(ITEMINFO_GEM)); } } } $this->sharedLV['onBeforeCreate'] = '$fi_initWeightedListview'; $this->sharedLV['onAfterCreate'] = '$fi_addUpgradeIndicator'; $this->sharedLV['sort'] = ['-score', 'name']; array_push($this->sharedLV['hiddenCols'], 'type', 'source'); return $gemScores; }
private function _searchItem($cndBase, &$shared) { $result = []; $miscData = []; $cndAdd = empty($this->query) ? [] : (is_int($this->query) ? ['id', $this->query] : $this->createLookup()); if ($this->searchMask & SEARCH_TYPE_JSON && $this->searchMask & 0x20 && !empty($shared['pcsToSet'])) { $cnd = [['i.id', array_keys($shared['pcsToSet'])], CFG_SQL_LIMIT_NONE]; $miscData = ['pcsToSet' => $shared['pcsToSet']]; } else { if ($this->searchMask & SEARCH_TYPE_JSON && $this->searchMask & 0x40) { $cnd = $cndBase; $cnd[] = ['i.class', [ITEM_CLASS_WEAPON, ITEM_CLASS_GEM, ITEM_CLASS_ARMOR]]; $cnd[] = $cndAdd; $slots = isset($_GET['slots']) ? explode(':', $_GET['slots']) : []; array_walk($slots, function (&$v, $k) { $v = intVal($v); }); if ($_ = array_filter($slots)) { $cnd[] = ['slot', $_]; } $itemFilter = new ItemListFilter(); if ($_ = $itemFilter->createConditionsForWeights($this->statWeight)) { $miscData['extraOpts'] = $itemFilter->extraOpts; $cnd = array_merge($cnd, [$_]); } } else { $cnd = array_merge($cndBase, [$cndAdd]); } } $items = new ItemList($cnd, $miscData); if ($data = $items->getListviewData($this->searchMask & SEARCH_TYPE_JSON ? ITEMINFO_SUBITEMS | ITEMINFO_JSON : 0)) { if ($this->searchMask & SEARCH_TYPE_REGULAR) { $this->extendGlobalData($items->getJSGlobals()); } if ($this->searchMask & SEARCH_TYPE_OPEN) { foreach ($items->iterate() as $__) { $data[$items->id]['param1'] = $items->getField('iconString'); $data[$items->id]['param2'] = $items->getField('quality'); } } $result = array('type' => TYPE_ITEM, 'appendix' => ' (Item)', 'matches' => $items->getMatches(), 'file' => ItemList::$brickFile, 'data' => $data, 'params' => []); if ($items->getMatches() > $this->maxResults) { $result['params']['note'] = sprintf(Util::$tryNarrowingString, 'LANG.lvnote_itemsfound', $items->getMatches(), $this->maxResults); $result['params']['_truncated'] = 1; } if (isset($result['params']['note'])) { $result['params']['note'] .= ' + LANG.dash + $WH.sprintf(LANG.lvnote_filterresults, \'?items&filter=na=' . urlencode($this->search) . '\')'; } else { $result['params']['note'] = '$$WH.sprintf(LANG.lvnote_filterresults, \'?items&filter=na=' . urlencode($this->search) . '\')'; } } return $result; }
protected function handleLoad() { /* params id: profileId items: string [itemIds.join(':')] unnamed: unixtime [only to force the browser to reload instead of cache] return lots... */ // titles, achievements, characterData, talents (, pets) // and some onLoad-hook to .. load it registerProfile($data) // everything else goes through data.php .. strangely enough if (!$this->_get['id']) { return; } $char = new ProfileList(array(['id', $this->_get['id'][0]])); // or string or whatever $buff = ''; if ($it = array_column($char->getField('inventory'), 0)) { $itemz = new ItemList(array(['id', $it, CFG_SQL_LIMIT_NONE])); $data = $itemz->getListviewData(ITEMINFO_JSON | ITEMINFO_SUBITEMS); // get and apply inventory foreach ($itemz->iterate() as $iId => $__) { $buff .= 'g_items.add(' . $iId . ', {name_' . User::$localeString . ":'" . Util::jsEscape($itemz->getField('name', true)) . "', quality:" . $itemz->getField('quality') . ", icon:'" . $itemz->getField('iconString') . "', jsonequip:" . Util::toJSON($data[$iId]) . "});\n"; } $buff .= "\n"; } if ($au = $char->getField('auras')) { $auraz = new SpellList(array(['id', $char->getField('auras')], CFG_SQL_LIMIT_NONE)); $dataz = $auraz->getListviewData(); $modz = $auraz->getProfilerMods(); // get and apply aura-mods foreach ($dataz as $id => $data) { $mods = []; if (!empty($modz[$id])) { foreach ($modz[$id] as $k => $v) { if (is_array($v)) { $mods[] = $v; } else { if ($str = @Util::$itemMods[$k]) { $mods[$str] = $v; } } } } $buff .= 'g_spells.add(' . $id . ", {id:" . $id . ", name:'" . Util::jsEscape(mb_substr($data['name'], 1)) . "', icon:'" . $data['icon'] . "', modifier:" . Util::toJSON($mods) . "});\n"; } $buff .= "\n"; } /* depending on progress-achievements // required by progress in JScript move to handleLoad()? Util::$pageTemplate->extendGlobalIds(TYPE_NPC, [29120, 31134, 29306, 29311, 23980, 27656, 26861, 26723, 28923, 15991]); */ // load available titles Util::loadStaticFile('p-titles-' . $char->getField('gender'), $buff, true); // load available achievements if (!Util::loadStaticFile('p-achievements', $buff, true)) { $buff .= "\n\ng_achievement_catorder = [];"; $buff .= "\n\ng_achievement_points = [0];"; } // excludes; structure UNK type => [maskBit => [typeIds]] ? /* g_user.excludes = [type:[typeIds]] g_user.includes = [type:[typeIds]] g_user.excludegroups = groupMask // requires g_user.settings != null maskBit are matched against fieldId from excludeGroups id: 1, label: LANG.dialog_notavail id: 2, label: LANG.dialog_tcg id: 4, label: LANG.dialog_collector id: 8, label: LANG.dialog_promo id: 16, label: LANG.dialog_nonus id: 96, label: LANG.dialog_faction id: 896, label: LANG.dialog_profession id: 1024, label: LANG.dialog_noexalted */ // $buff .= "\n\ng_excludes = {};"; // add profile to buffer $buff .= "\n\n\$WowheadProfiler.registerProfile(" . Util::toJSON($char->getEntry(2)) . ");"; // can't use JSON_NUMERIC_CHECK or the talent-string becomes a float return $buff . "\n"; }