Event editor

Post new mods and scenarios here.

Moderator: MOD_Command

Post Reply
gamer69
Posts: 12
Joined: Thu Mar 19, 2020 5:42 am

Event editor

Post by gamer69 »

HI

hope you had a good new year

Is it possible for you to check why this event is not running- the one for the IADS to shut down when a HARM launch is detected.
its not firing
Pun not intended

thank you
Attachments
bridge.zip
(284.86 KiB) Downloaded 8 times
Mark352
Posts: 59
Joined: Thu Jul 25, 2024 2:35 pm

Re: Event editor

Post by Mark352 »

This one is bit a over my head. I took a look at the Lua script in the Event action and noticed you use ScenEdit_GetUnits. That is not a valid function. I queried Google Gemini and to get some help and it identified some other errors in the script. You also had the wrong DBID for the SA-4 site used in the scenario. Here is some updated code I came up with using Gemini. Run it in the Lua console to check it. It will work shut off the radars.

Code: Select all

local IADS_DBIDs = {4130, 1937, 1637, 2735, 295}

function IADS_SuppressRadars(sideName, targetDBIDs)
    local sideObj = VP_GetSide({name = sideName})
    if not sideObj then 
        print("ERROR: Side '" .. sideName .. "' not found.")
        return 
    end

    -- 1. Force everything to strings for a "fuzzy" but safe match
    local dbidLookup = {}
    for _, id in ipairs(targetDBIDs) do 
        dbidLookup[tostring(id)] = true 
    end

    local affectedCount = 0
    print("--- Starting IADS Scan for " .. sideName .. " ---")

    for _, unitData in pairs(sideObj.units) do
        local u = ScenEdit_GetUnit({guid = unitData.guid})
        
        if u then
            -- 2. Check DBID using tostring to ensure 249 matches "249"
            if u.dbid and dbidLookup[tostring(u.dbid)] then
                -- 3. The "Deep" EMCON command
                ScenEdit_SetEMCON('unit', u.guid, 'radar=passive')
                
                affectedCount = affectedCount + 1
                print("SUCCESS: Found and Suppressed " .. u.name .. " (DBID: " .. u.dbid .. ")")
            end
        end
    end

    if affectedCount > 0 then
        ScenEdit_SpecialMessage(sideName, "IADS ALERT: " .. affectedCount .. " units suppressed.")
    else
        print("WARNING: No matching units found. Check if units are in a group or if DBID 249 is correct for this DB version.")
    end
end

IADS_SuppressRadars("RUS", IADS_DBIDs)
As far as I can tell the Lua action script will not trigger because the Trigger is setup to activate when a Harm missile is identified. That means what is says. The detecting side has to identify the missile as a Harm; not a Vampire or Guided Weapon. I'd tried changing the trigger to Guided Weapon and none, and fired Harms at the SA-4 site but, the radars did not shutdown when the weapon was identified. That could be because the side is under attack and needs the radars to defend themselves against the weapon. So I'm not sure how to get that trigger to work the way you want it too.

You might want to consider blinking the radars on an off rather than shutting them down. Again I'm sure if that works with the side under attack. Take a look at this thread -

https://forums.matrixgames.com/viewtopi ... g#p4462842

- maybe it will help execute what you are trying to do.

Good luck
Post Reply

Return to “Mods and Scenarios”