From 8d97ad06b2da9be964fe1a46a233552f3b0b4b34 Mon Sep 17 00:00:00 2001 From: VladimirMangos Date: Tue, 6 Apr 2010 18:49:53 +0400 Subject: [PATCH] Fixed random base poinst part calculation 0 - unused, 1 -> always +1, other in ranges (rand...1) or (1..rand) --- src/game/Unit.cpp | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp index 3083cdf79..8e622b179 100644 --- a/src/game/Unit.cpp +++ b/src/game/Unit.cpp @@ -11308,15 +11308,20 @@ int32 Unit::CalculateSpellDamage(SpellEntry const* spellProto, SpellEffectIndex int32 randomPoints = int32(spellProto->EffectDieSides[effect_index]); float comboDamage = spellProto->EffectPointsPerComboPoint[effect_index]; - if(randomPoints != 0) + switch(randomPoints) { - // range can have positive and negative values, so order its for irand - int32 randvalue = (0 > randomPoints) - ? irand(randomPoints, 0) - : irand(0, randomPoints); + case 0: break; // not used + case 1: basePoints += 1; break; // range 1..1 + default: + // range can have positive (1..rand) and negative (rand..1) values, so order its for irand + int32 randvalue = (randomPoints >= 1) + ? irand(1, randomPoints) + : irand(randomPoints, 1); - basePoints += randvalue; + basePoints += randvalue; + break; } + int32 value = basePoints;