mirror of
https://github.com/sys4-fr/server-nalc.git
synced 2024-11-18 00:08:25 +01:00
Updated 3d_armor
- Updated models - Updated armor.lua : new skin mod supported, and new method to drop the armor
This commit is contained in:
parent
681c2af852
commit
7932cf13fd
@ -88,6 +88,8 @@ elseif minetest.get_modpath("simple_skins") then
|
|||||||
skin_mod = "simple_skins"
|
skin_mod = "simple_skins"
|
||||||
elseif minetest.get_modpath("u_skins") then
|
elseif minetest.get_modpath("u_skins") then
|
||||||
skin_mod = "u_skins"
|
skin_mod = "u_skins"
|
||||||
|
elseif minetest.get_modpath("wardrobe") then
|
||||||
|
skin_mod = "wardrobe"
|
||||||
end
|
end
|
||||||
|
|
||||||
armor.def = {
|
armor.def = {
|
||||||
@ -110,17 +112,8 @@ armor.update_player_visuals = function(self, player)
|
|||||||
end
|
end
|
||||||
|
|
||||||
armor.set_player_armor = function(self, player)
|
armor.set_player_armor = function(self, player)
|
||||||
if not player then
|
local name, player_inv = armor:get_valid_player(player, "[set_player_armor]")
|
||||||
return
|
|
||||||
end
|
|
||||||
local name = player:get_player_name()
|
|
||||||
if not name then
|
if not name then
|
||||||
minetest.log("error", "3d_armor: Player name is nil [set_player_armor]")
|
|
||||||
return
|
|
||||||
end
|
|
||||||
local player_inv = player:get_inventory()
|
|
||||||
if not player_inv then
|
|
||||||
minetest.log("error", "3d_armor: Player inventory is nil [set_player_armor]")
|
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
local armor_texture = "3d_armor_trans.png"
|
local armor_texture = "3d_armor_trans.png"
|
||||||
@ -204,13 +197,8 @@ armor.set_player_armor = function(self, player)
|
|||||||
end
|
end
|
||||||
|
|
||||||
armor.update_armor = function(self, player)
|
armor.update_armor = function(self, player)
|
||||||
if not player then
|
local name, player_inv, armor_inv = armor:get_valid_player(player, "[update_armor]")
|
||||||
minetest.log("error", "3d_armor: Player reference is nil [update_armor]")
|
|
||||||
return
|
|
||||||
end
|
|
||||||
local name = player:get_player_name()
|
|
||||||
if not name then
|
if not name then
|
||||||
minetest.log("error", "3d_armor: Player name is nil[update_armor]")
|
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
local hp = player:get_hp() or 0
|
local hp = player:get_hp() or 0
|
||||||
@ -218,15 +206,6 @@ armor.update_armor = function(self, player)
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
if self.player_hp[name] > hp then
|
if self.player_hp[name] > hp then
|
||||||
local player_inv = player:get_inventory()
|
|
||||||
local armor_inv = minetest.get_inventory({type="detached", name=name.."_armor"})
|
|
||||||
if not player_inv then
|
|
||||||
minetest.log("error", "3d_armor: Player inventory is nil [update_armor]")
|
|
||||||
return
|
|
||||||
elseif not armor_inv then
|
|
||||||
minetest.log("error", "3d_armor: Detached inventory is nil [update_armor]")
|
|
||||||
return
|
|
||||||
end
|
|
||||||
local heal_max = 0
|
local heal_max = 0
|
||||||
local state = 0
|
local state = 0
|
||||||
local items = 0
|
local items = 0
|
||||||
@ -269,6 +248,8 @@ armor.get_player_skin = function(self, name)
|
|||||||
skin = skins.skins[name]
|
skin = skins.skins[name]
|
||||||
elseif skin_mod == "u_skins" then
|
elseif skin_mod == "u_skins" then
|
||||||
skin = u_skins.u_skins[name]
|
skin = u_skins.u_skins[name]
|
||||||
|
elseif skin_mod == "wardrobe" then
|
||||||
|
skin = string.gsub(wardrobe.playerSkins[name], '.png$','')
|
||||||
end
|
end
|
||||||
return skin or armor.default_skin
|
return skin or armor.default_skin
|
||||||
end
|
end
|
||||||
@ -280,10 +261,6 @@ armor.get_preview = function(self, name)
|
|||||||
end
|
end
|
||||||
|
|
||||||
armor.get_armor_formspec = function(self, name)
|
armor.get_armor_formspec = function(self, name)
|
||||||
if not name then
|
|
||||||
minetest.log("error", "3d_armor: Player name is nil [get_armor_formspec]")
|
|
||||||
return ""
|
|
||||||
end
|
|
||||||
if not armor.textures[name] then
|
if not armor.textures[name] then
|
||||||
minetest.log("error", "3d_armor: Player texture["..name.."] is nil [get_armor_formspec]")
|
minetest.log("error", "3d_armor: Player texture["..name.."] is nil [get_armor_formspec]")
|
||||||
return ""
|
return ""
|
||||||
@ -299,13 +276,8 @@ armor.get_armor_formspec = function(self, name)
|
|||||||
end
|
end
|
||||||
|
|
||||||
armor.update_inventory = function(self, player)
|
armor.update_inventory = function(self, player)
|
||||||
if not player then
|
local name = armor:get_valid_player(player, "[set_player_armor]")
|
||||||
minetest.log("error", "3d_armor: Player reference is nil [update_inventory]")
|
|
||||||
return
|
|
||||||
end
|
|
||||||
local name = player:get_player_name()
|
|
||||||
if not name then
|
if not name then
|
||||||
minetest.log("error", "3d_armor: Player name is nil [update_inventory]")
|
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
if inv_mod == "unified_inventory" then
|
if inv_mod == "unified_inventory" then
|
||||||
@ -325,6 +297,33 @@ armor.update_inventory = function(self, player)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
armor.get_valid_player = function(self, player, msg)
|
||||||
|
msg = msg or ""
|
||||||
|
if not player then
|
||||||
|
minetest.log("error", "3d_armor: Player reference is nil "..msg)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
local name = player:get_player_name()
|
||||||
|
if not name then
|
||||||
|
minetest.log("error", "3d_armor: Player name is nil "..msg)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
local pos = player:getpos()
|
||||||
|
local player_inv = player:get_inventory()
|
||||||
|
local armor_inv = minetest.get_inventory({type="detached", name=name.."_armor"})
|
||||||
|
if not pos then
|
||||||
|
minetest.log("error", "3d_armor: Player position is nil "..msg)
|
||||||
|
return
|
||||||
|
elseif not player_inv then
|
||||||
|
minetest.log("error", "3d_armor: Player inventory is nil "..msg)
|
||||||
|
return
|
||||||
|
elseif not armor_inv then
|
||||||
|
minetest.log("error", "3d_armor: Detached armor inventory is nil "..msg)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
return name, player_inv, armor_inv, pos
|
||||||
|
end
|
||||||
|
|
||||||
-- Register Player Model
|
-- Register Player Model
|
||||||
|
|
||||||
default.player_register_model("3d_armor_character.b3d", {
|
default.player_register_model("3d_armor_character.b3d", {
|
||||||
@ -347,7 +346,11 @@ default.player_register_model("3d_armor_character.b3d", {
|
|||||||
-- Register Callbacks
|
-- Register Callbacks
|
||||||
|
|
||||||
minetest.register_on_player_receive_fields(function(player, formname, fields)
|
minetest.register_on_player_receive_fields(function(player, formname, fields)
|
||||||
local name = player:get_player_name()
|
|
||||||
|
local name = armor:get_valid_player(player, "[on_player_receive_fields]")
|
||||||
|
if not name then
|
||||||
|
return
|
||||||
|
end
|
||||||
if inv_mod == "inventory_plus" and fields.armor then
|
if inv_mod == "inventory_plus" and fields.armor then
|
||||||
local formspec = armor:get_armor_formspec(name)
|
local formspec = armor:get_armor_formspec(name)
|
||||||
inventory_plus.set_inventory_formspec(player, formspec)
|
inventory_plus.set_inventory_formspec(player, formspec)
|
||||||
@ -446,6 +449,11 @@ minetest.register_on_joinplayer(function(player)
|
|||||||
if skin and u_skins.get_type(skin) == u_skins.type.MODEL then
|
if skin and u_skins.get_type(skin) == u_skins.type.MODEL then
|
||||||
armor.textures[name].skin = skin..".png"
|
armor.textures[name].skin = skin..".png"
|
||||||
end
|
end
|
||||||
|
elseif skin_mod == "wardrobe" then
|
||||||
|
local skin = wardrobe.playerSkins[name]
|
||||||
|
if skin then
|
||||||
|
armor.textures[name].skin = skin
|
||||||
|
end
|
||||||
end
|
end
|
||||||
if minetest.get_modpath("player_textures") then
|
if minetest.get_modpath("player_textures") then
|
||||||
local filename = minetest.get_modpath("player_textures").."/textures/player_"..name
|
local filename = minetest.get_modpath("player_textures").."/textures/player_"..name
|
||||||
@ -466,15 +474,27 @@ minetest.register_on_joinplayer(function(player)
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
if ARMOR_DROP == true or ARMOR_DESTROY == true then
|
if ARMOR_DROP == true or ARMOR_DESTROY == true then
|
||||||
|
armor.drop_armor = function(pos, stack)
|
||||||
|
local obj = minetest.add_item(pos, stack)
|
||||||
|
if obj then
|
||||||
|
local x = math.random(1, 5)
|
||||||
|
if math.random(1,2) == 1 then
|
||||||
|
x = -x
|
||||||
|
end
|
||||||
|
local z = math.random(1, 5)
|
||||||
|
if math.random(1,2) == 1 then
|
||||||
|
z = -z
|
||||||
|
end
|
||||||
|
obj:setvelocity({x=1/x, y=obj:getvelocity().y, z=1/z})
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
minetest.register_on_dieplayer(function(player)
|
minetest.register_on_dieplayer(function(player)
|
||||||
local name = player:get_player_name()
|
local name, player_inv, armor_inv, pos = armor:get_valid_player(player, "[on_dieplayer]")
|
||||||
local pos = player:getpos()
|
if not name then
|
||||||
if name and pos then
|
return
|
||||||
|
end
|
||||||
local drop = {}
|
local drop = {}
|
||||||
local player_inv = player:get_inventory()
|
|
||||||
local armor_inv = minetest.get_inventory({type="detached", name=name.."_armor"})
|
|
||||||
if not armor_inv then return end
|
|
||||||
-- MODIFICATION MADE FOR MFF ^
|
|
||||||
for i=1, player_inv:get_size("armor") do
|
for i=1, player_inv:get_size("armor") do
|
||||||
local stack = armor_inv:get_stack("armor", i)
|
local stack = armor_inv:get_stack("armor", i)
|
||||||
if stack:get_count() > 0 then
|
if stack:get_count() > 0 then
|
||||||
@ -493,40 +513,28 @@ if ARMOR_DROP == true or ARMOR_DESTROY == true then
|
|||||||
armor:update_inventory(player)
|
armor:update_inventory(player)
|
||||||
end
|
end
|
||||||
if ARMOR_DESTROY == false then
|
if ARMOR_DESTROY == false then
|
||||||
if minetest.get_modpath("bones") then
|
|
||||||
minetest.after(ARMOR_BONES_DELAY, function()
|
minetest.after(ARMOR_BONES_DELAY, function()
|
||||||
pos = vector.round(pos)
|
pos = vector.round(pos)
|
||||||
local node = minetest.get_node(pos)
|
local node = minetest.get_node(pos)
|
||||||
if node.name == "bones:bones" then
|
print(node)
|
||||||
|
print(node.name)
|
||||||
|
if node and node.name == "bones:bones" then
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
local owner = meta:get_string("owner")
|
local owner = meta:get_string("owner")
|
||||||
local inv = meta:get_inventory()
|
local inv = meta:get_inventory()
|
||||||
if name == owner then
|
|
||||||
for _,stack in ipairs(drop) do
|
for _,stack in ipairs(drop) do
|
||||||
if inv:room_for_item("main", stack) then
|
if name == owner and inv:room_for_item("main", stack) then
|
||||||
inv:add_item("main", stack)
|
inv:add_item("main", stack)
|
||||||
|
else
|
||||||
|
armor.drop_armor(pos, stack)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
else
|
||||||
|
for _,stack in ipairs(drop) do
|
||||||
|
armor.drop_armor(pos, stack)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
else
|
|
||||||
for _,stack in ipairs(drop) do
|
|
||||||
local obj = minetest.add_item(pos, stack)
|
|
||||||
if obj then
|
|
||||||
local x = math.random(1, 5)
|
|
||||||
if math.random(1,2) == 1 then
|
|
||||||
x = -x
|
|
||||||
end
|
|
||||||
local z = math.random(1, 5)
|
|
||||||
if math.random(1,2) == 1 then
|
|
||||||
z = -z
|
|
||||||
end
|
|
||||||
obj:setvelocity({x=1/x, y=obj:getvelocity().y, z=1/z})
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
BIN
mods/3d_armor/3d_armor/models/3d_armor_character.b3d
Executable file → Normal file
BIN
mods/3d_armor/3d_armor/models/3d_armor_character.b3d
Executable file → Normal file
Binary file not shown.
BIN
mods/3d_armor/3d_armor/models/3d_armor_character.blend
Executable file → Normal file
BIN
mods/3d_armor/3d_armor/models/3d_armor_character.blend
Executable file → Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user