summaryrefslogtreecommitdiffstats
path: root/src/Items
diff options
context:
space:
mode:
Diffstat (limited to 'src/Items')
-rw-r--r--src/Items/ItemFishingRod.h16
-rw-r--r--src/Items/ItemHandler.cpp3
-rw-r--r--src/Items/ItemThrowable.h3
3 files changed, 11 insertions, 11 deletions
diff --git a/src/Items/ItemFishingRod.h b/src/Items/ItemFishingRod.h
index 3958b12e5..2becc16b0 100644
--- a/src/Items/ItemFishingRod.h
+++ b/src/Items/ItemFishingRod.h
@@ -108,6 +108,8 @@ public:
return false;
}
+ auto & Random = GetRandomProvider();
+
if (a_Player->IsFishing())
{
cFloaterCallback FloaterInfo;
@@ -122,10 +124,10 @@ public:
else if (FloaterInfo.CanPickup())
{
cItems Drops;
- int ItemCategory = a_World->GetTickRandomNumber(99);
+ int ItemCategory = Random.RandInt(99);
if (ItemCategory <= 4) // Treasures 5%
{
- int Treasure = a_World->GetTickRandomNumber(5);
+ int Treasure = Random.RandInt(5);
switch (Treasure)
{
case 0:
@@ -140,7 +142,7 @@ public:
}
case 2:
{
- Drops.Add(cItem(E_ITEM_FISHING_ROD, 1, static_cast<short>(a_World->GetTickRandomNumber(50)))); // Fishing rod with durability. TODO: Enchantments on it
+ Drops.Add(cItem(E_ITEM_FISHING_ROD, 1, Random.RandInt<short>(50))); // Fishing rod with durability. TODO: Enchantments on it
break;
}
case 3:
@@ -164,14 +166,14 @@ public:
}
else if (ItemCategory <= 14) // Junk 10%
{
- int Junk = a_World->GetTickRandomNumber(70);
+ int Junk = Random.RandInt(70);
if (Junk <= 1)
{
Drops.Add(cItem(E_ITEM_DYE, 10, 0));
}
else if (Junk <= 4)
{
- Drops.Add(cItem(E_ITEM_BOW, 1, static_cast<short>(a_World->GetTickRandomNumber(64))));
+ Drops.Add(cItem(E_ITEM_BOW, 1, Random.RandInt<short>(64)));
}
else if (Junk <= 9)
{
@@ -214,7 +216,7 @@ public:
}
else // Fish
{
- int FishType = a_World->GetTickRandomNumber(99);
+ int FishType = Random.RandInt(99);
if (FishType <= 1) // Clownfish has a 2% chance of spawning
{
Drops.Add(cItem(E_ITEM_RAW_FISH, 1, E_META_RAW_FISH_CLOWNFISH));
@@ -250,7 +252,7 @@ public:
}
else
{
- cFloater * Floater = new cFloater(a_Player->GetPosX(), a_Player->GetStance(), a_Player->GetPosZ(), a_Player->GetLookVector() * 15, a_Player->GetUniqueID(), static_cast<int>(100 + static_cast<unsigned int>(a_World->GetTickRandomNumber(800)) - (a_Player->GetEquippedItem().m_Enchantments.GetLevel(cEnchantments::enchLure) * 100)));
+ cFloater * Floater = new cFloater(a_Player->GetPosX(), a_Player->GetStance(), a_Player->GetPosZ(), a_Player->GetLookVector() * 15, a_Player->GetUniqueID(), (Random.RandInt(100, 900) - static_cast<int>(a_Player->GetEquippedItem().m_Enchantments.GetLevel(cEnchantments::enchLure) * 100)));
if (!Floater->Initialize(*a_World))
{
delete Floater;
diff --git a/src/Items/ItemHandler.cpp b/src/Items/ItemHandler.cpp
index d037092b1..8e3d79506 100644
--- a/src/Items/ItemHandler.cpp
+++ b/src/Items/ItemHandler.cpp
@@ -861,8 +861,7 @@ bool cItemHandler::EatItem(cPlayer * a_Player, cItem * a_Item)
float Chance;
if (Success && GetEatEffect(EffectType, EffectDurationTicks, EffectIntensity, Chance))
{
- cFastRandom r1;
- if (r1.NextFloat() < Chance)
+ if (GetRandomProvider().RandBool(Chance))
{
a_Player->AddEntityEffect(EffectType, EffectDurationTicks, EffectIntensity, Chance);
}
diff --git a/src/Items/ItemThrowable.h b/src/Items/ItemThrowable.h
index eaeb118f0..7bdba17cc 100644
--- a/src/Items/ItemThrowable.h
+++ b/src/Items/ItemThrowable.h
@@ -36,8 +36,7 @@ public:
Vector3d Speed = a_Player->GetLookVector() * m_SpeedCoeff;
// Play sound
- cFastRandom Random;
- a_World->BroadcastSoundEffect("entity.arrow.shoot", a_Player->GetPosX(), a_Player->GetPosY() - a_Player->GetHeight(), a_Player->GetPosZ(), 0.5f, 0.4f / (Random.NextFloat(1.0f) * 0.4f + 0.8f));
+ a_World->BroadcastSoundEffect("entity.arrow.shoot", a_Player->GetPosX(), a_Player->GetPosY() - a_Player->GetHeight(), a_Player->GetPosZ(), 0.5f, 0.4f / GetRandomProvider().RandReal(0.8f, 1.2f));
if (a_World->CreateProjectile(Pos.x, Pos.y, Pos.z, m_ProjectileKind, a_Player, &a_Player->GetEquippedItem(), &Speed) == cEntity::INVALID_ID)
{