Dev Diary #09: CS Event Engine

The Campaign Series: Middle East 1948-1985 is a new turn-based, tactical wargame that focuses on conflicts in the Middle East.

Moderator: Jason Petho

User avatar
Crossroads
Posts: 17498
Joined: Sun Jul 05, 2009 8:57 am

Dev Diary #09: CS Event Engine

Post by Crossroads »

Berto suggested I'd start a new Developer Diary on CS Event Engine and what can be done with it to give the CS scenarios additional oomph. And why not. We're just out with the first CS Event Engine 1.0 code, so it's still early. But what better way to get everyone's thoughts and ideas in as early as possible than giving some living samples as what it can do already in this BETA stage.

So let us keep this interactive, and let us have those ideas coming in.

Berto will no doubt do a Coder Diary on Event Engine at some stage, giving out the details how Lua, the scripting language used in CS Event Engine, works. But in this thread, let us not get bogged down in technical details, let us talk scenario design instead.

With this in mind, I'll start with "Crisis in Sirte: 1. Prelude (H2H)" as the sample to use here.

At this stage, I've already got an initial list of ideas I want to try out. Here they are, in no particular order:

[*] I'd like to give both sides a briefing in the beginning as what their key tasks are.
[*] Later perhaps, I'd like to give the players feedback as how they are doing per achieving those tasks.
[*] I want events too, of course. So how about a few events that can trigger the arrival of reinforcements. Given how things go, they might come sooner, or later. Or not at all.
[*] For instance, I'll add a Libyan SAM site to the coast, and have some British SAS troops there to take it out. Only once its out can the Air assault begin.
[*] The Brits paratroopers may be used to being surrounded, too, but I'd like to have their supply situation worsen throughout the game play, for one. Perhaps some other difficulties as well?
[*] Losses might have an effect as well. Lose your commander, and everyone's Morale goes down?

What else?

In the Adaptive AI Dev thread, I fooled around with AI parameters. Those can be accessed from Event Engine as well, so that might be the proper place to do it.

I'll get started little by little on this one. Meanwhile, any ideas, wishes, what ever, please chip in!

So let us start by asking first what you'd like to see take place on that scenario?

Let us then see if I can then have them take place [:)]
Visit us at: Campaign Series Legion
---
CS: Vietnam 1948-1967 < Available now
CS: Middle East 1948-1985 2.0 < 3.0 In the works
User avatar
Crossroads
Posts: 17498
Joined: Sun Jul 05, 2009 8:57 am

RE: Dev Diary #09: CS Event Engine

Post by Crossroads »

We've not yet really talked about CS Event Engine so much, so here's a little something from Sneak Peeks to get things started:

ORIGINAL: Crossroads

ORIGINAL: berto


At latest count, over 120 functions in the new Campaign Series (Lua) Event Engine:

So cool, so much more finesse can now be put into scenario design.

For instance, with the Crisis in Sirte scenario "Prelude", what if the Libyan player just decides to vacate Sirte, saving his troops from losses and thus preventing his opponent to gain additional Victory Points for destructing enemy unis? Gamey tactics, even, if Sirte would be such a key port facility to deny the Brits have access to it in later Sirte scenarios.

How about we give him reinforcements, then, should he succesfully hang into Sirte for the first ten turns? Now he'd have a reason to fight tooth and nail to keep the Brits out!

Something like this perhaps? [:)]

-- Early stuff, by the way! The CS Event Engine will be worth both Coder and Developer Diaries in due time, just not quite yet --

Image

Image
Visit us at: Campaign Series Legion
---
CS: Vietnam 1948-1967 < Available now
CS: Middle East 1948-1985 2.0 < 3.0 In the works
User avatar
Crossroads
Posts: 17498
Joined: Sun Jul 05, 2009 8:57 am

RE: Dev Diary #09: CS Event Engine

Post by Crossroads »

Ok, so let us get this Diary on its way. First, here's the current set of CS Event Engine functions. They're at early 1.0 BETA stage, so expect to see some changes yet.

The Event Engine functions come in two major groupings: trigger functions, and action functions.

Trigger functions are something the game calls upon the particular event having taken place, they all start with on_* , for instance on_next_turn(turn); or on_next_phase(turn, side).

It is these functions you first provide in your scenario specific .lua files, and within them you then have the actions you want to take place at the time. They provide some parameters for you to help on determining what's going on, for instance the on_next_phase() gives you the current turn and side.

Trigger functions, as they currently stand, are:

