Jump to content

Recommended Posts

Posted (edited)

Anti-radiation missiles (ARMs) can lock on to and hit moving ships, but impacts only have limited effect on the health/hitpoints of the ship. Despite homing on radar emitters, ARM hits will not disable the radar in DCS World as of version 2.9.19.13478, because it lacks a ship damage model.

This script adds the necessary event handler to permanently disable the radar of a ship that is hit by an ARM via :enableEmission(false). Works in multiplayer and on the dedicated server.
Unfortunately, that will also disable all point-defense systems (CIWS) that should have independent targeting sensors, rendering ships entirely defenseless with the first ARM hit. While this is admittedly crude, IMHO, it's still a step up from DCS vanilla behavior of not modelling ARM hits on ships.

Install via the mission editor:

  1. Open trigger screen (via menu item "Set rules for triggers")
  2. Triggers > New > Type: Mission Start
  3. Actions > New > Action: Do Script File > File: Open > ARMsDisableShipRadars.lua

F-16 example mission (with debug messages enabled) attached: ARMs_Disable_Ship_Radars.miz

Contents of attached ARMsDisableShipRadars.lua for a quick view:

Spoiler
-- DCS World Anti-Radiation Missiles Disable Ship Radars Script v2025.08.17
-- (c) 2024-2025 Actium <ActiumDev@users.noreply.github.com>
-- SPDX-License-Identifier: MIT
--
-- Anti-radiation missiles (ARMs) can lock on to and hit moving ships, but
-- impacts only have limited effect on the health/hitpoints of the ship.
-- Despite homing on radar emitters, ARM hits will not disable the radar
-- in DCS World as of version DCS 2.9.19.13478.
-- This script adds the necessary event handler to permanently disable the
-- radar of a ship that is hit by an ARM via :enableEmission(false).
-- Unfortunately, that will also disable all point-defense systems (CIWS) that
-- should have independent targeting sensors, rendering ships *entirely*
-- defenseless.
--
-- Install via the mission editor:
--   1. Open trigger screen (via menu item "Set rules for triggers")
--   2. Triggers > New > Type: Mission Start
--   3. Actions > New > Action: Do Script File > File: Open > *select this script file*

local eh = {}

function eh:onEvent(event)
	-- filter for anti radiation missile (ARM) hits on ships
	-- https://wiki.hoggitworld.com/view/DCS_Class_Weapon
	-- https://wiki.hoggitworld.com/view/DCS_enum_weapon_flag
	-- NOTE: objects may randomly disappear in multiplayer, so verify accessed
	--       objects still exist
	if event.id == world.event.S_EVENT_HIT
	and event.target ~= nil and event.weapon ~= nil
	and event.target:isExist() and event.weapon:isExist()
	and event.target:getCategory() == Object.Category.UNIT
	and event.target:getCategoryEx() == Unit.Category.SHIP
	and event.weapon:getCategory() == Object.Category.WEAPON
	and event.weapon:getCategoryEx() == Weapon.Category.MISSILE
	and event.weapon:getDesc().guidance == Weapon.GuidanceType.RADAR_PASSIVE then
		-- ARMs that miss and impact the water close to the ship will 
		-- register as hits (happens particularly with fast moving ships).
		-- mitigate by ignoring ARMs that hit too close to the waterline.
		local pos_target = event.target:getPoint()
		local pos_weapon = event.weapon:getPoint()
		-- TODO: improve below heuristic via lookup table or bounding box:
		--       event.target:getDesc().box.{min,max}.{x,y,z}
		if pos_weapon.y >= pos_target.y + 5 then
			-- ARM hit ship, presumably its radar -> disable it
			event.target:enableEmission(false)
			--[[
			trigger.action.outText(string.format(
				"%s (%s) hit %s (%s) with ARM %s @ %.1f,%.1f,%.1f -> Radar disabled",
				(event.initiator ~= nil and event.initiator.getName ~= nil) and event.initiator:getName() or "nil",
				(event.initiator ~= nil and event.initiator.getTypeName ~= nil) and event.initiator:getTypeName() or "nil",
				event.target:getName(), event.target:getTypeName(),
				event.weapon:getTypeName(),
				pos_weapon.x - pos_target.x, pos_weapon.y - pos_target.y, pos_weapon.z - pos_target.z
			), 30)
		else
			-- ARM missed ship (impacted too close to waterline)
			trigger.action.outText(string.format(
				"%s (%s) missed %s (%s) with ARM %s @ %.1f,%.1f,%.1f",
				(event.initiator ~= nil and event.initiator.getName ~= nil) and event.initiator:getName() or "nil",
				(event.initiator ~= nil and event.initiator.getTypeName ~= nil) and event.initiator:getTypeName() or "nil",
				event.target:getName(), event.target:getTypeName(),
				event.weapon:getTypeName(),
				pos_weapon.x - pos_target.x, pos_weapon.y - pos_target.y, pos_weapon.z - pos_target.z
			), 30)
			--]]
		end
	end
end
world.addEventHandler(eh)
Edited by Actium
  • Recently Browsing   0 members

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