/** * @todo enchantments **/ public function GetCharacterItemInfo($slot) { if (!$this->guid) { $this->Log()->writeError('%s : player guid not provided', __METHOD__); return false; } $item_id = $this->getCharacterEquip($slot['slot']); if (!$item_id) { $this->Log()->writeLog('%s : unable to get item_id for player %d (%s); slotid is %s (nothing equipped?)', __METHOD__, $this->guid, $this->name, $slot['slot']); return false; } $durability = Items::getItemDurability($this->guid, $item_id); $gems = array('g0' => Items::extractSocketInfo($this->guid, $item_id, 1), 'g1' => Items::extractSocketInfo($this->guid, $item_id, 2), 'g2' => Items::extractSocketInfo($this->guid, $item_id, 3)); $item_data = $this->wDB->selectRow("SELECT `name`, `displayid`, `ItemLevel`, `Quality` FROM `item_template` WHERE `entry`=?", $item_id); $enchantment = $this->getCharacterEnchant($slot['slot']); $item_info = array('displayInfoId' => $item_data['displayid'], 'durability' => $durability['current'], 'icon' => Items::getItemIcon($item_id, $item_data['displayid']), 'id' => $item_id, 'level' => $item_data['ItemLevel'], 'maxDurability' => $durability['max'], 'name' => $this->_locale == 'en_gb' || $this->_locale == 'en_us' ? $item_data['name'] : Items::getItemName($item_id), 'permanentEnchantIcon' => 0, 'permanentEnchantItemId' => 0, 'permanentenchant' => null, 'pickUp' => 'PickUpLargeChain', 'putDown' => 'PutDownLArgeChain', 'randomPropertiesId' => 0, 'rarity' => $item_data['Quality'], 'seed' => 0, 'slot' => $slot['slotid']); for ($i = 0; $i < 3; $i++) { if ($gems['g' . $i]['item'] > 0) { $item_info['gem' . $i . 'Id'] = $gems['g' . $i]['item']; $item_info['gemIcon' . $i] = $gems['g' . $i]['icon']; } } return $item_info; }
private function CreateAdditionalItemTooltip($itemID, XMLHandler $xml, Characters $characters, $parent = false, $comparsion = false) { if (!$xml) { return false; } elseif ($parent == true && is_array($comparsion)) { return false; // both variables can't have 'true' value. } // Item comparsion mode $realm = false; if (is_array($comparsion) && isset($this->realmData[$comparsion['realm_id']])) { $realm = $this->realmData[$comparsion['realm_id']]; } $data = $this->wDB->selectRow("SELECT * FROM `item_template` WHERE `entry`=?", $itemID); if (!$data) { return false; } $isCharacter = $characters->CheckPlayer(); $xml->XMLWriter()->startElement('id'); $xml->XMLWriter()->text($itemID); $xml->XMLWriter()->endElement(); //id $xml->XMLWriter()->startElement('name'); if ($this->_locale == 'en_gb' || $this->_locale == 'en_us') { $xml->XMLWriter()->text($data['name']); } else { $xml->XMLWriter()->text(Items::getItemName($itemID)); } $xml->XMLWriter()->endElement(); //name $xml->XMLWriter()->startElement('icon'); $xml->XMLWriter()->text(Items::getItemIcon($itemID, $data['displayid'])); $xml->XMLWriter()->endElement(); //icon // 3.2.x heroic item flag if ($data['Flags'] == 8 || $data['Flags'] == 4104 && $data['itemset'] > 0) { $xml->XMLWriter()->startElement('heroic'); $xml->XMLWriter()->text(1); $xml->XMLWriter()->endElement(); //heroic } $xml->XMLWriter()->startElement('overallQualityId'); $xml->XMLWriter()->text($data['Quality']); $xml->XMLWriter()->endElement(); //overallQualityId $xml->XMLWriter()->startElement('bonding'); $xml->XMLWriter()->text($data['bonding']); $xml->XMLWriter()->endElement(); //bonding $xml->XMLWriter()->startElement('maxCount'); $xml->XMLWriter()->text($data['maxcount']); $xml->XMLWriter()->endElement(); //maxCount if ($data['startquest'] > 0) { $xml->XMLWriter()->startElement('startQuestId'); $xml->XMLWriter()->text($data['startquest']); $xml->XMLWriter()->endElement(); //startQuestId } $xml->XMLWriter()->startElement('classId'); $xml->XMLWriter()->text($data['class']); $xml->XMLWriter()->endElement(); //classId $xml->XMLWriter()->startElement('equipData'); $xml->XMLWriter()->startElement('inventoryType'); $xml->XMLWriter()->text($data['InventoryType']); $xml->XMLWriter()->endElement(); //inventoryType $xml->XMLWriter()->startElement('subclassName'); $xml->XMLWriter()->text(Items::GetItemSubTypeInfo($itemID, true, $data)); $xml->XMLWriter()->endElement(); //subclassName if ($data['class'] == ITEM_CLASS_CONTAINER) { $xml->XMLWriter()->startElement('containerSlots'); $xml->XMLWriter()->text($data['ContainerSlots']); $xml->XMLWriter()->endElement(); //containerSlots } $xml->XMLWriter()->endElement(); //equipData if ($data['class'] == ITEM_CLASS_WEAPON) { $xml->XMLWriter()->startElement('damageData'); $xml->XMLWriter()->startElement('damage'); $xml->XMLWriter()->startElement('type'); $xml->XMLWriter()->text('0'); $xml->XMLWriter()->endElement(); //type $xml->XMLWriter()->startElement('min'); $xml->XMLWriter()->text($data['dmg_min1']); $xml->XMLWriter()->endElement(); //min $xml->XMLWriter()->startElement('max'); $xml->XMLWriter()->text($data['dmg_max1']); $xml->XMLWriter()->endElement(); //max $xml->XMLWriter()->endElement(); //damage $xml->XMLWriter()->startElement('speed'); $xml->XMLWriter()->text(round($data['delay'] / 1000, 2)); $xml->XMLWriter()->endElement(); //speed $xml->XMLWriter()->startElement('dps'); $dps = null; for ($jj = 1; $jj <= 2; $jj++) { $d_type = $data['dmg_type' . $jj]; $d_min = $data['dmg_min' . $jj]; $d_max = $data['dmg_max' . $jj]; if ($d_max > 0 && $data['class'] != ITEM_CLASS_PROJECTILE) { $delay = $data['delay'] / 1000; if ($delay > 0) { $dps = $dps + round(($d_max + $d_min) / (2 * $delay), 1); } if ($jj > 1) { $delay = 0; } } } $xml->XMLWriter()->text($dps); $xml->XMLWriter()->endElement(); //dps $xml->XMLWriter()->endElement(); //damageData } if ($data['block'] > 0) { $xml->XMLWriter()->startElement('blockValue'); $xml->XMLWriter()->text($data['block']); $xml->XMLWriter()->endElement(); //blockValue } if ($data['fire_res'] > 0) { $xml->XMLWriter()->startElement('fireResist'); $xml->XMLWriter()->text($data['fire_res']); $xml->XMLWriter()->endElement(); //fireResist } if ($data['nature_res'] > 0) { $xml->XMLWriter()->startElement('natureResist'); $xml->XMLWriter()->text($data['nature_res']); $xml->XMLWriter()->endElement(); //natureResist } if ($data['frost_res'] > 0) { $xml->XMLWriter()->startElement('frostResist'); $xml->XMLWriter()->text($data['frost_res']); $xml->XMLWriter()->endElement(); //frostResist } if ($data['shadow_res'] > 0) { $xml->XMLWriter()->startElement('shadowResist'); $xml->XMLWriter()->text($data['shadow_res']); $xml->XMLWriter()->endElement(); //shadowResist } if ($data['arcane_res'] > 0) { $xml->XMLWriter()->startElement('arcaneResist'); $xml->XMLWriter()->text($data['arcane_res']); $xml->XMLWriter()->endElement(); //arcaneResist } for ($i = 1; $i < 11; $i++) { if ($data['stat_type' . $i] > 0 && $data['stat_value' . $i] > 0) { $bonus_template = Items::GetItemBonusTemplate($data['stat_type' . $i]); $xml->XMLWriter()->startElement($bonus_template); $xml->XMLWriter()->text($data['stat_value' . $i]); $xml->XMLWriter()->endElement(); } } $xml->XMLWriter()->startElement('armor'); if ($data['ArmorDamageModifier'] > 0) { $xml->XMLWriter()->writeAttribute('armorBonus', 1); } $xml->XMLWriter()->text($data['armor']); $xml->XMLWriter()->endElement(); //armor $ench_array = array(1 => 'head', 2 => 'neck', 3 => 'shoulder', 4 => 'shirt', 5 => 'chest', 6 => 'belt', 7 => 'legs', 8 => 'boots', 9 => 'wrist', 10 => 'gloves', 11 => 'ring1', 12 => 'trinket1', 13 => 'mainhand', 14 => 'offhand', 15 => 'relic', 16 => 'back', 17 => 'stave', 19 => 'tabard', 20 => 'chest', 21 => 'mainhand', 22 => '', 23 => 'offhand', 24 => '', 25 => 'thrown', 26 => 'gun', 28 => 'sigil'); if (isset($ench_array[$data['InventoryType']])) { $itemSlotName = $ench_array[$data['InventoryType']]; } else { $itemSlotName = false; } if (!$parent && $isCharacter && $itemSlotName) { $enchantment = $characters->getCharacterEnchant($itemSlotName, $characters->GetGUID()); if ($enchantment) { $xml->XMLWriter()->startElement('enchant'); $xml->XMLWriter()->text($this->aDB->selectCell("SELECT `text_" . $this->_locale . "` FROM `armory_enchantment` WHERE `id`=? LIMIT 1", $enchantment)); $xml->XMLWriter()->endElement(); //enchant } } // Random property if ($data['RandomProperty'] > 0 || $data['RandomSuffix'] > 0) { if (!$isCharacter) { $xml->XMLWriter()->startElement('randomEnchantData'); $xml->XMLWriter()->endElement(); //randomEnchantData } if ($itemSlotName) { $rPropInfo = Items::GetRandomPropertiesData($itemID, $characters->GetGUID(), $characters->GetEquippedItemGuidBySlot($itemSlotName)); } else { $rPropInfo = Items::GetRandomPropertiesData($itemID, $characters->GetGUID()); } if ($isCharacter && !$parent && is_array($rPropInfo)) { $xml->XMLWriter()->startElement('randomEnchantData'); $xml->XMLWriter()->startElement('suffix'); $xml->XMLWriter()->text($rPropInfo['suffix']); $xml->XMLWriter()->endElement(); //enchant if (is_array($rPropInfo['data'])) { foreach ($rPropInfo['data'] as $randProp) { $xml->XMLWriter()->startElement('enchant'); $xml->XMLWriter()->text($randProp); $xml->XMLWriter()->endElement(); //enchant } } $xml->XMLWriter()->endElement(); //randomEnchantData } } $xml->XMLWriter()->startElement('socketData'); $socket_data = false; $socketBonusCheck = array(); for ($i = 1; $i < 4; $i++) { if ($data['socketColor_' . $i] > 0) { switch ($data['socketColor_' . $i]) { case 1: $color = 'Meta'; $socket_data = array('color' => 'Meta'); $gem = Items::extractSocketInfo($characters->GetGUID(), $itemID, $i, $characters->GetEquippedItemGuidBySlot($itemSlotName)); if ($gem && !$parent) { $socket_data['enchant'] = $gem['enchant']; $socket_data['icon'] = $gem['icon']; $currentColor = $this->aDB->selectCell("SELECT `color` FROM `armory_gemproperties` WHERE `spellitemenchantement`=? LIMIT 1", $gem['enchant_id']); if ($currentColor == 1) { $socket_data['match'] = '1'; } } break; case 2: $socket_data = array('color' => 'Red'); $gem = Items::extractSocketInfo($characters->GetGUID(), $itemID, $i, $characters->GetEquippedItemGuidBySlot($itemSlotName)); if ($gem && !$parent) { $socket_data['enchant'] = $gem['enchant']; $socket_data['icon'] = $gem['icon']; $currentColor = $this->aDB->selectCell("SELECT `color` FROM `armory_gemproperties` WHERE `spellitemenchantement`=? LIMIT 1", $gem['enchant_id']); if ($currentColor == 6 || $currentColor == 10 || $currentColor == 14) { $socket_data['match'] = '1'; } } break; case 4: $socket_data = array('color' => 'Yellow'); $gem = Items::extractSocketInfo($characters->GetGUID(), $itemID, $i, $characters->GetEquippedItemGuidBySlot($itemSlotName)); if ($gem && !$parent) { $socket_data['enchant'] = $gem['enchant']; $socket_data['icon'] = $gem['icon']; $currentColor = $this->aDB->selectCell("SELECT `color` FROM `armory_gemproperties` WHERE `spellitemenchantement`=? LIMIT 1", $gem['enchant_id']); if ($currentColor == 6 || $currentColor == 12 || $currentColor == 14) { $socket_data['match'] = '1'; } } break; case 8: $socket_data = array('color' => 'Blue'); $gem = Items::extractSocketInfo($characters->GetGUID(), $itemID, $i, $characters->GetEquippedItemGuidBySlot($itemSlotName)); if ($gem && !$parent) { $socket_data['enchant'] = $gem['enchant']; $socket_data['icon'] = $gem['icon']; $currentColor = $this->aDB->selectCell("SELECT `color` FROM `armory_gemproperties` WHERE `spellitemenchantement`=? LIMIT 1", $gem['enchant_id']); if ($currentColor == 10 || $currentColor == 12 || $currentColor == 14) { $socket_data['match'] = '1'; } } break; } if (is_array($socket_data)) { $xml->XMLWriter()->startElement('socket'); foreach ($socket_data as $socket_key => $socket_value) { $xml->XMLWriter()->writeAttribute($socket_key, $socket_value); } $xml->XMLWriter()->endElement(); //socket $color = false; } } } if (isset($socketBonusCheck)) { $socketBonusCheckCount = count($socketBonusCheck); $socketMatches = 0; foreach ($socketBonusCheck as $socket) { if ($socket['color'] == $socket['current']) { $socketMatches++; } elseif ($socket['color'] == 2 && ($socket['current'] == 6 || $socket['current'] == 10 || $socket['current'] == 14)) { $socketMatches++; } elseif ($socket['color'] == 4 && ($socket['current'] == 6 || $socket['current'] == 12 || $socket['current'] == 14)) { $socketMatches++; } elseif ($socket['color'] == 8 && ($socket['current'] == 10 || $socket['current'] == 12 || $socket['current'] == 14)) { $socketMatches++; } } if ($socketBonusCheckCount == $socketMatches) { $socket_data['match'] = '1'; } } if ($data['socketBonus'] > 0) { $bonus_text = $this->aDB->selectCell("SELECT `text_" . $this->_locale . "` FROM `armory_enchantment` WHERE `id`=?", $data['socketBonus']); $xml->XMLWriter()->startElement('socketMatchEnchant'); $xml->XMLWriter()->text($bonus_text); $xml->XMLWriter()->endElement(); //socketMatchEnchant } $xml->XMLWriter()->endElement(); //socketData $allowable_classes = Items::AllowableClasses($data['AllowableClass']); if ($allowable_classes) { $xml->XMLWriter()->startElement('allowableClasses'); foreach ($allowable_classes as $al_class) { $xml->XMLWriter()->startElement('class'); $xml->XMLWriter()->text($al_class); $xml->XMLWriter()->endElement(); //class } $xml->XMLWriter()->endElement(); //allowableClasses } $allowable_races = Items::AllowableRaces($data['AllowableRace']); if ($allowable_races) { $xml->XMLWriter()->startElement('allowableRaces'); foreach ($allowable_races as $al_race) { $xml->XMLWriter()->startElement('race'); $xml->XMLWriter()->text($al_race); $xml->XMLWriter()->endElement(); //race } $xml->XMLWriter()->endElement(); //allowableRaces } if ($data['RequiredSkill'] > 0) { $xml->XMLWriter()->startElement('requiredSkill'); $xml->XMLWriter()->writeAttribute('name', $this->aDB->selectCell("SELECT `name_" . $this->_locale . "` FROM `armory_skills` WHERE `id`=?", $data['RequiredSkill'])); $xml->XMLWriter()->writeAttribute('rank', $data['RequiredSkillRank']); $xml->XMLWriter()->endElement(); //requiredSkill } if ($data['RequiredReputationFaction'] > 0) { $xml->XMLWriter()->startElement('requiredFaction'); $xml->XMLWriter()->writeAttribute('name', $this->aDB->selectCell("SELECT `name_" . $this->_locale . "` FROM `armory_faction` WHERE `id`=?", $data['RequiredReputationFaction'])); $xml->XMLWriter()->writeAttribute('rep', $data['RequiredReputationRank']); $xml->XMLWriter()->endElement(); //requiredFaction } $xml->XMLWriter()->startElement('requiredLevel'); $xml->XMLWriter()->text($data['RequiredLevel']); $xml->XMLWriter()->endElement(); //requiredLevel $xml->XMLWriter()->startElement('itemLevel'); $xml->XMLWriter()->text($data['ItemLevel']); $xml->XMLWriter()->endElement(); //itemLevel if ($data['itemset'] > 0) { $xml->XMLWriter()->startElement('setData'); $itemsetName = $this->aDB->selectCell("SELECT `name_" . $this->_locale . "` FROM `armory_itemsetinfo` WHERE `id`=?", $data['itemset']); $xml->XMLWriter()->startElement('name'); $xml->XMLWriter()->text($itemsetName); $xml->XMLWriter()->endElement(); $setdata = $this->aDB->selectRow("SELECT * FROM `armory_itemsetinfo` WHERE `id`=?", $data['itemset']); // t9/t10 Onyxia trinkets if ($data['itemset'] >= 843 && $data['itemset'] != 881 && $data['itemset'] != 882) { // Get itemset info from other table (armory_itemsetdata) $currentSetData = $this->aDB->selectRow("SELECT * FROM `armory_itemsetdata` WHERE `original`=? AND (`item1`=? OR `item2`=? OR `item3`=? OR `item4`=? OR `item5`=?)", $data['itemset'], $itemID, $itemID, $itemID, $itemID, $itemID); if ($currentSetData) { for ($i = 1; $i < 6; $i++) { if (Items::IsItemExists($currentSetData['item' . $i])) { $xml->XMLWriter()->startElement('item'); $xml->XMLWriter()->writeAttribute('name', Items::getItemName($currentSetData['item' . $i])); if ($characters->IsItemEquipped($currentSetData['item' . $i])) { $xml->XMLWriter()->writeAttribute('equipped', 1); } $xml->XMLWriter()->endElement(); //item } } } } else { for ($i = 1; $i < 10; $i++) { if (isset($setdata['item' . $i]) && Items::IsItemExists($setdata['item' . $i])) { $xml->XMLWriter()->startElement('item'); $xml->XMLWriter()->writeAttribute('name', Items::getItemName($setdata['item' . $i])); $xml->XMLWriter()->endElement(); //item } } } $itemsetbonus = Items::GetItemSetBonusInfo($setdata); if (is_array($itemsetbonus)) { foreach ($itemsetbonus as $item_bonus) { $xml->XMLWriter()->startElement('setBonus'); $xml->XMLWriter()->writeAttribute('desc', $item_bonus['desc']); $xml->XMLWriter()->writeAttribute('threshold', $item_bonus['threshold']); $xml->XMLWriter()->endElement(); //setBonus } } $xml->XMLWriter()->endElement(); //setData } $xml->XMLWriter()->startElement('spellData'); $spellData = 0; $spellInfo = false; for ($i = 1; $i < 6; $i++) { if ($data['spellid_' . $i] > 0) { $spellData = 1; $spell_tmp = $this->aDB->selectRow("SELECT * FROM `armory_spell` WHERE `id`=?", $data['spellid_' . $i]); if ($this->_locale == 'en_gb' || $this->_locale == 'ru_ru') { $tmp_locale = $this->_locale; } else { $tmp_locale = 'en_gb'; } if (!isset($spell_tmp['Description_' . $tmp_locale])) { continue; } $spellInfo = $this->spellReplace($spell_tmp, Utils::ValidateText($spell_tmp['Description_' . $tmp_locale])); if ($spellInfo) { $spellData = 2; $spellInfo = str_replace('"', '"', $spellInfo); $xml->XMLWriter()->startElement('spell'); $xml->XMLWriter()->startElement('trigger'); $xml->XMLWriter()->text($data['spelltrigger_' . $i]); $xml->XMLWriter()->endElement(); //trigger $xml->XMLWriter()->startElement('desc'); $xml->XMLWriter()->text($spellInfo); $xml->XMLWriter()->endElement(); //desc $xml->XMLWriter()->endElement(); //spell } } } if ($spellData == 1 && !empty($data['description'])) { $xml->XMLWriter()->startElement('spell'); $xml->XMLWriter()->startElement('trigger'); $xml->XMLWriter()->text(6); $xml->XMLWriter()->endElement(); //trigger $xml->XMLWriter()->startElement('desc'); if ($this->_locale == 'en_gb' || $this->_locale == 'en_us') { $xml->XMLWriter()->text($data['description']); } else { $xml->XMLWriter()->text(Items::GetItemDescription($itemID)); } $xml->XMLWriter()->endElement(); //desc if (!$parent) { for ($k = 1; $k < 4; $k++) { if ($spell_tmp['EffectItemType_' . $k] > 0 && Items::IsItemExists($spell_tmp['EffectItemType_' . $k])) { $xml->XMLWriter()->startElement('itemTooltip'); self::ItemTooltip($spell_tmp['EffectItemType_' . $k], $xml, $characters, true); $xml->XMLWriter()->endElement(); //itemTooltip $spellreagents = $this->GetSpellItemCreateReagentsInfo($spell_tmp['EffectItemType_' . $k]); if (is_array($spellreagents)) { foreach ($spellreagents as $reagent) { $xml->XMLWriter()->startElement('reagent'); $xml->XMLWriter()->writeAttribute('count', $reagent['count']); $xml->XMLWriter()->writeAttribute('name', $reagent['name']); $xml->XMLWriter()->endElement(); //reagent } } else { $xml->XMLWriter()->startElement('reag'); $xml->XMLWriter()->endElement(); //reagent } } } } $xml->XMLWriter()->endElement(); //spell } $xml->XMLWriter()->endElement(); //spellData if (!empty($data['description']) && $data['description'] != $spellInfo && $spellData != 1) { $xml->XMLWriter()->startElement('desc'); if ($this->_locale == 'en_gb' || $this->_locale == 'en_us') { $xml->XMLWriter()->text($data['description']); } else { $xml->XMLWriter()->text(Items::GetItemDescription($itemID)); } $xml->XMLWriter()->endElement(); //desc } if (!$parent) { $itemSource = Items::GetItemSource($itemID); if (is_array($itemSource)) { $xml->XMLWriter()->startElement('itemSource'); foreach ($itemSource as $source_key => $source_value) { $xml->XMLWriter()->writeAttribute($source_key, $source_value); } $xml->XMLWriter()->endElement(); //itemSource } if ($itemSource['value'] == 'sourceType.vendor' && ($reqArenaRating = Items::IsRequiredArenaRating($itemID))) { $xml->XMLWriter()->startElement('requiredPersonalArenaRating'); $xml->XMLWriter()->writeAttribute('personalArenaRating', $reqArenaRating); $xml->XMLWriter()->endElement(); //requiredPersonalArenaRating } } }