]> git.lizzy.rs Git - Crafter.git/commitdiff
Add player node suffocation
authoroilboi <47129783+oilboi@users.noreply.github.com>
Sat, 25 Apr 2020 15:30:47 +0000 (11:30 -0400)
committeroilboi <47129783+oilboi@users.noreply.github.com>
Sat, 25 Apr 2020 15:30:47 +0000 (11:30 -0400)
README.md
mods/new_functions/init.lua

index a11da74fa52c6fc9c4350bf1d4c7782811081b01..a330da7018da910f1ee879083c4b8b870dd2b445 100644 (file)
--- a/README.md
+++ b/README.md
@@ -39,6 +39,8 @@ enable_mod_channels = true
 - Make flying pigs drop 1-6 gold
 - Make mobs use builtin minetest.throw_item function (custom)
 - Double flying pigs sight radius
+- Add hurt_inside group
+- Add lava and fire to hurt_inside group
 ---
 
 
index ca5b5e2f65e9537c911ab8e6e577e614cc9d5fb5..412bd1245c80813b1b884d3748de254e5c30594e 100644 (file)
@@ -74,19 +74,7 @@ local function handle_hurt(player)
 end
 
 --handle inside hurt
-local temp_hurt
-
-local xcompare
-local ycompare
-local zcompare
-
 local c_player
-
-local subval = vector.subtract
-
-local abs_it = math.abs
-local floor_it = math.floor
-
 local heart
 local legs
 local head
@@ -112,6 +100,33 @@ local function handle_hurt_inside(player)
        return(false)
 end
 
+--handle player suffocating inside solid node
+local c_player
+local heart
+local legs
+local head
+local hurt_more
+local drawy
+
+local function handle_player_suffocation(player)
+       if player:get_hp() > 0 then
+               player_pos = player:get_pos()
+               name = player:get_player_name()
+               head = player_surroundings_index_table[name].head
+               if head then
+                       drawy = registered_nodes[head].drawtype
+
+                       if drawy == "normal" then
+                               heart = player:get_hp()
+                               player:set_hp(heart - 1)
+                               return(true)
+                       end
+               end
+       end
+       return(false)
+end
+
+
 --index specific things in area
 --declare here for ultra extreme efficiency
 local get_node = minetest.get_node
@@ -147,7 +162,7 @@ local function index_players_surroundings()
                        pos.y = pos.y + 0.940
                        player_surroundings_index_table[name].head = get_node(pos).name
                        
-
+                       handle_player_suffocation(player)
                        handle_hurt_inside(player)
 
                        --used for finding a damage node next to the player (centered at player's waist)