Jump to content

DCS 2.9.7.58923 apparently just broke the S_EVENT_DEAD event handler when detecting scenery objects destroyed.


Go to solution Solved by Riscorider,

Recommended Posts

Posted (edited)

Today's change (DCS 2.9.7.58923) somehow affected the Dead Event Handler.  Map buildings assigned as zones using the "assign as" feature are no longer being detected when dead/destroyed.    The script shown below still works fine for everything except the two munitions buildings.  Any ideas @BIGNEWY?

Log Error:

2024-08-10 15:26:47.848 ERROR   SCRIPTING (Main): Mission script error: [string "C:\Users\chiph\AppData\Local\Temp\DCS.openbeta\/~mis000044A6.lua"]:805: attempt to call method 'getName' (a nil value)
stack traceback:
    [C]: in function 'getName'
    [string "C:\Users\chiph\AppData\Local\Temp\DCS.openbeta\/~mis000044A6.lua"]:805: in function 'onEvent'
    [string "Scripts/World/EventHandlers.lua"]:13: in function <[string "Scripts/World/EventHandlers.lua"]:11>

 

Script:  

DeadUnitHandler = {}
function DeadUnitHandler:onEvent(Event)

    if Event.id == world.event.S_EVENT_DEAD then
        if Event.initiator then    

            local DeadUnitName = Event.initiator:getName()  -- this is line 805 in the mission script
        
            if ( string.find(DeadUnitName, "Bandar Abbas SA6 Launcher 1") or
                 string.find(DeadUnitName, "Bandar Abbas SA6 Launcher 2") or
                 string.find(DeadUnitName, "Bandar Abbas SA6 Launcher 3") or
                 string.find(DeadUnitName, "Bandar Abbas SA6 Launcher 4") ) then

                DeadLauncherCount = DeadLauncherCount + 1

                if ( DeadLauncherCount == 4 and SA6Dead == 0 ) then
                    
                    CPH_SA6Dead()
                else
                end
        
            elseif (string.find(DeadUnitName, "Bandar Abbas SA6 Radar") and SA6Dead == 0 ) then
                
                    CPH_SA6Dead()

            elseif (string.find(DeadUnitName, "MV Baltic Cove") ) then

                GROUP:FindByName("Iran Attack Group 1"):OptionAllowJettisonWeaponsOnThreat()
                GROUP:FindByName("Iran Attack Group 2"):OptionAllowJettisonWeaponsOnThreat()
                GROUP:FindByName("Iran Fighter Escort"):OptionAllowJettisonWeaponsOnThreat()
                GROUP:FindByName("Iran Attack Boats"):CommandSwitchWayPoint( 1, 4 )
                trigger.action.outText("MV Baltic Cove has been sunk!", 30)

            elseif (DeadUnitName == 163155054 ) then -- Munitions 1 Target
                
                AmmoDump1Hit = 1
                AmmoDumpsDestroyed = AmmoDumpsDestroyed +1
                trigger.action.setUserFlag('AmmoDump', AmmoDumpsDestroyed )
                timer.scheduleFunction(CPH_Ammo_Dump_Secondary, nil, timer.getTime() + 20)

            elseif (DeadUnitName == 163154967 ) then -- Munitions 2 Target

                AmmoDump2Hit = 1
                AmmoDumpsDestroyed = AmmoDumpsDestroyed +1
                trigger.action.setUserFlag('AmmoDump', AmmoDumpsDestroyed )
                timer.scheduleFunction(CPH_Ammo_Dump_Secondary, nil, timer.getTime() + 20)

            elseif (DeadUnitName == "Bandar Abbas Intl" ) then -- Detect Runway Destroyed
                
                RunwayDestroyed = 1
                trigger.action.setUserFlag('RunwayDestroyed', 1 )
                trigger.action.outTextForCoalition(2, "Bandar Abbas Runway Destroyed!!!", 30, true)
                CPH_Runway_Smoke()
        
            else        
            end
        end    
    end
end    

world.addEventHandler(DeadUnitHandler)

 


 

Edited by Riscorider
Posted

I think I may have figured out what has happened.  Looks like the object ID previously assigned to these particular buildings has changed during this update.  Must be a map update I'm guessing.  Gonna test it and update if that is, in fact, the cause.

 

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...