Make spider only hostile at night, and when punched or following during day

This commit is contained in:
oilboi 2020-05-22 22:26:22 -04:00
parent c4365530ea
commit f50031b5a6
4 changed files with 30 additions and 2 deletions

View File

@ -55,7 +55,13 @@ mob_register.death_animation_timer = 0
mob_register.dead = false
mob_register.mob = true
mob_register.hostile = def.hostile
if def.friendly_in_daylight == true then
mob_register.friendly_in_daylight = def.friendly_in_daylight
mob_register.friendly_in_daylight_timer = 0
end
mob_register.hostile_cooldown = def.hostile_cooldown
mob_register.hostile_timer = 0
@ -153,6 +159,10 @@ mob_register.on_step = function(self, dtime,moveresult)
self.look_around(self,dtime)
end
if self.handle_friendly_in_daylight_timer then
self.handle_friendly_in_daylight_timer(self,dtime)
end
self.manage_punch_timer(self,dtime)
else
self.manage_death_animation(self,dtime)

View File

@ -64,7 +64,7 @@ mobs.create_data_handling_functions = function(def,mob_register)
--animation on the mob's body
--we add in items we want to see in this list
local debug_items = {"hostile"}
local debug_items = {"hostile","hostile_timer"}
local text = ""
for _,item in pairs(debug_items) do
if self[item] ~= nil then

View File

@ -63,6 +63,23 @@ mobs.create_timer_functions = function(def,mob_register)
self.projectile_timer = self.projectile_timer - dtime
end
if def.friendly_in_daylight then
mob_register.handle_friendly_in_daylight_timer = function(self,dtime)
self.friendly_in_daylight_timer = self.friendly_in_daylight_timer + dtime
if self.friendly_in_daylight_timer >= 2 then
self.friendly_in_daylight_timer = 0
local pos = self.object:get_pos()
if minetest.get_node_light(pos) >= 13 then --1 greater than torch light
if self.following == false then
self.hostile = false
end
else
self.hostile = true
end
end
end
end
--this stops the pig from flying into the air
mob_register.manage_jump_timer = function(self,dtime)
if self.jump_timer > 0 then

View File

@ -669,7 +669,8 @@ mobs.register_mob(
hostile = true,
attacked_hostile = false,
friendly_in_daylight = true,
attacked_hostile = true,
attack_type = "punch",
group_attack = true,
--explosion_radius = 4, -- how far away the mob has to be to initialize the explosion