SteelRook Posted February 19, 2016 Author Share Posted February 19, 2016 (edited) Since AbilityTemplates defaultproperties dont change bShouldCreateDifficultyVariants it should be "false". This would imply that abilities in fact will not differ with difficulty.That's good news, then. I think I'll sidestep the entire process of changing difficulty for now, and instead work on the ability templates themselves. Pulling stats out of an ini file is going to be... Tricky, to say the least, but I'm starting to think that baking ability-specific skills into weapons is a bad approach in general. The templates system is meant to be moddable, so abilities should be handling their own extra stats, I think. *edit* Just one quick question because this is confusing me. What exactly does this line say? That's from X2Effect_Persistent. if (AbilityState.SourceWeapon == EffectState.ApplyEffectParameters.ItemStateObjectRef) Here, AbilityState is an object of type XComGameState_Ability and EffectState is an object of type XComGameState_Effect. It was explained to me that AbilityState.SourceWeapon return a StateObjectReference, which I can then use in the `XCOMHISTORY.GetGameStateForObjectID(AbilityState.SourceWeapon.ObjectID) macro in order to draw out the actual object of the weapon template. I used this to try and draw the extra data I'd put into my own unique weapon model. Can I do the same for the other one, though? Can I say this: `XCOMHISTORY.GetGameStateForObjectID(EffectState.ApplyEffectParameters.ItemStateObjectRef) ? Because if I can, then I can pull both of those out as variable, simplify the IF quite a bit and be left with a reference to the weapon template from which I can then draw tech level, on the basis of which I'll determine the strength of the bonus. My code grew cancerous in experimentation and now I'm trying to cull as many extraneous classes and code as I can. Edited February 19, 2016 by SteelRook Link to comment Share on other sites More sharing options...
SteelRook Posted February 19, 2016 Author Share Posted February 19, 2016 OK, this makes absolutely no sense to me... Apparently phantom objects now do things despite never being used, or else I'm missing something blindly obvious. I decided to ditch my alterations to the Ranger Swords and instead cooked the bonus values in a custom X2Effect_Persistent child. This worked when I was outright replacing the Blademaster template with a newly-created one, but I wanted to leave a smaller footprint. As such, I instead decided to tweak my custom persistent effect and add it to the existing Blademaster template as an additional persistent effect. The following code works, but with a caveat: function InitialiseStats() { local X2AbilityTemplateManager AbilityTemplateManager; local X2AbilityTemplate NewAbilityTemplate; local X2AbilityTemplate OldAbilityTemplate; local X2Effect_BonusEffect_Blademaster NewDamageEffect; AbilityTemplateManager = class'X2AbilityTemplateManager'.static.GetAbilityTemplateManager(); OldAbilityTemplate = AbilityTemplateManager.FindAbilityTemplate('Blademaster'); `CREATE_X2ABILITY_TEMPLATE(NewAbilityTemplate, 'Blademaster'); NewDamageEffect = new class'X2Effect_BonusEffect_Blademaster'; NewDamageEffect.BuildPersistentEffect(1, true, false, false); NewDamageEffect.SetDisplayInfo(ePerkBuff_Passive, OldAbilityTemplate.LocFriendlyName,OldAbilityTemplate.GetMyLongDescription(), OldAbilityTemplate.IconImage, true,,OldAbilityTemplate.AbilitySourceName); OldAbilityTemplate.AddTargetEffect(NewDamageEffect); } As you can see, I'm defining a NewAbilityTemplate variable which I never actually use. I create a blank template for it, which I don't fill in with anything. Thing is, if I remove the variable definition line and its initialisation line, then this function doesn't "work." The added damage and armour penetration from the persistent effect I'm trying to add to OldAbilityTemplate doesn't get added. I am completely stumped by this, because it makes no sense. Why would the existence of a variable I literally never use facilitate adding a new persistent effect into a completely different variable. It's `CREATE_X2ABILITY_TEMPLATE(NewAbilityTemplate, 'Blademaster'); that's doing it. Without that line, the extra effect doesn't get added, but that line should in no god damn way affect OldAbilityTemplate! I'm starting to get frustrated again... What am I missing here? Link to comment Share on other sites More sharing options...
SteelRook Posted February 20, 2016 Author Share Posted February 20, 2016 Hmm... So I've noticed something very, very odd. If I attempt to add an extra damage effect to an ability, that command fails. If, however, I create a completely useless new ability, never even reference it, the command succeeds. As long as I'm creating a new ability with the same name as the old one, everything goes through. I suspect that I'm missing a step of somehow "rebuilding" the OldAbilityTemplate in order for it to acknowledge the change, a sort of "rebuild" method hiding somewhere. I suspect what I'm missing is this: Template.BuildNewGameStateFn = TypicalAbility_BuildGameState; Does anyone know what this bit of code does and if I need to replicate it somehow in order to add new pieces to the ability? I'd dearly hate to have to scrap the ability template and make a new one in its place, even though I could. Link to comment Share on other sites More sharing options...
Deleted32045420User Posted February 20, 2016 Share Posted February 20, 2016 Hmm... So I've noticed something very, very odd. If I attempt to add an extra damage effect to an ability, that command fails. If, however, I create a completely useless new ability, never even reference it, the command succeeds. As long as I'm creating a new ability with the same name as the old one, everything goes through. I suspect that I'm missing a step of somehow "rebuilding" the OldAbilityTemplate in order for it to acknowledge the change, a sort of "rebuild" method hiding somewhere. I suspect what I'm missing is this: Template.BuildNewGameStateFn = TypicalAbility_BuildGameState; Does anyone know what this bit of code does and if I need to replicate it somehow in order to add new pieces to the ability? I'd dearly hate to have to scrap the ability template and make a new one in its place, even though I could.I dont know what the code is actually doing (though i suspect it's building a new gamestate to submit) but as long as your ability is a child of X2Ability it'll compile fine. Link to comment Share on other sites More sharing options...
SteelRook Posted February 20, 2016 Author Share Posted February 20, 2016 (edited) It compiles, but the new persistent effect doesn't trigger, or at the very least doesn't show up in the on-screen visualisation. Since I want to keep the project going, I've gone back to replacing the entire ability with an almost exact copy. I don't like doing that, but at least that way it works - I see everything on-screen and enemies take the appropriate damage, including armour-ignoring damage. I suspect I may have to leave the ability in this state until Firaxis implement a proper template overriding mechanic which doesn't rely on fishing for templates. That does leave the question open, though - if all I wanted to do was pull an ability template out of the manager and add an extra effect to it, how would I do that? Because literally doing what I described doesn't work. The code compiles but the new effect is not in effect. *edit*I also found a very... Problematic issue with the ranger swords. Sword_MG - the "magnetic" sword variant - stagged as Template.WeaponTech = 'conventional'; That... Is actually a huge problem because it means I can't make a specific check as to the swords' tech level. I may need to check for their names, instead, but this seems like a major slip in the source code. Edited February 20, 2016 by SteelRook Link to comment Share on other sites More sharing options...
Amineri Posted February 20, 2016 Share Posted February 20, 2016 I haven't thought about your particular case a ton, but off the top of my head, here are my suggestions : Each Ability Template, when created, can have an array of AdditionalAbilities. These additional abilities are added whenever the original is. So, if you create a new ability, that adds bonus damage for specific weapon types (I'd probably code this using a custom struct and config array of this custom struct), what you'd need to do is alter the base-game "Blademaster" ability by using Template.AdditionalAbilities.AddItem('Blademaster_BonusDamage'; The additional abilities are gathered when the unit enters a tactical mission from strategy, so it won't take effect when loading a tactical save, but only when you start a new mission. The new ability would have the same PostBeginPlay trigger that most mission-duration persistent effects have. Link to comment Share on other sites More sharing options...
SteelRook Posted February 20, 2016 Author Share Posted February 20, 2016 (edited) The additional abilities are gathered when the unit enters a tactical mission from strategy, so it won't take effect when loading a tactical save, but only when you start a new mission. The new ability would have the same PostBeginPlay trigger that most mission-duration persistent effects have. That's a problem, though, because the altered weapon stats are lost when quitting the game, which will have the knock-on effect of removing the ability if I save mid-tactical-mission and quit the game. For the time being, I've bitten the bullet and I'm currently overriding the entire ability template. That is to say - I pull the template from the ability templates manager, create a brand new ability, copy stats over from the old one, then outright replace the old one in the template manager with the new one. My head is about to split in half, this practice works so I'm likely going to stick with it until we gain the ability to overwrite base game templates. I'll fix it up nice and tidy at that point. Honestly, at this point I'm having recurring nightmares about this mod. Seriously. I dream of conditional statements... But at least it's almost done. Using brute-force approach of replacing the entire ability template with my own ability template of choice, using my own version of a damage effect, then checking each individual weapon for its DataName because the TechLevels aren't set properly works. The correct damage and armour penetration is applied to the correct weapon. I still have a few more things to finish up, but it looks to me like this is almost finished and should be ready for distribution. Then I'm going to sleep for 10 hours because I'm beginning to stress out. *edit*I do have a few things left to do to "pretty it up" that I don't know how to do. I'd like to create a mod-specific ini file where the actual stats would be, and I'm not entirely sure how that works. I also have an issue accessing the BonusDmg of the original Blademaster skill. For the time being, that's hard-coded to 2 since I couldn't pull it out of the old skill before replacing it. If you guys can help me solve those two, then I should be able to just throw this thing onto the Workshop and actually make it usable. Edited February 20, 2016 by SteelRook Link to comment Share on other sites More sharing options...
davidlallen Posted February 20, 2016 Share Posted February 20, 2016 Wow, I have to admit most of what you are doing is over my head so far, but it sounds like you are blazing an important trail. Lots of mods create their own ini files. It seems like you just add "config(BladeMaster)" in your class declaration and then add a few variables of "var config" type. This appears to automatically search for any BladeMaster.ini file, and override any of these variables with matching entry names from the ini file. I grant I haven't done it personally, so there may be some complexity I missed. Link to comment Share on other sites More sharing options...
SteelRook Posted February 20, 2016 Author Share Posted February 20, 2016 Wow, I have to admit most of what you are doing is over my head so far, but it sounds like you are blazing an important trail.I don't know, it doesn't feel like I'm doing much on my own. Most of this mod is put together from the stuff you guys have told me, or at the very least it's based on your explanations and suggestions. A lot of my efforts were spinning wheels in the mud, as well. Just now I axed three entire classes and one ini file :) Lots of mods create their own ini files. It seems like you just add "config(BladeMaster)" in your class declaration and then add a few variables of "var config" type. This appears to automatically search for any BladeMaster.ini file, and override any of these variables with matching entry names from the ini file. I grant I haven't done it personally, so there may be some complexity I missed.I got it to work, eventually, but the format is... Odd. It seems to me like the game expects all the ini files to be called XCom___, but you're not supposed to put that part in the actual config definitions. As such, I ended up calling my config file XComBlademasterEnhancement.ini, but declared it as a config file as config(BlademasterEnhancement). That took a few tries to figure out and I'm not entirely sure why it's even the case. My sneaking suspicion is this is to account for the difference between the "default" ini files which live in Steam and the implemented "XCom" ini files which live in My Documents. In either case, it works now, seemingly. All I have left to do is figure out how to pull the X2Effect_BonusWeaponDamage template out of the X2AbilityTemplate representation of the Blademaster ability. I already have a reference to the ability template itself and I know it stores its ability effects inside an array, but I've so far not been able to pull items out of that array. If you saw my comment on "getters" in the developer thread, this is what that was a reference to. I don't know how to get the templates of the effects an ability has. Link to comment Share on other sites More sharing options...
Amineri Posted February 20, 2016 Share Posted February 20, 2016 The additional abilities are gathered when the unit enters a tactical mission from strategy, so it won't take effect when loading a tactical save, but only when you start a new mission. The new ability would have the same PostBeginPlay trigger that most mission-duration persistent effects have. That's a problem, though, because the altered weapon stats are lost when quitting the game, which will have the knock-on effect of removing the ability if I save mid-tactical-mission and quit the game. For the time being, I've bitten the bullet and I'm currently overriding the entire ability template. That is to say - I pull the template from the ability templates manager, create a brand new ability, copy stats over from the old one, then outright replace the old one in the template manager with the new one. My head is about to split in half, this practice works so I'm likely going to stick with it until we gain the ability to overwrite base game templates. I'll fix it up nice and tidy at that point. I'm not seeing why this would be the case, unless you are doing something unusual that I'm not understanding. 1. When starting a tactical mission, the abilities are gathered, and instanced into XComGameState_Ability classes that are stored in the Abilities array in the XComGameState_Unit. That's what makes them persist through save/quit/load cycle when in the tactical game.2. If the ability has a trigger PostUnitBeginPlay then any effect it has will create an XComGameState_Effect class instance attached to the XComGameState_Unit. This is what makes effects persist through save/quit/load cycle. This trigger can be created using : Template.AbilityTriggers.AddItem(default.UnitPostBeginPlayTrigger); Link to comment Share on other sites More sharing options...
Recommended Posts