Modding Discussion Fixing inconsistent trap damage depending on max health

Discussion in 'Starbound Modding' started by rl.starbound, May 27, 2020.

  1. rl.starbound

    rl.starbound Phantasmal Quasar

    AKA: The Flame Trap Bug

    Background

    Balancing combat mechanics is difficult in any game, and Starbound's combat engine is not perfect. In some scenarios that might occur during a normal playthrough, the character may be hit with a flurry of high-damage attacks in a short period of time, which would overwhelm and kill even the best-prepared player. Such occurrences, while within the rules of the combat engine, would be very frustrating to players. Seemingly designed to mitigate this problem, a rule in the combat engine was introduced, such that if the character is hit with an attack doing more than 10% max damage (hitInvulnerabilityThreshold)[1], then the character is granted one second of invulnerability (hitInvulnerabilityTime). This prevents a high damage, high rate-of-fire attack from effectively one-shotting a character, by giving the player a moment to react. As it turns out, this rule is problematic, and does not solve the underlying problem (high damage, high rate-of-fire attacks cause frustrating and unbalanced combat) but rather hides it in most circumstances.

    The Problem

    Unfortunately, there are still circumstances where this rule fails, and an unsuspecting player's character suffers catastrophic, often fatal damage in less than a second.

    Flame traps showcase this bug most spectacularly. In the case of flame traps, the trap emits approximately 10 projectiles of fire per second, and each projectile does 20 defense-ignoring fire damage. Theoretically, this would do 200dps to the character. In some cases, such as the Arena of Fire, in which it's likely that the character may touch 2 flame traps simultaneously, they could suffer up to 400dps. This would kill virtually any character without any chance to escape, which is bad for playability.

    However, thanks to hitInvulnerabilityThreshold, flame traps are normally limited to approximately 20dps. This works if the character's max health is less than 200. If the character's max health is 200 or greater, then they will suffer the full theoretical damage of 200dps per trap. Likewise, if the character's max health is above 150 and they have fire resistance, for example by using the Fire Resist augment or the Burn Spray, they will suffer the adjusted maximum of 150dps (3/4 damage * 20 damage per projectile * 10 projectiles per second) per trap. The irony of getting killed by fire because you increased your fire resistance is lost on players seething with justifiable rage after experiencing this.

    The Solution

    When thinking about this bug, it becomes clear that hitInvulnerabilityThreshold hides the problem of the unbalanced combat mechanics of flame traps, rather than solving it. Assuming that the game designers intended flame traps to generate approximately 20dps of fire damage, the appropriate solution seems to be to reset the fire projectiles to do 2 damage per projectile. At this low power, no one fire projectile will cross hitInvulnerabilityThreshold, which means the character will take damage from all 10 projectiles per second, for an overall damage of approximately 20dps. This 20dps will hold regardless of how much health the character has. If the character uses fire resistance, then the flame trap will do 15dps, exactly as the specs say it should.

    I am working on a small bugfix mod that alters flame traps and a few other attacks and traps as specified above. Unfortunately there are many more side effects of hitInvulnerabilityThreshold that I can't easily fix. However, flame traps are the most extreme examples of this bug that I've found, and they are fixed with my mod. I'll link it into this discussion once I'm done play testing it.

    Notes

    [1] The Lua code also specifically avoids triggering invulnerability from damageType="Knockback" attacks. (Note, an attack can cause knockback, even if its damageType is not "Knockback".) However, I am not able to find any damage-causing attacks with that specific damageType. The only such attacks I can find are just shield-blocks, which technically count as "attacks" but do no damage.
     
    Last edited: Jun 1, 2020

Share This Page