Jump to content

R&D Tactical bug hunts (suppression and alien skipping turn)


johnnylump

Recommended Posts

My suggestion would be to replace the :

 

if(kAbility.iType == 8)
{
return Max(int(float((iOS + Ids) + iIS) * (AI_GetScoreModifier(kAbility))), 1);
}
// End:0x168
else
{
return int(float((iOS + Ids) + iIS) * (AI_GetScoreModifier(kAbility)));
}

 

construction with a single return statement with an embedded ternary operation, a la

 

 

return Max(int(float((iOS + Ids) + iIS) * (AI_GetScoreModifier(kAbility))), (kAbility.iType == 8 ? 50 : 0) );

Link to comment
Share on other sites

  • Replies 89
  • Created
  • Last Reply

Top Posters In This Topic

Nice JL I'll try it out.

Maybe it'd be possible to add a 50/50 chance using bool implicit casting. Ive already tested that in updateItemCharges, ala return max (whatever *( bool conditon, either 0 or 1)). Not sure if it would affect somehow turning negagive values to 0 though

Link to comment
Share on other sites

Hrm, seeing some maddeningly inconsistent behavior. With move set as the ability of interest and scored at a minimum 10, alien froze under all circumstances, but after reload the alien broke for it, even when overwatched by four soldiers, including a flanker.

 

Amineri, I'll try your alternate formulation, although I haven't done a ternary operation yet. I believe it would have to be with ability 7 (8 should be Rapid Fire, if the enumerated abilities count from 0). I take it you're certain 0 is the lowest score any ability can receive, yes?

 

Edit: Are those debug strings the code is forming viewable anywhere, like in the dev's console?

Edited by johnnylump
Link to comment
Share on other sites

Hmmm, I think the debug string in actionscript are only viewable via whatever Flash-tool was used to create the actionscript files in the first place, but I can't say I'm 100% certain.

 

The Ternary operation follows the format:

 

45 -- Ternary token

<boolean expression>

## ## -- two bytes representing the virtual size of the RETURN TRUE expression

<RETURN TRUE expression>

## ## -- two bytes representing the virtual size of the RETURN FALSE expression

<RETURN FALSE expression>

 

There is no 16 token used to terminate the ternary token. Of course, and of the there expressions may have a 0x16, but the ternary operator doesn't.

 

-------------------------

 

I concur -- EAbility_ShotStandard = 7, and EAbility_RapidFire = 8

 

My earlier post was in error :)

 

-------------------------

 

An ability can receive a score that is less than zero. However, only abilities with scores that are strictly positive are allowed to be considered for the alien's action, as I read the code.

Link to comment
Share on other sites

Now that I have the Expanded Perk Tree mod posted up to the wiki, I'm going to focus on helping JL squash this bug.

 

I'll be trawling through the AI code to see if I can't find any additional roadblocks that would be preventing the AI from selecting an action.

 

quick question: Does it only occur for sectoids, or do other alien types experience this glitch?

 

----

 

Also, welcome to fun, fun world of debugging AI code. The beauty of AI code is that it is complex and somewhat unpredictable. That also makes it a nightmare to debug ^_^

Link to comment
Share on other sites

A grateful nation thanks you.

 

It happens for other aliens. I'm mostly reporting on sectoids b/c I'm starting new games every time to test it.

 

I think that the AI classes persist over tactical savegames, so changing the code and testing on a saved tactical game won't work -- you'll at least need a new battle.

 

Possibly another way to gain bytes in AI_GetScore would be to combine these six lines into three:

 

 fOS = AI_OffenseScore(kAbility);
    fDS = AI_DefenseScore(kAbility);
    fIS = AI_IntangiblesScore(kAbility, fOS, fDS);
    iOS = int(float(100) * fOS);
    Ids = int(float(100) * fDS);
    iIS = int(float(100) * fIS);

as fOS, fDS, and fIS aren't referred to elsewhere in the function.

Link to comment
Share on other sites

Okay, if you attempt to force the alien to move, it uses the function XGAIBehavior.DecideNextDestination to do so. If it can't find a "good" destination then it defaults to some randomized behaviors.

 

It basically has a 60% chance to try and find a spot to run away to, and if it can't find one it will switch to attack. However, if attacks are still invalid for some reason, then it may end up taking no action.

The other 40% of the time it will pick a random point and move to it.

 

I've also identified that each alien gets a randomized aggression. The default behavioral aggression is:

 

m_fAggression = (class'XComEngine'.static.SyncFRand((string(Name) @ string(GetStateName())) @ string(GetFuncName())) * fAggroRange) + m_fMinAggro;
I'm not yet sure how this influences the rest of its behavior.
------------------------------
EDIT : and yes, the randomizers in the alien behavior are using the SyncRand functions, so the random seed state is being used. This means the same save-game will result in the same alien actions in the same way that shots are the same.
Edited by Amineri
Link to comment
Share on other sites

... and I don't know why your original proposal didn't work. Setting the score on "shoot" to 1 should make it a last option if everything else scores less than 1, right? So either "don't do anything" scores higher than 1, the score gets lowered to <= 0 later, or there's something that says don't shoot no matter what -- the ability is already removed from the list of possibilities.

Link to comment
Share on other sites

It could also be that something in the list of targets is trying to keep "bad" targets off the target list. In this case the alien wants to shoot but has no valid targets, so is unable. I'll poke around at that function.

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.

×
×
  • Create New...