Stats/Fixup
* fix melee attack power from spells counting towards generic attack power * combine melee and ranged attack power from the same spell into generic attack power, if amounts are equal
This commit is contained in:
parent
f7a1ae241f
commit
750e176c33
3 changed files with 28 additions and 12 deletions
|
|
@ -334,10 +334,19 @@ abstract class Stat // based on g_statTo
|
|||
|
||||
class StatsContainer implements \Countable
|
||||
{
|
||||
private $store = [];
|
||||
private array $store = [];
|
||||
|
||||
private $relSpells = [];
|
||||
private $relEnchantments = [];
|
||||
private array $relSpells = [];
|
||||
private array $relEnchantments = [];
|
||||
|
||||
private static array $combinedSpellStats = array (
|
||||
Stat::ATTACK_POWER => [Stat::RANGED_ATTACK_POWER, Stat::MELEE_ATTACK_POWER],
|
||||
Stat::SPELL_POWER => [Stat::DAMAGE_SPELL_POWER, Stat::HEALING_SPELL_POWER],
|
||||
// combat ratings below could be merged like this, but easier to handle as they are already in the same bitmask of the same spell effect
|
||||
// Stat::HIT_RTG => [Stat::MELEE_HIT_RTG, Stat::RANGED_HIT_RTG, Stat::SPELL_HIT_RTG],
|
||||
// Stat::CRIT_RTG => [Stat::MELEE_CRIT_TAKEN_RTG, Stat::RANGED_CRIT_RTG, Stat::SPELL_CRIT_RTG],
|
||||
// Stat::RESILIENCE_RTG => [Stat::MELEE_CRIT_RTG, Stat::RANGED_CRIT_TAKEN_RTG, Stat::SPELL_CRIT_TAKEN_RTG]
|
||||
);
|
||||
|
||||
public function __construct(array $relSpells = [], array $relEnchantments = [])
|
||||
{
|
||||
|
|
@ -415,8 +424,6 @@ class StatsContainer implements \Countable
|
|||
if ($onlyFoodBuff && !($spell['attributes2'] & SPELL_ATTR2_FOOD_BUFF))
|
||||
return $this;
|
||||
|
||||
// if spells grant an equal, non-zero amount of SPELL_DAMAGE and SPELL_HEALING, combine them to SPELL_POWER
|
||||
// this probably does not affect enchantments
|
||||
$tmpStore = [];
|
||||
|
||||
for ($i = 1; $i <= 3; $i++)
|
||||
|
|
@ -438,11 +445,20 @@ class StatsContainer implements \Countable
|
|||
Util::arraySumByKey($tmpStore, [$idx => $amt]);
|
||||
}
|
||||
|
||||
if (!empty($tmpStore[Stat::HEALING_SPELL_POWER]) && !empty($tmpStore[Stat::DAMAGE_SPELL_POWER]) && $tmpStore[Stat::HEALING_SPELL_POWER] == $tmpStore[Stat::DAMAGE_SPELL_POWER])
|
||||
foreach (self::$combinedSpellStats as $combined => $stats)
|
||||
{
|
||||
Util::arraySumByKey($tmpStore, [Stat::SPELL_POWER => $tmpStore[Stat::HEALING_SPELL_POWER]]);
|
||||
unset($tmpStore[Stat::HEALING_SPELL_POWER]);
|
||||
unset($tmpStore[Stat::DAMAGE_SPELL_POWER]);
|
||||
for ($i = 0; $i < count($stats); $i++)
|
||||
{
|
||||
if (empty($tmpStore[$stats[$i]]))
|
||||
continue 2;
|
||||
|
||||
if ($i && $tmpStore[$stats[$i]] != $tmpStore[$stats[$i - 1]])
|
||||
continue 2;
|
||||
}
|
||||
|
||||
Util::arraySumByKey($tmpStore, [$combined => $tmpStore[$stats[0]]]);
|
||||
foreach ($stats as $stat)
|
||||
unset($tmpStore[$stat]);
|
||||
}
|
||||
|
||||
Util::arraySumByKey($this->store, $tmpStore);
|
||||
|
|
@ -586,7 +602,6 @@ class StatsContainer implements \Countable
|
|||
if (($mask & $critMask) == $critMask)
|
||||
return [Stat::CRIT_RTG]; // generic crit rating
|
||||
|
||||
|
||||
$takentMask = (1 << CR_CRIT_TAKEN_MELEE) | (1 << CR_CRIT_TAKEN_RANGED) | (1 << CR_CRIT_TAKEN_SPELL);
|
||||
if (($mask & $takentMask) == $takentMask)
|
||||
return [Stat::RESILIENCE_RTG]; // resilience
|
||||
|
|
@ -689,7 +704,7 @@ class StatsContainer implements \Countable
|
|||
case SPELL_AURA_MOD_POWER_REGEN: // mp5
|
||||
return [Stat::MANA_REGENERATION];
|
||||
case SPELL_AURA_MOD_ATTACK_POWER:
|
||||
return [Stat::ATTACK_POWER/*, Stat::RANGED_ATTACK_POWER*/];
|
||||
return [Stat::MELEE_ATTACK_POWER];
|
||||
case SPELL_AURA_MOD_RANGED_ATTACK_POWER:
|
||||
return [Stat::RANGED_ATTACK_POWER];
|
||||
case SPELL_AURA_MOD_SHIELD_BLOCKVALUE:
|
||||
|
|
|
|||
|
|
@ -723,7 +723,7 @@ abstract class Util
|
|||
/* file handling */
|
||||
/*****************/
|
||||
|
||||
public static function writeFile($file, $content)
|
||||
public static function writeFile(string $file, string $content) : bool
|
||||
{
|
||||
$success = false;
|
||||
|
||||
|
|
|
|||
1
setup/sql/updates/1771934998_01.sql
Normal file
1
setup/sql/updates/1771934998_01.sql
Normal file
|
|
@ -0,0 +1 @@
|
|||
UPDATE `aowow_dbversion` SET `sql` = CONCAT(IFNULL(`sql`, ''), ' stats');
|
||||
Loading…
Add table
Add a link
Reference in a new issue