Jump to content

Modding details? Ask away!


Amineri

Recommended Posts

Hi Amineri

 

Most of the posts in this forum (including my last question) seem to have disappeared for some reason.

 

Anyhow, I'm sure you can help me with this. I'm trying to override some of the functions in XComHumanPawn but the game crashes whenever I load a game. The soldier "lurking" in the foreground of the main menu screen also fails to appear. Even if I don't change anything the game still crashes when I override anything.

 

If I check the launch log I get these errors appearing:

Warning: SpawnActor failed because template class (XComHumanPawn) does not match spawn class (XComHumanPawn_BigHeads)

 

It looks like I also need to modify a template class somehow but I don't know where to look to do that. What am I missing here?

 

Thanks!

 

Hi, good to see you back again :)

 

The reason you can't use an override on the given class is because it is an archetype class. This means that the artists use it as a template when creating art in UnreadEd.

 

If you launch the XCOM 2 Editor (aka UnrealEd), look in the content browser and do a search for types XComHumanPawn, you'll find that these are already instanced during development. The Spawn in this case is being used to create a copy of that already instanced archetype, not a brand new one, which is why it is failing.

 

AFAIK, there are only two ways to change archetypes currently :

1) Change the archetype class, create new instances using the new archetype in UnrealEd (linking to same assets), then update config/template data to point to the new archetypes. This is akin to the pipeline for creating new art, which are you in a way.

2) Build a complete replacement for XComGame.upk, which would allow you to change the functionality of XComHumanPawn without changing the name. This is possible, but pretty drastic.

 

Regarding "big heads", one significant different from XCOM EU/EW to keep in mind is the following :

1) In EU/EW, the "body" was the root object to which attachments were made (head, weapon, etc)

2) In XCOM 2, the "head" is the root object to which attachments are made (torso, face props, beard, hair, etc). The torso gets attached to head, then arms and legs are attached to torso.

 

This may have an impact on what you are trying to do.

Link to comment
Share on other sites

  • Replies 399
  • Created
  • Last Reply

Top Posters In This Topic

Hello again, Amineri!

 

<snip>

 

 

PS.Also is there a full list of events? Can I see it somewhere? I'd like to see more vanilla script to understand how their work.

 

There are two types of events and two event systems going on.

 

1) The built-in one in Unreal Engine, which is used to pass events between Unreal, Kismet and GFx components. In Unrealscript, these look like :

 

`XCOMGRI.DoRemoteEvent('AnEventName');

2) The custom one built by Firaxis, which is within the gamestate system to modifiy behavior. In Unrealscript, these look like :

 

`XEVENTMGR.TriggerEvent( 'EventName', EventState, SourceState, NewGameState);

 

Both of these are defined implicitly, so there's no single "master list" which has to be updated. In the latter case, a RegisterForEvent method in the X2EventManager allows creating a new EventID implicitly by the act of registering it. So you can either search for "TriggerEvent" to find the various types of events that get triggered, or you can add code to make the X2EventManager dump debug output via its "AllEventListenersToString" debug method, then dump the string out to the log. The latter method will only show events that are registered at the time you invoke it, however, which may not be all of them possible.

Link to comment
Share on other sites

Hello,

 

I'm trying to add a slew of countries for my Game of Thrones Character pool. I have followed the youtube video that has a pretty good step by step instruction of how-to. However, when I go to save my upk file, I get an error:

 

The following packages have references to external packages:

(upk_name) [24 times]

External packages won't be found when in a game and all references will be broken.

Proceed?

 

so I saved anyway, built the remainder of the items in ModBuddy, but then after compiling, with no errors. I would go to the character pool, and would get an error when trying to select that country (Can't load flag texture), and the flag would not show up.

 

Any help would be greatly appreciated. Also, I want to combine the character pool within the mod, I'm sure that's super easy, but I can't seem to find how that's done.

 

Thanks

 

So, when a upk has a reference to another object in another upk, Unreal has to create links in order to find them. When the objects are "sitting in place" /XComGame/Content/ (which maps to place in XComGame/CookedPCConsole in game folder), this is no problem.

 

However, when you save your upk to your project folder, it ends up outside the XComGame folder, so it treated as an "external" upk. These upks can reference objects within the XComGame folder without problem, but can't resolve links to each other -- which is what your error is stating.

 

1) The way I got around this for our release mods was to put all objects that reference each other inside the same upk inside the mod's content folder. So when I was working on LWSMG_CV.upk and would save it, I would get messages saying that links to itself could not be resolved. The base game kept archetypes and art in different packages, but for our mods I put them into the same package, for this specific reason.

 

