diff --git a/includes/types/creature.class.php b/includes/types/creature.class.php index 46a42d7e..05b8deff 100644 --- a/includes/types/creature.class.php +++ b/includes/types/creature.class.php @@ -117,7 +117,7 @@ class CreatureList extends BaseType return !$data ? 0 : $data[array_rand($data)]; } - public function getBaseStats($type) + public function getBaseStats(string $type) : array { // i'm aware of the BaseVariance/RangedVariance fields ... i'm just totaly unsure about the whole damage calculation switch ($type) @@ -142,8 +142,14 @@ class CreatureList extends BaseType $rngMin = ($this->getField('dmgMin') + ($this->getField('rngAtkPwrMin') / 14)) * $this->getField('dmgMultiplier') * $this->getField('rngAtkSpeed'); $rngMax = ($this->getField('dmgMax') * 1.5 + ($this->getField('rngAtkPwrMax') / 14)) * $this->getField('dmgMultiplier') * $this->getField('rngAtkSpeed'); return [$rngMin, $rngMax]; + case 'resistance': + $r = []; + for ($i = SPELL_SCHOOL_HOLY; $i < SPELL_SCHOOL_ARCANE+1; $i++) + $r[$i] = $this->getField('resistance'.$i); + + return $r; default: - return [0, 0]; + return []; } } diff --git a/localization/locale_dede.php b/localization/locale_dede.php index 15f5a8a2..7079bfcb 100644 --- a/localization/locale_dede.php +++ b/localization/locale_dede.php @@ -891,6 +891,7 @@ $lang = array( 'melee' => "Nahkampf", 'ranged' => "Fernkampf", 'armor' => "Rüstung", + 'resistances' => "Widerstände", 'foundIn' => "Dieser NPC befindet sich in", 'tameable' => "Zähmbar (%s)", 'waypoint' => "Wegpunkt", diff --git a/localization/locale_enus.php b/localization/locale_enus.php index 46b11a4c..2d3e638f 100644 --- a/localization/locale_enus.php +++ b/localization/locale_enus.php @@ -892,6 +892,7 @@ $lang = array( 'melee' => "Melee", 'ranged' => "Ranged", 'armor' => "Armor", + 'resistances' => "Resistances", 'foundIn' => "This NPC can be found in", 'tameable' => "Tameable (%s)", 'waypoint' => "Waypoint", diff --git a/localization/locale_eses.php b/localization/locale_eses.php index a3373e10..a93443e7 100644 --- a/localization/locale_eses.php +++ b/localization/locale_eses.php @@ -892,6 +892,7 @@ $lang = array( 'melee' => "Cuerpo a cuerpo", 'ranged' => "Ataque a distancia", 'armor' => "Armadura", + 'resistances' => "Resitencias", 'foundIn' => "Este PNJ se puede encontrar en", 'tameable' => "Domesticable (%s)", 'waypoint' => "punto de recorrido", diff --git a/localization/locale_frfr.php b/localization/locale_frfr.php index faef9554..afce72bf 100644 --- a/localization/locale_frfr.php +++ b/localization/locale_frfr.php @@ -892,6 +892,7 @@ $lang = array( 'melee' => "de mêlée", 'ranged' => "à distance", 'armor' => "Armure", + 'resistances' => "Résistances", 'foundIn' => "Ce PNJ se trouve dans", 'tameable' => "Domptable (%s)", 'waypoint' => "Point de route", diff --git a/localization/locale_ruru.php b/localization/locale_ruru.php index 11ab6211..6be1fbfc 100644 --- a/localization/locale_ruru.php +++ b/localization/locale_ruru.php @@ -892,6 +892,7 @@ $lang = array( 'melee' => "Ближнего боя", 'ranged' => "Дальнего боя", 'armor' => "Броня", + 'resistances' => "Сопротивление", 'foundIn' => "Этот объект может быть найден в следующих зонах:", 'tameable' => "Можно приручить (%s)", 'waypoint' => "Путевой точки", diff --git a/localization/locale_zhcn.php b/localization/locale_zhcn.php index 9e489589..d38ba315 100644 --- a/localization/locale_zhcn.php +++ b/localization/locale_zhcn.php @@ -892,6 +892,7 @@ $lang = array( 'melee' => "近战", 'ranged' => "远程", 'armor' => "护甲", + 'resistances' => "韧性", 'foundIn' => "这个NPC能在以下地区找到:", 'tameable' => "可驯服的(%s)", 'waypoint' => "路径点", diff --git a/pages/item.php b/pages/item.php index 1a8daab0..ef587ed8 100644 --- a/pages/item.php +++ b/pages/item.php @@ -386,7 +386,7 @@ class ItemPage extends genericPage 'quality' => $this->subject->getField('quality') ); - // merge identical stats and names for normal users (e.g. spellPower of a specific school became generel spellPower with 3.0) + // merge identical stats and names for normal users (e.g. spellPower of a specific school became general spellPower with 3.0) if (!User::isInGroup(U_GROUP_EMPLOYEE)) { diff --git a/pages/npc.php b/pages/npc.php index 4de0311f..aa343dc0 100644 --- a/pages/npc.php +++ b/pages/npc.php @@ -17,6 +17,7 @@ class NpcPage extends GenericPage protected $tabId = 0; protected $mode = CACHE_TYPE_PAGE; protected $js = ['swfobject.js']; + protected $css = [['path' => 'Profiler.css']]; private $soundIds = []; private $powerTpl = '$WowheadPower.registerNpc(%d, %d, %s);'; @@ -107,6 +108,9 @@ class NpcPage extends GenericPage } + + + /***********/ /* Infobox */ /***********/ @@ -247,6 +251,23 @@ class NpcPage extends GenericPage $armor = $this->subject->getBaseStats('armor'); $stats['armor'] = Lang::npc('armor').Lang::main('colon').($armor[0] < $armor[1] ? Lang::nf($armor[0]).' - '.Lang::nf($armor[1]) : Lang::nf($armor[0])); + // Resistances + $resNames = [null, 'hol', 'fir', 'nat', 'fro', 'sha', 'arc']; + $tmpRes = []; + $stats['resistance'] = ''; + foreach ($this->subject->getBaseStats('resistance') as $sc => $amt) + if ($amt) + $tmpRes[] = '[span class="moneyschool'.$resNames[$sc].'"]'.$amt.'[/span]'; + + if ($tmpRes) + { + $stats['resistance'] = Lang::npc('resistances').Lang::main('colon'); + if (count($tmpRes > 3)) + $stats['resistance'] .= implode(' ', array_slice($tmpRes, 0, 3)).'[br]'.implode(' ', array_slice($tmpRes, 3)); + else + $stats['resistance'] .= implode(' ', $tmpRes); + } + // Melee Damage $melee = $this->subject->getBaseStats('melee'); if ($_ = $this->subject->getField('dmgSchool')) // magic damage @@ -281,6 +302,22 @@ class NpcPage extends GenericPage $armor = $_altNPCs->getBaseStats('armor'); $modes['armor'][] = sprintf($modeRow, $m, $armor[0] < $armor[1] ? Lang::nf($armor[0]).' - '.Lang::nf($armor[1]) : Lang::nf($armor[0])); + // Resistances + $tmpRes = ''; + foreach ($_altNPCs->getBaseStats('resistance') as $sc => $amt) + $tmpRes .= '[td]'.$amt.'[/td]'; + + if ($tmpRes) + { + if (!isset($modes['resistance'])) // init table head + $modes['resistance'][] = '[td][/td][td][span class="moneyschoolhol"]    [/span][/td][td][span class="moneyschoolfir"]    [/span][/td][td][span class="moneyschoolnat"]    [/span][/td][td][span class="moneyschoolfro"]    [/span][/td][td][span class="moneyschoolsha"]    [/span][/td][td][span class="moneyschoolarc"][/span][/td]'; + + if (!$stats['resistance']) // base creature has no resistance. -> display list item. + $stats['resistance'] = Lang::npc('resistances').Lang::main('colon').'…'; + + $modes['resistance'][] = '[td]'.$m.'    [/td]'.$tmpRes; + } + // Melee Damage $melee = $_altNPCs->getBaseStats('melee'); if ($_ = $_altNPCs->getField('dmgSchool')) // magic damage diff --git a/setup/db_structure.sql b/setup/db_structure.sql index aed53a63..8a317b38 100644 --- a/setup/db_structure.sql +++ b/setup/db_structure.sql @@ -560,6 +560,12 @@ CREATE TABLE `aowow_creature` ( `manaMax` int(10) unsigned NOT NULL DEFAULT 1, `armorMin` mediumint(8) unsigned NOT NULL DEFAULT 1, `armorMax` mediumint(8) unsigned NOT NULL DEFAULT 1, + `resistance1` smallint(5) NOT NULL DEFAULT 0, + `resistance2` smallint(5) NOT NULL DEFAULT 0, + `resistance3` smallint(5) NOT NULL DEFAULT 0, + `resistance4` smallint(5) NOT NULL DEFAULT 0, + `resistance5` smallint(5) NOT NULL DEFAULT 0, + `resistance6` smallint(5) NOT NULL DEFAULT 0, `racialLeader` tinyint(3) unsigned NOT NULL DEFAULT 0, `mechanicImmuneMask` int(10) unsigned NOT NULL DEFAULT 0, `flagsExtra` int(10) unsigned NOT NULL DEFAULT 0, @@ -3132,7 +3138,7 @@ UNLOCK TABLES; LOCK TABLES `aowow_dbversion` WRITE; /*!40000 ALTER TABLE `aowow_dbversion` DISABLE KEYS */; -INSERT INTO `aowow_dbversion` VALUES (1591223186,0,NULL,NULL); +INSERT INTO `aowow_dbversion` VALUES (1608244865,0,NULL,NULL); /*!40000 ALTER TABLE `aowow_dbversion` ENABLE KEYS */; UNLOCK TABLES; diff --git a/setup/tools/sqlgen/creature.func.php b/setup/tools/sqlgen/creature.func.php index f0c93366..4da6ccf1 100644 --- a/setup/tools/sqlgen/creature.func.php +++ b/setup/tools/sqlgen/creature.func.php @@ -11,7 +11,7 @@ SqlGen::register(new class extends SetupScript { protected $command = 'creature'; - protected $tblDependancyTC = ['creature_template', 'creature_template_locale', 'creature_classlevelstats', 'instance_encounters']; + protected $tblDependancyTC = ['creature_template', 'creature_template_locale', 'creature_template_resistance', 'creature_template_spell', 'creature_classlevelstats', 'instance_encounters']; protected $dbcSourceFiles = ['creaturedisplayinfo', 'creaturedisplayinfoextra']; public function generate(array $ids = []) : bool @@ -65,6 +65,7 @@ SqlGen::register(new class extends SetupScript max.basemana * ct.ManaModifier AS manaMax, min.basearmor * ct.ArmorModifier AS armorMin, max.basearmor * ct.ArmorModifier AS armorMax, + IFNULL(ctr1.Resistance, 0), IFNULL(ctr2.Resistance, 0), IFNULL(ctr3.Resistance, 0), IFNULL(ctr4.Resistance, 0), IFNULL(ctr5.Resistance, 0), IFNULL(ctr6.Resistance, 0), RacialLeader, mechanic_immune_mask, flags_extra, @@ -107,6 +108,18 @@ SqlGen::register(new class extends SetupScript creature_template_spell cts6 ON ct.entry = cts6.CreatureID AND cts6.Index = 6 LEFT JOIN creature_template_spell cts7 ON ct.entry = cts7.CreatureID AND cts7.Index = 7 + LEFT JOIN + creature_template_resistance ctr1 ON ct.entry = ctr1.CreatureID AND ctr1.School = 1 + LEFT JOIN + creature_template_resistance ctr2 ON ct.entry = ctr2.CreatureID AND ctr2.School = 2 + LEFT JOIN + creature_template_resistance ctr3 ON ct.entry = ctr3.CreatureID AND ctr3.School = 3 + LEFT JOIN + creature_template_resistance ctr4 ON ct.entry = ctr4.CreatureID AND ctr4.School = 4 + LEFT JOIN + creature_template_resistance ctr5 ON ct.entry = ctr5.CreatureID AND ctr5.School = 5 + LEFT JOIN + creature_template_resistance ctr6 ON ct.entry = ctr6.CreatureID AND ctr6.School = 6 WHERE ct.entry > ?d { diff --git a/setup/updates/1608244863_01.sql b/setup/updates/1608244863_01.sql new file mode 100644 index 00000000..1bd640ca --- /dev/null +++ b/setup/updates/1608244863_01.sql @@ -0,0 +1,9 @@ +ALTER TABLE `aowow_creature` + ADD COLUMN `resistance1` SMALLINT NOT NULL DEFAULT 0 AFTER `armorMax`, + ADD COLUMN `resistance2` SMALLINT NOT NULL DEFAULT 0 AFTER `resistance1`, + ADD COLUMN `resistance3` SMALLINT NOT NULL DEFAULT 0 AFTER `resistance2`, + ADD COLUMN `resistance4` SMALLINT NOT NULL DEFAULT 0 AFTER `resistance3`, + ADD COLUMN `resistance5` SMALLINT NOT NULL DEFAULT 0 AFTER `resistance4`, + ADD COLUMN `resistance6` SMALLINT NOT NULL DEFAULT 0 AFTER `resistance5`; + +UPDATE `aowow_dbversion` SET `sql` = CONCAT(IFNULL(`sql`, ''), ' creature');