Modding Discussion Investigating Apparent Starbound Firearm Rate of Fire Limits

Discussion in 'Starbound Modding' started by rl.starbound, Dec 22, 2018.

  1. rl.starbound

    rl.starbound Phantasmal Quasar

    tl;dr Starbound appears to have a rate limit on automatic weapons fire of approximately 6.7 shots per second. Assault rifles and machine pistols whose stats exceed this limit are still bound by it, and therefore fail to deliver their full DPS.

    While testing a weapons mod, I noticed that my assault rifle appeared to use substantially less energy that I had specced for it. After a bit of debugging, I removed my mod and tested with the vanilla Iron Assault Rifle and Durasteel Assault Rifle to make sure that I hadn't made a mistake in my mod. I discovered that they too suffered from this bug. Like my custom weapon, both of these rifles advertise a fire rate 9.1 rounds per second. When firing single shots, these weapons used exactly as much energy as expected. However, when fired in full-auto mode, they used less energy than expected. Counting rounds fired is not easy, but after a number of experiments I came to the conclusion that the weapons were not reaching their full rate of fire. Further testing revealed that this also meant that the weapons were not reaching their rated DPS when fired automatically.

    Background

    Starbound firearms have three statistics governing their primary fire: baseDps, energyUsage, and fireTime. (Some assault rifles also have a "burst" fireType, but I will be focusing exclusively on "auto" weapons here.) The baseDps and energyUsage stats are both per-second stats. The fireTime stat gives the fraction of a second that it takes to fire a single shot. Actual damage and energy consumption are based on single shots, not per-second stats. When you fire a single round from an automatic weapon, the following equation determines how much damage that round can do (simplified to ignore the effects of armor bonuses, buffs, de-buffs, etc.):

    damagePerShot = baseDps * fireTime * levelMultiplier​

    The levelMultiplier is a multiplier given by the level of the weapon:

    { level1: 1.0,
    level2: 1.5,
    level3: 2.0,
    level4: 2.5,
    level5: 3.0,
    level6: 3.5 }​

    For example, the Iron Assault Rifle has `baseDps = 10.5`, `energyUsage = 31.5`, `fireTime = 0.11`, and level 1, giving it a single-shot damage of:

    damagePerShot = 10.5 * 0.11 * 1.0 = 1.155​

    which is rounded to 1.2 on the item display. Its single-shot energy use is given by:

    energyPerShot = 31.5 * 0.11 = 3.465​

    Methodology (Energy Drain)

    I performed all of my experiments on a completely empty space station of mine, Monitoring my machine's CPU usage and display frame rate indicated that the problem probably isn't caused by machine limitations. During full-automatic fire, my CPU utilization only increased by a few percent, and I saw no drop in frame rate that usually accompanies a stressed system.

    I first noticed the issue that my rifle seemed to be more energy-efficient than expected. I use Accelerator armor, so my energy pool is 250. Given this, I can use the above calculations to estimate how long I should be able to fire in full-auto mode before my energy is drained. I click down on the primary mouse button to begin firing while simultaneously starting a stopwatch. I stop the stopwatch as soon as my energy is depleted. Some preliminary experiments indicate that the margin of error for starting and stopping the stopwatch is plus or minus 0.25-0.4 seconds, so I'll consider my experiments a success if they fall within 0.4 seconds of the expected value.

    Experimental Results (Energy Drain)

    As a control, I used the Plasma Assault Rifle (a burst-type assault rifle), which has `energyUsage = 30.0` and a `fireTime = 0.3` and an expected time to energy depletion of 8.33 seconds. My results with 5 trials with the Plasma Assault Rifle averaged 8.23 seconds. This is well within the margin of error of my stopwatch.

    Using the Iron Assault Rifle as an example, with my energy at 250 and its rated energy use at 31.5 per second, I can expect full automatic fire to deplete my energy in 7.93 seconds. My actual results over 5 trials, however, averaged about 9.77 seconds. This energy drain rate is approximately 23.2% lower than expected.

    I repeated my test using the Durasteel Assault Rifle, which has the same energyUsage and fireTime stats as the Iron Assault Rifle. The average for the Durasteel Assault Rifle was 9.78 seconds. Like the iron Assault Rifle, the Durasteel Assault Rifle's energy drain rate was approximately 23.3% lower than expected.

    Clearly the energy usage rate for the two rifles with high rates of fire seemed to be less than advertised, while the energy usage rate for the slower plasma rifle was almost exactly as expected. Would this same pattern hold true for machine pistols? I used the Titanium Machine Pistol, which has `energyUsage = 21` and `fireTime = 0.11`. In this experiment, I was dual-wielding machine pistols, so my energy usage was doubled. Given the Titanium Machine Pistol's stats, I would expect to be able to fire two of them simultaneously for 5.95 seconds. My actual results over 5 trials averaged 7.42 seconds. This energy drain was approximately 24.7% lower than expected.

    Methodology (Damage Per Second)

    My theory for the power drain discrepancy was that the advertised rate of fire was greater than the actual rate of fire. Given that damage delivered is based on individual shots fired, rather than DPS, I then wondered whether this was causing the weapons to deliver less damage than their DPS ratings would indicate.

    Measuring damage delivered in Starbound over time is surprisingly difficult. My first thought was to use Punchy, however Punchy's healing ability makes it impossible to gauge accumulated damage. I settled on abusing my poor hover bike. The hover bike has 1000 health and 50% damage resistance (which effectively gives it 2000 health). By activating admin mode so that energy use is no longer a factor, I can measure how long it takes for sustained fire to destroy my bike. This will allow me to measure how much damage each weapon actually does per second.

    Using the stats given in the background section, we can calculate expected damage per second for each weapon. To reduce the time taken to destroy the hover bike, I will use the Manipulator armor set, which gives a 360% damage bonus. (I don't use the Accelerator armor for this test because, due to using admin mode, I don't care about energy.) The equation for damage per second for each weapon is:

    damagePerSecond = baseDps * levelMultiplier * armorMultiplier​

    The equation for the expected time to destroy the hover bike is then:

    expectedTime = 2000 / damagePerSecond​

    Experimental Results (Damage Per Second)

    My first experiment was using the Plasma Assault Rifle, as a control. The Plasma Assault Rifle has `baseDps = 10.5` and is level 6 so:

    damagePerSecond = 10.5 * 3.5 * 4.6 = 169.05 DPS
    expectedTime = 2000 / 169.05 = 11.83 seconds​

    Over 5 trials, the Plasma Assault Rifle averaged destruction of the hover bike in 12.02 seconds, within the margin of error of my stopwatch.

    Next I used the Durasteel Assault Rifle. It too has `baseDps = 10.5` but its level is 4, so:

    damagePerSecond = 10.5 * 2.5 * 4.6 = 120.75 DPS
    expectedTime = 2000 / 120.75 = 16.56 seconds​

    Over 5 trials, the Durasteel Assault Rifle averaged destruction of the hover bike in 20.54 seconds, giving it an actual DPS rating of approximately 97.37, which translates to an actual baseDps of approximately 8.47. This is approximately 80.67% of its advertised DPS rating.

    I skipped the Iron Assault Rifle because I didn't want to wait on a mere level 1 weapon. Instead, I skipped ahead to the Titanium Machine Pistol. Each of these has `baseDps = 7` and a level of 3. I double the expected damagePerSecond because I am dual-wielding them, so:

    damagePerSecond = 7.0 * 2.0 * 4.6 = 64.4 DPS
    expectedTime = 2000 / (2 * 64.4) = 15.53 seconds​

    Over 5 trials, the Titanium Machine Pistols averaged destruction of the hover bike in 19.19 seconds, giving it an actual DPS rating of approximately 52.11, which translates to an actual baseDps of approximately 5.66. This is approximately 80.86% of its advertised DPS rating.

    Conclusion

    I made a quick mod which patched the Iron Assault Rifle, Durasteel Assault Rifle, and Titanium Machine Pistol to have a lower rate of fire. Based on the numbers above, I guessed that `fireTime = 0.14` would be best. When I re-ran the above tests, while an improvement was noticeable, the weapons still were not meeting their energy drain and DPS goals. I set `fireTime = 0.15` and tried again. With this fire rate, I was able to fall within the margin of error for both energy consumption and DPS for all of the tested weapons. I've expanded my mod to update the minimum `fireTime = 0.15` for all firearms in the game, including procedurally-generated firearms. While capping shots per second to about 6.7 isn't as whiz-bang cool as 9.1, it is nice to have weapons that actually deliver on their advertised DPS.

    https://community.playstarbound.com/resources/auto-fire-rate-limit-fix.5622/
     
    SpazDiesFirst360.0 likes this.
  2. DeadSomething

    DeadSomething Subatomic Cosmonaut

    how about removing the cap instead?
     
  3. Nexus Of Chaos

    Nexus Of Chaos Parsec Taste Tester

    that actually may not be possible. I hav seen that some things r hard-coded and this may be 1
     
  4. DeadSomething

    DeadSomething Subatomic Cosmonaut

    hardcoded = the devs could change it, if they were to ever listen to the gamers.
     

Share This Page