1
0
Fork 0

Merge pull request 'Fix insane enderman 64 node radius check for players' (#1479) from jordan4ibanez/MineClone2-MobTweaks:master into master

Reviewed-on: MineClone2/MineClone2#1479
This commit is contained in:
jordan4ibanez 2021-04-07 00:25:52 +00:00
commit 4ec3fd0ba6
1 changed files with 22 additions and 29 deletions

View File

@ -328,37 +328,30 @@ mobs:register_mob("mobs_mc:enderman", {
--end --end
end end
-- Check to see if people are near by enough to look at us. -- Check to see if people are near by enough to look at us.
local objs = minetest.get_objects_inside_radius(enderpos, 64) for _,obj in pairs(minetest.get_connected_players()) do
local obj -- Check if they are looking at us.
for n = 1, #objs do local player_pos = obj:get_pos()
obj = objs[n] local look_dir_not_normalized = obj:get_look_dir()
if obj then local look_dir = vector.normalize(look_dir_not_normalized)
if minetest.is_player(obj) then local look_pos = vector.new({x = look_dir.x+player_pos.x, y = look_dir.y+player_pos.y + 1.5, z = look_dir.z+player_pos.z}) -- Arbitrary value (1.5) is head level according to player info mod.
-- Check if they are looking at us. -- Cast up to 64 to see if player is looking at enderman.
local player_pos = obj:get_pos() for n = 1,64,.25 do
local look_dir_not_normalized = obj:get_look_dir() local node = minetest.get_node(look_pos)
local look_dir = vector.normalize(look_dir_not_normalized) if node.name ~= "air" then
local look_pos = vector.new({x = look_dir.x+player_pos.x, y = look_dir.y+player_pos.y + 1.5, z = look_dir.z+player_pos.z}) -- Arbitrary value (1.5) is head level according to player info mod. break
-- Cast up to 64 to see if player is looking at enderman. end
for n = 1,64,.25 do if look_pos.x-1<enderpos.x and look_pos.x+1>enderpos.x and look_pos.y-2.89<enderpos.y and look_pos.y-2>enderpos.y and look_pos.z-1<enderpos.z and look_pos.z+1>enderpos.z then
local node = minetest.get_node(look_pos) self.provoked = "staring"
if node.name ~= "air" then self.attack = minetest.get_player_by_name(obj:get_player_name())
break break
end else
if look_pos.x-1<enderpos.x and look_pos.x+1>enderpos.x and look_pos.y-2.89<enderpos.y and look_pos.y-2>enderpos.y and look_pos.z-1<enderpos.z and look_pos.z+1>enderpos.z then if self.provoked == "staring" then
self.provoked = "staring" self.provoked = "broke_contact"
self.attack = minetest.get_player_by_name(obj:get_player_name())
break
else
if self.provoked == "staring" then
self.provoked = "broke_contact"
end
end
look_pos.x = look_pos.x + (.25 * look_dir.x)
look_pos.y = look_pos.y + (.25 * look_dir.y)
look_pos.z = look_pos.z + (.25 * look_dir.z)
end end
end end
look_pos.x = look_pos.x + (.25 * look_dir.x)
look_pos.y = look_pos.y + (.25 * look_dir.y)
look_pos.z = look_pos.z + (.25 * look_dir.z)
end end
end end
-- TAKE AND PLACE STUFF BEHAVIOUR BELOW. -- TAKE AND PLACE STUFF BEHAVIOUR BELOW.