Jump to content

Explosive Damage Randomization bug


Amineri

Recommended Posts

The excellent beta testers for Merciless pointed out a bug with the explosive damage randomization mod (I think the first mod I ever created).

 

It's relatively benign as these things go -- Laser pistols have no damage randomization and are unable to get increased damage (in XGTacticalGameCore.CalcOverallDamage) from critting.

 

Here is a reworked hex change that should correct the laser pistol issue.

[FIND]
07 9F 00 1B 8C 71 00 00 00 00 00 00 00 F3 76 00 00 2C 09 16 04 00 EE 76 00 00 

[REPLACE]
07 9F 00 1B 8C 71 00 00 00 00 00 00 00 F3 76 00 00 2C 14 16 04 00 EE 76 00 00 

This changes the decompiled code from:

	if(WeaponHasProperty(iWeapon, 9))
	{
		return iDamage;
	} 

to

	if(WeaponHasProperty(iWeapon, 20))
	{
		return iDamage;
	}

Weapon Property 20 is eWP_MAX, so this condition should never occur.

The original attempt changed the condition to iWeapon == eItem_ArcThrower, which had the side effect of making it impossible to stun aliens.

 

I still don't really know why this is happening, other than that the ArcThrower has 0 damage configured in its Weapons= entry, but will come out of CalcOverallDamage with a damage value of 1.

 

The new code should avoid both issues.

 

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

 

In the long term I'm looking into moving the explosive damage randomization into XGUnit.OnTakeDamage. This would result in damage that was randomized for each individual unit taking explosive damage, instead of one randomization roll being made and applying to all units hit.

Link to comment
Share on other sites

So, apparently applying the above hex replicates the same issues I'd experienced before -- it renders the ArcThrower unable to correctly stun targets.

 

I've got a save-game now set up to test stunning, so I'm going to poke around at this and see what's going on with this.

Link to comment
Share on other sites

I set it to Combat Stims in Merciless at the moment, and it's going well so far.

 

That's probably the easiest solution to the problem :)

 

It just really bugs me that returning for a nonsense property disables the arcthrower, while returning for Explosive damage property makes it work just fine. Makes me really leery of trying to play around in that function for worry of weird consequences.

 

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

 

On a side note, there appears to be some sort of bug relating to critical hit damage.

 

The formula for non-Damage Roulette crits is coded as follows in XGTacticalGameCore.CalcOverallDamage

1) damage = base damage + 1

2) damage = damage * 1.5

3) damage = damage + rand(3) -1

 

For a LPR, this should result in:

1) damage = 5 + 1 = 6

2) damage = 6 * 1.5 = 9

3) damage = 9 + rand(3) -1 = [8, 9, or 10], each with 33.3% chance

 

However, empirical testing has shown that in practice an LPR crit results in 7 damage 33.3% of the time and 9 damage 66.7% of the time.

 

When I adjusted the damage multiple down to 1.45, so that the damage range should have been [7, 8, 9] each with 33.3% chance, I instead got:

6 damage 33.3% of the time, 7 damage 33.3% of the time, and 9 damage 33.3% of the time.

 

The only thing that I think might be happening is this:

Immediately after the basic damage is computed in CalcOverallDamage, it is then adjusted via the line:

m_iActualDamage = CalcOverallDamageModFromPerk(float(m_iActualDamage));

This function is written in native code, so I can't tell what it's doing, but I suspect that there is a bug in it that is adjusting crit damage in ways that it shouldn't be. This function is most likely where perks such as Gunslinger, Bring Em On, Mayhem, and Headshot are applied.

 

I think I'm going to experiment with disabling this call and see what happens with the critical damage. If necessary I might be able to rebuild this function as a upk function somewhere, both to fix the bug and to allow additional perks (or perk effects or even carried items) to modify damage.

 

However, I've already used up the best candidate unused function in XGAbility_Targeted (GraduatedOdds) in order to implement the Ammo Mod, so will have to see.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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