Add: lag counter to blocking

master
Coder12a 2021-02-10 19:25:00 -06:00
parent 9603208be5
commit 29f3468346
2 changed files with 72 additions and 0 deletions

View File

@ -335,6 +335,30 @@ function pvp_revamped.shield_inv(user, name, player_pdata, data)
on_block_activate(user)
end
local hitdata = data.hit
if hitdata then
local server_lag = pvp_revamped.lag + get_player_information(name).avg_jitter * 1000000
local timeframe = get_us_time() - server_lag
local count = #hitdata
for i = count, 1, -1 do
local hd = hitdata[i]
if hd.time >= timeframe then
user:set_hp(user:get_hp() + hd.damage)
hitdata[i] = hitdata[count]
hitdata[count] = nil
end
count = count - 1
end
data.hit = hitdata
end
return true
end

View File

@ -181,6 +181,30 @@ minetest.register_on_mods_loaded(function()
-- Disable the damage texture modifier on tool block.
user:set_properties{damage_texture_modifier = ""}
local hitdata = data.hit
if hitdata then
local server_lag = pvp_revamped.lag + get_player_information(name).avg_jitter * 1000000
local timeframe = get_us_time() - server_lag
local count = #hitdata
for i = count, 1, -1 do
local hd = hitdata[i]
if hd.time >= timeframe then
user:set_hp(user:get_hp() + hd.damage)
hitdata[i] = hitdata[count]
hitdata[count] = nil
end
count = count - 1
end
data.hit = hitdata
end
player_data[name] = data
end
@ -361,6 +385,30 @@ minetest.register_on_mods_loaded(function()
if on_block_activate then
on_block_activate(user)
end
local hitdata = data.hit
if hitdata then
local server_lag = pvp_revamped.lag + get_player_information(name).avg_jitter * 1000000
local timeframe = get_us_time() - server_lag
local count = #hitdata
for i = count, 1, -1 do
local hd = hitdata[i]
if hd.time >= timeframe then
user:set_hp(user:get_hp() + hd.damage)
hitdata[i] = hitdata[count]
hitdata[count] = nil
end
count = count - 1
end
data.hit = hitdata
end
end
minetest.override_item(k, {on_secondary_use = function(itemstack, user, pointed_thing)