1
0
Fork 0

Merge pull request 'Add line of sight calculations to the enderman' (#1481) from jordan4ibanez/MineClone2-MobTweaks:master into master

Reviewed-on: https://git.minetest.land/MineClone2/MineClone2/pulls/1481
formspec-v4
jordan4ibanez 2021-04-07 01:30:19 +00:00
commit 8ab9de74dc
1 changed files with 2 additions and 1 deletions

View File

@ -351,12 +351,13 @@ mobs:register_mob("mobs_mc:enderman", {
--calculate very quickly the exact location the player is looking
--within the distance between the two "heads" (player and enderman)
local look_pos = vector.new(player_pos.x, player_pos.y + player_eye_height, player_pos.z)
local look_pos_base = look_pos
local ender_eye_pos = vector.new(enderpos.x, enderpos.y + 2.75, enderpos.z)
local eye_distance_from_player = vector.distance(ender_eye_pos, look_pos)
look_pos = vector.add(look_pos, vector.multiply(look_dir, eye_distance_from_player))
--if looking in general head position, turn hostile
if vector.distance(look_pos, ender_eye_pos) <= 0.4 then
if minetest.line_of_sight(ender_eye_pos, look_pos_base) and vector.distance(look_pos, ender_eye_pos) <= 0.4 then
self.provoked = "staring"
self.attack = minetest.get_player_by_name(obj:get_player_name())
break