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 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)
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).
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:
Configuration
The settings and options can be configured in the BetterAttachments file under the config directory. The use of an editor and validator is recommended to avoid formatting issues and syntax errors.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)
- 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
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.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:
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()