Jump to content

Modding details? Ask away!


Amineri

Recommended Posts

 

it's getting called every time the game creates a unit anyways, my main problem is that my code dosnt override the current code for some reason, i might be trying to get all the unit creation to be a Unit_NCE creation and it will call my function there

 

Wow, I wasn't around this week due to work. Looks like you solved the problem. Great job man.

Link to comment
Share on other sites

  • Replies 399
  • Created
  • Last Reply

Top Posters In This Topic

Completely nuts...

 

Very first attempt at compiling went like this;

 

--------------------

Warning/Error Summary
---------------------
G:\Steam\steamapps\common\XCOM 2 SDK\Development\Src\q--UI--ck\Classes\X2DownloadableContentInfo_q--UI--ck.uc(11) : Error, Class name 'X2DownloadableContentInfo_q' doesn't match name of source file 'X2DownloadableContentInfo_q--UI--ck'

-------------------

 

I must be stupid, somehow.

 

 

PS; Please dis-regard... since it is NOT me who was being stupid at all. VS/Shell +/- Steam/Workshop +/- Firaxis/MudBuddy aren't compatible with the extremely common MS-Windows ASCII character Dash(-) when typed into a simple mod name or whatever else must be attached to the string in question. Really? Soooooo weird. But at least it could compile with a new name like this... quuUIiick. There, happy now!! :geek:

Edited by Zyxpsilon
Link to comment
Share on other sites

I'm trying to figure out how to nerf Mimic Beacons so they just have the normal priority of a soldier, and are not always targeted first.

 

The AI units have behaviors defined like this in the AI.ini

Behaviors=(BehaviorName=AdvShieldBearer_RedAbilitySelector, NodeType=Selector, Child[0]=MimicBeaconBehavior, Child[1]=ShieldBearerFirstAction, Child[2]=ShieldBearerLastAction) 

If I remove the definition of MimicBeaconBehavior or the child notes, then all the AI units ignore Mimic Beacons instead.

 

 

in AIBehavior.uc this seems to be the result of the priority check:

function bool PassesRestriction( vector vPosition )
{

...

// If a visible mimic beacon exists, all destinations must have LoS to it.
			if( BTPriorityTarget > 0 && bScoringPriorityTarget )
			{
				TilePosition = XWorld.GetTileCoordinatesFromPosition(vPosition);
				PriorityTile = XWorld.GetTileCoordinatesFromPosition(ScoringPriorityLocation);
				if (!`XWORLD.CanSeeTileToTile(TilePosition, PriorityTile, VisInfo))
				{
					return false;
				}
			}


Is the BTPriorityTarget always a mimic beacon? iCacheScoringPriorityValues() and BT_SetTargetAsPriority() make it unclear. The AI code generally is super confusing to me.

 

So, I won't go into full detail on how the behavior tree works here, but the "NodeType=Selector" basically goes through each option in order, checking to see if it is valid and can be executed. In terms of a tree, it's a depth-first left-hand parsing rule.

 

Reworking the AI to target mimic beacons the same as any other unit would require folding it into the FirstAction and SecondAction options, at the least.

Link to comment
Share on other sites

Apparently it's possible to take advantage of subtype polymorphism to get around a limited set of the issues surrounding GameState classes and overriding.

 

<snip>

 

-- TL;DR --

Subclass an awkward class, replace objects dynamically in GameState instead of using ModOverrides. And hope that Firaxis does something to improve this situation - Too much of the important game logic that mods want to change is tucked away inside classes that we can't override through any sane means.

 

It's really great having an SDK and access to so much of the game's source code - It's a far cry from the hexediting we did with EU/EW, but it's also disappointing when you dig into the codebase and see just how much of it is far more awkward to manipulate than it could be. :sad:

 

Yes, overriding class is a bit of a pain and not friendly to other mods. However, there is a REALLY IMPORTANT tool regarding gamestates that hasn't been brought up yet, but I will do so now.

 

Built in to the XComGameState_BaseObject class is support for game state components. That is, any gamestate can attach any number of components to itself. This can recurse, so these can be organized into logical trees.

 

This doesn't allow overriding functionality in the original game state in many cases, but is the principle way to effectively add new functions or data to a gamestate class. As an example, in the officer mod I created a new class called XComGameState_Unit_LWOfficer. This actually directly extends BaseObject, not unit. I named it with "Unit" in the name to indicate that it is intended to function as a component of the Unit gamestate.

 

I also built a Utiity class with statics (although these could go into the gamestate itself to reduce class-count, I suppose) which allows retrieving the officer component given a unit game state. This works via code :

 

XComGameState_Unit_LWOfficer(Unit.FindComponentObject(class'XComGameState_Unit_LWOfficer'));

 

So, in UIcode where you'd typically think to access the Unit gamestate to store/retrieve data, or provide some sort of function, you can instead retrieve your mod's unit component to provide the same service.

Link to comment
Share on other sites

Hi, Amineri, one more question:

How to show any dialog on InstallNewCampaign?

I try to do that:

   local XComPresentationLayerBase presentationLayer;
    local Albeoris_RichHeritage_SelectFacilitiesDialog selectFacilitiesDialog;

    presentationLayer = XComPlayerController(class'UIInteraction'.static.GetLocalPlayer(0).Actor).Pres;
    selectFacilitiesDialog = presentationLayer.Spawn(class'Albeoris_RichHeritage_SelectFacilitiesDialog', presentationLayer);
    presentationLayer.ScreenStack.Push(selectFacilitiesDialog);

It displayd but instantly disappeared because into movie was played.

How can I avoid this?

 

P.S. I do not want to override any default functions, so as not to break compatibility with other mods.

 

I haven't tried this yet, so can't answer why it isn't working. But, I'll test it out in the next day or two and get back to you if I figure anything out.

Link to comment
Share on other sites

I have one final question and I'll stop bothering you, I promise!

 

Is it possible to override just a single function from a class without having to override the entire class? Failing that, how would I overwrite an entire class with another class which inherits it? A bit of context on what I'm trying to do:

 

I want to make Blademaster give +2 damage to conventional swords, +3 damage to magnetic swords and +4 damage to beam swords, as well as +0 armour penetration to conventional swords, +1 armour penetration to magnetic swords and +2 armour penetration to beam swords. Following the example of the Gremlin, I'll need to expand the X2WeaponTemplate class into, say, an X2RangerSword class. This new class will hold the added Blademaster extra damage and extra armour penetration values based on the sword's tech level. This brings up two problems:

 

1. I'll need to override three methods in "X2Item_DefaultWeapons.uc", specifically "CreateTemplate_Sword_Conventional()", "CreateTemplate_Sword_Magnetic()" and "CreateTemplate_Sword_Beam()" in order to have them build an X2RangerSword template, rather than an "X2WeaonTemplate" template, in order for me to add the extra damage and armour penetration for each individual sword.

 

2. I'll need to override one method in "X2Ability_RangerAbilitySet.uc", specifically "Blademaster()", such that it alters the damage buff it applies based on the sword's own tech level, as well as figure out a way to apply an armour penetration buff, which I'll probably end up pulling from the definition of AP rounds. *edit* Found the "X2Effect_APRounds.uc" which controls armour-piercing rounds, which is just a special-case "X2Effect_Persistent". I can make my own version of this, so that's that problem sorted.

 

There are still other things I'm not entirely sure how to do, such as add new entries to the ini files and actually have them read (can always hardcode, would like to not have to do that) and handle armour penetration since I don't know if a buff for that even exists, but that's solvable through more code diving. My primary issue right now is I'm missing the starting point. How do I alter the behaviour of an existing in-game class without overriding too much code? How would that even happen? I'm used to programming where I control the starting point - the main method - from where everything is called. How do I ensure my newly-created classes get added to the game without literally changing the game's own files?

 

Apologies for the scattershot questions. I'm trying to gain a deeper understanding of how UnrealScript works on a fundamental level, and this exercise seems like a good starting point since it's mostly stuff the game already does by itself. I'm missing the starting point, though.

 

In your case you don't need to override the "CreateTemplate" functions, as they are only run when the game launches. Their purpose is to create the template class instances, which get stored in the appropriate TemplateManager (this all happens in native code at launch, so is "invisible" to us).

 

What you need to do is either modify or overwrite the templates themselves.

Link to comment
Share on other sites

In your case you don't need to override the "CreateTemplate" functions, as they are only run when the game launches. Their purpose is to create the template class instances, which get stored in the appropriate TemplateManager (this all happens in native code at launch, so is "invisible" to us).

 

What you need to do is either modify or overwrite the templates themselves.

 

Well, my idea was to add the extra damage and extra armour penetration values into the ini files themselves so I don't have to go digging through UnrealScript files if I wanted to change them and - potentially - so people who want to tweak the mod don't have to, either. What I ended up doing is creating a unique template for swords which has two extra variables - one for extra Blademaster damage, one for extra Blademaster AP. I didn't see any other way to force the game to use my new X2SwordTemplate other than overriding the three CreateTemplate_Sword functions. Which, by the way, I found out how to do :smile:

 

I have a unique sword template, a tweak to X2Item_DefaultWeapons so that it both reads my six new settings from the ini file and creates a unique X2SwordTemplate which holds all the Sword's original stats plus the added Blademaster bonus stats. What stumped me is actually doing the conditional check for which weapon type I'm using. It's obvious the Blademaster ability doesn't have any explicit check on what what weapons it'll work with, which seems to be handled elsewhere in the code. What that means is I need my own version of X2Effect_BonusWeaponDamage which specifically checks for the Sword's bonus damage, but I don't know how to actually get the sword itself from within that.

 

What I've come to the conclusion that I need is to somehow find an instance of the weapon itself from within GetAttackingDamageModifier in X2Effect_BonusWeaponDamage, which I don't know how to do. The existing code uses AbilityState.SourceWeapon, but the problem is that that gives me an object of type StateObjectReference which I have no idea how to use. That's not in the SDK's "classes" folder, which leads me to suspect it's a UDK-specific class, and I don't know what methods and variables that has exposed. I'm not aware of any skills in the game which add bonus damage based on a weapon-specific trait, so I haven't the foggiest idea of how to do that.

 

Basically, if I have an XComGameState_Ability, how can I get an object variable of the weapon used to activate the ability, such that I can check its name, damage or other, potentially hidden stats? Or do I just typecast StateObjectReference into the proper weapon template? *edit* Or else what can I do to ensure Blademaster does different amounts of damage based on what sword is equipped?

Edited by SteelRook
Link to comment
Share on other sites

I have a question about adding the teleport ability to a custom class.

I copied the ranger class to use as a base for a new class but i want to give it the teleport ability from the avatar/codex.

 

I got the teleport working but there's no animation present so now the unit simply blinks from one point to the other.

UXcomAnimTreeController::PlayFullBodyDynamicAnim - Can't play animation HL_Teleportstart
UXcomAnimTreeController::PlayFullBodyDynamicAnim - Can't play animation HL_Teleportstop
How do i get the correct animation to show?
Do i have to create a 'X2Ability_<myclass>.uc' based on either the codex or avatar (PsiWitch and Cyberus respectively)?
Link to comment
Share on other sites

Simple question. I need to add class exclusivity to a grenade, but can't figure it out. I want the grenade to be equippable only by the Psi Operative. I've tried to use "Template.Requirements.RequiredSoldierClass = 'PsiOperative';" but it doesn't seem to work. Thanks in advance.

Link to comment
Share on other sites

Anyone know where the code is that does the target highlighting right when an ability is used?

 

I've run into a problem with my current implementation of trying to factor in aim assist effects into a displayed hit chance flyover (implemented in X2Action_ApplyWeaponDamageToUnit) - I need to show it somewhere before the gamestate is updated with the results of the shot, because retracing aim assist calculations requires looking up the player's miss streak and the number of live xcom soldiers before the shot is taken. This probably means finding a different class where 1) the ability being used is defined, so I can use its hit calc, and 2) the shot itself hasn't happened yet.

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.

×
×
  • Create New...