Jump to content

Poisonous birchnut tree spawning issues


hoxi
  • Pending

The conditions checked during entity search don't include if the tree has normal_anims, meaning closer small/tall trees can be selected and block other medium-sized ones from turning.

        if math.random() < chance * chance_mod then
            --print("Trying to spawn monster")
            local x, y, z = inst.Transform:GetWorldPosition()
            local ents = TheSim:FindEntities(x, y, z, 30, FINDTREETOTRANSFORM_MUST_TAGS, FINDTREETOTRANSFORM_CANT_TAGS)
            local max_monsters_to_spawn = math.random(3, 4)
            for i, v in ipairs(ents) do
                if v.leaf_state ~= "barren" and
                    not v.monster and
                    v.monster_start_task == nil and
                    v.monster_stop_task == nil and
                    v.domonsterstop_task == nil then
                    v.monster_start_task = v:DoTaskInTime(math.random(1, 4), delayed_start_monster)
                    if max_monsters_to_spawn <= 1 then
                        break
                    end
                    max_monsters_to_spawn = max_monsters_to_spawn - 1
                end
            end
        end

The same issue carried over to the treeguard idol, when looking for birchnut trees to turn into poisonous ones.

 

Also, another important issue is that the tree being chopped down can be found by the search, yet this isn't checked when iterating, essentially eating one of the possible spawns. There needs to be a v ~= inst check.

You could address this and lower the random max amount to math.random(2, 3) if you don't want to affect that it always resulted in a maximum of 2 or 3 even when other conditions were met.


Steps to Reproduce
  1. Place a lot of birchnut trees in an area.
  2. Chop down a non-barren tall birchnut tree surrounded by small or tall ones, and with medium ones behind them (ideally also, force the chance to be guaranteed).
  3. Notice how less of them will become poisonous, or even none if there's 4 non-medium ones the closest to the one you chopped down. Also notice how the max amount will always be 3, not 4, due to the tree that was chopped down being selected.



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...