Jump to content

Interesting UPK Stuff I've Found


BlackAlpha

Recommended Posts

I'm going to use this topic to post interesting settings I've found in the UPK files. Everything I change in my mod (Warspace), I will also list here, so everyone knows how it's done.

 

All changes to the Warspace mod can be found inside the modding tools archive, inside a file called "Changes to UPK files.txt":

http://forums.nexusmods.com/index.php?/topic/820867-here-are-upk-modding-tools/

 

I will also post things here with a bit more explanation of how they work.

 

 

 

 

XcomGame.upk:

 

==== XGTacticalGameCore ====

 

>>>> function bool CalcCriticallyWounded

 

 

"iCriticalWoundChance = 15 + aCurrentStats[7] - ROOKIE_STARTING_WILL;"

 

This seems to be the array of aCurrentStats:

const out TConfigCharacter ConfigChar, int iType, int iHP, int iOffense, int iDefense, int iMobility, int iSightRadius, int iWill, int iPsionics, int iCriticalHit, int iCriticalWound, int iFlightFuel, int iReaction, optional int iAbility1, optional int iAbility2, optional int iAbility3, optional int iAbility4, optional int iAbility5, optional int iAbility6, optional int iAbility7, optional int iAbility8, optional int iProperty1, optional int iProperty2, optional int iProperty3, optional int iProperty4, optional int iProperty5, optional int iProperty6

 

So, aCurrentstats[7] would point to the Will number of a soldier.

 

You can change the 15 to a higher or lower number to change the chances of your soldiers becoming critically injured, rather than die. Higher number is higher chance not to die. And now we also know how Will affects this.

 

Also, in the ini settings, "MAX_CRIT_WOUND" is the maximum allowed number for iCriticalWoundChance. So if you set MAX_CRIT_WOUND on 90, there will never be more than a 90% chance for soldiers to go critical, rather than die.

 

 

>>>> simulated function BuildCharacters

 

This function creates a character. If we could edit the code properly, we could add an "aUpgrades" property to default characters in the ini file to make them start with perks. By default, this function ignores that property, so it's not possible right now. Shame...

 

 

 

 

See the following topic on how to enable abductions in countries with a satellite:

 

http://forums.nexusmods.com/index.php?/topic/849122-storms-over-former-xcom-members-controlling-abductions/

 

 

 

==== XGUnit ====

 

>>> function Vector GetRandomTargetLocation

 

"return m_kPlayer.GetRandomValidPoint(self, vNearestEnemy, 6.00 * float(64));"

 

This code dictates where your soldiers will shoot when in panic.

 

Not sure at all, but I think "self" is the unit triggering the code. So the unit who is in panic.

 

"vNearestEnemy" is the enemy position firing at the soldier. I don't think this code finds any targets if there are no enemies spotted by the injured soldier, which means your soldiers will not shoot when there are no enemies in range.

 

The total float number here is 384. The float number is a radius in which targets are searched (targets can be friendlies). I'm assuming "384" covers the entire map. Center of radius is an enemy position.

 

So by reducing the number, the radius gets smaller, and so the chances of finding and shooting friendlies decreases dramatically, if not eliminated entirely.

 

I changed the float numbers to: "2.00 * float(1)". My guys haven't shot a friendly since.

 

Also, in the ini settings, "SHOOT_WHEN_PANICKED" is used as a random number to decide the chances of shooting. If it's 0, the soldier will not shoot. If it's higher than 0, the soldier will shoot. So setting it on 0 means the soldiers will never shoot when in panic. Setting it on 1 means there's a 50/50 chance. Setting it on 2 equals a 33/66 chance, etc.

 

Didn't work. See below for the post created by Drakous79 on how to solve friendly fire.

Edited by BlackAlpha
Link to comment
Share on other sites

