Jump to content

[MOD] [OOSP]out of sector Production


Laserzwei

Recommended Posts

updated for version 0.12.7 r8782

 

[Changes]

  -The mod does not affect Sectors with Player-property anymore (This excludes the current Playership).

The reason is the new vanilla game mechanic that loads such sectors autonomous.

  -All NPC (Trading-)Stations are now fully supported.

  This includes: biotopes, casinos, equipmentdocks, habitats, militaryoutposts, repairdocks, researchstations, resistance outposts, scrapyards, shipyard-trading and tradingoutposts

  -ResourceDepots now slowly regenerate resources to buy.

  -[inetrnal]changed from a tickbased to a timebased systems

  -The Versioncheck is now off by default

Link to comment
Share on other sites

  • Replies 174
  • Created
  • Last Reply

Top Posters In This Topic

Good to see that you are continuing your work!

 

I have one request tho, could you make it configurable to include player production?

The current engine limitations still makes it (almost) neccesary to turn it off on highly populated servers so that would be an useful option.

 

 

Link to comment
Share on other sites

Nice to see you restarted this great project. To include NPC consumers (equipmentdocks and so on) is a also a very good thing, thanks.

 

  -The mod does not affect Sectors with Player-property anymore (This excludes the current Playership).

The reason is the new vanilla game mechanic that loads such sectors autonomous.

 

I agree to Devious to make this configurable. To simulate player productions too does not hurt, we are doing this on our server since 0.12 came out (I merged the mod to the current version by myself) and it works fine.

 

How about complex support for this mod? Is there any chance to get this?

Link to comment
Share on other sites

 

I agree to Devious to make this configurable. To simulate player productions too does not hurt, we are doing this on our server since 0.12 came out (I merged the mod to the current version by myself) and it works fine.

 

How about complex support for this mod? Is there any chance to get this?

1) Should be relatively easy. The Code is the same as the NPC code (and always was). I just need to remove the new "blocker".

2) I stepped away from it. If Vanilla would work propery, complexes should be kept loaded anyway. Assuming it gets fixed, I would waste a lot of time in a feature that WILL become obsolete.

On a side note: Simulating Ships was never actually an aim for the mod. The only thing I would do is offer an Interface and another modauther has to do all the calculations for the ship simulation.

Link to comment
Share on other sites

The production of the current version looks bugged to me. Also there is an error in my server log (wich has nothing to do with too high productions).

 

Shorted server log (send me a pm if you need the whole logfile):

 

 

2017-08-07 21-41-57| [OOSP][0.9_8] timestamp: 154387.85238661 for Sector -434:133 updated
2017-08-07 21-41-57| could not execute function 'onSectorEntered' in '"data/scripts/player/oosproduction.lua"':
2017-08-07 21-41-57| data/scripts/player/oosproduction.lua:207: attempt to index a nil value
2017-08-07 21-41-57| stack traceback:
2017-08-07 21-41-57| 	data/scripts/player/oosproduction.lua:207: in function <data/scripts/player/oosproduction.lua:196>
2017-08-07 21-41-57| 
2017-08-07 21-41-57| Player Hammelpilaw moved to sector (-435:133)from (-434:133) server time taken for change: 179ms
2017-08-07 21-46-42| [OOSP][0.9_8] timestamp: 154673.79451005 for Sector -435:133 updated
2017-08-07 21-46-42| [OOSP][0.9_8] Sector: -434:133 needed 000:00:00:00.000246053: for sorting out
2017-08-07 21-46-42| [OOSP][0.9_8] Player: Hammelpilaw entered sector with: 0 more player(s)
2017-08-07 21-46-42| [OOSP][0.9_8] timestamp aquired: 154387.852386612017-08-07 21-46-42| [OOSP][0.9_8]     Aluminium Mine S    Njavdbi
2017-08-07 21-46-42| [OOSP][0.9_8] Garbage Storage Space reduces to: 36.125616459052
2017-08-07 21-46-42| [OOSP][0.9_8] The Factory is 36 processes behind.

 

 

I jumped out of the sector -435:133 at 21:41:57. About 5 minutes later i jumped in again, in that time the alu mine S should produce about 40 alu (4 processes per minute (15 sec per process) * 2 (size S factory) * 5 minutes = 40 goods), but it added almost 80 goods to it, wich fits to the logged 36 processes * 2. Maybe the size S multiplier is added twice in the calculation? Did not test with a higher sized factory yet.

