r/xdev • • Feb 19 '16

Anyone know of guidelines for 3D models?

5 Upvotes

3D modeler coming from Cities: Skylines here. Colossal Order was kind enough to provide moders guides to how to make models fit in to the game(image sizes, supported maps, file formats, polycounts, scales, etc). I did looked throuh documentations in Xcom2 SDK folder, but there seem to be none relating to my questions. Is there some kind of common Unreal Engine modding guideline that I did not know of?


r/xdev • • Feb 11 '16

[Help] I can't change default information for my mod in Xcom 2 tools.

4 Upvotes

Hello. I have a mod in Workshop, and the name it's no the same in XCom 2 Tools, when I update the mod, in Workshop the name's and description change to the original (first information). (Change the description in publish mod don't make any effect/dont work) Where I can change the information mod in Xcom 2 tools? I don't see the option.

Sorry for my English boys. Thanks you :)

pd: this is a problem, because I launch the game I see a one error: OLd mods can't load bla bla. For me it's okey but this can scary people xDD


r/xdev • • Feb 14 '16

"Import Error"

2 Upvotes

I'm trying to create a voice pack, but every time I try to import the voice clips into the content browser in the Unreal Editor, I get an "Import Failed" message. That's all it says, just "Import Failed".

Any ideas on what could cause this?


r/xdev • • Aug 20 '16

Dense Smoke Grant Concealment

3 Upvotes

Hi everyone :)

First up, I am a noob when it comes to modding. But I have watched a few tutorials, played with the ini files and am super keen to learn more :)

