Add shields

This commit is contained in:
NO411 2022-01-06 18:22:08 +01:00
parent 4dce90543d
commit aa8f4723a5
58 changed files with 538 additions and 52 deletions

View File

@ -88,6 +88,10 @@ for k,v in pairs(mcl_banners.colors) do
colors_reverse["mcl_banners:banner_item_"..v[1]] = k
end
function mcl_banners.color_reverse(itemname)
return colors_reverse[itemname]
end
-- Add pattern/emblazoning crafting recipes
dofile(modpath.."/patterncraft.lua")
@ -149,7 +153,7 @@ local function on_destruct_hanging_banner(pos)
return on_destruct_banner(pos, true)
end
local function make_banner_texture(base_color, layers)
function mcl_banners.make_banner_texture(base_color, layers)
local colorize
if mcl_banners.colors[base_color] then
colorize = mcl_banners.colors[base_color][4]
@ -171,11 +175,11 @@ local function make_banner_texture(base_color, layers)
finished_banner = finished_banner .. "^" .. layer
end
return { finished_banner }
return finished_banner
end
return { base }
return base
else
return { "mcl_banners_banner_base.png" }
return "mcl_banners_banner_base.png"
end
end
@ -192,7 +196,7 @@ local function spawn_banner_entity(pos, hanging, itemstack)
local imeta = itemstack:get_meta()
local layers_raw = imeta:get_string("layers")
local layers = minetest.deserialize(layers_raw)
local colorid = colors_reverse[itemstack:get_name()]
local colorid = mcl_banners.color_reverse(itemstack:get_name())
banner:get_luaentity():_set_textures(colorid, layers)
local mname = imeta:get_string("name")
if mname and mname ~= "" then
@ -604,7 +608,7 @@ local entity_standing = {
visual = "mesh",
mesh = "amc_banner.b3d",
visual_size = { x=2.499, y=2.499 },
textures = make_banner_texture(),
textures = {mcl_banners.make_banner_texture()},
pointable = false,
_base_color = nil, -- base color of banner
@ -624,7 +628,7 @@ local entity_standing = {
self._layers = inp._layers
self._name = inp._name
self.object:set_properties({
textures = make_banner_texture(self._base_color, self._layers),
textures = {mcl_banners.make_banner_texture(self._base_color, self._layers)},
})
end
-- Make banner slowly swing
@ -635,7 +639,7 @@ local entity_standing = {
-- Set the banner textures. This function can be used by external mods.
-- Meaning of parameters:
-- * self: Lua entity reference to entity.
-- * other parameters: Same meaning as in make_banner_texture
-- * other parameters: Same meaning as in mcl_banners.make_banner_texture
_set_textures = function(self, base_color, layers)
if base_color then
self._base_color = base_color
@ -643,7 +647,7 @@ local entity_standing = {
if layers then
self._layers = layers
end
self.object:set_properties({textures = make_banner_texture(self._base_color, self._layers)})
self.object:set_properties({textures = {mcl_banners.make_banner_texture(self._base_color, self._layers)}})
end,
}
minetest.register_entity("mcl_banners:standing_banner", entity_standing)

View File

@ -74,6 +74,7 @@ local ARROW_ENTITY={
_shooter=nil, -- ObjectRef of player or mob who shot it
_is_arrow = true,
_in_player = false,
_blocked = false,
_viscosity=0, -- Viscosity of node the arrow is currently in
_deflection_cooloff=0, -- Cooloff timer after an arrow deflection, to prevent many deflections in quick succession
}
@ -248,50 +249,55 @@ function ARROW_ENTITY.on_step(self, dtime)
-- Punch target object but avoid hurting enderman.
if not lua or lua.name ~= "mobs_mc:enderman" then
if self._in_player == false then
if not self._in_player then
damage_particles(self.object:get_pos(), self._is_critical)
end
if mcl_burning.is_burning(self.object) then
mcl_burning.set_on_fire(obj, 5)
end
if self._in_player == false then
if not self._in_player and not self._blocked then
obj:punch(self.object, 1.0, {
full_punch_interval=1.0,
damage_groups={fleshy=self._damage},
}, self.object:get_velocity())
if obj:is_player() then
local placement
self._placement = math.random(1, 2)
if self._placement == 1 then
placement = "front"
if not mcl_shields.is_blocking(obj) then
local placement
self._placement = math.random(1, 2)
if self._placement == 1 then
placement = "front"
else
placement = "back"
end
self._in_player = true
if self._placement == 2 then
self._rotation_station = 90
else
self._rotation_station = -90
end
self._y_position = random_arrow_positions("y", placement)
self._x_position = random_arrow_positions("x", placement)
if self._y_position > 6 and self._x_position < 2 and self._x_position > -2 then
self._attach_parent = "Head"
self._y_position = self._y_position - 6
elseif self._x_position > 2 then
self._attach_parent = "Arm_Right"
self._y_position = self._y_position - 3
self._x_position = self._x_position - 2
elseif self._x_position < -2 then
self._attach_parent = "Arm_Left"
self._y_position = self._y_position - 3
self._x_position = self._x_position + 2
else
self._attach_parent = "Body"
end
self._z_rotation = math.random(-30, 30)
self._y_rotation = math.random( -30, 30)
self.object:set_attach(obj, self._attach_parent, {x=self._x_position,y=self._y_position,z=random_arrow_positions("z", placement)}, {x=0,y=self._rotation_station + self._y_rotation,z=self._z_rotation})
else
placement = "back"
self._blocked = true
self.object:set_velocity(vector.multiply(self.object:get_velocity(), -0.25))
end
self._in_player = true
if self._placement == 2 then
self._rotation_station = 90
else
self._rotation_station = -90
end
self._y_position = random_arrow_positions("y", placement)
self._x_position = random_arrow_positions("x", placement)
if self._y_position > 6 and self._x_position < 2 and self._x_position > -2 then
self._attach_parent = "Head"
self._y_position = self._y_position - 6
elseif self._x_position > 2 then
self._attach_parent = "Arm_Right"
self._y_position = self._y_position - 3
self._x_position = self._x_position - 2
elseif self._x_position < -2 then
self._attach_parent = "Arm_Left"
self._y_position = self._y_position - 3
self._x_position = self._x_position + 2
else
self._attach_parent = "Body"
end
self._z_rotation = math.random(-30, 30)
self._y_rotation = math.random( -30, 30)
self.object:set_attach(obj, self._attach_parent, {x=self._x_position,y=self._y_position,z=random_arrow_positions("z", placement)}, {x=0,y=self._rotation_station + self._y_rotation,z=self._z_rotation})
minetest.after(150, function()
self.object:remove()
end)
@ -301,7 +307,7 @@ function ARROW_ENTITY.on_step(self, dtime)
if is_player then
if self._shooter and self._shooter:is_player() and self._in_player == false then
if self._shooter and self._shooter:is_player() and not self._in_player and not self._blocked then
-- “Ding” sound for hitting another player
minetest.sound_play({name="mcl_bows_hit_player", gain=0.1}, {to_player=self._shooter:get_player_name()}, true)
end
@ -318,7 +324,8 @@ function ARROW_ENTITY.on_step(self, dtime)
end
end
end
if self._in_player == false then
if not self._in_player and not self._blocked then
minetest.sound_play({name="mcl_bows_hit_other", gain=0.3}, {pos=self.object:get_pos(), max_hear_distance=16}, true)
end
end

View File

@ -1,6 +1,6 @@
name = mcl_bows
author = Arcelmi
description = This mod adds bows and arrows for MineClone 2.
depends = controls, mcl_particles, mcl_enchanting, mcl_init
depends = controls, mcl_particles, mcl_enchanting, mcl_init, mcl_shields
optional_depends = awards, mcl_achievements, mcl_core, mcl_mobitems, playerphysics, doc, doc_identifier, mesecons_button

View File

@ -0,0 +1,311 @@
local minetest, math, vector = minetest, math, vector
local modname = minetest.get_current_modname()
local S = minetest.get_translator(modname)
mcl_shields = {
types = {
mob = true,
player = true,
arrow = true,
generic = true,
explosion = true, -- ghasts don't work
dragon_breath = true,
},
enchantments = {"mending", "unbreaking"},
player_shields = {},
}
local interact_priv = minetest.registered_privileges.interact
interact_priv.give_to_singleplayer = false
interact_priv.give_to_admin = false
local overlay = mcl_enchanting.overlay
local hud = "mcl_shield_hud.png"
minetest.register_tool("mcl_shields:shield",{
description = S("Shield"),
_doc_items_longdesc = S("A shield is a tool used for protecting the player against attacks."),
inventory_image = "mcl_shield.png",
stack_max = 1,
groups = {shield = 1, weapon = 1, enchantability = 1, no_wieldview = 1},
sound = {breaks = "default_tool_breaks"},
_repair_material = "group:wood",
wield_scale = {x = 2, y = 2, z = 2},
})
local function wielded_item(obj)
return obj:get_wielded_item():get_name()
end
local function wielding_shield(obj)
return wielded_item(obj):find("mcl_shields:shield")
end
local function shield_is_enchanted(obj)
return wielding_shield(obj) and wielded_item(obj):find("_enchanted")
end
minetest.register_entity("mcl_shields:shield_entity", {
initial_properties = {
visual = "mesh",
mesh = "mcl_shield.obj",
physical = false,
pointable = false,
collide_with_objects = false,
textures = {"mcl_shield_base_nopattern.png"},
visual_size = vector.new(1, 1, 1),
},
_blocking = false,
on_step = function(self, dtime, moveresult)
local player = self.object:get_attach()
if player then
local shield_texture = "mcl_shield_base_nopattern.png"
if wielded_item(player) ~= "mcl_shields:shield" and wielded_item(player) ~= "mcl_shields:shield_enchanted" then
local meta_texture = player:get_wielded_item():get_meta():get_string("mcl_shields:shield_custom_pattern_texture")
if meta_texture ~= "" then
shield_texture = meta_texture
else
local color = minetest.registered_items[wielded_item(player)]._shield_color
if color then
shield_texture = "mcl_shield_base_nopattern.png^(mcl_shield_pattern_base.png^[colorize:" .. color .. ")"
end
end
end
if shield_is_enchanted(player) then
shield_texture = shield_texture .. overlay
end
self.object:set_properties({textures = {shield_texture}})
else
self.object:remove()
end
end,
})
for _, e in pairs(mcl_shields.enchantments) do
mcl_enchanting.enchantments[e].secondary.shield = true
end
function mcl_shields.is_blocking(obj)
if not obj then return end
local shield = mcl_shields.player_shields[obj]
if shield then
return shield:get_luaentity()._blocking
end
end
mcl_damage.register_modifier(function(obj, damage, reason)
local type = reason.type
local damager = reason.direct
minetest.chat_send_all(dump(damager))
if obj:is_player() and mcl_shields.is_blocking(obj) and mcl_shields.types[type] and damager then
local entity = damager:get_luaentity()
if entity and (type == "arrow" or type == "generic") then
damager = entity._shooter
end
if vector.dot(obj:get_look_dir(), vector.subtract(damager:get_pos(), obj:get_pos())) >= 0 then
local item = obj:get_wielded_item()
local durability = 336
local unbreaking = mcl_enchanting.get_enchantment(item, mcl_shields.enchantments[2])
if unbreaking > 0 then
durability = durability * (unbreaking + 1)
end
if not minetest.is_creative_enabled(obj:get_player_name()) and damage >= 3 then
item:add_wear(65535 / durability)
end
minetest.sound_play({name = "mcl_block"})
obj:set_wielded_item(item)
return 0
end
end
end)
local function modify_shield(player, vpos, vrot)
mcl_shields.player_shields[player]:set_attach(player, "Arm_Right", vpos, vrot, false)
end
local function set_shield(player, block)
if block then
modify_shield(player, vector.new(-8, 4, -3), vector.new(80, 80, 0))
else
modify_shield(player, vector.new(3, -5, 0), vector.new(0, 0, 0))
end
mcl_shields.player_shields[player]:get_luaentity()._blocking = block
end
local shield_hud = {}
local function set_interact(player, interact)
local player_name = player:get_player_name()
local privs = minetest.get_player_privs(player_name)
privs.interact = interact
minetest.set_player_privs(player_name, privs)
end
local function remove_shield_hud(player)
if shield_hud[player] then
player:hud_remove(shield_hud[player])
shield_hud[player] = nil
player:hud_set_flags({wielditem = true})
playerphysics.remove_physics_factor(player, "speed", "shield_speed")
set_interact(player, true)
set_shield(player, false)
end
end
local function add_shield(player)
local shield = minetest.add_entity(player:get_pos(), "mcl_shields:shield_entity")
mcl_shields.player_shields[player] = shield
set_shield(player, false)
end
local function update_shield(player)
if wielding_shield(player) and player:get_player_control().RMB then
if shield_hud[player] then
local image = player:hud_get(shield_hud[player]).text
if shield_is_enchanted(player) and image == hud then
player:hud_change(shield_hud[player], "text", hud .. overlay)
elseif not shield_is_enchanted(player) and image == hud .. overlay then
player:hud_change(shield_hud[player], "text", hud)
end
else
minetest.after(0.25, function()
if player and not shield_hud[player] and wielding_shield(player) and
player:get_player_control().RMB and mcl_shields.player_shields[player] then
local texture = hud
if shield_is_enchanted(player) then
texture = texture .. overlay
end
shield_hud[player] = player:hud_add({
hud_elem_type = "image",
position = {x = 0.5, y = 0.5},
scale = {x = -101, y = -101},
text = texture,
})
player:hud_set_flags({wielditem = false})
playerphysics.add_physics_factor(player, "speed", "shield_speed", 0.5)
set_shield(player, true)
set_interact(player, nil)
end
end)
end
else
remove_shield_hud(player)
end
end
local function remove_shield(player)
local shield = mcl_shields.player_shields[player]
if shield then
shield:remove()
mcl_shields.player_shields[player] = nil
end
end
minetest.register_globalstep(function(dtime)
for _, player in pairs(minetest.get_connected_players()) do
local player_shield = mcl_shields.player_shields[player]
if wielding_shield(player) then
if not player_shield then
add_shield(player)
else
update_shield(player)
end
elseif not wielding_shield(player) and player_shield then
remove_shield_hud(player)
remove_shield(player)
end
end
end)
minetest.register_on_dieplayer(function(player)
if not minetest.settings:get_bool("mcl_keepInventory") then
remove_shield_hud(player)
remove_shield(player)
end
end)
minetest.register_on_leaveplayer(function(player)
shield_hud[player] = nil
mcl_shields.player_shields[player] = nil
end)
minetest.register_craft({
output = "mcl_shields:shield",
recipe = {
{"group:wood", "mcl_core:iron_ingot", "group:wood"},
{"group:wood", "group:wood", "group:wood"},
{"", "group:wood", ""},
}
})
for _, colortab in pairs(mcl_banners.colors) do
minetest.register_tool("mcl_shields:shield_" .. colortab[1],{
description = S(colortab[6] .. " Shield"),
_doc_items_longdesc = S("A shield is a tool used for protecting the player against attacks."),
inventory_image = "mcl_shield.png^(mcl_shield_item_overlay.png^[colorize:" .. colortab[4] ..")",
stack_max = 1,
groups = {shield = 1, weapon = 1, enchantability = 1, no_wieldview = 1, not_in_creative_inventory = 1},
sound = {breaks = "default_tool_breaks"},
_repair_material = "group:wood",
wield_scale = {x = 2, y = 2, z = 2},
_shield_color = colortab[4],
})
local banner = "mcl_banners:banner_item_" .. colortab[1]
minetest.register_craft({
type = "shapeless",
output = "mcl_shields:shield_" .. colortab[1],
recipe = {"mcl_shields:shield", banner},
})
end
local function to_shield_texture(banner_texture)
return banner_texture
:gsub("mcl_banners_base_inverted.png", "mcl_shield_base_nopattern.png^mcl_shield_pattern_base.png")
:gsub("mcl_banners_banner_base.png", "mcl_shield_base_nopattern.png^mcl_shield_pattern_base.png")
:gsub("mcl_banners_base", "mcl_shield_pattern_base")
:gsub("mcl_banners", "mcl_shield_pattern")
end
local function craft_banner_on_shield(itemstack, player, old_craft_grid, craft_inv)
if string.find(itemstack:get_name(), "mcl_shields:shield_") then
local shield_stack
for i = 1, player:get_inventory():get_size("craft") do
local stack = old_craft_grid[i]
local name = stack:get_name()
if name == "mcl_shields:shield" then
shield_stack = stack
break
end
end
for i = 1, player:get_inventory():get_size("craft") do
local banner_stack = old_craft_grid[i]
local banner_name = banner_stack:get_name()
if string.find(banner_name, "mcl_banners:banner") and shield_stack then
local banner_meta = banner_stack:get_meta()
local layers_meta = banner_meta:get_string("layers")
if layers_meta ~= "" then
local color = mcl_banners.color_reverse(banner_name)
local layers = minetest.deserialize(layers_meta)
local texture = mcl_banners.make_banner_texture(color, layers)
itemstack:get_meta():set_string("mcl_shields:shield_custom_pattern_texture", to_shield_texture(texture))
end
itemstack:set_wear(shield_stack:get_wear())
break
end
end
end
return itemstack
end
minetest.register_craft_predict(function(itemstack, player, old_craft_grid, craft_inv)
return craft_banner_on_shield(itemstack, player, old_craft_grid, craft_inv)
end)
minetest.register_on_craft(function(itemstack, player, old_craft_grid, craft_inv)
return craft_banner_on_shield(itemstack, player, old_craft_grid, craft_inv)
end)

View File

@ -0,0 +1,19 @@
# textdomain: mcl_shields
Shield=Schild
A shield is a tool used for protecting the player against attacks.=Der Schild ist eine Schutzwaffe, die den Spieler vor Angriffen schützt.
White Shield=Weißer Schild
Grey Shield=Grauer Schild
Light Grey Shield=Hellgrauer Schild
Black Shield=Schwarzer Schild
Red Shield=Roter Schild
Yellow Shield=Gelber Schild
Green Shield=Grüner Schild
Cyan Shield=Türkiser Schild
Blue Shield=Blauer Schild
Magenta Shield=Magenta Schild
Orange Shield=Oranger Schild
Purple Shield=Violetter Schild
Brown Shield=Brauner Schild
Pink Shield=Rosa Schild
Lime Shield=Hellgrüner Schild
Light Blue Shield=Hellblauer Schild

View File

@ -0,0 +1,19 @@
# textdomain: mcl_shields
Shield=
A shield is a tool used for protecting the player against attacks.=
White Shield=
Grey Shield=
Light Grey Shield=
Black Shield=
Red Shield=
Yellow Shield=
Green Shield=
Cyan Shield=
Blue Shield=
Magenta Shield=
Orange Shield=
Purple Shield=
Brown Shield=
Pink Shield=
Lime Shield=
Light Blue Shield=

View File

@ -0,0 +1,3 @@
name = mcl_shields
author = NO11
depends = mcl_damage, mcl_enchanting, mcl_banners, playerphysics

View File

@ -0,0 +1,12 @@
# Blender MTL File: 'None'
# Material Count: 1
newmtl Material.002
Ns 323.999994
Ka 1.000000 1.000000 1.000000
Kd 0.800000 0.800000 0.800000
Ks 0.500000 0.500000 0.500000
Ke 0.000000 0.000000 0.000000
Ni 1.450000
d 1.000000
illum 2

View File

@ -0,0 +1,88 @@
# Blender v3.0.0 OBJ File: ''
# www.blender.org
mtllib mcl_shield.mtl
o Cube.002_Cube.003
v 4.663009 11.096291 6.387994
v 4.663009 4.596560 5.241916
v 5.213008 4.596560 5.241916
v 5.213008 11.096291 6.387994
v 5.213007 13.197435 -5.528180
v 5.213007 6.697705 -6.674258
v 4.663008 6.697705 -6.674258
v 4.663008 13.197435 -5.528180
v 4.663008 8.641873 -1.863572
v 4.663008 8.068833 1.386293
v 1.363008 8.068833 1.386294
v 1.363008 8.641873 -1.863572
v 1.363008 9.152122 1.577307
v 1.363008 9.725162 -1.672559
v 4.663008 9.152122 1.577306
v 4.663008 9.725162 -1.672559
vt 0.015625 0.984375
vt 0.203125 0.984375
vt 0.203125 1.000000
vt 0.015625 1.000000
vt 0.203125 0.640625
vt 0.203125 0.984375
vt 0.015625 0.984375
vt 0.015625 0.640625
vt 0.015625 0.984375
vt 0.015625 0.640625
vt -0.000000 0.640625
vt -0.000000 0.984375
vt 0.203125 0.984375
vt 0.390625 0.984375
vt 0.390625 1.000000
vt 0.203125 1.000000
vt 0.203125 0.984375
vt 0.203125 0.640625
vt 0.218750 0.640625
vt 0.218750 0.984375
vt 0.406250 0.640625
vt 0.406250 0.984375
vt 0.218750 0.984375
vt 0.218750 0.640625
vt 0.531250 0.812500
vt 0.625000 0.812500
vt 0.625000 0.906250
vt 0.531250 0.906250
vt 0.500000 0.906250
vt 0.500000 0.812500
vt 0.531250 0.812500
vt 0.531250 0.906250
vt 0.406250 0.812500
vt 0.500000 0.812500
vt 0.500000 0.906250
vt 0.406250 0.906250
vt 0.625000 0.812500
vt 0.656250 0.812500
vt 0.656250 0.906250
vt 0.625000 0.906250
vt 0.562500 1.000000
vt 0.531250 1.000000
vt 0.531250 0.906250
vt 0.562500 0.906250
vt 0.531250 1.000000
vt 0.500000 1.000000
vt 0.500000 0.906250
vt 0.531250 0.906250
vn 0.0000 -0.1736 0.9848
vn 1.0000 0.0000 -0.0000
vn 0.0000 -0.9848 -0.1736
vn 0.0000 0.1736 -0.9848
vn 0.0000 0.9848 0.1736
vn -1.0000 -0.0000 0.0000
usemtl Material.002
s 1
f 1/1/1 2/2/1 3/3/1 4/4/1
f 5/5/2 4/6/2 3/7/2 6/8/2
f 6/9/3 3/10/3 2/11/3 7/12/3
f 7/13/4 8/14/4 5/15/4 6/16/4
f 8/17/5 1/18/5 4/19/5 5/20/5
f 7/21/6 2/22/6 1/23/6 8/24/6
f 9/25/3 10/26/3 11/27/3 12/28/3
f 12/29/6 11/30/6 13/31/6 14/32/6
f 14/33/5 13/34/5 15/35/5 16/36/5
f 16/37/2 15/38/2 10/39/2 9/40/2
f 12/41/4 14/42/4 16/43/4 9/44/4
f 13/45/1 11/46/1 10/47/1 15/48/1

View File

@ -0,0 +1,12 @@
# Blender MTL File: 'shield.blend'
# Material Count: 1
newmtl Material
Ns 323.999994
Ka 1.000000 1.000000 1.000000
Kd 0.800000 0.800000 0.800000
Ks 0.500000 0.500000 0.500000
Ke 0.000000 0.000000 0.000000
Ni 1.450000
d 1.000000
illum 2

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 141 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 878 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

View File

@ -9,7 +9,7 @@ local animation_blend = 0
local function get_mouse_button(player)
local controls = player:get_player_control()
local get_wielded_item_name = player:get_wielded_item():get_name()
if controls.RMB and not string.find(get_wielded_item_name, "mcl_bows:bow") and not string.find(get_wielded_item_name, "mcl_bows:crossbow") or controls.LMB then
if controls.RMB and not string.find(get_wielded_item_name, "mcl_bows:bow") and not string.find(get_wielded_item_name, "mcl_bows:crossbow") and not string.find(get_wielded_item_name, "mcl_shields:shield") or controls.LMB then
return true
else
return false
@ -188,6 +188,9 @@ minetest.register_globalstep(function(dtime)
animation_speed_mod = animation_speed_mod / 2
end
if mcl_shields.is_blocking(player) then
animation_speed_mod = animation_speed_mod / 2
end
-- ask if player is swiming
@ -204,6 +207,9 @@ minetest.register_globalstep(function(dtime)
or walking and velocity.x < -0.35
or walking and velocity.z > 0.35
or walking and velocity.z < -0.35 then
local wielded_itemname = player:get_wielded_item():get_name()
local no_arm_moving = (string.find(wielded_itemname, "mcl_bows:bow") or string.find(wielded_itemname, "mcl_shields:shield"))
if player_sneak[name] ~= controls.sneak then
player_anim[name] = nil
player_sneak[name] = controls.sneak
@ -212,9 +218,9 @@ minetest.register_globalstep(function(dtime)
player_set_animation(player, "swim_walk_mine", animation_speed_mod)
elseif not controls.sneak and head_in_water and is_sprinting == true then
player_set_animation(player, "swim_walk", animation_speed_mod)
elseif string.find(player:get_wielded_item():get_name(), "mcl_bows:bow") and controls.RMB and controls.sneak or string.find(player:get_wielded_item():get_name(), "mcl_bows:crossbow_") and controls.sneak then
elseif no_arm_moving and controls.RMB and controls.sneak or string.find(wielded_itemname, "mcl_bows:crossbow_") and controls.sneak then
player_set_animation(player, "bow_sneak", animation_speed_mod)
elseif string.find(player:get_wielded_item():get_name(), "mcl_bows:bow") and controls.RMB or string.find(player:get_wielded_item():get_name(), "mcl_bows:crossbow_") then
elseif no_arm_moving and controls.RMB or string.find(wielded_itemname, "mcl_bows:crossbow_") then
player_set_animation(player, "bow_walk", animation_speed_mod)
elseif is_sprinting == true and get_mouse_button(player) == true and not controls.sneak and not head_in_water then
player_set_animation(player, "run_walk_mine", animation_speed_mod)

View File

@ -233,7 +233,9 @@ minetest.register_globalstep(function(dtime)
-- controls right and left arms pitch when shooting a bow
if string.find(wielded:get_name(), "mcl_bows:bow") and control.RMB then
if mcl_shields.is_blocking(player) then
player:set_bone_position("Arm_Right_Pitch_Control", vector.new(-3, 5.785,0), vector.new(20, -20, 0))
elseif string.find(wielded:get_name(), "mcl_bows:bow") and control.RMB then
player:set_bone_position("Arm_Right_Pitch_Control", vector.new(-3,5.785,0), vector.new(pitch+90,-30,pitch * -1 * .35))
player:set_bone_position("Arm_Left_Pitch_Control", vector.new(3.5,5.785,0), vector.new(pitch+90,43,pitch * .35))
-- controls right and left arms pitch when holing a loaded crossbow
@ -241,7 +243,7 @@ minetest.register_globalstep(function(dtime)
player:set_bone_position("Arm_Right_Pitch_Control", vector.new(-3,5.785,0), vector.new(pitch+90,-30,pitch * -1 * .35))
player:set_bone_position("Arm_Left_Pitch_Control", vector.new(3.5,5.785,0), vector.new(pitch+90,43,pitch * .35))
-- controls right and left arms pitch when loading a crossbow
elseif string.find(wielded:get_name(), "mcl_bows:crossbow_") then
elseif string.find(wielded:get_name(), "mcl_bows:crossbow_") then
player:set_bone_position("Arm_Right_Pitch_Control", vector.new(-3,5.785,0), vector.new(45,-20,25))
player:set_bone_position("Arm_Left_Pitch_Control", vector.new(3,5.785,0), vector.new(55,20,-45))
-- when punching

View File

@ -1,5 +1,4 @@
name = mcl_playerplus
author = TenPlus1
description = Adds some simple player-related gameplay effects: Hurt by touching a cactus, suffocation and more.
depends = mcl_init, mcl_core, mcl_particles, mcl_hunger, playerphysics, mcl_playerinfo, mcl_weather, mcl_spawn, mcl_enchanting, mcl_damage, mcl_sprint
depends = mcl_init, mcl_core, mcl_particles, mcl_hunger, playerphysics, mcl_playerinfo, mcl_weather, mcl_spawn, mcl_enchanting, mcl_damage, mcl_sprint, mcl_shields

View File

@ -6,7 +6,7 @@ mcl_wieldview = {
}
function mcl_wieldview.get_item_texture(itemname)
if itemname == "" then
if itemname == "" or minetest.get_item_group(itemname, "no_wieldview") ~= 0 then
return
end
@ -113,6 +113,10 @@ minetest.register_entity("mcl_wieldview:wieldnode", {
self.object:set_properties({textures = {""}})
end
if minetest.get_item_group(itemstring, "no_wieldview") ~= 0 then
self.object:set_properties({textures = {""}})
end
self.itemstring = itemstring
end
else