XCOM Squadsight Aim Penalty XGAbility Targeted GetUIHitChance Notes

From Nexus Mods Wiki
Jump to: navigation, search

Overview

This contains the development notes for the changes to the function XGAbility_Targeted.GetUIHitChance in XComGame.upk.

This change supports the additional of an aim penalty when using Squadsight.

XCOM_Squadsight_Aim_Penalty_Mod

Development Notes

Some tests to see if the other UI Hit chances can be adjusted

Looking at XGAbility_Targeted.GetUIHitChance

The relevant portion is at the end.

            if(HasProperty(36))
            {
                iUIHitChance = GetHitChance();
                iUICriticalChance = 0;
            }
            // End:0x1D8
            else
            {
                iUIHitChance = GetHitChance();
                iUICriticalChance = GetCriticalChance();
            }

This can be simplified to:

            iUIHitChance = GetHitChance();
            if(HasProperty(36))
            {
                iUICriticalChance = 0;
            }
            // End:0x1D8
            else
            {
                iUICriticalChance = GetCriticalChance();
            }
Then, the AdjustToHit can be applied.

            iUIHitChance = AdjustToHit(GetHitChance());
            if(HasProperty(36))
            {
                iUICriticalChance = 0;
            }
            // End:0x1D8
            else
            {
                iUICriticalChance = GetCriticalChance();
            }

			
original hex code:
header:
CC 7C 00 00 50 55 00 00 00 00 00 00 B4 7C 00 00 00 00 00 00 00 00 00 00 B7 7C 00 00 00 00 00 00 4D 02 00 00 C7 50 00 00 DB 01 00 00 67 01 00 00 

body: 06
07 23 01 1B 9A 36 00 00 00 00 00 00 24 20 16 07 31 00 9A 01 E2 7B 00 00 2C 4B 16 0F 00 B5 7C 00 00 1D E2 FF FF FF 06 D4 00 07 D4 00 9A 01 E2 7B 00 00 2C 35 16 07 D4 00 77 19 1B 38 34 00 00 00 00 00 00 16 0C 00 39 33 00 00 00 1B 21 31 00 00 00 00 00 00 2C 2B 16 2A 16 A2 00 B5 7C 00 00 19 19 2E FE 2C 00 00 19 12 20 4F FE FF FF 0A 00 D8 F9 FF FF 00 1C F6 FB FF FF 16 09 00 98 F9 FF FF 00 01 98 F9 FF FF 09 00 F0 2C 00 00 00 01 F0 2C 00 00 02 00 F0 2C 00 00 00 2C 28 16 0F 48 B7 7C 00 00 19 01 E6 7B 00 00 22 00 A4 33 00 00 00 1B B5 71 00 00 00 00 00 00 25 00 B5 7C 00 00 27 27 1B 38 34 00 00 00 00 00 00 16 4A 4A 16 0F 48 B6 7C 00 00 25 06 D8 01 07 7F 01 1B 9A 36 00 00 00 00 00 00 24 2D 16 0F 48 B7 7C 00 00 1B 8A 34 00 00 00 00 00 00 E1 D8 19 01 E6 7B 00 00 09 00 DE F8 FF FF 00 01 DE F8 FF FF 01 12 BC 00 00 16 16 16 0F 48 B6 7C 00 00 25 06 D8 01 07 B0 01 1B 9A 36 00 00 00 00 00 00 24 24 16 0F 48 B7 7C 00 00 1B A6 32 00 00 00 00 00 00 16 0F 48 B6 7C 00 00 25 06 D8 01 0F 48 B7 7C 00 00 1B A6 32 00 00 00 00 00 00 16 0F 48 B6 7C 00 00 1B D9 31 00 00 00 00 00 00 16 04 0B 53 

portion I am interested in:
else
06 D8 01 

	if(HasProperty(36))
	07 B0 01 1B 9A 36 00 00 00 00 00 00 24 24 16 

		iUIHitChance = GetHitChance();
		0F 48 B7 7C 00 00 1B A6 32 00 00 00 00 00 00 16 

		iUICriticalChance = 0;
		0F 48 B6 7C 00 00 25 

	else
	06 D8 01 

		iUIHitChance = GetHitChance();
		0F 48 B7 7C 00 00 1B A6 32 00 00 00 00 00 00 16 

		iUICriticalChance = GetCriticalChance();
		0F 48 B6 7C 00 00 1B D9 31 00 00 00 00 00 00 16
		
		
	from RollForHit
	iAdjustedChance = AdjustToHit(GetHitChance());
	0F 00 D3 7C 00 00 1B 9B 02 00 00 00 00 00 00 1B A6 32 00 00 00 00 00 00 16 16
	
	
Reworked code is:
else
06 D8 01 

	iUIHitChance = AdjustToHit(GetHitChance());
	0F 48 B7 7C 00 00 1B 9B 02 00 00 00 00 00 00 1B A6 32 00 00 00 00 00 00 16 16

	if(HasProperty(36))
	07 BA 01 1B 9A 36 00 00 00 00 00 00 24 24 16 

		iUICriticalChance = 0;
		0F 48 B6 7C 00 00 25 

	else
	06 D8 01 

		iUICriticalChance = GetCriticalChance();
		0F 48 B6 7C 00 00 1B D9 31 00 00 00 00 00 00 16
		
		null ops (6 bytes)
		0B 00 B5 7C 00 00 
		
consolidated hex code:
original: (virtual size 0x1DB)
06 D8 01 07 B0 01 1B 9A 36 00 00 00 00 00 00 24 24 16 0F 48 B7 7C 00 00 1B A6 32 00 00 00 00 00 00 16 0F 48 B6 7C 00 00 25 06 D8 01 0F 48 B7 7C 00 00 1B A6 32 00 00 00 00 00 00 16 0F 48 B6 7C 00 00 1B D9 31 00 00 00 00 00 00 16

new: (virtual size 0x1DB)
06 D8 01 0F 48 B7 7C 00 00 1B 9B 02 00 00 00 00 00 00 1B A6 32 00 00 00 00 00 00 16 16 07 BA 01 1B 9A 36 00 00 00 00 00 00 24 24 16 0F 48 B6 7C 00 00 25 06 D8 01 0F 48 B6 7C 00 00 1B D9 31 00 00 00 00 00 00 16 0B 00 B5 7C 00 00 

This corrects the Hit Chance displayed above the enemy icons in the lower right hand side of the screen.


References

Referred to by this article:

That refer to this article:

  • <none>