Phobos icon indicating copy to clipboard operation
Phobos copied to clipboard

Delayed fire weapons

Open Starkku opened this issue 1 year ago • 15 comments

New implementation of the same idea as #768

Delayed firing

  • It is possible to have any weapon fire with a delay by setting DelayedFire.Duration on a WeaponType - it supports a single integer or two comma-separated ones for a random range to pick value from.
    • If DelayedFire.SkipInTransport is set to true and firer is in a transport, no delay is applied to firing.
    • DelayedFire.Animation can be used to define animation to create when the delay timer starts. DelayedFire.OpenToppedAnimation is used instead if set if the firer is in a transport.
      • If DelayedFire.AnimIsAttached is set to true, the animation is attached to the firing TechnoType. If DelayedFire.RemoveAnimOnNoDelay is also set to true the animation is removed when the duration expires or firing is interrupted regardless of its remaining lifetime.
      • DelayedFire.AnimOffset can be used to override the weapon's firing coordinates / FLH for the animation's position.
      • DelayedFire.AnimOnTurret determines whether or not the animation's position is calculated relative to firer's body or turret (only if it has one).
      • If DelayedFire.CenterAnimOnFirer is set the animation is created at the firer's center rather than at the firing coordinates.
    • If the weapon was fired by InfantryType and DelayedFire.PauseFiringSequence is set to true, the infantry's firing sequence animation is paused when it hits the firing frame defined by FireUp/Prone or SecondaryFire/Prone in its artmd.ini entry until the delay timer has expired.
    • If the weapon has Burst > 1 and DelayedFire.OnlyOnInitialBurst set to true, the delay occurs only before the initial burst shot. Note that if using Ares, Burst index does not reset if firing is interrupted or the firer loses target, meaning it will be able to resume firing without waiting for the delay.

In rulesmd.ini:

[SOMEWEAPON]                           ; WeaponType
DelayedFire.Duration=                  ; integer - single or comma-sep. range (game frames)
DelayedFire.SkipInTransport=false      ; boolean
DelayedFire.Animation=                 ; Animation
DelayedFire.OpenToppedAnimation=       ; Animation
DelayedFire.AnimIsAttached=true        ; boolean
DelayedFire.AnimOffset=                ; integer - Forward,Lateral,Height
DelayedFire.AnimOnTurret=true          ; boolean
DelayedFire.CenterAnimOnFirer=false    ; boolean
DelayedFire.RemoveAnimOnNoDelay=false  ; boolean
DelayedFire.PauseFiringSequence=false  ; boolean
DelayedFire.OnlyOnInitialBurst=false   ; boolean

NOTE: AircraftTypes, due to their different attack patterns, will not wait for the delay to expire before attempting to fire and will instead continue without firing if the delay is too long.

Starkku avatar Aug 06 '24 20:08 Starkku

Nightly build for this pull request:

This comment is automatic and is meant to allow guests to get latest nightly builds for this pull request without registering. It is updated on every successful build.

github-actions[bot] avatar Aug 06 '24 20:08 github-actions[bot]

DelayedFire.PauseFiringSequence=yes breaks the weapon if used with Burst.FireWithinSequence=yes, as the infantry will be unable to fire. Seems to work fine otherwise, for infantry and units. Does not work most of the time for AircraftTypes, and even if it works, the animation doesn't play.

And i think this could use an option to play the charge animation only before the first shot if the weapon has Burst= above 1.

mevitar avatar Aug 09 '24 22:08 mevitar

Updated with fixes and some new features.

  • DelayedFire.Duration now supports two-comma separated values for random range.
  • DelayedFire.AnimOffset can be used to override FLH position for the animation.
  • DelayedFire.RemoveAnimOnNoDelay if set to true makes the animation disapper if delay is inactive (f.ex unit loses target mid-delay)
  • DelayedFire.OnlyOnInitialBurst if set to true makes it so that only first burst shot has delay. Do mind that with Ares burst index does not reset if unit stops firing midway through.

The interaction between DelayedFire.PauseFiringSequence and Burst.FireWithinSequence should now also be fixed.

Starkku avatar Sep 13 '24 19:09 Starkku

Still doesn't work for AircraftTypes, so it should be noted in the documentation. Other than that, everything seems to be working fine now. Didn't test in multiplayer.

mevitar avatar Sep 17 '24 08:09 mevitar

Rebased, improved the handling of animation offsets. This is ready for another testing and review pass if needed.

Starkku avatar Mar 28 '25 09:03 Starkku

This build crashes when building one specific unit, but that unit works fine with other builds so i don't know what's the problem. Here's the except file. except.zip

mevitar avatar May 13 '25 19:05 mevitar

This build crashes when building one specific unit, but that unit works fine with other builds so i don't know what's the problem.

Putting vehicle inside an open-topped vehicle crashes the game. This crash in particular happens for a VehicleType that has another VehicleType inside trough InitialPayload. Infantry does not cause this crash, only vehicles.

mevitar avatar May 26 '25 22:05 mevitar

Putting vehicle inside an open-topped vehicle crashes the game. This crash in particular happens for a VehicleType that has another VehicleType inside trough InitialPayload. Infantry does not cause this crash, only vehicles.

I can't reproduce this crash. There might be some parameters in play that I am missing.

Starkku avatar May 27 '25 07:05 Starkku

Try building it from a naval yard. Or preplace an open topped naval unit with a vehicle inside, that also crashes for me.

mevitar avatar May 27 '25 12:05 mevitar

Try building it from a naval yard. Or preplace an open topped naval unit with a vehicle inside, that also crashes for me.

Still doesn't crash. Any chance you could perhaps provide full crash log(s), or atleast both except+debug?

Starkku avatar May 27 '25 17:05 Starkku

I guess it might be related to me using the ground naval yard "hack", although i'm not sure why would it crash only with this build. Here's the crash including crashdump. https://drive.google.com/file/d/17xUR_p85On6gL7Jl1lpEZhmj36so2gGS/

mevitar avatar May 27 '25 18:05 mevitar

Any chance this could get reviewed, as well as maybe an another testing pass or so given that I had to rebase and refactor this to fit in with the infantry gattling / SHP unit FireUp functionality hopefully not breaking anything - something I do not want to do again.

As for that crash, it crashes trying to draw veterancy insignia. I don't know why it would be constrained to this build only and I do not really have a way to figure that out either.

Starkku avatar Jun 10 '25 17:06 Starkku

looking good

NetsuNegi avatar Jun 11 '25 12:06 NetsuNegi

if primary fire during secondary's charging, it'll stop the charging process. Guess this is an intended behavior

otherwise good in testing

Coronia avatar Jun 23 '25 11:06 Coronia

Per the current design charging is intentionally interrupted if firing is stopped or weapon changes. Persisting charging would require changing things and unsure how useful it would be (could quickly get confusing).

Starkku avatar Jun 23 '25 11:06 Starkku

now that this one is tested and reviewed, gonna merge it first since there're other PRs for weapons in the pipeline, which needs to be resolved based on this one (e.g. https://github.com/Phobos-developers/Phobos/pull/1467)

Coronia avatar Jul 08 '25 06:07 Coronia