/** * Return array with loot info: dropped by, contained in, disenchating to, reagent for, etc. * @category Items class * @example Items::BuildLootTable(35000, 'vendor') * @todo Currency for * @return array **/ public function BuildLootTable($item, $vendor, $data = false) { $lootTable = ''; switch ($vendor) { case 'vendor': $VendorLoot = $this->wDB->select("\n\t\t\t\tSELECT `entry`\n\t\t\t\t\tFROM `npc_vendor`\n\t\t\t\t\t\tWHERE `item`=?", $item); if (!empty($VendorLoot)) { $i = 0; foreach ($VendorLoot as $vItem) { $lootTable[$i] = array('name' => Mangos::GetNpcName($vItem['entry']), 'level' => Mangos::GetNpcInfo($vItem['entry'], 'level'), 'map' => Mangos::GetNpcInfo($vItem['entry'], 'map')); $i++; } } break; case 'boss': $BossLoot = $this->wDB->select("\n\t\t\t\tSELECT `entry`, `ChanceOrQuestChance`\n\t\t\t\t\tFROM `creature_loot_template`\n\t\t\t\t\t\tWHERE `item`=?", $item); if (!empty($BossLoot)) { $i = 0; foreach ($BossLoot as $bItem) { $map_npc = Mangos::GetNpcInfo($bItem['entry'], 'map'); if (!empty($map_npc)) { $lootTable[$i] = array('entry' => $bItem['entry'], 'name' => Mangos::GetNpcName($bItem['entry']), 'level' => Mangos::GetNpcInfo($bItem['entry'], 'level'), 'boss' => Mangos::GetNpcInfo($bItem['entry'], 'isBoss'), 'map' => $map_npc, 'difficult' => Mangos::GetNpcInfo($bItem['entry'], 'dungeonlevel'), 'drop_percent' => Mangos::DropPercent($bItem['ChanceOrQuestChance']), 'makro' => '1'); $i++; } } } break; case 'chest': $ChestLoot = $this->wDB->select("\n\t\t\t\tSELECT `entry`, `ChanceOrQuestChance`\n\t\t\t\t\tFROM `gameobject_loot_template`\n\t\t\t\t\t\tWHERE `item`=?", $item); if (!empty($ChestLoot)) { $i = 0; foreach ($ChestLoot as $cItem) { $map_chest = Mangos::GameobjectInfo($cItem['entry'], 'map'); if (!empty($map_chest)) { $lootTable[$i] = array('name' => Mangos::GameobjectInfo($cItem['entry'], 'name'), 'map' => $map_chest, 'difficult' => ' ', 'drop_percent' => Mangos::DropPercent($cItem['ChanceOrQuestChance'])); $i++; } } } break; case 'questreward': $QuestLoot = $this->wDB->select("\n\t\t\t\tSELECT `entry`, `MinLevel`\n\t\t\t\t\tFROM `quest_template`\n\t\t\t\t\t\tWHERE `RewChoiceItemId1` = ? OR `RewChoiceItemId2` = ? OR `RewChoiceItemId3` = ? OR \n\t\t\t\t\t\t`RewChoiceItemId4` = ? OR `RewChoiceItemId5` = ? OR `RewChoiceItemId6` = ?", $item, $item, $item, $item, $item, $item); if (!empty($QuestLoot)) { $i = 0; foreach ($QuestLoot as $qItem) { $lootTable[$i] = array('title' => Mangos::QuestInfo($qItem['entry'], 'title'), 'reqlevel' => $qItem['MinLevel'], 'map' => Mangos::QuestInfo($qItem['entry'], 'map')); $i++; } } break; case 'queststart': $QuestStart = $this->wDB->selectCell("SELECT `startquest` FROM `item_template` WHERE `entry`=?", $item); if (!$QuestStart) { return false; } $lootTable[0] = array('title' => Mangos::QuestInfo($QuestStart, 'title'), 'reqlevel' => Mangos::QuestInfo($QuestStart, 'reqlevel'), 'map' => Mangos::QuestInfo($QuestStart, 'map')); break; case 'providedfor': $QuestInfo = $this->wDB->select("SELECT `entry`, `MinLevel` FROM `quest_template` WHERE `SrcItemId`=?", $item); if (!$QuestInfo) { return false; } $i = 0; foreach ($QuestInfo as $quest) { $lootTable[$i] = array('title' => Mangos::QuestInfo($quest['entry'], 'title'), 'reqlevel' => $quest['MinLevel'], 'map' => Mangos::QuestInfo($quest['entry'], 'map')); } break; case 'objectiveof': $QuestInfo = $this->wDB->select("\n SELECT `entry`, `MinLevel`\n FROM `quest_template`\n WHERE `ReqItemId1`=? OR `ReqItemId2`=? OR `ReqItemId3`=?\n OR `ReqItemId4`=? OR `ReqItemId5`=?", $item, $item, $item, $item, $item); if (!$QuestInfo) { return false; } $i = 0; foreach ($QuestInfo as $quest) { $lootTable[$i] = array('title' => Mangos::QuestInfo($quest['entry'], 'title'), 'reqlevel' => $quest['MinLevel'], 'map' => Mangos::QuestInfo($quest['entry'], 'map')); } break; case 'item': $ItemLoot = $this->wDB->select("\n SELECT `entry`, `ChanceOrQuestChance`\n FROM `item_loot_template`\n WHERE `item`=?", $item); if (!empty($ItemLoot)) { $i = 0; foreach ($ItemLoot as $iItem) { $lootTable[$i] = array('name' => Items::GetItemName($iItem['entry']), 'drop_percent' => Mangos::DropPercent($iItem['ChanceOrQuestChance'])); $i++; } } break; case 'disenchant': $DisenchantLoot = $this->wDB->select("\n SELECT `item`, `ChanceOrQuestChance`, `maxcount`\n FROM `disenchant_loot_template`\n WHERE `entry`=?", $item); if (!empty($DisenchantLoot)) { $i = 0; foreach ($DisenchantLoot as $dItem) { $lootTable[$i] = array('entry' => $dItem['item'], 'name' => $this->GetItemName($dItem['item']), 'drop_percent' => Mangos::DropPercent($dItem['ChanceOrQuestChance']), 'count' => $dItem['maxcount'], 'icon' => $this->GetItemIcon($dItem['item'])); $i++; } } break; case 'craft': $CraftLoot = $this->aDB->select("\n SELECT `Reagent_1`, `Reagent_2`, `Reagent_3`, `Reagent_4`, `Reagent_5`, `Reagent_6`, `Reagent_7`, `Reagent_8`,\n `ReagentCount_1`, `ReagentCount_2`, `ReagentCount_3`, `ReagentCount_4`, `ReagentCount_5`, `ReagentCount_6`, \n `ReagentCount_7`, `ReagentCount_8`, `EffectItemType_1`, `EffectItemType_2`, `EffectItemType_3`,\n `SpellName`\n FROM `armory_spell`\n WHERE `EffectItemType_1` =? OR `EffectItemType_2`=? OR `EffectItemType_3`=?", $item, $item, $item); if (!empty($CraftLoot)) { $i = 0; foreach ($CraftLoot as $craftItem) { $lootTable[$i]['name'] = $craftItem['SpellName']; for ($o = 1; $o < 9; $o++) { if ($craftItem['Reagent_' . $o] > 0) { $lootTable[$i]['entry_reagent_' . $o] = $craftItem['Reagent_' . $o]; $lootTable[$i]['name_reagent_' . $o] = $this->GetItemName($craftItem['Reagent_' . $o]); $lootTable[$i]['icon_reagent_' . $o] = $this->GetItemIcon($craftItem['Reagent_' . $o]); $lootTable[$i]['count_reagent_' . $o] = $craftItem['ReagentCount_' . $o]; } } for ($j = 1; $j < 4; $j++) { if ($craftItem['EffectItemType_' . $j] > 0) { $lootTable[$i]['item_name_' . $j] = $this->GetItemName($craftItem['EffectItemType_' . $j]); $lootTable[$i]['item_entry_' . $j] = $craftItem['EffectItemType_' . $j]; $lootTable[$i]['item_icon_' . $j] = $this->GetItemIcon($craftItem['EffectItemType_' . $j]); $lootTable[$i]['item_quality_' . $j] = $this->GetItemInfo($craftItem['EffectItemType_' . $j], 'quality'); } } $i++; } } break; case 'currency': return false; break; case 'reagent': $ReagentLoot = $this->aDB->select("\n SELECT `Reagent_1`, `Reagent_2`, `Reagent_3`, `Reagent_4`, `Reagent_5`, `Reagent_6`, `Reagent_7`, `Reagent_8`,\n `ReagentCount_1`, `ReagentCount_2`, `ReagentCount_3`, `ReagentCount_4`, `ReagentCount_5`, `ReagentCount_6`, \n `ReagentCount_7`, `ReagentCount_8`, `EffectItemType_1`, `EffectItemType_2`, `EffectItemType_3`,\n `SpellName`\n FROM `armory_spell`\n WHERE `Reagent_1`=? OR `Reagent_2`=? OR `Reagent_3`=? OR `Reagent_4`=? OR \n `Reagent_5`=? OR `Reagent_6`=? OR `Reagent_7`=? OR `Reagent_8`=?", $item, $item, $item, $item, $item, $item, $item, $item); if ($ReagentLoot) { $i = 0; foreach ($ReagentLoot as $ReagentItem) { for ($j = 1; $j < 4; $j++) { if ($ReagentItem['EffectItemType_' . $j] > 0) { $lootTable[$i]['item_entry'] = $ReagentItem['EffectItemType_' . $j]; $lootTable[$i]['item_name'] = $this->getItemName($ReagentItem['EffectItemType_' . $j]); $lootTable[$i]['item_icon'] = $this->getItemIcon($ReagentItem['EffectItemType_' . $j]); $lootTable[$i]['item_quality'] = $this->GetItemInfo($ReagentItem['EffectItemType_' . $j], 'quality'); } } for ($o = 1; $o < 9; $o++) { if ($ReagentItem['Reagent_' . $o] > 0) { $lootTable[$i]['Reagent_' . $o] = $ReagentItem['Reagent_' . $o]; $lootTable[$i]['ReagentIcon_' . $o] = $this->getItemIcon($ReagentItem['Reagent_' . $o]); $lootTable[$i]['ReagentCount_' . $o] = $ReagentItem['ReagentCount_' . $o]; } } $i++; } } break; } return $lootTable; }
/** * Return array with loot info: dropped by, contained in, disenchating to, reagent for, etc. * @category Items class * @example Items::BuildLootTable(35000, 'vendor') * @todo Currency for * @return array **/ public function BuildLootTable($item, $vendor, $data = false) { $lootTable = array(); switch ($vendor) { case 'vendor': $VendorLoot = $this->wDB->select("SELECT `entry`, `ExtendedCost` FROM `npc_vendor` WHERE `item`=?", $item); if (is_array($VendorLoot)) { $i = 0; foreach ($VendorLoot as $vItem) { $lootTable[$i] = $this->wDB->selectRow("SELECT `entry` AS `id`, `minlevel` AS `minLevel`, `maxlevel` AS `maxLevel`, name FROM `creature_template` WHERE `entry`=?", $vItem['entry']); if ($this->_locale != 'en_gb' || $this->_locale != 'en_us') { $lootTable[$i]['name'] = Mangos::GetNpcName($vItem['entry']); } $lootTable[$i]['area'] = Mangos::GetNpcInfo($vItem['entry'], 'map'); $i++; } } break; case 'boss': $BossLoot = $this->wDB->select("SELECT `entry` FROM `creature_loot_template` WHERE `item`=?", $item); if (is_array($BossLoot)) { $i = 0; foreach ($BossLoot as $bItem) { $lootTable[$i] = $this->wDB->selectRow("SELECT `entry` AS `id`, `name`, `minlevel` AS `minLevel`, `maxlevel` AS `maxLevel`, `rank` AS `classification` FROM `creature_template` WHERE `entry`=?", $bItem['entry']); if ($this->_locale != 'en_gb' || $this->_locale != 'en_us') { $lootTable[$i]['name'] = Mangos::GetNpcName($bItem['entry']); } $lootTable[$i]['area'] = Mangos::GetNpcInfo($bItem['entry'], 'map'); $lootTable[$i]['areaUrl'] = Mangos::GetNpcInfo($bItem['entry'], 'areaUrl'); $drop_percent = Mangos::GenerateLootPercent($bItem['entry'], 'creature_loot_template', $item); $lootTable[$i]['dropRate'] = Mangos::DropPercent($drop_percent); if ($lootTable[$i]['areaUrl'] && Mangos::GetNpcInfo($bItem['entry'], 'isBoss')) { $lootTable[$i]['url'] = str_replace('boss=all', 'boss=' . $bItem['entry'], $lootTable[$i]['areaUrl']); } $i++; } } break; case 'chest': $ChestLoot = $this->wDB->select("SELECT `entry` FROM `gameobject_loot_template` WHERE `item`=?", $item); if (is_array($ChestLoot)) { $i = 0; foreach ($ChestLoot as $cItem) { $drop_percent = Mangos::GenerateLootPercent($cItem['entry'], 'gameobject_loot_template', $item); $lootTable[$i] = array('name' => Mangos::GameobjectInfo($cItem['entry'], 'name'), 'area' => Mangos::GameobjectInfo($cItem['entry'], 'map'), 'areaUrl' => Mangos::GameobjectInfo($cItem['entry'], 'areaUrl'), 'id' => $cItem['entry'], 'dropRate' => Mangos::DropPercent($drop_percent)); $i++; } } break; case 'questreward': $QuestLoot = $this->wDB->select("\n SELECT `entry` AS `id`, `Title` AS `name`, `QuestLevel` AS `level`, `MinLevel` AS `reqMinLevel`, `SuggestedPlayers` AS `suggestedPartySize`\n FROM `quest_template`\n WHERE `RewChoiceItemId1` = ? OR `RewChoiceItemId2` = ? OR `RewChoiceItemId3` = ? OR \n `RewChoiceItemId4` = ? OR `RewChoiceItemId5` = ? OR `RewChoiceItemId6` = ?", $item, $item, $item, $item, $item, $item); if (is_array($QuestLoot)) { $i = 0; foreach ($QuestLoot as $qItem) { $lootTable[$i] = $qItem; if ($this->_locale != 'en_gb' || $this->_locale != 'en_us') { $lootTable[$i]['name'] = Mangos::QuestInfo($qItem['id'], 'title'); } $lootTable[$i]['area'] = Mangos::QuestInfo($qItem['id'], 'map'); $i++; } } break; case 'queststart': $QuestStart = $this->wDB->selectCell("SELECT `startquest` FROM `item_template` WHERE `entry`=?", $item); if (!$QuestStart) { return false; } $lootTable = $this->wDB->selectRow("SELECT `entry` AS `id`, `Title` AS `name`, `QuestLevel` AS `level`, `MinLevel` AS `reqMinLevel`, `SuggestedPlayers` AS `suggestedPartySize` FROM `quest_template` WHERE `entry`=?", $QuestStart); if ($this->_locale != 'en_gb' || $this->_locale != 'en_us') { $lootTable['name'] = Mangos::QuestInfo($QuestStart, 'title'); } $lootTable['name'] = Mangos::QuestInfo($QuestStart, 'title'); $lootTable['area'] = Mangos::QuestInfo($QuestStart, 'map'); break; case 'providedfor': $QuestInfo = $this->wDB->select("SELECT `entry` AS `id`, `QuestLevel` AS `level`, `Title` AS `name`, `MinLevel` AS `reqMinLevel`, `SuggestedPlayers` AS `suggestedPartySize` FROM `quest_template` WHERE `SrcItemId`=?", $item); if (is_array($QuestInfo)) { $i = 0; foreach ($QuestInfo as $quest) { $lootTable[$i] = $quest; if ($this->_locale != 'en_gb' || $this->_locale != 'en_us') { $lootTable[$i]['name'] = Mangos::QuestInfo($quest['id'], 'title'); } $lootTable[$i]['area'] = Mangos::QuestInfo($quest['id'], 'map'); } } break; case 'objectiveof': $QuestInfo = $this->wDB->select("\n SELECT `entry` AS `id`, `QuestLevel` AS `level`, `Title` AS `name`, `MinLevel` AS `reqMinLevel`, `SuggestedPlayers` AS `suggestedPartySize`\n FROM `quest_template`\n WHERE `ReqItemId1`=? OR `ReqItemId2`=? OR `ReqItemId3`=? OR `ReqItemId4`=? OR `ReqItemId5`=?", $item, $item, $item, $item, $item); if (is_array($QuestInfo)) { $i = 0; foreach ($QuestInfo as $quest) { $lootTable[$i] = $quest; if ($this->_locale != 'en_gb' || $this->_locale != 'en_us') { $lootTable[$i]['name'] = Mangos::QuestInfo($quest['id'], 'title'); } $lootTable[$i]['area'] = Mangos::QuestInfo($quest['id'], 'map'); } } break; case 'disenchant': $DisenchantLoot = $this->wDB->select("SELECT `item`, `maxcount`, `mincountOrRef` FROM `disenchant_loot_template` WHERE `entry`=?", $item); if (is_array($DisenchantLoot)) { $i = 0; foreach ($DisenchantLoot as $dItem) { $tmp_info = $this->wDB->selectRow("SELECT `name`, `Quality`, `displayid` FROM `item_template` WHERE `entry`=? LIMIT 1", $dItem['item']); $drop_percent = Mangos::GenerateLootPercent($item, 'disenchant_loot_template', $dItem['item']); $lootTable[$i] = array('id' => $dItem['item'], 'name' => $this->_locale == 'en_gb' || $this->_locale == 'en_us' ? $tmp_info['name'] : self::GetItemName($dItem['item']), 'dropRate' => Mangos::DropPercent($drop_percent), 'maxCount' => $dItem['maxcount'], 'minCount' => $dItem['mincountOrRef'], 'icon' => self::getItemIcon($dItem['item'], $tmp_info['displayid']), 'quality' => $tmp_info['Quality']); $i++; } } break; case 'craft': if ($this->_locale == 'en_gb' || $this->_locale == 'ru_ru') { $CraftLoot = $this->aDB->select("\n SELECT `Reagent_1`, `Reagent_2`, `Reagent_3`, `Reagent_4`, `Reagent_5`, `Reagent_6`, `Reagent_7`, `Reagent_8`,\n `ReagentCount_1`, `ReagentCount_2`, `ReagentCount_3`, `ReagentCount_4`, `ReagentCount_5`, `ReagentCount_6`, \n `ReagentCount_7`, `ReagentCount_8`, `EffectItemType_1`, `EffectItemType_2`, `EffectItemType_3`,\n `SpellName_" . $this->_locale . "` AS `SpellName`, `spellicon`\n FROM `armory_spell`\n WHERE `EffectItemType_1` =? OR `EffectItemType_2`=? OR `EffectItemType_3`=?", $item, $item, $item); } else { $CraftLoot = $this->aDB->select("\n SELECT `Reagent_1`, `Reagent_2`, `Reagent_3`, `Reagent_4`, `Reagent_5`, `Reagent_6`, `Reagent_7`, `Reagent_8`,\n `ReagentCount_1`, `ReagentCount_2`, `ReagentCount_3`, `ReagentCount_4`, `ReagentCount_5`, `ReagentCount_6`, \n `ReagentCount_7`, `ReagentCount_8`, `EffectItemType_1`, `EffectItemType_2`, `EffectItemType_3`,\n `SpellName_en_gb` AS `SpellName`, `spellicon`\n FROM `armory_spell`\n WHERE `EffectItemType_1` =? OR `EffectItemType_2`=? OR `EffectItemType_3`=?", $item, $item, $item); } if (is_array($CraftLoot)) { $i = 0; foreach ($CraftLoot as $craftItem) { $lootTable[$i]['spell'] = array(); $lootTable[$i]['item'] = array(); $lootTable[$i]['reagent'] = array(); $lootTable[$i]['spell']['name'] = $craftItem['SpellName']; $lootTable[$i]['spell']['icon'] = $this->aDB->selectCell("SELECT `icon` FROM `armory_speillicon` WHERE `id`=?", $craftItem['spellicon']); for ($o = 1; $o < 9; $o++) { if ($craftItem['Reagent_' . $o] > 0) { $tmp_info = $this->wDB->selectRow("SELECT `name`, `Quality`, `displayid` FROM `item_template` WHERE `entry`=? LIMIT 1", $craftItem['Reagent_' . $o]); $lootTable[$i]['reagent'][$o]['id'] = $craftItem['Reagent_' . $o]; $lootTable[$i]['reagent'][$o]['name'] = $this->_locale == 'en_gb' || $this->_locale == 'en_us' ? $tmp_info['name'] : self::getItemName($craftItem['Reagent_' . $o]); $lootTable[$i]['reagent'][$o]['icon'] = self::getItemIcon($craftItem['Reagent_' . $o], $tmp_info['displayid']); $lootTable[$i]['reagent'][$o]['count'] = $craftItem['ReagentCount_' . $o]; $lootTable[$i]['reagent'][$o]['quality'] = $tmp_info['Quality']; } } for ($j = 1; $j < 4; $j++) { if ($craftItem['EffectItemType_' . $j] > 0) { $tmp_info = $this->wDB->selectRow("SELECT `name`, `Quality`, `displayid` FROM `item_template` WHERE `entry`=? LIMIT 1", $craftItem['EffectItemType_' . $j]); $lootTable[$i]['item'][$j]['name'] = $this->_locale == 'en_gb' || $this->_locale == 'en_us' ? $tmp_info['name'] : self::GetItemName($craftItem['EffectItemType_' . $j]); $lootTable[$i]['item'][$j]['id'] = $craftItem['EffectItemType_' . $j]; $lootTable[$i]['item'][$j]['icon'] = self::getItemIcon($craftItem['EffectItemType_' . $j], $tmp_info['displayid']); $lootTable[$i]['item'][$j]['quality'] = $tmp_info['Quality']; } } $i++; } } break; case 'currency': return false; break; case 'reagent': if ($this->_locale == 'en_gb' || $this->_locale == 'ru_ru') { $ReagentLoot = $this->aDB->select("\n SELECT `Reagent_1`, `Reagent_2`, `Reagent_3`, `Reagent_4`, `Reagent_5`, `Reagent_6`, `Reagent_7`, `Reagent_8`,\n `ReagentCount_1`, `ReagentCount_2`, `ReagentCount_3`, `ReagentCount_4`, `ReagentCount_5`, `ReagentCount_6`, \n `ReagentCount_7`, `ReagentCount_8`, `EffectItemType_1`, `EffectItemType_2`, `EffectItemType_3`,\n `SpellName_" . $this->_locale . "` AS `SpellName`, `spellicon`\n FROM `armory_spell`\n WHERE `Reagent_1`=? OR `Reagent_2`=? OR `Reagent_3`=? OR `Reagent_4`=? OR\n `Reagent_5`=? OR `Reagent_6`=? OR `Reagent_7`=? OR `Reagent_8`=?", $item, $item, $item, $item, $item, $item, $item, $item); } else { $ReagentLoot = $this->aDB->select("\n SELECT `Reagent_1`, `Reagent_2`, `Reagent_3`, `Reagent_4`, `Reagent_5`, `Reagent_6`, `Reagent_7`, `Reagent_8`,\n `ReagentCount_1`, `ReagentCount_2`, `ReagentCount_3`, `ReagentCount_4`, `ReagentCount_5`, `ReagentCount_6`, \n `ReagentCount_7`, `ReagentCount_8`, `EffectItemType_1`, `EffectItemType_2`, `EffectItemType_3`,\n `SpellName_en_gb` AS `SpellName`, `spellicon`\n FROM `armory_spell`\n WHERE `Reagent_1`=? OR `Reagent_2`=? OR `Reagent_3`=? OR `Reagent_4`=? OR\n `Reagent_5`=? OR `Reagent_6`=? OR `Reagent_7`=? OR `Reagent_8`=?", $item, $item, $item, $item, $item, $item, $item, $item); } if (!$ReagentLoot) { return false; } $i = 0; foreach ($ReagentLoot as $ReagentItem) { $lootTable[$i]['spell'] = array(); $lootTable[$i]['item'] = array(); $lootTable[$i]['reagent'] = array(); $lootTable[$i]['spell']['name'] = $ReagentItem['SpellName']; $lootTable[$i]['spell']['icon'] = $this->aDB->selectCell("SELEC `icon` FROM `armory_spellicon` WHERE `id`=?", $ReagentItem['spellicon']); for ($j = 1; $j < 4; $j++) { if ($ReagentItem['EffectItemType_' . $j] > 0) { $tmp_info = $this->wDB->selectRow("SELECT `name`, `Quality`, `displayid` FROM `item_template` WHERE `entry`=? LIMIT 1", $ReagentItem['EffectItemType_' . $j]); $lootTable[$i]['item'][$j]['id'] = $ReagentItem['EffectItemType_' . $j]; $lootTable[$i]['item'][$j]['name'] = $this->_locale == 'en_gb' || $this->_locale == 'en_us' ? $tmp_info['name'] : self::getItemName($ReagentItem['EffectItemType_' . $j]); $lootTable[$i]['item'][$j]['icon'] = self::getItemIcon($ReagentItem['EffectItemType_' . $j], $tmp_info['displayid']); $lootTable[$i]['item'][$j]['quality'] = $tmp_info['Quality']; } } for ($o = 1; $o < 9; $o++) { if ($ReagentItem['Reagent_' . $o] > 0) { $tmp_info = $this->wDB->selectRow("SELECT `name`, `Quality`, `displayid` FROM `item_template` WHERE `entry`=? LIMIT 1", $ReagentItem['Reagent_' . $o]); $lootTable[$i]['reagent'][$o]['id'] = $ReagentItem['Reagent_' . $o]; $lootTable[$i]['reagent'][$o]['icon'] = self::getItemIcon($ReagentItem['Reagent_' . $o], $tmp_info['displayid']); $lootTable[$i]['reagent'][$o]['count'] = $ReagentItem['ReagentCount_' . $o]; $lootTable[$i]['reagent'][$o]['name'] = $this->_locale == 'en_gb' || $this->_locale == 'en_us' ? $tmp_info['name'] : self::getItemName($ReagentItem['Reagent_' . $o]); } } $i++; } break; case 'randomProperty': $itemProperty = $this->wDB->selectRow("SELECT `RandomProperty`, `RandomSuffix` FROM `item_template` WHERE `entry`=? LIMIT 1", $item); if (!$itemProperty || $itemProperty['RandomProperty'] == 0 && $itemProperty['RandomSuffix'] == 0) { return false; } $type = false; if ($itemProperty['RandomProperty'] > 0) { $itemPropertyId = $itemProperty['RandomProperty']; $type = 'property'; } elseif ($itemProperty['RandomSuffix'] > 0) { $itemPropertyId = $itemProperty['RandomSuffix']; $type = 'suffix'; } $enchants_entries = $this->wDB->select("SELECT * FROM `item_enchantment_template` WHERE `entry`=?", $itemPropertyId); if (!$enchants_entries) { return false; } $count = count($enchants_entries); $ids = array(); for ($i = 0; $i < $count; $i++) { $ids[$enchants_entries[$i]['ench']] = $enchants_entries[$i]['ench']; } if ($type == 'property') { $enchants = $this->aDB->select("SELECT `id`, `name_" . $this->_locale . "` AS `name`, `ench_1`, `ench_2`, `ench_3` FROM `armory_randomproperties` WHERE `id` IN (?a)", $ids); } elseif ($type == 'suffix') { $enchants = $this->aDB->select("SELECT `id`, `name_" . $this->_locale . "` AS `name`, `ench_1`, `ench_2`, `ench_3`, `ench_4`, `ench_5`, `pref_1`, `pref_2`, `pref_3`, `pref_4`, `pref_5` FROM `armory_randomsuffix` WHERE `id` IN (?a)", $ids); } if (!$enchants) { return false; } $i = 0; $item_data = $this->wDB->selectRow("SELECT `InventoryType`, `ItemLevel`, `Quality` FROM `item_template` WHERE `entry`=?", $item); $points = self::GetRandomPropertiesPoints($item_data['ItemLevel'], $item_data['InventoryType'], $item_data['Quality']); foreach ($enchants as $entry) { $str_tmp = array(); $lootTable[$i]['name'] = $entry['name']; $lootTable[$i]['data'] = array(); for ($j = 1; $j < 6; $j++) { if (isset($entry['ench_' . $j]) && $entry['ench_' . $j] > 0) { if ($type == 'property') { $str_tmp[$entry['ench_' . $j]] = $entry['ench_' . $j]; } elseif ($type == 'suffix') { $str_tmp[$entry['ench_' . $j]] = $entry['ench_' . $j]; } } } $enchs = $this->aDB->select("SELECT `id`, `text_" . $this->_locale . "` AS `text` FROM `armory_enchantment` WHERE `id` IN (?a)", $str_tmp); if (!$enchs) { $i++; continue; } $k = 0; foreach ($enchs as $m_ench) { if ($type == 'suffix') { for ($l = 1; $l < 3; $l++) { if (isset($entry['ench_' . $l]) && $entry['ench_' . $l] > 0) { $lootTable[$i]['data'][$k] = str_replace('$i', round($points * $entry['pref_' . $l] / 10000, 0), $m_ench['text']); } } } else { $lootTable[$i]['data'][$k] = $m_ench['text']; } $k++; } $i++; } break; } return $lootTable; }
/** * Return array with loot info: dropped by, contained in, disenchating to, reagent for, etc. * @category Items class * @example Items::BuildLootTable(35000, 'vendor') * @todo Currency for * @return array **/ public function BuildLootTable($item, $vendor, $data = false) { $lootTable = array(); switch ($vendor) { case 'vendor': $VendorLoot = $this->wDB->select("SELECT `entry`, `ExtendedCost` FROM `npc_vendor` WHERE `item`=?", $item); if (is_array($VendorLoot)) { $i = 0; foreach ($VendorLoot as $vItem) { $lootTable[$i] = $this->wDB->selectRow("SELECT `entry` AS `id`, `minlevel` AS `minLevel`, `maxlevel` AS `maxLevel`, name FROM `creature_template` WHERE `entry`=?", $vItem['entry']); if ($this->_locale != 'en_gb' || $this->_locale != 'en_us') { $lootTable[$i]['name'] = Mangos::GetNpcName($vItem['entry']); } $lootTable[$i]['area'] = Mangos::GetNpcInfo($vItem['entry'], 'map'); $i++; } } break; case 'boss': $BossLoot = $this->wDB->select("SELECT `entry` FROM `creature_loot_template` WHERE `item`=?", $item); if (is_array($BossLoot)) { $i = 0; foreach ($BossLoot as $bItem) { $lootTable[$i] = $this->wDB->selectRow("SELECT `entry` AS `id`, `name`, `minlevel` AS `minLevel`, `maxlevel` AS `maxLevel`, `rank` AS `classification` FROM `creature_template` WHERE `entry`=?", $bItem['entry']); if ($this->_locale != 'en_gb' || $this->_locale != 'en_us') { $lootTable[$i]['name'] = Mangos::GetNpcName($bItem['entry']); } $lootTable[$i]['area'] = Mangos::GetNpcInfo($bItem['entry'], 'map'); $lootTable[$i]['areaUrl'] = Mangos::GetNpcInfo($bItem['entry'], 'areaUrl'); $drop_percent = Mangos::GenerateLootPercent($bItem['entry'], 'creature_loot_template', $item); $lootTable[$i]['dropRate'] = Mangos::DropPercent($drop_percent); if ($lootTable[$i]['areaUrl'] && Mangos::GetNpcInfo($bItem['entry'], 'isBoss')) { $lootTable[$i]['url'] = str_replace('boss=all', 'boss=' . $bItem['entry'], $lootTable[$i]['areaUrl']); } $i++; } } break; case 'chest': $ChestLoot = $this->wDB->select("SELECT `entry` FROM `gameobject_loot_template` WHERE `item`=?", $item); if (is_array($ChestLoot)) { $i = 0; foreach ($ChestLoot as $cItem) { $drop_percent = Mangos::GenerateLootPercent($cItem['entry'], 'gameobject_loot_template', $item); $lootTable[$i] = array('name' => Mangos::GameobjectInfo($cItem['entry'], 'name'), 'area' => Mangos::GameobjectInfo($cItem['entry'], 'map'), 'areaUrl' => Mangos::GameobjectInfo($cItem['entry'], 'areaUrl'), 'id' => $cItem['entry'], 'dropRate' => Mangos::DropPercent($drop_percent)); $i++; } } break; case 'questreward': $QuestLoot = $this->wDB->select("\n SELECT `entry` AS `id`, `Title` AS `name`, `QuestLevel` AS `level`, `MinLevel` AS `reqMinLevel`, `SuggestedPlayers` AS `suggestedPartySize`\n FROM `quest_template`\n WHERE `RewChoiceItemId1` = ? OR `RewChoiceItemId2` = ? OR `RewChoiceItemId3` = ? OR \n `RewChoiceItemId4` = ? OR `RewChoiceItemId5` = ? OR `RewChoiceItemId6` = ?", $item, $item, $item, $item, $item, $item); if (is_array($QuestLoot)) { $i = 0; foreach ($QuestLoot as $qItem) { $lootTable[$i] = $qItem; if ($this->_locale != 'en_gb' || $this->_locale != 'en_us') { $lootTable[$i]['name'] = Mangos::QuestInfo($qItem['id'], 'title'); } $lootTable[$i]['area'] = Mangos::QuestInfo($qItem['id'], 'map'); $i++; } } break; case 'queststart': $QuestStart = $this->wDB->selectCell("SELECT `startquest` FROM `item_template` WHERE `entry`=?", $item); if (!$QuestStart) { return false; } $lootTable = $this->wDB->selectRow("SELECT `entry` AS `id`, `Title` AS `name`, `QuestLevel` AS `level`, `MinLevel` AS `reqMinLevel`, `SuggestedPlayers` AS `suggestedPartySize` FROM `quest_template` WHERE `entry`=?", $QuestStart); if ($this->_locale != 'en_gb' || $this->_locale != 'en_us') { $lootTable['name'] = Mangos::QuestInfo($QuestStart, 'title'); } $lootTable['name'] = Mangos::QuestInfo($QuestStart, 'title'); $lootTable['area'] = Mangos::QuestInfo($QuestStart, 'map'); break; case 'providedfor': $QuestInfo = $this->wDB->select("SELECT `entry` AS `id`, `QuestLevel` AS `level`, `Title` AS `name`, `MinLevel` AS `reqMinLevel`, `SuggestedPlayers` AS `suggestedPartySize` FROM `quest_template` WHERE `SrcItemId`=?", $item); if (is_array($QuestInfo)) { $i = 0; foreach ($QuestInfo as $quest) { $lootTable[$i] = $quest; if ($this->_locale != 'en_gb' || $this->_locale != 'en_us') { $lootTable[$i]['name'] = Mangos::QuestInfo($quest['id'], 'title'); } $lootTable[$i]['area'] = Mangos::QuestInfo($quest['id'], 'map'); } } break; case 'objectiveof': $QuestInfo = $this->wDB->select("\n SELECT `entry` AS `id`, `QuestLevel` AS `level`, `Title` AS `name`, `MinLevel` AS `reqMinLevel`, `SuggestedPlayers` AS `suggestedPartySize`\n FROM `quest_template`\n WHERE `ReqItemId1`=? OR `ReqItemId2`=? OR `ReqItemId3`=? OR `ReqItemId4`=? OR `ReqItemId5`=?", $item, $item, $item, $item, $item); if (is_array($QuestInfo)) { $i = 0; foreach ($QuestInfo as $quest) { $lootTable[$i] = $quest; if ($this->_locale != 'en_gb' || $this->_locale != 'en_us') { $lootTable[$i]['name'] = Mangos::QuestInfo($quest['id'], 'title'); } $lootTable[$i]['area'] = Mangos::QuestInfo($quest['id'], 'map'); } } break; case 'disenchant': $DisenchantLoot = $this->wDB->select("SELECT `item`, `maxcount`, `mincountOrRef` FROM `disenchant_loot_template` WHERE `entry`=?", $item); if (is_array($DisenchantLoot)) { $i = 0; foreach ($DisenchantLoot as $dItem) { $tmp_info = $this->wDB->selectRow("SELECT `name`, `Quality`, `displayid` FROM `item_template` WHERE `entry`=? LIMIT 1", $dItem['item']); $drop_percent = Mangos::GenerateLootPercent($item, 'disenchant_loot_template', $dItem['item']); $lootTable[$i] = array('id' => $dItem['item'], 'name' => $this->_locale == 'en_gb' || $this->_locale == 'en_us' ? $tmp_info['name'] : self::GetItemName($dItem['item']), 'dropRate' => Mangos::DropPercent($drop_percent), 'maxCount' => $dItem['maxcount'], 'minCount' => $dItem['mincountOrRef'], 'icon' => self::getItemIcon($dItem['item'], $tmp_info['displayid']), 'quality' => $tmp_info['Quality']); $i++; } } break; case 'craft': $CraftLoot = $this->aDB->select("\n SELECT `Reagent_1`, `Reagent_2`, `Reagent_3`, `Reagent_4`, `Reagent_5`, `Reagent_6`, `Reagent_7`, `Reagent_8`,\n `ReagentCount_1`, `ReagentCount_2`, `ReagentCount_3`, `ReagentCount_4`, `ReagentCount_5`, `ReagentCount_6`, \n `ReagentCount_7`, `ReagentCount_8`, `EffectItemType_1`, `EffectItemType_2`, `EffectItemType_3`,\n `SpellName_" . $this->_locale . "` AS `SpellName`, `spellicon`\n FROM `armory_spell`\n WHERE `EffectItemType_1` =? OR `EffectItemType_2`=? OR `EffectItemType_3`=?", $item, $item, $item); if (is_array($CraftLoot)) { $i = 0; foreach ($CraftLoot as $craftItem) { $lootTable[$i]['spell'] = array(); $lootTable[$i]['item'] = array(); $lootTable[$i]['reagent'] = array(); $lootTable[$i]['spell']['name'] = $craftItem['SpellName']; $lootTable[$i]['spell']['icon'] = $this->aDB->selectCell("SELECT `icon` FROM `armory_speillicon` WHERE `id`=?", $craftItem['spellicon']); for ($o = 1; $o < 9; $o++) { if ($craftItem['Reagent_' . $o] > 0) { $tmp_info = $this->wDB->selectRow("SELECT `name`, `Quality`, `displayid` FROM `item_template` WHERE `entry`=? LIMIT 1", $craftItem['Reagent_' . $o]); $lootTable[$i]['reagent'][$o]['id'] = $craftItem['Reagent_' . $o]; $lootTable[$i]['reagent'][$o]['name'] = $this->_locale == 'en_gb' || $this->_locale == 'en_us' ? $tmp_info['name'] : self::getItemName($craftItem['Reagent_' . $o]); $lootTable[$i]['reagent'][$o]['icon'] = self::getItemIcon($craftItem['Reagent_' . $o], $tmp_info['displayid']); $lootTable[$i]['reagent'][$o]['count'] = $craftItem['ReagentCount_' . $o]; $lootTable[$i]['reagent'][$o]['quality'] = $tmp_info['Quality']; } } for ($j = 1; $j < 4; $j++) { if ($craftItem['EffectItemType_' . $j] > 0) { $tmp_info = $this->wDB->selectRow("SELECT `name`, `Quality`, `displayid` FROM `item_template` WHERE `entry`=? LIMIT 1", $craftItem['EffectItemType_' . $j]); $lootTable[$i]['item'][$j]['name'] = $this->_locale == 'en_gb' || $this->_locale == 'en_us' ? $tmp_info['name'] : self::GetItemName($craftItem['EffectItemType_' . $j]); $lootTable[$i]['item'][$j]['id'] = $craftItem['EffectItemType_' . $j]; $lootTable[$i]['item'][$j]['icon'] = self::getItemIcon($craftItem['EffectItemType_' . $j], $tmp_info['displayid']); $lootTable[$i]['item'][$j]['quality'] = $tmp_info['Quality']; } } $i++; } } break; case 'currency': return false; break; case 'reagent': $ReagentLoot = $this->aDB->select("\n SELECT `Reagent_1`, `Reagent_2`, `Reagent_3`, `Reagent_4`, `Reagent_5`, `Reagent_6`, `Reagent_7`, `Reagent_8`,\n `ReagentCount_1`, `ReagentCount_2`, `ReagentCount_3`, `ReagentCount_4`, `ReagentCount_5`, `ReagentCount_6`, \n `ReagentCount_7`, `ReagentCount_8`, `EffectItemType_1`, `EffectItemType_2`, `EffectItemType_3`,\n `SpellName_" . $this->_locale . "` AS `SpellName`, `spellicon`\n FROM `armory_spell`\n WHERE `Reagent_1`=? OR `Reagent_2`=? OR `Reagent_3`=? OR `Reagent_4`=? OR\n `Reagent_5`=? OR `Reagent_6`=? OR `Reagent_7`=? OR `Reagent_8`=?", $item, $item, $item, $item, $item, $item, $item, $item); if (!$ReagentLoot) { return false; } $i = 0; foreach ($ReagentLoot as $ReagentItem) { $lootTable[$i]['spell'] = array(); $lootTable[$i]['item'] = array(); $lootTable[$i]['reagent'] = array(); $lootTable[$i]['spell']['name'] = $ReagentItem['SpellName']; $lootTable[$i]['spell']['icon'] = $this->aDB->selectCell("SELEC `icon` FROM `armory_spellicon` WHERE `id`=?", $ReagentItem['spellicon']); for ($j = 1; $j < 4; $j++) { if ($ReagentItem['EffectItemType_' . $j] > 0) { $tmp_info = $this->wDB->selectRow("SELECT `name`, `Quality`, `displayid` FROM `item_template` WHERE `entry`=? LIMIT 1", $ReagentItem['EffectItemType_' . $j]); $lootTable[$i]['item'][$j]['id'] = $ReagentItem['EffectItemType_' . $j]; $lootTable[$i]['item'][$j]['name'] = $this->_locale == 'en_gb' || $this->_locale == 'en_us' ? $tmp_info['name'] : self::getItemName($ReagentItem['EffectItemType_' . $j]); $lootTable[$i]['item'][$j]['icon'] = self::getItemIcon($ReagentItem['EffectItemType_' . $j], $tmp_info['displayid']); $lootTable[$i]['item'][$j]['quality'] = $tmp_info['Quality']; } } for ($o = 1; $o < 9; $o++) { if ($ReagentItem['Reagent_' . $o] > 0) { $tmp_info = $this->wDB->selectRow("SELECT `name`, `Quality`, `displayid` FROM `item_template` WHERE `entry`=? LIMIT 1", $ReagentItem['Reagent_' . $o]); $lootTable[$i]['reagent'][$o]['id'] = $ReagentItem['Reagent_' . $o]; $lootTable[$i]['reagent'][$o]['icon'] = self::getItemIcon($ReagentItem['Reagent_' . $o], $tmp_info['displayid']); $lootTable[$i]['reagent'][$o]['count'] = $ReagentItem['ReagentCount_' . $o]; $lootTable[$i]['reagent'][$o]['name'] = $this->_locale == 'en_gb' || $this->_locale == 'en_us' ? $tmp_info['name'] : self::getItemName($ReagentItem['Reagent_' . $o]); } } $i++; } break; } return $lootTable; }