Page MenuHomeFeedback Tracker

CanFire is broken
New, WishlistPublic

Description

'CanFire' doesn't return expected Results.

'CanFire' should only consider the Damage Value of the Main Turret thus only return false if and only if the Main Turret is heavily damaged or destroyed (not moveable).

Currently 'CanFire' is only triggered by a few events (see "Additional Information") and behaves strangely in general. {F25385}

Details

Legacy ID
1270895176
Severity
None
Resolution
Open
Reproducibility
Always
Category
Scripting
Steps To Reproduce
  1. Create a Vehicle with a (at least one) Main Turret.
  2. Keep checking the Return Value of the Statement 'canFire X'.
Additional Information

Currently following Behaviour is observable:

  • It returns false if the Gunner Seat is empty
  • It returns true if the Gunner Seat was once occupied by some "brained" entity (i.e. Player or AI)
  • It returns true as long as any "brained" entity occupies any Seat featuring advanced Interaction (i.e. Driver, Gunner, CO - not Cargo e.g.)
  • It returns false if entities move out of the Vehicle who did not occupy the Gunner Seat - even occurs when the Gunner Seat ONCE was occupied (assuming no Gunner is left)
  • It returns false if the Vehicle Ammo was removed via SQF Statements (it would [still] return true if you'd empty all Magazines manually by firing thus making it IMPOSSIBLE to check this Exception via SQF) (assuming there's a Gunner)

A2/OA features this Bug, too.
In contrary to that: In OFP the Command works as intended.

Event Timeline

Roehre edited Steps To Reproduce. (Show Details)Jan 10 2015, 12:44 AM
Roehre edited Additional Information. (Show Details)
Roehre set Category to Scripting.
Roehre set Reproducibility to Always.
Roehre set Severity to None.
Roehre set Resolution to Open.
Roehre set Legacy ID to 1270895176.May 7 2016, 8:04 PM

Can I ask in case with ghosthawk that has 2 turrets, what this command should return?

Roehre added a subscriber: Roehre.May 7 2016, 8:04 PM

For coding convenience (and the hope that this gets also fixed in A2/OA) I would suggest just checking one turret i.e. the 'main' turret. That would be the exact turret which would be affected by 'addWeapon' or 'moveInGunner'.
Returning false for Vehicles w/o such a 'main' turret, would be OK; alternatively one could add a new Command which returns the 'canFire'-Value for each Turret via a Turret-Path-Array (i.e. [true (or false, if there is no 'main' turret), [false, true]] or [true , [true, true]] as in your Example.)
Maybe one could create a new Ticket after that one here (hopefully) gets fixed.

Btw.: I think you pointed out the exact Problem behind the Coding of this Command!
Because of the undefined Information which Turret should be considered (it seems to be stored as a Property of the Vehicle) 'canFire' returns false as a non-existing Turret isn't a Turret. Boarding the Main Turret Seat changes the Value to the Main Turret and let's 'canFire' work properly even after disembarking.
There seems, however, be a twist when disembarking from non-gunner seats (see "Additional Information")...

Personally I see no use in a command that only checks one turret but not the other and I don't quite understand the use of canFire command on a vehicle with many gunners and turrets. On a unit, yes, canStand, canMove, canFire etc, makes sense.

Also the turrets that can be damaged and rendered unusable all have hitpoints, so why not check turret damage directly with getHit or getHitPointDamage? And god forbid if some AI script is using canFire somewhere.

I am sorry if that is the Case.
But there is indeed very much Sense for such a Command. Especially in Missions of larger Scale a healthy ratio of usability and performance is vital! Caching a large Number of Strings (for a large Number of diff. Vehicles) to - maybe - check via 'getHit' (which isn't Part of A2's CMD-Pool) certainly doesn't belong to the category "reasonable" (not to speak about MP-Propagation).
But you cerainly already know a Case where it was used for a Mission of smaller Scale, too.

But BTT I think you might not understand the actual Purpose of all those 'can'-Commands: Their Routines are already used for other internal Calculation. The most Important: the AI.
So the AI switches their Behaviour exactly how all the 'can'-Commands (should) behave: if the Main Turret is destroyed, the Gunner doesn't care neither about targeting nor firing. If the Tracks are destroyed, the Driver won't care about driving anymore (currently they are disembarking the Vehicles and even a Gunner or Commander refuses to get in again). Whilst normal Gaming 'canFire' and 'canMove' both false are at least "Status Red" (due to the Pass-Through-Damage).
So these Commands are important to handle a Garbage Collector or AI Scripting.

Btw:

  1. Your Suggestion wouldn't work for Tanks (I tested the MBTs), because even if the Hit Point "main_turret_hit" would be destroyed - which is listed in the config as a Property of the Main Turret exclusively - the Commander's Sight aren't moveable anymore, too.
  2. The Ghosthawk seems to indeed have a Main Turret - the left Gunner. 'CanFire' would return true. I corrected my last Comment.