From ac2e3ede1d9cd76aec851e50a2312a4ab548b25a Mon Sep 17 00:00:00 2001 From: p-mcgowan Date: Fri, 21 Nov 2014 23:20:44 -0800 Subject: villagers turn into witches when struck by lightning --- src/Mobs/Villager.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/Mobs') diff --git a/src/Mobs/Villager.cpp b/src/Mobs/Villager.cpp index 5c9999a59..371132dfb 100644 --- a/src/Mobs/Villager.cpp +++ b/src/Mobs/Villager.cpp @@ -37,6 +37,11 @@ bool cVillager::DoTakeDamage(TakeDamageInfo & a_TDI) m_World->BroadcastEntityStatus(*this, esVillagerAngry); } } + if (a_TDI.DamageType == dtLightning) + { + m_World->SpawnMob((int) GetPosX(), (int) GetPosY(), (int) GetPosZ(), mtWitch); + super::Destroy(this); + } return true; } -- cgit v1.2.3 From 635e9321c6524d0ba4bba9ce2d716869373fdfac Mon Sep 17 00:00:00 2001 From: p-mcgowan Date: Fri, 21 Nov 2014 23:36:35 -0800 Subject: villagers turn into witches on lightning --- src/Mobs/Villager.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/Mobs') diff --git a/src/Mobs/Villager.cpp b/src/Mobs/Villager.cpp index 371132dfb..6bf88bd80 100644 --- a/src/Mobs/Villager.cpp +++ b/src/Mobs/Villager.cpp @@ -37,10 +37,12 @@ bool cVillager::DoTakeDamage(TakeDamageInfo & a_TDI) m_World->BroadcastEntityStatus(*this, esVillagerAngry); } } + if (a_TDI.DamageType == dtLightning) { - m_World->SpawnMob((int) GetPosX(), (int) GetPosY(), (int) GetPosZ(), mtWitch); - super::Destroy(this); + Destroy(); + m_World->SpawnMob(GetPosX(), GetPosY(), GetPosZ(), mtWitch); + return true; } return true; } -- cgit v1.2.3 From 793b1012c41edbc07f81510ce1cc9f229628a712 Mon Sep 17 00:00:00 2001 From: p-mcgowan Date: Fri, 21 Nov 2014 23:58:35 -0800 Subject: formatter error --- src/Mobs/Villager.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/Mobs') diff --git a/src/Mobs/Villager.cpp b/src/Mobs/Villager.cpp index 6bf88bd80..963595347 100644 --- a/src/Mobs/Villager.cpp +++ b/src/Mobs/Villager.cpp @@ -37,12 +37,12 @@ bool cVillager::DoTakeDamage(TakeDamageInfo & a_TDI) m_World->BroadcastEntityStatus(*this, esVillagerAngry); } } - + if (a_TDI.DamageType == dtLightning) { Destroy(); - m_World->SpawnMob(GetPosX(), GetPosY(), GetPosZ(), mtWitch); - return true; + m_World->SpawnMob(GetPosX(), GetPosY(), GetPosZ(), mtWitch); + return true; } return true; } -- cgit v1.2.3 From d1b7a965d10c66a27e1c4593ce3637a2537309d9 Mon Sep 17 00:00:00 2001 From: p-mcgowan Date: Sat, 22 Nov 2014 15:33:34 -0800 Subject: pigs turn into pigmen on lightning --- src/Mobs/Pig.cpp | 16 ++++++++++++++++ src/Mobs/Pig.h | 3 +++ 2 files changed, 19 insertions(+) (limited to 'src/Mobs') diff --git a/src/Mobs/Pig.cpp b/src/Mobs/Pig.cpp index 55a4412ca..ce53d04fb 100644 --- a/src/Mobs/Pig.cpp +++ b/src/Mobs/Pig.cpp @@ -98,3 +98,19 @@ void cPig::Tick(float a_Dt, cChunk & a_Chunk) + +bool cPig::DoTakeDamage(TakeDamageInfo & a_TDI) +{ + if (!super::DoTakeDamage(a_TDI)) + { + return false; + } + + if (a_TDI.DamageType == dtLightning) + { + Destroy(); + m_World->SpawnMob(GetPosX(), GetPosY(), GetPosZ(), mtZombiePigman); + return true; + } + return true; +} \ No newline at end of file diff --git a/src/Mobs/Pig.h b/src/Mobs/Pig.h index 953850b3a..0e026933a 100644 --- a/src/Mobs/Pig.h +++ b/src/Mobs/Pig.h @@ -17,6 +17,9 @@ public: CLASS_PROTODEF(cPig) + // cEntity overrides + virtual bool DoTakeDamage(TakeDamageInfo & a_TDI) override; + virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = nullptr) override; virtual void OnRightClicked(cPlayer & a_Player) override; virtual void Tick(float a_Dt, cChunk & a_Chunk) override; -- cgit v1.2.3 From 7a08c057879d1e0476699931a50c510edf499759 Mon Sep 17 00:00:00 2001 From: p-mcgowan Date: Sat, 22 Nov 2014 15:48:05 -0800 Subject: formatting - newline at EOF inserted: Pig.cpp --- src/Mobs/Pig.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/Mobs') diff --git a/src/Mobs/Pig.cpp b/src/Mobs/Pig.cpp index ce53d04fb..50b69e44f 100644 --- a/src/Mobs/Pig.cpp +++ b/src/Mobs/Pig.cpp @@ -113,4 +113,8 @@ bool cPig::DoTakeDamage(TakeDamageInfo & a_TDI) return true; } return true; -} \ No newline at end of file +} + + + + -- cgit v1.2.3