mirror of
https://git.minetest.land/VoxeLibre/VoxeLibre.git
synced 2024-11-22 10:31:06 +01:00
3 mob heads reduce mob detection range
This commit is contained in:
parent
364a4152ac
commit
460e7c0c67
6 changed files with 73 additions and 19 deletions
|
@ -91,6 +91,7 @@ local mod_tnt = minetest.get_modpath("mcl_tnt") ~= nil
|
||||||
local mod_mobspawners = minetest.get_modpath("mcl_mobspawners") ~= nil
|
local mod_mobspawners = minetest.get_modpath("mcl_mobspawners") ~= nil
|
||||||
local mod_hunger = minetest.get_modpath("mcl_hunger") ~= nil
|
local mod_hunger = minetest.get_modpath("mcl_hunger") ~= nil
|
||||||
local mod_worlds = minetest.get_modpath("mcl_worlds") ~= nil
|
local mod_worlds = minetest.get_modpath("mcl_worlds") ~= nil
|
||||||
|
local mod_armor = minetest.get_modpath("mcl_armor") ~= nil
|
||||||
|
|
||||||
-- play sound
|
-- play sound
|
||||||
local mob_sound = function(self, soundname, is_opinion, fixed_pitch)
|
local mob_sound = function(self, soundname, is_opinion, fixed_pitch)
|
||||||
|
@ -134,6 +135,31 @@ local mob_sound = function(self, soundname, is_opinion, fixed_pitch)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Reeturn true if object is in view_range
|
||||||
|
local function object_in_range(self, object)
|
||||||
|
if not object then
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
local factor
|
||||||
|
-- Apply view range reduction for special player armor
|
||||||
|
if object:is_player() and mod_armor then
|
||||||
|
factor = armor:get_mob_view_range_factor(object, self.name)
|
||||||
|
end
|
||||||
|
-- Distance check
|
||||||
|
local dist
|
||||||
|
if factor and factor == 0 then
|
||||||
|
return false
|
||||||
|
elseif factor then
|
||||||
|
dist = self.view_range * factor
|
||||||
|
else
|
||||||
|
dist = self.view_range
|
||||||
|
end
|
||||||
|
if vector.distance(self.object:get_pos(), object:get_pos()) > dist then
|
||||||
|
return false
|
||||||
|
else
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
-- attack player/mob
|
-- attack player/mob
|
||||||
local do_attack = function(self, player)
|
local do_attack = function(self, player)
|
||||||
|
@ -1524,7 +1550,6 @@ local specific_attack = function(list, what)
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
-- monster find someone to attack
|
-- monster find someone to attack
|
||||||
local monster_attack = function(self)
|
local monster_attack = function(self)
|
||||||
|
|
||||||
|
@ -1547,8 +1572,7 @@ local monster_attack = function(self)
|
||||||
|
|
||||||
if objs[n]:is_player() then
|
if objs[n]:is_player() then
|
||||||
|
|
||||||
if mobs.invis[ objs[n]:get_player_name() ] then
|
if mobs.invis[ objs[n]:get_player_name() ] or (not object_in_range(self, objs[n])) then
|
||||||
|
|
||||||
type = ""
|
type = ""
|
||||||
else
|
else
|
||||||
player = objs[n]
|
player = objs[n]
|
||||||
|
@ -1678,8 +1702,8 @@ local runaway_from = function(self)
|
||||||
if objs[n]:is_player() then
|
if objs[n]:is_player() then
|
||||||
|
|
||||||
if mobs.invis[ objs[n]:get_player_name() ]
|
if mobs.invis[ objs[n]:get_player_name() ]
|
||||||
or self.owner == objs[n]:get_player_name() then
|
or self.owner == objs[n]:get_player_name()
|
||||||
|
or (not object_in_range(self, objs[n])) then
|
||||||
type = ""
|
type = ""
|
||||||
else
|
else
|
||||||
player = objs[n]
|
player = objs[n]
|
||||||
|
@ -1757,7 +1781,7 @@ local follow_flop = function(self)
|
||||||
|
|
||||||
for n = 1, #players do
|
for n = 1, #players do
|
||||||
|
|
||||||
if vector.distance(players[n]:get_pos(), s) < self.view_range
|
if (object_in_range(self, players[n]))
|
||||||
and not mobs.invis[ players[n]:get_player_name() ] then
|
and not mobs.invis[ players[n]:get_player_name() ] then
|
||||||
|
|
||||||
self.following = players[n]
|
self.following = players[n]
|
||||||
|
@ -1808,7 +1832,7 @@ local follow_flop = function(self)
|
||||||
local dist = vector.distance(p, s)
|
local dist = vector.distance(p, s)
|
||||||
|
|
||||||
-- dont follow if out of range
|
-- dont follow if out of range
|
||||||
if dist > self.view_range then
|
if (not object_in_range(self, self.following)) then
|
||||||
self.following = nil
|
self.following = nil
|
||||||
else
|
else
|
||||||
local vec = {
|
local vec = {
|
||||||
|
@ -2071,7 +2095,7 @@ local do_states = function(self, dtime)
|
||||||
local dist = vector.distance(p, s)
|
local dist = vector.distance(p, s)
|
||||||
|
|
||||||
-- stop attacking if player invisible or out of range
|
-- stop attacking if player invisible or out of range
|
||||||
if dist > self.view_range
|
if not object_in_range(self, self.attack)
|
||||||
or not self.attack
|
or not self.attack
|
||||||
or not self.attack:get_pos()
|
or not self.attack:get_pos()
|
||||||
or self.attack:get_hp() <= 0
|
or self.attack:get_hp() <= 0
|
||||||
|
|
|
@ -1,2 +1,2 @@
|
||||||
name = mcl_mobs
|
name = mcl_mobs
|
||||||
optional_depends = mcl_weather, mcl_tnt, mcl_hunger, mcl_worlds, invisibility, lucky_block, cmi, doc_identifier
|
optional_depends = mcl_weather, mcl_tnt, mcl_hunger, mcl_worlds, invisibility, lucky_block, cmi, doc_identifier, mcl_armor
|
||||||
|
|
|
@ -157,6 +157,33 @@ armor.get_armor_points = function(self, player)
|
||||||
return pts
|
return pts
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Returns a change factor for a mob's view_range for the given player
|
||||||
|
-- or nil, if there's no change. Certain armors (like mob heads) can
|
||||||
|
-- affect the view range of mobs.
|
||||||
|
armor.get_mob_view_range_factor = function(self, player, mob)
|
||||||
|
local name, player_inv, armor_inv = armor:get_valid_player(player, "[get_mob_view_range_factor]")
|
||||||
|
if not name then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
local factor
|
||||||
|
for i=1, 6 do
|
||||||
|
local stack = player_inv:get_stack("armor", i)
|
||||||
|
if stack:get_count() > 0 then
|
||||||
|
local def = stack:get_definition()
|
||||||
|
if def._mcl_armor_mob_range_mob == mob then
|
||||||
|
if not factor then
|
||||||
|
factor = def._mcl_armor_mob_range_factor
|
||||||
|
elseif factor == 0 then
|
||||||
|
return 0
|
||||||
|
else
|
||||||
|
factor = factor * def._mcl_armor_mob_range_factor
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return factor
|
||||||
|
end
|
||||||
|
|
||||||
armor.get_player_skin = function(self, name)
|
armor.get_player_skin = function(self, name)
|
||||||
local skin = nil
|
local skin = nil
|
||||||
if skin_mod == "mcl_skins" then
|
if skin_mod == "mcl_skins" then
|
||||||
|
|
|
@ -2,7 +2,7 @@ local S = minetest.get_translator("mcl_heads")
|
||||||
|
|
||||||
-- Heads system
|
-- Heads system
|
||||||
|
|
||||||
local function addhead(name, texture, desc, longdesc)
|
local function addhead(name, texture, desc, longdesc, rangemob, rangefactor)
|
||||||
local on_rotate
|
local on_rotate
|
||||||
if minetest.get_modpath("screwdriver") then
|
if minetest.get_modpath("screwdriver") then
|
||||||
on_rotate = screwdriver.rotate_simple
|
on_rotate = screwdriver.rotate_simple
|
||||||
|
@ -46,13 +46,16 @@ local function addhead(name, texture, desc, longdesc)
|
||||||
on_rotate = on_rotate,
|
on_rotate = on_rotate,
|
||||||
_mcl_blast_resistance = 5,
|
_mcl_blast_resistance = 5,
|
||||||
_mcl_hardness = 1,
|
_mcl_hardness = 1,
|
||||||
|
_mcl_armor_mob_range_factor = rangefactor,
|
||||||
|
_mcl_armor_mob_range_mob = rangemob,
|
||||||
|
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Add heads
|
-- Add heads
|
||||||
addhead("zombie", "mcl_heads_zombie_node.png", S("Zombie Head"), S("A zombie head is a small decorative block which resembles the head of a zombie. It can also be worn as a helmet for fun, but does not offer any protection."))
|
addhead("zombie", "mcl_heads_zombie_node.png", S("Zombie Head"), S("A zombie head is a small decorative block which resembles the head of a zombie. It can also be worn as a helmet, which reduces the detection range of zombies by 50%."), "mobs_mc:zombie", 0.5)
|
||||||
addhead("creeper", "mcl_heads_creeper_node.png", S("Creeper Head"), S("A creeper head is a small decorative block which resembles the head of a creeper. It can also be worn as a helmet for fun, but does not offer any protection."))
|
addhead("creeper", "mcl_heads_creeper_node.png", S("Creeper Head"), S("A creeper head is a small decorative block which resembles the head of a creeper. It can also be worn as a helmet, which reduces the detection range of creepers by 50%."), "mobs_mc:creeper", 0.5)
|
||||||
-- Original Minecraft name: “Head”
|
-- Original Minecraft name: “Head”
|
||||||
addhead("steve", "mcl_heads_steve_node.png", S("Human Head"), S("A human head is a small decorative block which resembles the head of a human (i.e. a player character). It can also be worn as a helmet for fun, but does not offer any protection."))
|
addhead("steve", "mcl_heads_steve_node.png", S("Human Head"), S("A human head is a small decorative block which resembles the head of a human (i.e. a player character). It can also be worn as a helmet for fun, but does not offer any protection."))
|
||||||
addhead("skeleton", "mcl_heads_skeleton_node.png", S("Skeleton Skull"), S("A skeleton skull is a small decorative block which resembles the skull of a skeleton. It can also be worn as a helmet for fun, but does not offer any protection."))
|
addhead("skeleton", "mcl_heads_skeleton_node.png", S("Skeleton Skull"), S("A skeleton skull is a small decorative block which resembles the skull of a skeleton. It can also be worn as a helmet, which reduces the detection range of skeletons by 50%."), "mobs_mc:skeleton", 0.5)
|
||||||
addhead("wither_skeleton", "mcl_heads_wither_skeleton_node.png", S("Wither Skeleton Skull"), S("A wither skeleton skull is a small decorative block which resembles the skull of a wither skeleton. It can also be worn as a helmet for fun, but does not offer any protection."))
|
addhead("wither_skeleton", "mcl_heads_wither_skeleton_node.png", S("Wither Skeleton Skull"), S("A wither skeleton skull is a small decorative block which resembles the skull of a wither skeleton. It can also be worn as a helmet for fun, but does not offer any protection."))
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
# textdomain: mcl_heads
|
# textdomain: mcl_heads
|
||||||
Zombie Head=Zombiekopf
|
Zombie Head=Zombiekopf
|
||||||
A zombie head is a small decorative block which resembles the head of a zombie. It can also be worn as a helmet for fun, but does not offer any protection.=Ein Zombiekopf ist ein kleiner dekorativer Block, der so wie ein Kopf eines Zombies aussieht. Er kann auch als Helm zum Spaß getragen werden, aber er bietet keinerlei Schutz.
|
A zombie head is a small decorative block which resembles the head of a zombie. It can also be worn as a helmet, which reduces the detection range of zombies by 50%.=Ein Zombiekopf ist ein kleiner dekorativer Block, der so wie ein Kopf eines Zombies aussieht. Er kann auch als Helm getragen werden, was den Erkennungsradius von Zombies um 50% verringert.
|
||||||
Creeper Head=Creeper-Kopf
|
Creeper Head=Creeper-Kopf
|
||||||
A creeper head is a small decorative block which resembles the head of a creeper. It can also be worn as a helmet for fun, but does not offer any protection.=Ein Creeper-Kopf ist ein kleiner dekorativer Block, der so wie ein Kopf eines Creepers aussieht. Er kann auch als Helm zum Spaß getragen werden, aber er bietet keinerlei Schutz.
|
A creeper head is a small decorative block which resembles the head of a creeper. It can also be worn as a helmet, which reduces the detection range of creepers by 50%.=Ein Creeperkopf ist ein kleiner dekorativer Block, der so wie ein Kopf eines Creepers aussieht. Er kann auch als Helm getragen werden, was den Erkennungsradius von Creepern um 50% verringert.
|
||||||
Human Head=Menschenkopf
|
Human Head=Menschenkopf
|
||||||
A human head is a small decorative block which resembles the head of a human (i.e. a player character). It can also be worn as a helmet for fun, but does not offer any protection.=Ein Menschenkopf ist ein kleiner dekorativer Block, der so wie der Kopf eines Menschen (das heißt, einer Spielerfigur) aussieht. Er kann auch als Helm zum Spaß getragen werden, aber er bietet keinerlei Schutz.
|
A human head is a small decorative block which resembles the head of a human (i.e. a player character). It can also be worn as a helmet for fun, but does not offer any protection.=Ein Menschenkopf ist ein kleiner dekorativer Block, der so wie der Kopf eines Menschen (das heißt, einer Spielerfigur) aussieht. Er kann auch als Helm zum Spaß getragen werden, aber er bietet keinerlei Schutz.
|
||||||
Skeleton Skull=Skelettschädel
|
Skeleton Skull=Skelettschädel
|
||||||
A skeleton skull is a small decorative block which resembles the skull of a skeleton. It can also be worn as a helmet for fun, but does not offer any protection.=Ein Skelettschädel ist ein kleiner dekorativer Block, der so wie ein Schädel eines Skeletts aussieht. Er kann auch als Helm zum Spaß getragen werden, aber er bietet keinerlei Schutz.
|
A skeleton skull is a small decorative block which resembles the skull of a skeleton. It can also be worn as a helmet, which reduces the detection range of skeletons by 50%.=Ein Skelettschädel ist ein kleiner dekorativer Block, der so wie ein Schädel eines Skeletts aussieht. Er kann auch als Helm getragen werden, was den Erkennungsradius von Skeletten um 50% verringert.
|
||||||
Wither Skeleton Skull=Witherskelettschädel
|
Wither Skeleton Skull=Witherskelettschädel
|
||||||
A wither skeleton skull is a small decorative block which resembles the skull of a wither skeleton. It can also be worn as a helmet for fun, but does not offer any protection.=Ein Witherskelettschädel ist ein kleiner dekorativer Block, der so wie ein Schädel eines Witherskeletts aussieht. Er kann auch als Helm zum Spaß getragen werden, aber er bietet keinerlei Schutz.
|
A wither skeleton skull is a small decorative block which resembles the skull of a wither skeleton. It can also be worn as a helmet for fun, but does not offer any protection.=Ein Witherskelettschädel ist ein kleiner dekorativer Block, der so wie ein Schädel eines Witherskeletts aussieht. Er kann auch als Helm zum Spaß getragen werden, aber er bietet keinerlei Schutz.
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
# textdomain: mcl_heads
|
# textdomain: mcl_heads
|
||||||
Zombie Head=
|
Zombie Head=
|
||||||
A zombie head is a small decorative block which resembles the head of a zombie. It can also be worn as a helmet for fun, but does not offer any protection.=
|
A zombie head is a small decorative block which resembles the head of a zombie. It can also be worn as a helmet, which reduces the detection range of zombies by 50%.
|
||||||
Creeper Head=
|
Creeper Head=
|
||||||
A creeper head is a small decorative block which resembles the head of a creeper. It can also be worn as a helmet for fun, but does not offer any protection.=
|
A creeper head is a small decorative block which resembles the head of a creeper. It can also be worn as a helmet, which reduces the detection range of creepers by 50%.
|
||||||
Human Head=
|
Human Head=
|
||||||
A human head is a small decorative block which resembles the head of a human (i.e. a player character). It can also be worn as a helmet for fun, but does not offer any protection.=
|
A human head is a small decorative block which resembles the head of a human (i.e. a player character). It can also be worn as a helmet for fun, but does not offer any protection.=
|
||||||
Skeleton Skull=
|
Skeleton Skull=
|
||||||
A skeleton skull is a small decorative block which resembles the skull of a skeleton. It can also be worn as a helmet for fun, but does not offer any protection.=
|
A skeleton skull is a small decorative block which resembles the skull of a skeleton. It can also be worn as a helmet, which reduces the detection range of skeletons by 50%.
|
||||||
Wither Skeleton Skull=
|
Wither Skeleton Skull=
|
||||||
A wither skeleton skull is a small decorative block which resembles the skull of a wither skeleton. It can also be worn as a helmet for fun, but does not offer any protection.=
|
A wither skeleton skull is a small decorative block which resembles the skull of a wither skeleton. It can also be worn as a helmet for fun, but does not offer any protection.=
|
||||||
|
|
Loading…
Reference in a new issue