PATCHFILE Comet Strike (pop killed)

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
Tethys
Past Administrator
Past Administrator
Posts: 2403
Joined: Fri Jul 18, 2008 2:00 am
Location: Your mom's bed ;)
Contact:

PATCHFILE Comet Strike (pop killed)

Post by Tethys »

Ever been annoyed that your newly colonized system gets wiped out by a massive comet strike? Even more so, the annoyance that all your colonists decided to inhabit the impacted planet, and not any of the other planets you've terraformed?

You're in luck!

And it seems to be a pretty simple fix :up:
► Show Spoiler
^ Patch file download link at the bottom of spoiler ^

Comet strike takes a value of 10, (not sure exactly what math it performs, some idiv after adding more info into ecx) but I was able to produce a desired result by adjusting the value 0A (10) to value 64 (100) and the comet strike on a 66 population system killed only 6 pop rather than 60. So there is definitely some division happening here by the value 0A which can be adjusted for better gameplay. Value 1E killed 20 of 66 pop so I am happy with this number.

I have included in the patch a range of potential values which could potentially be used. User preference. (yay, my first game fix!) :)

viewtopic.php?f=20&t=369&p=4992&hilit=c ... rike#p4992
botf20.jpg
botf20.jpg (234.76 KiB) Viewed 2108 times
botf23.jpg
botf23.jpg (61.42 KiB) Viewed 2108 times
Last edited by Tethys on Fri Feb 25, 2022 7:44 pm, edited 1 time in total.
Not for the weak of heart...
Galaxies MOD v0.4.0 <--- GALM/Galaxies Mod latest version
User avatar
Tethys
Past Administrator
Past Administrator
Posts: 2403
Joined: Fri Jul 18, 2008 2:00 am
Location: Your mom's bed ;)
Contact:

Re: PATCHFILE Comet Strike (pop killed)

Post by Tethys »

More screenshots

20 pop killed
botf21.jpg
botf21.jpg (269.51 KiB) Viewed 2107 times
Now that's one big comet! ;)
botf22.jpg
botf22.jpg (239.34 KiB) Viewed 2107 times
Not for the weak of heart...
Galaxies MOD v0.4.0 <--- GALM/Galaxies Mod latest version
User avatar
Flocke
BORG Trouble Maker
BORG Trouble Maker
Posts: 3246
Joined: Sun Apr 27, 2008 2:00 am
Location: Hamburg, Germany
Contact:

Re: PATCHFILE Comet Strike (pop killed)

Post by Flocke »

Great job! Although, I really can't celebrate that comet strike. My sorrow is with you. :cry:
User avatar
Spocks-cuddly-tribble
Code Master
Code Master
Posts: 1926
Joined: Sun Apr 27, 2008 2:00 am

Re: PATCHFILE Comet Strike (pop killed)

Post by Spocks-cuddly-tribble »

Code: Select all

0044C666                 mov     ecx, 0Ah
In BotF system/planet current/max pop is sometimes stored times 10 (i.e. pop 60 -> 600, see system limits by Gowron).

The divisor 10 just calculates the right numbers (in this case it should be max pop of first terraformed planet, no random).

To get it right, you need to read the system's current pop related to max pop of all terraformed planets and estimate current pop of the hit planet depending on the planet/system pop ratio.

Also you should add at least one asm adr referrence in your patch codes (otherwise one must calculate hex/asm or search other modding posts to get the asm code location).
I don't know how many bugs is too many but that point is reached somewhere before however many in BotF is.
User avatar
Tethys
Past Administrator
Past Administrator
Posts: 2403
Joined: Fri Jul 18, 2008 2:00 am
Location: Your mom's bed ;)
Contact:

Re: PATCHFILE Comet Strike (pop killed)

Post by Tethys »

Spocks-cuddly-tribble wrote: Fri Feb 25, 2022 11:45 am

Code: Select all

0044C666                 mov     ecx, 0Ah
In BotF system/planet current/max pop is sometimes stored times 10 (i.e. pop 60 -> 600, see system limits by Gowron).

The divisor 10 just calculates the right numbers (in this case it should be max pop of first terraformed planet, no random).

To get it right, you need to read the system's current pop related to max pop of all terraformed planets and estimate current pop of the hit planet depending on the planet/system pop ratio.

Also you should add at least one asm adr referrence in your patch codes (otherwise one must calculate hex/asm or search other modding posts to get the asm code location).
Will do, thanks for the tips :)

But I'm not sure I want to wipe the total population of that planet out, common sense expects there to be at least some surviving population on the far side. But I will look into it for a proper fix. This workaround seems to work for the meantime.