Link to comment
Share on other sites

The production of the current version looks bugged to me. Also there is an error in my server log (wich has nothing to do with too high productions).

 

Shorted server log (send me a pm if you need the whole logfile):

 

 

2017-08-07 21-41-57| [OOSP][0.9_8] timestamp: 154387.85238661 for Sector -434:133 updated
2017-08-07 21-41-57| could not execute function 'onSectorEntered' in '"data/scripts/player/oosproduction.lua"':
2017-08-07 21-41-57| data/scripts/player/oosproduction.lua:207: attempt to index a nil value
2017-08-07 21-41-57| stack traceback:
2017-08-07 21-41-57| 	data/scripts/player/oosproduction.lua:207: in function <data/scripts/player/oosproduction.lua:196>
2017-08-07 21-41-57| 
2017-08-07 21-41-57| Player Hammelpilaw moved to sector (-435:133)from (-434:133) server time taken for change: 179ms
2017-08-07 21-46-42| [OOSP][0.9_8] timestamp: 154673.79451005 for Sector -435:133 updated
2017-08-07 21-46-42| [OOSP][0.9_8] Sector: -434:133 needed 000:00:00:00.000246053: for sorting out
2017-08-07 21-46-42| [OOSP][0.9_8] Player: Hammelpilaw entered sector with: 0 more player(s)
2017-08-07 21-46-42| [OOSP][0.9_8] timestamp aquired: 154387.852386612017-08-07 21-46-42| [OOSP][0.9_8]     Aluminium Mine S    Njavdbi
2017-08-07 21-46-42| [OOSP][0.9_8] Garbage Storage Space reduces to: 36.125616459052
2017-08-07 21-46-42| [OOSP][0.9_8] The Factory is 36 processes behind.

 

 

I jumped out of the sector -435:133 at 21:41:57. About 5 minutes later i jumped in again, in that time the alu mine S should produce about 40 alu (4 processes per minute (15 sec per process) * 2 (size S factory) * 5 minutes = 40 goods), but it added almost 80 goods to it, wich fits to the logged 36 processes * 2. Maybe the size S multiplier is added twice in the calculation? Did not test with a higher sized factory yet.

 

Sectors stay loaded ~ 5Minutes until shut down, after a player leaves. Within that time OOSP runs simultainiously with the game.

Edit: If you keep a Sector selected it will stay loaded. So there would also be a doubling effect.

Link to comment
Share on other sites

Sectors stay loaded ~ 5Minutes until shut down, after a player leaves. Within that time OOSP runs simultainiously with the game.

Edit: If you keep a Sector selected it will stay loaded. So there would also be a doubling effect.

 

Ah I thought loading/unloading a sector would trigger oosp to set ticks/timers. Just watched the code and saw I was wrong... That means activating sectors with player factories would also double productions if i'm right?

Link to comment
Share on other sites

Ah I thought loading/unloading a sector would trigger oosp to set ticks/timers. Just watched the code and saw I was wrong... That means

1)sadly there is no "onSectorUnloading"-Event.

 

activating sectors with player factories would also double productions if i'm right?

Yes. This is the reason, why I had to exclude playersectors from the mod.

 

Link to comment
Share on other sites

  • 2 weeks later...

Just wanted to say thank you, I've been trading the "bad old fashioned" way, sitting afk in sectors while working to let production happen.

 

So happy I don't have to do this anymore... wish it was part of the base game!

My pleasure. I whished that too.

 

updated to  0.9_9

[Changes]

  - Changed consumption to better reflect economy

Link to comment
Share on other sites

  • 2 months later...
  • 4 weeks later...

Hey.

 

Really like the mod! It makes trading/building your own stations soo much better.

One thing, imo Trading Posts generate goods too fast by default - I'm filthy stinking rich yo.

 

OOSP needs to be incorporated into the vanilla game imo. Thanks for everything!

 

Link to comment
Share on other sites

  • 2 weeks later...

Hey.

 

Really like the mod! It makes trading/building your own stations soo much better.

One thing, imo Trading Posts generate goods too fast by default - I'm filthy stinking rich yo.

 

