Jump to content

Modding details? Ask away!


Amineri

Recommended Posts

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.

 

DefaultClassData.ini seems to have definitions of gear restrictions, though it only defines restrictions for primary and secondary. However, the system looks like it's set up to handle any potential slot as long as you know its name. Check out X2SoldierClassTemplate.uc, that has a AllowedWeapons array. The ini file looks like it pumps two restrictions into that array when the PsiOperative template is created, allowing the PsiOp to use only rifles as a primary and PsiAmps as a secondary. However, you may need to override the IsWeaponAllowedByClass() function, as that has an explicit exit state for anything that's not a primary or a secondary weapon. Not sure why that's there, but that's likely what's preventing you from restricting the grenade of your choice.

 

Do note, however, that this restriction is probably there for a reason. The rest of the code may not be equipped to handle non-primary/secondary restrictions, or you may end up restricting all secondary weapons from all soldiers, which will force you to specifically list every grenade, vest and other gadget they can use.

Link to comment
Share on other sites

  • Replies 399
  • Created
  • Last Reply

Top Posters In This Topic

*SOLVED*



Okay, so, I am totally running against some kind of wall here.

 

I am trying to add armor values to primary armor (predator and wraith, specifically), as I require this for balance purposes.

I have already taken a look at "Armor gives Armor" on the workshop, but icewhisp there uses the default values from other items to add armor values, were as I would wish to have it configurable seperately.

 

For starts, all wcompiles/runs fine, but neither Wraith nor Predator seem to grant any additional armor.

 

 

This is my XcomGameCore.ini, the changes to hp/mobility/dodge are all fine and working.

;Adding/changing lines for the armor stats
[XComGame]

;Balance changes for existing entries
[XComGame.X2Ability_ItemGrantedAbilitySet]

;Predator armor
-MEDIUM_PLATED_HEALTH_BONUS=4
+MEDIUM_PLATED_HEALTH_BONUS=3

;Exo armor
-HEAVY_PLATED_HEALTH_BONUS=5
+HEAVY_PLATED_HEALTH_BONUS=4
-HEAVY_PLATED_MITIGATION_AMOUNT=1
+HEAVY_PLATED_MITIGATION_AMOUNT=2

;Spider armor gets +2 instead of +1 movement for balance purposes
-LIGHT_PLATED_MOBILITY_BONUS=1
+LIGHT_PLATED_MOBILITY_BONUS=2

;Warden armor
-MEDIUM_POWERED_HEALTH_BONUS=6
+MEDIUM_POWERED_HEALTH_BONUS=5
-MEDIUM_POWERED_MITIGATION_AMOUNT=1
+MEDIUM_POWERED_MITIGATION_AMOUNT=2

;War armor
-HEAVY_POWERED_MITIGATION_AMOUNT=2
+HEAVY_POWERED_MITIGATION_AMOUNT=3

;Wraith armor movement bonus stays the same, balances against warden/previous tier by raising dodge and adding armor
-LIGHT_POWERED_DODGE_BONUS=25
+LIGHT_POWERED_DODGE_BONUS=40

;New stat entries in a seperate category
+[XComGame.X2Ability_ItemGrantedAbilitySet_AP]

;Predator armor
+MEDIUM_PLATED_MITIGATION_CHANCE=100
+MEDIUM_PLATED_MITIGATION_AMOUNT=1

;Wraith armor
+LIGHT_POWERED_MITIGATION_CHANCE=100
+LIGHT_POWERED_MITIGATION_AMOUNT=1

Then I have my X2Ability_ItemGrantedAbilitySet_AP which extends the default item ability sets

// Extends ItemGrantedAbilitySet so we can have mid and lategame armors with additional stats
// only needed for Predator and Wraith armors because they both lack armor

class X2Ability_ItemGrantedAbilitySet_AP extends X2Ability_ItemGrantedAbilitySet
	dependson (XComGameStateContext_Ability) config (GameCore);

var config int MEDIUM_PLATED_MITIGATION_CHANCE;
var config int MEDIUM_PLATED_MITIGATION_AMOUNT;

var config int LIGHT_POWERED_MITIGATION_CHANCE;
var config int LIGHT_POWERED_MITIGATION_AMOUNT; 

I copied the functions to create the respective templates from the default file and added 2 lines each

 

for predator:

PersistentStatChangeEffect.AddPersistentStatChange(eStat_ArmorChance, default.MEDIUM_PLATED_MITIGATION_CHANCE);
PersistentStatChangeEffect.AddPersistentStatChange(eStat_ArmorMitigation, default.MEDIUM_PLATED_MITIGATION_AMOUNT);

and for wraith:

