Added water breathing brew to alchemy

This commit is contained in:
Billy S 2018-12-22 23:04:48 -05:00
parent 1a41115ce8
commit a2c9cad39d
7 changed files with 67 additions and 26 deletions

View File

@ -11,6 +11,7 @@ minetest.register_node("alchemy:beaker_empty", {
groups = {}, -- Unbreakable but picked up on punch - no particles groups = {}, -- Unbreakable but picked up on punch - no particles
paramtype = "light", paramtype = "light",
sunlight_propagates = true, sunlight_propagates = true,
inventory_image = "beaker_empty.png",
tiles = { tiles = {
"beaker.png" "beaker.png"

View File

@ -14,7 +14,10 @@ local function decrease_effect_timer()
alchemy.active_effects[p][e] = nil alchemy.active_effects[p][e] = nil
else else
if player then if player then
-- Update the HUD
alchemy.hud.update_effect(player, t.number, t) alchemy.hud.update_effect(player, t.number, t)
-- Run on_tick function
if t.on_tick then t.on_tick(player) end
end end
end end
end end
@ -30,7 +33,12 @@ local function register_effect(name, effect)
alchemy.effects["alchemy:beaker_" .. name] = effect alchemy.effects["alchemy:beaker_" .. name] = effect
end end
local function register_timed_effect(e, eName, time, on_start, on_end) local function register_timed_effect(e, def)
local eName = def.effect_name
local time = def.duration
local on_start = def.on_start
local on_tick = def.on_tick
local on_end = def.on_end
alchemy.effects["alchemy:beaker_" .. e] = function(p, pos) alchemy.effects["alchemy:beaker_" .. e] = function(p, pos)
local new_effect = false local new_effect = false
if on_start then if on_start then
@ -47,6 +55,7 @@ local function register_timed_effect(e, eName, time, on_start, on_end)
alchemy.active_effects[n][e].time = time alchemy.active_effects[n][e].time = time
new_effect = true new_effect = true
end end
alchemy.active_effects[n][e].on_tick = on_tick
alchemy.active_effects[n][e].on_end = on_end alchemy.active_effects[n][e].on_end = on_end
alchemy.active_effects[n][e].target = n alchemy.active_effects[n][e].target = n
alchemy.active_effects[n][e].name = eName alchemy.active_effects[n][e].name = eName
@ -85,7 +94,10 @@ register_effect("healing_brew", function(p, pos)
end) end)
-- Fire resistance -- Fire resistance
register_timed_effect("fire_resistance", "Fire Resistance", 30) register_timed_effect("fire_resistance", {
effect_name = "Fire Resistance",
duration = 30
})
minetest.register_on_player_hpchange(function(p, change) minetest.register_on_player_hpchange(function(p, change)
if change > 0 then return change end if change > 0 then return change end
local n = p:get_player_name() local n = p:get_player_name()
@ -116,34 +128,55 @@ minetest.register_on_player_hpchange(function(p, change)
end, true) end, true)
-- Jump brew -- Jump brew
register_timed_effect("jump_boost", "Jump Boost", 20, function(player, pos) register_timed_effect("jump_boost", {
effect_name = "Jump Boost",
duration = 20,
on_start = function(player, pos)
set_player_physics_multiplier(player, {jump = 2}, 20, "potions jump boost") set_player_physics_multiplier(player, {jump = 2}, 20, "potions jump boost")
end, end,
function(n) on_end = function(n)
local player = minetest.get_player_by_name(n) local player = minetest.get_player_by_name(n)
if player then if player then
remove_player_physics_multiplier(player, "potions jump boost") remove_player_physics_multiplier(player, "potions jump boost")
end end
end) end
})
-- Speed brew -- Speed brew
register_timed_effect("speed_boost", "Speed Boost", 120, function(player, pos) register_timed_effect("speed_boost", {
effect_name = "Speed Boost",
duration = 120,
on_start = function(player, pos)
set_player_physics_multiplier(player, {speed = 2}, 20, "potions speed boost") set_player_physics_multiplier(player, {speed = 2}, 20, "potions speed boost")
end, end,
function(n) on_end = function(n)
local player = minetest.get_player_by_name(n) local player = minetest.get_player_by_name(n)
if player then if player then
remove_player_physics_multiplier(player, "potions speed boost") remove_player_physics_multiplier(player, "potions speed boost")
end end
end) end
})
-- Invisibility potion -- Invisibility potion
register_timed_effect("invisibility_brew", "Invisibility", 20, function(player, pos) register_timed_effect("invisibility_brew", {
effect_name = "Invisibility",
duration = 20,
on_start = function(player, pos)
player:set_properties({visual_size = {x = 0, y = 0}}) player:set_properties({visual_size = {x = 0, y = 0}})
end, end,
function(n) on_end = function(n)
local player = minetest.get_player_by_name(n) local player = minetest.get_player_by_name(n)
if player then if player then
player:set_properties({visual_size = {x = 1, y = 1}}) player:set_properties({visual_size = {x = 1, y = 1}})
end end
end) end
})
-- Water-breathing potion
register_timed_effect("water_breathing_brew", {
effect_name = "Water Breathing",
duration = 120,
on_tick = function(player)
player:set_breath(20)
end
})

View File

@ -65,6 +65,7 @@ alchemy.register_basic_reactions = register_basic_reactions
register_basic_reactions("base", "default:mese_crystal", "energized_base", 1) register_basic_reactions("base", "default:mese_crystal", "energized_base", 1)
register_basic_reactions("energized_base", "alchemy:herb_glycon", "glycon_brew", 5) register_basic_reactions("energized_base", "alchemy:herb_glycon", "glycon_brew", 5)
register_basic_reactions("energized_base", "alchemy:herb_celros", "celros_brew", 8) register_basic_reactions("energized_base", "alchemy:herb_celros", "celros_brew", 8)
register_basic_reactions("energized_base", "alchemy:herb_firus", "firus_brew", 2)
register_basic_reactions("energized_base", "alchemy:herb_iceweed", "iceweed_brew", 2) register_basic_reactions("energized_base", "alchemy:herb_iceweed", "iceweed_brew", 2)
register_basic_reactions("energized_base", "alchemy:herb_shal_stalk", "shal_stalk_brew", 2) register_basic_reactions("energized_base", "alchemy:herb_shal_stalk", "shal_stalk_brew", 2)
@ -86,3 +87,6 @@ register_mix_reaction("boost", 1, "glycon_brew", "speed_boost")
-- Reaction for Invisibility brew -- Reaction for Invisibility brew
register_basic_reactions("mese", "alchemy:herb_parleaf", "invisibility_brew", 2) register_basic_reactions("mese", "alchemy:herb_parleaf", "invisibility_brew", 2)
-- Reaction for Water Breathing Brew
register_mix_reaction("firus_brew", 1, "iceweed_brew", "water_breathing_brew")

View File

@ -40,6 +40,8 @@ register_solution("energized_base", "Energized Base", "energized_base_solution.p
register_solution("glycon_brew", "Glycon Brew", "glycon_brew_solution.png") register_solution("glycon_brew", "Glycon Brew", "glycon_brew_solution.png")
-- Celros brew -- Celros brew
register_solution("celros_brew", "Celros Brew", "celros_brew_solution.png") register_solution("celros_brew", "Celros Brew", "celros_brew_solution.png")
-- Firus brew
register_solution("firus_brew", "Firus Brew", "firus_brew_solution.png")
-- Iceweed brew -- Iceweed brew
register_solution("iceweed_brew", "Iceweed Brew", "iceweed_brew_solution.png") register_solution("iceweed_brew", "Iceweed Brew", "iceweed_brew_solution.png")
-- Shal stalk brew -- Shal stalk brew
@ -58,3 +60,4 @@ register_solution("fire_resistance", "Fire Resistance", "fire_resistance_solutio
register_solution("jump_boost", "Jump Boost", "jump_boost_solution.png") register_solution("jump_boost", "Jump Boost", "jump_boost_solution.png")
register_solution("speed_boost", "Speed Boost", "speed_boost_solution.png") register_solution("speed_boost", "Speed Boost", "speed_boost_solution.png")
register_solution("invisibility_brew", "Invisibility Brew", "invisibility_brew_solution.png") register_solution("invisibility_brew", "Invisibility Brew", "invisibility_brew_solution.png")
register_solution("water_breathing_brew", "Water Breathing Brew", "water_breathing_brew_solution.png")

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 574 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB