Can AI be programmed to use countermeasures?

I’m not sure if there is a setting to set it up so that AIs can also use countermeasures as well. Some advice would be appreciated :)

1 Like

Try checking “allowAntimissile” within unit properties. Idk if it works though.
image

Appreciate the effort, but that didn’t do it. But weirdly enough, them shooting missiles kinda acts as its own countermeasure in a head-on xD

2 Likes

I am also waiting for this. Moreover, you cannot even turn on the automatic system that launches countermeasures. Only IR-lamp on Su-25T works.

I think about playerEmulateShortcut action, but it works only for player, not for AI.

I have tried to include bots in player’s team (tried both teams) - does not work.

There is also UnitSetControls action, which works in general, but it does not have flares.

it works for me. Im using custom units, so i set their flares trigger group to “gun”, and set maxShootingDistance to 10000m. So when trigger detect that missle exist in the world, it add them ammo to “shoot” flares at player

1 Like

Sounds interesting.
Could you please write trigger from .blk file?
Or share the very blk file please.
You said custom units? It means it is not standrad unit?

I’m currently not by my PC, but custom units means I took jas_39c.blk and fm and weapon presets, and modify them. Player can’t operate them, but ai can.
So, the simplest solution, is to change line in plane blk, from trigger type flares to gun/cannon.
And in mission, when player will be close enough, it just start spamming with flares. Actually it’s could freeze game for a while.

1 Like

Ok, I understand the idea in general, but I would appreciate more details.
Please share them at your convenience.

ok, forget about it.
The copy of aircraft blk is created, and its given the missile warning system with

automaticFlares:b=yes
flaresSeriesInterval:r=1.0
numFlares:i=4
flaresInterval:r=0.1

function. Works like a charm

2 Likes

or dont work. its pure random

Thanks! I will try it.

nevermind. It seems it works at UNceirtain conditions that i still can figure out. It work in the Roundtable mission for some reason

i figure it out

so idk how do you expect to detect the missile, but in order to make ai launches flares you can use this structure
rn there is unitWhenStatus Targeted, check player location relative to aircraft or check trigger status of nearby aircraft, but all this not scalable beyond simple duel/dogfight

  Flares{
    is_enabled:b=no (you turn it on when detect missile)
    comments:t=""

    props{
      actionsType:t="PERFORM_ONE_BY_ONE"
      conditionsType:t="ALL"
      enableAfterComplete:b=yes
    }

    events{
      periodicEvent{
        time:r=0.1
      }
    }

    conditions{}
    actions{
      unitSetProperties{
        object:t="aircraft"

        plane{
          weaponTriggers{
            trigger:t="countermeasures"
            set:b=yes
          }
        }
      }

      wait{
        time:r=0.1 (required pause to dont mess up, also the delay between the flares)
      }

      unitSetProperties{
        object:t="aircraft"

        plane{
          weaponTriggers{
            trigger:t="countermeasures" (must disaible to be aible launch again)
            set:b=no
          }
        }
      }
    }

(btw i liked your solution for interceptor ai)

UPD

the most primitive sln that checks if player launched missile and launches countermeasures

  missile{
    is_enabled:b=yes
    comments:t=""

    props{
      actionsType:t="PERFORM_ONE_BY_ONE"
      conditionsType:t="ALL"
      enableAfterComplete:b=yes
    }

    events{
      periodicEvent{
        time:r=0.1
      }
    }

    conditions{
      unitWhenStatus{
        object_type:t="hasMissilesInWorld"
        check_objects:t="any"
        object_marking:i=0
        object_var_name:t=""
        object_var_comp_op:t="equal"
        object_var_value:i=0
        target_type:t="isAlive"
        check_period:r=1
        object:t="player"
      }
    }

    actions{
      triggerActivate{
        target:t="Flares"
        activate_type:t="checkConidtions"
        check_trigger_status:b=no
        after_activation:t="disable"
      }

      wait{
        time:r=2
      }

      triggerDisable{
        target:t="Flares"
      }

      playHint{
        hintType:t="standard"
        name:t="missile"
        action:t="show"
        shouldFadeOut:b=no
        isOverFade:b=no
        time:r=-1
        priority:i=0
        target_marking:i=0
        object_var_name:t=""
        object_var_comp_op:t="equal"
        object_var_value:i=0
      }
    }

    else_actions{}
  }

  Flares{
    is_enabled:b=no
    comments:t=""

    props{
      actionsType:t="PERFORM_ONE_BY_ONE"
      conditionsType:t="ALL"
      enableAfterComplete:b=yes
    }

    events{
      periodicEvent{
        time:r=0.1
      }
    }

    conditions{}
    actions{
      unitSetProperties{
        object:t="phantoms"

        plane{
          weaponTriggers{
            trigger:t="countermeasures"
            set:b=yes
          }
        }
      }

      wait{
        time:r=0.1
      }

      unitSetProperties{
        object:t="phantoms"

        plane{
          weaponTriggers{
            trigger:t="countermeasures"
            set:b=no
          }
        }
      }
    }

    else_actions{}
  }

still, absoulutely not scalable.

what can be done though, is to filter this with unitsInLineOfSight,

2 Likes

That is absolutely awesome! Thanks! I will check this solution for my missions.

oh, and use triggerEnable instead of triggerActivate, cus in other way the cycle wont repeat itself

1 Like

What happens if you place " unitSetProperties" action directly into the trigger that checks missile presence?
I always use “triggerActivate” and never experienced any issues with that.

Maybe Mig is out of flares? You can restore its flares.

idk, i just dont like long squencess. I like having flares and the button than turn them on, not having to launch them using matches.