Skip to content

Commit

Permalink
[11023] Implement support for threat multiplier and AP based threat b…
Browse files Browse the repository at this point in the history
…onus for spells.

* Higher ranks are now automatically filled when not listed in spell_threat
* Added some loading checks to detect inconsistent data

Signed-off-by: Lynx3d <lynx3d@some-imaginary-isp.org>
  • Loading branch information
x3n authored and Lynx3d committed Jan 17, 2011
1 parent ab0945c commit f526a40
Show file tree
Hide file tree
Showing 12 changed files with 238 additions and 177 deletions.
238 changes: 120 additions & 118 deletions sql/mangos.sql
Expand Up @@ -24,7 +24,7 @@ CREATE TABLE `db_version` (
`version` varchar(120) default NULL,
`creature_ai_version` varchar(120) default NULL,
`cache_id` int(10) default '0',
`required_11018_01_mangos_command` bit(1) default NULL
`required_11023_01_mangos_spell_threat` bit(1) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Used DB version notes';

--
Expand Down Expand Up @@ -17629,6 +17629,8 @@ DROP TABLE IF EXISTS `spell_threat`;
CREATE TABLE `spell_threat` (
`entry` mediumint(8) unsigned NOT NULL,
`Threat` smallint(6) NOT NULL,
`multiplier` float NOT NULL default '1' COMMENT 'threat multiplier for damage/healing',
`ap_bonus` float NOT NULL default '0' COMMENT 'additional threat bonus from attack power',
PRIMARY KEY (`entry`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED;

Expand All @@ -17639,123 +17641,123 @@ CREATE TABLE `spell_threat` (
LOCK TABLES `spell_threat` WRITE;
/*!40000 ALTER TABLE `spell_threat` DISABLE KEYS */;
INSERT INTO `spell_threat` VALUES
(72,293),
(78,20),
(99,42),
(284,39),
(285,59),
(469,40),
(676,104),
(770,108),
(845,10),
(1160,16),
(1608,78),
(1672,180),
(1715,61),
(1735,42),
(2048,70),
(2139,300),
(5242,26),
(6190,26),
(6192,32),
(6343,17),
(6572,155),
(6673,18),
(6574,195),
(6807,322),
(6808,322),
(6809,322),
(7369,40),
(7372,101),
(7373,141),
(7379,235),
(7386,100),
(8198,40),
(8204,64),
(8205,96),
(8972,322),
(9490,42),
(9745,322),
(9747,42),
(9880,322),
(9881,322),
(9898,42),
(11549,40),
(11550,48),
(11551,56),
(11554,30),
(11555,37),
(11556,43),
(11564,98),
(11565,118),
(11566,137),
(11567,145),
(11580,143),
(11581,180),
(11600,275),
(11601,315),
(11608,60),
(11609,70),
(11775,395),
(14921,415),
(16857,108),
(17735,200),
(17750,300),
(17751,450),
(17752,600),
(20569,100),
(20736,100),
(20925,20),
(20927,30),
(20928,40),
(23922,160),
(23923,190),
(23924,220),
(23925,250),
(24394,580),
(24583,5),
(25202,50),
(25203,55),
(25231,130),
(25258,286),
(25264,215),
(25269,400),
(25286,175),
(25288,355),
(25289,62),
(26996,322),
(26998,42),
(27179,54),
(29704,230),
(29707,196),
(30324,220),
(30356,323),
(30357,483),
(33745,285),
(33878,129),
(33986,180),
(33987,232),
(47436,78),
(47437,63),
(47439,60),
(47440,80),
(47449,236),
(47450,259),
(47487,520),
(47488,770),
(47497,101),
(47498,101),
(47501,235),
(47502,260),
(47519,180),
(47520,225),
(48479,322),
(48480,322),
(48559,42),
(48560,42),
(48567,285),
(48568,285),
(57823,500);
( 72, 293, 1, 0),
( 78, 20, 1, 0),
( 99, 42, 1, 0),
( 284, 39, 1, 0),
( 285, 59, 1, 0),
( 469, 40, 1, 0),
( 676, 104, 1, 0),
( 770, 108, 1, 0),
( 845, 10, 1, 0),
( 1160, 16, 1, 0),
( 1608, 78, 1, 0),
( 1672, 180, 1, 0),
( 1715, 61, 1, 0),
( 1735, 42, 1, 0),
( 2048, 70, 1, 0),
( 2139, 300, 1, 0),
( 5242, 26, 1, 0),
( 6190, 26, 1, 0),
( 6192, 32, 1, 0),
( 6343, 17, 1, 0),
( 6572, 155, 1, 0),
( 6673, 18, 1, 0),
( 6574, 195, 1, 0),
( 6807, 322, 1, 0),
( 6808, 322, 1, 0),
( 6809, 322, 1, 0),
( 7369, 40, 1, 0),
( 7372, 101, 1, 0),
( 7373, 141, 1, 0),
( 7379, 235, 1, 0),
( 7386, 100, 1, 0),
( 8198, 40, 1, 0),
( 8204, 64, 1, 0),
( 8205, 96, 1, 0),
( 8972, 322, 1, 0),
( 9490, 42, 1, 0),
( 9745, 322, 1, 0),
( 9747, 42, 1, 0),
( 9880, 322, 1, 0),
( 9881, 322, 1, 0),
( 9898, 42, 1, 0),
(11549, 40, 1, 0),
(11550, 48, 1, 0),
(11551, 56, 1, 0),
(11554, 30, 1, 0),
(11555, 37, 1, 0),
(11556, 43, 1, 0),
(11564, 98, 1, 0),
(11565, 118, 1, 0),
(11566, 137, 1, 0),
(11567, 145, 1, 0),
(11580, 143, 1, 0),
(11581, 180, 1, 0),
(11600, 275, 1, 0),
(11601, 315, 1, 0),
(11608, 60, 1, 0),
(11609, 70, 1, 0),
(11775, 395, 1, 0),
(14921, 415, 1, 0),
(16857, 108, 1, 0),
(17735, 200, 1, 0),
(17750, 300, 1, 0),
(17751, 450, 1, 0),
(17752, 600, 1, 0),
(20569, 100, 1, 0),
(20736, 100, 1, 0),
(20925, 20, 1, 0),
(20927, 30, 1, 0),
(20928, 40, 1, 0),
(23922, 160, 1, 0),
(23923, 190, 1, 0),
(23924, 220, 1, 0),
(23925, 250, 1, 0),
(24394, 580, 1, 0),
(24583, 5, 1, 0),
(25202, 50, 1, 0),
(25203, 55, 1, 0),
(25231, 130, 1, 0),
(25258, 286, 1, 0),
(25264, 215, 1, 0),
(25269, 400, 1, 0),
(25286, 175, 1, 0),
(25288, 355, 1, 0),
(25289, 62, 1, 0),
(26996, 322, 1, 0),
(26998, 42, 1, 0),
(27179, 54, 1, 0),
(29704, 230, 1, 0),
(29707, 196, 1, 0),
(30324, 220, 1, 0),
(30356, 323, 1, 0),
(30357, 483, 1, 0),
(33745, 285, 1, 0),
(33878, 129, 1, 0),
(33986, 180, 1, 0),
(33987, 232, 1, 0),
(47436, 78, 1, 0),
(47437, 63, 1, 0),
(47439, 60, 1, 0),
(47440, 80, 1, 0),
(47449, 236, 1, 0),
(47450, 259, 1, 0),
(47487, 520, 1, 0),
(47488, 770, 1, 0),
(47497, 101, 1, 0),
(47498, 101, 1, 0),
(47501, 235, 1, 0),
(47502, 260, 1, 0),
(47519, 180, 1, 0),
(47520, 225, 1, 0),
(48479, 322, 1, 0),
(48480, 322, 1, 0),
(48559, 42, 1, 0),
(48560, 42, 1, 0),
(48567, 285, 1, 0),
(48568, 285, 1, 0),
(57823, 500, 1, 0);
/*!40000 ALTER TABLE `spell_threat` ENABLE KEYS */;
UNLOCK TABLES;

Expand Down
5 changes: 5 additions & 0 deletions sql/updates/11023_01_mangos_spell_threat.sql
@@ -0,0 +1,5 @@
ALTER TABLE db_version CHANGE COLUMN required_11018_01_mangos_command required_11023_01_mangos_spell_threat bit;

ALTER TABLE spell_threat ADD COLUMN multiplier FLOAT NOT NULL DEFAULT 1.0 COMMENT 'threat multiplier for damage/healing' AFTER Threat;

ALTER TABLE spell_threat ADD COLUMN ap_bonus FLOAT NOT NULL DEFAULT 0.0 COMMENT 'additional threat bonus from attack power' AFTER multiplier;
2 changes: 2 additions & 0 deletions sql/updates/Makefile.am
Expand Up @@ -153,6 +153,7 @@ pkgdata_DATA = \
10998_01_mangos_spell_proc_event.sql \
11002_01_mangos_spell_proc_event.sql \
11018_01_mangos_command.sql \
11023_01_mangos_spell_threat.sql \
README

## Additional files to include when running 'make dist'
Expand Down Expand Up @@ -286,4 +287,5 @@ EXTRA_DIST = \
10998_01_mangos_spell_proc_event.sql \
11002_01_mangos_spell_proc_event.sql \
11018_01_mangos_command.sql \
11023_01_mangos_spell_threat.sql \
README
14 changes: 9 additions & 5 deletions src/game/Spell.cpp
Expand Up @@ -1023,7 +1023,7 @@ void Spell::DoAllEffectOnTarget(TargetInfo *target)
int32 gain = caster->DealHeal(unitTarget, addhealth, m_spellInfo, crit, absorb);

if (real_caster)
unitTarget->getHostileRefManager().threatAssist(real_caster, float(gain) * 0.5f, m_spellInfo);
unitTarget->getHostileRefManager().threatAssist(real_caster, float(gain) * 0.5f * sSpellMgr.GetSpellThreatMultiplier(m_spellInfo), m_spellInfo);
}
// Do damage and triggers
else if (m_damage)
Expand Down Expand Up @@ -4225,14 +4225,18 @@ void Spell::HandleThreatSpells(uint32 spellId)
if(!m_targets.getUnitTarget()->CanHaveThreatList())
return;

uint16 threat = sSpellMgr.GetSpellThreat(spellId);
SpellThreatEntry const* threatEntry = sSpellMgr.GetSpellThreatEntry(spellId);

if(!threat)
if(!threatEntry || (!threatEntry->threat && threatEntry->ap_bonus == 0.0f))
return;

m_targets.getUnitTarget()->AddThreat(m_caster, float(threat), false, GetSpellSchoolMask(m_spellInfo), m_spellInfo);
float threat = threatEntry->threat;
if (threatEntry->ap_bonus != 0.0f)
threat += threatEntry->ap_bonus * m_caster->GetTotalAttackPowerValue(GetWeaponAttackType(m_spellInfo));

DEBUG_FILTER_LOG(LOG_FILTER_SPELL_CAST, "Spell %u, rank %u, added an additional %i threat", spellId, sSpellMgr.GetSpellRank(spellId), threat);
m_targets.getUnitTarget()->AddThreat(m_caster, threat, false, GetSpellSchoolMask(m_spellInfo), m_spellInfo);

DEBUG_FILTER_LOG(LOG_FILTER_SPELL_CAST, "Spell %u, rank %u, added an additional %f threat", spellId, sSpellMgr.GetSpellRank(spellId), threat);
}

void Spell::HandleEffects(Unit *pUnitTarget,Item *pItemTarget,GameObject *pGOTarget,SpellEffectIndex i, float DamageMultiplier)
Expand Down
10 changes: 5 additions & 5 deletions src/game/SpellAuras.cpp
Expand Up @@ -6879,7 +6879,7 @@ void Aura::PeriodicTick()
pCaster->CalculateHealAbsorb(heal, &absorbHeal);

int32 gain = pCaster->DealHeal(pCaster, heal - absorbHeal, spellProto, false, absorbHeal);
pCaster->getHostileRefManager().threatAssist(pCaster, gain * 0.5f, spellProto);
pCaster->getHostileRefManager().threatAssist(pCaster, gain * 0.5f * sSpellMgr.GetSpellThreatMultiplier(spellProto), spellProto);
break;
}
case SPELL_AURA_PERIODIC_HEAL:
Expand Down Expand Up @@ -6951,7 +6951,7 @@ void Aura::PeriodicTick()
if( BattleGround *bg = ((Player*)pCaster)->GetBattleGround() )
bg->UpdatePlayerScore(((Player*)pCaster), SCORE_HEALING_DONE, gain);

target->getHostileRefManager().threatAssist(pCaster, float(gain) * 0.5f, spellProto);
target->getHostileRefManager().threatAssist(pCaster, float(gain) * 0.5f * sSpellMgr.GetSpellThreatMultiplier(spellProto), spellProto);

// heal for caster damage
if(target != pCaster && spellProto->SpellVisual[0] == 163)
Expand Down Expand Up @@ -7091,7 +7091,7 @@ void Aura::PeriodicTick()
int32 gain = target->ModifyPower(power,pdamage);

if(Unit* pCaster = GetCaster())
target->getHostileRefManager().threatAssist(pCaster, float(gain) * 0.5f, spellProto);
target->getHostileRefManager().threatAssist(pCaster, float(gain) * 0.5f * sSpellMgr.GetSpellThreatMultiplier(spellProto), spellProto);
break;
}
case SPELL_AURA_OBS_MOD_MANA:
Expand All @@ -7117,7 +7117,7 @@ void Aura::PeriodicTick()
int32 gain = target->ModifyPower(POWER_MANA, pdamage);

