From 2574573c883fd7b5d19d19547f34dbef6820b5ea Mon Sep 17 00:00:00 2001 From: archshift Date: Sun, 8 Jun 2014 18:44:20 -0700 Subject: Monster: added IsUndead(), undead-specific entity effects --- src/Mobs/Monster.cpp | 65 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) (limited to 'src/Mobs/Monster.cpp') 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: -- cgit v1.2.3 From 5b2b6e06150b6299d1e19374be092c0858b0e3a8 Mon Sep 17 00:00:00 2001 From: archshift Date: Thu, 12 Jun 2014 19:50:02 -0700 Subject: Pawn: renamed HandleEntityEffects to HandleEntityEffect Exported entity effect functions for ToLua and documented them in APIDesc.lua --- src/Mobs/Monster.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/Mobs/Monster.cpp') diff --git a/src/Mobs/Monster.cpp b/src/Mobs/Monster.cpp index b8afbbc0c..4dfd81d88 100644 --- a/src/Mobs/Monster.cpp +++ b/src/Mobs/Monster.cpp @@ -436,7 +436,7 @@ void cMonster::HandleFalling() -void cMonster::HandleEntityEffects(cEntityEffect::eType a_EffectType, cEntityEffect a_Effect) +void cMonster::HandleEntityEffect(cEntityEffect::eType a_EffectType, cEntityEffect a_Effect) { switch (a_EffectType) { @@ -475,7 +475,7 @@ void cMonster::HandleEntityEffects(cEntityEffect::eType a_EffectType, cEntityEff } } - super::HandleEntityEffects(a_EffectType, a_Effect); + super::HandleEntityEffect(a_EffectType, a_Effect); } -- cgit v1.2.3 From 045ae2ef2c0d72b4902fa5151aad095823da9300 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Fri, 13 Jun 2014 09:49:42 +0200 Subject: Fixed MSVC compilation. --- src/Mobs/Monster.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/Mobs/Monster.cpp') diff --git a/src/Mobs/Monster.cpp b/src/Mobs/Monster.cpp index 4dfd81d88..8a8c4f67a 100644 --- a/src/Mobs/Monster.cpp +++ b/src/Mobs/Monster.cpp @@ -459,7 +459,7 @@ void cMonster::HandleEntityEffect(cEntityEffect::eType a_EffectType, cEntityEffe // 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()); + Heal((int)(6 * std::pow(2.0, a_Effect.GetIntensity()) * a_Effect.GetDistanceModifier())); return; } case cEntityEffect::effInstantHealth: @@ -469,8 +469,8 @@ void cMonster::HandleEntityEffect(cEntityEffect::eType a_EffectType, cEntityEffe // 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); + int damage = (int)(6 * std::pow(2.0, a_Effect.GetIntensity()) * a_Effect.GetDistanceModifier()); + TakeDamage(dtPotionOfHarming, a_Effect.GetUser(), damage, 0); return; } } -- cgit v1.2.3 From 68c30790db17b9d21b2fcda4c7edec679162c577 Mon Sep 17 00:00:00 2001 From: archshift Date: Fri, 13 Jun 2014 10:59:59 -0700 Subject: Entity effects: changed User to Creator, removed pawn pass-by-value --- src/Mobs/Monster.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/Mobs/Monster.cpp') diff --git a/src/Mobs/Monster.cpp b/src/Mobs/Monster.cpp index 8a8c4f67a..4c59960f6 100644 --- a/src/Mobs/Monster.cpp +++ b/src/Mobs/Monster.cpp @@ -470,7 +470,7 @@ void cMonster::HandleEntityEffect(cEntityEffect::eType a_EffectType, cEntityEffe // Undead mobs are damaged by instant health // Base damage = 6, doubles for every increase in intensity int damage = (int)(6 * std::pow(2.0, a_Effect.GetIntensity()) * a_Effect.GetDistanceModifier()); - TakeDamage(dtPotionOfHarming, a_Effect.GetUser(), damage, 0); + TakeDamage(dtPotionOfHarming, a_Effect.GetCreator(), damage, 0); return; } } -- cgit v1.2.3 From f5529e544cf8350daf8a20bb8d997f85ee2824f7 Mon Sep 17 00:00:00 2001 From: archshift Date: Mon, 16 Jun 2014 20:22:17 -0700 Subject: EntityEffects.x -> EntityEffect.x, Object-Oriented effects Changed effect map to take a pointer of the effect as a result. --- src/Mobs/Monster.cpp | 45 --------------------------------------------- 1 file changed, 45 deletions(-) (limited to 'src/Mobs/Monster.cpp') diff --git a/src/Mobs/Monster.cpp b/src/Mobs/Monster.cpp index 4c59960f6..a51315ecf 100644 --- a/src/Mobs/Monster.cpp +++ b/src/Mobs/Monster.cpp @@ -436,51 +436,6 @@ void cMonster::HandleFalling() -void cMonster::HandleEntityEffect(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((int)(6 * std::pow(2.0, 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 = (int)(6 * std::pow(2.0, a_Effect.GetIntensity()) * a_Effect.GetDistanceModifier()); - TakeDamage(dtPotionOfHarming, a_Effect.GetCreator(), damage, 0); - return; - } - } - - super::HandleEntityEffect(a_EffectType, a_Effect); -} - - - - int cMonster::FindFirstNonAirBlockPosition(double a_PosX, double a_PosZ) { int PosY = POSY_TOINT; -- cgit v1.2.3