Fractal Softworks Forum

Please login or register.

Login with username, password and session length

Author Topic: Disabled Weapons bug  (Read 685 times)

Timid

  • Admiral
  • *****
  • Posts: 640
  • Personal Text
    • View Profile
Disabled Weapons bug
« on: October 07, 2022, 03:46:05 AM »

A user has reported out that sometimes this weapon will refuse to fire (despite having ammo to reload) after being disabled mid-fire. The same user said it was somewhat fixable when it was re-disabled to be repaired again. Upon further inspection and some notice, I thought to myself the bugged weapon seemed to be missing "crystals" or its missile. I tried changing the weapon type to missile, same issue. I removed the render hint of RENDER_BARREL_BELOW and RENDER_LOADED_MISSILES to no avail. It would just stay forever in that state.





Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 24114
    • View Profile
Re: Disabled Weapons bug
« Reply #1 on: October 07, 2022, 07:05:04 AM »

Hmm, the "not rendering missiles despite having ammo" thing might happen if someone called weapon.disable(true) to "permanently" disable the weapon. It might then be re-enabled by calling weapon.repair().

The missiles might also not fade in if some code keeps resetting the weapon cooldown for a large value, for example.

Hmm. I just tried disabling a Breach mid-burst and am not seeing this problem. I strongly suspect that it's something mod-related - I mean, it's possible it's a vanilla issue, but it seems really likely that if it was, it would have come up by now - a weapon getting disabled mid-burst is pretty common, especially for some of the longer-burst weapons like the Squall and the Locust. And the "rendering missiles" thing is purely decorative, iirc it doesn't have any bearing on whether the weapon can fire or not.
Logged

Timid

  • Admiral
  • *****
  • Posts: 640
  • Personal Text
    • View Profile
Re: Disabled Weapons bug
« Reply #2 on: October 07, 2022, 07:45:17 PM »

Upon further tests and anecdotes from other modders, it seems to be related to any ship with stats of RoF increase/decreases and float imprecision (either from a ship system or a time mult passive itself). It seems to keep the weapon "firing" when it's disabled. I don't know if this is due to a float overflow to the negatives or if a float is left to be 0.00001f and never fire cuz it's technically still firing. I'll do some more testing to verify if this is the case.

Timid

  • Admiral
  • *****
  • Posts: 640
  • Personal Text
    • View Profile
Re: Disabled Weapons bug
« Reply #3 on: October 16, 2022, 09:36:30 PM »

So after more testing and searching with further users who were having issues on different weapons (storm needler and ion pulsers), the bug seem to be created when the weapon is disabled... and ends up

Code
WeaponAPI.getChargeLevel() returns NaN
WeaponAPI.getCooldownRemaining() returns NaN
WeaponAPI.IsFiring() returns true
setCooldownRemaining() to 0.1 will prevent the jamming but this feels impractical to apply to every weapon on an everyframescript to fix. I can't really explain why they would return NaN...

RoF increase/decreases seems to no longer matter when reproducing this bug.

RustyCabbage

  • Captain
  • ****
  • Posts: 347
    • View Profile
Re: Disabled Weapons bug
« Reply #4 on: October 17, 2022, 09:10:23 AM »

Explored this problem some more, a sufficient set of conditions are (from weapon_data.csv):
  • Chargeup > 0
  • Chargedown = 0
  • Burst size > 1
  • Burst delay > 0
Then I think if the weapon is disabled while firing it can break and no longer be usable even once it is repaired

Example cases where this occurs (chargeup/chargedown/burst size/burst delay):
Kadur Remnant's Volley Driver (0.5/0/8/0.05) and Crystal Resonance Splintergun (0.5/0/7/0.12)
Upgraded Rotary Weapons' edited versions of Storm Needler (0.2/0/9999/0.1) and Ion Pulser (0.1/0/3/0.1)

I don't see any cases where this is an issue in Vanilla, but I reproduced the issue by editing Plasma Cannon from 0.33/1.01/3/0.33 to 0.33/0/3/0.33.

By the presence of NaN issues and increasing the chargedown for the affected weapons to 0.0001 fixing the issue, the chargedown of 0 is definitely a necessary condition, although I was not able to reproduce it with IR Pulse Laser (0.333333/0/x/x) nor Paladin PD Laser (0/0/0.2/0.1).

Anyways, hopefully this is enough to diagnose what the issue is and the workaround for any potential mods.

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 24114
    • View Profile
Re: Disabled Weapons bug
« Reply #5 on: October 17, 2022, 10:57:33 AM »

Thank you for the added info! Hmm. I made the change to Plasma Cannon (reduced chargedown to 0), fired it, then disabled all the ship's weapons with some code running w.disable(). The Plasma Cannon came back online normally.

Any thoughts on what might be happening differently here?
Logged

RustyCabbage

  • Captain
  • ****
  • Posts: 347
    • View Profile
Re: Disabled Weapons bug
« Reply #6 on: October 17, 2022, 12:07:13 PM »

Ooh, um I was holding down the fire button, so I assume it has to be mid firing sequence/animation. Sorry I forgot to clarify!

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 24114
    • View Profile
Re: Disabled Weapons bug
« Reply #7 on: October 17, 2022, 12:19:29 PM »

Yeah, that's what I'm doing too! The disabling is somewhere mid-burst. Just tried it again, same (non) result.
Logged

RustyCabbage

  • Captain
  • ****
  • Posts: 347
    • View Profile
Re: Disabled Weapons bug
« Reply #8 on: October 17, 2022, 01:06:26 PM »

Ah okay, follow up: I reproduced it easily against the sim Conquest as seen below:


But I could not reproduce it against an Onslaught. I then reproduced the bug fighting against the sim Paragon and sim Aurora, so I think that it's related to taking EMP damage? Conquest has Mjolnirs, Squalls, Ion Pulser; Paragon has Tachyon Lance; Aurora has Ion Cannons and an Ion Pulser; while the Onslaught has no EMP damage and I didn't get issues from that.

Beyond that it's been very easily reproduced on my end. Try against the sim Conquest perhaps?

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 24114
    • View Profile
Re: Disabled Weapons bug
« Reply #9 on: October 17, 2022, 02:29:25 PM »

Ah, I wasn't trying it vs anything, just disabling it with code. I'll give that a go, thank you.
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 24114
    • View Profile
Re: Disabled Weapons bug
« Reply #10 on: October 17, 2022, 02:35:17 PM »

Hmm, still not happening at all over here! Or rather - I didn't run the console code to check, but the plasma cannons always come back online and are able to fire. Possible that I'd fixed this without realizing, I suppose?
Logged

RustyCabbage

  • Captain
  • ****
  • Posts: 347
    • View Profile
Re: Disabled Weapons bug
« Reply #11 on: October 17, 2022, 02:52:49 PM »

Possibly! I'll check again early next release I suppose. At any rate the workaround is available for the time being :)

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 24114
    • View Profile
Re: Disabled Weapons bug
« Reply #12 on: October 17, 2022, 03:02:09 PM »

Yeah, that's good to know :)
Logged