Shield Hediff - KonradHeinser/EBSGFramework GitHub Wiki

This comp allows you to create shields for pawns by using hediffs instead of equipment:

        <comps>
            <li Class="EBSGFramework.HediffCompProperties_Shield">
            </li>
        </comps>

These are the options that influence how energy works:

  • maxEnergy : Default (1) : The maximum energy the shield has. The value players see is 100 times this
  • multiplyMaxBySeverity : Default (False) : Multiplies the maximum energy by the hediff's severity
  • energyRechargeRate : Default (0.45) : The amount of energy recharged each second
  • multiplyRechargeBySeverity : Default (False) : Multiplies the energy recharge rate by the hediff's severity
  • usePawnMaxAndRecharge : Default (False) : Overrides maxEnergy and energyRechargeRate with the pawn's EnergyShieldEnergyMax and EnergyShieldRechargeRate stats. Generally not recommended unless you are very sure
  • energyPerDamageModifier : Default (0.033) : The amount of energy to remove based on damage (i.e. If this is at 0.01 and max is left at 1, then it would take 100 damage to shatter the shield, assuming recharge doesn't impact things)
  • resetDelay : Default (1) : How many ticks it takes to reset the shield after it's destroyed. It's recommended to make this a number much greater than 1, but technically not enforced
  • removeOnBreak : Default (False) : Causes the hediff to be removed when the shield is shattered
  • energyOnReset : Default (0.2) : The percentage of the max to set energy to when the resetDelay is over and when the hediff is initially added
  • blockOverdamage : Default (True) : Causes the shield to block all damage regardless of how much energy there is. This won't stop the shield from shattering, it'll just prevent the pawn from taking damage from the hit that shatters it
  • reduceDamagePostDestroy : Default (False) : Causes the shield to still reduce damage when destroyed based on how much energy was left. If blockOverdamage is True, this is ignored, and if both blockOverdamage and this are False, then a hit that destroys the shield will act as though the shield never existed
  • damageInfoPacks : A special list of special items that multiply how much energy specific damage types use up when blocked. Each applicable factor multiplies the energyPerDamageModifier
    • damageDef : The DamageDef to look for
    • factor : Default (1) : How much to multiply energyPerDamageModifier by. If set to a value below 0, then the damage pack instead causes the shield to ignore the damage
    • ranged : Default (True) : If False, ranged versions of the damage will be ignored
    • explosions : Default (True) : If False, explosive versions of the damage will be ignored
    • melee : Default (False) : If False, melee versions of the damage will be ignored

These options alter when the shield will actually try to stop damage. If the damage isn't allowed by any of these, then energy generally isn't changed, but the damage also isn't absorbed or mitigated

  • onlyBlockWhileDraftedOrHostile : Default (False) : Causes the shield to only block things if the pawn has attacked in the last 1000 ticks, is drafted, or has a hostile mental state
  • blocksRangedDamage : Default (True) : Allows the shield to block ranged attacks
  • blocksExplosions : Default (True) : Allows the shield to block explosive attacks
  • blocksMeleeDamage : Default (False) : Allows the shield to block melee attacks
  • immuneDamageDefs : A list of DamageDefs that can be blocked by the shield, and won't cause energy loss when blocked
  • blockedDamageDefs : A list of DamageDefs that can be blocked by the shield. If this is in use, then all DamageDefs not on the list won't be blocked
  • ignoredDamageDefs : A list of DamageDefs that won't be blocked by the shield. If blockedDamageDefs is being used, this is not needed
  • shatterOn : A list of DamageDefs that will cause the shield to shatter immediately. This means the energy will be reduced to 0, the resetDelay will begin, and any post-shatter effects will occur

These options are more miscellaneous effects that have a notable impact, but don't fit in the previous categories:

  • displayGizmo : Default (True) : Determines if a gizmo should be displayed when the character is selected. The gizmo lists the name of the hediff and the current energy levels
  • gizmoTitle : A string that overrides the name attached to the gizmo
  • gizmoTip : A string that overrides the tooltip attached to the gizmo
  • blocksRangedWeapons : Default (False) : While True, the pawn becomes unable to launch projectiles
  • shieldBreakExplosion : A special item that contains explosion data that is used post-shatter. Anyone familiar with the other explosive comps in this framework will already be familiar with all the options available
    • radius : Default (0) : How wide the explosion should be. Mutually exclusive with statRadius

    • statRadius : The StatDef to use to determine the explosion size

    • damageDef : The DamageDef to use. This is required

    • damageAmount : The amount of damage to deal. Will try to use the DamageDef's default damage if not filled in

    • armorPenetration : How well it pierces through armor. Defaults to the DamageDef's if not filled in

    • damageFalloff : Default (False) : When true, the damage amount decreases the further they are from the center

    • extraGasType : Default (Smoke) : An extra gas type to create when the explosion occurs. The Options are Smoke, None, Tox, and Rot

    • chanceToStartFire : Default (0) : Chance to try to catch flammable things on fire

    • excludeRadius : Default (0) : Usually better to just have exclusions set to Self

    • exclusions : Default (Self) : Determines what gets excluded from the explosion damage. The options are None, Self, Allies, and NonHostiles

    • explosionSound : The sound the explosion makes

    • postExplosionThingWater : Creates thing over water when the explosion overlaps with water

    • screenShakeFactor : Default (0) : Shake that screen

    • postExplosionThing : The ThingDef that is generated after explosion

    • postExplosionThingChance : Default (0) : The chances of the thing being created, with 1 being 100%

    • postExplosionSpawnThingCount : Default (1) : Number of things created

    • preExplosionThing : The ThingDef that is generated before the explosion

    • preExplosionThingChance : Default (0) : The chances of the thing being created, with 1 being 100%

    • preExplosionSpawnThingCount : Default (1) : Number of things created

    • effecter : The EffecterDef created at the start of the explosion

    • effecterTicks : If given a value above 0, the map will maintain the effecter for a number of ticks equal to this value. If it isn't added, then it's handled by the EffecterDef itself


These options alter the visuals and audios associated with the shield. The shield should still be able to function without issue if these are not used:

  • onlyRenderWhenDrafted : Default (False) : Only displays the shield when the pawn is drafted or aggressive

  • absorbSound : SoundDef played when damage is absorbed

  • shatterSound : SoundDef played when the shield shatters

  • resetSound : SoundDef played when the shield resets

  • absorbFleck : FleckDef used when damage is absorbed

  • breakFleck : FleckDef used when the shield shatters

  • shieldBreakEffecter : EffecterDef used when the shield shatters

  • minDrawSize : Default (1.2) : The minimum draw size of the shield

  • maxDrawSize : Default (1.55) : The maximum draw size of the shield

  • scaleWithOwner : Default (True) : Attempts to scale the draw size up with the pawn's size

  • spinning : Default (True) : Creates the spinning-like effect that the vanilla shield uses

  • noDisplay : Default (False) : Prevents the shield bubble from appearing. This will cause graphicData to be ignored and prevent the vanilla shield appearance

  • graphicData : Graphical override of the vanilla shield appearance. Has all the same stuff as normal graphicData things

  • attachedEffecterDef : EffecterDef attached to the equipment while it's worn

  • attachedMoteDef : Mote to attach to the equipment while it's worn

  • attachedMoteOffset : An offset on the mote's location, with the center (0,0,0) being the wearer

  • attachedMoteScale : Default (1) : Changes the mote's size


This example creates a shield hediff that gradually increases its maximum energy over time, but when it's shattered it is lost forever and releases an emp burst around the pawn:

    <HediffDef>
        <defName>EverGrowingShield</defName>
        <label>ever-growing shield</label>
        <description>This shield will keep expanding its maximum capacity, but if anything breaks it then a new one must be obtained.</description>
        <everCurableByItem>false</everCurableByItem>
        <initialSeverity>1</initialSeverity>
        <stages />
        <hediffClass>HediffWithComps</hediffClass>
        <comps>
            <li Class="EBSGFramework.HediffCompProperties_Shield">
                <maxEnergy>2</maxEnergy>
                <multiplyMaxBySeverity>True</multiplyMaxBySeverity>
                <energyRechargeRate>0.1</energyRechargeRate>
                <energyPerDamageModifier>0.03</energyPerDamageModifier>

                <energyOnReset>1</energyOnReset>
                <removeOnBreak>True</removeOnBreak>

                <blocksMeleeDamage>false</blocksMeleeDamage>
                <blocksExplosions>true</blocksExplosions>
                <blocksRangedDamage>true</blocksRangedDamage>

                <shieldBreakExplosion>
                    <damageDef>EMP</damageDef>
                    <radius>3.9</radius>
                </shieldBreakExplosion>

                <absorbFleck>ExplosionFlash</absorbFleck>
                <breakFleck>ExplosionFlash</breakFleck>
                <shieldBreakEffecter>Shield_Break</shieldBreakEffecter>

                <absorbSound>EnergyShield_AbsorbDamage</absorbSound>
                <resetSound>EnergyShield_Reset</resetSound>

                <displayGizmo>true</displayGizmo>
                <gizmoTitle>Growing Shield</gizmoTitle>
                <gizmoTip>A powerful shield that increases its maximum capacity over time, but will be gone forever if shattered.</gizmoTip>

                <onlyRenderWhenDrafted>true</onlyRenderWhenDrafted>
                <minDrawSize>1.5</minDrawSize>
                <maxDrawSize>1.8</maxDrawSize>
                <scaleWithOwner>true</scaleWithOwner>
                <spinning>false</spinning>
            </li>
            <li Class="HediffCompProperties_SeverityPerDay">
                <severityPerDay>0.1</severityPerDay>
            </li>
        </comps>
    </HediffDef>
⚠️ **GitHub.com Fallback** ⚠️