Angle Based Shotguns - SmArtKar/AthenaFramework GitHub Wiki
Athena allows modders to make angle-based shotguns that deal AOE damage instead of targeting a single target. Shooting such a shotgun creates a slight lag spike but in most cases it should unnoticeable as long as pellet amount is kept at sane levels.
To turn your shotgun angular you'll need to add AthenaFramework.AngularShotgunExtension
to your gun's mod extensions
Angle-based shotguns no longer have a downedHitChance
field and now use vanilla calculations
public class AngularShotgunExtension : DefModExtension
{
// Amount of pellets that your shotgun fires
public int pelletCount;
// Angle betweet fired pellets
public float pelletAngle;
// Randomly adjusts every pellet's fire angle up to this value
public float pelletRandomSpread = 0f;
}
After that you'll need to change Verb_Shoot
to AthenaFramework.Verb_ShootAngularShotgun
and it should be done
Here's an example of a modified vanilla pump shotgun that uses angle-based shotgun system and shoots 13 pellets with 3 degree spread between each pellet
<ThingDef ParentName="BaseHumanMakeableGun">
<defName>Gun_PumpShotgun</defName>
<label>pump shotgun</label>
<description>An ancient design of shotgun that emits a tight-packed spray of pellets. Deadly, but short range.</description>
...
<statBases>
<WorkToMake>12000</WorkToMake>
<Mass>3.4</Mass>
<AccuracyTouch>0.80</AccuracyTouch>
<AccuracyShort>0.87</AccuracyShort>
<AccuracyMedium>0.77</AccuracyMedium>
<AccuracyLong>0.64</AccuracyLong>
<RangedWeapon_Cooldown>1.25</RangedWeapon_Cooldown>
</statBases>
...
<verbs>
<li>
<verbClass>AthenaFramework.Verb_ShootAngularShotgun</verbClass>
<hasStandardCommand>true</hasStandardCommand>
<defaultProjectile>Bullet_Shotgun</defaultProjectile>
<warmupTime>0.9</warmupTime>
<range>15.9</range>
<soundCast>Shot_Shotgun</soundCast>
<soundCastTail>GunTail_Heavy</soundCastTail>
<muzzleFlashScale>9</muzzleFlashScale>
</li>
</verbs>
...
<modExtensions>
<li Class="AthenaFramework.AngularShotgunExtension">
<pelletCount>13</pelletCount>
<pelletAngle>3</pelletAngle>
</li>
</modExtensions>
</ThingDef>
In case you want to have shotgun-style abilities, you could use CompProperties_AbilityLaunchShotgunProjectiles
, just add it like any other ability comp and you're good to go
public class CompProperties_AbilityLaunchShotgunProjectiles : CompProperties_AbilityEffect
{
// Projectile that you want to fire
public ThingDef projectileDef;
// Amount of pellets that your ability fires
public int pelletCount;
// Angle betweet fired pellets
public float pelletAngle;
// Randomly adjusts every pellet's fire angle up to this value
public float pelletRandomSpread = 0f;
}