summaryrefslogtreecommitdiffstats
path: root/src/Mobs/Monster.cpp
diff options
context:
space:
mode:
authorarchshift <admin@archshift.com>2014-06-09 03:44:20 +0200
committerarchshift <admin@archshift.com>2014-06-17 20:39:20 +0200
commit2574573c883fd7b5d19d19547f34dbef6820b5ea (patch)
tree879dbef1bc12ff5924f9b5b012b190f04c5fe63e /src/Mobs/Monster.cpp
parentApplies splash potion effects to mobs as well as players (diff)
downloadcuberite-2574573c883fd7b5d19d19547f34dbef6820b5ea.tar
cuberite-2574573c883fd7b5d19d19547f34dbef6820b5ea.tar.gz
cuberite-2574573c883fd7b5d19d19547f34dbef6820b5ea.tar.bz2
cuberite-2574573c883fd7b5d19d19547f34dbef6820b5ea.tar.lz
cuberite-2574573c883fd7b5d19d19547f34dbef6820b5ea.tar.xz
cuberite-2574573c883fd7b5d19d19547f34dbef6820b5ea.tar.zst
cuberite-2574573c883fd7b5d19d19547f34dbef6820b5ea.zip
Diffstat (limited to '')
-rw-r--r--src/Mobs/Monster.cpp65
1 files changed, 65 insertions, 0 deletions
diff --git a/src/Mobs/Monster.cpp b/src/Mobs/Monster.cpp
index 5843ca5a6..b8afbbc0c 100644
--- a/src/Mobs/Monster.cpp
+++ b/src/Mobs/Monster.cpp
@@ -435,6 +435,52 @@ void cMonster::HandleFalling()
+
+void cMonster::HandleEntityEffects(cEntityEffect::eType a_EffectType, cEntityEffect a_Effect)
+{
+ switch (a_EffectType)
+ {
+ case cEntityEffect::effPoison:
+ {
+ // Default effect for non-undead mobs and non-spiders
+ if (!IsUndead() && GetMobType() != mtSpider) break;
+ return; // No effect
+ }
+ case cEntityEffect::effRegeneration:
+ {
+ // Default effect for non-undead mobs
+ if (!IsUndead() && GetMobType()) break;
+ return; // No effect
+ }
+ case cEntityEffect::effInstantDamage:
+ {
+ // Default effect for non-undead mobs
+ if (!IsUndead() && GetMobType()) break;
+
+ // Undead mobs are healed by instant damage
+ // Base heal = 6, doubles for every increase in intensity
+ Heal(6 * std::pow(2, a_Effect.GetIntensity()) * a_Effect.GetDistanceModifier());
+ return;
+ }
+ case cEntityEffect::effInstantHealth:
+ {
+ // Default effect for non-undead mobs
+ if (!IsUndead() && GetMobType()) break;
+
+ // Undead mobs are damaged by instant health
+ // Base damage = 6, doubles for every increase in intensity
+ int damage = 6 * std::pow(2, a_Effect.GetIntensity());
+ TakeDamage(dtPotionOfHarming, a_Effect.GetUser(), damage * a_Effect.GetDistanceModifier(), 0);
+ return;
+ }
+ }
+
+ super::HandleEntityEffects(a_EffectType, a_Effect);
+}
+
+
+
+
int cMonster::FindFirstNonAirBlockPosition(double a_PosX, double a_PosZ)
{
int PosY = POSY_TOINT;
@@ -706,6 +752,25 @@ void cMonster::GetMonsterConfig(const AString & a_Name)
+bool cMonster::IsUndead(void)
+{
+ switch (GetMobType())
+ {
+ case mtZombie:
+ case mtZombiePigman:
+ case mtSkeleton:
+ case mtWither:
+ {
+ return true;
+ }
+ }
+ return false;
+}
+
+
+
+
+
AString cMonster::MobTypeToString(cMonster::eType a_MobType)
{
// Mob types aren't sorted, so we need to search linearly: