1
0
Fork 0

Implement neutral mob mechanics and partial implement of zombie pigmen

mineclone5
jordan4ibanez 2021-04-21 11:00:02 -04:00
parent b0b1ec9436
commit 5062d56a5d
5 changed files with 16 additions and 3 deletions

View File

@ -347,6 +347,7 @@ function mobs:register_mob(name, def)
ignited_by_sunlight = def.ignited_by_sunlight or false, ignited_by_sunlight = def.ignited_by_sunlight or false,
eye_height = def.eye_height or 1.5, eye_height = def.eye_height or 1.5,
defuse_reach = def.defuse_reach or 4, defuse_reach = def.defuse_reach or 4,
hostile_cooldown = def.hostile_cooldown or 15,
-- End of MCL2 extensions -- End of MCL2 extensions
on_spawn = def.on_spawn, on_spawn = def.on_spawn,

View File

@ -571,10 +571,11 @@ mobs.mob_step = function(self, dtime)
return false return false
end end
local attacking = nil
if self.hostile then if self.hostile then
--true for line_of_sight is debug --true for line_of_sight is debug
local attacking = mobs.detect_closest_player_within_radius(self,true,self.view_range,self.eye_height) attacking = mobs.detect_closest_player_within_radius(self,true,self.view_range,self.eye_height)
--go get the closest player ROAR >:O --go get the closest player ROAR >:O
if attacking then if attacking then
@ -599,6 +600,17 @@ mobs.mob_step = function(self, dtime)
end end
end end
--count down hostile cooldown timer when no players in range
if self.neutral and self.hostile and not attacking and self.hostile_cooldown_timer then
self.hostile_cooldown_timer = self.hostile_cooldown_timer - dtime
if self.hostile_cooldown_timer <= 0 then
self.hostile = false
self.hostile_cooldown_timer = 0
end
end
--jump only (like slimes) --jump only (like slimes)
if self.jump_only then if self.jump_only then

View File

@ -47,7 +47,7 @@ mobs.mob_punch = function(self, hitter, tflp, tool_capabilities, dir)
if self.neutral then if self.neutral then
self.hostile = true self.hostile = true
--hostile_cooldown timer is initialized here --hostile_cooldown timer is initialized here
self.hostile_cooldown_timer self.hostile_cooldown_timer = self.hostile_cooldown
end end

View File

@ -13,7 +13,6 @@ mobs:register_mob("mobs_mc:creeper", {
type = "monster", type = "monster",
spawn_class = "hostile", spawn_class = "hostile",
hostile = true, hostile = true,
neutral = false,
rotate = 270, rotate = 270,
hp_min = 20, hp_min = 20,
hp_max = 20, hp_max = 20,

View File

@ -17,6 +17,7 @@ local pigman = {
neutral = true, neutral = true,
rotate = 270, rotate = 270,
spawn_class = "passive", spawn_class = "passive",
hostile_cooldown = 15, --seconds
hp_min = 20, hp_min = 20,
hp_max = 20, hp_max = 20,
xp_min = 6, xp_min = 6,