Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

C-RAM Phalanx stay off when bombs are inbound #107

Open
MacFlorent opened this issue Feb 12, 2024 · 0 comments
Open

C-RAM Phalanx stay off when bombs are inbound #107

MacFlorent opened this issue Feb 12, 2024 · 0 comments

Comments

@MacFlorent
Copy link

C-RAM Phalanx units managed by Skynet stay off when bombs are inbound, but they are perfectly capable to engage them.
The Phalanx are the first and only units that can engage bombs (as far as I know) so it was not a problem before, but we can note that in Skynet, this behavior is not by design but rather by accident.

In SkynetIADS.evaluateContacts(self), we decide which contacts will be passed to the IADS sites as follows:

local description = contact:getDesc()
local category = description.category
if category and category ~= Unit.Category.GROUND_UNIT and category ~= Unit.Category.SHIP and category ~= Unit.Category.STRUCTURE then
    samToTrigger:informOfContact(contact)
end

This will not always work, because it assumes that the contact is a unit. But actually a contact can be a unit or a weapon.
Categories returned by description.category will not be the same for a unit or a weapon:

Unit.Category = { AIRPLANE=0, HELICOPTER=1, GROUND_UNIT=2, SHIP=3, STRUCTURE=4 }
Weapon.Category = { SHELL=0, MISSILE=1, ROCKET=2, BOMB=3 }

As it is, we consider only the units categories that are not in [2, 3, 4], that is:
An airplane or a helicopter will be passed to the sites as designed
A missile (HARM, JSOW...) will be passed as well but only by chance because its category is equal to AIRPLANE

A bomb will not be passed because its category is the same as the SHIP category for units.

Proposed correction consists in correctly considering the contact object category before looking at its description category.

Note 1: we could enhance that by only turning the site on when it can indeed engage the target, like it is done for the HARMs.
Note 2: maybe the shells and rockets can be engaged by the CRAMs as it is in real life ?

Here is the proposed correction, that I will also put in a PR shortly.

local bShouldInform = false
local objectCategory = Object.getCategory(contact:getDCSRepresentation())
local category = contact:getDesc().category

if (objectCategory == Object.Category.UNIT) then
	bShouldInform = category ~= Unit.Category.GROUND_UNIT and category ~= Unit.Category.SHIP and category ~= Unit.Category.STRUCTURE
elseif (objectCategory == Object.Category.WEAPON) then
	bShouldInform = category ~= Weapon.Category.SHELL and category ~= Weapon.Category.ROCKET
end

if category and bShouldInform then
	samToTrigger:informOfContact(contact)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant