1
0
Fork 0

I think this addresses the crash and also makes enderman more passive during the day.

This commit is contained in:
Booglejr 2020-06-13 14:51:27 -05:00
parent a7b9107d31
commit d19bedc6d2
No known key found for this signature in database
GPG Key ID: 9298653061C12F5B
1 changed files with 39 additions and 14 deletions

View File

@ -3,7 +3,7 @@
--made for MC like Survival game
--License for code WTFPL and otherwise stated in readmes
-- ENDERMAN BEHAVIOUR:
-- ENDERMAN BEHAVIOUR (OLD):
-- In this game, endermen attack the player on sight, like other monsters do.
-- However, they have a reduced viewing range to make them less dangerous.
-- This differs from MC, in which endermen only become hostile when provoked,
@ -262,18 +262,31 @@ mobs:register_mob("mobs_mc:enderman", {
end
-- AGRESSIVELY WARP/CHASE PLAYER BEHAVIOUR HERE.
if self.state == "attack" then
if (minetest.get_timeofday() * 24000) > 5001 and (minetest.get_timeofday() * 24000) < 19000 then
self:teleport(nil)
self.state = ""
else
if self.attack then
target = self.attack
if vector.distance(self.object:get_pos(), target:get_pos()) > 10 then
self:teleport(target)
end
end
-- ARROW AVOIDANCE BEHAVIOUR HERE.
-- Check for arrows nearby.
end
end
-- ARROW / DAYTIME PEOPLE AVOIDANCE BEHAVIOUR HERE.
-- Check for arrows and people nearby.
local enderpos = self.object:get_pos()
local objs = minetest.get_objects_inside_radius(enderpos, 4)
for n = 1, #objs do
obj = objs[n]
if obj then
if minetest.is_player(obj) then
-- Warp from players during day.
if (minetest.get_timeofday() * 24000) > 5001 and (minetest.get_timeofday() * 24000) < 19000 then
self:teleport(nil)
end
else
lua = obj:get_luaentity()
if lua then
if lua.name == "mcl_bows:arrow_entity" then
@ -282,12 +295,20 @@ mobs:register_mob("mobs_mc:enderman", {
end
end
end
end
-- PROVOKED BEHAVIOUR HERE.
local enderpos = self.object:get_pos()
if self.provoked == "broke_contact" then
self.provoked = "false"
if (minetest.get_timeofday() * 24000) > 5001 and (minetest.get_timeofday() * 24000) < 19000 then
self:teleport(nil)
self.state = ""
else
if self.attack ~= nil then
self.state = 'attack'
end
end
end
-- Check to see if people are near by enough to look at us.
local objs = minetest.get_objects_inside_radius(enderpos, 64)
for n = 1, #objs do
@ -477,10 +498,14 @@ mobs:register_mob("mobs_mc:enderman", {
end,
do_punch = function(self, hitter, tflp, tool_caps, dir)
-- damage from rain caused by itself so we don't want it to attack itself.
if hitter ~= self.object then
if hitter ~= self.object and hitter ~= nil then
if (minetest.get_timeofday() * 24000) > 5001 and (minetest.get_timeofday() * 24000) < 19000 then
self:teleport(nil)
else
self:teleport(hitter)
self.state="attack"
self.attack=hitter
self.state="attack"
end
end
end,
water_damage = 8,