Skip to content

Commit

Permalink
Introduced Natural Aptitude as counterpart to ComInt but for stats
Browse files Browse the repository at this point in the history
  • Loading branch information
Musashi1584 committed Nov 22, 2018
1 parent a64ab97 commit 248447f
Show file tree
Hide file tree
Showing 14 changed files with 216 additions and 25 deletions.
Binary file added Assets/NaturalAptitudeIcon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,24 @@ HealthDeltaStrikeCostLamda = 15
DefaultStatPointsPerPromotion=15

; Class specific stat points override DefaultStatPointsPerPromotion
; +ClassStatPointsPerPromotion=(SoldierClassTemplateName=UniversalSoldier, StatPointsPerPromotion=20)
; +ClassStatPointsPerPromotion=(SoldierClassTemplateName=UniversalSoldier, StatPointsPerPromotion=20)

[StatUpgradeUI.StatUIHelper]
NaturalAptitudeAboveAverageChance=50
NaturalAptitudeThresholds[0]=50 ; 25% chance
NaturalAptitudeThresholds[1]=80 ; 15% chance
NaturalAptitudeThresholds[2]=99 ; 9.5% chance
NaturalAptitudeThresholds[3]=100 ; 0.5% chance

+NaturalAptitudeCharacterTemplates = Soldier
+NaturalAptitudeCharacterTemplates = ReaperSoldier
+NaturalAptitudeCharacterTemplates = SkirmisherSoldier
+NaturalAptitudeCharacterTemplates = TemplarSoldier
+NaturalAptitudeCharacterTemplates = XComMecSoldier
+NaturalAptitudeCharacterTemplates = SkirmXComMecSoldier

BaseSoldierNaturalAptitude[0]=0
BaseSoldierNaturalAptitude[1]=5
BaseSoldierNaturalAptitude[2]=10
BaseSoldierNaturalAptitude[3]=15
BaseSoldierNaturalAptitude[4]=20
4 changes: 2 additions & 2 deletions RPG/Config/XComEngine.ini
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
+NonNativePackages=XModBase_Lib
+NonNativePackages=XCOM2RPGOverhaul
+NonNativePackages=ExtendedUpgrades
+NonNativePackages=DetailedSoldierListWOTC
+NonNativePackages=NewPromotionScreenbyDefault
+NonNativePackages=StatUpgradeUI
+NonNativePackages=DetailedSoldierListWOTC
+NonNativePackages=Debug

[UnrealEd.EditorEngine]
Expand All @@ -17,9 +17,9 @@
+ModEditPackages=XModBase_Core_2_0_1
+ModEditPackages=XModBase_Lib
+ModEditPackages=ExtendedUpgrades
+ModEditPackages=DetailedSoldierListWOTC
+ModEditPackages=NewPromotionScreenbyDefault
+ModEditPackages=StatUpgradeUI
+ModEditPackages=DetailedSoldierListWOTC
+ModEditPackages=Debug

[Engine.Engine]
Expand Down
Binary file modified RPG/Content/DetailedSoldierListWOTC/UILibrary_LWToolbox.upk
Binary file not shown.
12 changes: 11 additions & 1 deletion RPG/Localization/StatUpgradeUI.int
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,14 @@ m_UpgradeCostHeader="SUM COSTS"
m_strSoldierSPLabel="SOLDIER SP"

[UIPanel_StatUI_StatLine]
PsiOffenseLabel="PSI"
PsiOffenseLabel="PSI"

[StatUIHelper]
NaturalAptitude="NATURAL APTITUDE"

NaturalAptitudeLabel[0]="Mortal"
NaturalAptitudeLabel[1]="Good Genes"
NaturalAptitudeLabel[2]="Peak Human"
NaturalAptitudeLabel[3]="Super Human"
NaturalAptitudeLabel[4]="Godlike"

5 changes: 4 additions & 1 deletion RPG/RPG.x2proj
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ tags=Gameplay, Soldier Class, Overhaul, RPG, Weapon, Item</Description>
<Content Include="Config\NewPromotionScreenbyDefault\XComPromotionUIMod.ini">
<SubType>Content</SubType>
</Content>
<Content Include="Config\StatUpgradeUI\XComUI.ini">
<Content Include="Config\StatUpgradeUI\XComStatUpgradeUI.ini">
<SubType>Content</SubType>
</Content>
<Content Include="Config\XComClassData.ini">
Expand Down Expand Up @@ -209,6 +209,9 @@ tags=Gameplay, Soldier Class, Overhaul, RPG, Weapon, Item</Description>
<Content Include="Src\NewPromotionScreenbyDefault\Classes\X2DownloadableContentInfo_NewPromotionScreenbyDefault.uc">
<SubType>Content</SubType>
</Content>
<Content Include="Src\StatUpgradeUI\Classes\StatUIHelper.uc">
<SubType>Content</SubType>
</Content>
<Content Include="Src\StatUpgradeUI\Classes\UIPanel_StatUI_StatLine.uc">
<SubType>Content</SubType>
</Content>
Expand Down
6 changes: 6 additions & 0 deletions RPG/ReadMe.txt
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,12 @@ Known incompatibilities:
- "Hack Plus" leads to insane high hacking stats
- I am the commander here


