Jump to content

2016-05-12 Patch SDK Changes


davidlallen

Recommended Posts

X2TacticalGameRuleset.StartStateSpawnAliens() is where the alien pods are actually added to the mission. I've modified this a bit in my own highlander-type mod to add PreSpawnAlienPods and PostSpawnAlienPods events that I listen to and make small modifications to the gamedata in order to adjust some parameters for the alien pod spawning algorithm. Basically adjusting where the pods think the objective is located so that they can have a valid spawn location, otherwise the pods will literally fail to spawn in the level.

`XEVENTMGR.TriggerEvent('PreSpawningAlienPods', BattleData, SpawnManager, None);
SpawnManager.SpawnAllAliens(ForceLevel, AlertLevel, StartState, MissionSiteState);
`XEVENTMGR.TriggerEvent('PostSpawningAlienPods', BattleData, SpawnManager, None);

The MissionSiteState contains the selected encounter data. Looks like this gets populated with pods during XComGameState_MissionSite.CacheSelectedMissionData(), which calls the native function XComAISpawnManager.SelectSpawnGroup().

 

Anywhere in this chain the selected pods could be modified. If the community wants greater customization, it should be quite doable. I think the only question is how much effort it will take, whether it's possible to just edit the selected mission encounters before the alien pod generation, or whether the pods need to be modified after generation. (Ideally before, because who knows exactly what the pod generation native functions actually DO.)

 

Well, the other question would be what format does the extra customizability come in? What's everybody's tldr on what they would ideally like to see?

Link to comment
Share on other sites

  • Replies 75
  • Created
  • Last Reply

Top Posters In This Topic

X2TacticalGameRuleset.StartStateSpawnAliens() is where the alien pods are actually added to the mission. I've modified this a bit in my own highlander-type mod to add PreSpawnAlienPods and PostSpawnAlienPods events that I listen to and make small modifications to the gamedata in order to adjust some parameters for the alien pod spawning algorithm. Basically adjusting where the pods think the objective is located so that they can have a valid spawn location, otherwise the pods will literally fail to spawn in the level.

`XEVENTMGR.TriggerEvent('PreSpawningAlienPods', BattleData, SpawnManager, None);
SpawnManager.SpawnAllAliens(ForceLevel, AlertLevel, StartState, MissionSiteState);
`XEVENTMGR.TriggerEvent('PostSpawningAlienPods', BattleData, SpawnManager, None);

The MissionSiteState contains the selected encounter data. Looks like this gets populated with pods during XComGameState_MissionSite.CacheSelectedMissionData(), which calls the native function XComAISpawnManager.SelectSpawnGroup().

 

Anywhere in this chain the selected pods could be modified. If the community wants greater customization, it should be quite doable. I think the only question is how much effort it will take, whether it's possible to just edit the selected mission encounters before the alien pod generation, or whether the pods need to be modified after generation. (Ideally before, because who knows exactly what the pod generation native functions actually DO.)

 

Well, the other question would be what format does the extra customizability come in? What's everybody's tldr on what they would ideally like to see?

 

In my limited tests I found no way of editing encounterdata before CacheSelectedMissionData() was completed. It seems like the values get pulled out of the inis directly when needed. However better programmers may be able to find a way. So in my understanding we actually have to do it after Caching is complete. We can add new encounters using the very same SelectSpawnGroup() and the other stuff thats in CacheSelectedMissionData() (I already did this in two mods). One just has to remember to update the shadowchamber again (which needs to be done with a new function, since the original one only updates, when CacheSelectedMissionData() returns true). The new DLC will probably need exceptions, so ruler pods dont get displayed.

I haven tried modifying already created encounters so far, but thats next on my list.

Link to comment
Share on other sites

So if anyone is interested: replacing enemies in missions is indeed very easy. As soon as the Encounterlist is populated, one can just change the template names of each individual enemy to ones liking. The difficult part is getting the shadowchamber to show the updated data correctly. Until now I tried to use a missionsite screenlistener. This works well for everything except for guerilla ops. The problem here is, that clicking on the button of one of the three options doesnt change the screenstack and therefore is not hookable afaik. There is the new UpdateShadowChamberMissionInfo hook. By the name of it one would assume that it just updates the displayed enemy names, but sadly returning true in this function rerolls the whole encounterlist for the selected mission which makes this useless for replacing single enemies.

Link to comment
Share on other sites

That function (UpdateShadowChamberMissionInfo) rerolls the encounters because it assumes you are modifying the TacticalGameplayTags on the HeadquartersXCom object, as those tags can force particular encounters to be included or excluded. Still, the game kind of assumes you are layering encounters on top of the default ones (like the Alien Hunters DLC does).

Link to comment
Share on other sites

Thanks once again for your input josh :). Sadly that doesnt seem to be useful for what we are trying to do. For a start I want to limit the spawnrates of my strong lategame enemies to a configurable amount without relying on the missions.ini (because compatibility stuff). I also tried to use UpdateShadowChamberMissionInfo as a simple hook without returning anything actually, sadly the guerilla ops mission behavior is kinda funky. The "primary" GOps mission is easy to change, updating the shadow chamber string can be done "manually". However the other two missions behave strangely. When i read the encounter data via UpdateShadowChamberMissionInfo or screenlistener, the console output is something entirely different than what the shadowchamber displays. Only after a second try (leaving the missionscreen and initiating it again), the console output and the shadowchamber info matches. At the moment I have the following idea: use onlosefocus on a strategymap listener to generate encounters for all missions that dont already have them and apply my changes. I am pretty sure for a programmer my ramblings are cringeworthy but ...whatever I'm just trying get stuff done! :p

Link to comment
Share on other sites

I did it! ...well mostly.

 

The order in which mission caching and the updating of shadowchamber strings has to be done in order to achieve the desired result for Guerilla ops is quite ...strange. There is a "primary" Mission (the one that gets selected when one chooses to use the mission button on the bottom of the strategy screen) and two secondary Missions by default. I had to make sure the primary Mission got cached before the UIMission screen initialized, else strange things would happen. All in all my code is probably messy, but it does the job. I can replace enemies if too much of them are detected, and the shadowchamber reflects this correctly. The only thing i probably cant account for: if UpdateShadowChamberMissionInfo returns true, my careful work will probably get destroyed. However I am sure the users of my mod can forgive slightly unaccurate shadowchamber info if that means the mission will be easier. For this reason i call my replacement function again with OnPreMission just to make sure that everything works.

 

The Replacement function itself is not very well developed but it does the job for my mod. It just replaces my enemy with a preselected different enemy depending on Encountername (so Boss encounters get a Sectopod or a Gatekeeper). A spawnsystem Overhaul mod would ofcourse need to take settings like Spawnweights, Forcelevels and MaxCharactersPerGroup into account to achieve good results.

 

For the curious (its a bit long and messy to post here):

https://dl.dropboxusercontent.com/u/61206138/MissionSite_Listener_Riftkeeper.uc

https://dl.dropboxusercontent.com/u/61206138/X2DownloadableContentInfo_Riftkeeper.uc

Edited by LeaderEnemyBoss
Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.

×
×
  • Create New...