summaryrefslogtreecommitdiffstats
path: root/src/Mobs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/Mobs/Monster.cpp26
-rw-r--r--src/Mobs/Monster.h20
-rw-r--r--src/Mobs/Mooshroom.cpp49
-rw-r--r--src/Mobs/Skeleton.cpp8
-rw-r--r--src/Mobs/Witch.cpp4
-rw-r--r--src/Mobs/Zombie.cpp1
-rw-r--r--src/Mobs/Zombiepigman.cpp1
7 files changed, 74 insertions, 35 deletions
diff --git a/src/Mobs/Monster.cpp b/src/Mobs/Monster.cpp
index c81f46d6a..23e4219e8 100644
--- a/src/Mobs/Monster.cpp
+++ b/src/Mobs/Monster.cpp
@@ -81,6 +81,11 @@ cMonster::cMonster(const AString & a_ConfigName, eType a_MobType, const AString
, m_AttackDamage(1)
, m_AttackRange(2)
, m_AttackInterval(0)
+ , m_DropChanceWeapon(0.085)
+ , m_DropChanceHelmet(0.085)
+ , m_DropChanceChestplate(0.085)
+ , m_DropChanceLeggings(0.085)
+ , m_DropChanceBoots(0.085)
, m_SightDistance(25)
, m_BurnsInDaylight(false)
{
@@ -912,22 +917,22 @@ 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 (r1.randInt() % 200 < ((m_DropChanceHelmet * 200) + (a_LootingLevel * 2)))
{
if (!GetEquippedHelmet().IsEmpty()) a_Drops.push_back(GetEquippedHelmet());
}
- if (r1.randInt() % 200 < (17 + (a_LootingLevel * 2)))
+ if (r1.randInt() % 200 < ((m_DropChanceChestplate * 200) + (a_LootingLevel * 2)))
{
if (!GetEquippedChestplate().IsEmpty()) a_Drops.push_back(GetEquippedChestplate());
}
- if (r1.randInt() % 200 < (17 + (a_LootingLevel * 2)))
+ if (r1.randInt() % 200 < ((m_DropChanceLeggings * 200) + (a_LootingLevel * 2)))
{
if (!GetEquippedLeggings().IsEmpty()) a_Drops.push_back(GetEquippedLeggings());
}
- if (r1.randInt() % 200 < (17 + (a_LootingLevel * 2)))
+ if (r1.randInt() % 200 < ((m_DropChanceBoots * 200) + (a_LootingLevel * 2)))
{
if (!GetEquippedBoots().IsEmpty()) a_Drops.push_back(GetEquippedBoots());
}
@@ -937,6 +942,19 @@ void cMonster::AddRandomArmorDropItem(cItems & a_Drops, short a_LootingLevel)
+void cMonster::AddRandomWeaponDropItem(cItems & a_Drops, short a_LootingLevel)
+{
+ MTRand r1;
+ if (r1.randInt() % 200 < ((m_DropChanceWeapon * 200) + (a_LootingLevel * 2)))
+ {
+ if (!GetEquippedWeapon().IsEmpty()) a_Drops.push_back(GetEquippedWeapon());
+ }
+}
+
+
+
+
+
void cMonster::HandleDaylightBurning(cChunk & a_Chunk)
{
if (!m_BurnsInDaylight)
diff --git a/src/Mobs/Monster.h b/src/Mobs/Monster.h
index 6f7352b52..b75ac444f 100644
--- a/src/Mobs/Monster.h
+++ b/src/Mobs/Monster.h
@@ -119,6 +119,17 @@ public:
void SetAttackDamage(int a_AttackDamage) { m_AttackDamage = a_AttackDamage; }
void SetSightDistance(int a_SightDistance) { m_SightDistance = a_SightDistance; }
+ float GetDropChanceWeapon() { return m_DropChanceWeapon; };
+ float GetDropChanceHelmet() { return m_DropChanceHelmet; };
+ float GetDropChanceChestplate() { return m_DropChanceChestplate; };
+ float GetDropChanceLeggings() { return m_DropChanceLeggings; };
+ float GetDropChanceBoots() { return m_DropChanceBoots; };
+ void SetDropChanceWeapon(float a_DropChanceWeapon) { m_DropChanceWeapon = a_DropChanceWeapon; };
+ void SetDropChanceHelmet(float a_DropChanceHelmet) { m_DropChanceHelmet = a_DropChanceHelmet; };
+ void SetDropChanceChestplate(float a_DropChanceChestplate) { m_DropChanceChestplate = a_DropChanceChestplate; };
+ void SetDropChanceLeggings(float a_DropChanceLeggings) { m_DropChanceLeggings = a_DropChanceLeggings; };
+ void SetDropChanceBoots(float a_DropChanceBoots) { m_DropChanceBoots = a_DropChanceBoots; };
+
/// Sets whether the mob burns in daylight. Only evaluated at next burn-decision tick
void SetBurnsInDaylight(bool a_BurnsInDaylight) { m_BurnsInDaylight = a_BurnsInDaylight; }
@@ -221,6 +232,12 @@ protected:
float m_AttackInterval;
int m_SightDistance;
+ float m_DropChanceWeapon;
+ float m_DropChanceHelmet;
+ float m_DropChanceChestplate;
+ float m_DropChanceLeggings;
+ float m_DropChanceBoots;
+
void HandleDaylightBurning(cChunk & a_Chunk);
bool m_BurnsInDaylight;
@@ -236,6 +253,9 @@ protected:
/** 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);
+ /** Adds weapon that is equipped with the chance of 8,5% (Looting 3: 11,5%) to the drop*/
+ void AddRandomWeaponDropItem(cItems & a_Drops, short a_LootingLevel);
+
} ; // tolua_export
diff --git a/src/Mobs/Mooshroom.cpp b/src/Mobs/Mooshroom.cpp
index 5873ec63f..8e4c52ae6 100644
--- a/src/Mobs/Mooshroom.cpp
+++ b/src/Mobs/Mooshroom.cpp
@@ -39,34 +39,35 @@ void cMooshroom::GetDrops(cItems & a_Drops, cEntity * a_Killer)
void cMooshroom::OnRightClicked(cPlayer & a_Player)
{
- if ((a_Player.GetEquippedItem().m_ItemType == E_ITEM_BUCKET))
+ switch (a_Player.GetEquippedItem().m_ItemType)
{
- if (!a_Player.IsGameModeCreative())
+ case E_ITEM_BUCKET:
{
- a_Player.GetInventory().RemoveOneEquippedItem();
- a_Player.GetInventory().AddItem(E_ITEM_MILK);
- }
- }
-
- if ((a_Player.GetEquippedItem().m_ItemType == E_ITEM_BOWL))
- {
- if (!a_Player.IsGameModeCreative())
+ if (!a_Player.IsGameModeCreative())
+ {
+ a_Player.GetInventory().RemoveOneEquippedItem();
+ a_Player.GetInventory().AddItem(E_ITEM_MILK);
+ }
+ } break;
+ case E_ITEM_BOWL:
{
- a_Player.GetInventory().RemoveOneEquippedItem();
- a_Player.GetInventory().AddItem(E_ITEM_MUSHROOM_SOUP);
- }
- }
-
- if (a_Player.GetEquippedItem().m_ItemType == E_ITEM_SHEARS)
- {
- if (!a_Player.IsGameModeCreative())
+ if (!a_Player.IsGameModeCreative())
+ {
+ a_Player.GetInventory().RemoveOneEquippedItem();
+ a_Player.GetInventory().AddItem(E_ITEM_MUSHROOM_SOUP);
+ }
+ } break;
+ case E_ITEM_SHEARS:
{
- a_Player.UseEquippedItem();
- }
-
- cItems Drops;
- Drops.push_back(cItem(E_BLOCK_RED_MUSHROOM, 5, 0));
- m_World->SpawnItemPickups(Drops, GetPosX(), GetPosY(), GetPosZ(), 10);
+ if (!a_Player.IsGameModeCreative())
+ {
+ a_Player.UseEquippedItem();
+ }
+
+ cItems Drops;
+ Drops.push_back(cItem(E_BLOCK_RED_MUSHROOM, 5, 0));
+ m_World->SpawnItemPickups(Drops, GetPosX(), GetPosY(), GetPosZ(), 10);
+ } break;
}
}
diff --git a/src/Mobs/Skeleton.cpp b/src/Mobs/Skeleton.cpp
index 661f0712c..47fcdbb26 100644
--- a/src/Mobs/Skeleton.cpp
+++ b/src/Mobs/Skeleton.cpp
@@ -27,19 +27,19 @@ void cSkeleton::GetDrops(cItems & a_Drops, cEntity * a_Killer)
}
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));
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);
- AddRandomArmorDropItem(a_Drops, LootingLevel);
+
}
+ AddRandomDropItem(a_Drops, 0, 2 + LootingLevel, E_ITEM_BONE);
+ AddRandomArmorDropItem(a_Drops, LootingLevel);
+ AddRandomWeaponDropItem(a_Drops, LootingLevel);
}
diff --git a/src/Mobs/Witch.cpp b/src/Mobs/Witch.cpp
index bdc9e11de..6956f7b7a 100644
--- a/src/Mobs/Witch.cpp
+++ b/src/Mobs/Witch.cpp
@@ -39,9 +39,7 @@ void cWitch::GetDrops(cItems & a_Drops, cEntity * a_Killer)
case 6: AddRandomDropItem(a_Drops, 0, 2 + LootingLevel, E_ITEM_SUGAR); break;
}
}
- cItems RareDrops;
- if (!GetEquippedWeapon().IsEmpty()) RareDrops.Add(GetEquippedWeapon());
- AddRandomRareDropItem(a_Drops, RareDrops, LootingLevel);
+ AddRandomWeaponDropItem(a_Drops, LootingLevel);
}
diff --git a/src/Mobs/Zombie.cpp b/src/Mobs/Zombie.cpp
index 999cd4a35..f19e096ee 100644
--- a/src/Mobs/Zombie.cpp
+++ b/src/Mobs/Zombie.cpp
@@ -35,6 +35,7 @@ void cZombie::GetDrops(cItems & a_Drops, cEntity * a_Killer)
RareDrops.Add(cItem(E_ITEM_POTATO));
AddRandomRareDropItem(a_Drops, RareDrops, LootingLevel);
AddRandomArmorDropItem(a_Drops, LootingLevel);
+ AddRandomWeaponDropItem(a_Drops, LootingLevel);
}
diff --git a/src/Mobs/Zombiepigman.cpp b/src/Mobs/Zombiepigman.cpp
index a967d5066..a0142b566 100644
--- a/src/Mobs/Zombiepigman.cpp
+++ b/src/Mobs/Zombiepigman.cpp
@@ -31,6 +31,7 @@ void cZombiePigman::GetDrops(cItems & a_Drops, cEntity * a_Killer)
RareDrops.Add(cItem(E_ITEM_GOLD));
AddRandomRareDropItem(a_Drops, RareDrops, LootingLevel);
AddRandomArmorDropItem(a_Drops, LootingLevel);
+ AddRandomWeaponDropItem(a_Drops, LootingLevel);
}