Make vampirism and extra health perks affect max health.

This commit is contained in:
IQuant 2024-06-30 18:09:09 +03:00
parent 4a61bffa9b
commit 6fea0d22c2
6 changed files with 69 additions and 1 deletions

View file

@ -0,0 +1,8 @@
- ABILITY_ACTIONS_MATERIALIZED
- RESPAWN
- TELEKINESIS
- SAVING_GRACE
- INVISIBILITY (because stains aren't synced)
- CORDYCEPS
- HOMUNCULUS

View file

@ -34,13 +34,22 @@ function rpc_base.opts_reliable()
rpc_inner.opts.reliable = true
end
-- Also call rpc on client who initiated it.
function rpc_base.opts_everywhere()
rpc_inner.opts.everywhere = true
end
local rpc_meta = {
__newindex = function (t, k, v)
table.insert(rpc_inner.rpcs, v)
local index = #rpc_inner.rpcs
local reliable = rpc_inner.opts.reliable == true
local everywhere = rpc_inner.opts.everywhere == true
rawset(t, k, function(...)
net.send(index, {...}, reliable)
if everywhere then
v(...)
end
end)
net_handling.mod[index] = function(peer_id, args)
ctx.rpc_peer_id = peer_id

View file

@ -3,9 +3,16 @@ local util = dofile_once("mods/quant.ew/files/src/util.lua")
local perk_fns = {}
-- Which perks we do not add to clients.
local perks_to_ignore = {
GAMBLE = true,
GAMBLE = true, -- Tends to get readded, causing players to get a lot of random perks.
-- Doesn't make sense to duplicate those to clients.
PERKS_LOTTERY = true,
REMOVE_FOG_OF_WAR = true,
MEGA_BEAM_STONE = true,
-- TODO: Needs extra work to work correctly
-- NO_MORE_SHUFFLE = true,
-- UNLIMITED_SPELLS = true,
}
function perk_fns.get_my_perks()

View file

@ -0,0 +1,22 @@
local function patch_perk(perk_id, fn, ignore_original_func)
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)
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
patch_perk("EXTRA_HP", function(entity_perk_item, entity_who_picked)
if EntityHasTag(entity_who_picked, "player_unit") then
CrossCall("ew_perks_modify_max_hp", 1.5, true)
end
end)
patch_perk("VAMPIRISM", function(entity_perk_item, entity_who_picked)
if EntityHasTag(entity_who_picked, "player_unit") then
CrossCall("ew_perks_modify_max_hp", 0.75)
end
end, true)

View file

@ -4,9 +4,30 @@ local net = dofile_once("mods/quant.ew/files/src/net.lua")
local player_fns = dofile_once("mods/quant.ew/files/src/player_fns.lua")
local np = require("noitapatcher")
local rpc = net.new_rpc_namespace()
local module = {}
ModLuaFileAppend("data/scripts/perks/perk_list.lua", "mods/quant.ew/files/src/system/perk_patches/append/perk_list.lua")
rpc.opts_reliable()
rpc.opts_everywhere()
function rpc.modify_max_hp(percent_amount, do_heal)
if ctx.is_host then
local player_count = tonumber(GlobalsGetValue("ew_player_count", "1"))
local health = ctx.cap.health
local max_hp = health.max_health()
health.set_max_health(max_hp + max_hp / player_count * (percent_amount-1))
if do_heal then
local hp = health.health()
health.set_health(hp + max_hp / player_count * (percent_amount-1))
end
if health.health() > health.max_health() then
health.set_health(health.max_health())
end
end
end
np.CrossCallAdd("ew_perks_modify_max_hp", rpc.modify_max_hp)
return module

View file

@ -52,6 +52,7 @@ local function load_modules()
ctx.dofile_and_add_hooks("mods/quant.ew/files/src/system/heart_pickups/sync.lua")
ctx.dofile_and_add_hooks("mods/quant.ew/files/src/system/spawn_hooks/init.lua")
ctx.dofile_and_add_hooks("mods/quant.ew/files/src/system/proxy_info.lua")
ctx.dofile_and_add_hooks("mods/quant.ew/files/src/system/perk_patches/init.lua")
end
function OnProjectileFired(shooter_id, projectile_id, initial_rng, position_x, position_y, target_x, target_y, send_message,