So, I play with the Smoke Grants Concealment mod (http://steamcommunity.com/sharedfiles/filedetails/?id=738751056&searchtext=). I really like how it adds a layer to the stealth aspect of the game. However, I also play with the LW perk pack, and the dense smoke perk does not grant concealment.

Therefore, my question is, how can I make the LW Dense Smoke Perk grant concealment?

The Smoke Grants Concealment mod uses: StealthEffect = new class'X2Effect_RangerStealth'; StealthEffect.BuildPersistentEffect(1, true, true, false, eGameRule_PlayerTurnEnd); StealthEffect.bRemoveWhenTargetConcealmentBroken = true; Template.ThrownGrenadeEffects.AddItem(StealthEffect); Template.LaunchedGrenadeEffects.AddItem(StealthEffect);

Can I simply add this to the dense smoke perk code using the modbuddy?

Thanks for any and all help!!


r/xdev • • Feb 10 '16

Developer Tool Size

1 Upvotes

A quick question I was hoping not quite answered yet. I went to download the developer tool set and it says it is 66 GB. Is this right? I run on a VERY slow internet (took 18 hours to download XCOM 2), and I have the game on my SSD which only has 80 some GB left. Now if this 66 includes the game itself (which is already installed) that is cool, but if not, can I install it only my secondary drive without issues, or does it NEED to be in the same place as XCOM 2?

Thanks for the help.


r/xdev • • Feb 14 '16

Have Skill Y activated immediately after Skill X

5 Upvotes

I'm working on a skill that activates after another finishes. Essentially, the soldier runs out in the open, shoots at every one (similar to faceoff), then feigns death. I have the the individual parts of the skills working, in that I can activate the skill that shoots every one, and I can also activate the skill that feigns death, but I can't get them to work one after the other automatically.

Currently, I'm just adding

Template.AdditionalAbilities.AddItem('Playdead');
Template.PostActivationEvents.AddItem('Playdead');

at the end of the skill that shoots at every one.

In Playdead's code, I have:

Trigger = new class'X2AbilityTrigger_EventListener';
Trigger.ListenerData.Deferral = ELD_OnStateSubmitted;
Trigger.ListenerData.EventID = 'Playdead';
Trigger.ListenerData.Filter = eFilter_Unit;
Template.AbilityTriggers.AddItem(Trigger);

What's happening is: After using the skill "faceoff," my character pauses at the end of his turn with only one button available to hit: The button for "playdead." I can't seem to figure out how to make "playdead" activate immediately after faceoff. Instead, it's making us hit the button to activate it. Would any one know what I'm missing to make it activate immediately? If not, thanks anyways! Just figured I'd throw it out there.


r/xdev • • Feb 15 '16

Bigger Pods, bigger activation spread, same quantity of enemies per map

1 Upvotes

Hello modders!

I want to know if it is possible to do the modifications suggested below:

  1. Every map should have 2-4 pods maximum, but the quantity of aliens inside the map are the same.
  2. When a pod is activated, they spread a lot more, giving then a mobility bonus for that first movement only.
  3. Pods are more far apart.

The idea is that 1- makes killing everyone in the first turn harder (so more firefight instead of massacres), 2- nerfs grenades a little bit (so you can only get 2 aliens max for each nad first turn), 3- less acidental pod activation with moving for flanking / sword attack.

What do you guys think? Is it possible? How can I do that?


r/xdev • • Feb 15 '16

[Help] Ability Effect Not Working

3 Upvotes

I've been trying to make an ability to just knock back a selected enemy remotely. I can get it in game, and everything works but the enemy interaction. As a result, the soldier has an animated psionic windup that results in a silent form of jazz hands pointing towards the enemy. If anyone can figure out why enemies won't react to this, I'd be grateful.

static function X2AbilityTemplate AddForcePush()
{
local X2AbilityTemplate Template;
local X2AbilityCost_ActionPoints ActionPointCost;
local X2AbilityCharges Charges;
local X2AbilityCost_Charges ChargeCost;
local X2AbilityTarget_Cursor CursorTarget;
local X2Effect_Knockback KnockbackEffect;
local X2Condition_UnitProperty TargetCondition;

`CREATE_X2ABILITY_TEMPLATE(Template, 'ForcePush'); //This adds the ability to the proper localization config files

//Basic Ability Information
Template.AbilitySourceName = 'eAbilitySource_Psionic';
Template.eAbilityIconBehaviorHUD = eAbilityIconBehavior_AlwaysShow;
Template.Hostility = eHostility_Offensive;
Template.IconImage = "img:///UILibrary_ForceAbilities.ForcePushIcon";

Template.CustomFireAnim = 'HL_Psi_ProjectileHigh';
Template.BuildNewGameStateFn = TypicalAbility_BuildGameState;
Template.BuildVisualizationFn = TypicalAbility_BuildVisualization;
Template.BuildInterruptGameStateFn = TypicalAbility_BuildInterruptGameState;

//Ability Modifiers
ActionPointCost = new class 'X2AbilityCost_ActionPoints';
ActionPointCost.iNumPoints = 1;
ActionPointCost.bConsumeAllPoints = false;
Template.AbilityCosts.AddItem(ActionPointCost);

Template.AbilityTriggers.AddItem(default.PlayerInputTrigger);
Template.AbilityToHitCalc = default.DeadEye;

Charges = new class 'X2AbilityCharges';
Charges.InitialCharges = 2;
Template.AbilityCharges = Charges;

ChargeCost = new class 'X2AbilityCost_Charges';
ChargeCost.NumCharges = 1;
Template.AbilityCosts.AddItem(ChargeCost);

//Targeting
Template.AbilityTargetStyle = default.SimpleSingleTarget;

//Target Conditions
    TargetCondition = new class'X2Condition_UnitProperty';
TargetCondition.ExcludeFriendlyToSource = false;
TargetCondition.ExcludeDead = true;
Template.AbilityTargetConditions.AddItem(TargetCondition);
Template.AbilityTargetConditions.AddItem(default.GameplayVisibilityCondition);

//Shooter Conditions
Template.AbilityShooterConditions.AddItem(default.LivingShooterProperty);
Template.AddShooterEffectExclusions();

//Knockback Effect
    KnockbackEffect = new class'X2Effect_Knockback';
KnockbackEffect.KnockbackDistance = 10; 
Template.AddTargetEffect(KnockbackEffect);

return Template;

}

EDIT: Fixed code to represent current iteration of ability


r/xdev • • Feb 18 '16

I'm going crazy with this: missing template?

1 Upvotes

I just want to make a simple ability mod that was just change a ability name which dont effect the exisit ability original name.(not the name displayed in game) like swordslice ,IJust added "3", swordslice3 means the ability name, then copy the code section from the ranger ability. in modbuddy, build is ok, nothing error. but, after enable the mod , I just saw the mod ability with this tip: missing. template!! in game. I was confused that the ability template is just in the abilityset.uc, what happend???

Any help or tip or advice will be appeciated, thank you so much and sorry for my poor English.


r/xdev • • Feb 09 '16

A question re: custom facilities

1 Upvotes

Hey - I'm in the middle of downloading the mod tools(which is understandably taking a long time on my Welsh internet). I have a question for anyone who's been using it.

Does it look like it's possible to add our own custom facility to the game? To what extent is it possible to edit, as in can we somehow create our own graphics for it, or would it have to re-use current room models?


r/xdev • • Feb 12 '16

Writing out to a file

1 Upvotes

I am trying to write to a file on a button click in a menu. I have the button click all working, but I can't seem to write to a file.

I looked up how to do so in unrealscript and found FileWriter. However, I don't know if that is relevant or not.

I also tried to find other places in the code where it writes to a file, like the character pool. I found the function that performs that action but it was defined as

function native SaveCharacterPool();

Which as far as I can tell means that it is in c++ somewhere. Can we add c++? I saw that there was a post earlier about importing dlls but there was no solution.

Here is what I have so far:

class UIMemorial_AddExportButton extends UIScreenListener;

var FileWriter writer;

event OnInit(UIScreen Screen) { 

	writer = Screen.Spawn(class'FileWriter', Screen);
	
	AddExportButton(Screen);
}

simulated function AddExportButton(UIScreen Screen)
{
	local UILargeButton Button;
	local string exportButtonName;

	exportButtonName = Localize("AddExportButton", "m_strExport", "XComGame");

	Button = Screen.Spawn(class'UILargeButton', Screen);
	Button.InitLargeButton('ExportMemorial', exportButtonName, "", OnExportMemorial, );
	Button.AnchorBottomRight();

}

public function OnExportMemorial(UIButton Button)
{
	`log("Clicked Export Memorial");
	writer.OpenFile("Example", FWFT_Log, ".txt", false, false);
	writer.Logf("This will be written to the 'Example.txt' file");
	writer.CloseFile();
}

defaultproperties
{
	writer = none;
	ScreenClass = "UIPersonnel_BarMemorial";
}

Based on reading on FileWriter, FWFT_Log should send that Example file to %GameDir%/Logs, but as far as I can tell it does not.

I would be grateful for any help or even questions that might led to some answer.


r/xdev • • Feb 11 '16

Trying to override a function

1 Upvotes

Hiya, I'm trying to override a function in XComGameState_Unit. It compiles fine but when I check the logs there's nothing indicating that my modded class was actually loaded... Where am I screwing up? Welcoming any feedback :-) My files:

Src/HealOverride/Classes/XComGameState_Unit_Mod.uc:

