0
0
Fork 0

Implement neutral mob mechanics and partial implement of zombie pigmen

This commit is contained in:
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,
eye_height = def.eye_height or 1.5,
defuse_reach = def.defuse_reach or 4,
hostile_cooldown = def.hostile_cooldown or 15,
-- End of MCL2 extensions
on_spawn = def.on_spawn,

View File

@ -571,10 +571,11 @@ mobs.mob_step = function(self, dtime)
return false
end
local attacking = nil
if self.hostile then
--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
if attacking then
@ -599,6 +600,17 @@ mobs.mob_step = function(self, dtime)
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)
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
self.hostile = true
--hostile_cooldown timer is initialized here
self.hostile_cooldown_timer
self.hostile_cooldown_timer = self.hostile_cooldown
end

View File

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

View File

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