1
0
mirror of https://codeberg.org/tenplus1/mobs_redo.git synced 2024-12-25 18:20:20 +01:00

added dtime to drive function

This commit is contained in:
TenPlus1 2016-12-29 15:28:53 +00:00
parent ef3217d77f
commit f7798e1b29
2 changed files with 30 additions and 5 deletions

View File

@ -281,7 +281,7 @@ This function will detach the player currently riding a mob to an offset positio
'offset' position table containing offset values 'offset' position table containing offset values
mobs:drive(self, move_animation, stand_animation, can_fly) mobs:drive(self, move_animation, stand_animation, can_fly, dtime)
This function allows an attached player to move the mob around and animate it at same time. This function allows an attached player to move the mob around and animate it at same time.
@ -289,6 +289,7 @@ This function allows an attached player to move the mob around and animate it at
'move_animation' string containing movement animation e.g. "walk" 'move_animation' string containing movement animation e.g. "walk"
'stand_animation' string containing standing animation e.g. "stand" 'stand_animation' string containing standing animation e.g. "stand"
'can_fly' if true then jump and sneak controls will allow mob to fly up and down 'can_fly' if true then jump and sneak controls will allow mob to fly up and down
'dtime' tick time used inside drive function
Certain variables need to be set before using the above functions: Certain variables need to be set before using the above functions:
@ -356,7 +357,7 @@ mobs:register_mob("mob_horse:horse", {
-- when riding mob call drive function to control -- when riding mob call drive function to control
if self.driver then if self.driver then
mobs.drive(self, "walk", "stand", false) mobs.drive(self, "walk", "stand", false, dtime)
return false -- skip rest of mob functions return false -- skip rest of mob functions
end end

View File

@ -18,6 +18,10 @@ local function node_is(pos)
return "air" return "air"
end end
if minetest.get_item_group(node.name, "lava") ~= 0 then
return "lava"
end
if minetest.get_item_group(node.name, "liquid") ~= 0 then if minetest.get_item_group(node.name, "liquid") ~= 0 then
return "liquid" return "liquid"
end end
@ -155,7 +159,7 @@ function mobs.detach(player, offset)
end end
function mobs.drive(entity, moving_anim, stand_anim, can_fly) function mobs.drive(entity, moving_anim, stand_anim, can_fly, dtime)
local rot_steer, rot_view = math.pi/2, 0 local rot_steer, rot_view = math.pi/2, 0
@ -283,7 +287,27 @@ function mobs.drive(entity, moving_anim, stand_anim, can_fly)
new_acce.y = 0 new_acce.y = 0
end end
elseif ni == "liquid" then elseif ni == "liquid" or ni == "lava" then
if ni == "lava" and entity.lava_damage ~= 0 then
entity.lava_counter = (entity.lava_counter or 0) + dtime
if entity.lava_counter > 1 then
minetest.sound_play("default_punch", {
object = entity.object,
max_hear_distance = 5
})
entity.object:punch(entity.object, 1.0, {
full_punch_interval = 1.0,
damage_groups = {fleshy = entity.lava_damage}
}, nil)
entity.lava_counter = 0
end
end
if entity.terrain_type == 2 if entity.terrain_type == 2
or entity.terrain_type == 3 then or entity.terrain_type == 3 then
@ -309,7 +333,7 @@ function mobs.drive(entity, moving_anim, stand_anim, can_fly)
end end
end end
else else
v = v*0.25 v = v * 0.25
end end
-- elseif ni == "walkable" then -- elseif ni == "walkable" then
-- v = 0 -- v = 0