Fixed Mob Drops, Add Rare and Uncommon Drops, Looting inflicts Drops
This commit is contained in:
parent
1b081a0fbb
commit
1b32b00562
@ -19,7 +19,11 @@ cBlaze::cBlaze(void) :
|
||||
|
||||
void cBlaze::GetDrops(cItems & a_Drops, cEntity * a_Killer)
|
||||
{
|
||||
AddRandomDropItem(a_Drops, 0, 1, E_ITEM_BLAZE_ROD);
|
||||
if (a_Killer->IsA("cPlayer") || a_Killer->IsA("cWolf"))
|
||||
{
|
||||
int LootingLevel = a_Killer->GetEquippedWeapon().m_Enchantments.GetLevel(21);
|
||||
AddRandomDropItem(a_Drops, 0, 1 + LootingLevel, E_ITEM_BLAZE_ROD);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -31,8 +31,12 @@ void cCavespider::Tick(float a_Dt, cChunk & a_Chunk)
|
||||
|
||||
void cCavespider::GetDrops(cItems & a_Drops, cEntity * a_Killer)
|
||||
{
|
||||
AddRandomDropItem(a_Drops, 0, 2, E_ITEM_STRING);
|
||||
AddRandomDropItem(a_Drops, 0, 1, E_ITEM_SPIDER_EYE);
|
||||
int LootingLevel = a_Killer->GetEquippedWeapon().m_Enchantments.GetLevel(21);
|
||||
AddRandomDropItem(a_Drops, 0, 2 + LootingLevel, E_ITEM_STRING);
|
||||
if (a_Killer->IsA("cPlayer") || a_Killer->IsA("cWolf"))
|
||||
{
|
||||
AddRandomUncommonDropItem(a_Drops, 33.0f, E_ITEM_SPIDER_EYE);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -48,8 +48,9 @@ void cChicken::Tick(float a_Dt, cChunk & a_Chunk)
|
||||
|
||||
void cChicken::GetDrops(cItems & a_Drops, cEntity * a_Killer)
|
||||
{
|
||||
AddRandomDropItem(a_Drops, 0, 2, E_ITEM_FEATHER);
|
||||
a_Drops.push_back(cItem(IsOnFire() ? E_ITEM_COOKED_CHICKEN : E_ITEM_RAW_CHICKEN, 1));
|
||||
int LootingLevel = a_Killer->GetEquippedWeapon().m_Enchantments.GetLevel(21);
|
||||
AddRandomDropItem(a_Drops, 0, 2 + LootingLevel, E_ITEM_FEATHER);
|
||||
AddRandomDropItem(a_Drops, 1, 1, IsOnFire() ? E_ITEM_COOKED_CHICKEN : E_ITEM_RAW_CHICKEN);
|
||||
}
|
||||
|
||||
|
||||
|
@ -21,8 +21,9 @@ cCow::cCow(void) :
|
||||
|
||||
void cCow::GetDrops(cItems & a_Drops, cEntity * a_Killer)
|
||||
{
|
||||
AddRandomDropItem(a_Drops, 0, 2, E_ITEM_LEATHER);
|
||||
AddRandomDropItem(a_Drops, 1, 3, IsOnFire() ? E_ITEM_STEAK : E_ITEM_RAW_BEEF);
|
||||
int LootingLevel = a_Killer->GetEquippedWeapon().m_Enchantments.GetLevel(21);
|
||||
AddRandomDropItem(a_Drops, 0, 2 + LootingLevel, E_ITEM_LEATHER);
|
||||
AddRandomDropItem(a_Drops, 1, 3 + LootingLevel, IsOnFire() ? E_ITEM_STEAK : E_ITEM_RAW_BEEF);
|
||||
}
|
||||
|
||||
|
||||
|
@ -39,7 +39,8 @@ void cCreeper::Tick(float a_Dt, cChunk & a_Chunk)
|
||||
|
||||
void cCreeper::GetDrops(cItems & a_Drops, cEntity * a_Killer)
|
||||
{
|
||||
AddRandomDropItem(a_Drops, 0, 2, E_ITEM_GUNPOWDER);
|
||||
int LootingLevel = a_Killer->GetEquippedWeapon().m_Enchantments.GetLevel(21);
|
||||
AddRandomDropItem(a_Drops, 0, 2 + LootingLevel, E_ITEM_GUNPOWDER);
|
||||
|
||||
if ((a_Killer != NULL) && (a_Killer->IsProjectile()))
|
||||
{
|
||||
|
@ -21,7 +21,8 @@ cEnderman::cEnderman(void) :
|
||||
|
||||
void cEnderman::GetDrops(cItems & a_Drops, cEntity * a_Killer)
|
||||
{
|
||||
AddRandomDropItem(a_Drops, 0, 1, E_ITEM_ENDER_PEARL);
|
||||
int LootingLevel = a_Killer->GetEquippedWeapon().m_Enchantments.GetLevel(21);
|
||||
AddRandomDropItem(a_Drops, 0, 1 + LootingLevel, E_ITEM_ENDER_PEARL);
|
||||
}
|
||||
|
||||
|
||||
|
@ -18,8 +18,9 @@ cGhast::cGhast(void) :
|
||||
|
||||
void cGhast::GetDrops(cItems & a_Drops, cEntity * a_Killer)
|
||||
{
|
||||
AddRandomDropItem(a_Drops, 0, 2, E_ITEM_GUNPOWDER);
|
||||
AddRandomDropItem(a_Drops, 0, 1, E_ITEM_GHAST_TEAR);
|
||||
int LootingLevel = a_Killer->GetEquippedWeapon().m_Enchantments.GetLevel(21);
|
||||
AddRandomDropItem(a_Drops, 0, 2 + LootingLevel, E_ITEM_GUNPOWDER);
|
||||
AddRandomDropItem(a_Drops, 0, 1 + LootingLevel, E_ITEM_GHAST_TEAR);
|
||||
}
|
||||
|
||||
|
||||
|
@ -140,7 +140,8 @@ void cHorse::OnRightClicked(cPlayer & a_Player)
|
||||
|
||||
void cHorse::GetDrops(cItems & a_Drops, cEntity * a_Killer)
|
||||
{
|
||||
AddRandomDropItem(a_Drops, 0, 2, E_ITEM_LEATHER);
|
||||
int LootingLevel = a_Killer->GetEquippedWeapon().m_Enchantments.GetLevel(21);
|
||||
AddRandomDropItem(a_Drops, 0, 2 + LootingLevel, E_ITEM_LEATHER);
|
||||
if (m_bIsSaddled)
|
||||
{
|
||||
a_Drops.push_back(cItem(E_ITEM_SADDLE, 1));
|
||||
|
@ -19,6 +19,7 @@ cIronGolem::cIronGolem(void) :
|
||||
void cIronGolem::GetDrops(cItems & a_Drops, cEntity * a_Killer)
|
||||
{
|
||||
AddRandomDropItem(a_Drops, 0, 5, E_ITEM_IRON);
|
||||
AddRandomDropItem(a_Drops, 0, 2, E_BLOCK_FLOWER);
|
||||
}
|
||||
|
||||
|
||||
|
@ -19,7 +19,10 @@ cMagmaCube::cMagmaCube(int a_Size) :
|
||||
|
||||
void cMagmaCube::GetDrops(cItems & a_Drops, cEntity * a_Killer)
|
||||
{
|
||||
AddRandomDropItem(a_Drops, 0, 1, E_ITEM_MAGMA_CREAM);
|
||||
if (GetSize() > 1)
|
||||
{
|
||||
AddRandomUncommonDropItem(a_Drops, 25.0f, E_ITEM_MAGMA_CREAM);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -880,6 +880,35 @@ void cMonster::AddRandomDropItem(cItems & a_Drops, unsigned int a_Min, unsigned
|
||||
|
||||
|
||||
|
||||
void cMonster::AddRandomUncommonDropItem(cItems & a_Drops, float a_Chance, short a_Item, short a_ItemHealth)
|
||||
{
|
||||
MTRand r1;
|
||||
int Count = r1.randInt() % 1000;
|
||||
if (Count < (a_Chance*10))
|
||||
{
|
||||
a_Drops.push_back(cItem(a_Item, 1, a_ItemHealth));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void cMonster::AddRandomRareDropItem(cItems & a_Drops, cItems & a_Items, short a_LootingLevel)
|
||||
{
|
||||
MTRand r1;
|
||||
int Count = r1.randInt() % 200;
|
||||
if (Count < (5 + a_LootingLevel))
|
||||
{
|
||||
int Rare = r1.randInt() % a_Items.Size();
|
||||
a_Drops.push_back(a_Items.at(Rare));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void cMonster::HandleDaylightBurning(cChunk & a_Chunk)
|
||||
{
|
||||
if (!m_BurnsInDaylight)
|
||||
|
@ -224,6 +224,9 @@ protected:
|
||||
bool m_BurnsInDaylight;
|
||||
|
||||
void AddRandomDropItem(cItems & a_Drops, unsigned int a_Min, unsigned int a_Max, short a_Item, short a_ItemHealth = 0);
|
||||
void AddRandomUncommonDropItem(cItems & a_Drops, float a_Chance, short a_Item, short a_ItemHealth = 0);
|
||||
void AddRandomRareDropItem(cItems & a_Drops, cItems & a_Items, short a_LootingLevel);
|
||||
|
||||
|
||||
} ; // tolua_export
|
||||
|
||||
|
@ -23,8 +23,9 @@ cMooshroom::cMooshroom(void) :
|
||||
|
||||
void cMooshroom::GetDrops(cItems & a_Drops, cEntity * a_Killer)
|
||||
{
|
||||
AddRandomDropItem(a_Drops, 0, 2, E_ITEM_LEATHER);
|
||||
AddRandomDropItem(a_Drops, 1, 3, IsOnFire() ? E_ITEM_STEAK : E_ITEM_RAW_BEEF);
|
||||
int LootingLevel = a_Killer->GetEquippedWeapon().m_Enchantments.GetLevel(21);
|
||||
AddRandomDropItem(a_Drops, 0, 2 + LootingLevel, E_ITEM_LEATHER);
|
||||
AddRandomDropItem(a_Drops, 1, 3 + LootingLevel, IsOnFire() ? E_ITEM_STEAK : E_ITEM_RAW_BEEF);
|
||||
}
|
||||
|
||||
|
||||
|
@ -21,7 +21,8 @@ cPig::cPig(void) :
|
||||
|
||||
void cPig::GetDrops(cItems & a_Drops, cEntity * a_Killer)
|
||||
{
|
||||
AddRandomDropItem(a_Drops, 1, 3, IsOnFire() ? E_ITEM_COOKED_PORKCHOP : E_ITEM_RAW_PORKCHOP);
|
||||
int LootingLevel = a_Killer->GetEquippedWeapon().m_Enchantments.GetLevel(21);
|
||||
AddRandomDropItem(a_Drops, 1, 3 + LootingLevel, IsOnFire() ? E_ITEM_COOKED_PORKCHOP : E_ITEM_RAW_PORKCHOP);
|
||||
if (m_bIsSaddled)
|
||||
{
|
||||
a_Drops.push_back(cItem(E_ITEM_SADDLE, 1));
|
||||
|
@ -20,8 +20,28 @@ cSkeleton::cSkeleton(bool IsWither) :
|
||||
|
||||
void cSkeleton::GetDrops(cItems & a_Drops, cEntity * a_Killer)
|
||||
{
|
||||
AddRandomDropItem(a_Drops, 0, 2, E_ITEM_ARROW);
|
||||
AddRandomDropItem(a_Drops, 0, 2, E_ITEM_BONE);
|
||||
int LootingLevel = a_Killer->GetEquippedWeapon().m_Enchantments.GetLevel(21);
|
||||
if (IsWither())
|
||||
{
|
||||
AddRandomDropItem(a_Drops, 0, 2 + LootingLevel, E_ITEM_BONE);
|
||||
AddRandomUncommonDropItem(a_Drops, 33.0f, E_ITEM_COAL);
|
||||
cItems RareDrops;
|
||||
RareDrops.Add(cItem(E_ITEM_HEAD, 1, 1));
|
||||
if (!GetEquippedWeapon().IsEmpty()) RareDrops.Add(GetEquippedWeapon());
|
||||
AddRandomRareDropItem(a_Drops, RareDrops, LootingLevel);
|
||||
}
|
||||
else
|
||||
{
|
||||
AddRandomDropItem(a_Drops, 0, 2 + LootingLevel, E_ITEM_ARROW);
|
||||
AddRandomDropItem(a_Drops, 0, 2 + LootingLevel, E_ITEM_BONE);
|
||||
cItems RareDrops;
|
||||
if (!GetEquippedHelmet().IsEmpty()) RareDrops.Add(GetEquippedHelmet());
|
||||
if (!GetEquippedChestplate().IsEmpty()) RareDrops.Add(GetEquippedChestplate());
|
||||
if (!GetEquippedLeggings().IsEmpty()) RareDrops.Add(GetEquippedLeggings());
|
||||
if (!GetEquippedBoots().IsEmpty()) RareDrops.Add(GetEquippedBoots());
|
||||
if (!GetEquippedWeapon().IsEmpty()) RareDrops.Add(GetEquippedWeapon());
|
||||
AddRandomRareDropItem(a_Drops, RareDrops, LootingLevel);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -20,8 +20,11 @@ cSlime::cSlime(int a_Size) :
|
||||
|
||||
void cSlime::GetDrops(cItems & a_Drops, cEntity * a_Killer)
|
||||
{
|
||||
// TODO: only when tiny
|
||||
AddRandomDropItem(a_Drops, 0, 2, E_ITEM_SLIMEBALL);
|
||||
int LootingLevel = a_Killer->GetEquippedWeapon().m_Enchantments.GetLevel(21);
|
||||
if (GetSize() == 1)
|
||||
{
|
||||
AddRandomDropItem(a_Drops, 0, 2 + LootingLevel, E_ITEM_SLIMEBALL);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -19,7 +19,7 @@ cSnowGolem::cSnowGolem(void) :
|
||||
|
||||
void cSnowGolem::GetDrops(cItems & a_Drops, cEntity * a_Killer)
|
||||
{
|
||||
AddRandomDropItem(a_Drops, 0, 5, E_ITEM_SNOWBALL);
|
||||
AddRandomDropItem(a_Drops, 0, 15, E_ITEM_SNOWBALL);
|
||||
}
|
||||
|
||||
|
||||
|
@ -18,8 +18,12 @@ cSpider::cSpider(void) :
|
||||
|
||||
void cSpider::GetDrops(cItems & a_Drops, cEntity * a_Killer)
|
||||
{
|
||||
AddRandomDropItem(a_Drops, 0, 2, E_ITEM_STRING);
|
||||
AddRandomDropItem(a_Drops, 0, 1, E_ITEM_SPIDER_EYE);
|
||||
int LootingLevel = a_Killer->GetEquippedWeapon().m_Enchantments.GetLevel(21);
|
||||
AddRandomDropItem(a_Drops, 0, 2 + LootingLevel, E_ITEM_STRING);
|
||||
if (a_Killer->IsA("cPlayer") || a_Killer->IsA("cWolf"))
|
||||
{
|
||||
AddRandomUncommonDropItem(a_Drops, 33.0f, E_ITEM_SPIDER_EYE);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -21,7 +21,8 @@ cSquid::cSquid(void) :
|
||||
void cSquid::GetDrops(cItems & a_Drops, cEntity * a_Killer)
|
||||
{
|
||||
// Drops 0-3 Ink Sacs
|
||||
AddRandomDropItem(a_Drops, 0, 3, E_ITEM_DYE, E_META_DYE_BLACK);
|
||||
int LootingLevel = a_Killer->GetEquippedWeapon().m_Enchantments.GetLevel(21);
|
||||
AddRandomDropItem(a_Drops, 0, 3 + LootingLevel, E_ITEM_DYE, E_META_DYE_BLACK);
|
||||
}
|
||||
|
||||
|
||||
|
@ -18,13 +18,26 @@ cWitch::cWitch(void) :
|
||||
|
||||
void cWitch::GetDrops(cItems & a_Drops, cEntity * a_Killer)
|
||||
{
|
||||
AddRandomDropItem(a_Drops, 0, 6, E_ITEM_GLASS_BOTTLE);
|
||||
AddRandomDropItem(a_Drops, 0, 6, E_ITEM_GLOWSTONE_DUST);
|
||||
AddRandomDropItem(a_Drops, 0, 6, E_ITEM_GUNPOWDER);
|
||||
AddRandomDropItem(a_Drops, 0, 6, E_ITEM_REDSTONE_DUST);
|
||||
AddRandomDropItem(a_Drops, 0, 6, E_ITEM_SPIDER_EYE);
|
||||
AddRandomDropItem(a_Drops, 0, 6, E_ITEM_STICK);
|
||||
AddRandomDropItem(a_Drops, 0, 6, E_ITEM_SUGAR);
|
||||
int LootingLevel = a_Killer->GetEquippedWeapon().m_Enchantments.GetLevel(21);
|
||||
MTRand r1;
|
||||
int DropTypeCount = (r1.randInt() % 3) + 1;
|
||||
for (int i = 0; i < DropTypeCount; i++)
|
||||
{
|
||||
int DropType = r1.randInt() % 7;
|
||||
switch (DropType)
|
||||
{
|
||||
case 0: AddRandomDropItem(a_Drops, 0, 2 + LootingLevel, E_ITEM_GLASS_BOTTLE);
|
||||
case 1: AddRandomDropItem(a_Drops, 0, 2 + LootingLevel, E_ITEM_GLOWSTONE_DUST);
|
||||
case 2: AddRandomDropItem(a_Drops, 0, 2 + LootingLevel, E_ITEM_GUNPOWDER);
|
||||
case 3: AddRandomDropItem(a_Drops, 0, 2 + LootingLevel, E_ITEM_REDSTONE_DUST);
|
||||
case 4: AddRandomDropItem(a_Drops, 0, 2 + LootingLevel, E_ITEM_SPIDER_EYE);
|
||||
case 5: AddRandomDropItem(a_Drops, 0, 2 + LootingLevel, E_ITEM_STICK);
|
||||
case 6: AddRandomDropItem(a_Drops, 0, 2 + LootingLevel, E_ITEM_SUGAR);
|
||||
}
|
||||
}
|
||||
cItems RareDrops;
|
||||
if (!GetEquippedWeapon().IsEmpty()) RareDrops.Add(GetEquippedWeapon());
|
||||
AddRandomRareDropItem(a_Drops, RareDrops, LootingLevel);
|
||||
}
|
||||
|
||||
|
||||
|
@ -2,6 +2,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "AggressiveMonster.h"
|
||||
#include "../MersenneTwister.h"
|
||||
|
||||
|
||||
|
||||
|
@ -23,9 +23,18 @@ cZombie::cZombie(bool a_IsVillagerZombie) :
|
||||
|
||||
void cZombie::GetDrops(cItems & a_Drops, cEntity * a_Killer)
|
||||
{
|
||||
AddRandomDropItem(a_Drops, 0, 2, E_ITEM_ROTTEN_FLESH);
|
||||
|
||||
// TODO: Rare drops
|
||||
int LootingLevel = a_Killer->GetEquippedWeapon().m_Enchantments.GetLevel(21);
|
||||
AddRandomDropItem(a_Drops, 0, 2 + LootingLevel, E_ITEM_ROTTEN_FLESH);
|
||||
cItems RareDrops;
|
||||
RareDrops.Add(cItem(E_ITEM_IRON));
|
||||
RareDrops.Add(cItem(E_ITEM_CARROT));
|
||||
RareDrops.Add(cItem(E_ITEM_POTATO));
|
||||
if (!GetEquippedHelmet().IsEmpty()) RareDrops.Add(GetEquippedHelmet());
|
||||
if (!GetEquippedChestplate().IsEmpty()) RareDrops.Add(GetEquippedChestplate());
|
||||
if (!GetEquippedLeggings().IsEmpty()) RareDrops.Add(GetEquippedLeggings());
|
||||
if (!GetEquippedBoots().IsEmpty()) RareDrops.Add(GetEquippedBoots());
|
||||
if (!GetEquippedWeapon().IsEmpty()) RareDrops.Add(GetEquippedWeapon());
|
||||
AddRandomRareDropItem(a_Drops, RareDrops, LootingLevel);
|
||||
}
|
||||
|
||||
|
||||
|
@ -19,10 +19,14 @@ cZombiePigman::cZombiePigman(void) :
|
||||
|
||||
void cZombiePigman::GetDrops(cItems & a_Drops, cEntity * a_Killer)
|
||||
{
|
||||
AddRandomDropItem(a_Drops, 0, 1, E_ITEM_ROTTEN_FLESH);
|
||||
AddRandomDropItem(a_Drops, 0, 1, E_ITEM_GOLD_NUGGET);
|
||||
int LootingLevel = a_Killer->GetEquippedWeapon().m_Enchantments.GetLevel(21);
|
||||
AddRandomDropItem(a_Drops, 0, 1 + LootingLevel, E_ITEM_ROTTEN_FLESH);
|
||||
AddRandomDropItem(a_Drops, 0, 1 + LootingLevel, E_ITEM_GOLD_NUGGET);
|
||||
|
||||
// TODO: Rare drops
|
||||
cItems RareDrops;
|
||||
RareDrops.Add(cItem(E_ITEM_GOLD));
|
||||
if (!GetEquippedWeapon().IsEmpty()) RareDrops.Add(GetEquippedWeapon());
|
||||
AddRandomRareDropItem(a_Drops, RareDrops, LootingLevel);
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user