summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--MCServer/Plugins/InfoReg.lua1
-rw-r--r--src/Mobs/Pig.cpp20
-rw-r--r--src/Mobs/Pig.h3
-rw-r--r--src/Mobs/Villager.cpp7
4 files changed, 31 insertions, 0 deletions
diff --git a/MCServer/Plugins/InfoReg.lua b/MCServer/Plugins/InfoReg.lua
index da5a9972c..92c4a2e59 100644
--- a/MCServer/Plugins/InfoReg.lua
+++ b/MCServer/Plugins/InfoReg.lua
@@ -51,6 +51,7 @@ local function MultiCommandHandler(a_Split, a_Player, a_CmdString, a_CmdInfo, a_
return a_CmdInfo.Handler(a_Split, a_Player);
end
-- Let the player know they need to give a subcommand:
+ assert(type(a_CmdInfo.Subcommands) == "table", "Info.lua error: There is no handler for command \"" .. a_CmdString .. "\" and there are no subcommands defined at level " .. a_Level)
ListSubcommands(a_Player, a_CmdInfo.Subcommands, a_CmdString);
return true;
end
diff --git a/src/Mobs/Pig.cpp b/src/Mobs/Pig.cpp
index 55a4412ca..50b69e44f 100644
--- a/src/Mobs/Pig.cpp
+++ b/src/Mobs/Pig.cpp
@@ -98,3 +98,23 @@ 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;
+}
+
+
+
+
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;
diff --git a/src/Mobs/Villager.cpp b/src/Mobs/Villager.cpp
index 5c9999a59..963595347 100644
--- a/src/Mobs/Villager.cpp
+++ b/src/Mobs/Villager.cpp
@@ -37,6 +37,13 @@ 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;
+ }
return true;
}