Skip to content

Shrapnel_projectiles

juanosarg edited this page Jun 4, 2026 · 1 revision

<- Back

Projectile_Shrapnel allows you to make projectiles that subdivide into other projectiles when impacting

You will need a projectile with this class, as well as projectiles with the Projectile_ShrapnelPiece class.

How do I use this code?

Assign the Projectile_Shrapnel class to any projectile's def:

	<thingClass>VEF.Weapons.Projectile_Shrapnel</thingClass>

Assign the Projectile_ShrapnelPiece class to any projectile's def that you want to act as the shrapnel pieces:

	<thingClass>VEF.Weapons.Projectile_Shrapnel</thingClass>

Finally, you will need new properties on the tag of the first item to handle the shrapnel creation, using ProjectileProperties_Shrapnel:

public class ProjectileProperties_Shrapnel : ProjectileProperties
{
    public float angleVariance;
    public int shrapnelCount;
    public ThingDef shrapnelProjectile;
    public float shrapnelRange;
}

An example, shrapnel shells in Vanilla Factions Expanded - Deserters:

 <ThingDef ParentName="BaseBullet">
    <defName>VFED_Bullet_Shell_Shrapnel</defName>
    <label>shrapnel shell</label>
    <graphicData>
      <texPath>Projectiles/ShellShrapnel</texPath>
      <graphicClass>Graphic_Single</graphicClass>
      <shaderType>TransparentPostLight</shaderType>
    </graphicData>
    <thingClass>VEF.Weapons.Projectile_Shrapnel</thingClass>
    <projectile Class="VEF.Weapons.ProjectileProperties_Shrapnel">
      <damageDef>Bomb</damageDef>
      <speed>41</speed>
      <explosionRadius>2.9</explosionRadius>
      <flyOverhead>true</flyOverhead>
      <soundHitThickRoof>Artillery_HitThickRoof</soundHitThickRoof>
      <soundExplode>MortarBomb_Explode</soundExplode>
      <soundImpactAnticipate>MortarRound_PreImpact</soundImpactAnticipate>
      <soundAmbient>MortarRound_Ambient</soundAmbient>
      <shrapnelProjectile>VFED_Bullet_Shrapnel</shrapnelProjectile>
      <shrapnelCount>24</shrapnelCount>
      <shrapnelRange>16.5</shrapnelRange>
      <angleVariance>25</angleVariance>
    </projectile>
  </ThingDef>

  <ThingDef ParentName="BaseBullet">
    <defName>VFED_Bullet_Shrapnel</defName>
    <label>shrapnel</label>
    <thingClass>VEF.Weapons.Projectile_ShrapnelPiece</thingClass>
    <graphicData>
      <texPath>Things/Projectile/Bullet_Small</texPath>
      <graphicClass>Graphic_Single</graphicClass>
    </graphicData>
    <projectile>
      <damageDef>Bullet</damageDef>
      <damageAmountBase>12</damageAmountBase>
      <speed>55</speed>
    </projectile>
  </ThingDef>

Clone this wiki locally