There are a lot of requests already on this forum in support of the idea of having additional sides or coalitions beyond the existing Red, Blue, and Neutral, I fully support these requests, and they should also include functions to set the hostility of the different coalitions.
In a similar vein adding a command that woud allow units or nations to have their coalition switched would be a welcome addition to DCS.
My use case for this is that I am making a mission in which the players will be primarily operating inside one country (UAE on the Persian Gulf terrain). I would like to have AI air patrols in adjacent countries (Qatar, Oman, Saudi Arabia) that will only become hostile only if they players stray into the airspace of the adjacent countries.
My current work around is to have the AI flights always as Opfor set to Late Activation, and then activate them with a triggers shaped to the airspace of the adjacent country.
If I had a way to change their coalition I could have them set to Neutral and actually on patrol, then use a fuction like setCoalition to change them to hostile if the players stray into their country's airspace.
Possible implementations of a setCoalition command could either change the coalition of the entire nation, or just of a specific unit, or add a command for each option.
Examples:
Change unit's side
CoalitionObject.setCoalitionUnit(coalition.side)
myPlane.setCoalitionUnit(RED)
Change nation's side
coalition.side.setCoalitionCountry(countryId)
RED.setCoalitionCountry(73)