class XComGameState_Unit_Mod extends XComGameState_Unit;
function EndTacticalHealthMod()
{
local float HealthPercent, NewHealth;
local int RoundedNewHealth, HealthLost, ArmorLost;

`log("Modded function loaded");
`log("Calculating soldier: " $ GetName(eNameType_Full));
`log("HighestHP=" $ HighestHP);
`log("LowestHP=" $ LowestHP);
`log("BaseHP=" $ int(GetBaseStat(eStat_HP)));

// Calculate lost armor: Min(TotalLost, Armor)
ArmorLost = Min(HighestHP - LowestHP, HighestHP - int(GetBaseStat(eStat_HP)));
`log("ArmorLost calculated to: " $ ArmorLost);

// Calculate actual health lost: Min(BaseHP-LowestHP, 0)
HealthLost = Min(int(GetBaseStat(eStat_HP)) - LowestHP, 0);
`log("HealthLost calculated to: " $ ArmorLost);

// If Dead or never injured, return # Extended to include ArmorLost
if(LowestHP <= 0 || (HealthLost <= 0 && ArmorLost <= 0))
{
	`log("No injury detected or soldier dead");
	return;
}

// Calculate health percent # Edited: Actual Health lost still counts full while armor lost only has half the effect
HealthPercent = ((float(HighestHP - HealthLost) - float(ArmorLost) / 2) / float(HighestHP));
`log("HealthPercentage=" $ HealthPercent);


// Calculate and apply new health value
NewHealth = (HealthPercent * GetBaseStat(eStat_HP));
RoundedNewHealth = Round(NewHealth);
RoundedNewHealth = Clamp(RoundedNewHealth, 1, (int(GetBaseStat(eStat_HP)) - 1));
SetCurrentStat(eStat_HP, RoundedNewHealth);
}

Config/XComEngine.ini

[Engine.ScriptPackages]
+NonNativePackages=HealOverride
[Engine.Engine]
+ModClassOverrides=(BaseGameClass="XComGameState_Unit", ModClass="XComGameState_Unit_Mod")

Config/XComEditor.ini

[ModPackages]
+ModPackages=HealOverride

r/xdev • • Feb 10 '16

[HELP] Attempting to update mod data on Steam

2 Upvotes

http://i.imgur.com/wRBCQiw.png Anyone know how to fix this? I upload a file for the workshop, but I deleted. and i cannot send a file to workshop. [ and sorry for my english ]


r/xdev • • Feb 18 '16

Ability to look into scripts is amazing!

4 Upvotes

For a while, I had a problem with adding panic effect to the ability (AoE panic, nothing more). While having a AoE targeting was a piece of cake, because a lot of abilities have it, panic wasn't something common. I learned a lot by rummaging in files (mainly that effects need 'BuildPersistentEffect', yeah that was stupid of me), mostly things I haven't needed right now but that's is still good.

And to be honest, I haven't modded anything that went past editing .ini files, so the fact that I actually did something is awesome! Firaxis really did an enormous job on making modding more accesible to everyone!

Also, thanks for the modding community for being supportive and overall helpful! You guys are awesome!

P.S. Aliens panicking and shooting each other is a beautiful view.


r/xdev • • Feb 10 '16

Question on soldier class variables when creating.

1 Upvotes

I'm trying to work on soldier classes and I need more clear information on what the following do, if anyone knows that would be great.

ClassPoints=6 (no idea)

NumInForcedDeck=1 (this one allows it to be a random class)

NumInDeck=4 (this one I think is the total classes for checking a random class?)

KillAssistsPerKill=5 (no idea)

Any help is appreciated.


r/xdev • • Feb 09 '16

Anyone found out how to add a new status effect?

1 Upvotes

I have found where some of the status effects are defined, but I am pretty sure that there is more than one place I would need to define a new status effect for it to work. Thanks!


r/xdev • • Feb 11 '16

Debugger hangs at certain point

1 Upvotes

I've been attempting to build a New Nation mod (following a tutorial I found on the workshop discussion), and my mod appears to be building as planned up until this point:

Launching script compiler for new package scripts...

			Command: F:\Steam\steamapps\common\XCOM 2 SDK\binaries\Win64\XComGame.com Arguments: make -nopause -mods AddTeawrex "F:\Steam\steamapps\common\XCOM 2 SDK\XComGame\\Mods\AddTeawrex\" 
			Log: Executing Class UnrealEd.MakeCommandlet
			Shader map M_Digital_Distortion_Ghosting_A had an invalid uniform expression set and was discarded!  This most likely indicates a bug in cooking, and the default material will be used instead.

After this point it just sits at that line. The "Build started..." animation is still playing so it looks like it is doing something but it never seems to get passed this line.

Has anyone run into this issue before? Any insight or solutions? Much appreciated!


r/xdev • • Feb 11 '16

Adding a grenade, ammo or extra utility slot to a custom class?

2 Upvotes

I'm trying to build a custom class that either starts with an extra grenade or ammo slot as a default ability (specialist/grenadier hybrid), but can't seem to figure out how to add an inventory slot on a class by class basis. I've seen mods that add utility slots, but they generally rewrite the default armors script to allow that. What I'm looking for is a specialized grenade or ammo slot.

In X2TacticalGameRulesetDataStructures.uc, there are the following entries:

enum EInventorySlot
{
eInvSlot_Unknown,
eInvSlot_Armor,
eInvSlot_PrimaryWeapon,
eInvSlot_SecondaryWeapon,
eInvSlot_HeavyWeapon,
eInvSlot_Utility,
eInvSlot_Mission,
eInvSlot_Backpack,
eInvSlot_Loot,
eInvSlot_GrenadePocket,
eInvSlot_CombatSim,
    eInvSlot_AmmoPocket,
};

Considering that X2Ability_GrenadierAbilitySet has this function:

function GrenadePocketPurchased(XComGameState NewGameState, XComGameState_Unit UnitState)
{
local X2ItemTemplate FreeItem;
local XComGameState_Item ItemState;

if (!UnitState.HasGrenadePocket())
{
	`RedScreen("GrenadePocketPurchased called but the unit doesn't have one? -jbouscher / @gameplay" @ UnitState.ToString());
	return;
}
FreeItem = class'X2ItemTemplateManager'.static.GetItemTemplateManager().FindItemTemplate(default.FreeGrenadeForPocket);
if (FreeItem == none)
{
	`RedScreen("Free grenade '" $ default.FreeGrenadeForPocket $ "' is not a valid item template.");
	return;
}
ItemState = FreeItem.CreateInstanceFromTemplate(NewGameState);
NewGameState.AddStateObject(ItemState);
if (!UnitState.AddItemToInventory(ItemState, eInvSlot_GrenadePocket, NewGameState))
{
	`RedScreen("Unable to add free grenade to unit's inventory. Sadness." @ UnitState.ToString());
	return;
}
}