I just noticed that editing "GetRandomTargetLocation" doesn't completely eliminate the chances of your soldiers shooting friendlies when in panic. It seems they still will try to shoot friendlies when there are no enemies in range of the unit who is in panic. I can't find the code responsible for that. I'm guessing it's somewhere in "XGAction_Fire" > "Setshot", not sure.
Link to comment
Share on other sites

===================

XComStrategyGame.upk:

===================

 

==== XGItemTree ====

 

>>>> GetItemBuildTime

 

if(eItemCat != 3 || (IsShipWeapon(eItem)))

{

iEngineerDays = 0;

}

 

Changed to:

 

goto J0x52;

eItemCat != 3 || (IsShipWeapon(eItem));

iEngineerDays = 0;

J0x52:

 

 

This is accomplished by changing the second 07 (at location 45) to an 06, so it skips all the code.

 

This makes it so the production times are re-enabled and everything takes time to build. See the INI file for the time settings.

 

Note that this one someone else found. I'm just repeating it to let people know about it. Credits to Daemonjax and Tbkiah.

 

 

 

 

 

==== XGFacility_Barracks ====

 

>>>> function DetermineTimeOut

 

kSoldier.m_iTurnsOut += 24 * iBaseTimeOut + Rand(iRandTimeOut);

 

Changed to:

 

kSoldier.m_iTurnsOut += 48 * iBaseTimeOut + Rand(iRandTimeOut);

 

 

This makes it so gravely wounded soldiers (who end a mission with less than half of their own maximum HP) will get a higher recovery time penalty. In this case, their recovery time penalty is roughly 3 times longer compared to soldiers with normal injuries.

 

In this function the recovery times are calculated. When a unit has less than half of their HP, it will be considered gravely injured and more recovery days will be added do it. Note the following HP numbers and when they will result in being gravely injured.

 

HP 1/2 = Will result in being injured, NOT gravely injured.

HP 2/4 = Will result in being injured, NOT gravely injured.

HP 2/3 = Will result in being injured, NOT gravely injured.

HP 5/9 = Will result in being injured, NOT gravely injured.

 

HP 1/4 = Will result in being GRAVELY injured.

HP 1/3 = Will result in being GRAVELY injured.

HP 4/9 = Will result in being GRAVELY injured.

 

Etc, etc.

 

 

 

 

 

==== XGAIBehavior ====

 

>>>> function float GetMoveOffenseScore

 

Changed "if(iHitChance < 50)" to "if(iHitChance < 15)".

 

This should make the AI move less and shoot more often when their hit chance is low. Should affect long range shooting the most.

 

I'm not sure about this one, though. It did seem to make a small difference when I tested it, but it could've been simply the RNG system messing with the results.

 

 

 

Check the following topic on how to mod the skill trees of all classes:

 

http://forums.nexusmods.com/index.php?/topic/813563-probably-found-a-way-to-edit-ability-trees-of-your-troops-and-enemies/

Edited by BlackAlpha
Link to comment
Share on other sites

top info thx Alpha...

 

so, with the gravely injured system..

 

if base days = 14

and

random days = 40 (as in your mod)

 

then the gravely injured tomeout (days injured) is 48 days plus 14 days )base) plus 40 (random) = 102 days?

Link to comment
Share on other sites

top info thx Alpha...

 

so, with the gravely injured system..

 

if base days = 14

and

random days = 40 (as in your mod)

 

then the gravely injured tomeout (days injured) is 48 days plus 14 days )base) plus 40 (random) = 102 days?

 

In the example from my post:

 

Injured days total = (base days + random days)

 

Gravely injured days total = (base days + random days) + ((base days + random days) * 2)

 

 

In vanilla it's:

 

Gravely injured days total = (base days + random days) + (base days + random days)

 

This has a high chance not to make any difference whatsoever from normal injury days, which is why I changed it in my mod.

Edited by BlackAlpha
Link to comment
Share on other sites

I just noticed that editing "GetRandomTargetLocation" doesn't completely eliminate the chances of your soldiers shooting friendlies when in panic. It seems they still will try to shoot friendlies when there are no enemies in range of the unit who is in panic. I can't find the code responsible for that.

