summaryrefslogtreecommitdiffstats
path: root/src/Mobs
diff options
context:
space:
mode:
Diffstat (limited to 'src/Mobs')
-rw-r--r--src/Mobs/CMakeLists.txt2
-rw-r--r--src/Mobs/IncludeAllMonsters.h1
-rw-r--r--src/Mobs/Monster.cpp186
-rw-r--r--src/Mobs/MonsterTypes.h1
-rw-r--r--src/Mobs/Skeleton.cpp17
-rw-r--r--src/Mobs/Skeleton.h8
-rw-r--r--src/Mobs/WitherSkeleton.cpp62
-rw-r--r--src/Mobs/WitherSkeleton.h28
8 files changed, 191 insertions, 114 deletions
diff --git a/src/Mobs/CMakeLists.txt b/src/Mobs/CMakeLists.txt
index d9969cfdc..15456595c 100644
--- a/src/Mobs/CMakeLists.txt
+++ b/src/Mobs/CMakeLists.txt
@@ -33,6 +33,7 @@ SET (SRCS
Villager.cpp
Witch.cpp
Wither.cpp
+ WitherSkeleton.cpp
Wolf.cpp
Zombie.cpp
ZombiePigman.cpp)
@@ -74,6 +75,7 @@ SET (HDRS
Villager.h
Witch.h
Wither.h
+ WitherSkeleton.h
Wolf.h
Zombie.h
ZombiePigman.h)
diff --git a/src/Mobs/IncludeAllMonsters.h b/src/Mobs/IncludeAllMonsters.h
index 53c709c2b..17a9dfacd 100644
--- a/src/Mobs/IncludeAllMonsters.h
+++ b/src/Mobs/IncludeAllMonsters.h
@@ -26,6 +26,7 @@
#include "Villager.h"
#include "Witch.h"
#include "Wither.h"
+#include "WitherSkeleton.h"
#include "Wolf.h"
#include "Zombie.h"
#include "ZombiePigman.h"
diff --git a/src/Mobs/Monster.cpp b/src/Mobs/Monster.cpp
index 5a01663e5..b56390b6f 100644
--- a/src/Mobs/Monster.cpp
+++ b/src/Mobs/Monster.cpp
@@ -37,37 +37,38 @@ static const struct
const char * m_VanillaNameNBT;
} g_MobTypeNames[] =
{
- {mtBat, "bat", "Bat", "bat"},
- {mtBlaze, "blaze", "Blaze", "blaze"},
- {mtCaveSpider, "cavespider", "CaveSpider", "cave_spider"},
- {mtChicken, "chicken", "Chicken", "chicken"},
- {mtCow, "cow", "Cow", "cow"},
- {mtCreeper, "creeper", "Creeper", "creeper"},
- {mtEnderman, "enderman", "Enderman", "enderman"},
- {mtEnderDragon, "enderdragon", "EnderDragon", "ender_dragon"},
- {mtGhast, "ghast", "Ghast", "ghast"},
- {mtGiant, "giant", "Giant", "giant"},
- {mtGuardian, "guardian", "Guardian", "guardian"},
- {mtHorse, "horse", "EntityHorse", "horse"},
- {mtIronGolem, "irongolem", "VillagerGolem", "iron_golem"},
- {mtMagmaCube, "magmacube", "LavaSlime", "magma_cube"},
- {mtMooshroom, "mooshroom", "MushroomCow", "mooshroom"},
- {mtOcelot, "ocelot", "Ozelot", "ocelot"},
- {mtPig, "pig", "Pig", "pig"},
- {mtRabbit, "rabbit", "Rabbit", "rabbit"},
- {mtSheep, "sheep", "Sheep", "sheep"},
- {mtSilverfish, "silverfish", "Silverfish", "silverfish"},
- {mtSkeleton, "skeleton", "Skeleton", "skeleton"},
- {mtSlime, "slime", "Slime", "slime"},
- {mtSnowGolem, "snowgolem", "SnowMan", "snow_golem"},
- {mtSpider, "spider", "Spider", "spider"},
- {mtSquid, "squid", "Squid", "squid"},
- {mtVillager, "villager", "Villager", "villager"},
- {mtWitch, "witch", "Witch", "witch"},
- {mtWither, "wither", "WitherBoss", "wither"},
- {mtWolf, "wolf", "Wolf", "wolf"},
- {mtZombie, "zombie", "Zombie", "zombie"},
- {mtZombiePigman, "zombiepigman", "PigZombie", "zombie_pigman"},
+ {mtBat, "bat", "Bat", "bat"},
+ {mtBlaze, "blaze", "Blaze", "blaze"},
+ {mtCaveSpider, "cavespider", "CaveSpider", "cave_spider"},
+ {mtChicken, "chicken", "Chicken", "chicken"},
+ {mtCow, "cow", "Cow", "cow"},
+ {mtCreeper, "creeper", "Creeper", "creeper"},
+ {mtEnderman, "enderman", "Enderman", "enderman"},
+ {mtEnderDragon, "enderdragon", "EnderDragon", "ender_dragon"},
+ {mtGhast, "ghast", "Ghast", "ghast"},
+ {mtGiant, "giant", "Giant", "giant"},
+ {mtGuardian, "guardian", "Guardian", "guardian"},
+ {mtHorse, "horse", "EntityHorse", "horse"},
+ {mtIronGolem, "irongolem", "VillagerGolem", "iron_golem"},
+ {mtMagmaCube, "magmacube", "LavaSlime", "magma_cube"},
+ {mtMooshroom, "mooshroom", "MushroomCow", "mooshroom"},
+ {mtOcelot, "ocelot", "Ozelot", "ocelot"},
+ {mtPig, "pig", "Pig", "pig"},
+ {mtRabbit, "rabbit", "Rabbit", "rabbit"},
+ {mtSheep, "sheep", "Sheep", "sheep"},
+ {mtSilverfish, "silverfish", "Silverfish", "silverfish"},
+ {mtSkeleton, "skeleton", "Skeleton", "skeleton"},
+ {mtSlime, "slime", "Slime", "slime"},
+ {mtSnowGolem, "snowgolem", "SnowMan", "snow_golem"},
+ {mtSpider, "spider", "Spider", "spider"},
+ {mtSquid, "squid", "Squid", "squid"},
+ {mtVillager, "villager", "Villager", "villager"},
+ {mtWitch, "witch", "Witch", "witch"},
+ {mtWither, "wither", "WitherBoss", "wither"},
+ {mtWitherSkeleton, "witherskeleton", "WitherSkeleton", "wither_skeleton"},
+ {mtWolf, "wolf", "Wolf", "wolf"},
+ {mtZombie, "zombie", "Zombie", "zombie"},
+ {mtZombiePigman, "zombiepigman", "PigZombie", "zombie_pigman"},
} ;
@@ -658,6 +659,7 @@ void cMonster::KilledBy(TakeDamageInfo & a_TDI)
case mtSkeleton:
case mtSpider:
case mtWitch:
+ case mtWitherSkeleton:
case mtZombie:
case mtZombiePigman:
case mtSlime:
@@ -1044,37 +1046,38 @@ cMonster::eFamily cMonster::FamilyFromType(eMonsterType a_Type)
switch (a_Type)
{
- case mtBat: return mfAmbient;
- case mtBlaze: return mfHostile;
- case mtCaveSpider: return mfHostile;
- case mtChicken: return mfPassive;
- case mtCow: return mfPassive;
- case mtCreeper: return mfHostile;
- case mtEnderDragon: return mfNoSpawn;
- case mtEnderman: return mfHostile;
- case mtGhast: return mfHostile;
- case mtGiant: return mfNoSpawn;
- case mtGuardian: return mfWater; // Just because they have special spawning conditions. If Watertemples have been added, this needs to be edited!
- case mtHorse: return mfPassive;
- case mtIronGolem: return mfPassive;
- case mtMagmaCube: return mfHostile;
- case mtMooshroom: return mfHostile;
- case mtOcelot: return mfPassive;
- case mtPig: return mfPassive;
- case mtRabbit: return mfPassive;
- case mtSheep: return mfPassive;
- case mtSilverfish: return mfHostile;
- case mtSkeleton: return mfHostile;
- case mtSlime: return mfHostile;
- case mtSnowGolem: return mfNoSpawn;
- case mtSpider: return mfHostile;
- case mtSquid: return mfWater;
- case mtVillager: return mfPassive;
- case mtWitch: return mfHostile;
- case mtWither: return mfNoSpawn;
- case mtWolf: return mfHostile;
- case mtZombie: return mfHostile;
- case mtZombiePigman: return mfHostile;
+ case mtBat: return mfAmbient;
+ case mtBlaze: return mfHostile;
+ case mtCaveSpider: return mfHostile;
+ case mtChicken: return mfPassive;
+ case mtCow: return mfPassive;
+ case mtCreeper: return mfHostile;
+ case mtEnderDragon: return mfNoSpawn;
+ case mtEnderman: return mfHostile;
+ case mtGhast: return mfHostile;
+ case mtGiant: return mfNoSpawn;
+ case mtGuardian: return mfWater; // Just because they have special spawning conditions. If Watertemples have been added, this needs to be edited!
+ case mtHorse: return mfPassive;
+ case mtIronGolem: return mfPassive;
+ case mtMagmaCube: return mfHostile;
+ case mtMooshroom: return mfHostile;
+ case mtOcelot: return mfPassive;
+ case mtPig: return mfPassive;
+ case mtRabbit: return mfPassive;
+ case mtSheep: return mfPassive;
+ case mtSilverfish: return mfHostile;
+ case mtSkeleton: return mfHostile;
+ case mtSlime: return mfHostile;
+ case mtSnowGolem: return mfNoSpawn;
+ case mtSpider: return mfHostile;
+ case mtSquid: return mfWater;
+ case mtVillager: return mfPassive;
+ case mtWitch: return mfHostile;
+ case mtWither: return mfNoSpawn;
+ case mtWitherSkeleton: return mfHostile;
+ case mtWolf: return mfHostile;
+ case mtZombie: return mfHostile;
+ case mtZombiePigman: return mfHostile;
default:
{
@@ -1173,11 +1176,6 @@ std::unique_ptr<cMonster> cMonster::NewMonsterFromType(eMonsterType a_MobType)
{
return cpp14::make_unique<cSlime>(1 << Random.RandInt(2)); // Size 1, 2 or 4
}
- case mtSkeleton:
- {
- // TODO: Actual detection of spawning in Nether
- return cpp14::make_unique<cSkeleton>(false);
- }
case mtVillager:
{
int VillagerType = Random.RandInt(6);
@@ -1206,32 +1204,34 @@ std::unique_ptr<cMonster> cMonster::NewMonsterFromType(eMonsterType a_MobType)
return cpp14::make_unique<cHorse>(HorseType, HorseColor, HorseStyle, HorseTameTimes);
}
- case mtBat: return cpp14::make_unique<cBat>();
- case mtBlaze: return cpp14::make_unique<cBlaze>();
- case mtCaveSpider: return cpp14::make_unique<cCaveSpider>();
- case mtChicken: return cpp14::make_unique<cChicken>();
- case mtCow: return cpp14::make_unique<cCow>();
- case mtCreeper: return cpp14::make_unique < cCreeper>();
- case mtEnderDragon: return cpp14::make_unique<cEnderDragon>();
- case mtEnderman: return cpp14::make_unique<cEnderman>();
- case mtGhast: return cpp14::make_unique<cGhast>();
- case mtGiant: return cpp14::make_unique<cGiant>();
- case mtGuardian: return cpp14::make_unique<cGuardian>();
- case mtIronGolem: return cpp14::make_unique<cIronGolem>();
- case mtMooshroom: return cpp14::make_unique<cMooshroom>();
- case mtOcelot: return cpp14::make_unique<cOcelot>();
- case mtPig: return cpp14::make_unique<cPig>();
- case mtRabbit: return cpp14::make_unique<cRabbit>();
- case mtSheep: return cpp14::make_unique<cSheep>();
- case mtSilverfish: return cpp14::make_unique<cSilverfish>();
- case mtSnowGolem: return cpp14::make_unique<cSnowGolem>();
- case mtSpider: return cpp14::make_unique<cSpider>();
- case mtSquid: return cpp14::make_unique<cSquid>();
- case mtWitch: return cpp14::make_unique<cWitch>();
- case mtWither: return cpp14::make_unique<cWither>();
- case mtWolf: return cpp14::make_unique<cWolf>();
- case mtZombie: return cpp14::make_unique<cZombie>(false); // TODO: Infected zombie parameter
- case mtZombiePigman: return cpp14::make_unique<cZombiePigman>();
+ case mtBat: return cpp14::make_unique<cBat>();
+ case mtBlaze: return cpp14::make_unique<cBlaze>();
+ case mtCaveSpider: return cpp14::make_unique<cCaveSpider>();
+ case mtChicken: return cpp14::make_unique<cChicken>();
+ case mtCow: return cpp14::make_unique<cCow>();
+ case mtCreeper: return cpp14::make_unique<cCreeper>();
+ case mtEnderDragon: return cpp14::make_unique<cEnderDragon>();
+ case mtEnderman: return cpp14::make_unique<cEnderman>();
+ case mtGhast: return cpp14::make_unique<cGhast>();
+ case mtGiant: return cpp14::make_unique<cGiant>();
+ case mtGuardian: return cpp14::make_unique<cGuardian>();
+ case mtIronGolem: return cpp14::make_unique<cIronGolem>();
+ case mtMooshroom: return cpp14::make_unique<cMooshroom>();
+ case mtOcelot: return cpp14::make_unique<cOcelot>();
+ case mtPig: return cpp14::make_unique<cPig>();
+ case mtRabbit: return cpp14::make_unique<cRabbit>();
+ case mtSheep: return cpp14::make_unique<cSheep>();
+ case mtSilverfish: return cpp14::make_unique<cSilverfish>();
+ case mtSkeleton: return cpp14::make_unique<cSkeleton>();
+ case mtSnowGolem: return cpp14::make_unique<cSnowGolem>();
+ case mtSpider: return cpp14::make_unique<cSpider>();
+ case mtSquid: return cpp14::make_unique<cSquid>();
+ case mtWitch: return cpp14::make_unique<cWitch>();
+ case mtWither: return cpp14::make_unique<cWither>();
+ case mtWitherSkeleton: return cpp14::make_unique<cWitherSkeleton>();
+ case mtWolf: return cpp14::make_unique<cWolf>();
+ case mtZombie: return cpp14::make_unique<cZombie>(false); // TODO: Infected zombie parameter
+ case mtZombiePigman: return cpp14::make_unique<cZombiePigman>();
default:
{
ASSERT(!"Unhandled mob type whilst trying to spawn mob!");
diff --git a/src/Mobs/MonsterTypes.h b/src/Mobs/MonsterTypes.h
index 6aaa61dc6..7a864fda4 100644
--- a/src/Mobs/MonsterTypes.h
+++ b/src/Mobs/MonsterTypes.h
@@ -39,6 +39,7 @@ enum eMonsterType
mtVillager,
mtWitch,
mtWither,
+ mtWitherSkeleton,
mtWolf,
mtZombie,
mtZombiePigman,
diff --git a/src/Mobs/Skeleton.cpp b/src/Mobs/Skeleton.cpp
index e8a345d7f..e58bb9384 100644
--- a/src/Mobs/Skeleton.cpp
+++ b/src/Mobs/Skeleton.cpp
@@ -9,9 +9,8 @@
-cSkeleton::cSkeleton(bool IsWither) :
- super("Skeleton", mtSkeleton, "entity.skeleton.hurt", "entity.skeleton.death", "entity.skeleton.ambient", 0.6, 1.8),
- m_bIsWither(IsWither)
+cSkeleton::cSkeleton(void) :
+ super("Skeleton", mtSkeleton, "entity.skeleton.hurt", "entity.skeleton.death", "entity.skeleton.ambient", 0.6, 1.8)
{
}
@@ -26,18 +25,8 @@ void cSkeleton::GetDrops(cItems & a_Drops, cEntity * a_Killer)
{
LootingLevel = a_Killer->GetEquippedWeapon().m_Enchantments.GetLevel(cEnchantments::enchLooting);
}
- if (IsWither())
- {
- AddRandomUncommonDropItem(a_Drops, 33.0f, E_ITEM_COAL);
- cItems RareDrops;
- RareDrops.Add(cItem(E_ITEM_HEAD, 1, 1));
- AddRandomRareDropItem(a_Drops, RareDrops, LootingLevel);
- }
- else
- {
- AddRandomDropItem(a_Drops, 0, 2 + LootingLevel, E_ITEM_ARROW);
+ AddRandomDropItem(a_Drops, 0, 2 + LootingLevel, E_ITEM_ARROW);
- }
AddRandomDropItem(a_Drops, 0, 2 + LootingLevel, E_ITEM_BONE);
AddRandomArmorDropItem(a_Drops, LootingLevel);
AddRandomWeaponDropItem(a_Drops, LootingLevel);
diff --git a/src/Mobs/Skeleton.h b/src/Mobs/Skeleton.h
index 0316fb9b5..cb7dec5ad 100644
--- a/src/Mobs/Skeleton.h
+++ b/src/Mobs/Skeleton.h
@@ -13,7 +13,7 @@ class cSkeleton :
typedef cAggressiveMonster super;
public:
- cSkeleton(bool IsWither);
+ cSkeleton(void);
CLASS_PROTODEF(cSkeleton)
@@ -23,12 +23,6 @@ public:
virtual bool IsUndead(void) override { return true; }
- bool IsWither(void) const { return m_bIsWither; }
-
-private:
-
- bool m_bIsWither;
-
} ;
diff --git a/src/Mobs/WitherSkeleton.cpp b/src/Mobs/WitherSkeleton.cpp
new file mode 100644
index 000000000..7dd8d5017
--- /dev/null
+++ b/src/Mobs/WitherSkeleton.cpp
@@ -0,0 +1,62 @@
+
+#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
+
+#include "WitherSkeleton.h"
+#include "../World.h"
+#include "../ClientHandle.h"
+
+
+
+
+cWitherSkeleton::cWitherSkeleton(void) :
+ super("WitherSkeleton", mtWitherSkeleton, "entity.wither_skeleton.hurt", "entity.wither_skeleton.death", "entity.wither_skeleton.ambient", 0.7, 2.4)
+{
+}
+
+
+
+
+
+bool cWitherSkeleton::Attack(std::chrono::milliseconds a_Dt)
+{
+ if (GetTarget() == nullptr)
+ {
+ return false;
+ }
+
+ GetTarget()->AddEntityEffect(cEntityEffect::effWither, 200, 0);
+ return super::Attack(a_Dt);
+}
+
+
+
+
+
+void cWitherSkeleton::GetDrops(cItems & a_Drops, cEntity * a_Killer)
+{
+ unsigned int LootingLevel = 0;
+ if (a_Killer != nullptr)
+ {
+ LootingLevel = a_Killer->GetEquippedWeapon().m_Enchantments.GetLevel(cEnchantments::enchLooting);
+ }
+ AddRandomUncommonDropItem(a_Drops, 33.0f, E_ITEM_COAL);
+ AddRandomUncommonDropItem(a_Drops, 8.5f, E_ITEM_STONE_SWORD, GetRandomProvider().RandInt<short>(50));
+
+ cItems RareDrops;
+ RareDrops.Add(cItem(E_ITEM_HEAD, 1, 1));
+ AddRandomRareDropItem(a_Drops, RareDrops, LootingLevel);
+
+ AddRandomDropItem(a_Drops, 0, 2 + LootingLevel, E_ITEM_BONE);
+ AddRandomArmorDropItem(a_Drops, LootingLevel);
+ AddRandomWeaponDropItem(a_Drops, LootingLevel);
+}
+
+
+
+
+
+void cWitherSkeleton::SpawnOn(cClientHandle & a_ClientHandle)
+{
+ super::SpawnOn(a_ClientHandle);
+ a_ClientHandle.SendEntityEquipment(*this, 0, cItem(E_ITEM_STONE_SWORD));
+}
diff --git a/src/Mobs/WitherSkeleton.h b/src/Mobs/WitherSkeleton.h
new file mode 100644
index 000000000..c77d06822
--- /dev/null
+++ b/src/Mobs/WitherSkeleton.h
@@ -0,0 +1,28 @@
+
+#pragma once
+
+#include "AggressiveMonster.h"
+
+
+
+
+
+class cWitherSkeleton :
+ public cAggressiveMonster
+{
+ typedef cAggressiveMonster super;
+
+public:
+ cWitherSkeleton(void);
+
+ CLASS_PROTODEF(cWitherSkeleton)
+
+ virtual bool Attack(std::chrono::milliseconds a_Dt) override;
+ virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = nullptr) override;
+ virtual void SpawnOn(cClientHandle & a_ClientHandle) override;
+
+} ;
+
+
+
+