Merge branch 'fix_wolves_behaviour' into master+nixnoxus

This commit is contained in:
nixnoxus 2024-03-03 12:32:31 +01:00
commit 8cb68c7325
8 changed files with 23 additions and 4 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

@ -360,7 +360,7 @@ function mob_class:monster_attack()
player = obj.object
name = obj.name or ""
end
if obj and obj.type == self.type and obj.passive == false and obj.state == "attack" and obj.attack then
if obj and obj.type == self.type and obj.passive == false and obj.state == "attack" and obj.attack and self.object ~= obj.attack then
table.insert(blacklist_attack, obj.attack)
end
end
@ -388,6 +388,7 @@ function mob_class:monster_attack()
-- find specific mob to attack, failing that attack player/npc/animal
if specific_attack(self.specific_attack, name)
and self.object ~= player
and (type == "player" or ( type == "npc" and self.attack_npcs )
or (type == "animal" and self.attack_animals == true)
or (self.extra_hostile and not self.attack_exception(player))) then
@ -1153,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,

View File

@ -112,6 +112,10 @@ mcl_mobs.register_mob("mobs_mc:llama", {
},
follow = { "mcl_farming:wheat_item", "mcl_farming:hay_block" },
view_range = 16,
attack_animals = true,
damage = 1,
shoot_reach = 5,
specific_attack = { "mobs_mc:wolf" },
do_custom = function(self, dtime)
-- set needed values if not already present

View File

@ -42,6 +42,7 @@ local rabbit = {
makes_footstep_sound = false,
walk_velocity = 1,
run_velocity = 3.7,
avoid_from = {"mobs_mc:wolf"},
follow_velocity = 1.1,
floats = 1,
runaway = true,

View File

@ -46,6 +46,7 @@ local skeleton = {
},
walk_velocity = 1.2,
run_velocity = 2.0,
runaway_from = {"mobs_mc:wolf"},
damage = 2,
reach = 2,
drops = {

View File

@ -44,6 +44,7 @@ mcl_mobs.register_mob("mobs_mc:witherskeleton", {
},
walk_velocity = 1.2,
run_velocity = 2.0,
runaway_from = {"mobs_mc:wolf"},
damage = 7,
reach = 2,
drops = {

View File

@ -97,7 +97,16 @@ local wolf = {
jump = true,
attacks_monsters = true,
attack_animals = true,
specific_attack = { "player", "mobs_mc:sheep" },
specific_attack = {
"player",
"mobs_mc:sheep",
"mobs_mc:rabbit",
-- TODO: "mobs_mc:fox",
"mobs_mc:skeleton",
"mobs_mc:stray",
"mobs_mc:witherskeleton",
},
avoid_from = { "mobs_mc:llama" },
}
mcl_mobs.register_mob("mobs_mc:wolf", wolf)