Improve player model hanlding and update to version 0.4.0

This commit is contained in:
stujones11 2013-11-12 21:22:52 +00:00
parent 9dbf76d013
commit 0b3deea513
29 changed files with 208 additions and 149 deletions

@ -1,12 +1,13 @@
[mod] Visible Player Armor [3d_armor] [mod] Visible Player Armor [3d_armor]
===================================== =====================================
depends: default, inventory_plus, unified_skins depends: default, inventory_plus
Adds craftable armor that is visible to other players. Each armor item worn contibutes to Adds craftable armor that is visible to other players. Each armor item worn contributes to
a player's armor group level making them less vulnerable to weapons. a player's armor group level making them less vulnerable to weapons.
Armor takes damage when a player is hurt but also offers a percentage chance of healing. Armor takes damage when a player is hurt but also offers a percentage chance of healing.
Overall level is boosted by 10% when wearing a full matching set.
default settings: [minetest.conf] default settings: [minetest.conf]

@ -14,36 +14,64 @@ armor = {
.."list[detached:player_name_armor;armor_torso;3,1;1,1;]" .."list[detached:player_name_armor;armor_torso;3,1;1,1;]"
.."list[detached:player_name_armor;armor_legs;3,2;1,1;]" .."list[detached:player_name_armor;armor_legs;3,2;1,1;]"
.."list[detached:player_name_armor;armor_feet;3,3;1,1;]", .."list[detached:player_name_armor;armor_feet;3,3;1,1;]",
textures = {},
default_skin = "character.png",
} }
-- armor.def - Added by BlockMen for HUD integration
armor.def = { armor.def = {
state = 0, state = 0,
count = 0 count = 0,
} }
armor.update_player_visuals = function(self, player)
if not player then
return
end
local name = player:get_player_name()
if self.textures[name] then
default.player_set_textures(player, {
self.textures[name].skin,
self.textures[name].armor,
self.textures[name].wielditem,
})
end
end
armor.set_player_armor = function(self, player) armor.set_player_armor = function(self, player)
if not player then if not player then
return return
end end
local name = player:get_player_name() local name = player:get_player_name()
local player_inv = player:get_inventory() local player_inv = player:get_inventory()
local armor_texture = uniskins.default_texture local armor_texture = "3d_armor_trans.png"
local armor_level = 0 local armor_level = 0
local state = 0 local state = 0
local items = 0 local items = 0
local textures = {} local textures = {}
for _,v in ipairs(self.elements) do local elements = {}
for i, v in ipairs(self.elements) do
local stack = player_inv:get_stack("armor_"..v, 1) local stack = player_inv:get_stack("armor_"..v, 1)
local level = stack:get_definition().groups["armor_"..v] local level = stack:get_definition().groups["armor_"..v]
local item = stack:get_name()
elements[i] = string.match(item, "%:.+_(.+)$")
if level then if level then
local item = stack:get_name()
table.insert(textures, item:gsub("%:", "_")..".png") table.insert(textures, item:gsub("%:", "_")..".png")
armor_level = armor_level + level armor_level = armor_level + level
state = state + stack:get_wear() state = state + stack:get_wear()
items = items+1 items = items + 1
end end
end end
if table.getn(textures) > 0 then if minetest.get_modpath("shields") then
armor_level = armor_level * 0.9
end
if elements[1] == elements[2] and
elements[1] == elements[3] and
elements[1] == elements[4] then
armor_level = armor_level * 1.1
end
if #textures > 0 then
armor_texture = table.concat(textures, "^") armor_texture = table.concat(textures, "^")
end end
local armor_groups = {fleshy=100} local armor_groups = {fleshy=100}
@ -52,10 +80,10 @@ armor.set_player_armor = function(self, player)
armor_groups.fleshy = 100 - armor_level armor_groups.fleshy = 100 - armor_level
end end
player:set_armor_groups(armor_groups) player:set_armor_groups(armor_groups)
uniskins.armor[name] = armor_texture self.textures[name].armor = armor_texture
uniskins:update_player_visuals(player) self.def[name].state = state
armor.def[name].state = state self.def[name].count = items
armor.def[name].count = items self:update_player_visuals(player)
end end
armor.update_armor = function(self, player) armor.update_armor = function(self, player)
@ -86,7 +114,7 @@ armor.update_armor = function(self, player)
armor_inv:set_stack("armor_"..v, 1, stack) armor_inv:set_stack("armor_"..v, 1, stack)
player_inv:set_stack("armor_"..v, 1, stack) player_inv:set_stack("armor_"..v, 1, stack)
state = state + stack:get_wear() state = state + stack:get_wear()
items = items+1 items = items + 1
if stack:get_count() == 0 then if stack:get_count() == 0 then
local desc = minetest.registered_items[item].description local desc = minetest.registered_items[item].description
if desc then if desc then
@ -97,8 +125,8 @@ armor.update_armor = function(self, player)
heal_max = heal_max + heal heal_max = heal_max + heal
end end
end end
armor.def[name].state = state self.def[name].state = state
armor.def[name].count = items self.def[name].count = items
if heal_max > math.random(100) then if heal_max > math.random(100) then
player:set_hp(self.player_hp[name]) player:set_hp(self.player_hp[name])
return return
@ -107,6 +135,25 @@ armor.update_armor = function(self, player)
self.player_hp[name] = hp self.player_hp[name] = hp
end end
-- Register Player Model
default.player_register_model("3d_armor_character.x", {
animation_speed = 30,
textures = {
armor.default_skin,
"3d_armor_trans.png",
"3d_armor_trans.png",
},
animations = {
stand = {x=0, y=79},
lay = {x=162, y=166},
walk = {x=168, y=187},
mine = {x=189, y=198},
walk_mine = {x=200, y=219},
sit = {x=81, y=160},
},
})
-- Register Callbacks -- Register Callbacks
minetest.register_on_player_receive_fields(function(player, formname, fields) minetest.register_on_player_receive_fields(function(player, formname, fields)
@ -117,16 +164,17 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
return return
end end
for field, _ in pairs(fields) do for field, _ in pairs(fields) do
if string.sub(field,0,string.len("skins_set_")) == "skins_set_" then if string.find(field, "^skins_set_") then
minetest.after(0, function(player) minetest.after(0, function(player)
uniskins.skin[name] = skins.skins[name]..".png" armor.textures[name].skin = skins.skins[name]..".png"
uniskins:update_player_visuals(player) armor:update_player_visuals(player)
end, player) end, player)
end end
end end
end) end)
minetest.register_on_joinplayer(function(player) minetest.register_on_joinplayer(function(player)
default.player_set_model(player, "3d_armor_character.x")
inventory_plus.register_button(player,"armor", "Armor") inventory_plus.register_button(player,"armor", "Armor")
local player_inv = player:get_inventory() local player_inv = player:get_inventory()
local name = player:get_player_name() local name = player:get_player_name()
@ -160,9 +208,28 @@ minetest.register_on_joinplayer(function(player)
end end
armor.player_hp[name] = 0 armor.player_hp[name] = 0
armor.def[name] = { armor.def[name] = {
state = 0, state = 0,
count = 0 count = 0,
} }
armor.textures[name] = {
skin = armor.default_skin,
armor = "3d_armor_trans.png",
wielditem = "3d_armor_trans.png",
}
if minetest.get_modpath("skins") then
local skin = skins.skins[name]
if skin and skins.get_type(skin) == skins.type.MODEL then
armor.textures[name].skin = skin..".png"
end
end
if minetest.get_modpath("player_textures") then
local filename = minetest.get_modpath("player_textures").."/textures/player_"..name
local f = io.open(filename..".png")
if f then
f:close()
armor.textures[name].skin = "player_"..name..".png"
end
end
minetest.after(0, function(player) minetest.after(0, function(player)
armor:set_player_armor(player) armor:set_player_armor(player)
end, player) end, player)

@ -15,6 +15,7 @@ Helmets:
[3d_armor:helmet_steel] X = [default:steel_ingot] [3d_armor:helmet_steel] X = [default:steel_ingot]
[3d_armor:helmet_bronze] X = [default:bronze_ingot] [3d_armor:helmet_bronze] X = [default:bronze_ingot]
[3d_armor:helmet_diamond] X = [default:diamond] [3d_armor:helmet_diamond] X = [default:diamond]
[3d_armor:helmet_mithril] X = [moreores:mithril_ingot] *
Chestplates: Chestplates:
@ -30,6 +31,7 @@ Chestplates:
[3d_armor:chestplate_steel] X = [default:steel_ingot] [3d_armor:chestplate_steel] X = [default:steel_ingot]
[3d_armor:chestplate_bronze] X = [default:bronze_ingot] [3d_armor:chestplate_bronze] X = [default:bronze_ingot]
[3d_armor:chestplate_diamond] X = [default:diamond] [3d_armor:chestplate_diamond] X = [default:diamond]
[3d_armor:chestplate_mithril] X = [moreores:mithril_ingot] *
Leggings: Leggings:
@ -45,6 +47,7 @@ Leggings:
[3d_armor:leggings_steel] X = [default:steel_ingot] [3d_armor:leggings_steel] X = [default:steel_ingot]
[3d_armor:leggings_bronze] X = [default:bronze_ingot] [3d_armor:leggings_bronze] X = [default:bronze_ingot]
[3d_armor:leggings_diamond] X = [default:diamond] [3d_armor:leggings_diamond] X = [default:diamond]
[3d_armor:leggings_mithril] X = [moreores:mithril_ingot] *
Boots: Boots:
@ -58,4 +61,7 @@ Boots:
[3d_armor:boots_steel] X = [default:steel_ingot] [3d_armor:boots_steel] X = [default:steel_ingot]
[3d_armor:boots_bronze] X = [default:bronze_ingot [3d_armor:boots_bronze] X = [default:bronze_ingot
[3d_armor:boots_diamond] X = [default:diamond] [3d_armor:boots_diamond] X = [default:diamond]
[3d_armor:boots_mithril] X = [moreores:mithril_ingot] *
* Requires moreores mod by Calinou - https://forum.minetest.net/viewtopic.php?id=549

@ -1,3 +1,3 @@
default default
inventory_plus inventory_plus
unified_skins

@ -1,4 +1,5 @@
dofile(minetest.get_modpath(minetest.get_current_modname()).."/armor.lua") dofile(minetest.get_modpath(minetest.get_current_modname()).."/armor.lua")
local use_moreores = minetest.get_modpath("moreores")
-- Regisiter Head Armor -- Regisiter Head Armor
@ -30,6 +31,14 @@ minetest.register_tool("3d_armor:helmet_diamond", {
wear = 0, wear = 0,
}) })
if use_moreores then
minetest.register_tool("3d_armor:helmet_mithril", {
description = "Mithril Helmet",
inventory_image = "3d_armor_inv_helmet_mithril.png",
groups = {armor_head=15, armor_heal=12, armor_use=50},
wear = 0,
})
end
-- Regisiter Torso Armor -- Regisiter Torso Armor
@ -61,6 +70,14 @@ minetest.register_tool("3d_armor:chestplate_diamond", {
wear = 0, wear = 0,
}) })
if use_moreores then
minetest.register_tool("3d_armor:chestplate_mithril", {
description = "Mithril Chestplate",
inventory_image = "3d_armor_inv_chestplate_mithril.png",
groups = {armor_torso=20, armor_heal=12, armor_use=50},
wear = 0,
})
end
-- Regisiter Leg Armor -- Regisiter Leg Armor
@ -92,6 +109,15 @@ minetest.register_tool("3d_armor:leggings_diamond", {
wear = 0, wear = 0,
}) })
if use_moreores then
minetest.register_tool("3d_armor:leggings_mithril", {
description = "Mithril Leggings",
inventory_image = "3d_armor_inv_leggings_mithril.png",
groups = {armor_legs=20, armor_heal=12, armor_use=50},
wear = 0,
})
end
-- Regisiter Boots -- Regisiter Boots
minetest.register_tool("3d_armor:boots_wood", { minetest.register_tool("3d_armor:boots_wood", {
@ -122,6 +148,15 @@ minetest.register_tool("3d_armor:boots_diamond", {
wear = 0, wear = 0,
}) })
if use_moreores then
minetest.register_tool("3d_armor:boots_mithril", {
description = "Mithril Boots",
inventory_image = "3d_armor_inv_boots_mithril.png",
groups = {armor_feet=15, armor_heal=12, armor_use=50},
wear = 0,
})
end
-- Register Craft Recipies -- Register Craft Recipies
local craft_ingreds = { local craft_ingreds = {
@ -131,6 +166,10 @@ local craft_ingreds = {
diamond = "default:diamond", diamond = "default:diamond",
} }
if use_moreores then
craft_ingreds.mithril = "moreores:mithril_ingot"
end
for k, v in pairs(craft_ingreds) do for k, v in pairs(craft_ingreds) do
minetest.register_craft({ minetest.register_craft({
output = "3d_armor:helmet_"..k, output = "3d_armor:helmet_"..k,
@ -165,4 +204,3 @@ for k, v in pairs(craft_ingreds) do
}) })
end end

Binary file not shown.

@ -1998,30 +1998,30 @@ Frame Root {
0.625000; 0.625000;, 0.625000; 0.625000;,
0.625000; 1.000000;, 0.625000; 1.000000;,
0.500000; 1.000000;, 0.500000; 1.000000;,
0.625000; 0.250000;, 0.622025; 0.250000;,
0.625000; 0.500000;, 0.622025; 0.500000;,
0.500000; 0.500000;, 0.497025; 0.500000;,
0.500000; 0.250000;, 0.497025; 0.250000;,
0.625000; 0.250000;, 0.622025; 0.250000;,
0.625000; 0.000000;, 0.622025; 0.000000;,
0.750000; 0.000000;, 0.747025; 0.000000;,
0.750000; 0.250000;, 0.747025; 0.250000;,
0.750000; 0.250000;, 0.747025; 0.250000;,
0.750000; 0.000000;, 0.747025; 0.000000;,
0.875000; 0.000000;, 0.872025; 0.000000;,
0.875000; 0.250000;, 0.872025; 0.250000;,
0.750000; 0.500000;, 0.747025; 0.500000;,
0.625000; 0.500000;, 0.622025; 0.500000;,
0.625000; 0.250000;, 0.622025; 0.250000;,
0.750000; 0.250000;, 0.747025; 0.250000;,
0.875000; 0.500000;, 0.872025; 0.500000;,
0.750000; 0.500000;, 0.747025; 0.500000;,
0.750000; 0.250000;, 0.747025; 0.250000;,
0.875000; 0.250000;, 0.872025; 0.250000;,
1.000000; 0.500000;, 0.997025; 0.500000;,
0.875000; 0.500000;, 0.872025; 0.500000;,
0.875000; 0.250000;, 0.872025; 0.250000;,
1.000000; 0.250000;, 0.997025; 0.250000;,
0.812500; 0.625000;, 0.812500; 0.625000;,
0.812500; 0.500000;, 0.812500; 0.500000;,
0.750000; 0.500000;, 0.750000; 0.500000;,
@ -2181,8 +2181,8 @@ Frame Root {
0.250000; 0.500000;, 0.250000; 0.500000;,
0.250000; 0.000000;, 0.250000; 0.000000;,
0.000000; 0.000000;, 0.000000; 0.000000;,
0.000000; 0.500000;, -0.000000; 0.500000;,
0.000000; 0.500000;, -0.000000; 0.500000;,
0.000000; 0.000000;, 0.000000; 0.000000;,
0.250000; 0.000000;, 0.250000; 0.000000;,
0.250000; 0.500000;, 0.250000; 0.500000;,

Binary file not shown.

After

Width:  |  Height:  |  Size: 472 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 203 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 242 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 228 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 237 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 760 B

Before

Width:  |  Height:  |  Size: 146 B

After

Width:  |  Height:  |  Size: 146 B

@ -1,36 +1,26 @@
Modpack - 3d Armor Modpack - 3d Armor [0.4.0]
================== ==========================
[mod] Unified Skins [unified_skins]
-----------------------------------
depends: default
A 3d character model re-texturing api used as the framework for this modpack.
Compatible with player skins mod [skins] by Zeg9 and Player Textures [player_textures] by sdzen.
Note: Currently only supports 64x32px player skins.
[mod] Visible Wielded Items [wieldview]
---------------------------------------
depends: unified_skins
Makes hand wielded items visible to other players.
Note: Currently only supports 16x16px texture packs, sorry!
[mod] Visible Player Armor [3d_armor] [mod] Visible Player Armor [3d_armor]
------------------------------------- -------------------------------------
depends: unified_skins, inventory_plus depends: default, inventory_plus
Adds craftable armor that is visible to other players. Each armor item worn contributes to Adds craftable armor that is visible to other players. Each armor item worn contributes to
a player's armor group level making them less vulnerable to weapons. a player's armor group level making them less vulnerable to weapons.
Armor takes damage when a player is hurt, however, many armor items offer a 'stackable' Armor takes damage when a player is hurt, however, many armor items offer a 'stackable'
percentage chance of restoring the lost health points. percentage chance of restoring the lost health points. Overall armor level is boosted by 10%
when wearing a full matching set (helmet, chestplate, leggings and boots of the same material)
Compatible with player skins [skins] by Zeg9 and Player Textures [player_textures] by PilzAdam.
[mod] Visible Wielded Items [wieldview]
---------------------------------------
depends: 3d_armor
Makes hand wielded items visible to other players.
[mod] Shields [shields] [mod] Shields [shields]
------------------------------------- -------------------------------------
@ -39,3 +29,4 @@ depends: 3d_armor
Originally a part of 3d_armor, shields have been re-included as an optional extra. Originally a part of 3d_armor, shields have been re-included as an optional extra.
If you do not want shields then simply remove the shields folder from the modpack. If you do not want shields then simply remove the shields folder from the modpack.

@ -1,3 +1,2 @@
default default
inventory_plus
3d_armor 3d_armor

@ -1,3 +1,5 @@
local use_moreores = minetest.get_modpath("moreores")
-- Regisiter Shields -- Regisiter Shields
minetest.register_tool("shields:shield_wood", { minetest.register_tool("shields:shield_wood", {
@ -28,6 +30,14 @@ minetest.register_tool("shields:shield_diamond", {
wear = 0, wear = 0,
}) })
if use_moreores then
minetest.register_tool("shields:shield_mithril", {
description = "Mithril Shield",
inventory_image = "shields_inv_shield_mithril.png",
groups = {armor_shield=15, armor_heal=12, armor_use=50},
wear = 0,
})
end
local craft_ingreds = { local craft_ingreds = {
wood = "default:wood", wood = "default:wood",
@ -36,6 +46,10 @@ local craft_ingreds = {
diamond = "default:diamond", diamond = "default:diamond",
} }
if has_moreores then
craft_ingreds.mithril = "moreores:mithril_ingot"
end
for k, v in pairs(craft_ingreds) do for k, v in pairs(craft_ingreds) do
minetest.register_craft({ minetest.register_craft({
output = "shields:shield_"..k, output = "shields:shield_"..k,
@ -58,4 +72,3 @@ minetest.after(0, function()
.."list[detached:player_name_armor;armor_shield;4,1;1,1;]" .."list[detached:player_name_armor;armor_shield;4,1;1,1;]"
end) end)

Binary file not shown.

After

Width:  |  Height:  |  Size: 647 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 616 B

@ -1,7 +0,0 @@
A 3d character model re-texturing api used as the framework for this modpack.
depends: default
Compatible with player skins mod [skins] by Zeg9 and Player Textures [player_textures] by sdzen.
Note: Currently only 64x32px player skins.

@ -1 +0,0 @@
default

@ -1,47 +0,0 @@
uniskins = {
skin = {},
armor = {},
wielditem = {},
default_skin = "character.png",
default_texture = "uniskins_trans.png",
}
uniskins.update_player_visuals = function(self, player)
if not player then
return
end
local name = player:get_player_name()
player:set_properties({
visual = "mesh",
mesh = "uniskins_character.x",
textures = {
self.skin[name],
self.armor[name],
self.wielditem[name]
},
visual_size = {x=1, y=1},
})
end
minetest.register_on_joinplayer(function(player)
local name = player:get_player_name()
uniskins.skin[name] = uniskins.default_skin
uniskins.armor[name] = uniskins.default_texture
uniskins.wielditem[name] = uniskins.default_texture
if minetest.get_modpath("player_textures") then
local filename = minetest.get_modpath("player_textures").."/textures/player_"..name
local f = io.open(filename..".png")
if f then
f:close()
uniskins.skin[name] = "player_"..name..".png"
end
end
if minetest.get_modpath("skins") then
local skin = skins.skins[name]
if skin and skins.get_type(skin) == skins.type.MODEL then
uniskins.skin[name] = skin..".png"
end
end
end)

@ -1,11 +1,9 @@
[mod] visible wielded items [wieldview] [mod] visible wielded items [wieldview]
======================================= =======================================
depends: default, unified_skins depends: default, 3d_armor
Makes hand wielded items visible to other players. Compatible with player skins mod [skins]. Makes hand wielded items visible to other players.
Note: Currently only supports 16x16px texture packs, sorry!
default settings: [minetest.conf] default settings: [minetest.conf]

@ -1,2 +1,2 @@
default default
unified_skins 3d_armor

@ -10,14 +10,15 @@ if not node_tiles then
minetest.setting_set("wieldview_node_tiles", "false") minetest.setting_set("wieldview_node_tiles", "false")
end end
dofile(minetest.get_modpath(minetest.get_current_modname()).."/transform.lua")
wieldview = { wieldview = {
wielded_item = {}, wielded_item = {},
transform = {},
} }
dofile(minetest.get_modpath(minetest.get_current_modname()).."/transform.lua")
wieldview.get_item_texture = function(self, item) wieldview.get_item_texture = function(self, item)
local texture = uniskins.default_texture local texture = "3d_armor_trans.png"
if item ~= "" then if item ~= "" then
if minetest.registered_items[item] then if minetest.registered_items[item] then
if minetest.registered_items[item].inventory_image ~= "" then if minetest.registered_items[item].inventory_image ~= "" then
@ -26,8 +27,8 @@ wieldview.get_item_texture = function(self, item)
texture = minetest.registered_items[item].tiles[1] texture = minetest.registered_items[item].tiles[1]
end end
end end
if wieldview_transform[item] then if wieldview.transform[item] then
texture = texture.."^[transform"..wieldview_transform[item] texture = texture.."^[transform"..wieldview.transform[item]
end end
end end
return texture return texture
@ -47,8 +48,8 @@ wieldview.update_wielded_item = function(self, player)
if self.wielded_item[name] == item then if self.wielded_item[name] == item then
return return
end end
uniskins.wielditem[name] = self:get_item_texture(item) armor.textures[name].wielditem = self:get_item_texture(item)
uniskins:update_player_visuals(player) armor:update_player_visuals(player)
end end
self.wielded_item[name] = item self.wielded_item[name] = item
end end

@ -1,6 +1,6 @@
-- Wielded Item Transformations - http://dev.minetest.net/texture -- Wielded Item Transformations - http://dev.minetest.net/texture
wieldview_transform = { wieldview.transform = {
["default:torch"]="R270", ["default:torch"]="R270",
["default:sapling"]="R270", ["default:sapling"]="R270",
["flowers:dandelion_white"]="R270", ["flowers:dandelion_white"]="R270",