TeamDragonpunk Posted March 7, 2016 Share Posted March 7, 2016 Slightly off topic, can anyone really tell what X2AmbientNarrativeCriteria actually does? I just traced it through the code, and I'm still unsure. Link to comment Share on other sites More sharing options...
davidlallen Posted March 7, 2016 Share Posted March 7, 2016 For the purpose of this thread, it doesn't even matter. The point is that it comes last. Link to comment Share on other sites More sharing options...
Lucubration Posted March 7, 2016 Share Posted March 7, 2016 Based on its name alone, I'd guess that it probably looks up your latest saved game (characters and mission environment) and character pool to figure out what it's supposed to play in the background of the main menu. Link to comment Share on other sites More sharing options...
traenol Posted March 7, 2016 Share Posted March 7, 2016 Slightly off topic, can anyone really tell what X2AmbientNarrativeCriteria actually does? I just traced it through the code, and I'm still unsure.Traced the code around and found XGBaseAmbientVOMgr ... which as its name implies, handles the background chatter in the Avenger base screen. It might be used elsewhere, I stopped once I found at least one reference to it actually being used outside of a native function call. For the actual X2AmbientNarrativeCriteria class(not its children classes) its just a template class for the purposes of type casting. It's children seem to handle the various types of narrative VO's, and most likely when they are valid for being played. Link to comment Share on other sites More sharing options...
Lucubration Posted March 7, 2016 Share Posted March 7, 2016 Slightly off topic, can anyone really tell what X2AmbientNarrativeCriteria actually does? I just traced it through the code, and I'm still unsure.Traced the code around and found XGBaseAmbientVOMgr ... which as its name implies, handles the background chatter in the Avenger base screen. It might be used elsewhere, I stopped once I found at least one reference to it actually being used outside of a native function call. For the actual X2AmbientNarrativeCriteria class(not its children classes) its just a template class for the purposes of type casting. It's children seem to handle the various types of narrative VO's, and most likely when they are valid for being played. Oh. Yeah, that makes more sense. Link to comment Share on other sites More sharing options...
HazyAssaulter Posted March 8, 2016 Share Posted March 8, 2016 At risk of sounding like a complete idiot: I assume the @ signs in the OP example of the hook are placeholder, but I don't know what is supposed to go there if that is the case. I have a mod in mind that modifies a template, and I do not believe I will need to worry about the problem with the difficulty settings, as the template in question is the same across all difficulties in the vanilla game. If I can get a solid example of how to exactly implement this to modify a template, I hope I can simply change what I need to make this mod. Link to comment Share on other sites More sharing options...
aggies11 Posted March 8, 2016 Share Posted March 8, 2016 (edited) At risk of sounding like a complete idiot: I assume the @ signs in the OP example of the hook are placeholder, but I don't know what is supposed to go there if that is the case. I have a mod in mind that modifies a template, and I do not believe I will need to worry about the problem with the difficulty settings, as the template in question is the same across all difficulties in the vanilla game. If I can get a solid example of how to exactly implement this to modify a template, I hope I can simply change what I need to make this mod. 1. Those @ signs in the text of the log function call, presumably are just placeholders to make it easy for him to see it in the rather large log file, helps make it stand out. Since they are inside the string quotes (") they act as just visual characters I believe. Outside of quotes the @ symbol in Unreal I believe works as a string concatenation(combining) operator. I think one that adds in blank/white space in between the strings? You can look that up on the UDN/UDK language reference for confirmation (a great resource for anyone unfamiliar with unrealscript) 2. If I understand correctly (which is never a guarantee at this early stage of my modding adventures :wink:, what you intend to do does not require use of technique in this post. This technique is to provide a single implementation of this method, implemented by one mod, and then other mods are to us functionality provided with it. Think of it like eXecator cutting a hole in the wall and building a doorframe for us to walk through, so that we don't have to always go around blasting holes in walls ourselves (which is messy). If that sounds appealing then you'd look up his mod that provides this and follow it's instructions. Otherwise you have two ways of accomplishing your task.1. Modify templates at RUNTIME, post creation, using custom UIScreenListener classes you make as the entry point for making your modifications. This is the "standard" way of doing this, but requires a bit of extra work. See Amineri's post(s) for examples of this, I believe it's used in the Longwar Studios office mod (so look at it's source for further enlightenment). 2. Use the information provided by eXecator in this post (note: not his code! His code exists to built a doorway for others to use) basically by "cheating" the createTemplates() function of custom version of the X2AmbientNarrativeCriteria class, as a "safe" place to modify templates. This is basically the same as #1, but a different way of doing it. Not sure if it's better/worse, but for eXecator's goal, it provides a good place to build that proverbial "doorway". If you are already familiar with extending Datasets to create templates, then this one should be the same speed and avoids having to learn about UIScreenListeners and the events they are invoked for. Hopefully that helps (and also is reasonably accurate :wink: Edited March 8, 2016 by aggies11 Link to comment Share on other sites More sharing options...
davidlallen Posted March 10, 2016 Share Posted March 10, 2016 OK, I have used this technique now, because I ran into a problem with simply copying the Chryssalid burrow ability. File X2Ability_Chryssalid contains some local, non-static functions, and I cannot get the syntax right to make this work when I copy just the ability. So instead, I am extending the ambient narrative class, to find the burrow ability and make it a neutral, rather than hostile action. This way when a playable chryssalid burrows, it won't break the player's concealment. My question is: what happens when a player loads two mods, both of which extend this class? Will both extensions take effect? But the functions have the same names, so won't one be ignored? If we use the doorway analogy, then I think if two mods try to use the same doorway, the first one blocks the door so nobody else can use it. Link to comment Share on other sites More sharing options...
Lucubration Posted March 12, 2016 Share Posted March 12, 2016 @davidlallen - If two modders extend the class, both class' CreateTemplates() static methods should get called in the order in which the mods are loaded. From what I understand, something in the native code finds everything that extends X2DataSet (or perhaps each of the subclass types it knows about, like X2Ability, X2Item, etc?) and calls the static method CreateTemplatesEvent(), which in turn calls CreateTemplates(). Link to comment Share on other sites More sharing options...
davidlallen Posted March 23, 2016 Share Posted March 23, 2016 (edited) I had a fairly long discussion with /u/fxsjosh about this and he suggested a slightly better approach. Sometimes, the problem of referring to nonstatic functions of other classes gets mixed into this, as described here: http://forums.nexusmods.com/index.php?/topic/3901270-referring-to-nonstatic-functions-from-another-class/ If you extend X2AmbientNarrativeCriteria as suggested in the OP, you can't access non-static functions of the class. If you extend the class itself, you can. Here is an example. I wanted to set the min/max forcelevel of all the default characters to 98/99, ensuring that none of the default leaders will never be chosen in encounters. class HO_Characters extends X2Character_DefaultCharacters config(XComGameData_CharacterStats); static function array<X2DataTemplate> CreateTemplates() { local array<X2DataTemplate> Templates; local X2CharacterTemplate Template; local int i, len; `log ("davea debug hoct enter"); Templates = super.CreateTemplates(); // Zero out the leader weights for all default characters for (i=0; i<Templates.Length; i++) { Template = X2CharacterTemplate(Templates[i]); len = Template.LeaderLevelSpawnWeights.Length; if (len > 0) { Template.LeaderLevelSpawnWeights[0].MinForceLevel=99; Template.LeaderLevelSpawnWeights[0].MaxForceLevel=98; } } // Add my templates Templates.AddItem(Create_HO_Brad('HO_Brad')); Templates.AddItem(Create_HO_Tygan('HO_Tygan')); Templates.AddItem(Create_HO_Shen('HO_Shen')); Templates.AddItem(Create_HO_Military('HO_Grenadier', 'SquaddieGrenadier')); Templates.AddItem(Create_HO_Military('HO_Specialist', 'SquaddieSpecialist')); Templates.AddItem(Create_HO_Military('HO_Ranger', 'SquaddieRanger')); Templates.AddItem(Create_HO_Military('HO_Sharp', 'SquaddieSharpshooter')); return Templates; }I can iterate over all the templates which were created to change them, and then add my own. This example doesn't refer to non-static functions, but the same technique would apply, and it can avoid the need of copy/pasting hundreds of lines of code. Link back to previous discussion:https://www.reddit.com/r/xcom2mods/comments/4555vw/overcoming_the_static_function_barrier_has_anyone/d18e7dq Edited March 23, 2016 by davidlallen Link to comment Share on other sites More sharing options...
Recommended Posts