[*] on_air_attack (x, y, pid, name, side, nation, points, strength)
[*] on_next_phase (turn, side)
[*] on_next_turn (turn)
[*] on_objective_capture (x, y, value, side)
[*] on_startup ()
[*] on_unit_kill (x, y, pid, name, side, nation, oid, orgname, points, strength, HQ, Leader)
[*] on_unit_reduce (x, y, trackid, pid, name, side, nation, oid, orgname, points, strength, HQ, Leader, loss)
[*] on_unit_reinforce (x, y, pid, name, side, nation, oid, orgname, points, strength, HQ, Leader)
[*] on_unit_release (pid, name, side, nation, oid, orgname, points, strength, HQ, Leader)
[*] on_unit_remove (x, y, pid, name, side, nation, oid, orgname, points, strength, HQ, Leader)


Action functions, then, are the stuff you want to happen when one of the events listed above happened, and the respective function in your in your scenario specific Lua file is called .

Action functions come in two flavors as well, one for getting more information from the game, and another for setting new values in place of the existing ones.

On the first, say if you need more information about some particular things, you'd use some of the "getter" functions to get them. You'd then have "setter" functions to pass back to the game engine.

For instance, you'd first figure out what the Ammo level is for the side your interested in by calling ammo_level(side), a "getter" function. As a parameter you provide it the side you're interested to learn about its current ammo level, and as a return value you get the said ammo level.

Then you then want to set a new value for the side's ammo level, you do it calling the set_ammo_level(side, value) function, a "setter", as youd guess. There you provide the side you want to change and the new ammo value to take place.

Here's the current set of functions, then: (list updated since I wrote this post)
ORIGINAL: berto


LUA EE FUNCTIONS

-------------------------------------------------------------------------------

on_air_attack (x, y, pid, name, side, nation, points, strength)
on_next_phase (turn, side)
on_next_turn (turn)
on_objective_capture (x, y, value, side)
on_startup ()
on_unit_kill (x, y, trackid, pid, name, side, nation, oid, orgname, points, strength, HQ, Leader)
on_unit_reduce (x, y, trackid, pid, name, side, nation, oid, orgname, points, strength, HQ, Leader, loss)
on_unit_reinforce (x, y, trackid, pid, name, side, nation, oid, orgname, points, strength, HQ, Leader)
on_unit_release (trackid, pid, name, side, nation, oid, orgname, points, strength, HQ, Leader)
on_unit_remove (x, y, trackid, pid, name, side, nation, oid, orgname, points, strength, HQ, Leader)

adaptive_ai (side, nation, index)
advantage ()
aggressiveness (side)
ai (side)
ai_index (parm)
ai_parameter (index)
air_support (side)
ammo_level (side)
arrived (id)
arty_ammo_level (side)
average_morale (side)
counter_airlevel (trackid)
counter_assault (trackid)
counter_defend (trackid)
counter_flags (trackid)
counter_hq (trackid)
counter_isairborne (trackid)
counter_ishq (trackid)
counter_isleader (trackid)
counter_leader (trackid)
counter_morale (trackid)
counter_name (trackid)
counter_nation (trackid)
counter_oid (trackid)
counter_orgname (trackid)
counter_pid (trackid)
counter_points (trackid)
counter_side (trackid)
counter_strength (trackid)
counter_type (trackid)
counter_x (trackid)
counter_y (trackid)
current_side ()
current_turn ()
current_visibility ()
debug (text)
event_points (side)
fow (side)
has_flag (flags, flag)
hexcoor (x, y)
inc_adaptive_ai (side, nation, index, increment)
inc_advantage (increment)
inc_aggressiveness (side, increment)
inc_air_support (side, increment)
inc_ammo_level (side, increment)
inc_arty_ammo_level (side, increment)
inc_event_points (side, increment)
inc_luav (index, value)
inc_morale_shift (nation, increment)
inc_reinforcement_prob (id, increment)
inc_release_prob (id, increment)
inc_smoke_ammo (side, increment)
inc_star_shells (side, increment)
isai (side)
isdisrupted (trackid)
isfixed (trackid)
isfow (side)
isisolated (trackid)
islowonammo (trackid)
isnight ()
losses (side)
loss_points (side)
luav (index)
map_center (x, y)
map_height ()
map_side (x, y)
map_slice (x, y)
map_trackid (x, y, number)
map_trackid_count (x, y)
map_up ()
map_width ()

map_up_half (x, y)
map_low_half (x, y)
map_left_half (x, y)
map_right_half (x, y)
map_up_left_quadrant (x, y)
map_up_right_quadrant (x, y)
map_low_right_quadrant (x, y)
map_low_left_quadrant (x, y)
map_nw_quadrant (x, y)
map_ne_quadrant (x, y)
map_se_quadrant (x, y)
map_sw_quadrant (x, y)
map_north_half (x, y)
map_south_half (x, y)
map_east_half (x, y)
map_west_half (x, y)
map_above (row, side)
map_below (row, side)
map_left_of (col, side)
map_right_of (col, side)