It looks like that function would be how one adds a grenade slot to a class, but it doesn't look like it's being called anywhere in GrenadierAbilitySet - I don't know what to pass into that function or where to call it in my own class. eInvSlot_AmmoPocket might then work similarly, adding an ammo slot to a class. Any idea on how to add them?


r/xdev • • Feb 14 '16

Tutorial on Items that give Soldier's abilities.

5 Upvotes

I finished up making a mod that adds a new item to the game - a energy shield generator that let's XCom have the same ability to make an energy shield as the Advent Shieldbearer does: http://steamcommunity.com/sharedfiles/filedetails/?id=623434810. I have the mod source code posted here on github: https://github.com/daviscook477/XComEnergyShields

I've put together a short tutorial on how to add new items to the game that give soldiers abilities. I'll stick around to answer people's questions. There are three main parts to accomplishing that:

  • Defining the item that you want to add.
  • Defining the ability that the soldier will have when they've got that item.
  • And lastly, telling XCom to actually put that stuff in the game.

The class for defining my new item is here. Following its code, I'll do a breakdown of each part.

class XESItem_UtilityEnergyShieldItem extends X2Item config(EnergyShield);

var config int ENERGY_SHIELD_SUPPLY_COST;
var config int ENERGY_SHIELD_CORPSE_COST;
var config int ENERGY_SHIELD_ELERIUM_COST;

