Scripted AI and Scenario Briefings

Welcome to the second part of my blog series on Scripted AI. In the first post of this series, I discussed Scripted AI in general. Then, before this one, I wrote about the two CSEE How-To documents that Berto created, which will soon be included in the game manual content. Now, let’s dissect the Scenario Briefings.

Scripted AI Scenario Briefing CSEE Lua

Scripted AI Scenario Briefing CSEE Lua

SMEAC

CS Vietnam 2.0 Scenario Description Template

CS Vietnam 2.0 Scenario Description Template

Our Scenario Briefings, courtesy of scenario-specific Campaign Series Event Engine (CSEE) Lua files, loosely follow the five-paragraph field order style: “S” for Situation, “M” for Mission, “E” for Execution, “A” for Administration and Logistics, and “C” for Command and Signal.

As we covered in the first blog, the csmkllua.pl (“make Lua”) utility initially generated what was mostly an empty skeleton for scenario designers to fill with the necessary details. The Scenario Briefing was one of those blank canvases. In the next update, the revised Make Lua utility will take things a step further.

Let’s dive into the details. As an example, I will use a Community mod available via the JSGME Mod Enabler that ships with the tool: Alan R. Arvold’s “Battle of Black Virgin Mountan, Octover 15, 1966, which is one of the three scenarios that are available under the Ode to Divided Ground Vietnam Mods Campaign, once enable.

Greetings, Commander!

Actually, even before the Situation paragraph, there’s a welcoming statement to this particular scenario.vided below. Carry out with accuracy.

With stock scenario files all starting with a two-letter country code as the prefix, csmklua uses that to set the scene. If, for any reason, such a prefix is not identified, the region name is used instead. For example: Welcome to Southeast Asia! Here, instead, as always suggested: I edited the Lua scenario file created by the Make Lua utility to introduce players to this Campaign set instead.

Next, there’s an encouragement to follow orders diligently. This message comes from a text array or table of sentences. Tables are easy to implement in Lua and are also used for other communications. For instance, when an objective falls into your hands after your genius strategy, a random commendation is sent your way.

So here we go:

Commander, welcome to Alan R. Arvold’s Ode to Divided Ground Vietnam Mod! Your SMEAC is provided below. Carry out with accuracy.

There is a wealth of intel about the scenario being opened on the game engine side. Some of this information was already available through the CSEE Lua API (application programming interface, or simply, a function you can call to process or retrieve data). However, since much of it was considered “chrome” (nonessential details), many aspects were not included.

Among the new APIs I wrote for this update, I added a function that retrieves the part of the scenario description template identifying the exact location where the depicted battle took place.

I. SITUATION:

Scenario: Battle of Black Virgin Mountain; 15 October, 1966

In addition, map intel such as Terrain type, Ground conditions, and Visibility is now retrieved and displayed under the Situation paragraph.

a. Area of Operations: Tay Ninh Province, South Vietnam. Terrain: Tropical Rainforest, dry ground. Weather: day, visibility 5000 meters.

For the Friendly and Enemy forces intel, I enhanced the Make Lua utility to include higher-level organizational names and calculate an average morale factor for those levels, alongside the usual unit IDs (trackids) used in CSEE code. This information is now presented to the player as well. It should prove to be valuable, especially when playing under Enhanced Fog of War, where intel on the map is scarce at the best of times. There’s a shout for the available support, typically Air Support, if any. Pay attention to your Command Reports as you play along, as all airstrikes are often not immediately available.

b. Enemy Forces: Elements of the 88th Rifle Regiment, 57th Heavy Mortar Battalion, 43rd NVA Special Action Group, 183rd VC Sniper Group, and Civilians. Enemy morale is assessed
as moderate. Adjust your tactics accordingly.

c. Friendly Forces: Units of the 25th Infantry Division, and Relay Station Garrison.

d. Supporting: Full Air Support available: 4 flights of Close Air Support. Current missions allocated can be found in the Status > Command Report.

Finally, there is a warning regarding indirect fire from or to inhabited hexes or for calling airstrikes there. The CSEE skeleton includes Event Point penalties for such actions, so pay close attention.

e. Civilian Considerations: You will lose Event Points for indirect fire or airstrikes on inhabited areas (villages, cities, suburbs), regardless of enemy presence.