major_defeat ()
major_victory ()
max_ai_index ()
max_luav_index ()
message (title, string)
minor_defeat ()
minor_victory ()
morale_shift (nation)
next_turn ()
night (turn)
note (title, string)
objective_owner (x, y)
objective_points ()
objective_value (x, y)
other_side (side)
previous_turn ()
random (x)
reinforcement_flags (id)
reinforcement_hexcoor (id)
reinforcement_prob (id)
reinforcement_scatter (id)
reinforcement_turn (id)
reinforcement_x (id)
reinforcement_y (id)
release_prob (id)
release_turn (id)
released (id)
set_adaptive_ai (side, nation, index, value)
set_advantage (value)
set_aggressiveness (side, value)
set_air_support (side, value)
set_ammo_level (side, value)
set_arty_ammo_level (side, value)
set_event_points (side, value)
set_luav (index, value)
set_major_defeat (value)
set_major_victory (value)
set_minor_defeat (value)
set_minor_victory (value)
set_morale_shift (nation, value)
set_objective (x, y, value, side)
set_objective_owner (x, y, side)
set_objective_value (x, y, value)
set_reinforcement (id, x, y, turn, prob, flags, scatter)
set_reinforcement_flags (id, flags)
set_reinforcement_hexcoor (id, hexcoor)
set_reinforcement_prob (id, prob)
set_reinforcement_scatter (id, scatter)
set_reinforcement_turn (id, turn)
set_reinforcement_x (id, x)
set_reinforcement_y (id, y)
set_release (id, turn, prob)
set_release_prob (id, prob)
set_release_turn (id, turn)
set_smoke_ammo (side, value)
set_star_shells (side, value)
set_victory (majordefeat, minordefeat, minorvictory, majorvictory)
smoke_ammo (side)
star_shells (side)
strength (side)
total_points ()
total_strength (side)
x (hexcoor)
y (hexcoor)

-------------------------------------------------------------------------------
Visit us at: Campaign Series Legion
---
CS: Vietnam 1948-1967 < Available now
CS: Middle East 1948-1985 2.0 < 3.0 In the works
User avatar
Crossroads
Posts: 17498
Joined: Sun Jul 05, 2009 8:57 am

RE: Dev Diary #09: CS Event Engine

Post by Crossroads »

ORIGINAL: Crossroads

Here's the current function set, then:
ORIGINAL: berto


LUA EE FUNCTIONS

...

Quite a few of them, already! So let us put some of them into use.

ORIGINAL: Crossroads

At this stage, I've already got an initial list of ideas I want to try out. Here they are, in no particular order:

[*] I'd like to give both sides a briefing in the beginning as what their key tasks are.
[*] Later perhaps, I'd like to give the players feedback as how they are doing per achieving those tasks.

on_next_phase (turn, side)

Let us start by giving both players a specific briefing in the beginning of the game. For this, we'll use the on_next_phase (turn, side) function, as we want to give each player a briefing on their first turn Side A and Side B phase.

First, I create the lua file for my scenario. The name needs to match the scenario file name, which is "E01_Sirte1985_H2H.scn" , so the lua file will be called "E01_Sirte1985_H2H.lua".

I start with an empty file, and place the on_next_phase() function template there. Now the game will have an event trigger it will call everytime a new phase begins in that particular scenario.

The empty template won't do me much, so I'll put the code in to use the parameters I receive upon call. So first I check if it is turn 1, and if it is, I provide a message dialog for each side separately.

The message text is quite long, so here it is as a whole (with '\n' markers for a newline to appear within the message dialog):
"Commander, the Sirte operation is on! \n \n Your first task is to secure the SAM site, west of Sirte, with the SAS teams already there. Once the SAM battery is out of play, the Air assault can proceed immediately. Otherwise, they would need to approach in a more cautious manner, which takes time that we simply do not have. \n \n Good luck, Commander!"

And here is how it plays out. I put the new lua file to the \scenarios folder, fire up the game, and what do you know:

Image
Attachments
luadiary_1.jpg
luadiary_1.jpg (494.26 KiB) Viewed 584 times
Visit us at: Campaign Series Legion
---
CS: Vietnam 1948-1967 < Available now
CS: Middle East 1948-1985 2.0 < 3.0 In the works
User avatar
Crossroads
Posts: 17498
Joined: Sun Jul 05, 2009 8:57 am

