Tech level upgrades taking thousands of turns

General Modding Information/Questions; support/discussion/questions

Moderator: thunderchero

Forum rules
:idea: Please search before starting new topic. :idea:
There is a good chance it has already been asked.
Post Reply
User avatar
Sailor-Moon
Cadet 2nd Year
Cadet 2nd Year
Posts: 7
Joined: Wed Apr 30, 2008 2:00 am

Tech level upgrades taking thousands of turns

Post by Sailor-Moon »

Hi all,
I'm playing with chat-gpt to make an easier interface for modding, based on the UE.
Everything is actually working great, except when major planets like Vulcan, Andor, Zakdorn etc get to about level 3 and then try to upgrade food, intel, anything to level 4, it gets stuck saying it will take between 2000 and 4900 turns.

anyone any idea what could be causing this?

Thanks in advance.
User avatar
Flocke
BORG Trouble Maker
BORG Trouble Maker
Posts: 3693
Joined: Sun Apr 27, 2008 2:00 am
Location: Hamburg, Germany
Contact:

Re: Tech level upgrades taking thousands of turns

Post by Flocke »

well, I'm not a magician nor a fortuneteller, so no
from the little you posted I don't even know what you are about to accomplish, or what you attempted to do and has failed :roll:

However, the past days the whole forums went down multiple times, presumably by continuous AI bot attacks. :(
While these attacks might be completely unrelated to the many AI supported projects currently in the works, and every modding project is welcome ofc, if you can, please try avoid targeting intense AI workloads crawling the forums (which on the web clearly is BotF modding source No1).
And when you start some larger workload that crawls the web anyway, please report so TC can check correlation. *sigh*

But back to your question. The upgrade cost is calculated by structure count * difference of the structure build cost of previous and upgraded version. And time then depends on the system's production output. So you should first check what values these are.
User avatar
Sailor-Moon
Cadet 2nd Year
Cadet 2nd Year
Posts: 7
Joined: Wed Apr 30, 2008 2:00 am

Re: Tech level upgrades taking thousands of turns

Post by Sailor-Moon »

Thanks, that is very helpful — I think that formula explains exactly what we are seeing.

For context, I’m working on a small personal BOTF campaign editor / diagnostic tool to make safer balance tweaks without having to manually chase everything through UE each time. At the moment I’m not trying to make a public mod or replace UE completely; I’m mainly trying to understand what values are being written where, and to stop myself breaking campaign saves.

The problem I hit was that some systems, especially named/minor/major planets like Talar, Vulcan, Trill etc, could show an upgrade as available, but once queued it would suddenly become thousands of turns.

One confirmed example from the save:

System: Talar
Current structure: 117 Type 2 Fusion Plant
Queued upgrade: 164 Type 3 Plasma Reactor
Saved cost: 589,284
Industry output: 141
Turns shown: about 4,179

At first I thought it might be a tech requirement issue, but after checking edifice.bst, alt.res, stbof.res, and the save-game system data, the building records themselves looked sane. The real issue appears to be that the save had one building family installed, but the game queued an upgrade into another family.

In this case:

Type 2 Fusion Plant cost = 160
Type 3 Plasma Reactor cost = 100

Using the formula you gave:

upgrade cost = structure count × (new build cost - old build cost)

That gives:

100 - 160 = -60

If that negative value is being treated as unsigned, then:

-60 becomes 65,476

And Talar appears to have 9 structures of that type:

65,476 × 9 = 589,284

Which exactly matches the bad saved cost in the queue.

So I think the cause is not the normal build cost field being too high, and not simply tech level. It looks like a cross-family upgrade problem where the target building has a lower base cost than the currently installed building, causing the upgrade-cost difference to underflow.

The repair idea I’m testing is:

1. Cancel/remove the poisoned queue item.
2. Align the system’s installed main structures to the same family the game is trying to upgrade into, while preserving the level.

For Talar, that would be something like:

Energy:
117 Type 2 Fusion Plant → 163 Type 2 Plasma Reactor

Industry:
181 Class 2 Machining Guild → 135 Type 2 Mass Replicator

Research:
126 Type 2 Science Center → 172 Type 2 University

Then the next upgrade should become:

163 Type 2 Plasma Reactor → 164 Type 3 Plasma Reactor

instead of the broken:

117 Type 2 Fusion Plant → 164 Type 3 Plasma Reactor

The next thing I’m trying to find is where the mismatched starting families come from in the first place — possibly building sets, named-system start data, or race/system templates — so the fix can be made at source rather than repairing saves after the fact.

Thanks again, because your upgrade-cost formula seems to explain the huge turn count perfectly.
User avatar
Flocke
BORG Trouble Maker
BORG Trouble Maker
Posts: 3693
Joined: Sun Apr 27, 2008 2:00 am
Location: Hamburg, Germany
Contact:

Re: Tech level upgrades taking thousands of turns

Post by Flocke »

Oh well, sounds interesting and I am glad to help! Although you might rather motivate me to work on the many UE fixtures needed for next release! :lol:

But given you try to understand savegame and code structures, you should check-out my current framework project:
https://gitlab.com/stbotf/botf-framework
There I included all the UE data structures and updated them for the latest IDA fndings and what more I found on the forums.
Like I recently noted on Discord, an actual quest and mission system comes high on my list. Thinking there of scriptable storyline events.
Have some wild ideas on it, but yet keep working on the necessary fundamentals. ;)

Feel welcome to join our Discord: https://discord.gg/x2QvyHvF77
We also have some further projects in development there!

P.S. The bot attacks luckily seem over for now, plus we can not thank cleverwise enough to have implemented some further server enhancements to sustain much heavier load and be more resilient now! So hopefully this makes these bot attacks a non-issue for the next upcoming years at least! :D
User avatar
Sailor-Moon
Cadet 2nd Year
Cadet 2nd Year
Posts: 7
Joined: Wed Apr 30, 2008 2:00 am

Re: Tech level upgrades taking thousands of turns

Post by Sailor-Moon »

Massive thank you :-)
Post Reply

Return to “General Modding Information/Questions”