if(Unit* pCaster = GetCaster())
target->getHostileRefManager().threatAssist(pCaster, float(gain) * 0.5f, spellProto);
target->getHostileRefManager().threatAssist(pCaster, float(gain) * 0.5f * sSpellMgr.GetSpellThreatMultiplier(spellProto), spellProto);
break;
}
case SPELL_AURA_POWER_BURN_MANA:
Expand Down Expand Up @@ -7179,7 +7179,7 @@ void Aura::PeriodicTick()

int32 gain = target->ModifyHealth(m_modifier.m_amount);
if (Unit *caster = GetCaster())
target->getHostileRefManager().threatAssist(caster, float(gain) * 0.5f, spellProto);
target->getHostileRefManager().threatAssist(caster, float(gain) * 0.5f * sSpellMgr.GetSpellThreatMultiplier(spellProto), spellProto);
break;
}
case SPELL_AURA_MOD_POWER_REGEN:
Expand Down
2 changes: 1 addition & 1 deletion src/game/SpellEffects.cpp
Expand Up @@ -3538,7 +3538,7 @@ void Spell::EffectHealPct(SpellEffectIndex /*eff_idx*/)
unitTarget->CalculateHealAbsorb(addhealth, &absorb);

int32 gain = caster->DealHeal(unitTarget, addhealth - absorb, m_spellInfo, false, absorb);
unitTarget->getHostileRefManager().threatAssist(caster, float(gain) * 0.5f, m_spellInfo);
unitTarget->getHostileRefManager().threatAssist(caster, float(gain) * 0.5f * sSpellMgr.GetSpellThreatMultiplier(m_spellInfo), m_spellInfo);
}
}

Expand Down

0 comments on commit f526a40

Please sign in to comment.