Changed type of FastRandom in monster drop calculation. (#3920)
* Fixed type of FastRandom in monster drop calculation. * Distribute dropped items into stacks. * Moved while loop outside if statement.
This commit is contained in:
parent
5e81024f89
commit
8f1ddfa6c3
@ -5,6 +5,7 @@
|
|||||||
#include "../Root.h"
|
#include "../Root.h"
|
||||||
#include "../Server.h"
|
#include "../Server.h"
|
||||||
#include "../ClientHandle.h"
|
#include "../ClientHandle.h"
|
||||||
|
#include "../Items/ItemHandler.h"
|
||||||
#include "../World.h"
|
#include "../World.h"
|
||||||
#include "../EffectID.h"
|
#include "../EffectID.h"
|
||||||
#include "../Entities/Player.h"
|
#include "../Entities/Player.h"
|
||||||
@ -1093,7 +1094,13 @@ std::unique_ptr<cMonster> cMonster::NewMonsterFromType(eMonsterType a_MobType)
|
|||||||
|
|
||||||
void cMonster::AddRandomDropItem(cItems & a_Drops, unsigned int a_Min, unsigned int a_Max, short a_Item, short a_ItemHealth)
|
void cMonster::AddRandomDropItem(cItems & a_Drops, unsigned int a_Min, unsigned int a_Max, short a_Item, short a_ItemHealth)
|
||||||
{
|
{
|
||||||
auto Count = GetRandomProvider().RandInt<char>(static_cast<char>(a_Min), static_cast<char>(a_Max));
|
auto Count = GetRandomProvider().RandInt<unsigned int>(a_Min, a_Max);
|
||||||
|
auto MaxStackSize = static_cast<unsigned char>(ItemHandler(a_Item)->GetMaxStackSize());
|
||||||
|
while (Count > MaxStackSize)
|
||||||
|
{
|
||||||
|
a_Drops.emplace_back(a_Item, MaxStackSize, a_ItemHealth);
|
||||||
|
Count -= MaxStackSize;
|
||||||
|
}
|
||||||
if (Count > 0)
|
if (Count > 0)
|
||||||
{
|
{
|
||||||
a_Drops.emplace_back(a_Item, Count, a_ItemHealth);
|
a_Drops.emplace_back(a_Item, Count, a_ItemHealth);
|
||||||
|
Loading…
Reference in New Issue
Block a user