MOOSE icon indicating copy to clipboard operation
MOOSE copied to clipboard

CORE: Torpedo hit events reach 'else catch all' logic and error at getName()

Open thebgpikester opened this issue 5 years ago • 3 comments

Current Code block around line 7500

 if Event.IniObjectCategory == Object.Category.STATIC then
          if Event.id==31 then
            --env.info("FF event 31")
            -- Event.initiator is a Static object representing the pilot. But getName() error due to DCS bug.
            Event.IniDCSUnit = Event.initiator
            local ID=Event.initiator.id_
            Event.IniDCSUnitName = string.format("Ejected Pilot ID %s", tostring(ID))
            Event.IniUnitName = Event.IniDCSUnitName
            Event.IniCoalition = 0
            Event.IniCategory  = 0
            Event.IniTypeName = "Ejected Pilot"
          else
            Event.IniDCSUnit = Event.initiator
            Event.IniDCSUnitName = Event.IniDCSUnit:getName()
            Event.IniUnitName = Event.IniDCSUnitName
            Event.IniUnit = STATIC:FindByName( Event.IniDCSUnitName, false )
            Event.IniCoalition = Event.IniDCSUnit:getCoalition()
            Event.IniCategory = Event.IniDCSUnit:getDesc().category
            Event.IniTypeName = Event.IniDCSUnit:getTypeName()
          end
        end

When a torpedo hits, it creates an event like:

{[id]=2,[time]=28910.681,[initiator]={[id_]=33561088,},[target]={[id_]=16778240,},[weapon]={[id_]=33561088,},[IniObjectCategory]=3,[weapon_name]=weapons.torpedoes.G7A_T1,}

Because the IniObjectCategory is 3 (a static) it hits the if clause, because it is not event.id==31, it hits the else clause and because there is no Event.IniDCSUnit, it errors to main logs with "the unit does not exist".

I need to check with you on three things: A check on what the "Event.IniObjectCategory == Object.Category.STATIC" is really for and if it is being used consistently by ED Is this the only weapon that uses static category? A check on the impact of this.... I need to ask, why do we even care about OnHit events?

thebgpikester avatar Jul 05 '20 23:07 thebgpikester

Thanks Pikey! To answer you three questions:

  1. I had introduced the if condition when the new event S_EVENT_LANDING_AFTER_EJECTION was introduced (before, there was no if condition for static objects at all). The initiator for that event is a static representing the pilot. However, unlike "normal" statics, the getName() function (and others) dont work for this object.
  2. Yes, I think it is the only weapon as the code ran well for years. In fact, I would say this is a DCS bug as the object category should be OBJECT.Category.WEAPON (=2) and not OBJECT.Category.STATIC (=3).
  3. Because people might hook into Hit events and do stuff (suppression class uses it, scoring also, users of cause).

funkyfranky avatar Jul 06 '20 07:07 funkyfranky

The bug was REPORTED but Grimes fedback it was known, I'm not entirely sure which is true, but if it is the latter, wouldn't expect to see much movement on this bug. We should leave the ticket open until the releases have matured past this point before giving up hope. The impact of the issue is fairly small amountd of log writing unless people want to hit handle torpedoes and are not aware of the issue. The impact would be they might exclude torps or have a few hours of confusion in the future.

thebgpikester avatar Jul 08 '20 10:07 thebgpikester

@thebgpikester @funkyfranky is this issue still relevant?

baluballa avatar Jun 05 '22 09:06 baluballa

Apprently Torpedoes are still WIP after 2 years so I think I will close this and if it crop up when they are being used more can revisit then

thebgpikester avatar Aug 26 '22 12:08 thebgpikester