From ce9b81d429a91c8c73c16128ca3ceabaa9b430ad Mon Sep 17 00:00:00 2001 From: tenplus1 Date: Thu, 5 Mar 2015 13:08:08 +0000 Subject: [PATCH] Warthogs attack when punched --- api.lua | 12 +++++------- warthog.lua | 6 +++++- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/api.lua b/api.lua index 3679268..2e18dee 100644 --- a/api.lua +++ b/api.lua @@ -675,9 +675,9 @@ function mobs:register_mob(name, def) self.object:setvelocity({x=dir.x*kb,y=ykb,z=dir.z*kb}) self.pause_timer = r ---[[ + -- attack puncher and call other mobs for help - if self.passive == false then + if self.passive == false and not self.tamed then if self.state ~= "attack" then self.do_attack(self,hitter,1) end @@ -692,7 +692,7 @@ function mobs:register_mob(name, def) end end end -]]-- + end, }) @@ -733,12 +733,10 @@ function mobs:register_spawn(name, nodes, max_light, min_light, chance, active_o -- are we spawning inside a node? local nod = minetest.get_node_or_nil(pos) - if not nod then return end - if minetest.registered_nodes[nod.name].walkable == true then return end + if not nod or minetest.registered_nodes[nod.name].walkable == true then return end pos.y = pos.y + 1 nod = minetest.get_node_or_nil(pos) - if not nod then return end - if minetest.registered_nodes[nod.name].walkable == true then return end + if not nod or minetest.registered_nodes[nod.name].walkable == true then return end if minetest.setting_getbool("display_mob_spawn") then minetest.chat_send_all("[mobs] Add "..name.." at "..minetest.pos_to_string(pos)) diff --git a/warthog.lua b/warthog.lua index ec973cb..95e2adc 100644 --- a/warthog.lua +++ b/warthog.lua @@ -14,6 +14,9 @@ mobs:register_mob("mobs:pumba", { mesh = "mobs_pumba.x", makes_footstep_sound = true, walk_velocity = 2, + run_velocity = 3, + damage = 1, + attack_type = "dogfight", armor = 200, drops = { {name = "mobs:pork_raw", @@ -34,12 +37,13 @@ mobs:register_mob("mobs:pumba", { stand_end = 55, walk_start = 70, walk_end = 100, + punch_start = 70, + punch_end = 100, }, follow = "farming:wheat", view_range = 5, jump = true, step = 1, -passive = true, on_rightclick = function(self, clicker) local item = clicker:get_wielded_item()