summaryrefslogtreecommitdiffstats
path: root/src/Mobs
diff options
context:
space:
mode:
Diffstat (limited to 'src/Mobs')
-rw-r--r--src/Mobs/Blaze.cpp2
-rw-r--r--src/Mobs/Cavespider.cpp2
-rw-r--r--src/Mobs/Monster.cpp28
-rw-r--r--src/Mobs/Monster.h8
-rw-r--r--src/Mobs/Skeleton.cpp10
-rw-r--r--src/Mobs/Witch.cpp14
-rw-r--r--src/Mobs/Zombie.cpp6
-rw-r--r--src/Mobs/Zombiepigman.cpp2
8 files changed, 48 insertions, 24 deletions
diff --git a/src/Mobs/Blaze.cpp b/src/Mobs/Blaze.cpp
index fb97ea3c4..cd5437d97 100644
--- a/src/Mobs/Blaze.cpp
+++ b/src/Mobs/Blaze.cpp
@@ -19,7 +19,7 @@ cBlaze::cBlaze(void) :
void cBlaze::GetDrops(cItems & a_Drops, cEntity * a_Killer)
{
- if (a_Killer != NULL && (a_Killer->IsPlayer() || a_Killer->IsA("cWolf")))
+ if ((a_Killer != NULL) && (a_Killer->IsPlayer() || a_Killer->IsA("cWolf")))
{
int LootingLevel = a_Killer->GetEquippedWeapon().m_Enchantments.GetLevel(E_ENCHANTMENT_LOOTING);
AddRandomDropItem(a_Drops, 0, 1 + LootingLevel, E_ITEM_BLAZE_ROD);
diff --git a/src/Mobs/Cavespider.cpp b/src/Mobs/Cavespider.cpp
index a2678744b..4ef80e5f0 100644
--- a/src/Mobs/Cavespider.cpp
+++ b/src/Mobs/Cavespider.cpp
@@ -37,7 +37,7 @@ void cCavespider::GetDrops(cItems & a_Drops, cEntity * a_Killer)
LootingLevel = a_Killer->GetEquippedWeapon().m_Enchantments.GetLevel(E_ENCHANTMENT_LOOTING);
}
AddRandomDropItem(a_Drops, 0, 2 + LootingLevel, E_ITEM_STRING);
- if (a_Killer != NULL && (a_Killer->IsPlayer() || a_Killer->IsA("cWolf")))
+ if ((a_Killer != NULL) && (a_Killer->IsPlayer() || a_Killer->IsA("cWolf")))
{
AddRandomUncommonDropItem(a_Drops, 33.0f, E_ITEM_SPIDER_EYE);
}
diff --git a/src/Mobs/Monster.cpp b/src/Mobs/Monster.cpp
index 777b78c63..c81f46d6a 100644
--- a/src/Mobs/Monster.cpp
+++ b/src/Mobs/Monster.cpp
@@ -909,6 +909,34 @@ void cMonster::AddRandomRareDropItem(cItems & a_Drops, cItems & a_Items, short a
+void cMonster::AddRandomArmorDropItem(cItems & a_Drops, short a_LootingLevel)
+{
+ MTRand r1;
+ if (r1.randInt() % 200 < (17 + (a_LootingLevel * 2)))
+ {
+ if (!GetEquippedHelmet().IsEmpty()) a_Drops.push_back(GetEquippedHelmet());
+ }
+
+ if (r1.randInt() % 200 < (17 + (a_LootingLevel * 2)))
+ {
+ if (!GetEquippedChestplate().IsEmpty()) a_Drops.push_back(GetEquippedChestplate());
+ }
+
+ if (r1.randInt() % 200 < (17 + (a_LootingLevel * 2)))
+ {
+ if (!GetEquippedLeggings().IsEmpty()) a_Drops.push_back(GetEquippedLeggings());
+ }
+
+ if (r1.randInt() % 200 < (17 + (a_LootingLevel * 2)))
+ {
+ if (!GetEquippedBoots().IsEmpty()) a_Drops.push_back(GetEquippedBoots());
+ }
+}
+
+
+
+
+
void cMonster::HandleDaylightBurning(cChunk & a_Chunk)
{
if (!m_BurnsInDaylight)
diff --git a/src/Mobs/Monster.h b/src/Mobs/Monster.h
index 670e899c5..6f7352b52 100644
--- a/src/Mobs/Monster.h
+++ b/src/Mobs/Monster.h
@@ -5,6 +5,7 @@
#include "../Defines.h"
#include "../BlockID.h"
#include "../Item.h"
+#include "../Enchantments.h"
@@ -225,11 +226,16 @@ protected:
/** Adds a random number of a_Item between a_Min and a_Max to itemdrops a_Drops*/
void AddRandomDropItem(cItems & a_Drops, unsigned int a_Min, unsigned int a_Max, short a_Item, short a_ItemHealth = 0);
- /** Adds a item a_Item with the chance of a_Chance to itemdrops a_Drops*/
+
+ /** Adds a item a_Item with the chance of a_Chance (in percent) to itemdrops a_Drops*/
void AddRandomUncommonDropItem(cItems & a_Drops, float a_Chance, short a_Item, short a_ItemHealth = 0);
+
/** Adds one rare item out of the list of rare items a_Items modified by the looting level a_LootingLevel(I-III or custom) to the itemdrop a_Drops*/
void AddRandomRareDropItem(cItems & a_Drops, cItems & a_Items, short a_LootingLevel);
+ /** Adds armor that is equipped with the chance of 8,5% (Looting 3: 11,5%) to the drop*/
+ void AddRandomArmorDropItem(cItems & a_Drops, short a_LootingLevel);
+
} ; // tolua_export
diff --git a/src/Mobs/Skeleton.cpp b/src/Mobs/Skeleton.cpp
index 7c62de9cf..c941ae521 100644
--- a/src/Mobs/Skeleton.cpp
+++ b/src/Mobs/Skeleton.cpp
@@ -31,20 +31,14 @@ void cSkeleton::GetDrops(cItems & a_Drops, cEntity * a_Killer)
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);
+ AddRandomArmorDropItem(a_Drops, 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);
+ AddRandomArmorDropItem(a_Drops, LootingLevel);
}
}
diff --git a/src/Mobs/Witch.cpp b/src/Mobs/Witch.cpp
index f9025afe3..a278a1964 100644
--- a/src/Mobs/Witch.cpp
+++ b/src/Mobs/Witch.cpp
@@ -30,13 +30,13 @@ void cWitch::GetDrops(cItems & a_Drops, cEntity * a_Killer)
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);
+ case 0: AddRandomDropItem(a_Drops, 0, 2 + LootingLevel, E_ITEM_GLASS_BOTTLE); break;
+ case 1: AddRandomDropItem(a_Drops, 0, 2 + LootingLevel, E_ITEM_GLOWSTONE_DUST); break;
+ case 2: AddRandomDropItem(a_Drops, 0, 2 + LootingLevel, E_ITEM_GUNPOWDER); break;
+ case 3: AddRandomDropItem(a_Drops, 0, 2 + LootingLevel, E_ITEM_REDSTONE_DUST); break;
+ case 4: AddRandomDropItem(a_Drops, 0, 2 + LootingLevel, E_ITEM_SPIDER_EYE); break;
+ case 5: AddRandomDropItem(a_Drops, 0, 2 + LootingLevel, E_ITEM_STICK); break;
+ case 6: AddRandomDropItem(a_Drops, 0, 2 + LootingLevel, E_ITEM_SUGAR); break;
}
}
cItems RareDrops;
diff --git a/src/Mobs/Zombie.cpp b/src/Mobs/Zombie.cpp
index 61cf49c14..5facf085e 100644
--- a/src/Mobs/Zombie.cpp
+++ b/src/Mobs/Zombie.cpp
@@ -33,12 +33,8 @@ void cZombie::GetDrops(cItems & a_Drops, cEntity * a_Killer)
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);
+ AddRandomArmorDropItem(a_Drops, LootingLevel);
}
diff --git a/src/Mobs/Zombiepigman.cpp b/src/Mobs/Zombiepigman.cpp
index 5492068c9..3ecc65fed 100644
--- a/src/Mobs/Zombiepigman.cpp
+++ b/src/Mobs/Zombiepigman.cpp
@@ -29,8 +29,8 @@ void cZombiePigman::GetDrops(cItems & a_Drops, cEntity * a_Killer)
cItems RareDrops;
RareDrops.Add(cItem(E_ITEM_GOLD));
- if (!GetEquippedWeapon().IsEmpty()) RareDrops.Add(GetEquippedWeapon());
AddRandomRareDropItem(a_Drops, RareDrops, LootingLevel);
+ AddRandomArmorDropItem(a_Drops, LootingLevel);
}