From 1020b080aae6a9133b752346dac8fbcd0f5a3103 Mon Sep 17 00:00:00 2001 From: crabman77 Date: Wed, 22 Jul 2015 00:11:38 +0200 Subject: [PATCH] added group_attack in cow,goat,warthog and npc added group attack if not tamed and type(name) identical fixed crash if unknow node in function env_damage --- mods/mobs/api.lua | 5 ++++- mods/mobs/cow.lua | 1 + mods/mobs/goat.lua | 1 + mods/mobs/npc.lua | 1 + mods/mobs/warthog.lua | 1 + 5 files changed, 8 insertions(+), 1 deletion(-) diff --git a/mods/mobs/api.lua b/mods/mobs/api.lua index 055e3807..28b5482d 100755 --- a/mods/mobs/api.lua +++ b/mods/mobs/api.lua @@ -317,6 +317,7 @@ function mobs:register_mob(name, def) local nod = minetest.get_node_or_nil(pos) if not nod then return end ; -- print ("standing in "..nod.name) local nodef = minetest.registered_nodes[nod.name] + if not nodef then return end pos.y = pos.y + 1 -- water @@ -1185,8 +1186,10 @@ end local obj = nil for _, oir in pairs(minetest.get_objects_inside_radius(hitter:getpos(), 5)) do obj = oir:get_luaentity() - if obj then + if obj + and obj.name == self.name then if obj.group_attack == true + and not obj.tamed and obj.state ~= "attack" then obj.do_attack(obj, hitter, 1) end diff --git a/mods/mobs/cow.lua b/mods/mobs/cow.lua index 789e7bc6..c7b5455f 100755 --- a/mods/mobs/cow.lua +++ b/mods/mobs/cow.lua @@ -6,6 +6,7 @@ mobs:register_mob("mobs:cow", { type = "animal", -- aggressive, does 5 damage to player when threatened passive = false, + group_attack = true, attack_type = "dogfight", damage = 4, -- health & armor diff --git a/mods/mobs/goat.lua b/mods/mobs/goat.lua index 626aa68e..9265b080 100755 --- a/mods/mobs/goat.lua +++ b/mods/mobs/goat.lua @@ -6,6 +6,7 @@ mobs:register_mob("mobs:goat", { type = "animal", -- aggressive, does 5 damage to player when threatened passive = false, + group_attack = true, attack_type = "dogfight", damage = 4, -- health & armor diff --git a/mods/mobs/npc.lua b/mods/mobs/npc.lua index 4e9e6e5e..b7814e77 100755 --- a/mods/mobs/npc.lua +++ b/mods/mobs/npc.lua @@ -13,6 +13,7 @@ mobs:register_mob("mobs:npc", { type = "npc", -- aggressive, deals 6 damage to player/monster when hit passive = false, + group_attack = true, damage = 5, -- 3 damages if tamed attack_type = "dogfight", attacks_monsters = true, diff --git a/mods/mobs/warthog.lua b/mods/mobs/warthog.lua index 1bf184ea..da0dae8a 100755 --- a/mods/mobs/warthog.lua +++ b/mods/mobs/warthog.lua @@ -6,6 +6,7 @@ mobs:register_mob("mobs:pumba", { type = "animal", -- aggressive, deals 5 damage to player when threatened passive = false, + group_attack = true, attack_type = "dogfight", damage = 4, -- health & armor