[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);
float comboDamage = spellProto->EffectPointsPerComboPoint[effect_index];
// prevent random generator from getting confused by spells casted with Unit::CastCustomSpell
int32 randvalue = spellProto->EffectBaseDice[effect_index] >= randomPoints ? spellProto->EffectBaseDice[effect_index]:irand(spellProto->EffectBaseDice[effect_index], randomPoints);
// range can have possitive and negative values, so order its for irand
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;
//random damage
if(comboDamage != 0 && unitPlayer && target && (target->GetGUID() == unitPlayer->GetComboTarget()))

View file

@ -34,27 +34,27 @@ static MTRandTSS mtRand;
int32 irand (int32 min, int32 max)
{
return int32 (mtRand.get ().randInt (max - min)) + min;
return int32 (mtRand.get ().randInt (max - min)) + min;
}
uint32 urand (uint32 min, uint32 max)
{
return mtRand.get ().randInt (max - min) + min;
return mtRand.get ().randInt (max - min) + min;
}
int32 rand32 ()
{
return mtRand.get ().randInt ();
return mtRand.get ().randInt ();
}
double rand_norm(void)
{
return mtRand.get ().randExc ();
return mtRand.get ().randExc ();
}
double rand_chance (void)
{
return mtRand.get ().randExc (100.0);
return mtRand.get ().randExc (100.0);
}
Tokens StrSplit(const std::string &src, const std::string &sep)

View file

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