[b]My soldier keep getting promited to basegame/other classes?[/b]
Its a strange bug cause by the config system for some people.
Use the mod Disable Any Class Wotc and disable all classes but UniversalSoldier in the ingame mod options.
https://steamcommunity.com/sharedfiles/filedetails/?id=1148535137

[h1]A note on the beta status[/h1]
This mod will change frequently.
Therefor it might be needed that you rebuild you soldiers.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ var UIText AimValue, DefenseValue;

//icons to be shown in the name area
var UIImage HealthIcon, MobilityIcon, WillIcon, HackIcon, DodgeIcon, PsiIcon, PrimaryWeaponIcon, SecondaryWeaponIcon;
var UIText HealthValue, MobilityValue, WillValue, HackValue, DodgeValue, PsiValue;
var UIText HealthValue, MobilityValue, WillValue, HackValue, DodgeValue, PsiValue, SPValue;

var UIIcon APIcon;
var UIIcon APIcon, NatAptIcon;

var array<UIIcon> BadTraitIcon;

Expand Down Expand Up @@ -541,14 +541,35 @@ function AddNameColumnIcons(XComGameState_Unit Unit, out string traitToolTip)
}
}

if (NatAptIcon == none)
{
NatAptIcon = Spawn(class'UIIcon', self);
NatAptIcon.bAnimateOnInit = false;
NatAptIcon.bDisableSelectionBrackets = true;
NatAptIcon.InitIcon('NaturalAptitudeIcon', "img:///UILibrary_LWToolbox.UI.NaturalAptitudeIcon", false, false);
}
IconXPos += IconXDelta;
NatAptIcon.SetScale(IconScale * 0.6);
NatAptIcon.SetPosition(IconXPos - (IconToValueOffsetX * 0.1), IconYPos);
NatAptIcon.Show();

if(SPValue == none)
{
SPValue = Spawn(class'UIText', self);
SPValue.bAnimateOnInit = false;
SPValue.InitText('SPValue_ListItem_LW').SetPosition(IconXPos + IconToValueOffsetX, IconYPos + IconToValueOffsetY);
}
SPValue.SetHtmlText(class'UIUtilities_Text'.static.GetColoredText(string(class'StatUpgradeUI.StatUIHelper'.static.GetSoldierSP(Unit)), eUIState_Normal));
SPValue.Show();

PrimaryLoadoutImage = "img:///UILibrary_RPG.loadout_icon_" $ string(X2WeaponTemplate(Unit.GetPrimaryWeapon().GetMyTemplate()).WeaponCat);
SecondaryLoadoutImage = "img:///UILibrary_RPG.loadout_icon_" $ string(X2WeaponTemplate(Unit.GetSecondaryWeapon().GetMyTemplate()).WeaponCat);

if (PrimaryWeaponIcon == none)
{
PrimaryWeaponIcon = Spawn(class'UIImage', self);
PrimaryWeaponIcon.bAnimateOnInit = false;
PrimaryWeaponIcon.InitImage('PrimaryLoadoutImage_ListItem', PrimaryLoadoutImage).SetScale(IconScale).SetPosition(IconXPos += 35, -9.0f);
PrimaryWeaponIcon.InitImage('PrimaryLoadoutImage_ListItem', PrimaryLoadoutImage).SetScale(IconScale).SetPosition(IconXPos += 35 - IconXDelta, -9.0f);
}

if (SecondaryWeaponIcon == none && Unit.GetSecondaryWeapon() != none)
Expand All @@ -559,7 +580,7 @@ function AddNameColumnIcons(XComGameState_Unit Unit, out string traitToolTip)
}


IconXPos += IconXDelta;
//IconXPos += IconXDelta;

EventTemplateManager = class'X2EventListenerTemplateManager'.static.GetEventListenerTemplateManager();

Expand Down Expand Up @@ -674,6 +695,11 @@ simulated function UpdateItemsForFocus(bool Focussed)
{
APIcon.SetForegroundColor(APColours[int(Unit.ComInt)]);
}
if (NatAptIcon != none)
{
NatAptIcon.SetForegroundColor(APColours[int(class'StatUpgradeUI.StatUIHelper'.static.GetNaturalAptitude(Unit))]);
}
}
}
Expand Down
105 changes: 105 additions & 0 deletions RPG/Src/StatUpgradeUI/Classes/StatUIHelper.uc
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
class StatUIHelper extends Object config(StatUpgradeUI);

