From 9c9d03dbb844d00e81853fe9e8e33c7c16f460d7 Mon Sep 17 00:00:00 2001 From: Sarjuuk Date: Sat, 6 Jul 2013 16:33:30 +0200 Subject: [PATCH] Achievement: - improved handling of rewards Spell: - moved calcuation of effectValue to separate function, use realPointsPerLevel - eval: applied proper format, fixed evalable string when facing multiple signs in a row - display modelviewer for summons Titles: - looks like titles behave differently when using "faction" or "side" Achievement: - implemented rewards (which i have forgotten for almost 2 years) * reworked pet-setup * typos and forgotten changes, that broke code here and there --- includes/class.achievement.php | 51 ++++++------- includes/class.creature.php | 4 +- includes/class.spell.php | 67 ++++++++++++----- includes/class.title.php | 22 ++++++ localization/locale_frfr.php | 2 +- pages/achievement.php | 32 ++++++-- pages/itemset.php | 4 +- pages/npc.php | 4 +- pages/spell.php | 20 +++-- setup/tools/dataset-assembler/talents.php | 17 +++-- setup/tools/sql/_pet.php | 89 +++++++++++++++++------ template/bricks/listviews/creature.tpl | 2 +- template/js/global.js | 27 ------- 13 files changed, 219 insertions(+), 122 deletions(-) diff --git a/includes/class.achievement.php b/includes/class.achievement.php index ee92c8dc..c8668e70 100644 --- a/includes/class.achievement.php +++ b/includes/class.achievement.php @@ -24,15 +24,19 @@ class AchievementList extends BaseType $this->templates[$this->id]['iconString'] = 'INV_Misc_QuestionMark'; //"rewards":[[11,137],[3,138]] [type, typeId] + $rewards = [TYPE_ITEM => [], TYPE_TITLE => []]; if (!empty($this->curTpl['rewardIds'])) { - $rewards = []; $rewIds = explode(" ", $this->curTpl['rewardIds']); foreach ($rewIds as $rewId) - $rewards[] = ($rewId > 0 ? [TYPE_ITEM => $rewId] : ($rewId < 0 ? [TYPE_TITLE => -$rewId] : NULL)); - - $this->templates[$this->id]['rewards'] = $rewards; + { + if ($rewId > 0) + $rewards[TYPE_ITEM][] = $rewId; + else if ($rewId < 0) + $rewards[TYPE_TITLE][] = -$rewId; + } } + $this->templates[$this->id]['rewards'] = $rewards; } $this->reset(); // restore 'iterator' @@ -40,27 +44,23 @@ class AchievementList extends BaseType public function addRewardsToJScript(&$refs) { - // collect Ids to execute in single query - $lookup = []; + $items = []; + $titles = []; while ($this->iterate()) { - $rewards = explode(" ", $this->curTpl['rewardIds']); + foreach ($this->curTpl['rewards'][TYPE_ITEM] as $_) + $items[] = $_; - foreach ($rewards as $reward) - { - if ($reward > 0) - $lookup['item'][] = $reward; - else if ($reward < 0) - $lookup['title'][] = -$reward; - } + foreach ($this->curTpl['rewards'][TYPE_TITLE] as $_) + $titles[] = $_; } - if (isset($lookup['item'])) - (new ItemList(array(['i.entry', array_unique($lookup['item'])])))->addGlobalsToJscript($refs); + if ($items) + (new ItemList(array(['i.entry', $items])))->addGlobalsToJscript($refs); - if (isset($lookup['title'])) - (new TitleList(array(['id', array_unique($lookup['title'])])))->addGlobalsToJscript($refs); + if ($titles) + (new TitleList(array(['id', $titles])))->addGlobalsToJscript($refs); } public function addGlobalsToJscript(&$refs) @@ -97,18 +97,15 @@ class AchievementList extends BaseType if ($this->curTpl['flags'] & ACHIEVEMENT_FLAG_COUNTER && $this->curTpl['parentCat'] != 1) $data[$this->id]['type'] = 1; - if (!empty($this->curTpl['rewards'])) - { - $rewards = []; - - foreach ($this->curTpl['rewards'] as $pair) - $rewards[] = '['.key($pair).','.current($pair).']'; + $rewards = []; + foreach ($this->curTpl['rewards'] as $type => $rIds) + foreach ($rIds as $rId) + $rewards[] = '['.$type.','.$rId.']'; + if ($rewards) $data[$this->id]['rewards'] = '['.implode(',', $rewards).']'; - } - else if (!empty ($this->curTpl['reward'])) + else if (!empty($this->curTpl['reward'])) $data[$this->id]['reward'] = Util::localizedString($this->curTpl, 'reward'); - } return $data; diff --git a/includes/class.creature.php b/includes/class.creature.php index 680c0948..433b8b37 100644 --- a/includes/class.creature.php +++ b/includes/class.creature.php @@ -17,7 +17,7 @@ class CreatureList extends BaseType { $n = DB::Aowow()->SelectRow(' SELECT - name, + name_loc0, name_loc2, name_loc3, name_loc6, @@ -85,7 +85,7 @@ class CreatureList extends BaseType $data = []; for ($i = 1; $i < 5; $i++) - if ($_ = $this->curTpl['modelid'.$i]) + if ($_ = $this->curTpl['displayId'.$i]) $data[] = $_; return !$data ? 0 : $data[array_rand($data)]; diff --git a/includes/class.spell.php b/includes/class.spell.php index 8cf37fa1..56e77df0 100644 --- a/includes/class.spell.php +++ b/includes/class.spell.php @@ -420,6 +420,44 @@ class SpellList extends BaseType return ''; } + // formulae base from TC + private function calculateAmountForCurrent($effIdx, $altTpl = null) + { + $ref = $altTpl ? $altTpl : $this; + $level = $this->charLevel; + $rppl = $ref->getField('effect'.$effIdx.'RealPointsPerLevel'); + $base = $ref->getField('effect'.$effIdx.'BasePoints'); + $add = $ref->getField('effect'.$effIdx.'DieSides'); + $maxLvl = $ref->getField('maxLevel'); + $baseLvl = $ref->getField('baseLevel'); + + if ($this->curTpl['attributes1'] & 0x200) // never a referenced spell, ALWAYS $this; SPELL_ATTR1_MELEE_COMBAT_SPELL: 0x200 + { + if ($level > $maxLvl && $maxLvl > 0) + $level = $maxLvl; + else if ($level < $baseLvl) + $level = $baseLvl; + + $level -= $ref->getField('spellLevel'); + $base += (int)($level * $rppl); + } + + switch ($add) // roll in a range <1;EffectDieSides> as of patch 3.3.3 + { + case 0: + case 1: // range 1..1 + return [ + $base + $add, + $base + $add + ]; + default: + return [ + $base + 1, + $base + $add + ]; + } + } + // description-, buff-parsing component private function resolveEvaluation($formula) { @@ -479,6 +517,9 @@ class SpellList extends BaseType return eval('return '.$formula.';'); } + // hm, minor eval-issue. eval doesnt understand two operators without a space between them (eg. spelll: 18126) + $formula = preg_replace('/(\+|-|\*|\/)(\+|-|\*|\/)/i', '\1 \2', $formula); + // there should not be any letters without a leading $ return eval('return '.$formula.';'); } @@ -656,15 +697,13 @@ class SpellList extends BaseType case 'O': if ($lookup) { - $base = $this->refSpells[$lookup]->getField('effect'.$effIdx.'BasePoints'); - $add = $this->refSpells[$lookup]->getField('effect'.$effIdx.'DieSides'); + list($min, $max) = $this->calculateAmountForCurrent($effIdx, $this->refSpells[$lookup]); $periode = $this->refSpells[$lookup]->getField('effect'.$effIdx.'Periode'); $duration = $this->refSpells[$lookup]->getField('duration'); } else { - $base = $this->getField('effect'.$effIdx.'BasePoints'); - $add = $this->getField('effect'.$effIdx.'DieSides'); + list($min, $max) = $this->calculateAmountForCurrent($effIdx); $periode = $this->getField('effect'.$effIdx.'Periode'); $duration = $this->getField('duration'); } @@ -672,12 +711,11 @@ class SpellList extends BaseType if (!$periode) $periode = 3000; - $tick = $duration / $periode; - $min = abs($base + 1) * $tick; - $max = abs($base + $add) * $tick; + $min *= $duration / $periode; + $max *= $duration / $periode; $equal = $min == $max; - if (in_array($op, $signs) && is_numeric($oparg) && is_numeric($base)) + if (in_array($op, $signs) && is_numeric($oparg)) if ($equal) eval("\$min = $min $op $oparg;"); @@ -708,24 +746,19 @@ class SpellList extends BaseType case 'S': if ($lookup) { - $base = $this->refSpells[$lookup]->getField('effect'.$effIdx.'BasePoints'); - $add = $this->refSpells[$lookup]->getField('effect'.$effIdx.'DieSides'); + list($min, $max) = $this->calculateAmountForCurrent($effIdx, $this->refSpells[$lookup]); $mv = $this->refSpells[$lookup]->getField('effect'.$effIdx.'MiscValue'); $aura = $this->refSpells[$lookup]->getField('effect'.$effIdx.'AuraId'); } else { - $base = $this->getField('effect'.$effIdx.'BasePoints'); - $add = $this->getField('effect'.$effIdx.'DieSides'); + list($min, $max) = $this->calculateAmountForCurrent($effIdx); $mv = $this->getField('effect'.$effIdx.'MiscValue'); $aura = $this->getField('effect'.$effIdx.'AuraId'); } - - $min = abs($base + 1); - $max = abs($base + $add); $equal = $min == $max; - if (in_array($op, $signs) && is_numeric($oparg) && is_numeric($base)) + if (in_array($op, $signs) && is_numeric($oparg)) if ($equal) eval("\$min = $min $op $oparg;"); @@ -878,7 +911,7 @@ class SpellList extends BaseType // step 3: try to evaluate result $evaled = $this->resolveEvaluation($str); - $return = is_numeric($evaled) ? number_format($evaled, $precision) : $evaled; + $return = is_numeric($evaled) ? number_format($evaled, $precision, '.', '') : $evaled; return $return.$suffix; } diff --git a/includes/class.title.php b/includes/class.title.php index 319ab976..b3be735e 100644 --- a/includes/class.title.php +++ b/includes/class.title.php @@ -107,13 +107,27 @@ class TitleList extends BaseType // Quest-source if (isset($src[4])) + { foreach ($src[4] as $s) + { + if (isset($sources[4][$s]['s'])) + $this->faction2Side($sources[4][$s]['s']); + $tmp[4][] = $sources[4][$s]; + } + } // Achievement-source if (isset($src[12])) + { foreach ($src[12] as $s) + { + if (isset($sources[12][$s]['s'])) + $this->faction2Side($sources[12][$s]['s']); + $tmp[12][] = $sources[12][$s]; + } + } // other source (only one item possible, so no iteration needed) if (isset($src[13])) @@ -131,6 +145,14 @@ class TitleList extends BaseType public function addRewardsToJScript(&$ref) { } public function renderTooltip() { } + + private function faction2Side(&$faction) // thats weird.. and hopefully unique to titles + { + if ($faction == 2) // Horde + $faction = 0; + else if ($faction != 1) // Alliance + $faction = 3; // Both + } } ?> diff --git a/localization/locale_frfr.php b/localization/locale_frfr.php index 227f0764..327398a0 100644 --- a/localization/locale_frfr.php +++ b/localization/locale_frfr.php @@ -240,7 +240,7 @@ $lang = array( ) ), 'pet' => array( - 'exotic' => "Exotique" + 'exotic' => "Exotique", "cat" => ["Férocité", "Tenacité", "Ruse"] ), 'itemset' => array( diff --git a/pages/achievement.php b/pages/achievement.php index 59ab56d6..7bfe2176 100644 --- a/pages/achievement.php +++ b/pages/achievement.php @@ -82,10 +82,10 @@ if (!$smarty->loadCache($cacheKeyPage, $pageData)) // infobox content switch ($acv->getField('faction')) { - case 0: + case 1: $pageData['infoBox'][] = Lang::$main['side'].': '.Lang::$game['si'][SIDE_ALLIANCE].''; break; - case 1: + case 2: $pageData['infoBox'][] = Lang::$main['side'].': '.Lang::$game['si'][SIDE_HORDE].''; break; default: // case 3 @@ -106,7 +106,8 @@ if (!$smarty->loadCache($cacheKeyPage, $pageData)) $pageData['page']['saParams'] = array( 'id' => 'see-also', 'name' => '$LANG.tab_seealso', - 'visibleCols' => "$['category']" + 'visibleCols' => "$['category']", + 'tabs' => '$tabsRelated' ); $saList->addRewardsToJscript($pageData); @@ -124,7 +125,8 @@ if (!$smarty->loadCache($cacheKeyPage, $pageData)) $pageData['page']['coParams'] = array( 'id' => 'criteria-of', 'name' => '$LANG.tab_criteriaof', - 'visibleCols' => "$['category']" + 'visibleCols' => "$['category']", + 'tabs' => '$tabsRelated' ); $coList->addRewardsToJscript($pageData); @@ -135,8 +137,24 @@ if (!$smarty->loadCache($cacheKeyPage, $pageData)) $pageData['page']['titleReward'] = []; $pageData['page']['itemReward'] = []; - foreach ($pageData['page']['titleReward'] as $k => $v) - $pageData['page']['titleReward'][$k] = sprintf(Lang::$achievement['titleReward'], $k, trim(str_replace('%s', '', $v['name']))); + if ($foo = $acv->getField('rewards')[TYPE_ITEM]) + { + $bar = new ItemList(array(['i.entry', $foo])); + while ($bar->iterate()) + { + $pageData['page']['itemReward'][$bar->id] = array( + 'name' => $bar->getField('name', true), + 'quality' => $bar->getField('Quality') + ); + } + } + + if ($foo = $acv->getField('rewards')[TYPE_TITLE]) + { + $bar = new TitleList(array(['id', $foo])); + while ($bar->iterate()) + $pageData['page']['titleReward'][] = sprintf(Lang::$achievement['titleReward'], $bar->id, trim(str_replace('%s', '', $bar->getField('male', true)))); + } // ***** // ACHIEVEMENT CRITERIA @@ -296,7 +314,7 @@ if (!$smarty->loadCache($cacheKeyPage, $pageData)) break; // link to faction (/w target reputation) case ACHIEVEMENT_CRITERIA_TYPE_GAIN_REPUTATION: - $crtName = Faction::getName($obj); + $crtName = FactionList::getName($obj); $tmp['link'] = array( 'href' => '?faction='.$obj, 'text' => $crtName ? $crtName : $crtName, diff --git a/pages/itemset.php b/pages/itemset.php index 90cf8983..56a61098 100644 --- a/pages/itemset.php +++ b/pages/itemset.php @@ -145,7 +145,7 @@ if (!$smarty->loadCache($cacheKeyPage, $pageData)) if ($mask & (1 << $i)) { if ($mask == (1 << $i)) // only bit set, add path - $path[] = $i; + $path[] = $i + 1; break; // break anyway (cant set multiple classes) } @@ -189,7 +189,7 @@ if (!$smarty->loadCache($cacheKeyPage, $pageData)) if ($ta && count($path) == 3) { $rel[] = ['id', $id, '!']; - $rel[] = ['classMask', 1 << end($path), '&']; + $rel[] = ['classMask', 1 << (end($path) - 1), '&']; $rel[] = ['contentGroup', (int)$ta]; } else if ($ev) diff --git a/pages/npc.php b/pages/npc.php index 11553d05..473b6069 100644 --- a/pages/npc.php +++ b/pages/npc.php @@ -20,7 +20,7 @@ if (isset($_GET['power'])) if (!$smarty->loadCache($cacheKeyTooltip, $x)) { - $npc = new CreatureList(array(['ct.entry', $id])); + $npc = new CreatureList(array(['ct.id', $id])); if ($npc->error) die('$WowheadPower.registerNpc(\''.$id.'\', '.User::$localeId.', {})'); @@ -41,7 +41,7 @@ if (isset($_GET['power'])) // regular page if (!$smarty->loadCache($cacheKeyPage, $pageData)) { - $npc = new CreatureList(array(['ct.entry', $id])); + $npc = new CreatureList(array(['ct.id', $id])); if ($npc->error) $smarty->notFound(Lang::$game['npc']); diff --git a/pages/spell.php b/pages/spell.php index 9bccc2a4..2e8fc502 100644 --- a/pages/spell.php +++ b/pages/spell.php @@ -30,9 +30,9 @@ if (isset($_GET['power'])) $pt[] = "\tname_".User::$localeString.": '".Util::jsEscape($n)."'"; if ($i = $spell->getField('iconString')) $pt[] = "\ticon: '".Util::jsEscape($i)."'"; - if ($t = $spell->renderTooltip($id)) + if ($t = $spell->renderTooltip()) $pt[] = "\ttooltip_".User::$localeString.": '".Util::jsEscape($t)."'"; - if ($b = $spell->renderBuff($id)) + if ($b = $spell->renderBuff()) $pt[] = "\tbuff_".User::$localeString.": '".Util::jsEscape($b)."'"; $x .= implode(",\n", $pt)."\n});"; @@ -238,6 +238,7 @@ if (!$smarty->loadCache($cacheKeyPage, $pageData)) $effMV = (int)$spell->getField('effect'.$i.'MiscValue'); $effBP = (int)$spell->getField('effect'.$i.'BasePoints'); $effDS = (int)$spell->getField('effect'.$i.'DieSides'); + $effRPPL = $spell->getField('effect'.$i.'RealPointsPerLevel'); $effAura = (int)$spell->getField('effect'.$i.'AuraId'); $foo = &$pageData['page']['effect'][]; @@ -283,6 +284,9 @@ if (!$smarty->loadCache($cacheKeyPage, $pageData)) if (($effBP + $effDS) && !$spell->getField('effect'.$i.'CreateItemId') && (!$spell->getField('effect'.$i.'TriggerSpell') || in_array($effAura, [225, 227]))) $foo['value'] = ($effDS != 1 ? ($effBP + 1).Lang::$game['valueDelim'] : null).($effBP + $effDS); + if ($effRPPL != 0) + $foo['value'] = (isset($foo['value']) ? $foo['value'] : '0') . sprintf(Lang::$spell['costPerLevel'], $effRPPL); + if($spell->getField('effect'.$i.'Periode') > 0) $foo['interval'] = $spell->getField('effect'.$i.'Periode') / 1000; @@ -303,7 +307,12 @@ if (!$smarty->loadCache($cacheKeyPage, $pageData)) case 88: // Summon Totem (slot 2) case 89: // Summon Totem (slot 3) case 90: // Summon Totem (slot 4) - $foo['name'] .= ': '.CreatureList::getName($effMV).' ('.$effMV.')'; + $summon = new CreatureList(array(['ct.id', $effMV])); + + if (!$pageData['view3D'] && $summon) + $pageData['view3D'] = $summon->getRandomModelId(); + + $foo['name'] .= ': '.$summon->getField('name', true).' ('.$effMV.')'; break; case 33: // open Lock $foo['name'] .= ' ('.sprintf(Util::$dfnString, @Util::$lockType[$effMV], $effMV).')'; @@ -327,6 +336,7 @@ if (!$smarty->loadCache($cacheKeyPage, $pageData)) case 105: // Summon Object (slot 2) case 106: // Summon Object (slot 3) case 107: // Summon Object (slot 4) + // todo (low): create modelviewer-data $foo['name'] .= ': '.GameObjectList::getName($effMV).' ('.$effMV.')'; break; case 74: // Apply Glyph @@ -334,7 +344,7 @@ if (!$smarty->loadCache($cacheKeyPage, $pageData)) $foo['name'] .= ': '.SpellList::getName($_).' ('.$effMV.')'; break; case 95: // Skinning - // todo: sort this out - 0:skinning (corpse, beast), 1:hearb (GO), 2: ineral (GO), 3: engineer (corpse, mechanic) + // todo (low): sort this out - 0:skinning (corpse, beast), 1:hearb (GO), 2: mineral (GO), 3: engineer (corpse, mechanic) $foo['name'] .= ' ('.sprintf(Util::$dfnString, 'NYI]', $effMV).')'; break; case 108: // Dispel Mechanic @@ -511,7 +521,7 @@ if (!$smarty->loadCache($cacheKeyPage, $pageData)) case 78: // Mounted case 56: // Transform { - $transform = new CreatureList(array(['ct.entry', $effMV])); + $transform = new CreatureList(array(['ct.id', $effMV])); if (!$pageData['view3D'] && $transform) $pageData['view3D'] = $transform->getRandomModelId(); diff --git a/setup/tools/dataset-assembler/talents.php b/setup/tools/dataset-assembler/talents.php index 22c69f52..f2c989ce 100644 --- a/setup/tools/dataset-assembler/talents.php +++ b/setup/tools/dataset-assembler/talents.php @@ -50,6 +50,7 @@ if (!defined('AOWOW_REVISION')) { $talents = DB::Aowow()->select(' SELECT + t.id AS tId, t.*, s.* FROM @@ -72,7 +73,7 @@ if (!defined('AOWOW_REVISION')) { $petFamId = log($tabs[$l]['pets'], 2); $result[$l]['icon'] = $petFamIcons[$petFamId]; - $petCategories = DB::Aowow()->SelectCol('SELECT Id AS ARRAY_KEY, categoryEnumId FROM ?_creatureFamily WHERE petTalentType = ?d', $petFamId); + $petCategories = DB::Aowow()->SelectCol('SELECT Id AS ARRAY_KEY, category FROM ?_pet WHERE type = ?d', $petFamId); $result[$l]['f'] = array_keys($petCategories); } @@ -82,11 +83,11 @@ if (!defined('AOWOW_REVISION')) for($j = 0; $j < count($talents); $j++) { - $tNums[$talents[$j]['id']] = $j; + $tNums[$talents[$j]['tId']] = $j; $d = []; $s = []; - $i = $talents[$j]['id']; + $i = $talents[$j]['tId']; $n = Util::localizedString($talents[$j], 'name'); $x = $talents[$j]['col']; $y = $talents[$j]['row']; @@ -114,7 +115,7 @@ if (!defined('AOWOW_REVISION')) for ($k = 0; $k <= ($m - 1); $k++) { - $tSpell = new SpellList(array(['s.id', $talents[$j]['rank'.($k + 1)]])); + $tSpell = new SpellList(array(['s.id', (int)$talents[$j]['rank'.($k + 1)]])); $d[] = $tSpell->parseText(); $s[] = $talents[$j]['rank'.($k + 1)]; @@ -154,10 +155,10 @@ if (!defined('AOWOW_REVISION')) $result[$l]['t'][$j]['iconname'] = $icon; // If this talent is a reference, add it to the array of talent dependencies - if (isset($depLinks[$talents[$j]['id']])) + if (isset($depLinks[$talents[$j]['tId']])) { - $result[$l]['t'][$depLinks[$talents[$j]['id']]]['r'][0] = $j; - unset($depLinks[$talents[$j]['id']]); + $result[$l]['t'][$depLinks[$talents[$j]['tId']]]['r'][0] = $j; + unset($depLinks[$talents[$j]['tId']]); } } @@ -203,7 +204,7 @@ if (!defined('AOWOW_REVISION')) // PetCalc if (empty($petIcons)) { - $pets = DB::Aowow()->SelectCol('SELECT Id AS ARRAY_KEY, iconString FROM ?_creatureFamily WHERE petTalentType <> -1'); + $pets = DB::Aowow()->SelectCol('SELECT Id AS ARRAY_KEY, iconString FROM ?_pet'); $petIcons = json_encode($pets, JSON_PRETTY_PRINT | JSON_NUMERIC_CHECK); } diff --git a/setup/tools/sql/_pet.php b/setup/tools/sql/_pet.php index 2efc584d..5e5ea6ee 100644 --- a/setup/tools/sql/_pet.php +++ b/setup/tools/sql/_pet.php @@ -5,6 +5,66 @@ if (!defined('AOWOW_REVISION')) class PetSetup extends PetList { + private static $setup = array( + 'CREATE TABLE `aowow_pet` ( + `id` int(11) NOT NULL , + `category` mediumint(8) NOT NULL , + `minLevel` smallint(6) NOT NULL , + `maxLevel` smallint(6) NOT NULL , + `foodMask` int(11) NOT NULL , + `type` tinyint(4) NOT NULL , + `exotic` tinyint(4) NOT NULL , + `expansion` tinyint(4) NOT NULL , + `name_loc0` varchar(64) NOT NULL , + `name_loc2` varchar(64) NOT NULL , + `name_loc3` varchar(64) NOT NULL , + `name_loc6` varchar(64) NOT NULL , + `name_loc8` varchar(64) NOT NULL , + `iconString` varchar(128) NOT NULL , + `skillLineId` mediumint(9) NOT NULL , + `spellId1` mediumint(9) NOT NULL , + `spellId2` mediumint(9) NOT NULL , + `spellId3` mediumint(9) NOT NULL , + `spellId4` mediumint(9) NOT NULL , + `armor` mediumint(9) NOT NULL , + `damage` mediumint(9) NOT NULL , + `health` mediumint(9) NOT NULL , + PRIMARY KEY (`id`) + ) DEFAULT CHARACTER SET=utf8 COLLATE=utf8_general_ci ENGINE=MyISAM', + + 'INSERT INTO aowow_pet SELECT + f.id, + categoryEnumId, + min(ct.minlevel), + max(ct.maxlevel), + itemPetFoodMask, + petTalentType, + IF(ct.type_flags & 0x10000, 1, 0), -- exotic + 0, -- expansion (static data :/) + nameEN, nameFR, nameDE, nameES, nameRU, + SUBSTRING_INDEX(iconFile, '\\', -1), + skillLine1, + 0, 0, 0, 0, -- spells + 0, 0, 0 -- mods (from "Tamed Pet Passive (DND)") + FROM + dbc.creatureFamily f + LEFT JOIN + ?_creature ct ON + f.id = ct.family + JOIN + world.creature c ON -- check if it is spawned (for min/max level) + ct.id = c.id + WHERE + pettalentType <> -1 AND + ct.type_flags & 0x1 + GROUP BY + f.id; + ', + + 'UPDATE aowow_pet SET expansion = 1 WHERE id IN (30, 31, 32, 33, 34)', + 'UPDATE aowow_pet SET expansion = 2 WHERE id IN (37, 38, 39, 41, 42, 43, 44, 45, 46)' + ); + private static $classicMods = array( // [Armor, Damage, Health] (see related "Tamed Pet Passive (DND)" spells per family. All values are set to +5% in wotlk) 1 => [ 5, 0, 0], // Wolf 2 => [ 0, 10, -2], // Cat @@ -31,22 +91,11 @@ class PetSetup extends PetList 35 => [ 0, 0, 0] // Serpent ); - private static $addonInfo = array( // i could have sworn that was somewhere in dbc - 30 => [1, 0], - 31 => [1, 0], - 32 => [1, 0], - 33 => [1, 0], - 34 => [1, 0], - 37 => [2, 0], - 38 => [2, 1], - 39 => [2, 1], - 41 => [2, 1], - 42 => [2, 1], - 43 => [2, 1], - 44 => [2, 0], - 45 => [2, 1], - 46 => [2, 1] - ), + public function __construct($params) + { + foreach ($this->setup as $query) + DB::Aowow()->query($query); + } function setupPetSpells() { @@ -71,15 +120,9 @@ class PetSetup extends PetList function setupClassicMods() { - foreach (self::$classicMods as $pet => $mods) + foreach ($this->classicMods as $pet => $mods) DB::Aowow()->query('UPDATE ?_pet SET armor = ?d, damage = ?d, health = ?d WHERE id = ?d', $mods[0], $mods[1], $mods[2], $pet); } - - function setupAddonInfo() - { - foreach (self::$addonInfo as $pet => $info) - DB::Aowow()->query('UPDATE ?_pet SET expansion = ?d, exotic = ?d WHERE id = ?d', $info[0], $info[1], $pet); - } } ?> diff --git a/template/bricks/listviews/creature.tpl b/template/bricks/listviews/creature.tpl index 355ffb86..f620a7db 100644 --- a/template/bricks/listviews/creature.tpl +++ b/template/bricks/listviews/creature.tpl @@ -1,7 +1,7 @@ {strip} new Listview({ldelim} template:'npc', - {if !isset($params.id)}id:'spells',{/if} + {if !isset($params.id)}id:'npcs',{/if} {if !isset($params.name)}name:LANG.tab_npcs,{/if} {if !isset($params.parent)}parent:'listview-generic',{/if} {foreach name=params from=$params key=k item=v} diff --git a/template/js/global.js b/template/js/global.js index f3b4d5ac..10c42630 100644 --- a/template/js/global.js +++ b/template/js/global.js @@ -12246,33 +12246,6 @@ Listview.templates = { } } }, - /* old: doesn't support text sent by server - getVisibleText: function(l) { - var h = { - achievements: g_achievements, - quests: g_quests - }, - m = "", - d = 0; - for (var f in h) { - var g = h[f], - a = l[f]; - if (!g || !a) { - continue - } - for (var e = 0, c = a.length; e < c; ++e) { - if (g[a[e]]) { - var b = (f == "achievements" ? "name": "name_" + g_locale.name); - if (d++>0) { - m += " " - } - m += g[a[e]][b] - } - } - } - return m - }, - */ getVisibleText: function(title) { var buff = '';