2) An theoretical alternative would be to create your content packages within the XComGame/Content folder so they are not treated as external packages. But then you would have to move them manually into your mod folder so that the precompileshaders commandlet gets run.

Link to comment
Share on other sites

 

There are two types of events and two event systems going on.

 

1) The built-in one in Unreal Engine, which is used to pass events between Unreal, Kismet and GFx components. In Unrealscript, these look like :

`XCOMGRI.DoRemoteEvent('AnEventName');

2) The custom one built by Firaxis, which is within the gamestate system to modifiy behavior. In Unrealscript, these look like :

`XEVENTMGR.TriggerEvent( 'EventName', EventState, SourceState, NewGameState);

Both of these are defined implicitly, so there's no single "master list" which has to be updated. In the latter case, a RegisterForEvent method in the X2EventManager allows creating a new EventID implicitly by the act of registering it. So you can either search for "TriggerEvent" to find the various types of events that get triggered, or you can add code to make the X2EventManager dump debug output via its "AllEventListenersToString" debug method, then dump the string out to the log. The latter method will only show events that are registered at the time you invoke it, however, which may not be all of them possible.

 

Thanks, I'll look into it.

 

I have another question - I started scripting and my project can't be built because I made a mistake in scripts. Is there any way I can debug this? XCOM2 Mod Buddy doesn't give me the reason script can't be compiled.

I tried setting up debug log but it seems like it's working in-game (judging by this thread http://forums.nexusmods.com/index.php?/topic/3788780-attaching-xcom2-to-debugger-modbuddy/).

Link to comment
Share on other sites

Hello again Amineri.

 

I've encountered an issue where skeletal meshes, such as the magazine and the trigger, connected to my weapon mod are in places they shouldn't be when in-game. When I load the skeletal mesh in the AnimSet Editor and put on Extra Meshs onto the Base of the weapon they are placed in their correct spots. I'm not entirely sure what may be causing this issue and I was wondering if you knew anything that could cause this problem. If you need me to provide pictures of what I'm talking about please let me know.

 

Thanks!

 

If you based your model off of something like the Assault Rifle, but modified the skeleton for your own weapon, then this is likely the culprit. We experienced this same issue with the SMGs.

 

The problem is likely the re-use of the AssaultRifle (or what you based on) animation set, as defined via the weapon archetype. When you actually play the animation, it will snap the skeleton back to the original Assault Rifle positions. So if you modify the skeleton, you properly should create a new animset.

 

Also, weapon attachments shouldn't be previewed via the "Extra Meshes" -- attachment are connected via Sockets, so you should preview attachments by loading the preview mesh in the Socket Manager for the Skeletal Mesh. Note that some of the sockets aren't connected to the root bone, but are connected to other bones instead. Hence if the skeleton deforms during the weapon animation, and the socket is attached to a bone that is moving, the attachment will move. This is often a desired feature :)

 

The way we got around this for the SMGs (in particular the conventional one where the Magazine bone is in a completely different place) was to attach the Mag socket to the root bone instead of to the Magazine bone. That way when the animation deformed the skeleton, the socket didn't move.

 

Hope this helps!

Link to comment
Share on other sites

Does anyone have a working example for overriding X2AbilityToHitCalc_StandardAim or a similar class? I've been trying, following the example template, and none of my subclass's functions are being called (no effect, no log output). There was one other poster in the thread who had the same problem with X2AbilityToHitCalc_Hacking, and at least a few others with problems getting their class overrides to do anything.

 

If you do a search through the source files for usages of X2AbilityToHitCalc_StandardAim (I use Notepad++), you'll find that the class is being explicitly specified in the weapon templates. Such as :

 

StandardAim = new class'X2AbilityToHitCalc_StandardAim';
StandardAim.bGuaranteedHit = true;
Template.AbilityToHitCalc = StandardAim;

from X2Ability_AdventMEC.CreateMicroMissilesAbility.

 

This is using new, so should be override-able, but it is being invoked when the game is launching, when the base-game templates are being loaded. Presumably this occurs prior to the mods being launched, so it's basically a sort of load-order issue. You'd want your class overrides to take place before these templates get loaded.

 

This is just a theory of mine, but could be confirmed by changing the DefaultEngine.ini to include your override definitions (implicitly making them part of the base game). I'm not quite sure when the relative timing of "config merging" versus "Template creation" occurs, since it's all deep down in the native exe ...

Link to comment
Share on other sites

I have a shamefully basic question, but is there any way to see either an API database representation of the game's base classes or at least have a look at the source code? The ExampleWeapon example shows a lot of interdependent functionality without explaining what any of the functions do, or what other functions or templates might be called, or where to find them.

 

