aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/game/ConfusedMovementGenerator.cpp4
-rw-r--r--src/game/GameObject.cpp2
-rw-r--r--src/game/Object.cpp4
-rw-r--r--src/game/Player.cpp20
-rw-r--r--src/game/RandomMovementGenerator.cpp4
-rw-r--r--src/game/Spell.cpp18
-rw-r--r--src/game/SpellEffects.cpp54
-rw-r--r--src/game/Unit.cpp32
8 files changed, 69 insertions, 69 deletions
diff --git a/src/game/ConfusedMovementGenerator.cpp b/src/game/ConfusedMovementGenerator.cpp
index 2a81facc126..a82553c0189 100644
--- a/src/game/ConfusedMovementGenerator.cpp
+++ b/src/game/ConfusedMovementGenerator.cpp
@@ -44,8 +44,8 @@ ConfusedMovementGenerator<T>::Initialize(T &unit)
for(unsigned int idx=0; idx < MAX_CONF_WAYPOINTS+1; ++idx)
{
- const float wanderX=wander_distance*rand_norm() - wander_distance/2;
- const float wanderY=wander_distance*rand_norm() - wander_distance/2;
+ const float wanderX=wander_distance*rand_norm() - wander_distance/2;
+ const float wanderY=wander_distance*rand_norm() - wander_distance/2;
i_waypoints[idx][0] = x + wanderX;
i_waypoints[idx][1] = y + wanderY;
diff --git a/src/game/GameObject.cpp b/src/game/GameObject.cpp
index 744b6679862..d50c2698759 100644
--- a/src/game/GameObject.cpp
+++ b/src/game/GameObject.cpp
@@ -1067,7 +1067,7 @@ void GameObject::Use(Unit* user)
int32 skill = player->GetSkillValue(SKILL_FISHING);
int32 chance = skill - zone_skill + 5;
- int32 roll = irand(1,100);
+ int32 roll = GetMap()->irand(1,100);
DEBUG_LOG("Fishing check (skill: %i zone min skill: %i chance %i roll: %i",skill,zone_skill,chance,roll);
diff --git a/src/game/Object.cpp b/src/game/Object.cpp
index fe3239e9d6b..04f6646bea1 100644
--- a/src/game/Object.cpp
+++ b/src/game/Object.cpp
@@ -1285,8 +1285,8 @@ void WorldObject::GetRandomPoint( float x, float y, float z, float distance, flo
}
// angle to face `obj` to `this`
- float angle = rand_norm()*2*M_PI;
- float new_dist = rand_norm()*distance;
+ float angle = GetMap()->rand_norm()*2*M_PI;
+ float new_dist = GetMap()->rand_norm()*distance;
rand_x = x + new_dist * cos(angle);
rand_y = y + new_dist * sin(angle);
diff --git a/src/game/Player.cpp b/src/game/Player.cpp
index e91728ab9be..e11b7e168ef 100644
--- a/src/game/Player.cpp
+++ b/src/game/Player.cpp
@@ -293,7 +293,7 @@ Player::Player (WorldSession *session): Unit()
// randomize first save time in range [CONFIG_INTERVAL_SAVE] around [CONFIG_INTERVAL_SAVE]
// this must help in case next save after mass player load after server startup
- m_nextSave = urand(m_nextSave/2,m_nextSave*3/2);
+ m_nextSave = GetMap()->urand(m_nextSave/2,m_nextSave*3/2);
clearResurrectRequestData();
@@ -905,7 +905,7 @@ void Player::HandleDrowning()
{
//TODO: Check this formula
uint64 guid = GetGUID();
- uint32 damage = GetMaxHealth() / 5 + urand(0, getLevel()-1);
+ uint32 damage = GetMaxHealth() / 5 + GetMap()->urand(0, getLevel()-1);
EnvironmentalDamage(guid, DAMAGE_DROWNING,damage);
m_breathTimer = 2000;
@@ -944,7 +944,7 @@ void Player::HandleLava()
if (!m_breathTimer)
{
uint64 guid = GetGUID();
- uint32 damage = urand(600, 700); // TODO: Get more detailed information about lava damage
+ uint32 damage = GetMap()->urand(600, 700); // TODO: Get more detailed information about lava damage
uint32 dmgZone = GetZoneId(); // TODO: Find correct "lava dealing zone" flag in Area Table
// Deal lava damage only in lava zones.
@@ -4724,7 +4724,7 @@ bool Player::UpdateSkill(uint32 skill_id, uint32 step)
if ((!max) || (!value) || (value >= max))
return false;
- if (value*512 < max*urand(0,512))
+ if (value*512 < max*GetMap()->urand(0,512))
{
uint32 new_value = value+step;
if(new_value > max)
@@ -4846,7 +4846,7 @@ bool Player::UpdateSkillPro(uint16 SkillId, int32 Chance, uint32 step)
if ( !MaxValue || !SkillValue || SkillValue >= MaxValue )
return false;
- int32 Roll = irand(1,1000);
+ int32 Roll = GetMap()->irand(1,1000);
if ( Roll <= Chance )
{
@@ -6139,7 +6139,7 @@ bool Player::RewardHonor(Unit *uVictim, uint32 groupsize, float honor, bool pvpt
if(groupsize > 1)
honor /= groupsize;
- honor *= (((float)urand(8,12))/10); // approx honor: 80% - 120% of real honor
+ honor *= (((float)GetMap()->urand(8,12))/10); // approx honor: 80% - 120% of real honor
}
// honor - for show honor points in log
@@ -7417,7 +7417,7 @@ void Player::SendLoot(uint64 guid, LootType loot_type)
loot->FillLoot(1, LootTemplates_Creature, this);
// It may need a better formula
// Now it works like this: lvl10: ~6copper, lvl70: ~9silver
- bones->loot.gold = (uint32)( urand(50, 150) * 0.016f * pow( ((float)pLevel)/5.76f, 2.5f) * sWorld.getRate(RATE_DROP_MONEY) );
+ bones->loot.gold = (uint32)( GetMap()->urand(50, 150) * 0.016f * pow( ((float)pLevel)/5.76f, 2.5f) * sWorld.getRate(RATE_DROP_MONEY) );
}
if (bones->lootRecipient != this)
@@ -7453,8 +7453,8 @@ void Player::SendLoot(uint64 guid, LootType loot_type)
loot->FillLoot(lootid, LootTemplates_Pickpocketing, this);
// Generate extra money for pick pocket loot
- const uint32 a = urand(0, creature->getLevel()/2);
- const uint32 b = urand(0, getLevel()/2);
+ const uint32 a = GetMap()->urand(0, creature->getLevel()/2);
+ const uint32 b = GetMap()->urand(0, getLevel()/2);
loot->gold = uint32(10 * (a + b) * sWorld.getRate(RATE_DROP_MONEY));
}
}
@@ -19021,7 +19021,7 @@ Player* Player::GetNextRandomRaidMember(float radius)
if (nearMembers.empty())
return NULL;
- uint32 randTarget = urand(0,nearMembers.size()-1);
+ uint32 randTarget = GetMap()->urand(0,nearMembers.size()-1);
return nearMembers[randTarget];
}
diff --git a/src/game/RandomMovementGenerator.cpp b/src/game/RandomMovementGenerator.cpp
index ffa82467fd0..ac16f969f41 100644
--- a/src/game/RandomMovementGenerator.cpp
+++ b/src/game/RandomMovementGenerator.cpp
@@ -128,7 +128,7 @@ RandomMovementGenerator<Creature>::Initialize(Creature &creature)
if (creature.canFly())
creature.AddUnitMovementFlag(MOVEMENTFLAG_FLYING2);
else
- creature.SetUnitMovementFlags(irand(0,RUNNING_CHANCE_RANDOMMV) > 0 ? MOVEMENTFLAG_WALK_MODE : MOVEMENTFLAG_NONE );
+ creature.SetUnitMovementFlags(creature.GetMap()->irand(0,RUNNING_CHANCE_RANDOMMV) > 0 ? MOVEMENTFLAG_WALK_MODE : MOVEMENTFLAG_NONE );
_setRandomLocation(creature);
}
@@ -171,7 +171,7 @@ RandomMovementGenerator<Creature>::Update(Creature &creature, const uint32 &diff
if (creature.canFly())
creature.AddUnitMovementFlag(MOVEMENTFLAG_FLYING2);
else
- creature.SetUnitMovementFlags(irand(0,RUNNING_CHANCE_RANDOMMV) > 0 ? MOVEMENTFLAG_WALK_MODE : MOVEMENTFLAG_NONE);
+ creature.SetUnitMovementFlags(creature.GetMap()->irand(0,RUNNING_CHANCE_RANDOMMV) > 0 ? MOVEMENTFLAG_WALK_MODE : MOVEMENTFLAG_NONE);
_setRandomLocation(creature);
}
else if(creature.isPet() && creature.GetOwner() && creature.GetDistance(creature.GetOwner()) > PET_FOLLOW_DIST+2.5f)
diff --git a/src/game/Spell.cpp b/src/game/Spell.cpp
index 4fdd26c806f..49b957c05bf 100644
--- a/src/game/Spell.cpp
+++ b/src/game/Spell.cpp
@@ -1601,7 +1601,7 @@ void Spell::SetTargetMap(uint32 i, uint32 cur)
AddUnitTarget(m_caster, i);
float min_dis = GetSpellMinRange(sSpellRangeStore.LookupEntry(m_spellInfo->rangeIndex));
float max_dis = GetSpellMaxRange(sSpellRangeStore.LookupEntry(m_spellInfo->rangeIndex));
- float dis = rand_norm() * (max_dis - min_dis) + min_dis;
+ float dis = m_caster->GetMap()->rand_norm() * (max_dis - min_dis) + min_dis;
float x, y, z;
m_caster->GetClosePoint(x, y, z, DEFAULT_WORLD_OBJECT_SIZE, dis);
m_targets.setDestination(x, y, z);
@@ -1729,7 +1729,7 @@ void Spell::SetTargetMap(uint32 i, uint32 cur)
if(dist < objSize)
dist = objSize;
else if(cur == TARGET_DEST_CASTER_RANDOM)
- dist = objSize + (dist - objSize) * rand_norm();
+ dist = objSize + (dist - objSize) * m_caster->GetMap()->rand_norm();
switch(cur)
{
@@ -1773,7 +1773,7 @@ void Spell::SetTargetMap(uint32 i, uint32 cur)
if(dist < objSize)
dist = objSize;
else if(cur == TARGET_DEST_CASTER_RANDOM)
- dist = objSize + (dist - objSize) * rand_norm();
+ dist = objSize + (dist - objSize) * m_caster->GetMap()->rand_norm();
switch(cur)
{
@@ -1785,7 +1785,7 @@ void Spell::SetTargetMap(uint32 i, uint32 cur)
case TARGET_DEST_TARGET_BACK_LEFT: angle = -3*M_PI/4; break;
case TARGET_DEST_TARGET_BACK_RIGHT: angle = 3*M_PI/4; break;
case TARGET_DEST_TARGET_FRONT_RIGHT:angle = M_PI/4; break;
- default: angle = rand_norm()*2*M_PI; break;
+ default: angle = m_caster->GetMap()->rand_norm()*2*M_PI; break;
}
target->GetGroundPointAroundUnit(x, y, z, dist, angle);
@@ -1818,13 +1818,13 @@ void Spell::SetTargetMap(uint32 i, uint32 cur)
case TARGET_DEST_DEST_BACK_LEFT: angle = -3*M_PI/4; break;
case TARGET_DEST_DEST_BACK_RIGHT: angle = 3*M_PI/4; break;
case TARGET_DEST_DEST_FRONT_RIGHT:angle = M_PI/4; break;
- default: angle = rand_norm()*2*M_PI; break;
+ default: angle = m_caster->GetMap()->rand_norm()*2*M_PI; break;
}
float dist, x, y, z;
dist = GetSpellRadius(sSpellRadiusStore.LookupEntry(m_spellInfo->EffectRadiusIndex[i]));
if (cur == TARGET_DEST_DEST_RANDOM)
- dist *= rand_norm();
+ dist *= m_caster->GetMap()->rand_norm();
x = m_targets.m_destX;
y = m_targets.m_destY;
@@ -3262,7 +3262,7 @@ void Spell::TakePower()
if(hit)
m_caster->ModifyPower(powerType, -m_powerCost);
else
- m_caster->ModifyPower(powerType, -irand(0, m_powerCost/4));
+ m_caster->ModifyPower(powerType, -m_caster->GetMap()->irand(0, m_powerCost/4));
// Set the five second timer
if (powerType == POWER_MANA && m_powerCost > 0)
@@ -3875,7 +3875,7 @@ uint8 Spell::CanCast(bool strict)
// chance for fail at orange skinning attempt
if( (m_selfContainer && (*m_selfContainer) == this) &&
skillValue < sWorld.GetConfigMaxSkillValue() &&
- (ReqValue < 0 ? 0 : ReqValue) > irand(skillValue-25, skillValue+37) )
+ (ReqValue < 0 ? 0 : ReqValue) > m_caster->GetMap()->irand(skillValue-25, skillValue+37) )
return SPELL_FAILED_TRY_AGAIN;
break;
@@ -4013,7 +4013,7 @@ uint8 Spell::CanCast(bool strict)
return SPELL_FAILED_LOW_CASTLEVEL;
// chance for failure in orange gather / lockpick (gathering skill can't fail at maxskill)
- if((canFailAtMax || SkillValue < sWorld.GetConfigMaxSkillValue()) && ReqValue > irand(SkillValue-25, SkillValue+37))
+ if((canFailAtMax || SkillValue < sWorld.GetConfigMaxSkillValue()) && ReqValue > m_caster->GetMap()->irand(SkillValue-25, SkillValue+37))
return SPELL_FAILED_TRY_AGAIN;
break;
diff --git a/src/game/SpellEffects.cpp b/src/game/SpellEffects.cpp
index 86c2235cdb5..a1cf876fc6c 100644
--- a/src/game/SpellEffects.cpp
+++ b/src/game/SpellEffects.cpp
@@ -315,7 +315,7 @@ void Spell::SpellDamageSchoolDmg(uint32 effect_idx)
//Gore
if(m_spellInfo->SpellIconID == 2269 )
{
- damage+= rand()%2 ? damage : 0;
+ damage+= (uint32)unitTarget->GetMap()->rand32()%2 ? damage : 0;
}
// Meteor like spells (divided damage to targets)
@@ -563,7 +563,7 @@ void Spell::SpellDamageSchoolDmg(uint32 effect_idx)
// Steady Shot
else if(m_spellInfo->SpellFamilyFlags & 0x100000000LL)
{
- int32 base = irand((int32)m_caster->GetWeaponDamageRange(RANGED_ATTACK, MINDAMAGE),(int32)m_caster->GetWeaponDamageRange(RANGED_ATTACK, MAXDAMAGE));
+ int32 base = m_caster->GetMap()->irand((int32)m_caster->GetWeaponDamageRange(RANGED_ATTACK, MINDAMAGE),(int32)m_caster->GetWeaponDamageRange(RANGED_ATTACK, MAXDAMAGE));
damage += int32(float(base)/m_caster->GetAttackTime(RANGED_ATTACK)*2800 + m_caster->GetTotalAttackPowerValue(RANGED_ATTACK)*0.2f);
bool found = false;
@@ -708,7 +708,7 @@ void Spell::EffectDummy(uint32 i)
return;
uint32 spell_id = 0;
- switch(urand(1,5))
+ switch(m_caster->GetMap()->urand(1,5))
{
case 1: spell_id = 8064; break; // Sleepy
case 2: spell_id = 8065; break; // Invigorate
@@ -725,7 +725,7 @@ void Spell::EffectDummy(uint32 i)
return;
uint32 spell_id = 0;
- switch(urand(1,2))
+ switch(m_caster->GetMap()->urand(1,2))
{
// Flip Out - ninja
case 1: spell_id = (m_caster->getGender() == GENDER_MALE ? 8219 : 8220); break;
@@ -785,7 +785,7 @@ void Spell::EffectDummy(uint32 i)
uint32 spell_id = 0;
- uint32 roll = urand(0, 99);
+ uint32 roll = m_caster->GetMap()->urand(0, 99);
if(roll < 2) // 2% for 30 sec self root (off-like chance unknown)
spell_id = 16566;
@@ -856,7 +856,7 @@ void Spell::EffectDummy(uint32 i)
return;
uint32 spell_id = 0;
- switch(urand(1,3))
+ switch(m_caster->GetMap()->urand(1,3))
{
case 1: spell_id = 16595; break;
case 2: spell_id = 16593; break;
@@ -932,7 +932,7 @@ void Spell::EffectDummy(uint32 i)
return;
case 23448: // Ultrasafe Transporter: Gadgetzan - backfires
{
- int32 r = irand(0, 119);
+ int32 r = m_caster->GetMap()->irand(0, 119);
if ( r < 20 ) // 1/6 polymorph
m_caster->CastSpell(m_caster,23444,true);
else if ( r < 100 ) // 4/6 evil twin
@@ -1033,7 +1033,7 @@ void Spell::EffectDummy(uint32 i)
uint32 spell_id = 0;
- switch(urand(1,5))
+ switch(m_caster->GetMap()->urand(1,5))
{
case 1: spell_id = 33053; break;
case 2: spell_id = 33057; break;
@@ -1071,7 +1071,7 @@ void Spell::EffectDummy(uint32 i)
{
// selecting one from Bloodstained Fortune item
uint32 newitemid;
- switch(urand(1,20))
+ switch(m_caster->GetMap()->urand(1,20))
{
case 1: newitemid = 32688; break;
case 2: newitemid = 32689; break;
@@ -1145,7 +1145,7 @@ void Spell::EffectDummy(uint32 i)
tempSummon->UnSummon();
- Creature* pCreature = m_caster->SummonCreature(entry_list[urand(0, 2)], x, y, z, o,TEMPSUMMON_TIMED_OR_DEAD_DESPAWN,180000);
+ Creature* pCreature = m_caster->SummonCreature(entry_list[m_caster->GetMap()->urand(0, 2)], x, y, z, o,TEMPSUMMON_TIMED_OR_DEAD_DESPAWN,180000);
if (!pCreature)
return;
@@ -1297,7 +1297,7 @@ void Spell::EffectDummy(uint32 i)
{
//Polymorph Cast Visual Rank 1
const uint32 spell_list[6] = {32813, 32816, 32817, 32818, 32819, 32820};
- unitTarget->CastSpell( unitTarget, spell_list[urand(0, 5)], true);
+ unitTarget->CastSpell( unitTarget, spell_list[m_caster->GetMap()->urand(0, 5)], true);
}
return;
}
@@ -2039,7 +2039,7 @@ void Spell::EffectTeleportUnits(uint32 i)
// Dimensional Ripper - Everlook
case 23442:
{
- int32 r = irand(0, 119);
+ int32 r = m_caster->GetMap()->irand(0, 119);
if ( r >= 70 ) // 7/12 success
{
if ( r < 100 ) // 4/12 evil twin
@@ -2054,7 +2054,7 @@ void Spell::EffectTeleportUnits(uint32 i)
{
if ( roll_chance_i(50) ) // 50% success
{
- int32 rand_eff = urand(1,7);
+ int32 rand_eff = m_caster->GetMap()->urand(1,7);
switch ( rand_eff )
{
case 1:
@@ -2099,7 +2099,7 @@ void Spell::EffectTeleportUnits(uint32 i)
{
if ( roll_chance_i(50) ) // 50% success
{
- int32 rand_eff = urand(1,4);
+ int32 rand_eff = m_caster->GetMap()->urand(1,4);
switch ( rand_eff )
{
case 1:
@@ -2557,7 +2557,7 @@ void Spell::DoCreateItem(uint32 i, uint32 itemtype)
/*int32 basePoints = m_currentBasePoints[i];
int32 randomPoints = m_spellInfo->EffectDieSides[i];
if (randomPoints)
- num_to_add = basePoints + irand(1, randomPoints);
+ num_to_add = basePoints + m_caster->GetMap()->irand(1, randomPoints);
else
num_to_add = basePoints + 1;*/
}
@@ -2747,7 +2747,7 @@ void Spell::EffectEnergize(uint32 i)
if (!elixirs.empty())
{
// cast random elixir on target
- uint32 rand_spell = urand(0,elixirs.size()-1);
+ uint32 rand_spell = m_caster->GetMap()->urand(0,elixirs.size()-1);
m_caster->CastSpell(unitTarget,elixirs[rand_spell],true,m_CastItem);
}
}
@@ -3292,7 +3292,7 @@ void Spell::EffectDispel(uint32 i)
for (int32 count=0; count < damage && list_size > 0; ++count)
{
// Random select buff for dispel
- Aura *aur = dispel_list[urand(0, list_size-1)];
+ Aura *aur = dispel_list[m_caster->GetMap()->urand(0, list_size-1)];
SpellEntry const* spellInfo = aur->GetSpellProto();
// Base dispel chance
@@ -3440,7 +3440,7 @@ void Spell::EffectPickPocket(uint32 /*i*/)
{
int32 chance = 10 + int32(m_caster->getLevel()) - int32(unitTarget->getLevel());
- if (chance > irand(0, 19))
+ if (chance > m_caster->GetMap()->irand(0, 19))
{
// Stealing successful
//sLog.outDebug("Sending loot from pickpocket");
@@ -4485,7 +4485,7 @@ void Spell::EffectScriptEffect(uint32 effIndex)
uint32 iTmpSpellId;
- switch(urand(0,3))
+ switch(m_caster->GetMap()->urand(0,3))
{
case 0:
iTmpSpellId = 26272;
@@ -4513,7 +4513,7 @@ void Spell::EffectScriptEffect(uint32 effIndex)
return;
uint32 spell_id = 0;
- switch(urand(1,5))
+ switch(m_caster->GetMap()->urand(1,5))
{
case 1: spell_id = 8854; break;
default: spell_id = 8855; break;
@@ -4682,7 +4682,7 @@ void Spell::EffectScriptEffect(uint32 effIndex)
for(uint8 i=0; i<5; i++)
if(unitTarget->HasAura(spellid+i, 0))
return;
- unitTarget->CastSpell(unitTarget, spellid+urand(0, 4), true);
+ unitTarget->CastSpell(unitTarget, spellid+m_caster->GetMap()->urand(0, 4), true);
break;
}
@@ -4702,7 +4702,7 @@ void Spell::EffectScriptEffect(uint32 effIndex)
case 29830:
{
uint32 item = 0;
- switch ( urand(1,6) )
+ switch ( m_caster->GetMap()->urand(1,6) )
{
case 1: case 2: case 3: item = 23584; break;// Loch Modan Lager
case 4: case 5: item = 23585; break;// Stouthammer Lite
@@ -4746,7 +4746,7 @@ void Spell::EffectScriptEffect(uint32 effIndex)
return;
uint32 spellId;
- switch(rand()%4)
+ switch((uint32)m_caster->GetMap()->rand32()%4)
{
case 0:
spellId=46740;
@@ -5747,7 +5747,7 @@ void Spell::EffectKnockBack(uint32 i)
float vcos, vsin;
if(dx < 0.001f && dy < 0.001f)
{
- float angle = rand_norm()*2*M_PI;
+ float angle = m_caster->GetMap()->rand_norm()*2*M_PI;
vcos = cos(angle);
vsin = sin(angle);
}
@@ -5991,7 +5991,7 @@ void Spell::EffectTransmitted(uint32 effIndex)
{
float min_dis = GetSpellMinRange(sSpellRangeStore.LookupEntry(m_spellInfo->rangeIndex));
float max_dis = GetSpellMaxRange(sSpellRangeStore.LookupEntry(m_spellInfo->rangeIndex));
- float dis = rand_norm() * (max_dis - min_dis) + min_dis;
+ float dis = m_caster->GetMap()->rand_norm() * (max_dis - min_dis) + min_dis;
m_caster->GetClosePoint(fx,fy,fz,DEFAULT_WORLD_OBJECT_SIZE, dis);
}
@@ -6041,7 +6041,7 @@ void Spell::EffectTransmitted(uint32 effIndex)
// end time of range when possible catch fish (FISHING_BOBBER_READY_TIME..GetDuration(m_spellInfo))
// start time == fish-FISHING_BOBBER_READY_TIME (0..GetDuration(m_spellInfo)-FISHING_BOBBER_READY_TIME)
int32 lastSec;
- switch(urand(0, 3))
+ switch(m_caster->GetMap()->urand(0, 3))
{
case 0: lastSec = 3; break;
case 1: lastSec = 7; break;
@@ -6221,7 +6221,7 @@ void Spell::EffectStealBeneficialBuff(uint32 i)
for (int32 count=0; count < damage && list_size > 0; ++count)
{
// Random select buff for dispel
- Aura *aur = steal_list[urand(0, list_size-1)];
+ Aura *aur = steal_list[m_caster->GetMap()->urand(0, list_size-1)];
// Not use chance for steal
// TODO possible need do it
success_list.push_back( std::pair<uint32,uint64>(aur->GetId(),aur->GetCasterGUID()));
diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp
index e6aee7de708..7d8ae44e7ce 100644
--- a/src/game/Unit.cpp
+++ b/src/game/Unit.cpp
@@ -505,8 +505,8 @@ void Unit::GetRandomContactPoint( const Unit* obj, float &x, float &y, float &z,
}
uint32 attacker_number = getAttackers().size();
if(attacker_number > 0) --attacker_number;
- GetNearPoint(obj,x,y,z,obj->GetCombatReach(), distance2dMin+(distance2dMax-distance2dMin)*rand_norm()
- , GetAngle(obj) + (attacker_number ? (M_PI/2 - M_PI * rand_norm()) * (float)attacker_number / combat_reach / 3 : 0));
+ GetNearPoint(obj,x,y,z,obj->GetCombatReach(), distance2dMin+(distance2dMax-distance2dMin)*GetMap()->rand_norm()
+ , GetAngle(obj) + (attacker_number ? (M_PI/2 - M_PI * GetMap()->rand_norm()) * (float)attacker_number / combat_reach / 3 : 0));
}
void Unit::RemoveMovementImpairingAuras()
@@ -851,7 +851,7 @@ uint32 Unit::DealDamage(Unit *pVictim, uint32 damage, CleanDamage const* cleanDa
// random durability for items (HIT TAKEN)
if (roll_chance_f(sWorld.getRate(RATE_DURABILITY_LOSS_DAMAGE)))
{
- EquipmentSlots slot = EquipmentSlots(urand(0,EQUIPMENT_SLOT_END-1));
+ EquipmentSlots slot = EquipmentSlots(GetMap()->urand(0,EQUIPMENT_SLOT_END-1));
((Player*)pVictim)->DurabilityPointLossForEquipSlot(slot);
}
}
@@ -861,7 +861,7 @@ uint32 Unit::DealDamage(Unit *pVictim, uint32 damage, CleanDamage const* cleanDa
// random durability for items (HIT DONE)
if (roll_chance_f(sWorld.getRate(RATE_DURABILITY_LOSS_DAMAGE)))
{
- EquipmentSlots slot = EquipmentSlots(urand(0,EQUIPMENT_SLOT_END-1));
+ EquipmentSlots slot = EquipmentSlots(GetMap()->urand(0,EQUIPMENT_SLOT_END-1));
((Player*)this)->DurabilityPointLossForEquipSlot(slot);
}
}
@@ -1754,7 +1754,7 @@ void Unit::CalcAbsorbResist(Unit *pVictim,SpellSchoolMask schoolMask, DamageEffe
tmpvalue2 = 0.0f;
if (tmpvalue2 > 0.75f)
tmpvalue2 = 0.75f;
- uint32 ran = urand(0, 100);
+ uint32 ran = GetMap()->urand(0, 100);
uint32 faq[4] = {24,6,4,6};
uint8 m = 0;
float Binom = 0.0f;
@@ -2025,7 +2025,7 @@ void Unit::DoAttackDamage (Unit *pVictim, uint32 *damage, CleanDamage *cleanDama
if(damageAfterArmor < *damage)
if(pVictim->GetTypeId() == TYPEID_PLAYER)
if (roll_chance_f(sWorld.getRate(RATE_DURABILITY_LOSS_ABSORB)))
- ((Player*)pVictim)->DurabilityPointLossForEquipSlot(EquipmentSlots(urand(EQUIPMENT_SLOT_START,EQUIPMENT_SLOT_BACK)));
+ ((Player*)pVictim)->DurabilityPointLossForEquipSlot(EquipmentSlots(GetMap()->urand(EQUIPMENT_SLOT_START,EQUIPMENT_SLOT_BACK)));
cleanDamage->damage += *damage - damageAfterArmor;
*damage = damageAfterArmor;
@@ -2523,7 +2523,7 @@ MeleeHitOutcome Unit::RollMeleeOutcomeAgainst (const Unit *pVictim, WeaponAttack
int32 skillBonus = 4 * ( attackerWeaponSkill - victimMaxSkillValueForLevel );
int32 skillBonus2 = 4 * ( attackerMaxSkillValueForLevel - victimDefenseSkill );
int32 sum = 0, tmp = 0;
- int32 roll = urand (0, 10000);
+ int32 roll = GetMap()->urand (0, 10000);
DEBUG_LOG ("RollMeleeOutcomeAgainst: skill bonus of %d for attacker", skillBonus);
DEBUG_LOG ("RollMeleeOutcomeAgainst: rolled %d, miss %d, dodge %d, parry %d, block %d, crit %d",
@@ -2714,7 +2714,7 @@ uint32 Unit::CalculateDamage (WeaponAttackType attType, bool normalized)
if(max_damage == 0.0f)
max_damage = 5.0f;
- return urand((uint32)min_damage, (uint32)max_damage);
+ return GetMap()->urand((uint32)min_damage, (uint32)max_damage);
}
float Unit::CalculateLevelPenalty(SpellEntry const* spellProto) const
@@ -2841,7 +2841,7 @@ SpellMissInfo Unit::MeleeSpellHitResult(Unit *pVictim, SpellEntry const *spell)
int32 skillDiff = attackerWeaponSkill - int32(pVictim->GetMaxSkillValueForLevel(this));
int32 fullSkillDiff = attackerWeaponSkill - int32(pVictim->GetDefenseSkillValue(this));
- uint32 roll = urand (0, 10000);
+ uint32 roll = GetMap()->urand (0, 10000);
uint32 missChance = uint32(MeleeSpellMissChance(pVictim, attType, fullSkillDiff, spell->Id)*100.0f);
// Roll miss
@@ -2970,7 +2970,7 @@ SpellMissInfo Unit::MagicSpellHitResult(Unit *pVictim, SpellEntry const *spell)
if (HitChance < 100) HitChance = 100;
if (HitChance > 9900) HitChance = 9900;
- uint32 rand = urand(0,10000);
+ uint32 rand = GetMap()->urand(0,10000);
if (rand > HitChance)
return SPELL_MISS_RESIST;
return SPELL_MISS_NONE;
@@ -5205,14 +5205,14 @@ bool Unit::HandleDummyAuraProc(Unit *pVictim, uint32 damage, Aura* triggeredByAu
case CLASS_DRUID: // 39511,40997,40998,40999,41002,41005,41009,41011,41409
{
uint32 RandomSpell[]={39511,40997,40998,40999,41002,41005,41009,41011,41409};
- triggered_spell_id = RandomSpell[ irand(0, sizeof(RandomSpell)/sizeof(uint32) - 1) ];
+ triggered_spell_id = RandomSpell[ GetMap()->irand(0, sizeof(RandomSpell)/sizeof(uint32) - 1) ];
break;
}
case CLASS_ROGUE: // 39511,40997,40998,41002,41005,41011
case CLASS_WARRIOR: // 39511,40997,40998,41002,41005,41011
{
uint32 RandomSpell[]={39511,40997,40998,41002,41005,41011};
- triggered_spell_id = RandomSpell[ irand(0, sizeof(RandomSpell)/sizeof(uint32) - 1) ];
+ triggered_spell_id = RandomSpell[ GetMap()->irand(0, sizeof(RandomSpell)/sizeof(uint32) - 1) ];
break;
}
case CLASS_PRIEST: // 40999,41002,41005,41009,41011,41406,41409
@@ -5221,13 +5221,13 @@ bool Unit::HandleDummyAuraProc(Unit *pVictim, uint32 damage, Aura* triggeredByAu
case CLASS_WARLOCK: // 40999,41002,41005,41009,41011,41406,41409
{
uint32 RandomSpell[]={40999,41002,41005,41009,41011,41406,41409};
- triggered_spell_id = RandomSpell[ irand(0, sizeof(RandomSpell)/sizeof(uint32) - 1) ];
+ triggered_spell_id = RandomSpell[ GetMap()->irand(0, sizeof(RandomSpell)/sizeof(uint32) - 1) ];
break;
}
case CLASS_HUNTER: // 40997,40999,41002,41005,41009,41011,41406,41409
{
uint32 RandomSpell[]={40997,40999,41002,41005,41009,41011,41406,41409};
- triggered_spell_id = RandomSpell[ irand(0, sizeof(RandomSpell)/sizeof(uint32) - 1) ];
+ triggered_spell_id = RandomSpell[ GetMap()->irand(0, sizeof(RandomSpell)/sizeof(uint32) - 1) ];
break;
}
default:
@@ -10304,7 +10304,7 @@ int32 Unit::CalculateSpellDamage(SpellEntry const* spellProto, uint8 effect_inde
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);
+ int32 randvalue = spellProto->EffectBaseDice[effect_index] >= randomPoints ? spellProto->EffectBaseDice[effect_index]:GetMap()->irand(spellProto->EffectBaseDice[effect_index], randomPoints);
int32 value = basePoints + randvalue;
//random damage
if(comboDamage != 0 && unitPlayer /*&& target && (target->GetGUID() == unitPlayer->GetComboTarget())*/)
@@ -12060,7 +12060,7 @@ Unit* Unit::SelectNearbyTarget(float dist) const
return NULL;
// select random
- uint32 rIdx = urand(0,targets.size()-1);
+ uint32 rIdx = GetMap()->urand(0,targets.size()-1);
std::list<Unit *>::const_iterator tcIter = targets.begin();
for(uint32 i = 0; i < rIdx; ++i)
++tcIter;