XComgame.upk, class XGUnit, function AddTargetsInSight, switch(kType)

case 1:
 arrVisibleTargetsToUse = m_arrVisibleEnemies;
 if(IsPanicActive() && (arrVisibleTargetsToUse.Length == 0))
 {
 	arrVisibleTargetsToUse = m_arrVisibleFriends;
 }
 bProcessTargets = true;

 

  if(IsPanicActive() && (arrVisibleTargetsToUse.Length == 0))

If panicking and number of enemies in sight is 0, add friends to targets.

 

  if(IsPanicActive() && (arrVisibleTargetsToUse.Length > 0))

If panicking and number of enemies in sight is more than 0, add friends to targets anyway.

 

  if(IsPanicActive() && (arrVisibleTargetsToUse.Length < 0))

If panicking and number of enemies in sight is less than 0, condition failed, no shooting friends.

 

Changing the operator to is less or is more does the job. Could be better to skip the conditional. Also I fear it's gonna work for aliens as well.

 

So I took my team of star rookies with reduced will to the first misson on impossible. Took some time to get the right situation (in cover, not flanked, enemies in sight) and after some wild chase with angry sectoids, the team ended behing a van. Henderson (top right) threw a grenade on main shooter Roux (top left) and victim Gordon (bottom) to start panicking.

 

http://i.imgur.com/CtYIM.jpg

== No targets in Henderson's sight, he shooted at Roux, who shooted the sectoid.

> Henderson decided to take new cover next to Roux, who got pissed and shooted Henderson (date canceled).

< Henderson decided to take new cover next to Roux, who shooted the sectiod.

 

Edit: Savegame available, if anyone is interested. Always loaded the same save after changes to upk. Tried < in a game with no enemies in sight and with == a soldier shooted at friend, with < she decided for new cover.

 

I'm going to quote some comments from reddit topic Certainly didn't expect this the first time it happened. Hope it isn't against rules, because they made me laugh so much.

 

That may be so, but it still looks ridiculous when your sniper in panic mode slowly puts the rifle on his elbow takes aim for about 10 seconds and then headshots his buddy from highschool.

Anyhow, yeah. I've had a few panic casades - one was especially bad - my friggin' heavy (Named after this incident "Ms. Fire") somehow went off target with her rocket, blowing up a car and killing a support that was hunkering down, ready to stablize a downed soldier. She then freaked out, gunning down a sniper. I think she didn't want to leave any witnesses.

Without Ironman: HAHAHAHA he panicked and shot my most decorated sniper! I had no idea that they could even DO that! This game is f***ing brilliant! [reload save]

With Ironman: F**********CK!!!!!!! [break monitor]

Edited by Drakous79
Link to comment
Share on other sites

XComgame.upk, class XGUnit, function AddTargetsInSight, switch(kType)

case 1:
 arrVisibleTargetsToUse = m_arrVisibleEnemies;
 if(IsPanicActive() && (arrVisibleTargetsToUse.Length == 0))
 {
 	arrVisibleTargetsToUse = m_arrVisibleFriends;
 }
 bProcessTargets = true;

 

  if(IsPanicActive() && (arrVisibleTargetsToUse.Length == 0))

If panicking and number of enemies in sight is 0, add friends to targets.

 

  if(IsPanicActive() && (arrVisibleTargetsToUse.Length > 0))

If panicking and number of enemies in sight is more than 0, add friends to targets anyway.

 

  if(IsPanicActive() && (arrVisibleTargetsToUse.Length < 0))

If panicking and number of enemies in sight is less than 0, condition failed, no shooting friends.

 

Changing the operator to is less or is more does the job. Could be better to skip the conditional. Also I fear it's gonna work for aliens as well.

 

