Jump to content

R&D AI Improvements


Amineri

Recommended Posts

  • Replies 144
  • Created
  • Last Reply

Top Posters In This Topic

I've tried to enable overmind debug info, but had no luck either. :sad:

 

DebugOvermind does nothing and various AI debugging functions are not showing overmind state info. And I need to know in what state it is, as I suspect it gets pushed into "Fight" state on Council missions.

 

UPD: Overmind actually should go into "Fight" state and it does. Seems, patrols get deactivated somewhere else.

 

BTW, alien player is represented by XGAIPlayer. Overmind and PodManager are managed by it. For whatever reason Overmind is accessed via intermediate handler class, which makes tracing function calls even more painful.

Edited by wghost81
Link to comment
Share on other sites

On the "AI tweaking" front, I've modified that "HasPotentialKillShot" to take into account critical damage. The vanilla version only looks at the based possible damage. This function is primarily used to determine "Predetermined" ability and to choose the best target. Currently I've got it hard-coded for the x1.5 damage without the Damage Roulette second wave option.

 

Here is the file in UPKmodder format (I had to size up the function a bit to get it to fit) :

 

 

MODFILEVERSION=4
UPKFILE=XComGame.upk
GUID=5B 06 B8 18 67 22 12 44 85 9B A8 5B 9D 57 1D 4B // XComGame_EW_patch1.upk
FUNCTION=HasPotentialKillShot@XGAIBehavior
RESIZE=28

// take into account critical damage when determining a possible killshot


[BEFORE_HEX]
[HEADER]
A1 01 00 00 19 01 00 00 
[/HEADER]
[code]
//iAttackAbility = GetPrimaryAttackType()
0F 00 6A 9B 00 00 1B 97 3A 00 00 00 00 00 00 16 

//foreach m_kUnit.m_arrVisibleEnemies(kTarget,)
58 19 01 8F 9A 00 00 4B 01 95 39 00 00 00 01 95 39 00 00 00 6D 9B 00 00 00 4A 74 01 

	//kAbility = XGAbility_Targeted(m_kAbilityDM.GetBestAbilityOption(iAttackAbility, kTarget))
	0F 00 67 9B 00 00 2E BA 8A 00 00 19 01 8A 9A 00 00 1C 00 49 98 00 00 00 1B 5A 37 00 00 00 00 00 00 00 6A 9B 00 00 00 6D 9B 00 00 16 

	//if((kAbility != none) && kAbility.CheckAvailable())
	07 73 01 82 77 00 67 9B 00 00 2A 16 18 20 00 19 00 67 9B 00 00 0A 00 69 89 00 00 00 1C 6A 89 00 00 16 16 

		//iHP = kTarget.GetUnitHP()
		0F 00 69 9B 00 00 19 00 6D 9B 00 00 0A 00 AA 3A 00 00 00 1B A6 3B 00 00 00 00 00 00 16 

		//if(iHP <= kAbility.GetPossibleDamage())
		07 73 01 98 00 69 9B 00 00 19 00 67 9B 00 00 0A 00 4B 8A 00 00 00 1B 88 3A 00 00 00 00 00 00 16 16 

			//iHitChance = kAbility.GetHitChance()
			0F 00 6B 9B 00 00 19 00 67 9B 00 00 0A 00 FB 89 00 00 00 1B D3 38 00 00 00 00 00 00 16 

			//if(iHitChance > iBestHitChance)
			07 73 01 97 00 6B 9B 00 00 00 6C 9B 00 00 16 

				//iBestHitChance = iHitChance
				0F 00 6C 9B 00 00 00 6B 9B 00 00 

				//kBestAbility = kAbility
				0F 00 68 9B 00 00 00 67 9B 00 00 

	//IN
	31 
		
	//IP
	30 
	
//kAbility_Out = kBestAbility
0F 48 6F 9B 00 00 00 68 9B 00 00 

//return iBestHitChance > 50
04 97 00 6C 9B 00 00 2C 32 16 

//return ReturnValue
04 3A 6E 9B 00 00 

//EOS
53 
[/CODE]
[/BEFORE_HEX]



