diff --git a/abms.lua b/abms.lua index a93208f..b800d89 100644 --- a/abms.lua +++ b/abms.lua @@ -192,30 +192,26 @@ minetest.register_globalstep(function(dtime) -- Remove status effects. local status = fun_caves.db.status[player_name] - for name, stat in pairs(status) do - local def = fun_caves.registered_status[name] + for status_name, status_param in pairs(status) do + local def = fun_caves.registered_status[status_name] if not def then - print('Fun Caves: Error - unregistered status ' .. name) + print('Fun Caves: Error - unregistered status ' .. status_name) break end local remove - if type(stat.remove) == 'number' then - if stat.remove < time then + if type(status_param.remove) == 'number' then + if status_param.remove < time then remove = true end elseif def.remove then remove = def.remove(player) else - print('Fun Caves: Error in status remove for ' .. name) + print('Fun Caves: Error in status remove for ' .. status_name) end if remove then - if def and def.terminate then - fun_caves.db.status[player_name][name] = def.terminate(player) - else - fun_caves.db.status[player_name][name] = nil - end + fun_caves.remove_status(player_name, status_name) elseif def.during then def.during(player) end diff --git a/elixir.lua b/elixir.lua index 3450979..b3e976f 100644 --- a/elixir.lua +++ b/elixir.lua @@ -204,6 +204,16 @@ minetest.register_craft({ }) +fun_caves.register_status({ + name = 'damage_elixir', + terminate = function(player) + local player_name = player:get_player_name() + minetest.chat_send_player(player_name, minetest.colorize('#FF0000', 'You feel weaker...')) + fun_caves.db.status[player_name].damage_elixir = nil + end, +}) + + fun_caves.register_status({ name = 'armor_elixir', terminate = function(player) @@ -235,6 +245,14 @@ if fun_caves.expire_elixir_on_death then end +local function increase_damage(user, bonus) + local player_name = user:get_player_name() + + minetest.chat_send_player(player_name, 'You feel strong...') + fun_caves.set_status(player_name, 'damage_elixir', elixir_duration, {bonus = bonus}) +end + + local function armor(user, factor) local player_name = user:get_player_name() local armor = user:get_armor_groups() @@ -305,3 +323,54 @@ if fun_caves.elixir_armor then }) end end + + +local descs = { + {'boar', 2, 'fun_caves:meteorite'}, + {'lion', 4, 'fun_caves:eternal_ice_crystal'}, + {'grizzly', 6}, + {'bull', 8}, + {'rhino', 10}, + {'elephant', 12}, +} + +for _, desc in pairs(descs) do + local name = desc[1] + local uname = name:gsub("(%l)(%w*)", function(a,b) return string.upper(a)..b end) + local bonus = desc[2] + minetest.register_craftitem("fun_caves:elixir_strength_"..name, { + description = 'Dr Robertson\'s Patented '..uname..' Strength Elixir', + drawtype = "plantlike", + paramtype = "light", + tiles = {'fun_caves_elixir_strength_'..name..'.png'}, + inventory_image = 'fun_caves_elixir_strength_'..name..'.png', + groups = {dig_immediate = 3, vessel = 1}, + sounds = default.node_sound_glass_defaults(), + on_use = function(itemstack, user, pointed_thing) + increase_damage(user, bonus) + itemstack:take_item() + return itemstack + end, + }) + + if desc[3] then + minetest.register_craft({ + type = "shapeless", + output = 'fun_caves:elixir_strength_'..name, + recipe = { + 'mobs_slimes:green_slimeball', + desc[3], + "vessels:glass_bottle", + }, + }) + + minetest.register_craft({ + type = "shapeless", + output = 'fun_caves:elixir_strength_'..name, + recipe = { + 'fun_caves:syrup', + desc[3], + }, + }) + end +end diff --git a/init.lua b/init.lua index df6c48d..ede0562 100644 --- a/init.lua +++ b/init.lua @@ -148,6 +148,18 @@ function fun_caves.set_status(player_name, status, time, param) end end +function fun_caves.remove_status(player_name, status) + local player = minetest.get_player_by_name(player_name) + local def = fun_caves.registered_status[status] + if player and def then + if def.terminate then + fun_caves.db.status[player_name][status] = def.terminate(player) + else + fun_caves.db.status[player_name][status] = nil + end + end +end + --dofile(fun_caves.path .. "/recipe_list.lua") diff --git a/mobs.lua b/mobs.lua index ec762fa..62af420 100644 --- a/mobs.lua +++ b/mobs.lua @@ -155,8 +155,18 @@ for _, mob in pairs(mob_stats) do end end +local function fun_caves_punch(self, puncher, time_from_last_punch, tool_capabilities, dir) + local player_name = puncher:get_player_name() + if fun_caves.db.status[player_name].damage_elixir then + tool_capabilities.damage_groups.fleshy = tool_capabilities.damage_groups.fleshy + fun_caves.db.status[player_name].damage_elixir.bonus + end + self.on_punch_orig(self, puncher, time_from_last_punch, tool_capabilities, dir) +end + for _, mob in pairs(mob_stats) do if minetest.registered_entities[mob.name] then + minetest.registered_entities[mob.name].on_punch_orig = minetest.registered_entities[mob.name].on_punch + minetest.registered_entities[mob.name].on_punch = fun_caves_punch minetest.registered_entities[mob.name].damage = mob.damage minetest.registered_entities[mob.name].hp_min = math.ceil(mob.hp * 0.5) minetest.registered_entities[mob.name].hp_max = math.ceil(mob.hp * 1.5) diff --git a/textures/fun_caves_elixir_strength_boar.png b/textures/fun_caves_elixir_strength_boar.png new file mode 100644 index 0000000..1b5132a Binary files /dev/null and b/textures/fun_caves_elixir_strength_boar.png differ diff --git a/textures/fun_caves_elixir_strength_bull.png b/textures/fun_caves_elixir_strength_bull.png new file mode 100644 index 0000000..aa7ee0f Binary files /dev/null and b/textures/fun_caves_elixir_strength_bull.png differ diff --git a/textures/fun_caves_elixir_strength_elephant.png b/textures/fun_caves_elixir_strength_elephant.png new file mode 100644 index 0000000..7841f8c Binary files /dev/null and b/textures/fun_caves_elixir_strength_elephant.png differ diff --git a/textures/fun_caves_elixir_strength_grizzly.png b/textures/fun_caves_elixir_strength_grizzly.png new file mode 100644 index 0000000..2edc302 Binary files /dev/null and b/textures/fun_caves_elixir_strength_grizzly.png differ diff --git a/textures/fun_caves_elixir_strength_lion.png b/textures/fun_caves_elixir_strength_lion.png new file mode 100644 index 0000000..871dbb8 Binary files /dev/null and b/textures/fun_caves_elixir_strength_lion.png differ diff --git a/textures/fun_caves_elixir_strength_rhino.png b/textures/fun_caves_elixir_strength_rhino.png new file mode 100644 index 0000000..acf8c5a Binary files /dev/null and b/textures/fun_caves_elixir_strength_rhino.png differ