Make mobs get damaged in fire and lava

This commit is contained in:
oilboi 2020-04-25 12:15:06 -04:00
parent e6a1bdca1f
commit 3afe1dabf8
10 changed files with 70 additions and 5 deletions

View File

@ -41,6 +41,7 @@ enable_mod_channels = true
- Double flying pigs sight radius
- Add hurt_inside group
- Add lava and fire to hurt_inside group
- Make mobs get damaged in fire and lava
---
@ -51,7 +52,6 @@ enable_mod_channels = true
## REDSTONE:
- breaker (mines whatever is in front of it)
- dispenser (shoots out first item in inventory, or shoots item into pipe)
- sticky piston (pulls node in front of it)
- piston in general (if node is falling and piston is pointing up then FLING IT, if detects falling node entity FLING IT)

View File

@ -23,6 +23,7 @@ exploder.hp = 10
exploder.speed = 5
exploder.jump_timer = 0
exploder.hurt_inside_timer = 0
exploder.death_animation_timer = 0
exploder.dead = false

View File

@ -61,7 +61,7 @@ exploder.on_punch = function(self, puncher, time_from_last_punch, tool_capabilit
local hp = hp-hurt
if (self.punched_timer <= 0 and hp > 1) or puncher == self.object then
if (self.punched_timer <= 0 and hp > 1) then
self.hostile = true
self.hostile_timer = 20
self.punched_timer = 0.8

View File

@ -21,6 +21,8 @@ exploder.move = function(self,dtime)
self.speed = math.random(0,6)
--self.object:set_yaw(yaw)
end
self.hurt_inside(self,dtime)
local currentvel = self.object:getvelocity()
local goal = vector.multiply(self.direction,self.speed)
@ -29,6 +31,25 @@ exploder.move = function(self,dtime)
self.object:add_velocity(acceleration)
end
local get_group = minetest.get_node_group
local get_node = minetest.get_node
exploder.hurt_inside = function(self,dtime)
if self.hp > 0 and self.hurt_inside_timer <= 0 then
local pos = self.object:getpos()
local hurty = get_group(get_node(pos).name, "hurt_inside")
if hurty > 0 then
self.object:punch(self.object, 2,
{
full_punch_interval=1.5,
damage_groups = {damage=hurty},
})
end
else
self.hurt_inside_timer = self.hurt_inside_timer - dtime
end
end
--use raycasting to jump
exploder.jump = function(self)
if self.jump_timer <= 0 then

View File

@ -61,7 +61,7 @@ pig.on_punch = function(self, puncher, time_from_last_punch, tool_capabilities,
local hp = hp-hurt
if (self.punched_timer <= 0 and hp > 1) or puncher == self.object then
if (self.punched_timer <= 0 and hp > 1) then
self.hostile = true
self.hostile_timer = 20
self.punched_timer = 0.8

View File

@ -22,6 +22,8 @@ pig.move = function(self,dtime)
--self.object:set_yaw(yaw)
end
self.hurt_inside(self,dtime)
local currentvel = self.object:getvelocity()
local goal = vector.multiply(self.direction,self.speed)
local acceleration = vector.new(goal.x-currentvel.x,0,goal.z-currentvel.z)
@ -29,6 +31,25 @@ pig.move = function(self,dtime)
self.object:add_velocity(acceleration)
end
local get_group = minetest.get_node_group
local get_node = minetest.get_node
pig.hurt_inside = function(self,dtime)
if self.hp > 0 and self.hurt_inside_timer <= 0 then
local pos = self.object:getpos()
local hurty = get_group(get_node(pos).name, "hurt_inside")
if hurty > 0 then
self.object:punch(self.object, 2,
{
full_punch_interval=1.5,
damage_groups = {damage=hurty},
})
end
else
self.hurt_inside_timer = self.hurt_inside_timer - dtime
end
end
--use raycasting to jump
pig.jump = function(self)
if self.jump_timer <= 0 then

View File

@ -22,6 +22,7 @@ pig.hp = 10
pig.speed = 5
pig.jump_timer = 0
pig.hurt_inside_timer = 0
pig.death_animation_timer = 0
pig.dead = false

View File

@ -61,7 +61,7 @@ slime.on_punch = function(self, puncher, time_from_last_punch, tool_capabilities
local hp = hp-hurt
if (self.punched_timer <= 0 and hp > 1) or puncher == self.object then
if (self.punched_timer <= 0 and hp > 1) then
self.hostile = true
self.hostile_timer = 20
self.punched_timer = 0.8

View File

@ -21,7 +21,8 @@ slime.move = function(self,dtime)
self.speed = math.random(0,6)
--self.object:set_yaw(yaw)
end
self.hurt_inside(self,dtime)
local currentvel = self.object:getvelocity()
if currentvel.y ~= 0 then
@ -32,6 +33,25 @@ slime.move = function(self,dtime)
end
end
local get_group = minetest.get_node_group
local get_node = minetest.get_node
slime.hurt_inside = function(self,dtime)
if self.hp > 0 and self.hurt_inside_timer <= 0 then
local pos = self.object:getpos()
local hurty = get_group(get_node(pos).name, "hurt_inside")
if hurty > 0 then
self.object:punch(self.object, 2,
{
full_punch_interval=1.5,
damage_groups = {damage=hurty},
})
end
else
self.hurt_inside_timer = self.hurt_inside_timer - dtime
end
end
--use raycasting to jump
slime.jump = function(self)
local vel = self.object:get_velocity()

View File

@ -22,6 +22,7 @@ slime.hp = 10
slime.speed = 5
slime.jump_timer = 0
slime.hurt_inside_timer = 0
slime.death_animation_timer = 0
slime.dead = false