Here’s the complete Lua section that creates the Scenario Briefings for scenarios:

Scripted AI - Lua code behdind the Scenario Briefing

Scripted AI – Lua code behdind the Scenario Briefing

Mission

If Situation was still about “chrome” in some way, Mission is where things get interesting.

Those familiar with our Scenario Editor that comes with all games (alongside the Map and Organization editors) might recall there is a dialog to assign Mission Types for both sides. These mission types were not previously used by the game engine, but now they are being put to good use.

There is now a new CSEE API to retrieve Mission Types for both sides. Each mission type now has a weight attached to it, representing postures that range from tentative recon attacks to strong or even fanatical last-ditch defensive postures. Note another dynamically created phrase to bring some flare to this.

II. MISSION:

Your mission directives are: Mopping Up, from turn 1 to turn 24. Search and Destroy, from turn 1 to turn 24.

Enemy actions are anticipated to focus on: Ambush, from turn 1 to turn 24. Infantry Assault, from turn 1 to turn 24.

Prepare to act on all mission directives.

In addition to the mission weight, or mission posture, there is now a set duration for each mission. By default, since the Scenario Editor does not provide this level of detail, each mission is assigned a duration from turn one to the last turn of the scenario. However, there is a TO DO tag set for the scenario designer to edit these. For example, a Meeting Engagement for the first ten turns, followed by a Rearguard Action for the remaining turns as opposition was found to be too strong.

Which brings us to…

Execution

First, the scenario briefing is quite generic at this stage. To add situation intel, scenario designers are encouraged to chip in.

III. EXECUTION:

Stay agile and modify your approach based on battlefield changes. Pay close attention to CSEE events during combat, as they may affect your strategy.

Victory depends on reaching mission targets while maintaining operational strength. Monitor Status > SITREP for real-time updates on the operational situation.

With mission_posture now available in the CSEE Lua file, it can be put to good use in guiding the Scripted AI to execute according to the mission_posture in play. Weighed die rolls to determine between weak, normal, strong, or fanatical attack() or defend()? Yes, why not.

Mission Posture Set-up Lua

Mission Posture Set-up Lua

The Mission Type itself can also be utilized in CSEE, which is particularly useful if a Rearguard mission is in play. For example, units can fall back to the next objective behind the lines, defend weakly (where the defending unit is more likely to retreat than take casualties), and then fall back again to the next objective in the rear.

This kind of tactical execution was already implemented by scenario designers, such as in Vietnam 1.0, so it is not entirely new. What is new is that this type of execution can and will become more automated as we continue to enhance the Make Lua utility.

Administration and Logistics

“Amateurs talk about tactics, but professionals study logistics.” And why not, as logistics takes on a stronger role even in the mostly tactical battles depicted in Campaign Series scenarios. The new CSEE Lua skeleton now tracks the gradual decline of Ammo and Artillery Ammo levels once the first shots of both types are fired. The decline is slow, but in a long scenario, it can have a noticeable impact. Even at this tactical scale, not all units should be able to go all out all the time, right?

In Vietnam 1.0 scenarios, it was already common for losing a Supply source to decrease Ammo levels. Additionally, there were often scripted means in CSEE to replenish supply. Now, there is added automation for this. For every full set of 10 turns (a default that scenario designers can adjust), a Logistics Round is triggered, increasing Ammo levels by 10 percent.

IV. ADMIN AND LOGISTICS:

Current Supply levels: Ammo: 80%, Artillery Ammo: 80%, Smoke: 12, Flares: 0.

Be aware that supply levels will decrease as combat intensifies, so plan accordingly.

As of the current status, Logistics is prepared to deliver 2 Ammo resupply and 2 Artillery resupply rounds.

As another improvement, there is a new dialog to check for any orders available. The Make Lua utility will now include these Logistics Rounds by default.

Resupply available! Check for Orders dialog in action.

Resupply available! Check for Orders dialog in action.

Scenario designers can expand on them by incorporating other tactical options and considerations.

Command and Signal

Finally, Command and Signal. While the Scenario Briefing keeps this paragraph relatively brief, there is a lot happening on the Command side of the computer opponent, with Scripted AI working in its favor.

V. COMMAND AND SIGNAL:

