make target algorithm select other mobs as targets if configured
This commit is contained in:
parent
f092801511
commit
5e3368f01b
@ -156,6 +156,12 @@ local mob_template = {
|
||||
--! @brief [OPTIONAL] is mob sensitive to sun?
|
||||
sun_sensitive=true,
|
||||
|
||||
--! @brief [OPTIONAL] attacks hostile mobs
|
||||
attack_hostile_mobs=false,
|
||||
|
||||
--! @brief [UNUSED] attacks hostile mobs
|
||||
--attack_friendly_mobs=false,
|
||||
|
||||
--! @brief [OPTIONAL] configuration of meele attack
|
||||
melee = {
|
||||
--! @brief [MANDATORY] maximum damage mob does per hit
|
||||
@ -171,7 +177,9 @@ local mob_template = {
|
||||
attack="some_entity",
|
||||
--! @brief [MANDATORY] distance to issue an attack
|
||||
range=10,
|
||||
--! @brief [MANDATORY] minimum time between two attacks
|
||||
--! @brief [OPTIONAL] minimum range of distance attack (should be > range of melee attack)
|
||||
min_range = 3,
|
||||
--! @brief [MANDATORY] minimum time between two attacks
|
||||
speed=2,
|
||||
},
|
||||
|
||||
|
@ -520,19 +520,35 @@ function fighting.get_target(entity)
|
||||
|
||||
for i,v in ipairs(objectlist) do
|
||||
|
||||
local playername = v.get_player_name(v)
|
||||
|
||||
if playername ~= nil and
|
||||
playername ~= "" then
|
||||
count = count + 1
|
||||
table.insert(possible_targets,v)
|
||||
dbg_mobf.fighting_lvl3(playername .. " is next to a mob of type "
|
||||
.. entity.data.name);
|
||||
if v:is_player() then
|
||||
local playername = v:get_player_name()
|
||||
|
||||
--don't attack spawner
|
||||
if entity.dynamic_data.spawning.spawner == nil or
|
||||
entity.dynamic_data.spawning.spawner ~= playername then
|
||||
count = count + 1
|
||||
table.insert(possible_targets,v)
|
||||
dbg_mobf.fighting_lvl2("MOBF: " .. playername ..
|
||||
" is next to a mob of type ".. entity.data.name)
|
||||
else
|
||||
dbg_mobf.fighting_lvl2("MOBF: " .. entity.data.name ..
|
||||
" not attacking: " .. playername .. " is spwaner")
|
||||
end
|
||||
else
|
||||
if entity.data.combat.attack_hostile_mobs then
|
||||
if v.data ~= nil and
|
||||
v.data.combat ~= nil and
|
||||
v.data.combat.starts_attack then
|
||||
|
||||
table.insert(possible_targets,v)
|
||||
dbg_mobf.fighting_lvl3(v.data.name .. " is next to a mob of type "
|
||||
.. entity.data.name)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
dbg_mobf.fighting_lvl3("Found ".. count .. " objects within attack range of "
|
||||
.. entity.data.name)
|
||||
dbg_mobf.fighting_lvl2("MOBF: found ".. count .. " objects within" ..
|
||||
" attack range of " .. entity.data.name)
|
||||
end
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user