[AFTER_HEX]
[HEADER]
D1 01 00 00 41 01 00 00 
[/HEADER]
[code]
//foreach m_kUnit.m_arrVisibleEnemies(kTarget,)
58 19 01 8F 9A 00 00 8F 01 95 39 00 00 00 01 95 39 00 00 00 6D 9B 00 00 00 4A A4 01 

	//kAbility = XGAbility_Targeted(m_kAbilityDM.GetBestAbilityOption(GetPrimaryAttackType(), kTarget))
	0F 00 67 9B 00 00 2E BA 8A 00 00 19 01 8A 9A 00 00 1D 00 49 98 00 00 00 1B 5A 37 00 00 00 00 00 00 1B 97 3A 00 00 00 00 00 00 16 00 6D 9B 00 00 16 

	//if((kAbility != none) && kAbility.CheckAvailable())
	07 A3 01 82 77 00 67 9B 00 00 2A 16 18 20 00 19 00 67 9B 00 00 0A 00 69 89 00 00 00 1C 6A 89 00 00 16 16 

		//iAttackAbility = kAbility.GetPossibleDamage()
		0F 00 6A 9B 00 00 19 00 67 9B 00 00 0A 00 4B 8A 00 00 00 1B 88 3A 00 00 00 00 00 00 16 

		//if(kAbility.GetCriticalChance() >= 50)
		07 10 01 99 19 00 67 9B 00 00 0A 00 FD 89 00 00 00 1B F7 37 00 00 00 00 00 00 16 2C 32 16 

			//iAttackAbility *= 1.5 // 3FC00000
			9F 00 6A 9B 00 00 1E 00 00 C0 3F 16 

			//iAttackAbility += 1
			A1 00 6A 9B 00 00 2C 01 16 

		//if(kTarget.GetUnitHP() <= iAttackAbility)
		07 A3 01 98 19 00 6D 9B 00 00 0A 00 AA 3A 00 00 00 1B A6 3B 00 00 00 00 00 00 16 00 6A 9B 00 00 16 

			//iHitChance = kAbility.GetHitChance()
			0F 00 6B 9B 00 00 19 00 67 9B 00 00 0A 00 FB 89 00 00 00 1B D3 38 00 00 00 00 00 00 16 

			//if(iHitChance > iBestHitChance)
			07 A3 01 97 00 6B 9B 00 00 00 6C 9B 00 00 16 

				//iBestHitChance = iHitChance
				0F 00 6C 9B 00 00 00 6B 9B 00 00 

				//kBestAbility = kAbility
				0F 00 68 9B 00 00 00 67 9B 00 00 

	//IN
	31 
		
	//IP
	30 
	
//kAbility_Out = kBestAbility
0F 48 6F 9B 00 00 00 68 9B 00 00 

//return iBestHitChance > 50
04 97 00 6C 9B 00 00 2C 32 16 

//return ReturnValue
04 3A 6E 9B 00 00 

//EOS
53 
[/CODE]
[/AFTER_HEX]
 

 

 

 

The new code looks like so as decompiled by UE Explorer :

simulated function bool HasPotentialKillShot(out XGAbility_Targeted kAbility_Out)
{
    local XGUnit kTarget;
    local int iBestHitChance, iHitChance, iAttackAbility, iHP;
    local XGAbility_Targeted kBestAbility, kAbility;

    foreach m_kUnit.m_arrVisibleEnemies(kTarget,)
    {
        kAbility = XGAbility_Targeted(m_kAbilityDM.GetBestAbilityOption(GetPrimaryAttackType(), kTarget));
        if((kAbility != none) && kAbility.CheckAvailable())
        {
            iAttackAbility = kAbility.GetPossibleDamage();
            if(kAbility.GetCriticalChance() >= 50)
            {
                iAttackAbility *= 1.50;
                iAttackAbility += 1;
            }
            if(kTarget.GetUnitHP() <= iAttackAbility)
            {
                iHitChance = kAbility.GetHitChance();
                if(iHitChance > iBestHitChance)
                {
                    iBestHitChance = iHitChance;
                    kBestAbility = kAbility;
                }
            }
        }        
    }    
    kAbility_Out = kBestAbility;
    return iBestHitChance > 50;
    //return ReturnValue;    
}
Link to comment
Share on other sites

  • 2 months later...

Converted AI Improvements to PatchUPK pseudo-code, as all old AI bugs are still present in EU, including flanked+overwatched=freeze bug. :sad: Added it to "Interface and Gameplay Tweaks" collection.

 

Just wanted to say: Amineri, this mod is a piece of art. So much is done without any of the modding tools we have today. Great job!

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.

×
×
  • Create New...