Refer to the Status > Find Organizations dialog for your complete command structure.

Hold that thought, as the third installment of my Scripted AI blog series will dive into the Battle Plan portion of the new CSEE scenario skeletons.

Good luck, commander!

Thank you for reading this far, and stay tuned!

CS Event Engine How-To Volumes I and II

I thought I’d have the second part of the CSEE Lua Scripting posts available by now, but with the decision to update both games to full reimages for the next update (due in about a month), it’s been a very busy time!

As a little teaser, the upcoming Vietnam 2.00 and Middle East 3.00 updates—while requiring a complete uninstall and reinstall—are packed with goodies:

  • A completely new Scenario Browser front-end dialog, replacing the old Main Menu front-end dialogs. Redesigned in-game dialogs, too.
  • Completely revamped 3D map graphics for both games, courtesy of Bill ‘Mausman’ Blake
  • Brand-new Orders of Battle for Middle East, featuring Iran and a fully revised Iraq (1948–1985)
  • Ditto for Vietnam, with the addition of North Korea’s Order of Battle (1948–1985)
  • All Middle East scenarios now include accompanying CSEE Lua files

… and that last item brings me back to the topic of this post: CSEE How-to manuals for all you Lua programming fans out there.

CSEE How-To Volume I (2017)

I don’t know how many of you have noticed, but part of the Middle East Manuals subfolder has included this How-to guideline since the release of Middle East 2.00 back in early 2018.

CSEE How-To Vol I Table of Contents

CSEE How-To Vol I Table of Contents

Alongside the guideline, there was (and still is) also a scenario Lua file containing all the examples detailed in the document, showcasing various Scripted AI (SAI) battle plans coded there. Those were the early days, and there was still quite a bit for scenario designers to handle beyond battle tactics such as saving and restoring Lua variable values between game saves and resumes.

Featuring around 50+ pages of detailed examples, I’ve updated the document to meet our current game manual standards. While it includes Middle East content, this guideline will also be part of the Vietnam Manuals for added utility.

CSEE How-To Volume 2 (2022)

Fast forward four years to early 2022, and the second revision of the CS Event Engine was released alongside Vietnam 1.00. This iteration was a far more advanced system, with significant automation of the nitty-gritty tasks, improved placeholders for Scripted AI battle plans and events, and a robust application programming interface (API) that allowed Lua scripts to call the game engine for various actions and data retrieval.

This time, there wasn’t a formal guideline document. Instead, Berto produced a highly detailed blog series in the Matrix Games Vietnam forum (link opens there). The series focused on scripting for the Battle of Rung Sat, where he first created a defensive battle plan for Side B and, once that was complete, scripted the offensive actions for Side A.

Through these posts, Berto not only explained the scripting process in depth but also demonstrated how to use the game’s auto-testing feature. This feature allowed the Scripted AI for both sides to engage each other, pausing at predefined intervals to observe results, analyze performance, and refine the Scripted AI further for optimal effectiveness.

CSEE How-To Volume II Table of Contents

Over the past several days, I’ve been determined to turn this CSEE intel into a proper guideline document. After editing roughly 50% of Berto’s blog content into our manual format, I paused, at around 170+ pages. The result is an impressive How-to guideline for mastering the CSEE API.

This document includes the first complete iteration Berto created based on his auto-tests. At 173 pages, I felt it was sufficient to cover the essentials. However, Berto continued refining the scenario’s CSEE, and I’ve included links in the guideline to his follow-up work he posted in the Matrix Games forum for those interested in diving even deeper.

This truly is the document to read. While the CSEE Lua API continues to evolve—and has evolved further with the release of Vietnam 2.0 and Middle East 3.0—this evolution builds on the foundation established in the Volume II feature set. It’s more refinement than revolution, making the guideline an essential resource for understanding the core API.

This guideline, too, will be included in Manuals folder content for the both games in the coming Updates.

I’ll continue my Scripted AI blog series with the next installment, focusing on the evolved Scripted AI in this coming next iteration. Not quite a revolution, but perhaps a Volume 2.5—with further improvements to explore.

Before that, I strongly recommend reading these guideines, as they provide the foundation needed to grasp the next set of CSEE API features.

 

Thank you for reading this far, and until next time!