Esempio n. 1
0
 public function GetImprovedItemSource($itemID, $bossID)
 {
     $dungeonData = $this->aDB->selectRow("SELECT `instance_id`, `name_" . $this->_locale . "` AS `name`, `lootid_1`, `lootid_2`, `lootid_3`, `lootid_4` FROM `armory_instance_data` WHERE `id`=? OR `lootid_1`=? OR `lootid_2`=? OR `lootid_3`=? OR `lootid_4`=? OR `name_id`=? LIMIT 1", $bossID, $bossID, $bossID, $bossID, $bossID, $bossID);
     if (!$dungeonData) {
         $this->Log()->writeError('%s : dungeonData for lootid %d not found (current_locale: %s, locId: %d)', __METHOD__, $bossID, $this->_locale, $this->_loc);
         return false;
     }
     $difficulty_enum = array(1 => '10n', 2 => '25n', 3 => '10h', 4 => '25h');
     $heroic_string = Utils::GetArmoryString(19);
     $item_difficulty = null;
     for ($i = 1; $i < 5; $i++) {
         if (isset($dungeonData['lootid_' . $i]) && $dungeonData['lootid_' . $i] == $bossID && isset($difficulty_enum[$i])) {
             $item_difficulty = $difficulty_enum[$i];
         }
     }
     switch ($item_difficulty) {
         case '10n':
             if ($dungeonData['instance_id'] == 4812 || $dungeonData['instance_id'] == 4722 || $dungeonData['instance_id'] == 4987) {
                 $instance_data = $this->aDB->selectRow("SELECT `id` AS `areaId`, `name_" . $this->_locale . "` AS `areaName`, `is_heroic` FROM `armory_instance_template` WHERE `id`=? AND `partySize`=10 AND `is_heroic`=1", $dungeonData['instance_id']);
             } else {
                 $instance_data = $this->aDB->selectRow("SELECT `id` AS `areaId`, `name_" . $this->_locale . "` AS `areaName`, `is_heroic` FROM `armory_instance_template` WHERE `id`=?", $dungeonData['instance_id']);
             }
             if (!$instance_data) {
                 return false;
             }
             break;
         case '10h':
             if ($dungeonData['instance_id'] == 4812 || $dungeonData['instance_id'] == 4722 || $dungeonData['instance_id'] == 4987) {
                 $instance_data = $this->aDB->selectRow("SELECT `id` AS `areaId`, `name_" . $this->_locale . "` AS `areaName`, `is_heroic` FROM `armory_instance_template` WHERE `id`=? AND `partySize`=10 AND `is_heroic`=1", $dungeonData['instance_id']);
             } else {
                 $instance_data = $this->aDB->selectRow("SELECT `id` AS `areaId`, `name_" . $this->_locale . "` AS `areaName`, `is_heroic` FROM `armory_instance_template` WHERE `id`=?", $dungeonData['instance_id']);
             }
             if (!$instance_data) {
                 return false;
             }
             if ($heroic_string) {
                 $instance_data['areaName'] .= ' ' . $heroic_string;
             }
             break;
         case '25n':
             if ($dungeonData['instance_id'] == 4812 || $dungeonData['instance_id'] == 4722 || $dungeonData['instance_id'] == 4987) {
                 $instance_data = $this->aDB->selectRow("SELECT `id` AS `areaId`, `name_" . $this->_locale . "` AS `areaName`, `is_heroic` FROM `armory_instance_template` WHERE `id`=? AND `partySize`=25 AND `is_heroic`=1", $dungeonData['instance_id']);
             } else {
                 $instance_data = $this->aDB->selectRow("SELECT `id` AS `areaId`, `name_" . $this->_locale . "` AS `areaName`, `is_heroic` FROM `armory_instance_template` WHERE `id`=?", $dungeonData['instance_id']);
             }
             if (!$instance_data) {
                 return false;
             }
             if ($instance_data['is_heroic'] == 0) {
                 if ($heroic_string) {
                     $instance_data['areaName'] .= ' ' . $heroic_string;
                 } else {
                     $instance_data['areaName'] .= ' (25)';
                 }
             }
             break;
         case '25h':
             if ($dungeonData['instance_id'] == 4812 || $dungeonData['instance_id'] == 4722 || $dungeonData['instance_id'] == 4987) {
                 $instance_data = $this->aDB->selectRow("SELECT `id` AS `areaId`, `name_" . $this->_locale . "` AS `areaName`, `is_heroic` FROM `armory_instance_template` WHERE `id`=? AND `partySize`=25 AND `is_heroic`=1", $dungeonData['instance_id']);
             } else {
                 $instance_data = $this->aDB->selectRow("SELECT `id` AS `areaId`, `name_" . $this->_locale . "` AS `areaName`, `is_heroic` FROM `armory_instance_template` WHERE `id`=?", $dungeonData['instance_id']);
             }
             if (!$instance_data) {
                 return false;
             }
             if ($heroic_string) {
                 $instance_data['areaName'] .= ' ' . $heroic_string;
             }
             break;
     }
     if (!isset($instance_data)) {
         return false;
     }
     $instance_data['creatureId'] = $this->aDB->selectCell("SELECT `id` FROM `armory_instance_data` WHERE `id`=? OR `lootid_1`=? OR `lootid_2`=? OR `lootid_3`=? OR `lootid_4`=? OR `name_id`=? LIMIT 1", $bossID, $bossID, $bossID, $bossID, $bossID, $bossID);
     $instance_data['creatureName'] = $dungeonData['name'];
     if ($bossID > 100000) {
         // GameObject
         $drop_percent = Mangos::GenerateLootPercent($bossID, 'gameobject_loot_template', $itemID);
     } else {
         // Creature
         $drop_percent = Mangos::GenerateLootPercent($bossID, 'creature_loot_template', $itemID);
     }
     $instance_data['dropRate'] = Mangos::DropPercent($drop_percent);
     $instance_data['value'] = 'sourceType.creatureDrop';
     return $instance_data;
 }
Esempio n. 2
0
 /**
  * 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' => '&nbsp;', '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;
 }