Edit:
Spocks-cuddly-tribble wrote: Fri Feb 25, 2022 11:45 am (in this case it should be max pop of first terraformed planet, no random).
So you're telling me that if planet 1 is not terraformed, but planet 2 is, the comet will always hit planet 2? Or are you saying that if you first terraform planet 2, then later on terraform planet 1, and then a comet strikes, it will hit planet 2 since it was the first one terraformed? (if you knew the amount of research I do on things before asking for help you'd wonder where I even get the time to do any modding...)
Not for the weak of heart...
Galaxies MOD v0.4.0 <--- GALM/Galaxies Mod latest version
User avatar
Spocks-cuddly-tribble
Code Master
Code Master
Posts: 1926
Joined: Sun Apr 27, 2008 2:00 am

Re: PATCHFILE Comet Strike (pop killed)

Post by Spocks-cuddly-tribble »

Tethys wrote: Fri Feb 25, 2022 1:58 pmSo you're telling me that if planet 1 is not terraformed, but planet 2 is, the comet will always hit planet 2?
I'm not certain, the code appears like this (I was expecting random selection).

Just try to edit the code to trigger the event more often for testing:

Code: Select all

0044C079                 jz      loc_44C18A diffi_switch_systems -> jmp loc_44C2C5 Comet_Strike
I don't know how many bugs is too many but that point is reached somewhere before however many in BotF is.
User avatar
Tethys
Past Administrator
Past Administrator
Posts: 2403
Joined: Fri Jul 18, 2008 2:00 am
Location: Your mom's bed ;)
Contact:

Re: PATCHFILE Comet Strike (pop killed)

Post by Tethys »

Spocks-cuddly-tribble wrote: Sat Feb 26, 2022 10:09 am
Just try to edit the code to trigger the event more often for testing:

Code: Select all

0044C079                 jz      loc_44C18A diffi_switch_systems -> jmp loc_44C2C5 Comet_Strike
Yes that works, but I get a comet @ Mercury every turn.. placing the trigger at

Code: Select all

0044C20E                 ja      loc_44C5EE invalid_eplus -> ja loc_44C2C5 Comet_Strike
seems to be more efficient, I got 2 comet strikes per turn on different systems. Very good, this should help out a bit, thank you.

Already I have gathered that the closest terraformed planet to the star is the planet that will get hit. So if you get a hit on planet 2, and then you terraform planet 1 after, planet 1 becomes the new target. If you do not terraform it, planet 2 remains the target for any future comet strike. I feel this should be randomized for planet selection, not always the first planet, but only the "inner" planets should experience comet strikes imo. Take total nr planets divide by 2 and double the remainder (0.5 > 1.0) so 9 planet system = first 5 planets potential (random) target. ;)

(the above would be an intricate code change involving math and some new info into the registers)

As for labeling things (you can disregard comet impact strength label as I know now this is just added to esi+40), I hope at least some of what I have here is correct. From what I can tell 0A is added to the current pop and compared against the planet type being impacted, and if the current pop+0A is less than the impacted planet, KILL ENTIRE POPULATION. It seems to disregard whether other planets are terraformed even though it calls for it earlier in the sub... :shock:
labeling.jpg
labeling.jpg (444.35 KiB) Viewed 1966 times
Which means the initial patch file will actually prevent total annihilation of single planet systems as well (unintended). I think in the pop killed section is enough bytes to relocate and cmp some more values ... for (next post)

Still not sure what edx is... but I suspect its just a systInfo clone ???
Last edited by Tethys on Tue Mar 01, 2022 9:39 am, edited 1 time in total.
Not for the weak of heart...
Galaxies MOD v0.4.0 <--- GALM/Galaxies Mod latest version
User avatar
Tethys
Past Administrator
Past Administrator
Posts: 2403
Joined: Fri Jul 18, 2008 2:00 am
Location: Your mom's bed ;)
Contact:

Re: PATCHFILE Comet Strike (pop killed)

Post by Tethys »

Maybe something like cmp edi+6Ah, 1 (# of planets = 1)

if 1 -> pop killed section

else go to 44c679 (or a new section for a reasonable comet impact value for low pop system)

This could ensure single planet systems are depopulated while preserving multi planet (terraformed) systems, and divisor 0A can remain unchanged.
cmp byte [esi+6a], 1
jz to pop killed
jmp to calculate pop loss
cmp 01 seems to massively screw things up, I had -100 billion credits and killed system kept repopulating.. onward

or
cmp byte [esi+6a], 1
jne to calculate pop
jmp to pop killed
this arrangement of code fails during second comet strike on same system

I wouldn't waste any more time on this. I can be satisfied with my original code change, even if it's not proper, it performs the desired function of NOT killing the entire population. I am interested in your gas giant/OB mod for comet strike. Perhaps I will adapt that in some way :)

nonworking code (which I may come back to at later date)
► Show Spoiler
Notes:
planet pop idiv # of planets incl gas (esi+6a)
store result (register)
cmp current pop+10 to result
jnb (kill pop)
else remove some population
Not for the weak of heart...
Galaxies MOD v0.4.0 <--- GALM/Galaxies Mod latest version
Post Reply

Return to “General Modding Information/Questions”