Jump to content

The accuracy variables are killing me!


Pumpernickels

Recommended Posts

lol I don't mind it (been modding Jagged Alliance 2 for over a decade :D )

 

I just think to develop that idea further it's not hard to have multiple seeds calculated and applied to each entity in a map (max entities never really gets over 30 anyway). That would piss off the save scummers even more because it removes the transference ability to enemies...

 

I do like a good RNG though that actually works like an RNG not a weighted in the favour of the player crap :D

Link to comment
Share on other sites

  • 1 month later...

I know this thread is pretty old, but I figured I'd reply anyways. After couple of similar experiences I did a bit of research. I watched a few Let's plays on Youtube and recorded to-hit-% and actual hit%.

After 127 datapoints, the results were as follows:

 

Average to-hit% = 65.3 % (Average %-to-hit in game)

Actual hit% = 63.8 % (Actual hits in game)

 

Sample size was pretty small for probability comparison, but it suggests that there is no bias for or against ai. Which just means crappy luck sometimes. :P

 

Edit: 73 of the recorded shots were on Classic difficulty and the reset were in Impossible. The difficulty change didn't reflect any change on the data.

Edited by SgtVennamo
Link to comment
Share on other sites

Here comes the magic:

 

function int AdjustToHit(int iHitChance)
{
   local int iMissAdjustment, iAdjustment, iAdjustedHitChance;
   local XGPlayer kPlayer;

   // End:0x19
   if(!DoesDamage())
   {
       return iHitChance;
   }
   // End:0x52a
   if(WorldInfo.NetMode == 0)
   {
       // End:0x6c
       if(m_kUnit.m_aCurrentStats[1] > 199)
       {
           return 100;
       }
       // End:0xe7
       if(XComTacticalCheatManager(GetALocalPlayerController().CheatManager) != none && XComTacticalCheatManager(GetALocalPlayerController().CheatManager).bDebugDisableHitAdjustment)
       {
           return iHitChance;
       }
       kPlayer = XGBattle_SP(XComTacticalGRI(class'Engine'.static.GetCurrentWorldInfo().GRI).m_kBattle).GetHumanPlayer();
       // End:0x1ba
       if(m_kUnit.IsMine() && kPlayer.m_bCantLose && m_bHasFlank)
       {
           return 100;
       }
       // End:0x2c2
       if(kPlayer.m_bCantLose || XComTacticalGRI(class'Engine'.static.GetCurrentWorldInfo().GRI).m_kBattle.m_kDesc.m_iDifficulty == 0)
       {
           iAdjustedHitChance = GraduatedOdds(iHitChance, kPlayer, kPlayer.m_bCantLose);
           // End:0x2c2
           if(iAdjustedHitChance != -1)
           {
               return iAdjustedHitChance;
           }
       }
       // End:0x35e
       if(m_bReactionFire || XComTacticalGRI(class'Engine'.static.GetCurrentWorldInfo().GRI).m_kBattle.m_kDesc.m_iDifficulty >= 2)
       {
           return iHitChance;
       }
       // End:0x424
       if(m_kUnit.IsMine() && !GetPrimaryTarget().IsMine() && iHitChance > 0)
       {
           iAdjustment = iHitChance / 5;
           // End:0x421
           if(iHitChance >= 50)
           {
               iMissAdjustment = m_kUnit.GetPlayer().m_iMissCounter * 15;
           }
       }
       // End:0x4b2
       else
       {
           // End:0x4b2
           if(!m_kUnit.IsMine() && GetPrimaryTarget().IsMine())
           {
               iAdjustment = -GetPrimaryTarget().GetPlayer().m_iHitCounter * 10;
           }
       }
       // End:0x4f9
       if(kPlayer.GetSquad().GetNumAliveAndWell() > 4)
       {
           iAdjustment = 0;
       }
       iAdjustedHitChance = Clamp(iHitChance + iAdjustment + iMissAdjustment, 1, 95);
   }
   // End:0x53d
   else
   {
       iAdjustedHitChance = iHitChance;
   }
   return iAdjustedHitChance;
}

 

As you can see, there are adjustments that make real life hit chance different, than displayed on UI while checking hit odds.

If I read this code correctly on difficulties 2 and above they are not used.

 

I'm trying to inject somewhere inside this function cover bonus value for particular shot, to finally make it possible to increase it, but as I do not have any experience in playing with compiled UE scripts I find it very tiresome.

 

Theoretically I have everything I need. I extracted needed formulas from GetShotSummary:

 

source: kTarget = GetPrimaryTarget();

compiled: 0F 00 1A 7D 00 00 1B 31 34 00 00 00 00 00 00 16

 

and

 

coverPerks = kTarget.GetTacticalSenseCoverBonus();

0F 00 21 7D 00 00 19 00 1A 7D 00 00 0A 00 D1 33 00 00 00 1B DC 34 00 00 00 00 00 00 16

 

So, we know how to get to the cover value used by engine to calculate hit penalty. It will be 0 or 20 or 40.

If we just could subtract this value (or its fraction) from int iHitchance, it would practically increase hit penalty (cover bonus).

 

But as I can not find in AdjustToHit function any variables that are set or used in exact manner, it is not as easy at it seemed.

Playing with compiled scripts forces us to carefully count length of injected code so it would start and end exactly like replaced one.

In another words, there are always too many or too few bytes to inject.

 

I thought about replacing :

 

iAdjustedHitChance = GraduatedOdds(iHitChance, kPlayer, kPlayer.m_bCantLose);

0F 00 A2 7C 00 00 1B D9 35 00 00 00 00 00 00 00 A6 7C 00 00 00 A1 7C 00 00 19 00 A1 7C 00 00 0A 00 B6 93 00 00 00 2D 01 B6 93 00 00 16

 

 

with

iAdjustment = -GetPrimaryTarget().GetTacticalSenseCoverBonus();

 

or

 

iAdjustment = -GetPrimaryTarget().GetPlayer().m_iHitCounter * 10;

0F 00 A3 7C 00 00 90 8F 19 19 1B 31 34 00 00 00 00 00 00 16 0A 00 C8 B2 00 00 00 1B 03 34 00 00 00 00 00 00 16 09 00 B9 93 00 00 00 01 B9 93 00 00 16 2C 0A 16

 

with

iAdjustment = int (-GetPrimaryTarget().GetTacticalSenseCoverBonus() * SOMECONSTANT f)

 

the second would be great, if we could replace xxx with some unused float constant from gamecore.mod, we could change how much we want to increase cover bonus

using XCOM Meddler or editing .mod file and modpatching upk.

 

The rest would be playing with if ... checks, so our code would be always executed.

 

Is there someone, on this forum, who is able to do this ?

Link to comment
Share on other sites

I might be wrong in this but reloading after a missed shot and having another soldier fire does not guarantee a miss. It simply transfers that roll to him. I think the best analogy would be D&D in that one character may need a 16 to hit while another needs only a 12. So if all your guys miss reloading and hunkering them doesnt guarantee the aliens will miss as well. From experience I've been able to save scum my way out of some bad situations simply by reloading and trying different combos of moves and shots/etc untill I got the perfect result.

 

So I think its misleading to tell ppl to hunker and pass the missed rolls to the aliens.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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