Add strength potions
This commit is contained in:
parent
decf0ec624
commit
2c1b4e518c
|
@ -233,6 +233,27 @@ minetest.register_globalstep(function(dtime)
|
|||
|
||||
end
|
||||
|
||||
-- Check for Strong players
|
||||
for player, vals in pairs(is_strong) do
|
||||
|
||||
if is_strong[player] and player:get_properties() then
|
||||
|
||||
player = player or player:get_luaentity()
|
||||
|
||||
is_strong[player].timer = is_strong[player].timer + dtime
|
||||
|
||||
if player:get_pos() then mcl_potions._add_spawner(player, "#7700BB") end
|
||||
|
||||
if is_strong[player].timer >= is_strong[player].dur then
|
||||
is_strong[player] = nil
|
||||
end
|
||||
|
||||
elseif not player:get_properties() then
|
||||
is_strong[player] = nil
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end)
|
||||
|
||||
minetest.register_on_player_hpchange(function(player, hp_change)
|
||||
|
@ -240,6 +261,7 @@ minetest.register_on_player_hpchange(function(player, hp_change)
|
|||
if is_fire_proof[player] and hp_change < 0 then
|
||||
-- This is a bit forced, but it assumes damage is taken by fire and avoids it
|
||||
-- also assumes any change in hp happens between calls to this function
|
||||
-- it's worth noting that you don't take damage from players in this case...
|
||||
local player_info = mcl_playerinfo[player:get_player_name()]
|
||||
|
||||
if fire_nodes[player_info.node_head] or fire_nodes[player_info.node_feet] or fire_nodes[player_info.node_stand] then
|
||||
|
@ -487,6 +509,26 @@ function mcl_potions.weakness_func(player, factor, duration)
|
|||
for i=1,math.floor(duration) do
|
||||
minetest.after(i, function() mcl_potions._add_spawner(player, "#6600AA") end)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
function mcl_potions.strength_func(player, factor, duration)
|
||||
|
||||
if not is_strong[player] then
|
||||
|
||||
is_strong[player] = {dur = duration, timer = 0, factor = factor}
|
||||
|
||||
else
|
||||
|
||||
local victim = is_strong[player]
|
||||
|
||||
victim.factor = factor
|
||||
victim.dur = math.max(duration, victim.dur - victim.timer)
|
||||
victim.timer = 0
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
|
|
@ -307,7 +307,7 @@ local awkward_table = {
|
|||
["mcl_farming:carrot_item_gold"] = "mcl_potions:night_vision",
|
||||
["mcl_core:sugar"] = "mcl_potions:swiftness",
|
||||
["mcl_mobitems:magma_cream"] = "mcl_potions:fire_resistance",
|
||||
["mcl_mobitems:blaze_powder"] = "mcl_potions:strength", --add craft
|
||||
["mcl_mobitems:blaze_powder"] = "mcl_potions:strength",
|
||||
["mcl_fishing:pufferfish_raw"] = "mcl_potions:water_breathing",
|
||||
["mcl_mobitems:ghast_tear"] = "mcl_potions:regeneration",
|
||||
["mcl_mobitems:spider_eye"] = "mcl_potions:poison",
|
||||
|
@ -324,7 +324,7 @@ local output_table = {
|
|||
local enhancement_table = {}
|
||||
local extension_table = {}
|
||||
local potions = {"awkward", "mundane", "thick"}
|
||||
for i, potion in ipairs({"healing","harming","swiftness","slowness","leaping","poison","regeneration","invisibility","weakness","water_breathing","night_vision"}) do
|
||||
for i, potion in ipairs({"healing","harming","swiftness","slowness","leaping","poison","regeneration","invisibility","weakness","strength","water_breathing","night_vision"}) do
|
||||
|
||||
table.insert(potions, potion)
|
||||
|
||||
|
|
|
@ -235,3 +235,15 @@ register_lingering("weakness", "Lingering Weakness", "#6600AA", {
|
|||
register_lingering("weakness_plus", "Lingering Weakness +", "#7700BB", {
|
||||
potion_fun = function(player, redx) mcl_potions.weakness_func(player, -4, mcl_potions.DURATION_PLUS*mcl_potions.INV_FACTOR*0.25) end
|
||||
})
|
||||
|
||||
register_lingering("strength", "lingering Strength", "#D444D4", {
|
||||
potion_fun = function(player, redx) mcl_potions.strength_func(player, 3, mcl_potions.DURATION) end
|
||||
})
|
||||
|
||||
register_lingering("strength_2", "Lingering Strength II", "#D444F4", {
|
||||
potion_fun = function(player, redx) mcl_potions.strength_func(player, 6, smcl_potions.DURATION_2) end
|
||||
})
|
||||
|
||||
register_lingering("strength_plus", "Lingering Strength +", "#D444E4", {
|
||||
potion_fun = function(player, redx) mcl_potions.strength_func(player, 3, mcl_potions.DURATION_PLUS) end
|
||||
})
|
||||
|
|
|
@ -473,7 +473,77 @@ minetest.register_craftitem("mcl_potions:weakness_plus", {
|
|||
end
|
||||
})
|
||||
|
||||
minetest.register_craftitem("mcl_potions:strength", {
|
||||
description = S("Strength Potion"),
|
||||
_tt_help = S("+1.5 hearts per damage | 3:00"),
|
||||
_doc_items_longdesc = brewhelp,
|
||||
wield_image = potion_image("#D444D4"),
|
||||
inventory_image = potion_image("#D444D4"),
|
||||
groups = { brewitem=1, food=3, can_eat_when_full=1, not_in_creative_inventory=0 },
|
||||
stack_max = 1,
|
||||
|
||||
on_place = function(itemstack, user, pointed_thing)
|
||||
mcl_potions.weakness_func(user, 3, mcl_potions.DURATION)
|
||||
minetest.do_item_eat(0, "mcl_potions:glass_bottle", itemstack, user, pointed_thing)
|
||||
mcl_potions._use_potion(itemstack, user, "#D444D4")
|
||||
return itemstack
|
||||
end,
|
||||
|
||||
on_secondary_use = function(itemstack, user, pointed_thing)
|
||||
mcl_potions.weakness_func(user, 3, mcl_potions.DURATION)
|
||||
minetest.do_item_eat(0, "mcl_potions:glass_bottle", itemstack, user, pointed_thing)
|
||||
mcl_potions._use_potion(itemstack, user, "#D444D4")
|
||||
return itemstack
|
||||
end
|
||||
})
|
||||
|
||||
minetest.register_craftitem("mcl_potions:strength_2", {
|
||||
description = S("Strength Potion II"),
|
||||
_tt_help = S("+3 hearts per damage | 1:30"),
|
||||
_doc_items_longdesc = brewhelp,
|
||||
wield_image = potion_image("#D444E4"),
|
||||
inventory_image = potion_image("#D444E4"),
|
||||
groups = { brewitem=1, food=3, can_eat_when_full=1, not_in_creative_inventory=0 },
|
||||
stack_max = 1,
|
||||
|
||||
on_place = function(itemstack, user, pointed_thing)
|
||||
mcl_potions.weakness_func(user, 6, mcl_potions.DURATION_2)
|
||||
minetest.do_item_eat(0, "mcl_potions:glass_bottle", itemstack, user, pointed_thing)
|
||||
mcl_potions._use_potion(itemstack, user, "#D444E4")
|
||||
return itemstack
|
||||
end,
|
||||
|
||||
on_secondary_use = function(itemstack, user, pointed_thing)
|
||||
mcl_potions.weakness_func(user, 6, mcl_potions.DURATION_2)
|
||||
minetest.do_item_eat(0, "mcl_potions:glass_bottle", itemstack, user, pointed_thing)
|
||||
mcl_potions._use_potion(itemstack, user, "#D444E4")
|
||||
return itemstack
|
||||
end
|
||||
})
|
||||
|
||||
minetest.register_craftitem("mcl_potions:strength_plus", {
|
||||
description = S("Strength Potion +"),
|
||||
_tt_help = S("1.5 hearts per damage | 8:00"),
|
||||
_doc_items_longdesc = brewhelp,
|
||||
wield_image = potion_image("#D444F4"),
|
||||
inventory_image = potion_image("#D444F4"),
|
||||
groups = { brewitem=1, food=3, can_eat_when_full=1, not_in_creative_inventory=0 },
|
||||
stack_max = 1,
|
||||
|
||||
on_place = function(itemstack, user, pointed_thing)
|
||||
mcl_potions.weakness_func(user, 3, mcl_potions.DURATION_PLUS)
|
||||
minetest.do_item_eat(0, "mcl_potions:glass_bottle", itemstack, user, pointed_thing)
|
||||
mcl_potions._use_potion(itemstack, user, "#D444F4")
|
||||
return itemstack
|
||||
end,
|
||||
|
||||
on_secondary_use = function(itemstack, user, pointed_thing)
|
||||
mcl_potions.weakness_func(user, 3, mcl_potions.DURATION_PLUS)
|
||||
minetest.do_item_eat(0, "mcl_potions:glass_bottle", itemstack, user, pointed_thing)
|
||||
mcl_potions._use_potion(itemstack, user, "#D444F4")
|
||||
return itemstack
|
||||
end
|
||||
})
|
||||
minetest.register_craftitem("mcl_potions:poison", {
|
||||
description = S("Poison Potion"),
|
||||
_tt_help = S("-1/2 Heart / 2.5sec | 0:45"),
|
||||
|
|
|
@ -194,6 +194,18 @@ register_splash("weakness_plus", "Splash Weakness +", "#7700BB", {
|
|||
potion_fun = function(player, redx) mcl_potions.weakness_func(player, -4, splash_DUR_pl*mcl_potions.INV_FACTOR*redx) end
|
||||
})
|
||||
|
||||
register_splash("strength", "Splash Strength", "#D444D4", {
|
||||
potion_fun = function(player, redx) mcl_potions.strength_func(player, 3, splash_DUR*redx) end
|
||||
})
|
||||
|
||||
register_splash("strength_2", "Splash Strength II", "#D444F4", {
|
||||
potion_fun = function(player, redx) mcl_potions.strength_func(player, 6, splash_DUR_2*redx) end
|
||||
})
|
||||
|
||||
register_splash("strength_plus", "Splash Strength +", "#D444E4", {
|
||||
potion_fun = function(player, redx) mcl_potions.strength_func(player, 3, splash_DUR_pl*redx) end
|
||||
})
|
||||
|
||||
register_splash("water_breathing", "Splash Water Breathing", "#0000AA", {
|
||||
potion_fun = function(player, redx) mcl_potions.water_breathing_func(player, splash_DUR*redx) end
|
||||
})
|
||||
|
|
Loading…
Reference in New Issue
Block a user