Explosive Damage - XCOM:EU 2012

From Nexus Mods Wiki
Revision as of 00:01, 16 November 2018 by Dubiousintent (talk | contribs) (Added 'Category:Mod_Creation')
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Overview

This article will provide information relating to several mods that change the nature of explosive damage.

  1. Making explosive damage randomized instead of fixed
  2. Making explosive damage destroy alien corpses in addition to weapon fragment
  3. Making explosive damage radius randomized

Background

By default, explosive damage is very reliable and predictable. Even with the Second Wave option "Damage Roulette" enabled, Grenade and Rocket damage is not randomized. Grenade and Rocket "Area of Effect" (AoE) is fixed, which allows for extremely precise positioning of the blast. Explosive damage will destroy any weapon fragment that might have been obtained, but will not destroy alien corpses or the Alloys/Elerium from defeated alien robots.

These series of mods provide options for changing these default behaviors.

Details about what each Mod does

  1. Makes explosive damage follow the same rules as other weapons. Damage is +/-1 in normal, with increased variability with Second Wave option "Damage Roulette"
  2. Makes aliens killed by explosives not yield any corpses. They will still yield:
    1. Cyberdiscs yield Alloys and/or Elerium
    2. Drones yield Alloys and/or Elerium
    3. Heavy Floaters yield Alloys and/or Elerium
    4. Sectopods yield Alloys and/or Elerium
  3. Make explosive radius randomized. This is represented graphically by making the "AoE bubble" fluctuate rapidly to indicate the possible area covered.

Randomized Explosive Damage File Changes

Only one small file change is required to implement this. The change alters a condition which would prevent randomized damage from being applied if the weapon had property 8 (eWP_Explosive). The conditional checks to see if the weapon is of type 8 (Laser Pistol). This change was found to eliminate a bug that would prevent ArcThrowers from being able to stun enemies.

Hex Change

XcomGame.upk >> XGTacticalGameCore.CalcOverallDamage
original: 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
new: 07 9F 00 9A 00 F3 76 00 00 2C 08 16 04 00 EE 76 00 00 0B 0B 0B 0B 0B 0B 0B 0B

Decompiled Code

Original Code

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

New Code

    if(iWeapon == 8)
    {
        return iDamage;                                                                
    }
  

Increased Explosive Destruction File Changes

Only one small file change is required to implement this. The change alters the code so that a large section of code is skipped if the alien was killed by explosive damage. The default code would prevent a Sectoid Commander from being counted as "destroyed by explosive damage" on a base mission. This is also changed so that any Sectoid Commanders killed in a base attack mission will no longer yield corpses.

Hex Change

XcomGame.upk >> XGSummaryUI.CollectArtifactsFromDeadAliens
original: 07 7B 03 19 00 CC AD 00 00 0A 00 90 AF 00 00 00 2D 01 90 AF 00 00 07 7B 03 9A 35 D3 0D 00 00 D5 0D 00 00 00 00 19 19 00 CC AD 00 00 0A 00 63 B4 00 00 00 1B 7B 31 00 00 00 00 00 00 16 09 00 C3 A2 00 00 00 01 C3 A2 00 00 2C 09 16 07 7B 03 9A 19 1B BD 19 00 00 00 00 00 00 16 09 00 B0 9F 00 00 00 01 B0 9F 00 00 2C 06 16 14 19 00 CC AD 00 00 0A 00 90 AF 00 00 00 2D 01 90 AF 00 00 28 07 8D 03 72 00 CC AD 00 00 2A 16 06 93 0B
new: 07 8D 03 19 00 CC AD 00 00 0A 00 90 AF 00 00 00 2D 01 90 AF 00 00 07 7B 03 9A 35 D3 0D 00 00 D5 0D 00 00 00 00 19 19 00 CC AD 00 00 0A 00 63 B4 00 00 00 1B 7B 31 00 00 00 00 00 00 16 09 00 C3 A2 00 00 00 01 C3 A2 00 00 2C 09 16 07 7B 03 9A 19 1B BD 19 00 00 00 00 00 00 16 09 00 B0 9F 00 00 00 01 B0 9F 00 00 2C 06 16 14 19 00 CC AD 00 00 0A 00 90 AF 00 00 00 2D 01 90 AF 00 00 28 0B 0B 0B 0B 00 CC AD 00 00 0B 0B 06 9F 05

