Jump to content

Buzzard spawner oversights with lunar hail


hoxi
  • Pending

Despite buzzards being gone during winter, which is backed up to be what's intended by the lunar hail watchers being disabled during winter, this bit here can still kill them and mutate them, which makes no sense:

local function OnEntitySleep(inst)
    for i = #inst.buzzardshadows, 1, -1 do
        inst.buzzardshadows[i]:Remove()
        table.remove(inst.buzzardshadows, i)
    end
    CancelAwakeTasks(inst)

    -- HERE
    if TheWorld.state.islunarhailing then
        InstantKillBuzzardsWithLunarHail(inst)
    end
end

Not only that, but this will also completely skip the lunar hail level check (which delays the deaths until near the end of the lunar hail event). Meaning you could move away from a spawner to unload it just after lunar hail started and the buzzards will die and mutate instantly, as well as make it so if you walk near a spawner during winter, you'll see no buzzard or buzzard shadows, but after you leave, suddenly or shortly after there will be mutated buzzards following you.

This seems like it was maybe put there for testing and wasn't removed, since everything should work as expected without that line, including when the spawner is asleep.

 

Also, more of an edge case but still a relevant oversight, the following function doesn't ensure to set inst._drop_buzzards_at_lunar_hail_level to nil and remove the "lunarhaillevel" world watcher when applicable:

local function SpawnerOnIsWinter(inst, iswinter)
    if iswinter then
        inst:StopWatchingWorldState("isnight", SpawnerOnIsNight)
        inst:StopWatchingWorldState("islunarhailing", SpawnerOnIsLunarHailing)

        -- HERE, this is missing
        if inst._drop_buzzards_at_lunar_hail_level ~= nil then
            inst._drop_buzzards_at_lunar_hail_level = nil
            inst:StopWatchingWorldState("lunarhaillevel", OnLunarHailLevel)
        end

        UpdateChildSpawner(inst)
        ReturnChildren(inst)
        CancelAwakeTasks(inst)
    else
        inst:WatchWorldState("isnight", SpawnerOnIsNight)
        inst:WatchWorldState("islunarhailing", SpawnerOnIsLunarHailing)
        SpawnerOnIsNight(inst, TheWorld.state.isnight)
        SpawnerOnIsLunarHailing(inst, TheWorld.state.islunarhailing)
    end
end

As said earlier, when winter starts, the buzzards are all technically gone (even if they're technically not removed from their spawners), so they shouldn't suddenly be able to show up, die, and mutate if lunar hail started just before winter started.

 

These two functions could also use some small similar tweaks to be cleaner:

local function OnLunarHailLevel(inst, lunarhaillevel)
    if lunarhaillevel <= inst._drop_buzzards_at_lunar_hail_level then
        if inst:IsAsleep() then
            InstantKillBuzzardsWithLunarHail(inst)
            inst._drop_buzzards_at_lunar_hail_level = nil -- HERE
            inst:StopWatchingWorldState("lunarhaillevel", OnLunarHailLevel)
        elseif inst.components.childspawner.childreninside > 0 then
            local corpse = inst.components.childspawner:SpawnChild(nil, "buzzardcorpse")
            if corpse ~= nil and TUNING.SPAWN_MUTATED_BUZZARDS_GESTALT then
                -- state and position is handled in OnSpawn
                corpse:StartGestaltTimer(5 + math.random() * 6)
            end
        else
            inst._drop_buzzards_at_lunar_hail_level = nil -- HERE
            inst:StopWatchingWorldState("lunarhaillevel", OnLunarHailLevel)
        end
    end
end

local function SpawnerOnIsLunarHailing(inst, islunarhailing)
    if islunarhailing then
        inst._drop_buzzards_at_lunar_hail_level = BUZZARDSPAWNER_KILL_BUZZARDS_LUNAR_HAIL_BASE + math.random() * BUZZARDSPAWNER_KILL_BUZZARDS_LUNAR_HAIL_VAR
        inst:WatchWorldState("lunarhaillevel", OnLunarHailLevel)

        UpdateChildSpawner(inst)
        ReturnChildren(inst)
        CancelAwakeTasks(inst)
    else
        -- HERE
        if inst._drop_buzzards_at_lunar_hail_level ~= nil then
            inst._drop_buzzards_at_lunar_hail_level = nil
            inst:StopWatchingWorldState("lunarhaillevel", OnLunarHailLevel)
        end

        UpdateChildSpawner(inst)
        if not inst:IsAsleep() then
            UpdateAwakeTasks(inst)
        end
    end
end

 

Lastly, not an issue, but regarding the fact that buzzards are gone during winter but are technically still in the spawner, you could further reinforce this by removing them in there as well (the method to do so is up to you), this would make them start regenerating once winter is over, which could be seen as them slowly coming back!

 

EDIT: just immediately realized there's another oversight:

local function InstantKillBuzzardsWithLunarHail(inst)
    local mutatedbirdmanager = TheWorld.components.mutatedbirdmanager
    if mutatedbirdmanager and TUNING.SPAWN_MUTATED_BUZZARDS_GESTALT then
        local childspawner = inst.components.childspawner
        local num_children = childspawner:NumChildren()

        mutatedbirdmanager:FillMigrationTaskAtInst("mutatedbuzzard_gestalt", inst, num_children)

        -- Clear the children
        childspawner.childreninside = 0
        for k, child in pairs(childspawner.childrenoutside) do
            child:Remove()
        end
    end
end

This function won't properly kill buzzards if the setting to spawn mutated buzzards is disabled, which doesn't match with the OnLunarHailLevel function (shown in the previous code block). if the setting is disabled, they're supposed to still die, but not mutate.

Also I'm not sure how likely it is but, this function could cause buzzards to despawn in plain sight, if they're awake, but the spawner isn't, but that'd require them to be far away from the spawner.


Steps to Reproduce

For the OnEntitySleep issue:

  • Walk near a buzzard spawner during winter to wake it up.
  • Walk away as soon as lunar hail starts, and make it go sleep.
  • Notice how mutated buzzards will show up despite buzzards being gone during winter.

For the other edge case with winter start:

  • Make lunar hail start (with debug tools/commands) right before winter starts.
  • You can be close or far away to the spawners (just don't walk away after waking up the spawner or you'll trigger the case above), but notice how when the lunar hail point to kill buzzards is reached, they'll die and mutate despite them being gone.
  • Like 1
  • Thanks 1



User Feedback


There are no comments to display.



Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
  • Create New...