[6975] Fixed spell damage calculation for negative EffectDieSides.

Thanks to NoFantasy for testing.

Also small code style apply to random generation functions.
This commit is contained in:
VladimirMangos 2008-12-29 22:55:03 +03:00
parent 02cc37bcd0
commit c5976f93da
3 changed files with 11 additions and 8 deletions

View file

@ -8757,8 +8757,11 @@ int32 Unit::CalculateSpellDamage(SpellEntry const* spellProto, uint8 effect_inde
int32 randomPoints = int32(spellProto->EffectDieSides[effect_index] + level * randomPointsPerLevel); int32 randomPoints = int32(spellProto->EffectDieSides[effect_index] + level * randomPointsPerLevel);
float comboDamage = spellProto->EffectPointsPerComboPoint[effect_index]; float comboDamage = spellProto->EffectPointsPerComboPoint[effect_index];
// prevent random generator from getting confused by spells casted with Unit::CastCustomSpell // range can have possitive and negative values, so order its for irand
int32 randvalue = spellProto->EffectBaseDice[effect_index] >= randomPoints ? spellProto->EffectBaseDice[effect_index]:irand(spellProto->EffectBaseDice[effect_index], randomPoints); int32 randvalue = int32(spellProto->EffectBaseDice[effect_index]) >= randomPoints
? irand(randomPoints, int32(spellProto->EffectBaseDice[effect_index]))
: irand(int32(spellProto->EffectBaseDice[effect_index]), randomPoints);
int32 value = basePoints + randvalue; int32 value = basePoints + randvalue;
//random damage //random damage
if(comboDamage != 0 && unitPlayer && target && (target->GetGUID() == unitPlayer->GetComboTarget())) if(comboDamage != 0 && unitPlayer && target && (target->GetGUID() == unitPlayer->GetComboTarget()))

View file

@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__ #ifndef __REVISION_NR_H__
#define __REVISION_NR_H__ #define __REVISION_NR_H__
#define REVISION_NR "6974" #define REVISION_NR "6975"
#endif // __REVISION_NR_H__ #endif // __REVISION_NR_H__