Jump to content

Random Number of Simultaneous Abductions


Ohma

Recommended Posts

Okay, since I'm banging my head against the wall trying to do this I'll ask people.

I'm trying to tweak some things to my personal taste. Two of the more major tweaks (mostly because they involve tinkering with the .upk files) are focused on swapping terror and abduction missions around as the main way panic is increased/decreased across the globe. The terror mission changes were easy, I just changed the iCountryPanicChange and iContinentPanicChange values in the CalcTerrorMissionPanicResult function. The major abduction change on the other hand...

Basically, the last thing I need to change here is to randomize the number of simultaneous abductions. With successful abductions only increasing panic in a single country by 1, abduction UFOs visible to a player, and abductions set to occur in countries with satellites, a random number of abductions should allow a player to mitigate the effects of terror mission panic (with my settings you'd have to save 14 or more civilians to keep a country's panic from rising more than 1 point, and that's the best you can do) without trivializing those effects (a single abduction might be a boon early game, but later, when you're capable of seeing and shooting down two of those UFOs, and you've got a continent in the yellow and orange).

So that's what I'm trying to do, the problem is that I need to change this bit of hex code:

04 2C 03 04 (return 3)

To this:

04 92 2C 01 A7 2C 02 16 16 04 (return 1 + Rand(2))

Which is uh...longer than the original.

So is that even possible? Is there any part of the hex code for the XGStrategyAI.GetNumAbductionSites function that's actually superfluous and can be re-appropriated? Would my change actually do the thing it's supposed to do (guarantee at least 1 site per abduction, with the potential for 1 or 2 more)? Would this have any effect on the number of UFOs that appear with ShowUFOsOnMission set to 1 (or would three scouts appear regardless of how many sites there were)? Oh yeah, and one last question that relates to the CalcTerrorMissionPanicResult function: do the iContinent/CountryPanicChange values act as modifiers to the PANIC_TERROR_COUNTRY/CONTINENT values in the DGC.ini? Like, if iContinentPanicChange = -1 and PANIC_TERROR_CONTINENT = 2, then what you should see post mission is a continent-wide panic increase of 1 right?

 

EDIT: Also I just realized I posted this in Mod Requests instead of Mod Troubleshooting...oops. If this topic could be moved there I'd be greatful.

Edited by Ohma
Link to comment
Share on other sites

So that's what I'm trying to do, the problem is that I need to change this bit of hex code:

04 2C 03 04 (return 3)

To this:

04 92 2C 01 A7 2C 02 16 16 04 (return 1 + Rand(2))

Which is uh...longer than the original.

 

So is that even possible? Is there any part of the hex code for the XGStrategyAI.GetNumAbductionSites function that's actually superfluous and can be re-appropriated?

No, but you can replace the calls to GetNumAbductionSites() in AddNewAbductions with 1 + Rand(2) which is just as good (with a lot of extra effort involved)

Link to comment
Share on other sites

Probably "Mod Talk" is the best place to get a response; that's where the coders hang out.

 

You can't increase the size of functions beyond the original. GetNumAbductionSites() is a tiny function.

 

However, a return isn't denoted by two 04s. Let me break down the code:

 

04 2c 01 RETURN 1

04 3a 4b 42 00 00 RETURN RETURN VALUE

53 END OF SCRIPT

 

Good news: You can make the 2c 01 into a 26 -- 25 and 26 are one-byte 0 and 1, respectively. You can also drop the 04 3a 4b 42 00 00 -- if you've already got another return, this code bit does nothing.

 

So, try

04 92 26 a7 2c 02 16 16 and then put in 0bs (null bytes) until you hit the 53, which MUST be there. Again, functions can't change sizes, so we use 0bs to fill in the extra space we've cleared out.

 

Tokens view in UE Explorer is very helpful with the kind of work you are doing.

 

Also, don't let the sites go above 3, because the UI can't handle it without further modding.

The one problem with a randomizer, though, is that GetNumAbductionSites is called twice from AddNewAbductions. Scanning the code, I'm not sure if they both have to have the same result or not, but you may get wonky outcomes if it rolls 1 abduction once and 3 the other time. I guess you'd have to test.

 

 

 

Would this have any effect on the number of UFOs that appear with ShowUFOsOnMission set to 1 (or would three scouts appear regardless of how many sites there were)?

 

Not without another hex change -- satellites prevent abductions in the given country, so you'd never see the scouts or abductors. If you made the change, then I'd expect three scouts at roughly the same time, and three abductors all at once.

 

 

 

Oh yeah, and one last question that relates to the CalcTerrorMissionPanicResult function: do the iContinent/CountryPanicChange values act as modifiers to the PANIC_TERROR_COUNTRY/CONTINENT values in the DGC.ini? Like, if iContinentPanicChange = -1 and PANIC_TERROR_CONTINENT = 2, then what you should see post mission is a continent-wide panic increase of 1 right?

 

I think that's right, but not 100%

Link to comment
Share on other sites

Okay, so this has been super helpful. I think I'm a lot closer to getting this to work, in fact, last afternoon I was able to replace the references to GetNumAbductionSites() in the AddNewAbductions function with 1 + Rand(2), and it seemed to work (I can't say for sure that the number of UFOs were affected since the save I tested it on didn't have full satellite coverage, but there were abductions with 3, 2, and 1 sites). The weird thing is that I started another test game this morning and apparently the change from yesterday causes a CtD at the end of every month (which is weird since my initial testing involved scanning for multiple months). So I don't know what happened, I guess I may have changed something when I made this into a mod that I can install through Toolboks?

 

Meanwhile, it really does seem like changing the full 04 2C 03 04 3a 4b 42 00 00 53 string in GetNumAbductionSites() to 04 92 2C 01 A7 2C 02 16 16 53 should work (like, the script looks right and everything) but the game crashes on start with that change. It's really weird.

 

EDIT: AH HA!!

 

I hadn't noticed before that the Jump Offset Assistant had a correction for my code! Everything works fine now, and all it took was the change of a single byte. Thank you both a ton!

 

One final question: Can a single custom mod that's intended to be installed through Toolboks alter multiple hex strings in the same .upk file? Like, if I set it up like:

 

UPK_FILE= A.UPK

OFFSET= [A NUMBER]

[MODDED_HEX]

[bYTES]

 

UPK_FILE= A.UPK

OFFSET= [A DIFFERENT NUMBER]

[MODDED_HEX]

[OTHER BYTES]

 

Would this work?

Edited by Ohma
Link to comment
Share on other sites

One final question: Can a single custom mod that's intended to be installed through Toolboks alter multiple hex strings in the same .upk file? Like, if I set it up like:

 

UPK_FILE= A.UPK

OFFSET= [A NUMBER]

[MODDED_HEX]

[bYTES]

 

UPK_FILE= A.UPK

OFFSET= [A DIFFERENT NUMBER]

[MODDED_HEX]

[OTHER BYTES]

 

Would this work?

Yes :smile:

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...