RE: Dev Diary #09: CS Event Engine

Post by Crossroads »

ORIGINAL: Crossroads

And here is how it plays out. I put the new lua file to the \scenarios folder, fire up the game, and what do you know:

So let us recap what we did so far:

[*] I created a new, empty CS Event Engine file called "E01_Sirte1985_H2H.lua" , where the file name body matches that of the scenario file itself.
[*] I put the first trigger event there: function on_next_phase (turn, side). Now, the game will call this function everytime a next phase starts, passing me two parameters to use: the current turn, and current side.
[*] I then added the content to this trigger event, the stuff in the red square in the lua code. First I checked if it is turn one, and if it is, if it is Side A ("a", in lua code). If it is, I pop up a message for the Side A player (UK), if not it must be turn one but Side B (Libya), so he gets a briefing of its own. I will not touch the Libyan side for now, more of them later.

So far so good. We have the player briefing. So what is the conditional Air assault the Side A briefing talks about?

If you're familiar with the current Sirte 1. Prelude scenario, there's no events of course. In this new version, as you can see above, I added an SAS team already on ground, behind a ridge to a new Libyan objective, hosting a SAM Radar, Battery, and an understrength guarding unit.

Obviously, the idea would be that the SAS team captures that objective. But first, let us look at other changes to the scenario. The Air Assault troops are now set to arrive in turn 5 as reinforcements. There's other reinforcements there, too. See:


Image
Attachments
luadiary_2.jpg
luadiary_2.jpg (520.08 KiB) Viewed 584 times
Visit us at: Campaign Series Legion
---
CS: Vietnam 1948-1967 < Available now
CS: Middle East 1948-1985 2.0 < 3.0 In the works
User avatar
Crossroads
Posts: 17498
Joined: Sun Jul 05, 2009 8:57 am

RE: Dev Diary #09: CS Event Engine

Post by Crossroads »

ORIGINAL: Crossroads

Obviously, the idea would be that the SAS team captures that objective. But first, let us look at other changes to the scenario. The Air Assault troops are now set to arrive in turn 5 as reinforcements. There's other reinforcements there, too. See:

on_objective_capture (x, y, value, side)

Note the new value in the Schedule Dialog: the reinforcement ID. Yes, this can be used in the Event Engine to refer to a particular reinfocement, and to play around it.

But where do we play with it? It is time to introduce another trigger function: on_objective_capture (x, y, value, side)

Similarly, I add this trigger function template to my new scenario lua script, and provide it with some meat as well. What I want to happen, is that upon capturing the SAM site objective, the Brits will have their Air Assault reinforcements released earlier. If they miss out, at worse they arrive at turn 5 anyway, but important time - five turns out of eighteen - have been lost.

So here's the code, and here's how it played out upon capturing the objective. Note: this function is called by the game engine every time an objective is captured, so there's work remaining to figure out if it was the SAM site that indeed was captured.

Also, this time I the trigger function on_objective_capture() does not provide me with much of the information I need, so I need to figure them out by the "get" action functions:

[*] First I figure out if it was the Brits who captured an objective, checking the side parameter passed to me by the function.
[*] Then, I use the objective "x" and "y" parameters passed to me as well by the function to figure if it is the SAM site (at 26,4).
[*] So far so good! Then, I check if the turn is four, or less, and if it is,
[*] I set each of the Air Assault Regt reinforcements to take place next turn. set_reinforcement_turn() requires two input parameters, first the reinforcement ID (and this I need to know, see the Schedule Dialog above, the Air Assault reinforcement IDs are 1 through 5), and the turn the reinforcements are set to arrive.

As you see on_objective_capture () does not pass me the current turn, so I had to call the current_turn() action to learn about it. I stored the turn information to a local variable, and create another one for next turn # by adding one to it.

A bit more work this time, but here we are! By the way, I use a programmer's text editor that recognizes the lua syntax and color codes it for an easier read. Recommended, get one such as Notepad++ or JEdit, it will ease things up.

As for the Sirte 1. Prelude, as I managed to capture the SAM site on turn one, the air assault will now begin on turn two. Yay!
Image
Attachments
luadiary_3.jpg
luadiary_3.jpg (423.33 KiB) Viewed 584 times
Visit us at: Campaign Series Legion
---
CS: Vietnam 1948-1967 < Available now
CS: Middle East 1948-1985 2.0 < 3.0 In the works
User avatar
Crossroads
Posts: 17498
Joined: Sun Jul 05, 2009 8:57 am

RE: Dev Diary #09: CS Event Engine

Post by Crossroads »

