Weapons have now a reloading sound

This commit is contained in:
Zughy 2020-11-12 19:50:58 +01:00
parent 058dc39036
commit 7645292170
5 changed files with 9 additions and 4 deletions

View File

@ -21,6 +21,7 @@ block_league.register_weapon("block_league:pixelgun", {
continuos_fire = false, continuos_fire = false,
sound_shoot = "bl_pixelgun_shoot", sound_shoot = "bl_pixelgun_shoot",
sound_reload = "bl_pixelgun_reload",
bullet_trail = { bullet_trail = {
image = "bl_pixelgun_trail.png", image = "bl_pixelgun_trail.png",
amount = 20, amount = 20,

View File

@ -20,6 +20,7 @@ block_league.register_weapon("block_league:smg", {
continuos_fire = true, continuos_fire = true,
sound_shoot = "bl_smg_shoot", sound_shoot = "bl_smg_shoot",
sound_reload = "bl_smg_reload",
bullet_trail = { bullet_trail = {
image = "bl_smg_trail.png", image = "bl_smg_trail.png",
amount = 5 amount = 5

View File

@ -41,6 +41,7 @@ function block_league.register_weapon(name, def)
continuos_fire = def.continuos_fire, continuos_fire = def.continuos_fire,
sound_shoot = def.sound_shoot, sound_shoot = def.sound_shoot,
sound_reload = def.sound_reload,
bullet_trail = def.bullet_trail, bullet_trail = def.bullet_trail,
consume_bullets = def.consume_bullets, consume_bullets = def.consume_bullets,
@ -65,7 +66,7 @@ function block_league.register_weapon(name, def)
-- Q = reload -- Q = reload
on_drop = function(itemstack, user, pointed_thing) on_drop = function(itemstack, user, pointed_thing)
weapon_reload(def, user) weapon_reload(user, def)
end end
}) })
@ -352,7 +353,7 @@ end
function weapon_reload(weapon, player) function weapon_reload(player, weapon)
local w_name = weapon.name local w_name = weapon.name
local p_name = player:get_player_name() local p_name = player:get_player_name()
@ -365,6 +366,8 @@ function weapon_reload(weapon, player)
or arena.players[p_name].weapons_magazine[w_name] == weapon.magazine or arena.players[p_name].weapons_magazine[w_name] == weapon.magazine
then return end then return end
minetest.sound_play(weapon.sound_reload, {to_player = p_name})
p_meta:set_int("bl_reloading", 1) p_meta:set_int("bl_reloading", 1)
player:set_physics_override({ player:set_physics_override({
@ -457,9 +460,9 @@ function update_magazine(player, weapon)
-- automatically reload if the magazine is now empty -- automatically reload if the magazine is now empty
if arena.players[p_name].weapons_magazine[w_name] == 0 and p_meta:get_int("bl_reloading") == 0 then if arena.players[p_name].weapons_magazine[w_name] == 0 and p_meta:get_int("bl_reloading") == 0 then
weapon_reload(weapon, player) weapon_reload(player, weapon)
end end
block_league.weapons_hud_update(arena, p_name, w_name) block_league.weapons_hud_update(arena, p_name, w_name)
end end

Binary file not shown.

BIN
sounds/bl_smg_reload.ogg Normal file

Binary file not shown.