sync mom orbs better and probably a bunch of enemy things

This commit is contained in:
bgkillas 2024-11-10 09:20:34 -05:00
parent a19dc7d165
commit ef732da3a2
3 changed files with 52 additions and 14 deletions

View file

@ -271,6 +271,10 @@ function util.make_type(typedata)
inner = inner .. "bool "..var..";\n" inner = inner .. "bool "..var..";\n"
end end
for _, var in ipairs(typedata.vecbool or {}) do
inner = inner .. "bool "..var.."[16];\n"
end
for _, var in ipairs(typedata.peer_id or {}) do for _, var in ipairs(typedata.peer_id or {}) do
inner = inner .. "char "..var.."[16];\n" inner = inner .. "char "..var.."[16];\n"
end end

View file

@ -31,28 +31,23 @@ local EnemyDataKolmi = util.make_type({
bool = {"enabled"}, bool = {"enabled"},
}) })
local EnemyDataMom = util.make_type({
u32 = {"enemy_id"},
f32 = {"x", "y", "vx", "vy"},
vecbool = {"orbs"},
})
local EnemyDataFish = util.make_type({ local EnemyDataFish = util.make_type({
u32 = {"enemy_id"}, u32 = {"enemy_id"},
f32 = {"x", "y", "vx", "vy"}, f32 = {"x", "y", "vx", "vy"},
u8 = {"r"}, u8 = {"r"},
}) })
--local EnemyDataSniper = util.make_type({
-- u32 = {"enemy_id"},
-- f32 = {"x", "y", "vx", "vy"},
-- bool = {"aiming"},
--})
local HpData = util.make_type({ local HpData = util.make_type({
u32 = {"enemy_id"}, u32 = {"enemy_id"},
f32 = {"hp", "max_hp"} f32 = {"hp", "max_hp"}
}) })
--local HpDataMom = util.make_type({
-- u32 = {"enemy_id"},
-- f32 = {"hp", "max_hp", "hp1", "hp2", "hp3", "hp4"}
--})
local FULL_TURN = math.pi * 2 local FULL_TURN = math.pi * 2
local PhysData = util.make_type({ local PhysData = util.make_type({
@ -281,6 +276,23 @@ function enemy_sync.host_upload_entities()
vy = vy, vy = vy,
enabled = EntityGetFirstComponent(enemy_id, "BossHealthBarComponent", "disabled_at_start") ~= nil, enabled = EntityGetFirstComponent(enemy_id, "BossHealthBarComponent", "disabled_at_start") ~= nil,
} }
elseif EntityHasTag(enemy_id, "boss_wizard") then
local orbs = {false, false, false, false, false, false, false, false}
for _, child in pairs(EntityGetAllChildren(enemy_id) or {}) do
local var = EntityGetFirstComponentIncludingDisabled(child, "VariableStorageComponent")
if EntityHasTag(child, "touchmagic_immunity") and var ~= nil then
local n = ComponentGetValue2(var, "value_int")
orbs[n] = true
end
end
en_data = EnemyDataMom {
enemy_id = enemy_id,
x = x,
y = y,
vx = vx,
vy = vy,
orbs = orbs
}
elseif worm ~= nil then elseif worm ~= nil then
local tx, ty = ComponentGetValue2(worm, "mTargetVec") local tx, ty = ComponentGetValue2(worm, "mTargetVec")
en_data = EnemyDataWorm { en_data = EnemyDataWorm {
@ -593,6 +605,10 @@ local function sync_enemy(enemy_info_raw, force_no_cull)
else else
EntitySetTransform(enemy_id, x, y) EntitySetTransform(enemy_id, x, y)
end end
local parent = EntityGetParent(enemy_id)
if parent ~= nil then
EntitySetTransform(parent, x, y)
end
local worm = EntityGetFirstComponentIncludingDisabled(enemy_id, "WormAIComponent") local worm = EntityGetFirstComponentIncludingDisabled(enemy_id, "WormAIComponent")
or EntityGetFirstComponentIncludingDisabled(enemy_id, "BossDragonComponent") or EntityGetFirstComponentIncludingDisabled(enemy_id, "BossDragonComponent")
if worm ~= nil and ffi.typeof(en_data) == EnemyDataWorm then if worm ~= nil and ffi.typeof(en_data) == EnemyDataWorm then
@ -630,6 +646,22 @@ local function sync_enemy(enemy_info_raw, force_no_cull)
execute_every_n_frame = "-1"}) execute_every_n_frame = "-1"})
end end
end end
if ffi.typeof(en_data) == EnemyDataMom then
local orbs = en_data.orbs
for _, child in pairs(EntityGetAllChildren(enemy_id) or {}) do
local var = EntityGetFirstComponentIncludingDisabled(child, "VariableStorageComponent")
local damage_component = EntityGetFirstComponentIncludingDisabled(child, "DamageModelComponent")
if EntityHasTag(child, "touchmagic_immunity") and var ~= nil then
local n = ComponentGetValue2(var, "value_int")
if orbs[n] then
ComponentSetValue2(damage_component, "wait_for_kill_flag_on_death", true)
else
ComponentSetValue2(damage_component, "wait_for_kill_flag_on_death", false)
EntityKill(child)
end
end
end
end
end end
local inv = EntityGetFirstComponentIncludingDisabled(enemy_id, "Inventory2Component") local inv = EntityGetFirstComponentIncludingDisabled(enemy_id, "Inventory2Component")

View file

@ -205,9 +205,11 @@ local function player_died()
set_cosmetics_locally(ctx.my_id) set_cosmetics_locally(ctx.my_id)
local inv = EntityGetFirstComponentIncludingDisabled(ctx.my_player.entity, "Inventory2Component") local inv = EntityGetFirstComponentIncludingDisabled(ctx.my_player.entity, "Inventory2Component")
ComponentSetValue2(inv, "mItemHolstered", false) if inv ~= nil then
ComponentSetValue2(inv, "mActualActiveItem", 0) ComponentSetValue2(inv, "mItemHolstered", false)
ComponentSetValue2(inv, "mActiveItem", 0) ComponentSetValue2(inv, "mActualActiveItem", 0)
ComponentSetValue2(inv, "mActiveItem", 0)
end
polymorph.switch_entity(ent + 1) polymorph.switch_entity(ent + 1)