enum ENaturalAptitude
{
eNaturalAptitude_Standard,
eNaturalAptitude_AboveAverage,
eNaturalAptitude_Gifted,
eNaturalAptitude_Genius,
eNaturalAptitude_Savant,
};


var config array<name> NaturalAptitudeCharacterTemplates;
var config array<int> NaturalAptitudeThresholds;
var config int NaturalAptitudeAboveAverageChance;
var config array<ENaturalAptitude> BaseSoldierNaturalAptitude;

var localized string NaturalAptitudeLabel[ENaturalAptitude.EnumCount]<BoundEnum = ENaturalAptitude>;
var localized string NaturalAptitude;

static function OnPostCharacterTemplatesCreated()
{
local X2CharacterTemplateManager CharacterTemplateMgr;
local X2CharacterTemplate SoldierTemplate;
local array<X2DataTemplate> DataTemplates;
local int ScanTemplates, ScanAdditions;

CharacterTemplateMgr = class'X2CharacterTemplateManager'.static.GetCharacterTemplateManager();

for ( ScanAdditions = 0; ScanAdditions < default.NaturalAptitudeCharacterTemplates.Length; ++ScanAdditions )
{
CharacterTemplateMgr.FindDataTemplateAllDifficulties(default.NaturalAptitudeCharacterTemplates[ScanAdditions], DataTemplates);
for (ScanTemplates = 0; ScanTemplates < DataTemplates.Length; ++ScanTemplates)
{
SoldierTemplate = X2CharacterTemplate(DataTemplates[ScanTemplates]);
if (SoldierTemplate != none)
{
SoldierTemplate.OnStatAssignmentCompleteFn = class'StatUIHelper'.static.OnStatAssignmentCompleteNaturalAptitude;
}
}
}
}

static function OnStatAssignmentCompleteNaturalAptitude(XComGameState_Unit UnitState)
{
local ENaturalAptitude Apt;

Apt = RollNaturalAptitude();

//`LOG(default.Class @ GetFuncName() @ Apt @ float(Apt),, 'RPG');
UnitState.SetUnitFloatValue('NaturalAptitude', float(Apt) , eCleanUp_Never);
}

static function int GetBonusStatPointsFromNaturalAptitude(XComGameState_Unit UnitState)
{
//`LOG(default.Class @ GetFuncName() @ default.BaseSoldierNaturalAptitude[GetNaturalAptitude(UnitState)],, 'RPG');
return default.BaseSoldierNaturalAptitude[GetNaturalAptitude(UnitState)];
}

static function ENaturalAptitude GetNaturalAptitude(XComGameState_Unit UnitState)
{
local UnitValue NaturalAptitudeValue;

UnitState.GetUnitValue('NaturalAptitude', NaturalAptitudeValue);

//`LOG(default.Class @ GetFuncName() @ NaturalAptitudeValue.fValue @ GetEnum(Enum'ENaturalAptitude', NaturalAptitudeValue.fValue),, 'RPG');

return ENaturalAptitude(NaturalAptitudeValue.fValue);
}

