1
0
Fork 0

Add armor equip/unequip sounds

objects
Wuzzy 2020-02-18 07:33:08 +01:00
parent f700463c4f
commit ef077fed72
12 changed files with 100 additions and 1 deletions

View File

@ -9,3 +9,20 @@ a player's armor group level making them less vulnerable to some forms of damage
Armor takes damage when a player is hurt. Armor takes damage when a player is hurt.
This mod is based on 3D Armor mod by stu. This mod is based on 3D Armor mod by stu.
Media credits
-------------
* 3d_armor_equip_diamond.ogg
* 3d_armor_unequip_diamond.ogg
Licensed CC0, by Freesound.org user juryduty.
Source: <https://freesound.org/people/juryduty/sounds/180231/>
* 3d_armor_equip_iron.ogg
* 3d_armor_unequip_iron.ogg
Licensed CC0, by Freesound.org user mtchanary.
Source: <https://freesound.org/people/mitchanary/sounds/506148/>
All other sounds licensed CC0 by OpenGameArt.org user artisticdude.
Source: <https://opengameart.org/content/rpg-sound-pack>
Other media files: See MineClone 2 license.

View File

@ -265,6 +265,22 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
end end
end) end)
local function play_equip_sound(player, stack, unequip)
local def = stack:get_definition()
local estr = "equip"
if unequip then
estr = "unequip"
end
local snd = def.sounds and def.sounds["_mcl_armor_"..estr]
if not snd then
-- Fallback sound
snd = { name = "3d_armor_"..estr.."_iron" }
end
if snd then
minetest.sound_play(snd, {object=player, gain=0.5, max_hear_distance=8})
end
end
minetest.register_on_joinplayer(function(player) minetest.register_on_joinplayer(function(player)
mcl_player.player_set_model(player, "3d_armor_character.b3d") mcl_player.player_set_model(player, "3d_armor_character.b3d")
local name = player:get_player_name() local name = player:get_player_name()
@ -274,11 +290,13 @@ minetest.register_on_joinplayer(function(player)
player:get_inventory():set_stack(listname, index, stack) player:get_inventory():set_stack(listname, index, stack)
armor:set_player_armor(player) armor:set_player_armor(player)
armor:update_inventory(player) armor:update_inventory(player)
play_equip_sound(player, stack)
end, end,
on_take = function(inv, listname, index, stack, player) on_take = function(inv, listname, index, stack, player)
player:get_inventory():set_stack(listname, index, nil) player:get_inventory():set_stack(listname, index, nil)
armor:set_player_armor(player) armor:set_player_armor(player)
armor:update_inventory(player) armor:update_inventory(player)
play_equip_sound(player, stack, true)
end, end,
on_move = function(inv, from_list, from_index, to_list, to_index, count, player) on_move = function(inv, from_list, from_index, to_list, to_index, count, player)
local plaver_inv = player:get_inventory() local plaver_inv = player:get_inventory()
@ -287,6 +305,7 @@ minetest.register_on_joinplayer(function(player)
player_inv:set_stack(from_list, from_index, nil) player_inv:set_stack(from_list, from_index, nil)
armor:set_player_armor(player) armor:set_player_armor(player)
armor:update_inventory(player) armor:update_inventory(player)
play_equip_sound(player, stack)
end, end,
allow_put = function(inv, listname, index, stack, player) allow_put = function(inv, listname, index, stack, player)
local iname = stack:get_name() local iname = stack:get_name()
@ -435,4 +454,3 @@ minetest.register_on_player_hpchange(function(player, hp_change, reason)
end end
return hp_change return hp_change
end, true) end, true)

View File

@ -14,6 +14,10 @@ minetest.register_tool("3d_armor:helmet_leather", {
inventory_image = "3d_armor_inv_helmet_leather.png", inventory_image = "3d_armor_inv_helmet_leather.png",
groups = {armor_head=1, mcl_armor_points=1, mcl_armor_uses=56}, groups = {armor_head=1, mcl_armor_points=1, mcl_armor_uses=56},
_repair_material = "mcl_mobitems:leather", _repair_material = "mcl_mobitems:leather",
sounds = {
_mcl_armor_equip = "3d_armor_equip_leather",
_mcl_armor_unequip = "3d_armor_unequip_leather",
},
}) })
minetest.register_tool("3d_armor:helmet_iron", { minetest.register_tool("3d_armor:helmet_iron", {
@ -23,6 +27,10 @@ minetest.register_tool("3d_armor:helmet_iron", {
inventory_image = "3d_armor_inv_helmet_iron.png", inventory_image = "3d_armor_inv_helmet_iron.png",
groups = {armor_head=1, mcl_armor_points=2, mcl_armor_uses=166}, groups = {armor_head=1, mcl_armor_points=2, mcl_armor_uses=166},
_repair_material = "mcl_core:iron_ingot", _repair_material = "mcl_core:iron_ingot",
sounds = {
_mcl_armor_equip = "3d_armor_equip_iron",
_mcl_armor_unequip = "3d_armor_unequip_iron",
},
}) })
minetest.register_tool("3d_armor:helmet_gold", { minetest.register_tool("3d_armor:helmet_gold", {
@ -41,6 +49,10 @@ minetest.register_tool("3d_armor:helmet_diamond",{
inventory_image = "3d_armor_inv_helmet_diamond.png", inventory_image = "3d_armor_inv_helmet_diamond.png",
groups = {armor_head=1, mcl_armor_points=3, mcl_armor_uses=364, mcl_armor_toughness=2}, groups = {armor_head=1, mcl_armor_points=3, mcl_armor_uses=364, mcl_armor_toughness=2},
_repair_material = "mcl_core:diamond", _repair_material = "mcl_core:diamond",
sounds = {
_mcl_armor_equip = "3d_armor_equip_diamond",
_mcl_armor_unequip = "3d_armor_unequip_diamond",
},
}) })
minetest.register_tool("3d_armor:helmet_chain", { minetest.register_tool("3d_armor:helmet_chain", {
@ -50,6 +62,10 @@ minetest.register_tool("3d_armor:helmet_chain", {
inventory_image = "3d_armor_inv_helmet_chain.png", inventory_image = "3d_armor_inv_helmet_chain.png",
groups = {armor_head=1, mcl_armor_points=2, mcl_armor_uses=166}, groups = {armor_head=1, mcl_armor_points=2, mcl_armor_uses=166},
_repair_material = "mcl_core:iron_ingot", _repair_material = "mcl_core:iron_ingot",
sounds = {
_mcl_armor_equip = "3d_armor_equip_chainmail",
_mcl_armor_unequip = "3d_armor_unequip_chainmail",
},
}) })
-- Regisiter Torso Armor -- Regisiter Torso Armor
@ -61,6 +77,10 @@ minetest.register_tool("3d_armor:chestplate_leather", {
inventory_image = "3d_armor_inv_chestplate_leather.png", inventory_image = "3d_armor_inv_chestplate_leather.png",
groups = {armor_torso=1, mcl_armor_points=3, mcl_armor_uses=81}, groups = {armor_torso=1, mcl_armor_points=3, mcl_armor_uses=81},
_repair_material = "mcl_mobitems:leather", _repair_material = "mcl_mobitems:leather",
sounds = {
_mcl_armor_equip = "3d_armor_equip_leather",
_mcl_armor_unequip = "3d_armor_unequip_leather",
},
}) })
minetest.register_tool("3d_armor:chestplate_iron", { minetest.register_tool("3d_armor:chestplate_iron", {
@ -70,6 +90,10 @@ minetest.register_tool("3d_armor:chestplate_iron", {
inventory_image = "3d_armor_inv_chestplate_iron.png", inventory_image = "3d_armor_inv_chestplate_iron.png",
groups = {armor_torso=1, mcl_armor_points=6, mcl_armor_uses=241}, groups = {armor_torso=1, mcl_armor_points=6, mcl_armor_uses=241},
_repair_material = "mcl_core:iron_ingot", _repair_material = "mcl_core:iron_ingot",
sounds = {
_mcl_armor_equip = "3d_armor_equip_iron",
_mcl_armor_unequip = "3d_armor_unequip_iron",
},
}) })
minetest.register_tool("3d_armor:chestplate_gold", { minetest.register_tool("3d_armor:chestplate_gold", {
@ -88,6 +112,10 @@ minetest.register_tool("3d_armor:chestplate_diamond",{
inventory_image = "3d_armor_inv_chestplate_diamond.png", inventory_image = "3d_armor_inv_chestplate_diamond.png",
groups = {armor_torso=1, mcl_armor_points=8, mcl_armor_uses=529, mcl_armor_toughness=2}, groups = {armor_torso=1, mcl_armor_points=8, mcl_armor_uses=529, mcl_armor_toughness=2},
_repair_material = "mcl_core:diamond", _repair_material = "mcl_core:diamond",
sounds = {
_mcl_armor_equip = "3d_armor_equip_diamond",
_mcl_armor_unequip = "3d_armor_unequip_diamond",
},
}) })
minetest.register_tool("3d_armor:chestplate_chain", { minetest.register_tool("3d_armor:chestplate_chain", {
@ -97,6 +125,10 @@ minetest.register_tool("3d_armor:chestplate_chain", {
inventory_image = "3d_armor_inv_chestplate_chain.png", inventory_image = "3d_armor_inv_chestplate_chain.png",
groups = {armor_torso=1, mcl_armor_points=5, mcl_armor_uses=241}, groups = {armor_torso=1, mcl_armor_points=5, mcl_armor_uses=241},
_repair_material = "mcl_core:iron_ingot", _repair_material = "mcl_core:iron_ingot",
sounds = {
_mcl_armor_equip = "3d_armor_equip_chainmail",
_mcl_armor_unequip = "3d_armor_unequip_chainmail",
},
}) })
-- Regisiter Leg Armor -- Regisiter Leg Armor
@ -108,6 +140,10 @@ minetest.register_tool("3d_armor:leggings_leather", {
inventory_image = "3d_armor_inv_leggings_leather.png", inventory_image = "3d_armor_inv_leggings_leather.png",
groups = {armor_legs=1, mcl_armor_points=2, mcl_armor_uses=76}, groups = {armor_legs=1, mcl_armor_points=2, mcl_armor_uses=76},
_repair_material = "mcl_mobitems:leather", _repair_material = "mcl_mobitems:leather",
sounds = {
_mcl_armor_equip = "3d_armor_equip_leather",
_mcl_armor_unequip = "3d_armor_unequip_leather",
},
}) })
minetest.register_tool("3d_armor:leggings_iron", { minetest.register_tool("3d_armor:leggings_iron", {
@ -117,6 +153,10 @@ minetest.register_tool("3d_armor:leggings_iron", {
inventory_image = "3d_armor_inv_leggings_iron.png", inventory_image = "3d_armor_inv_leggings_iron.png",
groups = {armor_legs=1, mcl_armor_points=5, mcl_armor_uses=226}, groups = {armor_legs=1, mcl_armor_points=5, mcl_armor_uses=226},
_repair_material = "mcl_core:iron_ingot", _repair_material = "mcl_core:iron_ingot",
sounds = {
_mcl_armor_equip = "3d_armor_equip_iron",
_mcl_armor_unequip = "3d_armor_unequip_iron",
},
}) })
minetest.register_tool("3d_armor:leggings_gold", { minetest.register_tool("3d_armor:leggings_gold", {
@ -135,6 +175,10 @@ minetest.register_tool("3d_armor:leggings_diamond",{
inventory_image = "3d_armor_inv_leggings_diamond.png", inventory_image = "3d_armor_inv_leggings_diamond.png",
groups = {armor_legs=1, mcl_armor_points=6, mcl_armor_uses=496, mcl_armor_toughness=2}, groups = {armor_legs=1, mcl_armor_points=6, mcl_armor_uses=496, mcl_armor_toughness=2},
_repair_material = "mcl_core:diamond", _repair_material = "mcl_core:diamond",
sounds = {
_mcl_armor_equip = "3d_armor_equip_diamond",
_mcl_armor_unequip = "3d_armor_unequip_diamond",
},
}) })
minetest.register_tool("3d_armor:leggings_chain", { minetest.register_tool("3d_armor:leggings_chain", {
@ -144,6 +188,10 @@ minetest.register_tool("3d_armor:leggings_chain", {
inventory_image = "3d_armor_inv_leggings_chain.png", inventory_image = "3d_armor_inv_leggings_chain.png",
groups = {armor_legs=1, mcl_armor_points=4, mcl_armor_uses=226}, groups = {armor_legs=1, mcl_armor_points=4, mcl_armor_uses=226},
_repair_material = "mcl_core:iron_ingot", _repair_material = "mcl_core:iron_ingot",
sounds = {
_mcl_armor_equip = "3d_armor_equip_chainmail",
_mcl_armor_unequip = "3d_armor_unequip_chainmail",
},
}) })
-- Regisiter Boots -- Regisiter Boots
@ -154,6 +202,10 @@ minetest.register_tool("3d_armor:boots_leather", {
inventory_image = "3d_armor_inv_boots_leather.png", inventory_image = "3d_armor_inv_boots_leather.png",
groups = {armor_feet=1, mcl_armor_points=1, mcl_armor_uses=66}, groups = {armor_feet=1, mcl_armor_points=1, mcl_armor_uses=66},
_repair_material = "mcl_mobitems:leather", _repair_material = "mcl_mobitems:leather",
sounds = {
_mcl_armor_equip = "3d_armor_equip_leather",
_mcl_armor_unequip = "3d_armor_unequip_leather",
},
}) })
minetest.register_tool("3d_armor:boots_iron", { minetest.register_tool("3d_armor:boots_iron", {
@ -163,6 +215,10 @@ minetest.register_tool("3d_armor:boots_iron", {
inventory_image = "3d_armor_inv_boots_iron.png", inventory_image = "3d_armor_inv_boots_iron.png",
groups = {armor_feet=1, mcl_armor_points=2, mcl_armor_uses=196}, groups = {armor_feet=1, mcl_armor_points=2, mcl_armor_uses=196},
_repair_material = "mcl_core:iron_ingot", _repair_material = "mcl_core:iron_ingot",
sounds = {
_mcl_armor_equip = "3d_armor_equip_iron",
_mcl_armor_unequip = "3d_armor_unequip_iron",
},
}) })
minetest.register_tool("3d_armor:boots_gold", { minetest.register_tool("3d_armor:boots_gold", {
@ -181,6 +237,10 @@ minetest.register_tool("3d_armor:boots_diamond",{
inventory_image = "3d_armor_inv_boots_diamond.png", inventory_image = "3d_armor_inv_boots_diamond.png",
groups = {armor_feet=1, mcl_armor_points=3, mcl_armor_uses=430, mcl_armor_toughness=2}, groups = {armor_feet=1, mcl_armor_points=3, mcl_armor_uses=430, mcl_armor_toughness=2},
_repair_material = "mcl_core:diamond", _repair_material = "mcl_core:diamond",
sounds = {
_mcl_armor_equip = "3d_armor_equip_diamond",
_mcl_armor_unequip = "3d_armor_unequip_diamond",
},
}) })
minetest.register_tool("3d_armor:boots_chain", { minetest.register_tool("3d_armor:boots_chain", {
@ -190,6 +250,10 @@ minetest.register_tool("3d_armor:boots_chain", {
inventory_image = "3d_armor_inv_boots_chain.png", inventory_image = "3d_armor_inv_boots_chain.png",
groups = {armor_feet=1, mcl_armor_points=1, mcl_armor_uses=196}, groups = {armor_feet=1, mcl_armor_points=1, mcl_armor_uses=196},
_repair_material = "mcl_core:iron_ingot", _repair_material = "mcl_core:iron_ingot",
sounds = {
_mcl_armor_equip = "3d_armor_equip_chainmail",
_mcl_armor_unequip = "3d_armor_unequip_chainmail",
},
}) })
-- Register Craft Recipies -- Register Craft Recipies