1
0
Fork 0

add "all" to immune_to table, optimized floating code

This commit is contained in:
TenPlus1 2018-05-30 10:55:39 +01:00 committed by bakawun
parent 4cf865a36c
commit 55813c153f
4 changed files with 26 additions and 11 deletions

View File

@ -139,6 +139,7 @@ functions needed for the mob to work properly which contains the following:
{"default:sword_wood",0} -- causes no damage.
{"default:gold_lump", -10} -- heals by 10 health points.
{"default:coal_block", 20} -- 20 damage when hit on head with coal blocks.
{"all"} -- stops all weapons causing damage apart from those on list.
'makes_footstep_sound' when true you can hear mobs walking.
'sounds' this is a table with sounds of the mob

View File

@ -614,6 +614,9 @@ function mob_class:on_punch(hitter, tflp, tool_capabilities, dir)
damage = self.immune_to[n][2] or 0
break
-- if "all" then no tool does damage unless it's specified in list
elseif self.immune_to[n][1] == "all" then
damage = self.immune_to[n][2] or 0
end
end

View File

@ -387,8 +387,7 @@ end
-- are we flying in what we are suppose to? (taikedz)
function mob_class:flight_check()
local nod = self.standing_in
local def = minetest.registered_nodes[nod]
local def = minetest.registered_nodes[self.standing_in]
if not def then return false end -- nil check
@ -402,7 +401,7 @@ function mob_class:flight_check()
end
for _,checknode in pairs(fly_in) do
if nod == checknode or nod == "ignore" then
if self.standing_in == checknode or self.standing_in == "ignore" then
return true
end
end
@ -664,16 +663,27 @@ function mob_class:do_env_damage()
end
local y_level = self.collisionbox[2]
-- get node at foot level every quarter second
self.node_timer = (self.node_timer or 0) + dtime
if self.child then
y_level = self.collisionbox[2] * 0.5
if self.node_timer > 0.25 then
self.node_timer = 0
local y_level = self.collisionbox[2]
if self.child then
y_level = self.collis77ionbox[2] * 0.5
end
-- what is mob standing in?
self.standing_in = node_ok({
x = pos.x, y = pos.y + y_level + 0.25, z = pos.z}, "air").name
-- print ("standing in " .. self.standing_in)
end
-- what is mob standing in?
pos.y = pos.y + y_level + 0.25 -- foot level
-- check if falling, flying, floating
local pos2 = {x=pos.x, y=pos.y-1, z=pos.z}
self.standing_in = node_ok(pos, "air").name
self.standing_on = node_ok(pos2, "air").name
local pos3 = vector.offset(pos, 0, 1, 0)
@ -937,7 +947,7 @@ function mob_class:falling(pos)
local acc = self.object:get_acceleration()
local registered_node = minetest.registered_nodes[node_ok(pos).name]
local registered_node = minetest.registered_nodes[self.standing_in]
if registered_node.groups.lava then
if acc and self.floats_on_lava == 1 then
@ -948,7 +958,7 @@ function mob_class:falling(pos)
-- in water then float up
if registered_node.groups.water then
if acc and self.floats == 1 and minetest.registered_nodes[node_ok(vector.offset(pos,0,self.collisionbox[5] -0.25,0)).name].groups.water then
self.object:set_acceleration(vector.new(0, -self.fall_speed / (math.max(1, v.y) ^ 2), 0))
self.object:set_acceleration(vector.new(0, -self.fall_speed / (math.max(1, v.y) ^ 8), 0))
end
else
-- fall damage onto solid ground

View File

@ -20,6 +20,7 @@ mcl_mobs_mob_poof.ogg:
------------
Changelog from original Mobs Redo mod:
- 1.42- Added "all" option to immune_to table, tidied floating mobs to be less intensive
- 1.41- Mob pathfinding has been updated thanks to Elkien3
- 1.40- Updated to use newer functions, requires Minetest 0.4.16+ to work.
- 1.39- Added 'on_breed', 'on_grown' and 'do_punch' custom functions per mob