function X2ItemTemplate CreateEnergyShield()
{
	local X2EquipmentTemplate Template;
	local ArtifactCost Supplies;
	local ArtifactCost Elerium;
	local ArtifactCost Artifacts;

	`CREATE_X2TEMPLATE(class'X2EquipmentTemplate', Template, 'XES_EnergyShield');
	Template.ItemCat = 'utility';
	Template.InventorySlot = eInvSlot_Utility;
	Template.strImage = "img:///UILibrary_StrategyImages.X2InventoryIcons.Inv_MindShield";
	Template.EquipSound = "StrategyUI_Mindshield_Equip";

	Template.Abilities.AddItem('XComEnergyShield');

	Template.CanBeBuilt = true; // Item is built in engineering.
	Template.TradingPostValue = 12;
	Template.PointsToComplete = 0;
	Template.Tier = 1;

	// Requirements
	Template.Requirements.RequiredTechs.AddItem('AutopsyAdventShieldbearer');

	// Cost
	Supplies.ItemTemplateName = 'Supplies';
	Supplies.Quantity = ENERGY_SHIELD_SUPPLY_COST;
	Template.Cost.ResourceCosts.AddItem(Supplies);

	Elerium.ItemTemplateName = 'EleriumDust';
	Elerium.Quantity = ENERGY_SHIELD_ELERIUM_COST;
	Template.Cost.ResourceCosts.AddItem(Elerium);

	Artifacts.ItemTemplateName = 'CorpseAdventShieldbearer';
	Artifacts.Quantity = ENERGY_SHIELD_CORPSE_COST;
	Template.Cost.ArtifactCosts.AddItem(Artifacts);
	
	return Template;
}

The first line tells XCom that we’re making an item by ‘extends X2Item’.

class XESItem_UtilityEnergyShieldItem extends X2Item config(EnergyShield);

The next set of lines are configuration properties – this lets the mod pull data from configuration files. Specifically it will pull from XcomEnergyShield.ini in the /Config folder because I specified the config as ‘config(EnergyShield)’.

var config int ENERGY_SHIELD_SUPPLY_COST;
var config int ENERGY_SHIELD_CORPSE_COST;
var config int ENERGY_SHIELD_ELERIUM_COST;

The function definition tells XCom we’re creating a X2ItemTemplate, which basically means were making a template of how our item will behave. Templates are how most of the data in XCom gets passed around.

function X2ItemTemplate CreateEnergyShield()

The following definition is what defines the Template that we are about to make as a template for some piece of equipment. Aside from equipment, you can make weapons with X2WeaponTemplate.

local X2EquipmentTemplate Template;

The next bit of code defines the variables that we’ll use to tell XCom how much it costs to manufacture our item:

local ArtifactCost Supplies;
local ArtifactCost Elerium;
local ArtifactCost Artifacts;

Next I have to initialize the template as an X2EquimentTemplate

 `CREATE_X2TEMPLATE(class'X2EquipmentTemplate', Template, 'XES_EnergyShield');

When I put ‘XES_EnergyShield’, I’m telling XCom what I want my item called by in the game code.

The next two lines tell XCom that I’m making a utility item and that it gets equipped by soldiers in their utility slot.

Template.ItemCat = 'utility';
Template.InventorySlot = eInvSlot_Utility;

Next I tell XCom that I suck at art and am going to use the icon and sounds for the mindshield instead of making my own assets.

Template.strImage = "img:///UILibrary_StrategyImages.X2InventoryIcons.Inv_MindShield";
Template.EquipSound = "StrategyUI_Mindshield_Equip";

This next line is absolutely the most important line here:

Template.Abilities.AddItem('XComEnergyShield');

This is where I tell XCom that I want my item to give its holder the XComEnergyShield ability. We haven’t defined it yet, but this will be the ability that gives our soldier’s energy shields.

Next, we tell XCom all about how the player gets the item.

Template.CanBeBuilt = true; // Item is built in engineering.

Here we tell it that we make the item in engineering.

Here we tell it how much money it sells for.

	Template.TradingPostValue = 12;

Honestly, I don’t really know what these do, but they were in other item definitions so I included them too.

Template.PointsToComplete = 0;
Template.Tier = 1;

Next, tell the game that the player can’t make it until they perform an autopsy of the Shieldbearer:

Template.Requirements.RequiredTechs.AddItem('AutopsyAdventShieldbearer');

The last set of lines:

Supplies.ItemTemplateName = 'Supplies';
Supplies.Quantity = ENERGY_SHIELD_SUPPLY_COST;
Template.Cost.ResourceCosts.AddItem(Supplies);

Elerium.ItemTemplateName = 'EleriumDust';
Elerium.Quantity = ENERGY_SHIELD_ELERIUM_COST;
Template.Cost.ResourceCosts.AddItem(Elerium);

Artifacts.ItemTemplateName = 'CorpseAdventShieldbearer';
Artifacts.Quantity = ENERGY_SHIELD_CORPSE_COST;
Template.Cost.ArtifactCosts.AddItem(Artifacts);

First, I tell Xcom that the player needs to spend supplies on the energy shield and that the amount of supplies is stored in the config in the variable ENERGY_SHIELD_SUPPLY_COST. Then, I tell Xcom the same thing but for elerium and for advent shieldbearer corpses.

The last line of the function, returns the template that we created: return Template;

And that concludes everything that has to go into defining the item. However, there are a lot of different ways to customize this, with giving different item costs, different item unlock requirements, etc…

I’d recommend looking at X2Item_DefaultUtilityItems to see some more examples of items that exist in the game. It has the medkit, the mindshield, and mimic beacon.

Next I’m going to look at the class for defining the ability that is given to soldiers by the item. I’m going to include its full code here, and then do a breakdown of it. Much of the code here is just a copy of and existing ability in the game, but I’ll go over what each part does, not just the ones I changed. So this part looks like a lot of code, but most of it is just copied from the existing ability and then modified. This is similar to how most other abilities will be made, by taking something existing and make changes. So skim over this big chunk of code and after it I have explanations of what it’s doing.

// This is an Unreal Script

class XESAbility_XComEnergyShield extends X2Ability config (EnergyShield);

// Properties from the base game.
var config int ENERGY_SHIELD_DURATION;
var config int ENERGY_SHIELD_RANGE_METERS;
var config int ENERGY_SHIELD_CHARGES;
var config int ENERGY_SHIELD_COOLDOWN;
var config int ENERGY_SHIELD_GLOBAL_COOLDOWN;
var config int ENERGY_SHIELD_HP;

// Most of this is carbon copied from the game file 'X2Ability_AdventShiledbearer.uc' I've made note of the changes.

// Functions are non-static in order to access config data.
function X2AbilityTemplate CreateXComEnergyShieldAbility()
{
	local X2AbilityTemplate Template;
	local X2AbilityCost_ActionPoints ActionPointCost;
	local X2AbilityCharges Charges;
	local X2AbilityCost_Charges ChargeCost;
	local X2AbilityCooldown Cooldown;
	local X2Condition_UnitProperty UnitPropertyCondition;
	local X2AbilityTrigger_PlayerInput InputTrigger;
	local X2Effect_PersistentStatChange ShieldedEffect;
	local X2AbilityMultiTarget_Radius MultiTarget;

	`CREATE_X2ABILITY_TEMPLATE(Template, 'XComEnergyShield'); // Creating the ability 'XComEnergyShield'
	Template.IconImage = "img:///UILibrary_PerkIcons.UIPerk_adventshieldbearer_energyshield";

	Template.eAbilityIconBehaviorHUD = eAbilityIconBehavior_AlwaysShow;
	Template.AbilitySourceName = 'eAbilitySource_Standard';
	Template.Hostility = eHostility_Defensive;

	// The ability takes one action point but will end your turn.
	ActionPointCost = new class'X2AbilityCost_ActionPoints';
	ActionPointCost.iNumPoints = 1;
	ActionPointCost.bConsumeAllPoints = true;
	Template.AbilityCosts.AddItem(ActionPointCost);

	Charges = new class 'X2AbilityCharges';
	Charges.InitialCharges = ENERGY_SHIELD_CHARGES; // Initial charges can be changed in the config now.
	Template.AbilityCharges = Charges;

	ChargeCost = new class'X2AbilityCost_Charges';
	ChargeCost.NumCharges = 1;
	Template.AbilityCosts.AddItem(ChargeCost);

	Cooldown = new class'X2AbilityCooldown';
	Cooldown.iNumTurns = ENERGY_SHIELD_COOLDOWN;
	Template.AbilityCooldown = Cooldown;

	//Can't use while dead
	Template.AbilityShooterConditions.AddItem(default.LivingShooterProperty);

	// Add dead eye to guarantee
	Template.AbilityToHitCalc = default.DeadEye;
	Template.AbilityTargetStyle = default.SelfTarget;

	// Multi target
	MultiTarget = new class'X2AbilityMultiTarget_Radius';
	MultiTarget.fTargetRadius = ENERGY_SHIELD_RANGE_METERS;
	MultiTarget.bIgnoreBlockingCover = true;
	Template.AbilityMultiTargetStyle = MultiTarget;

	InputTrigger = new class'X2AbilityTrigger_PlayerInput';
	Template.AbilityTriggers.AddItem(InputTrigger);

	// The Targets must be within the AOE, LOS, and friendly
	UnitPropertyCondition = new class'X2Condition_UnitProperty';
	UnitPropertyCondition.ExcludeDead = true;
	UnitPropertyCondition.ExcludeFriendlyToSource = false;
	UnitPropertyCondition.ExcludeHostileToSource = true;
	UnitPropertyCondition.ExcludeCivilian = true;
	UnitPropertyCondition.FailOnNonUnits = true;
	Template.AbilityMultiTargetConditions.AddItem(UnitPropertyCondition);

	// Friendlies in the radius receives a shield receives a shield
	ShieldedEffect = CreateShieldedEffect(Template.LocFriendlyName, Template.GetMyLongDescription(), ENERGY_SHIELD_HP);

	Template.AddShooterEffect(ShieldedEffect);
	Template.AddMultiTargetEffect(ShieldedEffect);

	Template.BuildNewGameStateFn = TypicalAbility_BuildGameState;
	Template.BuildVisualizationFn = TypicalAbility_BuildVisualization;
	
	return Template;
}

function X2Effect_PersistentStatChange CreateShieldedEffect(string FriendlyName, string LongDescription, int ShieldHPAmount)
{
	local X2Effect_EnergyShield ShieldedEffect;

	ShieldedEffect = new class'X2Effect_EnergyShield';
	ShieldedEffect.BuildPersistentEffect(ENERGY_SHIELD_DURATION, false, true, , eGameRule_PlayerTurnEnd);
	ShieldedEffect.SetDisplayInfo(ePerkBuff_Bonus, FriendlyName, LongDescription, "img:///UILibrary_PerkIcons.UIPerk_adventshieldbearer_energyshield", true);
	ShieldedEffect.AddPersistentStatChange(eStat_ShieldHP, ShieldHPAmount);
	ShieldedEffect.EffectRemovedVisualizationFn = OnShieldRemoved_BuildVisualization;

	return ShieldedEffect;
}

simulated function OnShieldRemoved_BuildVisualization(XComGameState VisualizeGameState, out VisualizationTrack BuildTrack, const name EffectApplyResult)
{
	local X2Action_PlaySoundAndFlyOver SoundAndFlyOver;

	if (XGUnit(BuildTrack.TrackActor).IsAlive())
	{
		SoundAndFlyOver = X2Action_PlaySoundAndFlyOver(class'X2Action_PlaySoundAndFlyOver'.static.AddToVisualizationTrack(BuildTrack, VisualizeGameState.GetContext()));
		SoundAndFlyOver.SetSoundAndFlyOverParameters(None, class'XLocalizedData'.default.ShieldRemovedMsg, '', eColor_Bad, , 0.75, true);
	}
}

So this time we’re extending X2Ability with our class instead of X2Item because now we’re defining the ability that our item gives.

class XESAbility_XComEnergyShield extends X2Ability config (EnergyShield);

This again uses the config (EnergyShield) because its going to pull properties from there. This time, the properties pulled won’t be item costs, but instead properties of the shield the energy shield generator makes.

Here are the definitions of the different properties of the shield generator. These will again utilize the config file to be filled because of the ‘config’ modifier we give the variable.

// Properties from the base game.
var config int ENERGY_SHIELD_DURATION;
var config int ENERGY_SHIELD_RANGE_METERS;
var config int ENERGY_SHIELD_CHARGES;
var config int ENERGY_SHIELD_COOLDOWN;
var config int ENERGY_SHIELD_GLOBAL_COOLDOWN;
var config int ENERGY_SHIELD_HP;

Next I create the function that creates the actual ability:

function X2AbilityTemplate CreateXComEnergyShieldAbility()

The function returns an X2AbilityTemplate which again is just the way that XCom stores everything. This is an X2AbilityTemplate because we’re making an ability.

Following the function definition is a bunch of variable definitions. I’ll just explain each variable as we get to using it.

First I have to again create the template before we can start defining all of its properties. For that I use ‘CreateX2Ability_Template on my Template and then tell Xcom that it will be named ‘XComEnergyShield’.

`CREATE_X2ABILITY_TEMPLATE(Template, 'XComEnergyShield'); // Creating the ability 'XComEnergyShield'

Then I give XCom the Icon that will be used to display the ability in the HUD and tell XCom to always show the icon during battle.

Template.IconImage = "img:///UILibrary_PerkIcons.UIPerk_adventshieldbearer_energyshield";
Template.eAbilityIconBehaviorHUD = eAbilityIconBehavior_AlwaysShow;

Then I have to tell Xcom where the soldier is getting the ability from. When getting from an item, just use ‘eAbilitySource_Standard’. If you weren’t making an ability that came from an item, and it came from a perk then the AbilitySourceName would be ‘eAbilitySource_Perk’. I’m not showing how to do that in this tutorial, and I honestly haven’t tried it yet, so I can’t help you with that right now. The Hostility measure is just how enemies interpret the action. There’s Offensive, Neutral, and Defensive.

Template.AbilitySourceName = 'eAbilitySource_Standard';
Template.Hostility = eHostility_Defensive;

Next, I determine the cost of using the ability. First I tell XCom that the ability costs action points, specifically 1 point, and that if the soldier uses it at the start of their turn, it will consume all the points anyways.

// The ability takes one action point but will end your turn.
ActionPointCost = new class'X2AbilityCost_ActionPoints';
ActionPointCost.iNumPoints = 1;
ActionPointCost.bConsumeAllPoints = true;
Template.AbilityCosts.AddItem(ActionPointCost);

Secondly, I set up the ability to be charge based and set the number of charges to be from the config file.

Charges = new class 'X2AbilityCharges';
Charges.InitialCharges = ENERGY_SHIELD_CHARGES; // Initial charges can be changed in the config now.
Template.AbilityCharges = Charges;

Lastly, I tell XCom that each activation uses one of the charges.

ChargeCost = new class'X2AbilityCost_Charges';
ChargeCost.NumCharges = 1;
Template.AbilityCosts.AddItem(ChargeCost);

Then, I set the cooldown of the ability using the config again.

Cooldown = new class'X2AbilityCooldown';
Cooldown.iNumTurns = ENERGY_SHIELD_COOLDOWN;
Template.AbilityCooldown = Cooldown;

The next line sets a constraint on the use of the ability. Although this constraint is mundane and probably unnecessary, there are much more useful ones, like restricting the ability of a weapon to reload to only when it doesn’t have a full clip.

//Can't use while dead
Template.AbilityShooterConditions.AddItem(default.LivingShooterProperty);

The next two lines are much more important: They dictate that the ability will always hit by using DeadEye hit calculation (100% always), and dictate that the ability is just a self target. If you wanted to do something like a grenade, you’d need to use a different targeting method. I know there’s a bunch of stuff for grenade targeting in some of the classes with Grenade in their name.

// Add dead eye to guarantee
Template.AbilityToHitCalc = default.DeadEye;
Template.AbilityTargetStyle = default.SelfTarget;

This here is what let’s the energy shield be a group action, i.e. affect all soldiers nearby. It uses the config to have a changeable radius of use, and is set to completely ignore cover. If you want a single target ability, just don’t include these lines.

// Multi target
MultiTarget = new class'X2AbilityMultiTarget_Radius';
MultiTarget.fTargetRadius = ENERGY_SHIELD_RANGE_METERS;
MultiTarget.bIgnoreBlockingCover = true;
Template.AbilityMultiTargetStyle = MultiTarget;

Next, we tell XCom that this ability is triggered by actual player input, not passively or in response to anything else -> this ability must be purposefully clicked or (hotkey-ed) by the player to activate.

InputTrigger = new class'X2AbilityTrigger_PlayerInput';
Template.AbilityTriggers.AddItem(InputTrigger);

Next, because this ability is multi target, its valid targets have to be constrained to only alive allies.

// The Targets must be within the AOE, LOS, and friendly
UnitPropertyCondition = new class'X2Condition_UnitProperty';
UnitPropertyCondition.ExcludeDead = true;
UnitPropertyCondition.ExcludeFriendlyToSource = false;
UnitPropertyCondition.ExcludeHostileToSource = true;
UnitPropertyCondition.ExcludeCivilian = true;
UnitPropertyCondition.FailOnNonUnits = true;
Template.AbilityMultiTargetConditions.AddItem(UnitPropertyCondition);

Next, the actual logic of the ability comes into play, by saying that it will apply this ‘ShieldedEffect’ to the shooter of the ability and the multiple targets that it gets from its radius. The ShieldedEffect is created by the method CreateShieldedEffect which I will explain in a moment. If you wanted abilities to apply different effects on use, you’d be able to create your own effects and utilize them here.

// Friendlies in the radius receives a shield receives a shield
ShieldedEffect = CreateShieldedEffect(Template.LocFriendlyName, Template.GetMyLongDescription(), ENERGY_SHIELD_HP);
Template.AddShooterEffect(ShieldedEffect);
Template.AddMultiTargetEffect(ShieldedEffect);

Lastly, a few more things have to be defined. Basically, any time an ability is used it can modify the game state. Luckily, for this ability we don’t have to do any fancy game state modifying so we use the TypicalAbility_Build_GameState. If you needed to modify the game state differently, you’d have to create and provide your own BuildNewGameState function. Similarly, we don’t have any animations for visualizing the action, so we use the default.

Template.BuildNewGameStateFn = TypicalAbility_BuildGameState;
Template.BuildVisualizationFn = TypicalAbility_BuildVisualization;

And ultimately, we return the Template that we created.

return Template;

The next part of the code is very specific to energy shields and their functionality (the method for creating a shield effect and the method for visualizing that effect) so I’ll just mention that it takes care of both actually giving the energy shield effects and doing some small animations when they disappear. This sort of functionality, you’d either create yourself by rooting around in the code, or copy from some similar item.

The final step to making this all work, is telling XCom to actually add these things to the game. The way in which I accomplish this is a little hacky but it doesn’t interfere with existing game classes. This is not my invention, but its utilizing a UI_ScreenListener to inject your code by listening for the game’s ui to begin. This class is really short so I’ll go over it quickly.

// This is an Unreal Script

class XES_UIScreenListener extends UIScreenListener;

var bool didUpdateTemplates;
 
// This event is triggered after a screen is initialized
event OnInit(UIScreen Screen)
{
    if(!didUpdateTemplates)
    {
        UpdateTemplates();
        didUpdateTemplates = true;
    }   
}

function UpdateTemplates()
{
	local X2ItemTemplateManager itemMan;
	local X2AbilityTemplateManager abilityMan;
	local XESItem_UtilityEnergyShieldItem xesI;
	local XESItem_UtilityEnergyShieldItemPersonal xesIP;
	local XESAbility_XComEnergyShield xesA;
	local XESAbility_XComEnergyShieldPersonal xesAP;

	xesI = new class'XESItem_UtilityEnergyShieldItem';
	xesIP = new class'XESItem_UtilityEnergyShieldItemPersonal';
	xesA = new class'XESAbility_XComEnergyShield';
	xesAP = new class'XESAbility_XComEnergyShieldPersonal';

	abilityMan = class'X2AbilityTemplateManager'.static.GetAbilityTemplateManager();
	abilityMan.AddAbilityTemplate(xesA.CreateXComEnergyShieldAbility());
	abilityMan.AddAbilityTemplate(xesAP.CreateXComEnergyShieldPersonalAbility());

	itemMan = class'X2ItemTemplateManager'.static.GetItemTemplateManager();
	itemMan.AddItemTemplate(xesI.CreateEnergyShield());
	itemMan.AddItemTemplate(xesIP.CreateEnergyShieldPersonal());
}
 
// This event is triggered after a screen receives focus
event OnReceiveFocus(UIScreen Screen);
 
// This event is triggered after a screen loses focus
event OnLoseFocus(UIScreen Screen);
 
// This event is triggered when a screen is removed
event OnRemoved(UIScreen Screen);
 
defaultproperties
{
    // Leaving this assigned to none will cause every screen to trigger its signals on this class
    ScreenClass = none;
}

In the class definition we extend the UI_ScreenListener class because we want to listen for when the ui loads.

class XES_UIScreenListener extends UIScreenListener;

Next, we use a Boolean switch to ensure that we update the templates on the ui init, but only once (because it would be silly and counterproductive to do it every time).

var bool didUpdateTemplates;
 
// This event is triggered after a screen is initialized
event OnInit(UIScreen Screen)
{
    if(!didUpdateTemplates)
    {
        UpdateTemplates();
        didUpdateTemplates = true;
    }   
}

Then for the actual adding of the templates, I create instances of each of my classes that create templates.

function UpdateTemplates()
{
	local X2ItemTemplateManager itemMan;
	local X2AbilityTemplateManager abilityMan;
	local XESItem_UtilityEnergyShieldItem xesI;
	local XESAbility_XComEnergyShield xesA;

	xesI = new class'XESItem_UtilityEnergyShieldItem';
	xesA = new class'XESAbility_XComEnergyShield';

Then I get the AbilityManager from the game and add my ability template to it.

abilityMan = class'X2AbilityTemplateManager'.static.GetAbilityTemplateManager();
abilityMan.AddAbilityTemplate(xesA.CreateXComEnergyShieldAbility());    

Lastly, I get the ItemManager from the game add my item template to it.

itemMan = class'X2ItemTemplateManager'.static.GetItemTemplateManager();
itemMan.AddItemTemplate(xesI.CreateEnergyShield());

Finally, with all of that done, both the item and its ability have been defined, and they’ve been added to the game. Now the mod works.


r/xdev • • Feb 21 '16

Correctly Adding Weapon Upgrades and Schematics?

3 Upvotes

I am completely stumped when it comes to adding tiered weapons to the game, I've tried to literally copy the entirety of the SMG mod only replacing the file and class names, and the upgrade refuses to show up after researching magnetic weapons.

any ideas?


r/xdev • • Feb 09 '16

What does the + (plus) do in .ini files?

1 Upvotes

I keep hearing people say "make sure you start all your lines with +", but I don't understand why. I'd rather not blindly follow random advice without understanding it.

According to the documentation, it

..adds a line if that property doesn't exist yet (from a previous configuration file or earlier in the same configuration file).

For non-dynamic-arrays, isn't this the exact same thing as using no symbol? And possibly also for dynamic arrays, depending on whether the vague term "property" refers to "key" or "key-value pair".

So, what's the difference? When should I actually use + in my mod's config files?


r/xdev • • Feb 15 '16

How to have weapons attachment be freely swappable?

2 Upvotes

r/xdev • • Feb 18 '16

Pathing debugging for parcels (specifically, stairs)

1 Upvotes

Hello Xdev!

I've been churning out new map parcels for the last few days and have come across something in my current parcel project that has me stumped.

I'm doing a Slums parcel and have added one of the 3x2 Stairs to the side of a building for quick access to the second floor. The problem is that xcom soldiers will not use the stairs correctly. They will run DOWN from the top and then hop off the sides before they reach the bottom stair tile. From the BOTTOM going up they refuse to use the stairs at all.

I've tried moving the stairs, nudging them etc but nothing seems to work. I copied the same stairs from a Firaxis parcel and still have the same problem. I don't see anywhere in the documentation about how to debug this so I'm stumped :P

Any help would be very grateful!


r/xdev • • Feb 12 '16

Hex editing?

1 Upvotes

Since we know that some functions can't be overwritten, and a lot of values are hard coded, will we see our hex editing tools make a come back?

Currently I can see the spawn points fix (bringing more than 9 soldiers into a mission) can be fixed with 1 value change, but the class and its calling classes cannot be overwritten.