Can AI be programmed to use countermeasures?

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.

If you put unitSetProperties directly into missile check trigger, you will get less code. No need to referr to additional trigger.

Not sure if I get it. The aim is to make bot to launch flares, right?

yes

image

my mission require scalability. i cant create separate sln for each aircraft

the point was to create selfrefering trigger that will reapeat itself until i say stop

Ah, ok, now I get the point.
How do you start/stop it? As I understand, “playerShortcutPressed” condition works only in SP missions.
I usually create missions by URL where this function does not work.

but it doesnt look for player shortcutpressed.
rn, im only looking of player have missile in world and then filter it with another condition, like distance or line of sight.
then i launch trigger that theoreticly should launch flares for sec or two and then stop untill new missile

updated logic.

so here one launch takes 0.2sec, i control time using

 wait{
        time:r=2
      }

so i get around 10 launches…

triggers{
  isCategory:b=yes
  is_enabled:b=yes

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

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

    events{
      periodicEvent{
        time:r=5
      }
    }

    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"
      }

      playerSeesUnit{
        target_type:t="isAlive"
        check_targets:t="any"
        target:t="phantoms"
        viewAngle:r=90
        distance:r=2000
      }
    }

    actions{
      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
      }

      triggerEnable{
        target:t="Flares"
      }

      wait{
        time:r=2
      }

      triggerDisable{
        target:t="Flares"
      }
    }

    else_actions{}
  }

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

    props{
      actionsType:t="PERFORM_ONE_BY_ONE"
      conditionsType:t="ANY"
      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{}
  }
}

Hmmm, I made F-18 to drop one flare. Then trigger stopped working at all.


i found the way to scale the solution
requires at least 3 triggers per unit
cruck only in multiplayer…
in furbal looking good though

1 Like