ORIGINAL: Crossroads

A bit more work this time, but here we are! By the way, I use a programmer's text editor that recognizes the lua syntax and color codes it for an easier read. Recommended, get one such as Notepad++ or JEdit, it will ease things up.

And I stop here for now.

As you see from the above sample, having reinforcements arrive as a CS Event Engine action required already quite some coding.

We will provide lots of samples in the coming CSME 2.0, in form of documentation, and in form of being able to use existing scenario lua files as a basis, instead of starting from a clean slate.
Visit us at: Campaign Series Legion
---
CS: Vietnam 1948-1967 < Available now
CS: Middle East 1948-1985 2.0 < 3.0 In the works
User avatar
Crossroads
Posts: 17498
Joined: Sun Jul 05, 2009 8:57 am

RE: Dev Diary #09: CS Event Engine

Post by Crossroads »

ORIGINAL: Crossroads

And I stop here for now.

on_unit_reinforce (x, y, pid, name, side, nation, oid, orgname, points, strength, HQ, Leader)

Nah, let us introduce one more trigger funtion: on_unit_reinforce (x, y, pid, name, side, nation, oid, orgname, points, strength, HQ, Leader). Quite a lot of parameters I get that one, so it will be an easier function to implement.

This function is called everytime a reinforcement is called to arrive from Schedule Dialog. If needed, each arrival could then trigger something to happen. I'll do two things here.

First, I'll have Air Assault HQ report the player his next task
Second, I'll have the Lynx Gunship leader report that they've only got four ATGM missile loads (ie. I've provided no Lynx HQ where they could get a reload from). Vital information!

To achieve this,

[*] I place the trigger function template to my lua file
[*] Just to do this in various ways, I first check if the reinforcement is the Gazelle flight who transports the Airborne Bq HQ (Platoon ID P096524 but omit the P and the leading zero), or if not, if it is the reinforcement set to arrive in hex (66,1), the Lynx leader.

Each case gets its own message to display.

And here we go, from previous screen capture I click the UK turn to finish, click over the Libyan turn, and click the UK turn #2 to begin:

[1] There's the command report informing there's reinforcements (aha!)
[2] Schedule Dialog tells me what to expect - see Air assault reinforcements 1 through 5 are now all arriving on turn 2
[3] I click them to arrive one by one
[4] HQ upon its arrival informs me of my next task as the UK player

From Airborne HQ
"Commander, Air assault is ON! FYI: once we secure one of the Sirte ports, the first elements of the Landing Force will arrive to aid us! Godspeed!"

[5] Lynx flight informs me they can't reload once they're out of ATGMs.

From Lynx Leader:
"Lynx Alpha Leader to Sirte CP: Alpha One and Alpha Two are now entering the Sirte airspace. We only have ATGM loads for four missions per flight, use them wisely! Awaiting orders..."

Neat, eh [:)]


Image
Attachments
luadiary_4.jpg
luadiary_4.jpg (387.76 KiB) Viewed 584 times
Visit us at: Campaign Series Legion
---
CS: Vietnam 1948-1967 < Available now
CS: Middle East 1948-1985 2.0 < 3.0 In the works
User avatar
Crossroads
Posts: 17498
Joined: Sun Jul 05, 2009 8:57 am

RE: Dev Diary #09: CS Event Engine

Post by Crossroads »

OK, now I stop.

Thoughts, comments, what else you'd like to see?
Visit us at: Campaign Series Legion
---
CS: Vietnam 1948-1967 < Available now
CS: Middle East 1948-1985 2.0 < 3.0 In the works
dox44
Posts: 653
Joined: Sun May 07, 2000 8:00 am
Location: the woodlands, texas

RE: Dev Diary #09: CS Event Engine

Post by dox44 »

ok so far so good.

opens up all kinds of stuff. never tried using lua and didn't know how anyway.

i play another matrix game (Command) that scenario designers can use lua. really makes for some interesting
situations.

thanks for taking time to explain this.

casebier
User avatar
Crossroads
Posts: 17498
Joined: Sun Jul 05, 2009 8:57 am

RE: Dev Diary #09: CS Event Engine

Post by Crossroads »

ORIGINAL: casebier

ok so far so good.

opens up all kinds of stuff. never tried using lua and didn't know how anyway.

i play another matrix game (Command) that scenario designers can use lua. really makes for some interesting
situations.

thanks for taking time to explain this.

casebier


Sure thing casebier!

There are so many possibilities. For the Air Assault reinforcement thing, I could actually have them originally arrive from the far eastern map edge, in order to depict them arriving while the SAM threat remains. So that's how I'd set it up in the Scenario Editor.

