Headshot | pixelgun doesn't oneshot anymore (18 dmg)
parent
2959079b58
commit
82c1750800
1
init.lua
1
init.lua
|
@ -93,6 +93,7 @@ dofile(srcpath .. "/debug/testkit.lua")
|
|||
dofile(srcpath .. "/HUD/hud_achievements.lua")
|
||||
dofile(srcpath .. "/HUD/hud_broadcast.lua")
|
||||
dofile(srcpath .. "/HUD/hud_bullets.lua")
|
||||
dofile(srcpath .. "/HUD/hud_critical.lua")
|
||||
dofile(srcpath .. "/HUD/hud_energy.lua")
|
||||
dofile(srcpath .. "/HUD/hud_info_panel.lua")
|
||||
dofile(srcpath .. "/HUD/hud_inputs.lua")
|
||||
|
|
|
@ -40,6 +40,9 @@ You already are in test mode!=Sei già in modalità test!
|
|||
You've entered test mode=Sei entrato in modalità test
|
||||
You've left test mode=Sei uscito dalla modalità test
|
||||
|
||||
# HUD/hud_critical.lua
|
||||
CRITICAL!=CRITICO!
|
||||
|
||||
# HUD/hud_info_panel.lua
|
||||
TDs=TD
|
||||
Deaths=Morti
|
||||
|
|
|
@ -40,6 +40,9 @@ You already are in test mode!=
|
|||
You've entered test mode=
|
||||
You've left test mode=
|
||||
|
||||
# HUD/hud_critical.lua
|
||||
CRITICAL!=
|
||||
|
||||
# HUD/hud_info_panel.lua
|
||||
TDs=
|
||||
Deaths=
|
||||
|
|
Binary file not shown.
|
@ -0,0 +1,46 @@
|
|||
local S = minetest.get_translator("block_league")
|
||||
local saved_huds = {} -- p_name = {HUD_ID, display_ID}; utilizzo display_ID per controllare se il "Critical!" mostrato sia lo stesso di 1.5 secondi prima o meno
|
||||
|
||||
|
||||
|
||||
function block_league.HUD_critical_create(p_name)
|
||||
|
||||
local HUD = {
|
||||
hud_elem_type = "text",
|
||||
position = { x = 1, y = 0.5 },
|
||||
offset = { x = -25 },
|
||||
alignment = { x = -1 },
|
||||
text = "",
|
||||
size = { x = 4 },
|
||||
number = "0xe6482e"
|
||||
}
|
||||
local player = minetest.get_player_by_name(p_name)
|
||||
local HUD_ID = player:hud_add(HUD)
|
||||
|
||||
saved_huds[p_name] = {HUD_ID, 0}
|
||||
end
|
||||
|
||||
|
||||
|
||||
function block_league.HUD_critical_remove(p_name)
|
||||
minetest.get_player_by_name(p_name):hud_remove(saved_huds[p_name][1])
|
||||
saved_huds[p_name] = nil
|
||||
end
|
||||
|
||||
|
||||
|
||||
function block_league.HUD_critical_show(p_name)
|
||||
minetest.get_player_by_name(p_name):hud_change(saved_huds[p_name][1], "text", S("CRITICAL!"))
|
||||
saved_huds[p_name][2] = saved_huds[p_name][2] + 1
|
||||
|
||||
local display_ID = saved_huds[p_name][2]
|
||||
|
||||
minetest.after(1.5, function()
|
||||
if not arena_lib.is_player_in_arena(p_name, "block_league") then return end -- se è andato offline o uscito dalla partita
|
||||
|
||||
-- se nessun nuovo critico è apparso, faccio sparire
|
||||
if saved_huds[p_name][2] == display_ID then
|
||||
minetest.get_player_by_name(p_name):hud_change(saved_huds[p_name][1], "text", "")
|
||||
end
|
||||
end)
|
||||
end
|
|
@ -193,6 +193,7 @@ end
|
|||
|
||||
function create_and_show_HUD(arena, p_name, is_spectator)
|
||||
block_league.HUD_broadcast_create(p_name)
|
||||
block_league.HUD_critical_create(p_name)
|
||||
block_league.scoreboard_create(arena, p_name)
|
||||
block_league.hud_log_create(p_name)
|
||||
|
||||
|
@ -209,6 +210,7 @@ end
|
|||
|
||||
|
||||
function remove_HUD(p_name, is_spectator)
|
||||
block_league.HUD_critical_remove(p_name)
|
||||
panel_lib.get_panel(p_name, "bl_broadcast"):remove()
|
||||
panel_lib.get_panel(p_name, "bl_scoreboard"):remove()
|
||||
panel_lib.get_panel(p_name, "bl_log"):remove()
|
||||
|
|
|
@ -1,9 +1,36 @@
|
|||
function block_league.sound_play(sound, p_name)
|
||||
minetest.sound_play(sound, {to_player = p_name})
|
||||
local function stop_and_update_last_sound() end
|
||||
|
||||
local sounds = {} -- KEY: p_name; VALUE: { sounds_name = handle }
|
||||
|
||||
|
||||
|
||||
function block_league.sound_play(sound, p_name, not_overlappable)
|
||||
local handle = minetest.sound_play(sound, {to_player = p_name})
|
||||
|
||||
if not_overlappable then
|
||||
stop_and_update_last_sound(p_name, sound, handle)
|
||||
end
|
||||
|
||||
if arena_lib.is_player_spectated(p_name) then
|
||||
for sp_name, _ in pairs(arena_lib.get_player_spectators(p_name)) do
|
||||
minetest.sound_play(sound, {to_player = sp_name})
|
||||
handle = minetest.sound_play(sound, {to_player = sp_name})
|
||||
|
||||
if not_overlappable then
|
||||
stop_and_update_last_sound(sp_name, sound, handle)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
-- interrompi l'ultimo suono chiamato "sound" e lo aggiorna a quello passatogli
|
||||
function stop_and_update_last_sound(p_name, sound, handle)
|
||||
sounds[p_name] = sounds[p_name] or {}
|
||||
|
||||
if sounds[p_name][sound] then
|
||||
minetest.sound_stop(sounds[p_name][sound])
|
||||
end
|
||||
|
||||
sounds[p_name][sound] = handle
|
||||
end
|
||||
|
|
|
@ -29,7 +29,7 @@ local function register_bouncer(name, desc, energy)
|
|||
end
|
||||
|
||||
local dir = user:get_look_dir()
|
||||
local knockback = user:get_player_velocity().y < 1 and -15 or -10
|
||||
local knockback = user:get_velocity().y < 1 and -15 or -10
|
||||
|
||||
user:add_velocity(vector.multiply(dir, knockback))
|
||||
block_league.sound_play("bl_bouncer", p_name)
|
||||
|
|
|
@ -10,7 +10,7 @@ block_league.register_weapon("block_league:pixelgun", {
|
|||
|
||||
weapon_type = 1,
|
||||
|
||||
damage = 999,
|
||||
damage = 18,
|
||||
weapon_range = 150,
|
||||
knockback = 0,
|
||||
fire_delay = 0.9,
|
||||
|
|
|
@ -37,12 +37,12 @@ block_league.register_weapon("block_league:sword", {
|
|||
|
||||
dir.y = 0
|
||||
|
||||
local player_vel = user:get_player_velocity()
|
||||
local player_vel = user:get_velocity()
|
||||
local sprint = vector.multiply(dir,18)
|
||||
|
||||
user:add_player_velocity(sprint)
|
||||
user:add_velocity(sprint)
|
||||
player_vel = vector.multiply(player_vel, -0.7)
|
||||
user:add_player_velocity(player_vel)
|
||||
user:add_velocity(player_vel)
|
||||
user:set_physics_override({
|
||||
speed = 0.5,
|
||||
jump = 0
|
||||
|
|
|
@ -174,7 +174,11 @@ function block_league.get_pointed_players(head_pos, dir, range, user, particle,
|
|||
if hit.ref and hit.ref:is_player() then
|
||||
-- e non è colui che spara
|
||||
if hit.ref ~= user then
|
||||
table.insert(players, hit.ref)
|
||||
if (hit.intersection_point.y - hit.ref:get_pos().y) > 1.275 then
|
||||
table.insert(players, {player=hit.ref, headshot=true})
|
||||
else
|
||||
table.insert(players, {player=hit.ref, headshot=false})
|
||||
end
|
||||
end
|
||||
elseif hit.ref:get_luaentity() then
|
||||
local entity = hit.ref:get_luaentity()
|
||||
|
@ -193,16 +197,19 @@ function block_league.get_pointed_players(head_pos, dir, range, user, particle,
|
|||
-- se è un nodo mi fermo, e ritorno l'array se > 0 (ovvero ha trovato giocatori)
|
||||
if hit.type == "node" then
|
||||
if #players > 0 then
|
||||
if particle ~= nil then
|
||||
if not has_piercing then
|
||||
local impact_dist = get_dist(head_pos, players[1]:get_pos())
|
||||
draw_particles(particle, dir, p1, range, impact_dist)
|
||||
else
|
||||
if has_piercing then
|
||||
if particle ~= nil then
|
||||
local impact_dist = get_dist(head_pos, hit.intersection_point)
|
||||
draw_particles(particle, dir, p1, range, impact_dist)
|
||||
end
|
||||
return players
|
||||
else
|
||||
if particle ~= nil then
|
||||
local impact_dist = get_dist(head_pos, players[1].player:get_pos())
|
||||
draw_particles(particle, dir, p1, range, impact_dist)
|
||||
end
|
||||
return {players[1]}
|
||||
end
|
||||
return players
|
||||
else
|
||||
if particle ~= nil then
|
||||
local impact_dist = get_dist(head_pos, hit.intersection_point)
|
||||
|
@ -223,7 +230,7 @@ function block_league.get_pointed_players(head_pos, dir, range, user, particle,
|
|||
return players
|
||||
else
|
||||
if particle ~= nil then
|
||||
local impact_dist = get_dist(head_pos, players[1]:get_pos())
|
||||
local impact_dist = get_dist(head_pos, players[1].player:get_pos())
|
||||
draw_particles(particle, dir, p1, range, impact_dist)
|
||||
end
|
||||
return {players[1]}
|
||||
|
@ -243,7 +250,7 @@ function block_league.apply_damage(user, targets, weapon, decrease_damage_with_d
|
|||
|
||||
local damage = weapon.damage
|
||||
local knockback = weapon.knockback
|
||||
|
||||
|
||||
local p_name = user:get_player_name()
|
||||
local arena = arena_lib.get_arena_by_player(p_name)
|
||||
local killed_players = 0
|
||||
|
@ -259,6 +266,9 @@ function block_league.apply_damage(user, targets, weapon, decrease_damage_with_d
|
|||
-- per ogni giocatore colpito
|
||||
for _, target in pairs(targets) do
|
||||
|
||||
headshot = target.headshot
|
||||
target = target.player
|
||||
|
||||
if target:get_hp() <= 0 then return end
|
||||
if target:get_meta():get_int("bl_immunity") == 1 then return end
|
||||
|
||||
|
@ -270,9 +280,17 @@ function block_league.apply_damage(user, targets, weapon, decrease_damage_with_d
|
|||
-- eventuale knockback
|
||||
if knockback > 0 and knockback_dir then
|
||||
local knk= vector.multiply(knockback_dir,knockback)
|
||||
target:add_player_velocity(knk)
|
||||
target:add_velocity(knk)
|
||||
end
|
||||
|
||||
-- eventuale headshot
|
||||
if headshot and weapon.type ~= 3 then
|
||||
damage = damage * 1.5
|
||||
block_league.HUD_critical_show(p_name)
|
||||
block_league.sound_play("bl_hit_critical", p_name, "not_overlappable")
|
||||
end
|
||||
|
||||
-- eventuale danno decrementato a seconda della distanza
|
||||
if weapon.weapon_type == 1 and decrease_damage_with_distance then
|
||||
local dist = get_dist(user:get_pos(), target:get_pos())
|
||||
local damage = damage - (damage * dist / weapon.weapon_range)
|
||||
|
@ -584,8 +602,8 @@ function check_weapon_type_and_attack(player, weapon, pointed_thing)
|
|||
|
||||
else
|
||||
if pointed_thing.type ~= "object" or not pointed_thing.ref:is_player() then return end
|
||||
|
||||
block_league.apply_damage(player, pointed_thing.ref, weapon, false, player:get_look_dir())
|
||||
local target = {{player = pointed_thing.ref, headshot = false}}
|
||||
block_league.apply_damage(player, target, weapon, false, player:get_look_dir())
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue