forked from MineClone5/MineClone5
Implement zombie pigmen and make them turn hostile when punched
This commit is contained in:
parent
f1dc286442
commit
b0b1ec9436
|
@ -357,7 +357,7 @@ function mobs:register_mob(name, def)
|
|||
|
||||
--do_punch = def.do_punch,
|
||||
|
||||
--on_punch = mob_punch,
|
||||
on_punch = mobs.mob_punch,
|
||||
|
||||
--on_breed = def.on_breed,
|
||||
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
local math_floor = math.floor
|
||||
|
||||
mobs.feed_tame = function(self)
|
||||
return nil
|
||||
end
|
||||
|
@ -40,8 +42,16 @@ mobs.create_mob_on_rightclick = function(on_rightclick)
|
|||
end
|
||||
|
||||
-- deal damage and effects when mob punched
|
||||
local mob_punch = function(self, hitter, tflp, tool_capabilities, dir)
|
||||
mobs.mob_punch = function(self, hitter, tflp, tool_capabilities, dir)
|
||||
|
||||
if self.neutral then
|
||||
self.hostile = true
|
||||
--hostile_cooldown timer is initialized here
|
||||
self.hostile_cooldown_timer
|
||||
end
|
||||
|
||||
|
||||
--[[
|
||||
-- custom punch function
|
||||
if self.do_punch then
|
||||
|
||||
|
@ -312,4 +322,5 @@ local mob_punch = function(self, hitter, tflp, tool_capabilities, dir)
|
|||
end
|
||||
end
|
||||
end
|
||||
]]--
|
||||
end
|
||||
|
|
|
@ -14,6 +14,8 @@ local pigman = {
|
|||
-- type="animal", passive=false: This combination is needed for a neutral mob which becomes hostile, if attacked
|
||||
type = "animal",
|
||||
passive = false,
|
||||
neutral = true,
|
||||
rotate = 270,
|
||||
spawn_class = "passive",
|
||||
hp_min = 20,
|
||||
hp_max = 20,
|
||||
|
|
Loading…
Reference in New Issue