Skip to content

Commit

Permalink
Bugfixes and improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
LoneWolfHT committed May 2, 2020
1 parent def6f36 commit ec0e571
Show file tree
Hide file tree
Showing 11 changed files with 65 additions and 27 deletions.
2 changes: 1 addition & 1 deletion mods/combat/swords/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ minetest.register_tool("swords:sword", {
description = "A basic sword",
inventory_image = "swords_sword.png",
groups = {sword = 1},
wield_scale = vector.new(1.5, 1.5, 1.5),
wield_scale = vector.new(2, 2.5, 1.5),
tool_capabilities = {
full_punch_interval = 1.5,
damage_groups = {fleshy = 2},
Expand Down
4 changes: 2 additions & 2 deletions mods/nodes/stations.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ minetest.register_node("nodes:anvil", {
tiles = {"nodes_iron.png"},
drawtype = "nodebox",
paramtype = "light",
groups = {unbreakable = 1, loadme = 1},
groups = {unbreakable = 1, loadme = 1, overrides_pointable = 1},
on_construct = function(pos)
local meta = minetest.get_meta(pos)

Expand All @@ -28,7 +28,7 @@ minetest.register_node("nodes:forge", {
tiles = {"nodes_iron.png"},
drawtype = "nodebox",
paramtype = "light",
groups = {unbreakable = 1, loadme = 1},
groups = {unbreakable = 1, loadme = 1, overrides_pointable = 1},
on_construct = function(pos)
local meta = minetest.get_meta(pos)

Expand Down
2 changes: 1 addition & 1 deletion mods/nodes/treasure_chests.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ function nodes.register_lootbox(name, def)
"nodes_chest_side.png", "nodes_chest_side.png",
"nodes_chest_back.png", "nodes_chest_front.png"
},
groups = {unbreakable = 1, loadme = 1, lootbox = 1},
groups = {unbreakable = 1, loadme = 1, lootbox = 1, overrides_pointable = 1},
paramtype = "light",
paramtype2 = "facedir",
on_construct = function(pos)
Expand Down
17 changes: 16 additions & 1 deletion mods/players/player/experience.lua
Original file line number Diff line number Diff line change
@@ -1,12 +1,24 @@
hb.register_hudbar("xp", 0xffffff, "XP", {bar = "xp.png"}, 0, 10, false, nil, nil)

local xp_huds = {}

minetest.register_on_joinplayer(function(player)
local meta = player:get_meta()

if meta:get_int("level") <= 0 then
meta:set_int("level", 1)
end

xp_huds[player:get_player_name()] = player:hud_add({
hud_elem_type = "text",
position = {x = 0.5, y = 1.0},
scale = {x = 100, y = 100},
text = ("Level %d"):format(meta:get_int("level")),
number = 0xffffff,
alignment = {x = 0, y = 1},
offset = {x = 0, y = -136},
})

hb.init_hudbar(player, "xp", meta:get_int("xp"), meta:get_int("level") * 50)
end)

Expand All @@ -18,10 +30,13 @@ function players.add_xp(player, xp)
new_xp = 0
meta:set_int("level", meta:get_int("level")+1)

player:hud_change(xp_huds[player:get_player_name()], "text", ("Level %d"):format(meta:get_int("level")))
meta:set_int("available_statpoints", meta:get_int("available_statpoints") + player_stats.statpoints_per_level)
players.hud_info_add(player, "Level up!")
else
players.hud_info_add(player, ("+%d XP"):format(xp))
end

meta:set_int("xp", new_xp)
hb.change_hudbar(player, "xp", new_xp, meta:get_int("level") * 50)
players.hud_info_add(player, ("+%d XP"):format(xp))
end
31 changes: 31 additions & 0 deletions mods/players/player/hp.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
minetest.register_on_joinplayer(function(player)
local max_hp = player:get_meta():get_int("max_hp")
local new_hp = player:get_hp()

if max_hp <= 20 then
max_hp = 35
new_hp = 50
end

players.set_max_hp(player, max_hp)
player:set_hp(new_hp, {reason = "Update player HP"})
end)

function players.set_max_hp(player, amount)
local meta = player:get_meta()
local stat_hp = meta:get_int("strength") * (meta:get_int("level") * 5)

player:set_properties({hp_max = amount + stat_hp})
hb.change_hudbar(player, "health", player:get_hp(), amount + stat_hp)
meta:set_int("max_hp", amount)
end

function players.update_max_hp(player)
local meta = player:get_meta()
local amount = meta:get_int("max_hp")
local stat_hp = (meta:get_int("strength") * 5) + (meta:get_int("level") * 10)

player:set_properties({hp_max = amount + stat_hp})
hb.change_hudbar(player, "health", player:get_hp(), amount + stat_hp)
meta:set_int("max_hp", amount)
end
3 changes: 2 additions & 1 deletion mods/players/player/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@ end)
--

local dirs = { -- Lua files to include
"experience.lua",
"hp.lua",
"inventory.lua",
"hud_info.lua",
"gold.lua",
"experience.lua",
"regen.lua",
"model.lua"
}
Expand Down
14 changes: 0 additions & 14 deletions mods/players/player/inventory.lua
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
hb.settings.bar_type = "progress_bar"

minetest.register_on_joinplayer(function(player)
local max_hp = player:get_meta():get_int("max_hp")
if not max_hp or max_hp < 50 then max_hp = 50 end

players.set_max_hp(player, max_hp)

player:set_formspec_prepend(
"background[0,0;0,0;gui_formbg.png;true]" ..
"real_coordinates[true]"
Expand All @@ -19,12 +14,3 @@ sfinv.override_page("sfinv:crafting", {
]], true)
end
})

function players.set_max_hp(player, amount)
local meta = player:get_meta()

player:set_properties({hp_max = amount})
player:set_hp(amount)
hb.change_hudbar(player, "health", amount, amount)
meta:set_int("max_hp", amount)
end
2 changes: 1 addition & 1 deletion mods/players/player/mod.conf
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
name = player
depends = sfinv, nodes, hudbars, sscsm
depends = sfinv, nodes, hudbars, sscsm, player_stats
4 changes: 0 additions & 4 deletions mods/players/player/regen.lua
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@ minetest.register_globalstep(function(dtime)
local meta = player:get_meta()
local new_hp = player:get_hp() + (meta:get_int("regen")/3)

if new_hp > meta:get_int("max_hp") then
new_hp = meta:get_int("max_hp")
end

player:set_hp(new_hp)
end
end
Expand Down
4 changes: 4 additions & 0 deletions mods/players/player_stats/stat_tab.lua
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ sfinv.register_page("sfinv:stats", {
if available_statpoints > 0 and statcount < 100 then
meta:set_int("available_statpoints", available_statpoints - 1)
meta:set_int(stat, statcount + 1)

if stat == "strength" then
players.update_max_hp(player)
end
end

sfinv.set_page(player, context.page)
Expand Down
9 changes: 7 additions & 2 deletions mods/vkore/init.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
vkore = {
settings = {
game_mode = "dev",
game_mode = "play", -- dev, regular
world_size = 3200,
},
}
Expand Down Expand Up @@ -51,8 +51,13 @@ end
minetest.register_on_mods_loaded(function()
for name, def in pairs(minetest.registered_nodes) do
if not def.groups then def.groups = {} end
local pointable = true
def.groups.all = 1

minetest.override_item(name, {groups = def.groups})
if vkore.settings.game_mode == "play" and def.groups.overrides_pointable ~= 1 then
pointable = false
end

minetest.override_item(name, {pointable = pointable, groups = def.groups})
end
end)

0 comments on commit ec0e571

Please sign in to comment.