But upon SAM site being taken out, in addition to have them arrive earlier, I could change their arrival co-ordinates to be directly above the SAS troops, to depict now they could have flown a more direct route into Sirte [:)]

By the way, I had actually implemented one more trigger function.

Here's the list of ideas I had in the opening post, with the ones not implemented so far showing up:
ORIGINAL: Crossroads

At this stage, I've already got an initial list of ideas I want to try out. Here they are, in no particular order:

[*] Later perhaps, I'd like to give the players feedback as how they are doing per achieving those tasks.
[*] The Brits paratroopers may be used to being surrounded, too, but I'd like to have their supply situation worsen throughout the game play, for one. Perhaps some other difficulties as well?
[*] Losses might have an effect as well. Lose your commander, and everyone's Morale goes down?

on_next_turn (turn)

So, I had in fact provided the UK worsening supply situation logic in a lua file.

Just to do it differently I put it to on_next_turn() trigger function, it could have been in the on_next_phase() one as well.

Here's the code, to see it working check the above screenshot again: It is turn #2 and the UK supply levels are down to 78, while Libyan ones remain at 80 [:)]

Image
Attachments
luadiary_5.jpg
luadiary_5.jpg (109.17 KiB) Viewed 587 times
Visit us at: Campaign Series Legion
---
CS: Vietnam 1948-1967 < Available now
CS: Middle East 1948-1985 2.0 < 3.0 In the works
User avatar
berto
Posts: 21461
Joined: Wed Mar 13, 2002 1:15 am
Location: metro Chicago, Illinois, USA
Contact:

RE: Dev Diary #09: CS Event Engine

Post by berto »


This is all a work-in-progress, still in the beta stage. In the message dialogs, you might see where at the end of some lines, in the display the line-ending word is clipped. A glitch. Will be fixed.
Campaign Series Legion https://cslegion.com/
Campaign Series Lead Coder https://www.matrixgames.com/forums/view ... hp?f=10167
Panzer Campaigns, Panzer Battles Lead Coder https://wargameds.com
User avatar
Crossroads
Posts: 17498
Joined: Sun Jul 05, 2009 8:57 am

RE: Dev Diary #09: CS Event Engine

Post by Crossroads »

Let us finish the to-do list from the opening post, two things remaining there, first the feedback event, then the unit loss event:
ORIGINAL: Crossroads

At this stage, I've already got an initial list of ideas I want to try out. Here they are, in no particular order:

[*] I'd like to give both sides a briefing in the beginning as what their key tasks are.
[*] Later perhaps, I'd like to give the players feedback as how they are doing per achieving those tasks.
[*] I want events too, of course. So how about a few events that can trigger the arrival of reinforcements. Given how things go, they might come sooner, or later. Or not at all.
[*] For instance, I'll add a Libyan SAM site to the coast, and have some British SAS troops there to take it out. Only once its out can the Air assault begin.
[*] The Brits paratroopers may be used to being surrounded, too, but I'd like to have their supply situation worsen throughout the game play, for one. Perhaps some other difficulties as well?
[*] Losses might have an effect as well. Lose your commander, and everyone's Morale goes down?

Let us do the feedback event first, for the UK player.

Recall in the opening phase he is informed he needs to clear the SAM site quickly, in order for the Air Assault to arrive (earlier). Let us check if he's done so by turn 3, and if not, let us give him a notification. For that, there's the objective_owner(x, y) function to check the side that owns the given objective ("a", or "b").

This time, I used note() instead of message(), to have a smaller dialog for this one-liner of a hairblower treatment for the Brit player [:)]

Note the UK supply situation has gone down to 76 by turn three. By turn 10 it will be 60. Things are getting tougher and tougher for them, if they waste too much time on getting their task done!!

PS: if for real I'd probably need to add some additional checks, like what if the UK player indeed captured the SAM site on turn #1, then evacuated it for the Libyan player to recapture it. For the sample I am doing here, I am not going to worry about that level of detail for now.

^^ Edit: What the heck, added a check that the (first element of) Air assault has not arrived. That should fix the issue above [:)]

Image
Attachments
luadiary_6.jpg
luadiary_6.jpg (480.64 KiB) Viewed 587 times
Visit us at: Campaign Series Legion
---
CS: Vietnam 1948-1967 < Available now
CS: Middle East 1948-1985 2.0 < 3.0 In the works
User avatar
Crossroads
Posts: 17498
Joined: Sun Jul 05, 2009 8:57 am

RE: Dev Diary #09: CS Event Engine

Post by Crossroads »

ORIGINAL: Crossroads