static function ENaturalAptitude RollNaturalAptitude()
{
local array<int> Thresholds;
local int idx, NaturalAptitudeRoll;

if (class'X2StrategyGameRulesetDataStructures'.static.Roll(default.NaturalAptitudeAboveAverageChance))
{
Thresholds = default.NaturalAptitudeThresholds;
NaturalAptitudeRoll = `SYNC_RAND_STATIC(100);

for (idx = 0; idx < Thresholds.Length; idx++)
{
if (NaturalAptitudeRoll < Thresholds[idx])
{
return ENaturalAptitude(1 + idx);
break;
}
}
}

return eNaturalAptitude_Standard;
}

static function string GetNaturalAptitudeLabel(ENaturalAptitude NatApt)
{
//`LOG(default.Class @ GetFuncName() @ NatApt @ default.NaturalAptitudeLabel[NatApt] @ default.NaturalAptitudeLabel[eNaturalAptitude_Standard],, 'RPGO');
return default.NaturalAptitudeLabel[NatApt];
}

static function int GetSoldierSP(XComGameState_Unit UnitState)
{
local UnitValue StatPointsValue;
UnitState.GetUnitValue('StatPoints', StatPointsValue);
return int(StatPointsValue.fValue);
}
2 changes: 1 addition & 1 deletion RPG/Src/StatUpgradeUI/Classes/UIPanel_StatUI_StatLine.uc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class UIPanel_StatUI_StatLine extends UIPanel config (UI);
class UIPanel_StatUI_StatLine extends UIPanel config (StatUpgradeUI);

struct StatCostBind
{
Expand Down
18 changes: 13 additions & 5 deletions RPG/Src/StatUpgradeUI/Classes/UIScreen_StatUI.uc
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
class UIScreen_StatUI extends UIArmory config(UI);
class UIScreen_StatUI extends UIArmory config(StatUpgradeUI);

var UIPanel Container;
var UIBGBox PanelBG;
var UIBGBox FullBG;
var UIX2PanelHeader TitleHeader;
var UIImage SCImage;
var UIButton SaveButton;
var UIText StatPointsText, AbilityPointsText, StatNameHeader, StatValueHeader, UpgradePointsHeader, StatCostHeader, UpgradeCostHeader;
var UIText NaturalAptitudeText, StatPointsText, AbilityPointsText, StatNameHeader, StatValueHeader, UpgradePointsHeader, StatCostHeader, UpgradeCostHeader;
var array<UIPanel_StatUI_StatLine> StatLines;
var bool bLog;

Expand Down Expand Up @@ -54,6 +54,10 @@ function InitPanels()
AbilityPointsText.SetWidth(200);
AbilityPointsText.SetPosition(Container.Width - AbilityPointsText.Width - StatPointsText.Width - LeftPadding, LeftPadding);

NaturalAptitudeText = Spawn(class'UIText', Container).InitText('NaturalAptitudeText');
NaturalAptitudeText.SetWidth(450);
NaturalAptitudeText.SetPosition(Container.Width - NaturalAptitudeText.Width - LeftPadding, LeftPadding * 2);

TitleHeader = Spawn(class'UIX2PanelHeader', Container);
TitleHeader.InitPanelHeader('', "", "");
TitleHeader.SetPosition(SCImage.Width + RunningHeaderOffsetX + 10, LeftPadding);
Expand Down Expand Up @@ -116,7 +120,6 @@ function InitStatLines()
{
local UIPanel_StatUI_StatLine StatLine;
local int Index, OffsetX, OffsetY;
local UnitValue StatPointsValue;
local bool bUseBetaStrikeHealthProgression;

bUseBetaStrikeHealthProgression = UnitState.GetSoldierClassTemplateName() == 'UniversalSoldier';
Expand Down Expand Up @@ -162,6 +165,8 @@ function InitStatLines()

function PopulateHeaderData()
{
local string NaturalAptitude;

if (UnitState.GetSoldierClassTemplate() != none)
{
SCImage.LoadImage(UnitState.GetSoldierClassIcon());
Expand All @@ -170,6 +175,9 @@ function PopulateHeaderData()

TitleHeader.SetText(UnitState.GetName(eNameType_FullNick), Caps(UnitState.IsSoldier() ? UnitState.GetSoldierClassDisplayName() : ""));
TitleHeader.MC.FunctionVoid("realize");

NaturalAptitude = class'UIUtilities_Text'.static.AlignRight(class'UIUtilities_Text'.static.GetColoredText(class'StatUIHelper'.default.NaturalAptitude $ ":" @ Caps(class'StatUIHelper'.static.GetNaturalAptitudeLabel(class'StatUIHelper'.static.GetNaturalAptitude(UnitState))), eUIState_Normal, FontSize));
NaturalAptitudeText.SetHtmlText(NaturalAptitude);
}

function PopulateSoldierPoints()
Expand All @@ -179,7 +187,7 @@ function PopulateSoldierPoints()
CurrentSP = Max(GetSoldierSP() - StatPointCostSum, 0);
CurrentAP = GetSoldierAP() - AbilityPointCostSum - Min(GetSoldierSP() - StatPointCostSum, 0);

StatPointsText.SetHtmlText(class'UIUtilities_Text'.static.GetColoredText(m_strSoldierSPLabel @ string(CurrentSP), eUIState_Normal, FontSize));
StatPointsText.SetHtmlText(class'UIUtilities_Text'.static.AlignRight(class'UIUtilities_Text'.static.GetColoredText(m_strSoldierSPLabel @ string(CurrentSP), eUIState_Normal, FontSize)));
AbilityPointsText.SetHtmlText(class'UIUtilities_Text'.static.GetColoredText(class'UIArmory_PromotionHero'.default.m_strSoldierAPLabel @ string(CurrentAP), eUIState_Normal, FontSize));
}

Expand Down Expand Up @@ -360,7 +368,7 @@ simulated function bool IsAllowedToCycleSoldiers()

defaultproperties
{
StatOffsetY=70
StatOffsetY=90
LeftPadding=40
Padding=20
FontSize=32
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
class X2DownloadableContentInfo_StatUpgradeUI extends X2DownloadableContentInfo;


static event OnPostTemplatesCreated()
{
class'StatUIHelper'.static.OnPostCharacterTemplatesCreated();
}

exec function DebugStatUIHeader(
int StatNameHeaderWidth,
Expand Down
Loading

0 comments on commit 248447f

Please sign in to comment.