Make shield perk calculate it's radius properly.

This commit is contained in:
IQuant 2024-08-26 14:20:33 +03:00
parent 4101da7e9e
commit 515ca94358
3 changed files with 23 additions and 3 deletions

View file

@ -1,6 +1,9 @@
dofile_once("data/scripts/perks/perk_list.lua")
local util = dofile_once("mods/quant.ew/files/core/util.lua")
local function lazyload()
dofile_once("data/scripts/perks/perk_list.lua")
end
local perk_fns = {}
-- Which perks we do not add to clients.
@ -23,6 +26,7 @@ local perks_to_ignore = {
}
function perk_fns.get_my_perks()
lazyload()
local perks = {}
for i=1, #perk_list do
local perk_flag_name = get_perk_picked_flag_name(perk_list[i].id)
@ -35,6 +39,7 @@ function perk_fns.get_my_perks()
end
local function give_one_perk(entity_who_picked, perk_info, count)
lazyload()
-- add game effect
if perk_info.game_effect ~= nil then
local game_effect_comp = GetGameEffectLoadTo( entity_who_picked, perk_info.game_effect, true )
@ -69,6 +74,7 @@ local function give_one_perk(entity_who_picked, perk_info, count)
end
function perk_fns.update_perks(perk_data, player_data)
lazyload()
local entity = player_data.entity
local current_counts = util.get_ent_variable(entity, "ew_current_perks") or {}
for perk_id, count in pairs(perk_data) do
@ -98,6 +104,7 @@ end
function perk_fns.update_perks_for_entity(perk_data, entity, allow_perk)
lazyload()
local current_counts = util.get_ent_variable(entity, "ew_current_perks") or {}
for perk_id, count in pairs(perk_data) do
local current = (current_counts[perk_id] or 0)

View file

@ -1,3 +1,11 @@
local function patch_perk_2(perk_id, fn)
local perk_data = get_perk_with_id(perk_list, perk_id)
local old_func = perk_data.func
perk_data.func = function(entity_perk_item, entity_who_picked, item_name, pickup_count)
fn(entity_perk_item, entity_who_picked, item_name, pickup_count, old_func)
end
end
local function hide_perk(perk_id)
local perk_data = get_perk_with_id(perk_list, perk_id)
perk_data.not_in_default_perk_pool = true
@ -9,3 +17,8 @@ hide_perk("CORDYCEPS")
hide_perk("HOMUNCULUS")
hide_perk("ATTACK_FOOT")
hide_perk("ANGRY_GHOST")
patch_perk_2("SHIELD", function(entity_perk_item, entity_who_picked, item_name, pickup_count, orig_fn)
GlobalsSetValue("PERK_SHIELD_COUNT", tostring(pickup_count-1))
orig_fn(entity_perk_item, entity_who_picked, item_name, pickup_count)
end)

View file

@ -2,10 +2,10 @@ local function patch_perk(perk_id, ignore_original_func, fn)
local perk_data = get_perk_with_id(perk_list, perk_id)
local old_func = perk_data.func
perk_data.func = function(entity_perk_item, entity_who_picked, item_name, pickup_count)
fn(entity_perk_item, entity_who_picked, item_name, pickup_count)
if not ignore_original_func then
old_func(entity_perk_item, entity_who_picked, item_name, pickup_count)
end
fn(entity_perk_item, entity_who_picked, item_name, pickup_count)
end
end