add mob_class:shoot_reach

This commit is contained in:
nixnoxus 2024-03-03 11:29:44 +01:00
parent 4f99ce0af5
commit 3e4474b8d8
3 changed files with 4 additions and 2 deletions

View File

@ -82,6 +82,7 @@ functions needed for the mob to work properly which contains the following:
'reach' is how far the mob can attack player when standing
nearby, default is 3 nodes.
'shoot_reach' is how far the mob can shoot, default is 16 nodes.
'docile_by_day' when true has mobs wandering around during daylight
hours and only attacking player at night or when
provoked.

View File

@ -1154,9 +1154,9 @@ function mob_class:do_states_attack (dtime)
end
end
elseif self.attack_type == "shoot"
elseif dist <= self.shoot_reach and (self.attack_type == "shoot"
or (self.attack_type == "dogshoot" and self:dogswitch(dtime) == 1)
or (self.attack_type == "dogshoot" and (dist > self.reach or dist < self.avoid_distance and self.shooter_avoid_enemy) and self:dogswitch() == 0) then
or (self.attack_type == "dogshoot" and (dist > self.reach or dist < self.avoid_distance and self.shooter_avoid_enemy) and self:dogswitch() == 0)) then
p.y = p.y - .5
s.y = s.y + .5

View File

@ -229,6 +229,7 @@ function mcl_mobs.register_mob(name, def)
health = 0,
frame_speed_multiplier = 1,
reach = def.reach or 3,
shoot_reach = def.shoot_reach or def.view_range or 16,
htimer = 0,
texture_list = def.textures,
child_texture = def.child_texture,