From c9ba04f33974fa17b4a935c1277a13e66db2c350 Mon Sep 17 00:00:00 2001 From: crabman77 Date: Mon, 14 Sep 2015 18:53:48 +0200 Subject: [PATCH] update mobs --- mods/mobs/api.lua | 114 ++++++++++++++--------- mods/mobs/dungeonmaster.lua | 8 +- mods/mobs/mese_monster.lua | 19 ++-- mods/mobs/models/character.b3d | Bin 86880 -> 86880 bytes mods/mobs/models/mobs_dungeon_master.b3d | Bin 26289 -> 26289 bytes mods/mobs/models/mobs_kitten.b3d | Bin 98176 -> 98176 bytes mods/mobs/models/mobs_oerkki.b3d | Bin 42149 -> 42149 bytes mods/mobs/models/mobs_rat.b3d | Bin 6956 -> 6956 bytes mods/mobs/models/mobs_sand_monster.b3d | Bin 115989 -> 115989 bytes mods/mobs/models/mobs_sheep.b3d | Bin 71405 -> 71405 bytes mods/mobs/models/mobs_sheep_shaved.b3d | Bin 55932 -> 55932 bytes mods/mobs/models/mobs_stone_monster.b3d | Bin 29900 -> 29900 bytes mods/mobs/models/mobs_tree_monster.b3d | Bin 51386 -> 51386 bytes 13 files changed, 88 insertions(+), 53 deletions(-) diff --git a/mods/mobs/api.lua b/mods/mobs/api.lua index 5273fa72..e26eb4f3 100755 --- a/mods/mobs/api.lua +++ b/mods/mobs/api.lua @@ -1,4 +1,4 @@ --- Mobs Api (28th August 2015) +-- Mobs Api (9th September 2015) mobs = {} mobs.mod = "redo" @@ -110,24 +110,21 @@ function mobs:register_mob(name, def) return (v.x ^ 2 + v.z ^ 2) ^ (0.5) end, --[[ - in_fov = function(self,pos) + in_fov = function(self, pos) -- checks if POS is in self's FOV local yaw = self.object:getyaw() + self.rotate local vx = math.sin(yaw) local vz = math.cos(yaw) local ds = math.sqrt(vx ^ 2 + vz ^ 2) local ps = math.sqrt(pos.x ^ 2 + pos.z ^ 2) - local d = { x = vx / ds, z = vz / ds } - local p = { x = pos.x / ps, z = pos.z / ps } - local an = ( d.x * p.x ) + ( d.z * p.z ) + local d = {x = vx / ds, z = vz / ds} + local p = {x = pos.x / ps, z = pos.z / ps} + local an = (d.x * p.x) + (d.z * p.z) - a = math.deg( math.acos( an ) ) - - if a > ( self.fov / 2 ) then + if math.deg(math.acos(an)) > (self.fov / 2) then return false - else - return true end + return true end, ]] set_animation = function(self, type) @@ -186,8 +183,8 @@ function mobs:register_mob(name, def) on_step = function(self, dtime) - if self.type == "monster" - and peaceful_only then + if (self.type == "monster" and peaceful_only) + or not within_limits(self.object:getpos(), 0) then self.object:remove() return end @@ -198,7 +195,8 @@ function mobs:register_mob(name, def) self.lifetimer = self.lifetimer - dtime if self.lifetimer <= 0 and self.state ~= "attack" then - minetest.log("action","lifetimer expired, removed "..self.name) + minetest.log("action", + "lifetimer expired, removed "..self.name) effect(self.object:getpos(), 15, "tnt_smoke.png") self.object:remove() return @@ -330,7 +328,9 @@ function mobs:register_mob(name, def) -- lava or fire if self.lava_damage ~= 0 - and (nodef.groups.lava or nod.name == "fire:basic_flame") then + and (nodef.groups.lava + or nod.name == "fire:basic_flame" + or nod.name == "xanadu:safe_fire") then self.object:set_hp(self.object:get_hp() - self.lava_damage) effect(pos, 5, "fire_basic_flame.png") if check_for_death(self) then return end @@ -528,23 +528,23 @@ function mobs:register_mob(name, def) for i,obj in ipairs(ents) do ent = obj:get_luaentity() - -- check for same animal with different colour - local canmate = false - if ent then - if ent.name == self.name then - canmate = true - else - local entname = string.split(ent.name,":") - local selfname = string.split(self.name,":") - if entname[1] == selfname[1] then - entname = string.split(entname[2],"_") - selfname = string.split(selfname[2],"_") + -- check for same animal with different colour + local canmate = false + if ent then + if ent.name == self.name then + canmate = true + else + local entname = string.split(ent.name,":") + local selfname = string.split(self.name,":") if entname[1] == selfname[1] then - canmate = true + entname = string.split(entname[2],"_") + selfname = string.split(selfname[2],"_") + if entname[1] == selfname[1] then + canmate = true + end end end end - end if ent and canmate == true @@ -1150,8 +1150,9 @@ end -- weapon wear hitter:set_detach() --MFF (crabman|27/7/2015) anti usebug, immortal if attached local weapon = hitter:get_wielded_item() + local punch_interval = tool_capabilities.full_punch_interval or 1.4 if weapon:get_definition().tool_capabilities ~= nil then - local wear = ( (weapon:get_definition().tool_capabilities.full_punch_interval or 1.4) / 75 ) * 9000 + local wear = (punch_interval / 75) * 9000 weapon:add_wear(wear) hitter:set_wielded_item(weapon) end @@ -1338,8 +1339,9 @@ function mobs:explosion(pos, radius, fire, smoke, sound) max_hear_distance = 16 }) end - -- if area protected then no blast damage - if minetest.is_protected(pos, "") then + -- if area protected or at map limits then no blast damage + if minetest.is_protected(pos, "") + or not within_limits(pos, radius) then return end for z = -radius, radius do @@ -1481,11 +1483,15 @@ function mobs:register_arrow(name, def) on_step = function(self, dtime) self.timer = (self.timer or 0) + 1 - if self.timer > 150 then self.object:remove() return end + local pos = self.object:getpos() + if self.timer > 150 + or not within_limits(pos, 0) then + self.object:remove() + return + end local engage = 10 - (self.velocity / 2) -- clear entity before arrow becomes active - local pos = self.object:getpos() - local node = minetest.get_node_or_nil(self.object:getpos()) + local node = minetest.get_node_or_nil(pos) if node then node = node.name else node = "air" end if self.hit_node @@ -1537,7 +1543,7 @@ function mobs:register_egg(mob, desc, background, addegg) inventory_image = invimg, on_place = function(itemstack, placer, pointed_thing) local pos = pointed_thing.above - if pointed_thing.above + if pos and within_limits(pos, 0) and not minetest.is_protected(pos, placer:get_player_name()) then pos.y = pos.y + 0.5 local mob = minetest.add_entity(pos, mob) @@ -1632,7 +1638,7 @@ function follow_holding(self, clicker) end -- feeding, taming and breeding (thanks blert2112) -function mobs:feed_tame(self, clicker, feed_count, breed) +function mobs:feed_tame(self, clicker, feed_count, breed, tame) if not self.follow then return false end @@ -1640,7 +1646,7 @@ function mobs:feed_tame(self, clicker, feed_count, breed) -- can eat/tame with item in hand if follow_holding(self, clicker) then ---print ("mmm, tasty") + -- take item if not minetest.setting_getbool("creative_mode") then item:take_item() @@ -1649,9 +1655,17 @@ function mobs:feed_tame(self, clicker, feed_count, breed) -- heal health local hp = self.object:get_hp() - hp = math.min(hp + 4, self.hp_max) - self.object:set_hp(hp) - self.health = hp + --if hp < self.hp_max then + hp = hp + 4 + if hp >= self.hp_max then + hp = self.hp_max + minetest.chat_send_player(clicker:get_player_name(), + self.name:split(":")[2] + .. " at full health") + end + self.object:set_hp(hp) + self.health = hp + --end -- make children grow quicker if self.child == true then @@ -1667,9 +1681,11 @@ function mobs:feed_tame(self, clicker, feed_count, breed) self.horny = true end self.gotten = false - self.tamed = true - if not self.owner or self.owner == "" then - self.owner = clicker:get_player_name() + if tame then + self.tamed = true + if not self.owner or self.owner == "" then + self.owner = clicker:get_player_name() + end end -- make sound when fed so many times @@ -1685,3 +1701,17 @@ function mobs:feed_tame(self, clicker, feed_count, breed) return false end end + +-- check if within map limits (-30911 to 30927) +function within_limits(pos, radius) + if (pos.x - radius) > -30913 + and (pos.x + radius) < 30928 + and (pos.y - radius) > -30913 + and (pos.y + radius) < 30928 + and (pos.z - radius) > -30913 + and (pos.z + radius) < 30928 then + return true -- within limits + end + return false -- beyond limits +end + diff --git a/mods/mobs/dungeonmaster.lua b/mods/mobs/dungeonmaster.lua index 9ba30085..693a346d 100755 --- a/mods/mobs/dungeonmaster.lua +++ b/mods/mobs/dungeonmaster.lua @@ -81,17 +81,17 @@ mobs:register_arrow("mobs:fireball", { -- direct hit, no fire... just plenty of pain hit_player = function(self, player) - player:punch(self.object, 1.0, { + player:punch(self.object, 1.0, { full_punch_interval = 1.0, damage_groups = {fleshy = 12}, - }, 0) + }, nil) end, hit_mob = function(self, player) - player:punch(self.object, 1.0, { + player:punch(self.object, 1.0, { full_punch_interval = 1.0, damage_groups = {fleshy = 12}, - }, 0) + }, nil) end, -- node hit, bursts into flame (cannot blast through obsidian or protection redo mod items) diff --git a/mods/mobs/mese_monster.lua b/mods/mobs/mese_monster.lua index 8795105f..090f8190 100755 --- a/mods/mobs/mese_monster.lua +++ b/mods/mobs/mese_monster.lua @@ -54,11 +54,16 @@ mobs:register_mob("mobs:mese_monster", { light_damage = 0, -- model animation animation = { - speed_normal = 15, speed_run = 15, - stand_start = 0, stand_end = 14, - walk_start = 15, walk_end = 38, - run_start = 40, run_end = 63, - punch_start = 15, punch_end = 38, -- was 40 & 63 + speed_normal = 15, + speed_run = 15, + stand_start = 0, + stand_end = 14, + walk_start = 15, + walk_end = 38, + run_start = 40, + run_end = 63, + punch_start = 40, + punch_end = 63, }, }) -- spawn on stone between 20 and -1 light, 1 in 7000 chance, 1 in area below -25 @@ -77,14 +82,14 @@ mobs:register_arrow("mobs:mese_arrow", { player:punch(self.object, 1.0, { full_punch_interval = 1.0, damage_groups = {fleshy = 8}, --Modif MFF - }, 0) + }, nil) end, hit_mob = function(self, player) player:punch(self.object, 1.0, { full_punch_interval = 1.0, damage_groups = {fleshy = 8}, --Modif MFF - }, 0) + }, nil) end, hit_node = function(self, pos, node) diff --git a/mods/mobs/models/character.b3d b/mods/mobs/models/character.b3d index bc9d92735aa6bf688cfb55e4d552c347f453f3fe..5ea45e0a79cbd972026ae23534bf584e1716c2eb 100755 GIT binary patch delta 30 kcmaE`jP=1XRskm`W0#0vMg~R(28IYAXcX8gz!(q=0FQnMDF6Tf delta 30 lcmaE`jP=1XRskm`W0#0vMg~R(28IyVh~P$ntpbbz!2phI2n_%L diff --git a/mods/mobs/models/mobs_dungeon_master.b3d b/mods/mobs/models/mobs_dungeon_master.b3d index f6045b50acfbaaec4e719eb64dc1fd1504364c5b..f45e76099f1711846a9967d812e2346a4ba10310 100755 GIT binary patch delta 27 hcmdmZmT}`*Mgb=$W0#d_3=E763=9!Kuu))P8UTD`2toh= delta 27 jcmdmZmT}`*Mgb=$W0#d_3=E763=AQz5y2Y;7N!9Jd!`5` diff --git a/mods/mobs/models/mobs_kitten.b3d b/mods/mobs/models/mobs_kitten.b3d index baaa3a79f7f7d0525aa6782d189babf0372bff3b..c2478fefd8e3c8da60b9d71ba38e1f238799ae9f 100755 GIT binary patch delta 30 kcmZqp&)V>xRlv!~*rlSLk%5tcfgu728U?lrFc#DU0FxmIvj6}9 delta 30 lcmZqp&)V>xRlv!~*rlSLk%5tcfg!{-BDhgts{ms`Jphsq2$ui= diff --git a/mods/mobs/models/mobs_oerkki.b3d b/mods/mobs/models/mobs_oerkki.b3d index dcd1ef9c1eb8d8ec8fd4c6486f779f16b3ce987d..6290af38b43133f638ad787af1663013e015ac64 100755 GIT binary patch delta 27 hcmZ2_l4;SL2#5dx delta 27 jcmZ2_l4wL~x_PRslxVqX2qt2ax~( diff --git a/mods/mobs/models/mobs_sheep.b3d b/mods/mobs/models/mobs_sheep.b3d index fa4173dc7a89405fd8324db5c3dfa1368a038b82..bcf2dfc5cc0899c4d0eac4715919a9b45e7f8234 100755 GIT binary patch delta 30 kcmaF6mgVhQ76B(GW0$95j0}tn3=9!K&?vA~fbp&v0Ghc7?*IS* delta 30 mcmaF6mgVhQ76B(GW0$95j0}tn3=AQz5y6cDTLl>JiU9zbrwG#k diff --git a/mods/mobs/models/mobs_sheep_shaved.b3d b/mods/mobs/models/mobs_sheep_shaved.b3d index 0c17676042975011169ebeb977a599b9807d407b..857b406ae80db976d2e53b4251139cd79ed4d5bd 100755 GIT binary patch delta 27 hcmeyfh564GW&tNBW0#U!3=E763=9!Kuu&lA766KH2`B&n delta 27 jcmeyfh564GW&tNBW0#U!3=E763=AQz5y2Y;a&7?tiLwa{ diff --git a/mods/mobs/models/mobs_stone_monster.b3d b/mods/mobs/models/mobs_stone_monster.b3d index 0dec5b86dcdcd6dcda80058d0a6b5aeb6353b4ff..d9c0c717c4050482181946154785dcdf103844a4 100755 GIT binary patch delta 27 hcmX@}lJU$-Mgb=$W0xZ(3=E763=9!Kuu))72>^-b2?78B delta 27 jcmX@}lJU$-Mgb=$W0xZ(3=E763=AQz5y2Y;_LKksi75!? diff --git a/mods/mobs/models/mobs_tree_monster.b3d b/mods/mobs/models/mobs_tree_monster.b3d index 2b5d881acf6e1d7c6df345ed7400204c5e02a84f..1625b37c2ba71eb463c2d974b31847bbadc0c5c6 100755 GIT binary patch delta 27 hcmdlrk$KldW&tNBW0y@Q7#J8C7#JdeV57jQ699SB2(|zK delta 27 jcmdlrk$KldW&tNBW0y@Q7#J8C7#KoaBZ4;ytU3Vzc@+qn