After looking at what Germanicu5 did with his AI Switcher program, and installing a handy program called DebugView, I think I've found that I can change the files the game runs with depending on the faction chosen. The process might be fairly involved, or it might be fairly easy, but I'm certain that it's plausible.
What I had been hoping for is a way to identify that a player switched factions, without needing any input from them besides their selection of that faction. I found that in the form of faction map and faction unit, which are searched for to display when you click on a faction. This is the exact lines in question that DebugView printed:
Those lines are extremely important, because they appear to only show up when you have your selection on that faction, unlike the buttons which seem to load randomly(or maybe as your cursor scrolls over them?). What I'll need to do is get a program to fluently read the output from DebugView and latch onto 'hot words' like /FE_faction_units/goryeo.tga. If it picks that up it should be able to assume that the current selection is Goryeo and run other processes off that. It will obviously have to loop until the campaign is loaded, but that shouldn't be much of an issue.00048958 102.62872314 [1844] 16:45:00.046 [system.io] [trace] file open,,auh-newbuild/data/world/maps/campaign/imperial_campaign/map_goryeo.tga,544
00048959 102.62881470 [1844] 16:45:00.046 [system.io] [info] open: found auh-newbuild/data/world/maps/campaign/imperial_campaign/map_goryeo.tga (from: F:\Modding Files\AUH - Test Environment)
00048960 102.62916565 [1844] 16:45:00.046 [system.io] [trace] file open,,data/menu/symbols/FE_faction_units/goryeo.tga,,not found
00048961 102.62925720 [1844] 16:45:00.046 [system.io] [trace] pack open,packs/localized.pack,data/menu/symbols/FE_faction_units/goryeo.tga,,not found
00048962 102.62934875 [1844] 16:45:00.046 [system.io] [trace] pack open,packs/data_1.pack,data/menu/symbols/FE_faction_units/goryeo.tga,,not found
00048963 102.62942505 [1844] 16:45:00.046 [system.io] [warning] open: data/menu/symbols/FE_faction_units/goryeo.tga is missing
You might be wondering why this is a big deal. It's a big deal because it means we don't need to try and trick the game to do certain things for certain factions in-game, and we can set it up separately. To provide just one example, let's look at challenge factions. Challenge factions are what we envision as antagonists that only appear in certain campaigns for the player. For the Mongols this would be other Mongol tribes, for the Tibetans it would be other Monastic orders, for Pagan it might be Mon nationalists. The goal of having these as non-rebel is to make their AI less passive and more driven to oppose the player.
Trying to do this by altering the scenario once the game starts is nearly impossible. You have to spawn armies to conquer cities and set everything up through script, assuming it even works as intended. Other behavior and things that make up that faction can't be altered because there's no scripting commands to do so.
HOWEVER! If we can have a program that works like this one, we can make the files for each campaign different. The Tibetan campaign can have a number of built-in shadow slots, complete with insignia, names, positioning, etc. right from the start. All this involves then is having this handy program that's running in the background switch in new descr_strat and other files depending on the faction selected by the player. Voila, every campaign is noticeably different without the scripting overhead and without putting the burden on the end user to have to switch files in and out or only play one faction.
Aside from the problem of a noob programmer like me trying to write this utility, there's only two issues I foresee at this juncture. The first is that there might need to be a notice like "Leave 5 seconds after choosing faction for files to re-populate.", so the utility has enough time to realize what faction has been selected and move files around. That's not really an issue, and it may not even be necessary because programs tend to work in milliseconds. The second is that saved games work differently than newly started campaigns, because there's no faction select screen. Assuming I can get basic functionality for brand new games working, I'll then take a look at if there's anything to latch onto for saved games.
This has made me a very happy camper. I'm going to probably be attacking some programming eBooks now to see if I can piece this utility together in time for the Tibetan preview.
---
Update: There's also enough information in the log for me to ascertain if a player has chosen to play a Custom Battle or a Campaign game. This should make it possible to also switch out the separate EDU files without forcing the player to restart the game and select which they intend to play. Sadly I can't say the same about saved games right now, since nothing at all loads into the debug log when a save is selected it seems, and the interval between the save being loaded and the files being cached is under a second once 'Load' is pressed, so it could prove more difficult.
---
Update #2: After examining the contents of the .sav file in a Hex editor, I'm fairly confident I could glean enough information from the strings in that file corresponding to buildings or events to ascertain which faction the player is in any given save. Having said that, the .sav file is not loaded on click it seems, but only on pressing load, and then only a mere second before it starts processing, probably not enough time to parse a 1k KB file for a string and switch some files, even if the program were written in C and optimized for speed. I'm not entirely sure that file changes are needed for saved games, since I'm not sure which files it actually loads and which were already loaded into memory. For instance descr_strat should have no bearing on saves since it only modifies the starting scenario.
I'll have to consult someone about what files changes are considered 'save breaking', since these same changes will not need switching to work with a save game since they're pre-loaded into memory via the save. Another thing is some files seem to have no issue being changed during runtime. Germanicu5 AI changer shows that the BAI files can be changed while the campaign game is being played with no issues. If enough files either are pre-loaded or can be changed during runtime(ie. aren't cached), the save 'problem' may not be a problem at all.
---
Attached three files for my own future reference, just log outputs of different things with pauses in between so I could separate out what was logged during what action.
(Please don't mention this outside of the dev forums for now. If it works as intended then I'll try to build the utility so it can be easily adapted for other mod teams and release it as a tool, but I'd prefer no pressure in that respect. If I find I can't do anything with it then I'll mention it in the workshop and see if anyone wants to take up the challenge.)






Reply With Quote