PersistentStatChangeEffect.AddPersistentStatChange(eStat_ArmorChance, default.LIGHT_POWERED_MITIGATION_CHANCE);
PersistentStatChangeEffect.AddPersistentStatChange(eStat_ArmorMitigation, default.LIGHT_POWERED_MITIGATION_AMOUNT);

Last but not least, I extend X2Item_DefaultArmors, copy the respective functions and add a single line each,

 

predator:

Template.SetUIStatMarkup(class'XLocalizedData'.default.ArmorLabel, eStat_ArmorMitigation, class'X2Ability_ItemGrantedAbilitySet_AP'.default.MEDIUM_PLATED_MITIGATION_AMOUNT);

wraith:

Template.SetUIStatMarkup(class'XLocalizedData'.default.ArmorLabel, eStat_ArmorMitigation, class'X2Ability_ItemGrantedAbilitySet_AP'.default.LIGHT_POWERED_MITIGATION_AMOUNT);

I have absolutely no clue, why this is not working.

And yes, I tried both with and without using +ModClassOverrides aswell as adding the new config lines directly into X2Ability_ItemGrantedAbilitySet, with '+', '.' and without any prefix. Didn't change a thing :sad:

 

Can anyone here help me?

Edited by LazySkyrimPlayer
Link to comment
Share on other sites

I'm trying to learn from other Mods and some have files with the extension: .u

I can look at it in UE Explorer, but I have no idea how the file is loaded/referenced in Mod Buddy. The file has it's own Script directory, but where do you reference it in Mod Buddy? Thanks!

Link to comment
Share on other sites

F*ck me, I found it myself. I am such an idiot. I rewrote everything and put made a seperate config file for all default armors, then extended the edfault armor class and pointed my custom ability set to look for stats in my new config file.

That is, when I realized I did not properly declare my values in my .ini. I feel like an absolute moron -___-

Link to comment
Share on other sites

Folks, now that we have a whole sub-forum, can you post questions in new topics instead of just this thread? I am sure Amineri reads more than just this thread, and we have other modders who can answer also. When a thread is huge and has lots of unrelated topics, it's hard to follow which post is a solution to which previous problem. It's also easier to find an existing answer to a question if there are good thread titles to look through.

Link to comment
Share on other sites

 

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.

 

 

That's good to know, thanks! I'm finding that the most common thing I want to do is replace something in the existing behaviour, though. For instance, Firaxis' code for whether a unit can be treated like a Psi Operative (in terms of getting training at the Psi Lab, or showing their Psi stat in the SoldierHeader) is buried inside XComGameState_Unit and is bascially just checking that the Soldier's class TemplateName == 'PsiOperative', which is a massive pain in the ass and tantamount to hardcoding something that should be totally dynamic instead.

 

If 'IsPsiOperative()' were defined as a helper function that takes a unit as its argument, instead of a method on the Unit class; it'd be fine, but.. Alas.

 

Relatedly; I've had some very weird experiences over the weekend where class overrides that were previously working just inexplicably stopped working. I've gone over the overrides, the ini statements, everything - to no avail. It feels like the ModOverrides system has a bunch of quirks (or outright bugs) that are impossible to know about from a modders' perspective because it's tucked away in the C++.

I've actually completely given up on using ModOverrides at this point and I'm just using hacks to inject my code from ScreenListeners and ridiculous abuses of polymorphism now instead.

 

I really appreciate the Lengths that Firaxis have gone to in giving us the SDK, the UnrealScript source code and giving us some hooks to get our code into the game; but I wish we could get some more info from Firaxis about how that stuff is working internally. Inventing hacks to get things working is fun and educational, but it's not conducive to actually getting things done..

 

 

Edited by Kvalyr
Link to comment
Share on other sites

Folks, now that we have a whole sub-forum, can you post questions in new topics instead of just this thread? I am sure Amineri reads more than just this thread, and we have other modders who can answer also. When a thread is huge and has lots of unrelated topics, it's hard to follow which post is a solution to which previous problem. It's also easier to find an existing answer to a question if there are good thread titles to look through.

 

Fair enough. Some of those questions are getting quite complex, as well.

Link to comment
Share on other sites

Does anyone know how to add new buttons for existing screens? for instance the soldier abilities screen (where you choose promotion abilities) it's pretty much mandatory for my Commander's choice mod (and would help a lot for the other parts of my other mods)

I'd suggest creating a UIScreenListener and manipulating the ScreenStack to get at the screen you want to modify.

local UIScreenStack ScreenStack;
local UIArmory ArmoryScreen;
ScreenStack = `SCREENSTACK;
ArmoryScreen = UIArmory(ScreenStack.GetScreen(class'UIArmory'));

 

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.

×
×
  • Create New...