mirror of
https://github.com/IntQuant/noita_entangled_worlds.git
synced 2025-10-19 15:13:16 +00:00
fix poly resetting wand fire counts
This commit is contained in:
parent
515ca94358
commit
16bc21332e
4 changed files with 25 additions and 5 deletions
|
@ -58,7 +58,7 @@ function rpc.add_nickname(id)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function remove_healthbar_locally()
|
local function remove_healthbar_locally()
|
||||||
local player_components = EntityGetAllComponents(ctx.my_player.entity)
|
local player_components = EntityGetAllComponents(ctx.my_player.entity)
|
||||||
if player_components ~= nil then
|
if player_components ~= nil then
|
||||||
for _, comp in ipairs(player_components) do
|
for _, comp in ipairs(player_components) do
|
||||||
|
|
|
@ -29,7 +29,8 @@ function wandfinder.find_attack_wand(dont_do)
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
local largest = {-1, -1}
|
local largest = {-1, -1}
|
||||||
for entity, fire_count in pairs(ctx.my_player.wand_fire_count) do
|
for entity, tuple in pairs(ctx.my_player.wand_fire_count) do
|
||||||
|
local fire_count, _ = tuple[1], tuple[2]
|
||||||
for _, wand in ipairs(wands) do
|
for _, wand in ipairs(wands) do
|
||||||
if wand == entity then
|
if wand == entity then
|
||||||
goto here
|
goto here
|
||||||
|
@ -48,4 +49,20 @@ function wandfinder.find_attack_wand(dont_do)
|
||||||
return largest[1]
|
return largest[1]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function wandfinder.set_wands_after_poly()
|
||||||
|
local wands = get_all_wands({})
|
||||||
|
for entity, tuple in pairs(ctx.my_player.wand_fire_count) do
|
||||||
|
local _, slot = tuple[1], tuple[2]
|
||||||
|
for _, wand in ipairs(wands) do
|
||||||
|
local item = EntityGetFirstComponentIncludingDisabled(wand, "ItemComponent")
|
||||||
|
local slot2 = ComponentGetValue2(item, "inventory_slot")
|
||||||
|
if slot == slot2 then
|
||||||
|
ctx.my_player.wand_fire_count[wand] = ctx.my_player.wand_fire_count[entity]
|
||||||
|
table.remove(ctx.my_player.wand_fire_count, entity)
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
return wandfinder
|
return wandfinder
|
|
@ -2,6 +2,7 @@ local util = dofile_once("mods/quant.ew/files/core/util.lua")
|
||||||
local ctx = dofile_once("mods/quant.ew/files/core/ctx.lua")
|
local ctx = dofile_once("mods/quant.ew/files/core/ctx.lua")
|
||||||
local net = dofile_once("mods/quant.ew/files/core/net.lua")
|
local net = dofile_once("mods/quant.ew/files/core/net.lua")
|
||||||
local player_fns = dofile_once("mods/quant.ew/files/core/player_fns.lua")
|
local player_fns = dofile_once("mods/quant.ew/files/core/player_fns.lua")
|
||||||
|
local wandfinder = dofile_once("mods/quant.ew/files/system/notplayer_ai/wandfinder.lua")
|
||||||
local np = require("noitapatcher")
|
local np = require("noitapatcher")
|
||||||
|
|
||||||
local rpc = net.new_rpc_namespace()
|
local rpc = net.new_rpc_namespace()
|
||||||
|
@ -19,6 +20,7 @@ local function entity_changed()
|
||||||
rpc.change_entity({data = np.SerializeEntity(ctx.my_player.entity)})
|
rpc.change_entity({data = np.SerializeEntity(ctx.my_player.entity)})
|
||||||
else
|
else
|
||||||
rpc.change_entity(nil)
|
rpc.change_entity(nil)
|
||||||
|
wandfinder.set_wands_after_poly()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -115,12 +115,13 @@ function OnProjectileFired(shooter_id, projectile_id, initial_rng, position_x, p
|
||||||
-- If it was an initial shot by host
|
-- If it was an initial shot by host
|
||||||
if is_suitable_target(ctx.my_player.entity) then
|
if is_suitable_target(ctx.my_player.entity) then
|
||||||
local inventory = EntityGetFirstComponent(ctx.my_player.entity, "Inventory2Component")
|
local inventory = EntityGetFirstComponent(ctx.my_player.entity, "Inventory2Component")
|
||||||
local wand = ComponentGetValue2(inventory, "mActiveItem")
|
local wand = ComponentGetValue2(inventory, "mActualActiveItem")
|
||||||
|
local item = EntityGetFirstComponentIncludingDisabled(wand, "ItemComponent")
|
||||||
local wands = ctx.my_player.wand_fire_count
|
local wands = ctx.my_player.wand_fire_count
|
||||||
if wands[wand] == nil then
|
if wands[wand] == nil then
|
||||||
wands[wand] = 0
|
wands[wand] = {0, {-1, -1}}
|
||||||
end
|
end
|
||||||
wands[wand] = wands[wand] + 1
|
wands[wand] = {wands[wand][1] + 1, ComponentGetValue2(item, "inventory_slot")}
|
||||||
end
|
end
|
||||||
|
|
||||||
if (entity_that_shot == 0 and multicast_index ~= -1 and unknown3 == 0) then
|
if (entity_that_shot == 0 and multicast_index ~= -1 and unknown3 == 0) then
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue