Skip to content

Commit

Permalink
Creature/DetailPage
Browse files Browse the repository at this point in the history
 * display school resistance under stats in infobox
  • Loading branch information
Sarjuuk committed Dec 18, 2020
1 parent cac57f5 commit 5b41450
Show file tree
Hide file tree
Showing 12 changed files with 82 additions and 5 deletions.
10 changes: 8 additions & 2 deletions includes/types/creature.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ public function getRandomModelId()
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)
Expand All @@ -142,8 +142,14 @@ public function getBaseStats($type)
$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 [];
}
}

Expand Down
1 change: 1 addition & 0 deletions localization/locale_dede.php
Original file line number Diff line number Diff line change
Expand Up @@ -891,6 +891,7 @@
'melee' => "Nahkampf",
'ranged' => "Fernkampf",
'armor' => "Rüstung",
'resistances' => "Widerstände",
'foundIn' => "Dieser NPC befindet sich in",
'tameable' => "Zähmbar (%s)",
'waypoint' => "Wegpunkt",
Expand Down
1 change: 1 addition & 0 deletions localization/locale_enus.php
Original file line number Diff line number Diff line change
Expand Up @@ -892,6 +892,7 @@
'melee' => "Melee",
'ranged' => "Ranged",
'armor' => "Armor",
'resistances' => "Resistances",
'foundIn' => "This NPC can be found in",
'tameable' => "Tameable (%s)",
'waypoint' => "Waypoint",
Expand Down
1 change: 1 addition & 0 deletions localization/locale_eses.php
Original file line number Diff line number Diff line change
Expand Up @@ -892,6 +892,7 @@
'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",
Expand Down
1 change: 1 addition & 0 deletions localization/locale_frfr.php
Original file line number Diff line number Diff line change
Expand Up @@ -892,6 +892,7 @@
'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",
Expand Down
1 change: 1 addition & 0 deletions localization/locale_ruru.php
Original file line number Diff line number Diff line change
Expand Up @@ -892,6 +892,7 @@
'melee' => "Ближнего боя",
'ranged' => "Дальнего боя",
'armor' => "Броня",
'resistances' => "Сопротивление",
'foundIn' => "Этот объект может быть найден в следующих зонах:",
'tameable' => "Можно приручить (%s)",
'waypoint' => "Путевой точки",
Expand Down
1 change: 1 addition & 0 deletions localization/locale_zhcn.php
Original file line number Diff line number Diff line change
Expand Up @@ -892,6 +892,7 @@
'melee' => "近战",
'ranged' => "远程",
'armor' => "护甲",
'resistances' => "韧性",
'foundIn' => "这个NPC能在以下地区找到:",
'tameable' => "可驯服的(%s)",
'waypoint' => "路径点",
Expand Down
2 changes: 1 addition & 1 deletion pages/item.php
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ protected function generateContent()
'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))
{
Expand Down
37 changes: 37 additions & 0 deletions pages/npc.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);';
Expand Down Expand Up @@ -107,6 +108,9 @@ protected function generateContent()
}





/***********/
/* Infobox */
/***********/
Expand Down Expand Up @@ -247,6 +251,23 @@ protected function generateContent()
$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('&nbsp;', array_slice($tmpRes, 0, 3)).'[br]'.implode('&nbsp;', array_slice($tmpRes, 3));
else
$stats['resistance'] .= implode('&nbsp;', $tmpRes);
}

// Melee Damage
$melee = $this->subject->getBaseStats('melee');
if ($_ = $this->subject->getField('dmgSchool')) // magic damage
Expand Down Expand Up @@ -281,6 +302,22 @@ protected function generateContent()
$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"]&nbsp;&nbsp;&nbsp;&nbsp;[/span][/td][td][span class="moneyschoolfir"]&nbsp;&nbsp;&nbsp;&nbsp;[/span][/td][td][span class="moneyschoolnat"]&nbsp;&nbsp;&nbsp;&nbsp;[/span][/td][td][span class="moneyschoolfro"]&nbsp;&nbsp;&nbsp;&nbsp;[/span][/td][td][span class="moneyschoolsha"]&nbsp;&nbsp;&nbsp;&nbsp;[/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.'&nbsp;&nbsp;&nbsp;&nbsp;[/td]'.$tmpRes;
}

// Melee Damage
$melee = $_altNPCs->getBaseStats('melee');
if ($_ = $_altNPCs->getField('dmgSchool')) // magic damage
Expand Down
8 changes: 7 additions & 1 deletion setup/db_structure.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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;

Expand Down
15 changes: 14 additions & 1 deletion setup/tools/sqlgen/creature.func.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
{
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
Expand Down Expand Up @@ -65,6 +65,7 @@ public function generate(array $ids = []) : bool
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,
Expand Down Expand Up @@ -107,6 +108,18 @@ public function generate(array $ids = []) : bool
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
{
Expand Down
9 changes: 9 additions & 0 deletions setup/updates/1608244863_01.sql
Original file line number Diff line number Diff line change
@@ -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');

0 comments on commit 5b41450

Please sign in to comment.