Add strength elixirs.
This commit is contained in:
parent
dd81a5777a
commit
b6e66def05
10 changed files with 98 additions and 11 deletions
18
abms.lua
18
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
|
||||
|
|
69
elixir.lua
69
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
|
||||
|
|
12
init.lua
12
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")
|
||||
|
||||
|
|
10
mobs.lua
10
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)
|
||||
|
|
BIN
textures/fun_caves_elixir_strength_boar.png
Normal file
BIN
textures/fun_caves_elixir_strength_boar.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.3 KiB |
BIN
textures/fun_caves_elixir_strength_bull.png
Normal file
BIN
textures/fun_caves_elixir_strength_bull.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.3 KiB |
BIN
textures/fun_caves_elixir_strength_elephant.png
Normal file
BIN
textures/fun_caves_elixir_strength_elephant.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.3 KiB |
BIN
textures/fun_caves_elixir_strength_grizzly.png
Normal file
BIN
textures/fun_caves_elixir_strength_grizzly.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.3 KiB |
BIN
textures/fun_caves_elixir_strength_lion.png
Normal file
BIN
textures/fun_caves_elixir_strength_lion.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.3 KiB |
BIN
textures/fun_caves_elixir_strength_rhino.png
Normal file
BIN
textures/fun_caves_elixir_strength_rhino.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.3 KiB |
Loading…
Add table
Add a link
Reference in a new issue