SteelRook Posted July 28, 2016 Share Posted July 28, 2016 Gatekeepers are pure cheese and I hate them for it. That massive unavoidable AoE means either you kill the Gatekeeper on its own turn or you're losing soldiers, which makes for uninspired gameplay in my eyes. At the very least for my own game, I want to drop the Gatekeeper's damage on the Mass Reanimation attack considerably, down to something like 2-4. The problem with that is it basically takes the teeth out of the unit all but entirely, so I'd need to add something back. So... How about Shred? I tracked the ability itself down to X2Ability_Gatekeeper in its own CreateMassPsiReanimationAbility() function. So far, so good. I figured I could copy the design of either Schism (which is just a check to enable additional effects in Insanity and Void Rift) or Rupture (which seems to be called Bullet Shred in the game files). This faces me with several problems, however. And yes, this one I do fully intend to finish, unlike the Death From Above thing :) Problem #1: I don't actually know how "rupture" works. I haven't the slightest idea how Schism manages to "rupture" targets since all it seems to do is apply weapon damage via the standard X2Effect_ApplyWeaponDamage. class. Bullet Shred, aka Rupture, does use its own custom X2Effect_Shredder class which inherits X2Effect_ApplyWeaponDamage, but I'm not sure how that works. All it does is override the GetBonusEffectDamageValue function in that class which... What does that do? From everything I understand of X2Effect_ApplyWeaponDamage is it's a single-run class, meaning you run it once to apply damage without leaving any persistent effects on the enemy. Rupture, I thought, would be some variety of the X2Effect_Persistent class since it's... You know, a persistent effect, but I clearly don't know what's going on. How DOES the "rupture effect" work? Problem #2: I don't know how to actually introduce a new aspect to the Gatekeeper's Mass Reanimation ability without screwing it up majorly. The skill definition is full of very scary comments to the tune of "// DO NOT CHANGE THE ORDER OF THE DAMAGE AND THIS EFFECT" which make me reluctant to touch... Really any part of that skill. There must be a reason for the programmer to be this loud. If the Rupture effect is indeed some variety of X2Effect_ApplyWeaponDamage, then I can probably piggy-back it onto the already-existing Mass Reanimation damage by just altering that one effect, but... Can I be positive that won't mess something up? Problem #3: I don't know if aliens have separate variants per difficulty setting. Soldiers don't (luckily) which means I can theoretically just create a single new ability and jam that in the template manager at game launch and it will work. In fact, my Blademaster Enhancement mod just creates a child of the Ranger class and it seems to work fine. Difficulty-specific templates, however, get split into several versions of the same template and need to be fished out of the template manager one by one. I don't know if aliens and their skills require this or not. Any help on the matter would be greatly appreciated. Sorry to be needy like this, but I've done about as much of the legwork as my skills will allow me to. Link to comment Share on other sites More sharing options...
kexx456 Posted July 29, 2016 Share Posted July 29, 2016 Seems complicated, but doable. Personally, I'm afraid I won't be much help, BUT, in creating my own new enemy, I research a whole of units in the workshop. LeaderBoss has created several, and one of them is the Rift Keeper, a deadlier variant of the Gatekeeper. I would suggest you look into it, as all its complexities might help guide you into the right direction. As for the little advice/help I can offer, I would suggest creating a "new enemy" Gatekeeper to replace the original. Keep him the same but with your changes, so in any case you're changing him something goes belly up, you can still salvage the original alien. Link to comment Share on other sites More sharing options...
Stormhunter117 Posted July 29, 2016 Share Posted July 29, 2016 As I understand it (I could be wrong): Rupture is a stat that all XComGameState_Units have that specifies permanent extra damage to take. Similarly, Shred is a stat that XComGameState_Units have that specifics permanent reductions to the armor stat. Weapon damage is not done via direct integer value, instead, a struct called WeaponDamageValue is filled out and applied, which has Damage, Shred, and Rupture values among others. X2Effect_ApplyWeaponDamage has a method called GetBonusEffectDamageValue that other subclasses can call to add additional effects. X2Effect_Shredder extends this to add additional Shred damage, which affects the "Shred" value in the same way that "Damage" affects the "HP" value. Also, I'm not entirely sure about what's going on with the Reanimate ability but it might be that if you try to Reanimate units that aren't already dead you'll have problems, or it would just fail. Link to comment Share on other sites More sharing options...
SteelRook Posted July 29, 2016 Author Share Posted July 29, 2016 Wait, so Ruprture is permanent? That's... Not what I was expecting to hear, but it does make sense the way you've described it. That concerns me a little, if that's the case. Suppose Gatekeepr AoE only did 2-4 damage but ruptured all targets in range. That can potentially rupture your entire squad and do even more damage to them long-term than the standard Mass Resurrection AoE. If I'm reading this correctly, then Rupture (technically) adds "rupture points" onto a target, which then get added to any damage that target receives from that point on. From looking at the Grenadier code, it... Sort of looks like all I'd need to do is grab the Gatekeeper damage effect and append WeaponDamageEffect.EffectDamageValue.Rupture = <shred value> to it - literally one added line of code. I mean from your description, it sounds like it's literally as simple as that since the weapon damage effect is already part of the skill. That's... A lot simpler than I was expecting, but it gives me something to go on :) That still leaves the question of how to overwrite or append the ability, however. I found the RiftKeeper (turns out it's one word) mod, but that adds an entire new enemy, rather than replacing existing enemy skills. I was given an interesting approach to modding skills at runtime in another thread which I can probably use here, but that's predicated on there being just one copy of that skill. Do alien skills get replicated for all difficulty settings like weapons do, or do their templates exist as a single instance of the ability template? Because if the latter is the case, I can just pull out reanimation ability by its ability name ('AnimaInversion' if I'm not mistaken), access its PsiDamageEffect... Though I'm not entirely positive how that might work. The effect is added via the AddMultiTargetEffect() method, meaning it's adding something to an array that I'd then need to fish effects out of, and THOSE don't seem to be identified by a unique name. I mean worse come to worst, I can probably just create another instance of the Mass Reanimation ability with the same name, which SOMETIMES manages to overwrite the existing ability at start-up, but that would mean copy-pasting the entire body of code to add one line. Link to comment Share on other sites More sharing options...
Stormhunter117 Posted July 29, 2016 Share Posted July 29, 2016 (edited) Google and utilize OnPostTemplatesCreated to change existing stuff. And I don't understand what you mean concerning AddMultiTargetEffect(). All that states is that the effect gets applied to everything highlighted by the ability's corresponding MultiTargetStyle. Edited July 29, 2016 by Stormhunter117 Link to comment Share on other sites More sharing options...
SteelRook Posted July 29, 2016 Author Share Posted July 29, 2016 prowler83 explained to me how to use the OnPostTemplatesCreated method and how to reach the template for an item I'm looking for. The thing is that supposing I reach the 'AnimaInversion' ability's template, I'm not sure how to reach its X2Effect_ApplyWeaponDamage effect, which is what I need to add psychic damage to. The ability template is an object of class X2AbilityTemplate and the AddMultiTargetEffect() function adds an effect into an array called AbilityMultiTargetEffects in the template. That array is protected, meaning I can't access it directly unless my class extends X2AbilityTemplate, which X2DownloadableContentInfo_<class name> (where OnPostTemplatesCreated) doesn't. Normally there'd be a "getter" function for either the entire array or specific elements from it, but there isn't one that I can find. Basically, assuming I can find the X2AbilityTemplate of the Mass Resurrection skill, how can I "get" its AbilityMultiTargetEffects array? Once I have that, the rest should be easy. It looks like there's only one multi-target effect for that skill, so I can just draw member 0 from the array and add Rupture damage to it. Now, I presume the above will work like it would in Java where all objects references are inherently pointers. What I mean is if I draw a member from an array and alter it (add an extra damage component), the member still inside the array will also be altered since both would just be references pointing to the same object. I still have nightmares from doing C++ back in the day and having to manually specify *memory_address and &object_pointer. Incidentally, I managed to get this working through a very, very thuggish approach. I created a class which extends X2Ability_Gatekeeper and overwrites its CreateMassPsiReanimationAbility() function. XCOM 2 appears to search for classes in that inheritance tree and creates objects from them without my input. For some reason - and this may well be unreliable - modded objects which extend ability classes end up taking priority over base-game objects of the same kind, so the mod technically works. Now I COULD use OnPostTemplatesCreated to find the ability template itself in the template manager, but I'd still need a child of X2Ability_Gatekeeper or something else that's going to get pulled into the lists at run-time, which seems to do the same thing. Basically, it works for now, but I don't think that's a good way of doing it. Link to comment Share on other sites More sharing options...
SteelRook Posted July 29, 2016 Author Share Posted July 29, 2016 (edited) Actually, I take that back. I've not been able to get OnPostTemplatesCreated to work at all. It doesn't seem to trigger at any point. I put a log message in there which never shows up anywhere whatsoever. I may be checking the wrong longs (XCOM 2 SDK\XComGame\logs\Launch.log) and crucially - the changes I'm trying to make don't work. This is caused by an issue I've had before, where trying to read from configuration files when extending a class which already reads from those configuration files doesn't seem to work, and gives me no feedback as to what's going on. *edit*Never mind, figured it out. I was trying to use ini files wrong, so my value for Rupture wasn't being used, which I think caused the whole method to throw a silent exception and the template to never be finished. Now it works, and all I did was extend X2Ability_Gatekeeper. My new ability overrode the Vanilla one by itself, so now my Gatekeepers will do 2-4 damage with their mass resurrection AoE, but will shred soldiers (and Aliens and Advent) caught in the blast for 2. Cool. Edited July 29, 2016 by SteelRook Link to comment Share on other sites More sharing options...
prowler83 Posted July 30, 2016 Share Posted July 30, 2016 You can set child classes to read from a different ini file than the parent and they will get the values for its new variables from there. And for future reference, all template managers have FindDataTemplateAllDifficulties(name DataName, out array<X2DataTemplate> Templates) which will fill out the templates array with the difficulty variants of the specified name. Link to comment Share on other sites More sharing options...
Recommended Posts