I then make the mistake of ordering everybody out, thinking that the mortar fire was about to wipe us out. In a panic, I check my casualties and I have two men down. We are at the ruins in the mid background. Then the enemy mortar fire starts to fall on us. Our ranges of engagement shorten dramatically. The other enemy squads are finding their way towards our position. One of the enemy AI squads threw smoke, which is something I heard about before but it was very cool to see for the first time. But bullets still fly over us, a clear indication that we have not achieved total fire superiority on all the enemy squads. One of their squads is overwhelmed by our fire. The enemy is still not aware of our location and advances without too much care.
The enemy has one mortar tube ("mortar1") located on the other side of those hills. The enemy is advancing towards our position from the far background. We try to hold our fire as much as possible. We spot the enemy platoon when it is at a range of around 1 kilometer or so. The defensive position is placed in the ruins of a farm. I tested the setup in a self-edited mission where a squad of AAF infantry has to defend itself against a platoon of enemy rebels (FIA faction, computer controlled). There is no need for "mortar1" to have a LOS on the target at which is firing with this trigger. This is to simulate the time taken to transmit the coordinates by the BLUFOR forces to their mortar. I added a timer of a minimum of 2 minutes to activate the triggered mortar fire (see "timer" fields in the above screenshot).
#Arma 3 sync move waypoints code
Then add the code shown above in the "ON ACT." field: that makes "mortar1" to fire at the position where the OPFOR (that is us in this case) was detected. The trigger activates when the OPFOR (in this case my troops are OPFOR) is detected by BLUFOR (in this case enemy rebels). Then create a trigger entity, big enough to cover the area of operations (a circle of 5,000 meters in this case). In the editor, create a mortar, name it "mortar1" and if you want it to have unlimited ammo, place the line of code seen in the initialization field.
So I found this page, where the process of creating such a thing is just a handful of clicks and just two lines of code that is added straight into the editor's entities. But I always prefer something very simple and maintenance free. I'm sure there are many scripts out there to have the enemy AI to shoot a mortar shell at you.