diff --git a/goblin_ice.lua b/goblin_ice.lua new file mode 100644 index 0000000..36e784e --- /dev/null +++ b/goblin_ice.lua @@ -0,0 +1,143 @@ + + +mobs:register_mob("fun_caves:goblin_ice", { + description = "Ice Goblin", + type = "animal", + passive = false, + damage = 1, + attack_type = "dogfight", + attacks_monsters = true, + hp_min = 5, + hp_max = 10, + armor = 100, + collisionbox = {-0.35,-1,-0.35, 0.35,-.1,0.35}, + visual = "mesh", + mesh = "goblins_goblin.b3d", + drawtype = "front", + textures = { + {"fun_caves_goblin_ice2.png"}, + }, + makes_footstep_sound = true, + sounds = { + random = "goblins_goblin_ambient", + warcry = "goblins_goblin_attack", + attack = "goblins_goblin_attack", + damage = "goblins_goblin_damage", + death = "goblins_goblin_death", + distance = 15, + }, + walk_velocity = 2, + run_velocity = 3, + jump = true, + drops = { + {name = "default:coal_lump", + chance = 1, min = 1, max = 3}, + {name = "fun_caves:mushroom_steak", + chance = 2, min = 1, max = 2}, + {name = "default:torch", + chance = 3, min = 1, max = 10}, + }, + water_damage = 0, + lava_damage = 4, + cold_damage = 0, + light_damage = 0, + follow = {"default:diamond"}, + view_range = 10, + owner = "", + order = "follow", + animation = { + speed_normal = 30, + speed_run = 30, + stand_start = 0, + stand_end = 79, + walk_start = 168, + walk_end = 187, + run_start = 168, + run_end = 187, + punch_start = 200, + punch_end = 219, + }, + on_rightclick = function(self, clicker) + local item = clicker:get_wielded_item() + local name = clicker:get_player_name() + + -- feed to heal goblin + if item:get_name() == "fun_caves:mushroom_steak" + or item:get_name() == "farming:bread" then + + local hp = self.object:get_hp() + -- return if full health + if hp >= self.hp_max then + minetest.chat_send_player(name, "goblin at full health.") + return + end + hp = hp + 4 + if hp > self.hp_max then hp = self.hp_max end + self.object:set_hp(hp) + -- take item + if not minetest.setting_getbool("creative_mode") then + item:take_item() + clicker:set_wielded_item(item) + end + + -- right clicking with gold lump drops random item from fun_caves.goblin_drops + elseif item:get_name() == "default:gold_lump" then + if not minetest.setting_getbool("creative_mode") then + item:take_item() + clicker:set_wielded_item(item) + end + local pos = self.object:getpos() + pos.y = pos.y + 0.5 + minetest.add_item(pos, {name = fun_caves.goblin_drops[math.random(1, #fun_caves.goblin_drops)]}) + + else + -- if owner switch between follow and stand + if self.owner and self.owner == clicker:get_player_name() then + if self.order == "follow" then + self.order = "stand" + else + self.order = "follow" + end +-- else +-- self.owner = clicker:get_player_name() + end + end + + mobs:capture_mob(self, clicker, 0, 5, 80, false, nil) + end, + + do_custom = function(self) + fun_caves.search_replace(self.object:getpos(), 5, {"default:torch"}, "air") + --fun_caves.search_replace(self.object:getpos(), 20, {"default:stone"}, "default:mossycobble") + fun_caves.search_replace(self.object:getpos(), 50, {"default:ice"}, "fun_caves:ice_trap") + end, + +}) +mobs:register_egg("fun_caves:goblin_ice", "Goblin Egg (ice)", "default_mossycobble.png", 1) +mobs:register_spawn("fun_caves:goblin_ice", {"default:ice"}, 100, 0, 5 * fun_caves.goblin_spawn_frequency, 3, 31000) + +minetest.register_node("fun_caves:ice_trap", { + description = "Ice Trap", + tiles = {"default_ice.png^default_mineral_coal.png"}, + groups = {cracky = 3}, + drop = 'default:ice', + is_ground_content = false, + sounds = default.node_sound_stone_defaults(), +}) + +minetest.register_abm({ + nodenames = {"fun_caves:ice_trap"}, + interval = 1, + chance = 1, + action = function(pos, node, active_object_count, active_object_count_wider) + for _,object in ipairs(minetest.env:get_objects_inside_radius(pos, 2)) do + if object:is_player() then + minetest.set_node(pos, {name="fire:basic_flame"}) + if object:get_hp() > 0 then + object:set_hp(object:get_hp()-2) + end + end + end + end +}) + diff --git a/mapgen.lua b/mapgen.lua index c74b5e3..8bcfb61 100644 --- a/mapgen.lua +++ b/mapgen.lua @@ -298,7 +298,7 @@ function fun_caves.generate(p_minp, p_maxp, seed) local sr = math.random(1,1000) -- fluids - if (data[ivm_below] == node("default:stone") or data[ivm_below] == node("fun_caves:hot_cobble")) and sr < 10 then + if (data[ivm_below] == node("default:stone") or data[ivm_below] == node("fun_caves:hot_cobble")) and sr < 20 then data[ivm] = node("default:lava_source") elseif data[ivm_below] == node("fun_caves:stone_with_moss") and sr < 5 then data[ivm] = node("default:water_source") diff --git a/mobs.lua b/mobs.lua index fcbdd6d..a7002ce 100644 --- a/mobs.lua +++ b/mobs.lua @@ -36,6 +36,7 @@ fun_caves.goblin_drops = { "default:pick_steel", "default:sword_steel", "defaul dofile(fun_caves.path.."/goblin_cobbler.lua") dofile(fun_caves.path.."/goblin_digger.lua") dofile(fun_caves.path.."/goblin_coal.lua") +dofile(fun_caves.path.."/goblin_ice.lua") dofile(fun_caves.path.."/goblin_copper.lua") dofile(fun_caves.path.."/goblin_iron.lua") dofile(fun_caves.path.."/goblin_gold.lua") diff --git a/nodes.lua b/nodes.lua index c8f9f48..446b9d3 100644 --- a/nodes.lua +++ b/nodes.lua @@ -416,37 +416,28 @@ minetest.register_node("fun_caves:hot_cobble", { local last_dps_check = 0 minetest.register_globalstep(function(dtime) - if last_dps_check < 20 then - last_dps_check = last_dps_check + 1 - else + last_dps_check = last_dps_check + 1 + if last_dps_check > 20000 then last_dps_check = 0 + end + + if last_dps_check % 20 == 0 then for id, player in pairs(minetest.get_connected_players()) do local minp = vector.subtract(player:getpos(), 0.5) local maxp = vector.add(player:getpos(), 0.5) - local counts = minetest.find_nodes_in_area(minp, maxp, {"group:surface_hot", "group:surface_cold"}) - if #counts > 3 then + + local counts = minetest.find_nodes_in_area(minp, maxp, {"group:surface_hot"}) + if #counts > 1 then player:set_hp(player:get_hp() - 1) end - end - -- This just won't work. - -- - --for id, ent in pairs(minetest.luaentities) do - -- if ent.object and not string.find(ent.name, "__built") then - -- local minp = vector.subtract(ent.object:getpos(), 1) - -- local maxp = vector.add(ent.object:getpos(), 1) - -- local counts = minetest.find_nodes_in_area(minp, maxp, {"group:hot"}) - -- if #counts > 3 then - -- ent.object:set_hp(ent.object:get_hp() - 1) - -- ent.old_health = ent.health - -- ent.health = ent.health - 1 - -- print(ent.name.." suffers, "..ent.object:get_hp().."/"..ent.health.." left") - -- --if ent.object:get_hp() < 1 then - -- -- print(dump(ent)) - -- --end - -- end - -- end - --end + if last_dps_check % 200 == 0 then + local counts = minetest.find_nodes_in_area(minp, maxp, {"group:surface_cold"}) + if #counts > 1 then + player:set_hp(player:get_hp() - 1) + end + end + end end end) diff --git a/textures/fun_caves_goblin_ice2.png b/textures/fun_caves_goblin_ice2.png new file mode 100644 index 0000000..9fa83a0 Binary files /dev/null and b/textures/fun_caves_goblin_ice2.png differ