Jump to content

Remaining mineable asteroids calculated incorrectly for respawn mechanic


Graendal

Recommended Posts

From the scripts/sector/background/respawnresourceasteroids.lua:

function RespawnResourceAsteroids.respawnRichAsteroids()
    local sector = Sector()
    local richAsteroids = sector:getNumEntitiesByComponent(ComponentType.MineableMaterial)
    local numAsteroids = sector:getNumEntitiesByType(EntityType.Asteroid)

    if numAsteroids == 0 then return end
    if richAsteroids / numAsteroids > self.respawningThreshold then return end

    ...
end

Correct me if I'm wrong, but it looks like the line

local richAsteroids = sector:getNumEntitiesByComponent(ComponentType.MineableMaterial)

includes wreckages in the total number of rich asteroids because wreckages also have the component type of 'MineableMaterial'.  I'm thinking the fix is as easy as:

local richAsteroids = sector:getNumEntitiesByComponent(ComponentType.MineableMaterial) - sector:getNumEntitiesByType(EntityType.Wreckage)
Link to comment
Share on other sites

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