Let's say, for instance, that I want to change what Death From Above does fundamentally, say to what Damn Good Ground used to do back in the day. Clearly that's not going to work with just ini file editing, but I haven't the foggiest which classes I'm supposed to look at, how they work or even how to override an existing skill rather than adding a new one.

Link to comment
Share on other sites

I'm missing something about how crit chance is handled in this game.

 

In X2AbilityToHitCalc_StandardAim.GetHitChance, all of the hit, crit, and graze modifiers are tallied (ex: 70% hit, 90% crit, 50% graze), and then X2AbilityToHitCalc.FinalizeHitChance to turn those numbers into a 0-100 "table" for hit, crit, graze, and miss.

 

The core of FinalizeHitChance is:

m_ShotBreakdown.FinalHitChance = m_ShotBreakdown.ResultTable[eHit_Success];
//  if crit goes negative, hit would get a boost, so restrict it to 0
if (m_ShotBreakdown.ResultTable[eHit_Crit] < 0)
	m_ShotBreakdown.ResultTable[eHit_Crit] = 0;
//  Crit is folded into the chance to hit, so lower accordingly
m_ShotBreakdown.ResultTable[eHit_Success] -= m_ShotBreakdown.ResultTable[eHit_Crit];
//  Graze is scaled against Success
if (m_ShotBreakdown.ResultTable[eHit_Graze] > 0)
{
	GrazeScale = float(m_ShotBreakdown.ResultTable[eHit_Graze]) / 100.0f;
	GrazeScale *= float(m_ShotBreakdown.FinalHitChance);
	FinalGraze = Round(GrazeScale);
	m_ShotBreakdown.ResultTable[eHit_Success] -= FinalGraze;
	m_ShotBreakdown.ResultTable[eHit_Graze] = FinalGraze;
}

The problem is that I can't seem to find the step in between where m_ShotBreakdown.ResultTable[eHit_Crit] is changed from a sum of crit mods (90%) into a final chance scaled to hit chance (0.7 * 90% = 63%). Without this step it makes no sense to directly subtract it from m_ShotBreakdown.ResultTable[eHit_Success]. Graze is scaled with hit chance before being subtracted, but I can't find a similar step for scaling crit.

 

I think that you are correct that this is a bit hinky.

 

In mathematical notation, if we set :

A = Event "Hit"

B = Event "Crit"

 

It seems that they are confusing P(B) with the conditional P(B | A). When we say "there is a 20% chance to crit", my understanding is that it's not an absolute, but is really a 20% chance to crit IF the shot hits -- that is, it is conditional. And by the definition of independent events :

 

P(B) = P(B | A) * P(A)

 

That is, the absolute probability of getting a crit is the conditional probably (e.g. 20%) times the probability of getting a hit in the first place.

 

With the code as it is,

 

P(A) = 20%, P(B | A) = 100%

 

The result is that the calculated to-hit ends up at -80% (0.2 - 1.0) and the Miss Result ends up at 180% (1.0 - (-0.8)). So not handling the crit conditional probably could have some strange effects, yes...

Link to comment
Share on other sites

I'm currently working on an alternative health display and this is what I've got right now.

<snip>

I'm having some problems getting the text to behave quite how I'd like it to. I can use UIText.SetTitle to get large text or I can use UIText.SetCenteredText to center the text, but I haven't found a way to do both at once.

 

Is there some way to freely style UIText or some other text related class I should be using instead?

 

 

You can use the class'UIUtilities_Text' static methods to apply html styling to your text. You can also nest them in order to add more tags (i.e. set title font/size as well as add centered html tags). Of course you can always add the html tags yourself, if you want :).

 

After that, it's a matter if using the inherited UIPanel controls (SetPosition, SetX, SetY) to position it accordingly. The position is relative to the how you create your UIIcon or UIText object in the InitPanel(...) or InitText(...) method.

Link to comment
Share on other sites

 

Does anyone know how to add multiplayer units into the single player barracks? I have looked at the .ini's for the soldier classes and there is a variable bMultiplayerOnly. How would I make this so advent troops(from multiplayer) can be loaded/recruited into them? I know they would work in the stat department as you can nickname them online. However, from what I have seen, only human soldier pawns can be added to the barracks. Any help would be super useful. Thanks.

 

P.S I just really want an ADVENT MEC as a soldier.

 

The game makes certain assumptions about classes, but you may be able to to what you want in the ClassData.ini.

 

You'd need to add your new class to XComGame.X2SoldierClass_DefaultClasses section.

Then create a new section for [AdvSoldier X2SoldierClassTemplate] in the same config

 

Ok thanks, im currently working on adding it to the barracks at the beginning, i got the class set up already. I will post my code up here if i cant get it to work. Thanks again for the help!

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.

×
×
  • Create New...