Industry overflow
Moderator: thunderchero
Forum rules
Please search before starting new topic.
There is a good chance it has already been asked.
Please search before starting new topic.
There is a good chance it has already been asked.
- thunderchero
- Site Administrator aka Fleet Admiral
- Posts: 7963
- Joined: Fri Apr 25, 2008 2:00 am
- Location: On a three month training mission, in command of the USS Valiant.
Industry overflow
Hi Everyone,
I know this has been requested before but could not find any answer or if it might even be possible.
what I am talking about
lets say current industry is 2400
build queue slots
1. Basic Shipyard (500 industry)
2. Basic Replicators (300 industry)
3. Dilithium Refinery (500 industry)
4. Phoenix Facility (400 industry)
total industry of the 4 slots = 1700, so all 4 items would be built in a single turn.
problem is I am not sure where to even begin.
plus if it is possible, how should it handle when first item is bought with credits
or should credits go to last item when not enough industry
any thoughts?
I know this has been requested before but could not find any answer or if it might even be possible.
what I am talking about
lets say current industry is 2400
build queue slots
1. Basic Shipyard (500 industry)
2. Basic Replicators (300 industry)
3. Dilithium Refinery (500 industry)
4. Phoenix Facility (400 industry)
total industry of the 4 slots = 1700, so all 4 items would be built in a single turn.
problem is I am not sure where to even begin.
plus if it is possible, how should it handle when first item is bought with credits
or should credits go to last item when not enough industry
any thoughts?
- Flocke
- BORG Trouble Maker
- Posts: 3258
- Joined: Sun Apr 27, 2008 2:00 am
- Location: Hamburg, Germany
- Contact:
Re: Industry overflow
yeah that one I would love to see fixed!
thought No1: inject some external code that is triggered during turn processing and processes the build queue of each system to spend excessive industry
requirements:
all the hard part of it is already solved or known, but to realize this it will still need quite some work
likely one will also want to power built structures or assign people and care for other details
I pretty much doubt you will want to implement such a hook in assembler
to fix it in asm, you'd better
I can't tell what will be easier. My No1 requires alot of preparation and investigation, but makes things easy once all is set up and allows for lots of further changes when you know some very basic coding. The asm route in theory looks to be simple, but might trouble when you try to re-use same old build routine.
thought No1: inject some external code that is triggered during turn processing and processes the build queue of each system to spend excessive industry
requirements:
- code injection - already solved
- hook turn processing - already solved
- figure needed data structures - mostly solved via sav game analysis
- galInfo lists the system count -> for processing the systInfo file, already analysed
- systInfo the system production values, build task & queue -> currently am fixing it for UE
- strcInfo the system buildings -> a plain listing of build structures already analysed
- the many task force and ship files -> recently analysed and fixed them all for UE
- empsInfo to update ships under construction etc -> possibly needs some analysis
- check on other sav data side references - figure the key variable data adresses - the main ones have been found I guess
- figure the structure cost from stbof.res file - possibly needs some search and investigation
- UE knows how to read and modify the structure values and stbof.res is loaded to known key variables - write some c++ code like the following pseudo code
for(int i=0; i<galInfo.sysCount; i++) { system = systInfo construction = stbofRes.ueKnows.get(system.construction) while(system.production - construction.cost > 0) { if(contruction is ship) addTaskForce(construction.type) // <- I just solved for UE else if(construction is building) strcInfo.buildType[construction.type] += 1 // <- plain structure counters system.production -= construction.cost system.construction = system.nextConstruction construction = stbofRes.ueKnows.get(system.construction) } }
all the hard part of it is already solved or known, but to realize this it will still need quite some work
likely one will also want to power built structures or assign people and care for other details
I pretty much doubt you will want to implement such a hook in assembler
to fix it in asm, you'd better
- search for the responsible build routine
- search for where the cost is compared or where the values can be read
- save away the excessive production
- search for where the queue is updated
- overwrite the invested production with the computed excessive production
- once that works, search for a good location to re-iterate or call the build routine again if there was any excessive production, and hope this can be done per system
I can't tell what will be easier. My No1 requires alot of preparation and investigation, but makes things easy once all is set up and allows for lots of further changes when you know some very basic coding. The asm route in theory looks to be simple, but might trouble when you try to re-use same old build routine.
- slickrcbd
- Lieutenant-Commander
- Posts: 200
- Joined: Tue Sep 08, 2015 9:22 pm
- Location: in front of a computer
Re: Industry overflow
I'm not sure about building multiple objects, but having the game give you credits for excess industry as if you had chosen "capitalization" might be a better choice. If for game balance if nothing else. I'm thinking of say the Benzites with their industrial output being able to build multiple transports or science vessels in one turn otherwise. Maybe even destroyers with some races.
I know the capitalization sucks compare to say building a transport and scrapping it, but it would be better than just wasting excess industry.
As it stands, in the above situation I try to pull some workers off of industry and put them into science or intel until the item is built. I drop it down until I see "2 turns left" then put 2 workers back on rather than 1 because of all the times I get a minor moral hit and suddenly that item with 1 turn left is now 2 turns left.
I know the capitalization sucks compare to say building a transport and scrapping it, but it would be better than just wasting excess industry.
As it stands, in the above situation I try to pull some workers off of industry and put them into science or intel until the item is built. I drop it down until I see "2 turns left" then put 2 workers back on rather than 1 because of all the times I get a minor moral hit and suddenly that item with 1 turn left is now 2 turns left.
- thunderchero
- Site Administrator aka Fleet Admiral
- Posts: 7963
- Joined: Fri Apr 25, 2008 2:00 am
- Location: On a three month training mission, in command of the USS Valiant.
Re: Industry overflow
I don't think we are only ones either
(Tethys liked the idea when I mentioned it also)
the Game already does this. problem is this can also be taken advantage of by using the early buy of ships to get credits back. (personally I never saw much of an advantage expect you build fleets a little quicker, and you still spend credits just a little less)
scrapping can be prevented now, so not much of an issue now a days.
as for ships this will not be much of a benefit since most ships will cost more than current industry. and even if you are able to build 2 scouts or troop transports i don't see any issue there. But I would also hope to see the overflow go to next build.
example
current industry is 2400
build queue slots
1. command cruiser (4600 industry) first turn 2400 as partial build, second turn 2200 to complete build (200 overflow)
2. scout (500 industry) the 200 overflow would be put towards this build as a partial build.
- slickrcbd
- Lieutenant-Commander
- Posts: 200
- Joined: Tue Sep 08, 2015 9:22 pm
- Location: in front of a computer
Re: Industry overflow
viewtopic.php?f=7&t=3885&p=51495&hilit=buy#p51495thunderchero wrote: ↑Tue May 25, 2021 8:04 pmthe Game already does this. problem is this can also be taken advantage of by using the early buy of ships to get credits back. (personally I never saw much of an advantage expect you build fleets a little quicker, and you still spend credits just a little less)
- thunderchero
- Site Administrator aka Fleet Admiral
- Posts: 7963
- Joined: Fri Apr 25, 2008 2:00 am
- Location: On a three month training mission, in command of the USS Valiant.
Re: Industry overflow
your question was last turn of build and that has no advantage, but if you buy 2 turns before that is when you get credits as SCT explained in final post.slickrcbd wrote: ↑Wed May 26, 2021 12:36 pmviewtopic.php?f=7&t=3885&p=51495&hilit=buy#p51495thunderchero wrote: ↑Tue May 25, 2021 8:04 pmthe Game already does this. problem is this can also be taken advantage of by using the early buy of ships to get credits back. (personally I never saw much of an advantage expect you build fleets a little quicker, and you still spend credits just a little less)
Spocks-cuddly-tribble wrote: ↑Wed Mar 18, 2020 11:18 am 2.) No, buy when 2 production turns remain to avoid waste of surplus industry. The buy cost preview calculation does not substract your current industry output (might still change due to many aspects like morale). You get this refund added to total credits next turn, but no surplus. It is advised to keep always enough credits to buy your stuff that way.
Now you can humiliate that retarded AI and unaware noobs in multiplayer to death.
- Spocks-cuddly-tribble
- Code Master
- Posts: 1961
- Joined: Sun Apr 27, 2008 2:00 am
Re: Industry overflow
At 0046249C is the ECONOMY order loop (for all empire systems)
sub_460940 building -> 460B2A finished
sub_45FED0 ship -> 460152 finished
sub_4603A0 Upgrade buildings -> 460771 finished
Study 'finished' each to create a new shared code setting a new system order from next queue slot. Storing industry surplus for next item (and/or 'trade goods' credit bonus) should be easy.
If ordInfo can handle more than 1 per turn, your new orders must be added at the end of the ordInfo list to be included later in the main loop.
Due to a bug or feature these comes after the ECONOMY_order_loop:
energy_vs_running_buildings_update
sub_461640 update_player_AI_build_queue -> should be done by now?
update_worker_assignation
But either way it will be more work than you expect:
- even greater AI disadvantage (unless AI code can handle this, remember 'one per empire' bug)
- global file handling of ordInfo, result list and so on -> sync errors in multiplayer?
- industry surplus exceptions for special industry bonuses like utopia planitia
- further diminish of dilithium (more than 1 ship per system/turn) and possible issues with dilthium vs ships under construction empsInfo feature depending on used dilithium options
- systInfo building bonus area should to be updated after each finish (new building bonus patch depends on it)
slickrcbd means using surplus industry as if 'trade goods' i.e. "capitalization" was set. Default is nothing.
sub_460940 building -> 460B2A finished
sub_45FED0 ship -> 460152 finished
sub_4603A0 Upgrade buildings -> 460771 finished
Study 'finished' each to create a new shared code setting a new system order from next queue slot. Storing industry surplus for next item (and/or 'trade goods' credit bonus) should be easy.
If ordInfo can handle more than 1 per turn, your new orders must be added at the end of the ordInfo list to be included later in the main loop.
Due to a bug or feature these comes after the ECONOMY_order_loop:
energy_vs_running_buildings_update
sub_461640 update_player_AI_build_queue -> should be done by now?
update_worker_assignation
But either way it will be more work than you expect:
- even greater AI disadvantage (unless AI code can handle this, remember 'one per empire' bug)
- global file handling of ordInfo, result list and so on -> sync errors in multiplayer?
- industry surplus exceptions for special industry bonuses like utopia planitia
- further diminish of dilithium (more than 1 ship per system/turn) and possible issues with dilthium vs ships under construction empsInfo feature depending on used dilithium options
- systInfo building bonus area should to be updated after each finish (new building bonus patch depends on it)
slickrcbd means using surplus industry as if 'trade goods' i.e. "capitalization" was set. Default is nothing.
I don't know how many bugs is too many but that point is reached somewhere before however many in BotF is.
- thunderchero
- Site Administrator aka Fleet Admiral
- Posts: 7963
- Joined: Fri Apr 25, 2008 2:00 am
- Location: On a three month training mission, in command of the USS Valiant.
Re: Industry overflow
Thanks Spocks-cuddly-tribble for all the detailed info, I plan on taking a good look at everything before I even attempt any code changes.
I still wonder if AI can already build multiple items in one turn, example question from discord
I have also seen quicker than possible orbitals built before.
as for a sync errors in multiplayer would be a big problem, I doubt if we would know if this would be an issue until code is working.
I never considered utopia planitia bonus very good point to study.
further diminish of dilithium (more than 1 ship per system/turn), I might consider limiting code changes to structures?
very interesting points.Spocks-cuddly-tribble wrote: ↑Wed May 26, 2021 2:44 pm - even greater AI disadvantage (unless AI code can handle this, remember 'one per empire' bug)
- global file handling of ordInfo, result list and so on -> sync errors in multiplayer?
- industry surplus exceptions for special industry bonuses like utopia planitia
- further diminish of dilithium (more than 1 ship per system/turn) and possible issues with dilthium vs ships under construction empsInfo feature depending on used dilithium options
- systInfo building bonus area should to be updated after each finish (new building bonus patch depends on it)
I still wonder if AI can already build multiple items in one turn, example question from discord
even if it was 2 or 3 turns before he was able to assault system 7 orbitals is not possible in 3 turns.I was playing the Ultimate Dominon mod earlier and I lost a system to the Klingons. It had no orbitals. I have a system directly opposite. Built a troop transport to retake it but they somehow built 7 orbitals in one turn. Has this happened to anyone else?
I have also seen quicker than possible orbitals built before.
as for a sync errors in multiplayer would be a big problem, I doubt if we would know if this would be an issue until code is working.
I never considered utopia planitia bonus very good point to study.
further diminish of dilithium (more than 1 ship per system/turn), I might consider limiting code changes to structures?
- Spocks-cuddly-tribble
- Code Master
- Posts: 1961
- Joined: Sun Apr 27, 2008 2:00 am
Re: Industry overflow
I have never seen it myself, but the 'build wonder' AI task B code looks as if it can do some extra cheat OBs: viewtopic.php?p=34081#p34081thunderchero wrote: ↑Wed May 26, 2021 4:56 pmI still wonder if AI can already build multiple items in one turn, example question from discord
even if it was 2 or 3 turns before he was able to assault system 7 orbitals is not possible in 3 turns.I was playing the Ultimate Dominon mod earlier and I lost a system to the Klingons. It had no orbitals. I have a system directly opposite. Built a troop transport to retake it but they somehow built 7 orbitals in one turn. Has this happened to anyone else?
I have also seen quicker than possible orbitals built before.
But I remember strange AI ship building shenanigans (each turn one older, outdated cruiser per system - without industry, credits, dilithium or shipyard) I think related to emergency ship building agenda and/or build wonder: viewtopic.php?p=34142#p34142
Also AI can ignore dilithium building restictions in some cases (e.g. for shipyards).
I don't know how many bugs is too many but that point is reached somewhere before however many in BotF is.
- thunderchero
- Site Administrator aka Fleet Admiral
- Posts: 7963
- Joined: Fri Apr 25, 2008 2:00 am
- Location: On a three month training mission, in command of the USS Valiant.
Re: Industry overflow
After just a quick look at code locations Spocks-cuddly-tribble provided,
1. I found locations of current industry, build cost, queue item id, structure info, systinfo (for structure)
2. I did not find yet where it might remove or be able to switch to next item in queue or where it calculates the overflow (remaining industry) (I may have not gone far enough in de-bug yet)
but since each type is in different sub-section this brings up issues when next queue item is different type.
my first thought was to just to add a loop in code but don't think this will work without adding code to go to next queue item. But even before that it will need to check if current queue has multi build items. then if single build go to next queue item after that it will need to check queue type (1=build building, 2=upgrade building(s), 3=build ship, 5=tradegoods, 7=unrest order) and go to the required section of new code or exit.
As I said before there will be a lot of research to do before any code change will be made.
1. I found locations of current industry, build cost, queue item id, structure info, systinfo (for structure)
2. I did not find yet where it might remove or be able to switch to next item in queue or where it calculates the overflow (remaining industry) (I may have not gone far enough in de-bug yet)
but since each type is in different sub-section this brings up issues when next queue item is different type.
my first thought was to just to add a loop in code but don't think this will work without adding code to go to next queue item. But even before that it will need to check if current queue has multi build items. then if single build go to next queue item after that it will need to check queue type (1=build building, 2=upgrade building(s), 3=build ship, 5=tradegoods, 7=unrest order) and go to the required section of new code or exit.
that might be an big understatement.Spocks-cuddly-tribble wrote: ↑Wed May 26, 2021 2:44 pm But either way it will be more work than you expect:
As I said before there will be a lot of research to do before any code change will be made.
- Flocke
- BORG Trouble Maker
- Posts: 3258
- Joined: Sun Apr 27, 2008 2:00 am
- Location: Hamburg, Germany
- Contact:
Re: Industry overflow
sounds like a lot of fun!thunderchero wrote: ↑Wed May 26, 2021 9:59 pm As I said before there will be a lot of research to do before any code change will be made.
best indeed would be when you find some root sub routine for a single system that can be called to loop the build task processing
for ai however I guess they have no build queue, and they might not even have a current build task
randomly adding some ships and buildings disregarding all pre-requirements is a common way to skip development work on ai calculations like people and energy assignment and mask inabilities of strategic ai planning
usually all the player can't see is fake and I pretty much doubt botf does any better
best leave ai alone or do the same and do some random selection
for the player however there must be some location where the next task is assigned, and even if there is code in between that can't be looped, you might find some routine to call to select next build item
I remember when I analysed the minor advancement, it might even be that in part it is shared with major ai advancement, or there is some flag that tells how to process the advancement
GL
- thunderchero
- Site Administrator aka Fleet Admiral
- Posts: 7963
- Joined: Fri Apr 25, 2008 2:00 am
- Location: On a three month training mission, in command of the USS Valiant.
Re: Industry overflow
I did some more testing after I found where the queue info is updated to next item (if more than 1 of same item in first slot ID remains same), but the funny thing was I noticed the AI does use this sub routine also. but AI so far has never had a second item in build queue (expected) so if I use the start of loop point I am thinking about AI would never use new code.Flocke wrote: ↑Thu May 27, 2021 2:27 am for ai however I guess they have no build queue, and they might not even have a current build task
randomly adding some ships and buildings disregarding all pre-requirements is a common way to skip development work on ai calculations like people and energy assignment and mask inabilities of strategic ai planning
I also took a quick look at the ship sub-section, it may bring up some problems switching between build types. stored ship info is longer than structure info (I expect same for upgrade type). this will cause issues resetting registries (esp) when build is complete. This maybe as simple as reset after each build then add correct amount for next build depending on type.