]> git.lizzy.rs Git - Crafter.git/commitdiff
Make mobs get damaged in fire and lava
authoroilboi <47129783+oilboi@users.noreply.github.com>
Sat, 25 Apr 2020 16:15:06 +0000 (12:15 -0400)
committeroilboi <47129783+oilboi@users.noreply.github.com>
Sat, 25 Apr 2020 16:15:06 +0000 (12:15 -0400)
README.md
mods/mob/exploder/exploderinit.lua
mods/mob/exploder/interaction_code.lua
mods/mob/exploder/movement_code.lua
mods/mob/pig/interaction_code.lua
mods/mob/pig/movement_code.lua
mods/mob/pig/piginit.lua
mods/mob/slime/interaction_code.lua
mods/mob/slime/movement_code.lua
mods/mob/slime/slimeinit.lua

index a330da7018da910f1ee879083c4b8b870dd2b445..e4cbf78f940c2265b977bfb4e35262208d177658 100644 (file)
--- a/README.md
+++ b/README.md
@@ -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)
 
 
index abd9e312185ca243ccf34067eb17c0ec26707698..98934346d1edb3398dee133880c6dc705301f6e3 100644 (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
 
index f4cf0f7432401db89da8f112a77828ceeff2f8b5..50d17fa8c0f6d2e570d8bc7181ec532e052dd67a 100644 (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
index bbe6ca6467c3501701b2ecdee4ccf0b9613da634..d61dcfc764fa6a8cdb9b736d36cadaa2e0b7ab4b 100644 (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
index ee9175bab61cc56d0b2c1163d006c90e1acb2e58..5e4a5be8995450a00d71372ee0c1c5f5db684718 100644 (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
index 8df229c5510c9b4d1f666438f58dda2a018d8565..e673838ef9b0604b832d0d6d2bf50fbbab67c065 100644 (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
index 7f3a09621678425e4247a1cf42a031b2673a202c..7a8565dd9ce4d11da8926c9d27d5fe623b863748 100644 (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
 
index c72d727cb333e95ff5c660f0ed3d2f4b8f75139a..02e1b171b1c060a598fe70385d3655e843dcd84f 100644 (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
index ffa646506e13c13299a1cd0611e83cb0ff369f55..5e300d5773aeefdfc32bd185a97e562c1cadf979 100644 (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()
index 5f6eeeb965a83d5020223215d29f5921675c2a2a..f3918926b39b2bef3b0adac46fe4d4c810cd3fa7 100644 (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