aboutsummaryrefslogtreecommitdiff
path: root/src/game/Unit.cpp
diff options
context:
space:
mode:
authorQAston <none@none>2009-02-07 22:03:29 +0100
committerQAston <none@none>2009-02-07 22:03:29 +0100
commit401ebf5455f665f53f770bd5037bd67bfe597d40 (patch)
treecb331beb404c63765eaaab9596dcb355af0aee59 /src/game/Unit.cpp
parent8a1b07e9c7259c1c426a3e1015df4cdf0c718c9b (diff)
*Handle SPELL_AURA_MOD_AURA_DURATION_BY_DISPEL and SPELL_AURA_MOD_AURA_DURATION_BY_DISPEL_NOT_STACK.
*Fix SPELL_AURA_MECHANIC_DURATION_MOD and SPELL_AURA_MECHANIC_DURATION_MOD_NOT_STACK for PVP. --HG-- branch : trunk
Diffstat (limited to 'src/game/Unit.cpp')
-rw-r--r--src/game/Unit.cpp38
1 files changed, 29 insertions, 9 deletions
diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp
index bc026849496..5ade3845276 100644
--- a/src/game/Unit.cpp
+++ b/src/game/Unit.cpp
@@ -10015,7 +10015,7 @@ int32 Unit::CalculateSpellDamage(SpellEntry const* spellProto, uint8 effect_inde
return value;
}
-int32 Unit::CalculateSpellDuration(SpellEntry const* spellProto, uint8 effect_index, Unit const* target)
+int32 Unit::CalcSpellDuration(SpellEntry const* spellProto)
{
Player* unitPlayer = (GetTypeId() == TYPEID_PLAYER) ? (Player*)this : NULL;
@@ -10031,16 +10031,24 @@ int32 Unit::CalculateSpellDuration(SpellEntry const* spellProto, uint8 effect_in
else
duration = minduration;
- if (duration > 0)
+ return duration;
+}
+
+int32 Unit::ModSpellDuration(SpellEntry const* spellProto, uint8 effect_index, Unit const* target, int32 duration)
+{
+ //don't mod permament auras duration
+ if (duration<0)
+ return duration;
+
+ //cut duration only of negative effects
+ if (!IsPositiveEffect(spellProto->Id, effect_index) )
{
int32 mechanic = GetEffectMechanic(spellProto, effect_index);
+
// Find total mod value (negative bonus)
int32 durationMod_always = target->GetTotalAuraModifierByMiscValue(SPELL_AURA_MECHANIC_DURATION_MOD, mechanic);
- // Modify from SPELL_AURA_MOD_DURATION_OF_EFFECTS_BY_DISPEL aura (stack always ?)
- durationMod_always+=target->GetTotalAuraModifierByMiscValue(SPELL_AURA_MOD_DURATION_OF_EFFECTS_BY_DISPEL, spellProto->Dispel);
// Find max mod (negative bonus)
int32 durationMod_not_stack = target->GetMaxNegativeAuraModifierByMiscValue(SPELL_AURA_MECHANIC_DURATION_MOD_NOT_STACK, mechanic);
-
int32 durationMod = 0;
// Select strongest negative mod
if (durationMod_always > durationMod_not_stack)
@@ -10049,12 +10057,24 @@ int32 Unit::CalculateSpellDuration(SpellEntry const* spellProto, uint8 effect_in
durationMod = durationMod_always;
if (durationMod != 0)
- duration = int32(int64(duration) * (100+durationMod) /100);
+ duration *= float(100.0f+durationMod) /100.0f;
- if (duration < 0) duration = 0;
- }
+ // there are only negative mods currently
+ durationMod_always =target->GetTotalAuraModifierByMiscValue(SPELL_AURA_MOD_AURA_DURATION_BY_DISPEL, spellProto->Dispel);
+ durationMod_not_stack=target->GetMaxNegativeAuraModifierByMiscValue(SPELL_AURA_MOD_AURA_DURATION_BY_DISPEL_NOT_STACK, spellProto->Dispel);
- return duration;
+ durationMod=0;
+ if (durationMod_always > durationMod_not_stack)
+ durationMod += durationMod_not_stack;
+ else
+ durationMod += durationMod_always;
+
+ if (durationMod != 0)
+ duration *= float(100.0f+durationMod) /100.0f;
+ }
+ //else positive mods here, there are no currently
+ //when there will be, change GetTotalAuraModifierByMiscValue to GetTotalPositiveAuraModifierByMiscValue
+ return duration>0 ? duration : 0;
}
DiminishingLevels Unit::GetDiminishing(DiminishingGroup group)