Decompiled Code

Development Notes

Randomized Explosive Radius File Changes

Background

Introduction: This mod requires re-writing a very small function, XComGame.XGWeapon.GetDamageRadius, but it only uses functions already present in the original one. There are many possible implementations of this modlet, here I've chosen an approach with great randomness, and because of that the "Danger Zone" perk bonus doesn't stack with default explosives radius (so it's only useful to the machine-gun), but you can adapt the code as you see fit. The only suggestion is to keep the random factor at two tiles at least.

Calculating Area of Effect:

  • Despite the game calling it "radius", it is in fact the total diameter of the "Area of Effect" (AoE).
  • Each tile is 64 units wide

That is why by default the Danger Zone perk grants +192 "radius", because 1) it assumes default weapon radius is 0, and 2) 192/64 = 3 tiles, because you've got to count the one in the middle that now has to be covered entirely, so yes, effectively you've got now two more tiles of AoE.

Decompiled Code

Original Code:

simulated function float GetDamageRadius()
{
    // End:0xF6
    if((m_eType == 7) || m_eType == 19)
    {
        // End:0xF6
        if((m_kOwner != none) && m_kOwner.GetCharacter().HasUpgrade(25))
        {
            return float(m_kTWeapon.iRadius + XComGameReplicationInfo(class'Engine'.static.GetCurrentWorldInfo().GRI).m_kGameCore.192);
        }
    }
    return float(m_kTWeapon.iRadius);
    //return ReturnValue;
}

New Code:

simulated function float GetDamageRadius()
{
    // End:0xE2
    if((m_eType == 85) || (m_eType == 88) || (m_eType == 7) || (m_eType == 19) || m_kOwner.GetCharacter().HasUpgrade(25))
    {
        return float(m_kTWeapon.iRadius + Rand(m_kTWeapon.iRadius));
    }
    return float(m_kTWeapon.iRadius);
    //return ReturnValue;
}
Hex Code:

Original Code:


New Code:

// End:0xE2
if((m_eType == 85) || (m_eType == 88) || (m_eType == 7) || (m_eType == 19) || m_kOwner.GetCharacter().HasUpgrade(25))

	;if((m_eType == 85) || {other conditions}
	07 E2 00 84 9A 01 XX XX 00 00 2C 55 16 18 6E 00 
		;JumpIfNot
		07 E2 00 
		;OR ||
		84 
		;Equals ==
		9A 
		;m_eType
		01 XX XX 00 00 (check function hex)
		; integer 88
		2C 55 
		;end comparison ==
		16 
		;skip 00 6E positions (check Hex editing tutorial)
		18 6E 00 
	
	;(m_eType == 88) || (m_eType == 7) || (m_eType == 19)
	84 9A 01 XX XX 00 00 2C 58 16 18 5C 00 84 9A 01 XX XX 00 00 2C 07 16 18 4A 00 84 9A 01 XX XX 00 00 2C 13 16 18 38 00 
		;OR ||; equals ==; m_eType; int 88; end equals; 
		84 9A 01 XX XX 00 00 2C 58 16 
		;skip 00 5C
		18 5C 00 
		;OR ||; equals ==; m_eType; int 7; end equals; 
		84 9A 01 XX XX 00 00 2C 07 16 
		;skip 00 4A
		18 4A 00 
		;OR ||; equals ==; m_eType; int 19; end equals; 
		84 9A 01 XX XX 00 00 2C 13 16 
		;skip 00 38
		18 38 00 

	;m_kOwner.GetCharacter().HasUpgrade(25))
	(check original function for hex code)
	; end OR, end OR, end OR, end OR
	16 16 16 16 

;return float(m_kTWeapon.iRadius + Rand(m_kTWeapon.iRadius));
		
		;return
		04 
		;float casting
		38 3F 
		;sum +
		92 
		;m_kTWeapon.iRadius
		35 XX XX 00 00 XX XX 00 00 00 00 01 XX XX 00 00 
		;random
		A7 
		;m_kTWeapon.iRadius
		35 XX XX 00 00 XX XX 00 00 00 00 01 XX XX 00 00 
		;end random, end sum
		16 16

This edit requires adjusting function's virtual size in it's header to 0x10B and fill with null values the rest of the function's body, except for default return null and any footer there might be.


References

Referred to by this article:


That refer to this article: