From ffd4c8e0342910bc086898bb7f1ed68a04579ab9 Mon Sep 17 00:00:00 2001 From: Sarjuuk Date: Wed, 19 Feb 2014 22:36:01 +0100 Subject: [PATCH] fixups for npc --- includes/types/creature.class.php | 35 +++++++++- localization/locale_dede.php | 6 +- localization/locale_enus.php | 6 +- localization/locale_eses.php | 6 +- localization/locale_frfr.php | 6 +- localization/locale_ruru.php | 6 +- pages/npc.php | 110 ++++++++++++++++++------------ search.php | 2 +- 8 files changed, 127 insertions(+), 50 deletions(-) diff --git a/includes/types/creature.class.php b/includes/types/creature.class.php index bfd7a0eb..7370df0f 100644 --- a/includes/types/creature.class.php +++ b/includes/types/creature.class.php @@ -17,8 +17,8 @@ class CreatureList extends BaseType public $queryOpts = array( 'ct' => [['ft', 'clsMin', 'clsMax', 'qr']], 'ft' => ['j' => '?_factiontemplate ft ON ft.id = ct.factionA', 's' => ', ft.*'], - 'clsMin' => ['j' => 'creature_classlevelstats clsMin ON ct.unitClass = clsMin.class AND ct.minLevel = clsMin.level', 's' => ', CASE ct.exp WHEN 0 THEN clsMin.basehp0 * healthMod WHEN 1 THEN clsMin.basehp1 * healthMod ELSE clsMin.basehp2 * healthMod END AS healthMin, clsMin.baseMana * manaMod AS manaMin'], - 'clsMax' => ['j' => 'creature_classlevelstats clsMax ON ct.unitClass = clsMax.class AND ct.maxLevel = clsMax.level', 's' => ', CASE ct.exp WHEN 0 THEN clsMax.basehp0 * healthMod WHEN 1 THEN clsMax.basehp1 * healthMod ELSE clsMax.basehp2 * healthMod END AS healthMax, clsMax.baseMana * manaMod AS manaMax'], + 'clsMin' => ['j' => 'creature_classlevelstats clsMin ON ct.unitClass = clsMin.class AND ct.minLevel = clsMin.level', 's' => ', clsMin.attackpower AS mleAtkPwrMin, clsMin.rangedattackpower AS rngAtkPwrMin, clsMin.baseArmor * armorMod AS armorMin, (CASE ct.exp WHEN 0 THEN clsMin.damage_base WHEN 1 THEN clsMin.damage_exp1 ELSE clsMin.damage_exp2 END) * dmgMultiplier AS dmgMin, (CASE ct.exp WHEN 0 THEN clsMin.basehp0 WHEN 1 THEN clsMin.basehp1 ELSE clsMin.basehp2 END) * healthMod AS healthMin, clsMin.baseMana * manaMod AS manaMin'], + 'clsMax' => ['j' => 'creature_classlevelstats clsMax ON ct.unitClass = clsMax.class AND ct.maxLevel = clsMax.level', 's' => ', clsMax.attackpower AS mleAtkPwrMax, clsMax.rangedattackpower AS rngAtkPwrMax, clsMax.baseArmor * armorMod AS armorMax, (CASE ct.exp WHEN 0 THEN clsMin.damage_base WHEN 1 THEN clsMin.damage_exp1 ELSE clsMin.damage_exp2 END) * dmgMultiplier AS dmgMax, (CASE ct.exp WHEN 0 THEN clsMax.basehp0 WHEN 1 THEN clsMax.basehp1 ELSE clsMax.basehp2 END) * healthMod AS healthMax, clsMax.baseMana * manaMod AS manaMax'], 'qr' => ['j' => ['creature_questrelation qr ON qr.id = ct.id', true], 's' => ', qr.quest', 'g' => 'ct.id'], // start 'ir' => ['j' => ['creature_involvedrelation ir ON ir.id = ct.id', true]], // end 'qtqr' => ['j' => 'quest_template qtqr ON qr.quest = qtqr.id'], @@ -117,6 +117,37 @@ class CreatureList extends BaseType return !$data ? 0 : $data[array_rand($data)]; } + public function getBaseStats($type) + { + // unsure of implementation: creature_classlevestats just got reworked + + switch ($type) + { + case 'health': + $hMin = $this->getField('healthMin'); + $hMax = $this->getField('healthMax'); + return [$hMin, $hMax]; + case 'power': + $mMin = $this->getField('manaMin'); + $mMax = $this->getField('manaMax'); + return [$mMin, $mMax]; + case 'armor': + $aMin = $this->getField('armorMin'); + $aMax = $this->getField('armorMax'); + return [$aMin, $aMax]; + case 'melee': + $mleMin = $this->getField('dmgMin') + $this->getField('mleAtkPwrMin') / 7; + $mleMax = ($this->getField('dmgMax') + $this->getField('mleAtkPwrMax') / 7) * 1.5; + return [$mleMin, $mleMax]; + case 'ranged': + $rngMin = $this->getField('dmgMin') + $this->getField('rngAtkPwrMin') / 7; + $rngMax = ($this->getField('dmgMax') + $this->getField('rngAtkPwrMax') / 7) * 1.5; + return [$rngMin, $rngMax]; + default: + return [0, 0]; + } + } + public function getListviewData($addInfoMask = 0x0) { /* looks like this data differs per occasion diff --git a/localization/locale_dede.php b/localization/locale_dede.php index 3dbedb28..47480c9c 100644 --- a/localization/locale_dede.php +++ b/localization/locale_dede.php @@ -277,7 +277,6 @@ $lang = array( 'capturePoint' => "Eroberungspunkt" ), 'npc' => array( - 'rank' => [0 => "Normal", 1 => "Elite", 4 => "Rar", 2 => "Rar Elite", 3 => "Boss"], 'classification'=> "Einstufung", 'petFamily' => "Tierart", 'react' => "Reaktion", @@ -289,6 +288,11 @@ $lang = array( 'repWith' => "Ruf mit der Fraktion", 'stopsAt' => "Stoppt bei %s", 'vehicle' => "Fahrzeug", + 'stats' => "Werte", + 'melee' => "Nahkampf", + 'ranged' => "Fernkampf", + 'armor' => "Rüstung", + 'rank' => [0 => "Normal", 1 => "Elite", 4 => "Rar", 2 => "Rar Elite", 3 => "Boss"], 'textTypes' => [null, "schreit", "sagt", "flüstert"], 'modes' => array( 1 => ["Normal", "Heroisch"], diff --git a/localization/locale_enus.php b/localization/locale_enus.php index 10f542ce..04ee60b5 100644 --- a/localization/locale_enus.php +++ b/localization/locale_enus.php @@ -264,7 +264,6 @@ $lang = array( 'capturePoint' => "Capture Point" ), 'npc' => array( - 'rank' => [0 => "Normal", 1 => "Elite", 4 => "Rare", 2 => "Rare Elite", 3 => "Boss"], 'classification'=> "Classification", 'petFamily' => "Pet familiy", 'react' => "React", @@ -276,6 +275,11 @@ $lang = array( 'repWith' => "reputation with", 'stopsAt' => "stops at %s", 'vehicle' => "Vehicle", + 'stats' => "Stats", + 'melee' => "Melee", + 'ranged' => "Ranged", + 'armor' => "Armor", + 'rank' => [0 => "Normal", 1 => "Elite", 4 => "Rare", 2 => "Rare Elite", 3 => "Boss"], 'textTypes' => [null, "yells", "says", "whispers"], 'modes' => array( 1 => ["Normal", "Heroic"], diff --git a/localization/locale_eses.php b/localization/locale_eses.php index e8d98e8c..8d38ba9a 100644 --- a/localization/locale_eses.php +++ b/localization/locale_eses.php @@ -235,7 +235,6 @@ $lang = array( 'capturePoint' => "Punto de captura" ), 'npc' => array( - 'rank' => [0 => "Normal", 1 => "Élite", 4 => "Raro", 2 => "Élite raro", 3 => "Jefe"], 'classification'=> "Clasificación", 'petFamily' => "Familia de mascota", 'react' => "Reacción", @@ -247,6 +246,11 @@ $lang = array( 'repWith' => "reputación con", 'stopsAt' => "se detiene en %s", 'vehicle' => "Vehículo", + 'stats' => "Estadisticas", + 'melee' => "Cuerpo a cuerpo", + 'ranged' => "Ataque a distancia", + 'armor' => "Armadura", + 'rank' => [0 => "Normal", 1 => "Élite", 4 => "Raro", 2 => "Élite raro", 3 => "Jefe"], 'textTypes' => [null, "grita", "dice", "susurra"], 'modes' => array( 1 => ["Normal", "Heroico"], diff --git a/localization/locale_frfr.php b/localization/locale_frfr.php index b3121a3a..a1c1f726 100644 --- a/localization/locale_frfr.php +++ b/localization/locale_frfr.php @@ -235,7 +235,6 @@ $lang = array( 'capturePoint' => "Point de capture" ), 'npc' => array( - 'rank' => [0 => "Standard", 1 => "Élite", 4 => "Rare", 2 => "Élite rare", 3 =>"Boss"], 'classification'=> "Classification", 'petFamily' => "Familier", 'react' => "Réaction", @@ -247,6 +246,11 @@ $lang = array( 'repWith' => "points de réputation avec", 'stopsAt' => "arrête à %s", 'vehicle' => "Véhicule", + 'stats' => "Statistiques", + 'melee' => "de mêlée", + 'ranged' => "à distance", + 'armor' => "Armure", + 'rank' => [0 => "Standard", 1 => "Élite", 4 => "Rare", 2 => "Élite rare", 3 =>"Boss"], 'textTypes' => [null, "crie", "dit", "chuchote"], 'modes' => array( 1 => ["Normal", "Héroïque"], diff --git a/localization/locale_ruru.php b/localization/locale_ruru.php index e831b7b2..181b6e64 100644 --- a/localization/locale_ruru.php +++ b/localization/locale_ruru.php @@ -235,7 +235,6 @@ $lang = array( 'capturePoint' => "Точка захвата" ), 'npc' => array( - 'rank' => [0 => "Обычный", 1 => "Элитный", 4 => "Редкий", 2 => "Редкий элитный", 3 =>"Босс"], 'classification'=> "Классификация", 'petFamily' => "Семейство питомца", 'react' => "Реакция", @@ -247,6 +246,11 @@ $lang = array( 'repWith' => "репутации с", 'stopsAt' => 'останавливается на уровне "%s"', 'vehicle' => "Автомобиль", + 'stats' => "Характеристики", + 'melee' => "Ближнего боя", + 'ranged' => "Дальнего боя", + 'armor' => "Броня", + 'rank' => [0 => "Обычный", 1 => "Элитный", 4 => "Редкий", 2 => "Редкий элитный", 3 =>"Босс"], 'textTypes' => [null, "кричит", "говорит", "шепчет"], 'modes' => array( 1 => ["Обычный", "Героический"], diff --git a/pages/npc.php b/pages/npc.php index 08231dff..066dec52 100644 --- a/pages/npc.php +++ b/pages/npc.php @@ -76,14 +76,19 @@ if (!$smarty->loadCache($cacheKeyPage, $pageData)) $_altNPCs = new CreatureList(array(['id', array_keys($_altIds)])); } - // map mode $mapType = 0; - $maps = DB::Aowow()->selectCol('SELECT DISTINCT map from creature WHERE id = ?d', $_id); - if (count($maps) == 1) // should only exist in one instance - { - $map = new ZoneList(array(1, ['mapId', $maps[0]])); + if (count($_altIds) > 1) // temp until zones.. + $mapType = 2; + else if (count($_altIds) == 1) + $mapType = 1; + + // map mode + // $maps = DB::Aowow()->selectCol('SELECT DISTINCT map from creature WHERE id = ?d', $_id); + // if (count($maps) == 1) // should only exist in one instance + // { + // $map = new ZoneList(array(1, ['mapId', $maps[0]])); // $mapType = $map->getField('areaType'); //NYI - } + // } /***********/ /* Infobox */ @@ -141,59 +146,80 @@ if (!$smarty->loadCache($cacheKeyPage, $pageData)) $infobox[] = 'AI'.Lang::$colon.$_; } - $_nf = function ($num) { return number_format($num, 0, '', '.'); }; - + // > Stats + $_nf = function ($num) { return number_format($num, 0, '', '.'); }; + $stats = []; + $modes = []; // get difficulty versions if set + $hint = '[tooltip name=%3$s][table cellspacing=10][tr]%1s[/tr][/table][/tooltip][span class=tip tooltip=%3$s]%2s[/span]'; + $modeRow = '[tr][td]%s  [/td][td]%s[/td][/tr]'; // Health - $health = $npc->getField('healthMin'); - $maxHealth = $npc->getField('healthMax'); - $health = $health < $maxHealth ? $_nf($health).' - '.$_nf($maxHealth) : $_nf($health); + $health = $npc->getBaseStats('health'); + $stats['health'] = Util::ucFirst(Lang::$spell['powerTypes'][-2]).Lang::$colon.($health[0] < $health[1] ? $_nf($health[0]).' - '.$_nf($health[1]) : $_nf($health[0])); + + // Mana (may be 0) + $mana = $npc->getBaseStats('power'); + $stats['mana'] = $mana[0] ? Lang::$spell['powerTypes'][0].Lang::$colon.($mana[0] < $mana[1] ? $_nf($mana[0]).' - '.$_nf($mana[1]) : $_nf($mana[0])) : null; + + // Armor + $armor = $npc->getBaseStats('armor'); + $stats['armor'] = Lang::$npc['armor'].Lang::$colon.($armor[0] < $armor[1] ? $_nf($armor[0]).' - '.$_nf($armor[1]) : $_nf($armor[0])); + + // Melee Damage + $melee = $npc->getBaseStats('melee'); + if ($_ = $npc->getField('dmgSchool')) // magic damage + $stats['melee'] = Lang::$npc['melee'].Lang::$colon.$_nf($melee[0]).' - '.$_nf($melee[1]).' ('.Lang::$game['sc'][$_].')'; + else // phys. damage + $stats['melee'] = Lang::$npc['melee'].Lang::$colon.$_nf($melee[0]).' - '.$_nf($melee[1]); + + // Ranged Damage + $ranged = $npc->getBaseStats('ranged'); + $stats['ranged'] = Lang::$npc['ranged'].Lang::$colon.$_nf($ranged[0]).' - '.$_nf($ranged[1]); - $modes = []; - $tipp = '[tooltip name=healthModes][table cellspacing=10][tr]%s[/tr][/table][/tooltip][span class=tip tooltip=healthModes]%s[/span]'; if ($mapType == 1 || $mapType == 2) // Dungeon or Raid { - foreach ($_altIds as $mode => $id) + foreach ($_altIds as $id => $mode) { foreach ($_altNPCs->iterate() as $dId => $__) { if ($dId != $id) continue; - $hp = $_altNPCs->getField('healthMin'); - $hpMax = $_altNPCs->getField('healthMax'); - $hp = $hp < $hpMax ? $_nf($hp).' - '.$_nf($hpMax) : $_nf($hp); + $m = Lang::$npc['modes'][$mapType][$mode]; - $modes[] = '[tr][td]'.Lang::$npc['modes'][$mapType][$mode].'  [/td][td]'.$hp.'[/td][/tr]'; - break; + // Health + $health = $_altNPCs->getBaseStats('health'); + $modes['health'][] = sprintf($modeRow, $m, $health[0] < $health[1] ? $_nf($health[0]).' - '.$_nf($health[1]) : $_nf($health[0])); + + // Mana (may be 0) + $mana = $_altNPCs->getBaseStats('power'); + $modes['mana'][] = $mana[0] ? sprintf($modeRow, $m, $mana[0] < $mana[1] ? $_nf($mana[0]).' - '.$_nf($mana[1]) : $_nf($mana[0])) : null; + + // Armor + $armor = $_altNPCs->getBaseStats('armor'); + $modes['armor'][] = sprintf($modeRow, $m, $armor[0] < $armor[1] ? $_nf($armor[0]).' - '.$_nf($armor[1]) : $_nf($armor[0])); + + // Melee Damage + $melee = $_altNPCs->getBaseStats('melee'); + if ($_ = $_altNPCs->getField('dmgSchool')) // magic damage + $modes['melee'][] = sprintf($modeRow, $m, $_nf($melee[0]).' - '.$_nf($melee[1]).' ('.Lang::$game['sc'][$_].')'); + else // phys. damage + $modes['melee'][] = sprintf($modeRow, $m, $_nf($melee[0]).' - '.$_nf($melee[1])); + + // Ranged Damage + $ranged = $_altNPCs->getBaseStats('ranged'); + $modes['ranged'][] = sprintf($modeRow, $m, $_nf($ranged[0]).' - '.$_nf($ranged[1])); } } - - if ($modes) - $health = Lang::$spell['powerTypes'][-2].' ('.Lang::$npc['modes'][$mapType][0].')'.Lang::$colon.$health; } if ($modes) - $infobox[] = sprintf($tipp, implode('[/tr][tr]', $modes), $health); - else - $infobox[] = Lang::$spell['powerTypes'][-2].Lang::$colon.$health; + foreach ($stats as $k => $v) + if ($v) + $stats[$k] = sprintf($hint, implode('[/tr][tr]', $modes[$k]), $v, $k); - // Mana - $mana = $npc->getField('manaMin'); - $maxMana = $npc->getField('manaMax'); - if ($maxMana) - { - $mana = $mana < $maxMana ? $_nf($mana).' - '.$_nf($maxMana) : $_nf($mana); - $infobox[] = Lang::$spell['powerTypes'][0].Lang::$colon.$mana; - } - - -/* - if damage -
  • {#Damage#}: {$npc.mindmg} - {$npc.maxdmg}
  • - - if armor -
  • {#Armor#}: {$npc.armor}
  • -*/ + // < Stats + if ($stats) + $infobox[] = Lang::$npc['stats'].($modes ? ' ('.Lang::$npc['modes'][$mapType][0].')' : null).Lang::$colon.'[ul][li]'.implode('[/li][li]', $stats).'[/li][/ul]'; /****************/ diff --git a/search.php b/search.php index 8c5f182e..60351fff 100644 --- a/search.php +++ b/search.php @@ -281,7 +281,7 @@ if (!$smarty->loadCache($cacheKey, $found)) if ($searchMask & 0x0000020) { // ['item1', 0, '!'], // remove empty sets from search, set in cuFlags - $cnd = array_merge($cndBase, is_int($query) ? ['id', $query] : ['name_loc'.User::$localeId, $query]); + $cnd = array_merge($cndBase, [is_int($query) ? ['id', $query] : ['name_loc'.User::$localeId, $query]]); $sets = new ItemsetList($cnd);