Jump to content

The Anenemy Nonstop generate(bug?)


Recommended Posts

This is definitely a bug. I've seen this with some mods before.

local function on_deploy(inst, position, deployer)
    local new_trap_starfish = SpawnPrefab("trap_starfish")
    if new_trap_starfish ~= nil then
        -- Dropped and deployed starfish traps shouldn't spawn in a reset state (or they'll bite the deployer).
        new_trap_starfish.AnimState:PlayAnimation("trap_idle")
        new_trap_starfish.components.mine:Spring()

        new_trap_starfish.Transform:SetPosition(position:Get())
        new_trap_starfish.SoundEmitter:PlaySound("dontstarve/common/plant")
    end
end

There are two separate prefabs for Anenemy Traps, one is "dug_trap_starfish" and the other is "trap_starfish". The dug version is the inventory item, and the normal version is when it's planted. Anenemy Traps have a "deployable" component to them. Whenever a prefab is deployed, it needs its coordinates to be specified. This is usually done by getting the deployer's coordinates.

However, if you look at the code above, deploying a "dug_trap_starfish" spawns a "trap_starfish" when deployed. Going back to the "deployable" component, the "dug_trap_starfish" will attempt to deploy itself at some coordinate. Since there is no coordinate specified, it defaults to the coordinate (0, 0).

A simple fix to this bug would be to add inst:Remove() to the code, which would delete the "dug_trap_starfish" when deployed (which is what we want since it becomes a "trap_starfish" anyway).

Archived

This topic is now archived and is closed to further replies.

Please be aware that the content of this thread may be outdated and no longer applicable.

×
  • Create New...