mirror of
https://codeberg.org/tenplus1/mobs_redo.git
synced 2025-04-01 18:00:28 +02:00
add friendly_fire mob setting for arrows (thx eschan145)
This commit is contained in:
parent
3bd2ee8129
commit
cd4fb6f2a6
17
api.lua
17
api.lua
@ -25,7 +25,7 @@ local use_cmi = minetest.global_exists("cmi")
|
|||||||
|
|
||||||
mobs = {
|
mobs = {
|
||||||
mod = "redo",
|
mod = "redo",
|
||||||
version = "20230325",
|
version = "20230326",
|
||||||
intllib = S,
|
intllib = S,
|
||||||
invis = minetest.global_exists("invisibility") and invisibility or {}
|
invis = minetest.global_exists("invisibility") and invisibility or {}
|
||||||
}
|
}
|
||||||
@ -197,6 +197,7 @@ mobs.mob_class = {
|
|||||||
attack_animals = false,
|
attack_animals = false,
|
||||||
attack_players = true,
|
attack_players = true,
|
||||||
attack_npcs = true,
|
attack_npcs = true,
|
||||||
|
friendly_fire = true,
|
||||||
facing_fence = false,
|
facing_fence = false,
|
||||||
_breed_countdown = nil,
|
_breed_countdown = nil,
|
||||||
_cmi_is_mob = true
|
_cmi_is_mob = true
|
||||||
@ -2953,8 +2954,17 @@ function mob_class:on_punch(hitter, tflp, tool_capabilities, dir, damage)
|
|||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- do damage
|
-- check for friendly fire (arrows from same mob)
|
||||||
self.health = self.health - floor(damage)
|
if self.friendly_fire then
|
||||||
|
self.health = self.health - floor(damage) -- do damage regardless
|
||||||
|
else
|
||||||
|
local entity = hitter and hitter:get_luaentity()
|
||||||
|
|
||||||
|
-- check if arrow from same mob, if so then do no damage
|
||||||
|
if entity and entity.name ~= self.arrow then
|
||||||
|
self.health = self.health - floor(damage)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
-- exit here if dead, check for tools with fire damage
|
-- exit here if dead, check for tools with fire damage
|
||||||
local hot = tool_capabilities and tool_capabilities.damage_groups
|
local hot = tool_capabilities and tool_capabilities.damage_groups
|
||||||
@ -3604,6 +3614,7 @@ minetest.register_entity(name, setmetatable({
|
|||||||
attack_players = def.attack_players,
|
attack_players = def.attack_players,
|
||||||
attack_npcs = def.attack_npcs,
|
attack_npcs = def.attack_npcs,
|
||||||
specific_attack = def.specific_attack,
|
specific_attack = def.specific_attack,
|
||||||
|
friendly_fire = def.friendly_fire,
|
||||||
runaway_from = def.runaway_from,
|
runaway_from = def.runaway_from,
|
||||||
owner_loyal = def.owner_loyal,
|
owner_loyal = def.owner_loyal,
|
||||||
pushable = def.pushable,
|
pushable = def.pushable,
|
||||||
|
3
api.txt
3
api.txt
@ -150,6 +150,9 @@ functions needed for the mob to work properly which contains the following:
|
|||||||
arrow/fireball appears on mob.
|
arrow/fireball appears on mob.
|
||||||
'specific_attack' has a table of entity names that mob can also attack
|
'specific_attack' has a table of entity names that mob can also attack
|
||||||
e.g. {"player", "mobs_animal:chicken"}.
|
e.g. {"player", "mobs_animal:chicken"}.
|
||||||
|
'friendly_fire` when set to false, mobs will not be able to harm other
|
||||||
|
mobs of the same type with friendly fire arrows.
|
||||||
|
Defaults to true.
|
||||||
'runaway_from' contains a table with mob names to run away from, add
|
'runaway_from' contains a table with mob names to run away from, add
|
||||||
"player" to list to runaway from player also.
|
"player" to list to runaway from player also.
|
||||||
'ignore_invisibility' When true mob will still be able to see and attack
|
'ignore_invisibility' When true mob will still be able to see and attack
|
||||||
|
Loading…
x
Reference in New Issue
Block a user