OOSP needs to be incorporated into the vanilla game imo. Thanks for everything!

 

For slower good generation in /mods/oosp/config/oosp.lua set

config.consumptionTime = 604000
config.generationTime =604000 

 

Can this be installed serverside only?  Or does client need as well?

Could work, I wouldn't try ;)

Link to comment
Share on other sites

Hi, your mod is great, thanks for your work.

 

Found a bug: Trading Post uses "oospConfig.consumptionTime" for both soldGoods and boughtGoods. So basically config variable "generationTime" doesn't affect anything. Version 0.99_2d

 

 

Is there any chance for a version, that will use current "TradingManager:useUpBoughtGoods" algorithm?

function TradingManager:useUpBoughtGoods(timeStep)

    if not self.useUpGoodsEnabled then return end

    self.useTimeCounter = self.useTimeCounter + timeStep

    if self.useTimeCounter > 5 then
        self.useTimeCounter = 0

        if math.random () < 0.5 then

            local amount = math.random(1, 6)
            local good = self.boughtGoods[math.random(1, #self.boughtGoods)]

            if good ~= nil then
                self:decreaseGoods(good.name, amount)
            end
        end
    end

end

 

So, basically, this uses 1 to 6 of a 1 random good(that station buys) every 5 seconds with 50% chance.

 

Why I think that this algorithm is better that current one? Because current one doesn't really care about how many goods can fit in the station. If "config.consumptionTime = 86400" it will eat all goods from Shipyard or Upgrade station regardless of its size in 1 day.

 

I'm currently in stating sector and I already see that Shipyard has almost 6 times more goods than an Upgrade station and ingame algorithm will use all goods from Upgrade station in 20 hours and from Shipyard in 6 days.

Link to comment
Share on other sites

Hi, your mod is great, thanks for your work.

 

Found a bug: Trading Post uses "oospConfig.consumptionTime" for both soldGoods and boughtGoods. So basically config variable "generationTime" doesn't affect anything. Version 0.99_2d

Sure thing I fixed it on the github page already: oosp

 

Is there any chance for a version, that will use current "TradingManager:useUpBoughtGoods" algorithm?

function TradingManager:useUpBoughtGoods(timeStep)

    if not self.useUpGoodsEnabled then return end

    self.useTimeCounter = self.useTimeCounter + timeStep

    if self.useTimeCounter > 5 then
        self.useTimeCounter = 0

        if math.random () < 0.5 then

            local amount = math.random(1, 6)
            local good = self.boughtGoods[math.random(1, #self.boughtGoods)]

            if good ~= nil then
                self:decreaseGoods(good.name, amount)
            end
        end
    end

end

 

So, basically, this uses 1 to 6 of a 1 random good(that station buys) every 5 seconds with 50% chance.

 

Why I think that this algorithm is better that current one? Because current one doesn't really care about how many goods can fit in the station. If "config.consumptionTime = 86400" it will eat all goods from Shipyard or Upgrade station regardless of its size in 1 day.

 

I'm currently in stating sector and I already see that Shipyard has almost 6 times more goods than an Upgrade station and ingame algorithm will use all goods from Upgrade station in 20 hours and from Shipyard in 6 days.

You can't know, but you posted some code I've gone through over 100 times. I know it premise, its actions and its pitfalls: It doesn't scale.

Remember oosp has to retro-activly calculate past actions. In other words: Everything that could have happen since the last visit has to be calculated within a single gameTick. Now let's see what happens on a less populated server, when a sector has not been visited for 11,5 Days (1Million Seconds) -That is actually a pretty short timeframe! - . TradingManager:useUpBoughtGoods(timeStep) gets called every 5 seconds and on every 6th time it has a 50% chance to consume 1-6 goods. So let's assume we are clever and only use the code after

if self.useTimeCounter > 5 then

And set timeStep = 30.

That reduces the number of calls from 200,000 to 33,333 calls for every factory and habitat and Tradingpost and shipyard and ... . But it's still too f***ing slow. So I took an approach  from stochastics and looked how often every good would get it's 50% chance and accumulate it.

You can have a look at the old system in oosProductionMod_0.9_91.zip(it's still downloadable on the main page-but for 0.14). where I implemented that exact behaviour. And it sucked big time: It was slow, unreliable and worst of all: If you have goods with small Volume (e.g. Processors) you end up with  processor-stocks of 20,000 Units, while everything else is empty.

 

The new system treats every good equally as it looks at the total stock and removes a percentage of it depending on the time that passed. Where config.generationTime is the time after which a full stock is expected to be empty and config.generationTimeVariation is a variaton of that timeframe so you end up with an interval of [config.generationTimeVariation*(1-config.generationTimeVariation), config.generationTimeVariation* (1+config.generationTimeVariation) ] (default +-10%). It is predictable, it's fast, it's easy to understand and easy to mainain.

 

If you really want the vanilla behaviour in oosp, then you have to write code that implements it and is as fast, understandable and maintainable as mine and add pull request for it on github.

Link to comment
Share on other sites

Please if you have spare time, check this out and tell me what do you think about it. I'll pull request on github in the near future maybe too.

From my point of view, it's as fast as your code, but maybe I missed something.

This is mine implementation of ingame formula for your mod. I tested it, it works (there might be a few bugs though).

It's not precise as default (rounded a few things) ingame algorithm, but still.

 

oospConfig.consumptionFormulaMultiplier is 1.0 by default

 

Instead of calculating every 5 seconds independently (apply 50% chance, select random good, decrease count 1 to 6), we take:

1) 10 seconds, assuming that 50% means 1 fail and 1 success in 10 seconds.

2) Important moment: default ingame formula doesn't check if station has enough good. And I like it, it's like people on the station needed it, but there is no more processors. And they're like "well ok".

 

So:

1) Divide timeDelta / 10 and round it to the smaller value. This is the number of "steps" (times that our ingame function worked).

2) Spread steps equally amongst all goods. In case we have some leftovers or like 3 steps and 10 goods, I added an algorithm that will randomly choose goods.

3) Take result value for every good, and get a random number between result and result * 6

