Allows modifying attachments attributes

Supported Games

Better Attachments overrides default attachment attributes and allows to customize penalties/bonuses for each attachment. Additionally, you can define "failure" conditions for attachments that are damaged.

Configuration

Configuration elements are derived from the built-in Rust attachment attributes, and stored in a map based on the attachment short prefab name:
flashlight.entity, holosight.entity, lasersight.entity, muzzleboost.entity, muzzlebrake.entity, silencer.entity, smallscope.entity

The attributes themselves can be created for any attachment, but I can't guarantee certain attributes will be taken into account for any particular attachment... Additionally, some monkeying around with values might be necessary to determine what effect each attribute has for various attachments. (If you have any corrections please let me know)

  • repeatDelay: Weapon fire rate delay (time between shots)
  • projectileVelocity: Projectile velocity
  • projectileDamage: Projectile damage
  • projectileDistance: Max projectile distance
  • aimsway: Amount of weapon sway (vertical/horizontal movement)
  • aimswaySpeed: Speed of weapon sway
  • recoil: Recoil amount
  • sightAimCone: Projectile spread while aiming down sights
  • hipAimCone: Projectile spread while shooting from the hip
  • conditionLoss: Wear damage from use (1.0 = 100%, 0.0 = 0%, etc)

Additionally, each attribute except conditionLoss can contain 3 fields:

  • enabled: Flag indicating whether the configuration attribute will override the Rust defaults
  • scalar: Represents a percentage of attribute to apply - 1.0 = 100%, 0.0 = 0%, etc.
  • offset: Additional modifier added after scalar is applied

I believe a simplified formula for how these values are applied is: ([baseAttribute] * scalar) offset, where [baseAttribute] is derived from the weapon and ammo type. However, I'm not yet familiar on how scalar and offset are applied regarding aimsway, aimswaySpeed, recoil, sightAimCone, and hipAimCone. I will update this description as I figure these out.

The default configuration has a simple setup for silencers, which eliminates damage and bullet speed penalties (scalar set to 1.0), and also prevents them from taking wear damage (conditionLoss set to 0.0).

Creating Catastrophic Failures

For an extra challenge, you can now add a failure behavior to attachments that wear beyond a certain point - a few examples are created in the default configuration, so it is recommended you delete the old json and let a new one be generated to see this in effect.

  "failures": { // new "failures" section
    "muzzleboost.entity": { // attachment name (short prefab name)
      "enabled": true, // enabled/disabled flag
      "start": 0.15, // starting point for failure (in % of max attachment HP)
      "target": 0.02, // guaranteed failure point (in % of max attachment HP)
      "weaponDamage": 0.2, // damage to weapon on failure (% of max weapon HP)
      "playerDamage": 0.2 // damage to player on failure (% of max player HP)
    }
...

This behavior allows a "failure" to occur if your attachments reach a certain point of wear. The chance of failure is calculated using a logarithmic scale from the start HP percentage, to the target HP percentage, where there is a 0% chance of failure above start HP, and a 100% chance of failure at/below target HP.

In the event that a failure occurs on firing the weapon, the weapon will take damage and/or the player will take damage as a percentage of their max possible HP. Additionally, effects will be run on the weapon (currently sparks metal impact noises) to indicate there was a failure.

Because the chance of failure is logarithmic, letting your attachment wear closer to the target HP greatly increases your chances of failure. For example, using the 15% and 2% chances in the configuration snippet above:

% HP    % Chance of Failure
0        100.00
1        100.00
2        100.00
3         79.88
4         65.60
5         54.52
6         45.48
7         37.83
8         31.20
9         25.35
10        20.12
11        15.39
12        11.07
13         7.10
14         3.42
15         0.00

Default Configuration

  • Flashlight: 5% better aim accuracy, slightly reduced recoil, slightly reduced aim sway speed
  • Holosight: 10% better aim accuracy
  • Lasersight: 90% aim sway (Rust is 80%), slightly reduced recoil (Rust is 85%), 25% smaller firing cone (Rust is 75%, which is shenanigans)
  • Muzzle Boost: 20% better firing rate (Rust is 10%), 5% bullet velocity penalty (Rust is 10%), no damage penalty (Rust is 10%), 5% better recoil, (Rust is 2%)
  • Muzzle Brake: 5% more aim sway, 5% slower aim sway, 60% less recoil (Rust is 50%), 5% smaller sight-aim cone (Rust widens a lot), normal hip-fire cone (Rust widens a lot)
  • Silencer: 5% more bullet velocity (Rust is 25% less), normal bullet damage (Rust is 25% less), 5% less aim sway (Rust is 20%), 25% less recoil (Rust is 20%), 5% smaller sight-aim cone (Rust is 30% smaller), 5% smaller hip-fire cone (Rust is 40% smaller)
  • Scope: 5% slower aim sway, 5% less recoil (Rust is 20%), 50% smaller sight-aim cone (Rust is 30%)

Default Failures

  • Muzzle Boost: start at 15%, guaranteed failure at 2%, 20% weapon/player damage
  • Muzzle Brake: start at 10%, guaranteed failure at 1%, 5% weapon damage, 10% player damage
  • Silencer: starts at 10%, guaranteed failure at 1%, 10% weapon damage, 15% player damage

TODO

  • Remove unnecessary ResourceId
  • Change plugin title to be title case
  • Potentially reduce string concatenation in AttachmentModifier.ToString()

Credit

ignignokt84, the original author of this plugin

No license