At this stage, I've already got an initial list of ideas I want to try out. Here they are, in no particular order:

[*] I'd like to give both sides a briefing in the beginning as what their key tasks are.
[*] Later perhaps, I'd like to give the players feedback as how they are doing per achieving those tasks.
[*] I want events too, of course. So how about a few events that can trigger the arrival of reinforcements. Given how things go, they might come sooner, or later. Or not at all.
[*] For instance, I'll add a Libyan SAM site to the coast, and have some British SAS troops there to take it out. Only once its out can the Air assault begin.
[*] The Brits paratroopers may be used to being surrounded, too, but I'd like to have their supply situation worsen throughout the game play, for one. Perhaps some other difficulties as well?
[*] Losses might have an effect as well. Lose your commander, and everyone's Morale goes down?

I still need to finish the final to-do item of an event triggered by a unit loss. There's a trigger function already for that too, called on_unit_kill (), which is called by the game engine every time a unit is reduced to 0 strength and removed from map as a total kill.

There's a new version of it coming that I need though, so that will have to wait for the next week.

Meanwhile, any questions or comments let me know!
Visit us at: Campaign Series Legion
---
CS: Vietnam 1948-1967 < Available now
CS: Middle East 1948-1985 2.0 < 3.0 In the works
User avatar
budd
Posts: 3070
Joined: Sat Jul 04, 2009 3:16 pm
Location: Tacoma

RE: Dev Diary #09: CS Event Engine

Post by budd »

ORIGINAL: Crossroads

ORIGINAL: Crossroads

At this stage, I've already got an initial list of ideas I want to try out. Here they are, in no particular order:

[*] I'd like to give both sides a briefing in the beginning as what their key tasks are.
[*] Later perhaps, I'd like to give the players feedback as how they are doing per achieving those tasks.
[*] I want events too, of course. So how about a few events that can trigger the arrival of reinforcements. Given how things go, they might come sooner, or later. Or not at all.
[*] For instance, I'll add a Libyan SAM site to the coast, and have some British SAS troops there to take it out. Only once its out can the Air assault begin.
[*] The Brits paratroopers may be used to being surrounded, too, but I'd like to have their supply situation worsen throughout the game play, for one. Perhaps some other difficulties as well?
[*] Losses might have an effect as well. Lose your commander, and everyone's Morale goes down?

I still need to finish the final to-do item of an event triggered by a unit loss. There's a trigger function already for that too, called on_unit_kill (), which is called by the game engine every time a unit is reduced to 0 strength and removed from map as a total kill.

There's a new version of it coming that I need though, so that will have to wait for the next week.

Meanwhile, any questions or comments let me know!
I want events too, of course. So how about a few events that can trigger the arrival of reinforcements. Given how things go, they might come sooner, or later. Or not at all.

Sounds exciting. The highlighted above should go along way to balance things and keep scenarios/campaigns interesting, especially in PBEM.
Enjoy when you can, and endure when you must. ~Johann Wolfgang von Goethe

"Be Yourself; Everyone else is already taken" ~Oscar Wilde

*I'm in the Wargamer middle ground*
I don't buy all the wargames I want, I just buy more than I need.
User avatar
76mm
Posts: 4765
Joined: Sun May 02, 2004 4:26 am
Location: Washington, DC

RE: Dev Diary #09: CS Event Engine

Post by 76mm »

This sounds awesome. And while the coding is important, please don't neglect the documentation, so that more average schmo players rather than coding gurus can figure out how to use it. This thread is a helpful start, but just sayin'...
User avatar
berto
Posts: 21461
Joined: Wed Mar 13, 2002 1:15 am
Location: metro Chicago, Illinois, USA
Contact:

RE: Dev Diary #09: CS Event Engine

Post by berto »


No worry. This will all be more than adequately documented, with copious examples and comments.
Campaign Series Legion https://cslegion.com/
Campaign Series Lead Coder https://www.matrixgames.com/forums/view ... hp?f=10167
Panzer Campaigns, Panzer Battles Lead Coder https://wargameds.com
User avatar
Crossroads
Posts: 17498
Joined: Sun Jul 05, 2009 8:57 am

RE: Dev Diary #09: CS Event Engine

Post by Crossroads »

ORIGINAL: Crossroads


I still need to finish the final to-do item of an event triggered by a unit loss. There's a trigger function already for that too, called on_unit_kill (), which is called by the game engine every time a unit is reduced to 0 strength and removed from map as a total kill.

There's a new version of it coming that I need though, so that will have to wait for the next week.

... and here it is!

ORIGINAL: berto


In today's release, I have added trackid as a parameter to these on_unit_*() functions:

on_unit_kill (x, y, trackid, pid, name, side, nation, oid, orgname, points, strength, HQ, Leader)
on_unit_reinforce (x, y, trackid, pid, name, side, nation, oid, orgname, points, strength, HQ, Leader)
on_unit_release (trackid, pid, name, side, nation, oid, orgname, points, strength, HQ, Leader)
on_unit_remove (x, y, trackid, pid, name, side, nation, oid, orgname, points, strength, HQ, Leader)

If you have used any of those functions in your <scenario>.lua files, you will need to edit in those trackid references.

Sooner or later, I will have to mass edit the scenario placeholder .lua files to do the same (also to introduce the on_startup() function).

on_unit_kill (x, y, trackid, pid, name, side, nation, oid, orgname, points, strength, HQ, Leader)

Missing piece, trackid, or Tracking ID, was now added to these trigger functions. Now it's possible to figure out the exact unit, based on the individual Tracking ID each of them receives in scenario specific *.PRG file. Be it a Battalion sized or Corps sized battle, each unit is now uniquely tracked!!

Let us put this to use. In this quite busy screenshot, see the new function, (1) should a unit get killed, I first put a message out (2) as which unit (Organizational name, Tracking ID, and Platoon ID) it was that got killed. Then, I check if it was the British Airborne HQ, in which case the Libyans get 50 Event Points (3) added to their tally.

Yes, with Events, it is not possible to assign Victory points as well [:)]

Image
Attachments
luadiary_8.jpg
luadiary_8.jpg (478.76 KiB) Viewed 587 times
Visit us at: Campaign Series Legion
---
CS: Vietnam 1948-1967 < Available now
CS: Middle East 1948-1985 2.0 < 3.0 In the works
Deepstuff3725
Posts: 157
Joined: Sat Mar 01, 2014 4:38 pm
Location: Indianapolis, IN, USA

RE: Dev Diary #09: CS Event Engine

Post by Deepstuff3725 »

Really liking the "events" enhancements being worked on. i like to create scenarios, and i can envision how this can take scenario creation to a whole new level.
Will it be fairly easy to edit the messages from HQ for a scenario? I think it would be cool to create a scenario and be able to edit the messages a player will receive depending on triggers and how the scenario unfolds. For example, in Eastern Front III, if the Germans are not doing well in a scenario then messages might say things like "we're falling behind in reaching our objectives. You don't want to disappoint the Furor."

In the messages, could it be possible to list the player's name? For instance a player can type in the name they want to use for the scenario, say Major Gerhard Schneider. Then as the scenario is played, the player will see messages referring to him as "Major Schneider" in the scenario.


User avatar
Crossroads
Posts: 17498
Joined: Sun Jul 05, 2009 8:57 am

RE: Dev Diary #09: CS Event Engine

Post by Crossroads »

ORIGINAL: Deepstuff123

Really liking the "events" enhancements being worked on. i like to create scenarios, and i can envision how this can take scenario creation to a whole new level.
Will it be fairly easy to edit the messages from HQ for a scenario? I think it would be cool to create a scenario and be able to edit the messages a player will receive depending on triggers and how the scenario unfolds. For example, in Eastern Front III, if the Germans are not doing well in a scenario then messages might say things like "we're falling behind in reaching our objectives. You don't want to disappoint the Furor."

Hello Deepstuff, yes, it is very easy to add a storyboard to the game, with the relative success (or the lack of it) results in various feedback. For instance with the sample provided here the UK player is first instructed to clear the SAM site quickly in order for the Air Assault to commence (and congratulated when he does so), and in the beginning of turn 3 it is then checked if the said objective is taken. If not, he's told to step on it!

Similarly, it is quite possible to track progress with the various functions available and then based on that to provide feedback - good or bad - to the player. I agree this adds to the immersion of the scenario being played quite nicely.
ORIGINAL: Deepstuff123
In the messages, could it be possible to list the player's name? For instance a player can type in the name they want to use for the scenario, say Major Gerhard Schneider. Then as the scenario is played, the player will see messages referring to him as "Major Schneider" in the scenario.

While there isn't anything exactly like that at the moment, it is quite possible to fire up the Organization Editor and input one's own name to the scenario ORG file before playing that scenario, to replace the commander name there.

Also, as part of designing a scenario, the designer can put whatever the commander name in place as he prefers, and then use that name on the player feedback.
Visit us at: Campaign Series Legion
---
CS: Vietnam 1948-1967 < Available now
CS: Middle East 1948-1985 2.0 < 3.0 In the works
Post Reply

Return to “Campaign Series: Middle East 1948-1985”