So I took my team of star rookies with reduced will to the first misson on impossible. Took some time to get the right situation (in cover, not flanked, enemies in sight) and after some wild chase with angry sectoids, the team ended behing a van. Henderson (top right) threw a grenade on main shooter Roux (top left) and victim Gordon (bottom) to start panicking.

 

http://i.imgur.com/CtYIM.jpg

== No targets in Henderson's sight, he shooted at Roux, who shooted the sectoid.

> Henderson decided to take new cover next to Roux, who got pissed and shooted Henderson (date canceled).

< Henderson decided to take new cover next to Roux, who shooted the sectiod.

 

Edit: Savegame available, if anyone is interested. Always loaded the same save after changes to upk. Tried < in a game with no enemies in sight and with == a soldier shooted at friend, with < she decided for new cover.

 

I'm going to quote some comments from reddit topic Certainly didn't expect this the first time it happened. Hope it isn't against rules, because they made me laugh so much.

 

That may be so, but it still looks ridiculous when your sniper in panic mode slowly puts the rifle on his elbow takes aim for about 10 seconds and then headshots his buddy from highschool.

Anyhow, yeah. I've had a few panic casades - one was especially bad - my friggin' heavy (Named after this incident "Ms. Fire") somehow went off target with her rocket, blowing up a car and killing a support that was hunkering down, ready to stablize a downed soldier. She then freaked out, gunning down a sniper. I think she didn't want to leave any witnesses.

Without Ironman: HAHAHAHA he panicked and shot my most decorated sniper! I had no idea that they could even DO that! This game is f***ing brilliant! [reload save]

With Ironman: FUUUUUUUUUUCK!!!!!!! [break monitor]

 

So you fixed it completely?! Very nice! I'll put it in the next Warspace version and give you the props for it. :)

 

You fixed the most annoying thing in this entire game! (in my opinion)

Link to comment
Share on other sites

Hopefully yes :) It worked for me fine, but will be great, if more people put it to test.

 

I am trying to fully understand panic in XGunit class codewise to verify it works. Haven't tested SquadSight for snipers and am suspicious about random tossed grenades.

 

Will be happy, if the fix can be included in Warspace!

 

Well, maybe the most annoying is we don't have localized maps like Egypt with pyramids hehe. And not so annoying but my favorite - not customizable country with name next to flag. *stops whinning*

Link to comment
Share on other sites

==== XComUnitPawn ====

 

>>>> state WaitingToBeDestroyed

 

Changed:

if(WorldInfo.TimeSeconds - LastRenderTime > 5.00)

 

To:

if(WorldInfo.TimeSeconds - LastRenderTime > 7200.00)

 

This makes it so dead bodies stay for a much longer time. I've no idea what the numbers actually mean. First I thought it was seconds, but bodies in vanilla disappear like after 30 seconds, so I don't know. Setting it really high does the trick, though!

 

Props to Bokauk for figuring this out.

 

HEX Hint: It's a float, so look for the value of "00 00 a0 40". Change it to "00 00 E1 45".

 

 

 

>>>> function OnTakeDamage

 

Changed:

m_aCurrentStats[7] -= XComGameReplicationInfo(class'Engine'.static.GetCurrentWorldInfo().GRI).m_kGameCore.15;
GetCharacter().m_kChar.aStats[7] -= XComGameReplicationInfo(class'Engine'.static.GetCurrentWorldInfo().GRI).m_kGameCore.15;

 

To:

m_aCurrentStats[7] -= XComGameReplicationInfo(class'Engine'.static.GetCurrentWorldInfo().GRI).m_kGameCore.5;
GetCharacter().m_kChar.aStats[7] -= XComGameReplicationInfo(class'Engine'.static.GetCurrentWorldInfo().GRI).m_kGameCore.5;

 

This will reduce the permanent will penalty that soldiers receive when they become critically injured.

 

Props to Bokauk for figuring this out.

 

HEX Hint: Change the only two "2C 0F" values to "2C 05".

Edited by BlackAlpha
Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...