4) Decrease.

 

 

function consumption(station, timestamp)
...
    --CUSTOM: OOSP adjustments
    if oospConfig.consumptionUseGameFormula then
        local goodsCount = #boughtGoods
        local steps = math.floor(timeDelta / 10 / oospConfig.consumptionFormulaMultiplier)
        local part = math.floor(steps / goodsCount)
        local extra = steps % goodsCount

        for i = 1, goodsCount do
            local good = boughtGoods[i]
            local amount = part
            if extra > 0 and math.random() <= extra / (goodsCount - i + 1) then
                amount = amount + 1
                extra = extra - 1
            end
            amount = math.random(amount, amount * 6)
            debugPrint(4, "(ingame)removing", nil, amount, good.name, "from", station.name, maxStock, percentageToTake, currentStock)
            local status = station:invokeFunction("scripts/entity/merchants/consumer.lua", "decreaseGoods", good.name, amount)
        end
    else
    --CUSTOM
        for _,good in pairs(boughtGoods) do
            local status, currentStock, maxStock = station:invokeFunction("scripts/entity/merchants/consumer.lua", "getStock", good.name)
            local percentageToTake = (timeDelta / oospConfig.consumptionTime) * (1 + (math.random() * 2 * oospConfig.consumptionTimeVariation) - oospConfig.consumptionTimeVariation)
            local amount = math.floor(maxStock * percentageToTake)
            debugPrint(4, "removing", nil, amount, good.name, "from", station.name, maxStock, percentageToTake, currentStock)
            if amount > 5 then
                local status = station:invokeFunction("scripts/entity/merchants/consumer.lua", "decreaseGoods", good.name, amount)
            end
        end
    end --CUSTOM: OOSP adjustments

Link to comment
Share on other sites

Question I have installed this mod correctly I believe... but I am receiving this error that is pretty confusing...

 

Capture4314.png

 

any help would be great?

I still had the install instructions for 0.9_91 in the guide. (oosp_0.99_2d.zip is the current version)

I've updated the installation guide on the frontpage accordingly.

please do a clean reinstallation of the game. Follow the guide afterwards.

Link to comment
Share on other sites

  • 2 weeks later...

Quick question: with the current version of Avorion having "keep-alive" enabled on Sectors while the player is not inside them, is this mod still required to have Out-Of-Sector production? Is production exempt from the "keep-alive" functionality, or is OOSP now functionality that is incorporated into the base game itself?

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