CSlint How-To

Post new scenarios and mods here to share with other gamers.

Moderator: Campaign Series Matrix Edition Development Group

User avatar
berto
Posts: 21461
Joined: Wed Mar 13, 2002 1:15 am
Location: metro Chicago, Illinois, USA
Contact:

Re: CSlint How-To

Post by berto »

csmklua.pl


csmklua.pl is a Perl script (program) to create starter CSEE (Campaign Series Event Engine) scenario Lua (.lua) files. csmklua.pl references the .scn & .org files when doing this.

(This will document how to use the csmklua.pl tool. It will not explore in detail the contents of the generated scenario Lua file, much less how to flesh it out. That will be discussed elsewhere in other forum threads, and other documentation venues.)

(Note: In the course of preparing this, we discovered some csmklua.pl bugs in the currently available public CSlint release. The fixed csmklua.pl will be included in CSVN v1.20 and later. Until then, if you try the exercises following, your results might vary.)

Start by displaying the program help:



rober@Rob10rto ~/cslint
$ ./csmklua.pl -h

Usage: csmklua.pl [-h|-help] [{+|-}G|-debug] [-a[bbreviate]] [-p[rune]] [-r[everse]] [-b[locks]] -g[ame] {me|vn|cw|ef|wf|pf} -f <scenario file> -o <lua file>



Let's try generating a Lua file for the Vietnam scenario VN_550921_Rung_Sat:



rober@Rob10rto ~/cslint
$ ./csmklua.pl -a -p -b -g vn -f VN_550921_Rung_Sat.scn
------------------------------------------------------------------------------------------------------------------------

-- VN_550921_Rung_Sat.lua

-- Author:
-- Scripter:

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

function on_startup () -- DO NOT REMOVE
[... output omitted for brevity ...]



Whoa! Hundreds of lines flood the terminal display. That's not what we want.

No, what we want is to capture that output to a file. We do that by:



rober@Rob10rto ~/cslint
$ ./csmklua.pl -a -p -b -g vn -f VN_550921_Rung_Sat.scn -o VN_550921_Rung_Sat_TEST.lua



Verifying:



rober@Rob10rto ~/cslint
$ ls -l "$VN"/Scenarios/VN_550921_Rung_Sat_TEST.lua
-rw-r--r--+ 1 rober rober 66535 May 10 06:36 '/cygdrive/c/Games/Matrix Games/Vietnam/vietnam/Scenarios/VN_550921_Rung_Sat_TEST.lua'



Yes indeed, we have successfully created the VN_550921_Rung_Sat_TEST.lua file. (Note the date & time, which is correct at the time I write this.)

Normally, you would not name your auto-generated Lua file as 'TEST' this or that. But I do it in this case -- I do not specify '-o VN_550921_Rung_Sat.lua' -- since I don't want to clobber the existing Lua file by that name.

The

-f <scenario file>

always references a .scn file in the Scenarios folder. By default, the -o dumps the generated Lua file to the same Scenarios folder. You might instead place the file elsewhere, for example



rober@Rob10rto ~/cslint
$ ./csmklua.pl -a -p -b -g vn -f VN_550921_Rung_Sat.scn > /cygdrive/c/Temp/csmklua_TEST.lua

rober@Rob10rto ~/cslint
$ ls -l /cygdrive/c/Temp/csmklua_TEST.lua
-rwxrw-r--+ 1 rober rober 66530 May 10 06:43 /cygdrive/c/Temp/csmklua_TEST.lua



which would locate the newly created file in the /cygdrive/c/Temp (C:\Temp) folder.

(Interpret that '>' as in effect a "funnel" redirecting output (on the left side of the '>') to a file (on the right side of the '>').)

Or, because experimenting, you might just want to pipe the csmklua.pl output to the 'less' command for viewing purposes:



rober@Rob10rto ~/cslint
$ ./csmklua.pl -a -p -b -g vn -f VN_550921_Rung_Sat.scn | less



csmklua.pl has several options (see the '-h' output above).

  • [-a[bbreviate]]

says to abbreviate several common unit org names, such as 'COMPANY' -> 'COY', 'BATTALION' -> 'BTN', etc.

In the csmklua.pl code, we (currently) have:



sub abbreviate() {
local(*oname) = @_;

$oname =~ s/PLATOON/PLT/g;
$oname =~ s/COMPANY/COY/g;
$oname =~ s/BATTALION/BTN/g;
$oname =~ s/REGIMENT/RGT/g;
$oname =~ s/BRIGADE/BRG/g;
$oname =~ s/DIVISION/DIV/g;
#$oname =~ s/CORPS//g;
#$oname =~ s/ARMY//g;

$oname =~ s/BATTERY/BTY/g;
$oname =~ s/RECONNAISSANCE/RECON/g;
$oname =~ s/INFANTRY/INF/g;
$oname =~ s/HEADQUARTERS/HQ/g;
}



That list is not exhaustive. We might decide eventually to add still more abbreviations.

Why would you want to abbreviate like that? It's because the auto-generated unit names can otherwise be quite lengthy, therefore hard to read and unwieldy. Compare this

_RECONNAISSANCE_COMPANY_50_133 [unabbreviated]

with this

_RECON_COY_50_133 [abbreviated]

The latter is more readable, especially in a dense, wordy block of Lua code. Anything to reduce clutter helps,

The next option

  • [-p[rune]]

says to prune from the auto-generated unit org list any organizations present in the scenario .org file but missing in the .scn file, hence absent from the scenario. In this Lua file snippet auto-generated without using the '-p' option



...
_2ND_58TH_INF_COY_55_B_309 = {310,311,312,313} -- [C] [1102239] 2nd/58th Infantry Company 55 - B
_1ST_PLT_310 = {310} -- [P] [32,36] [112007] ARVN Infantry Platoon 55 B
_2ND_PLT_311 = {311} -- [P] [32,36] [112007] ARVN Infantry Platoon 55 B
_3RD_PLT_312 = {312} -- [P] [32,35] [112007] ARVN Infantry Platoon 55 B
_60MM_MORTARS_314 = {314} -- [P] [] []
_3RD_58TH_INF_COY_55_B_315 = {316,317,318,319} -- [C] [1102239] 3rd/58th Infantry Company 55 - B
_1ST_PLT_316 = {316} -- [P] [27,38] [112007] ARVN Infantry Platoon 55 B
_2ND_PLT_317 = {317} -- [P] [27,38] [112007] ARVN Infantry Platoon 55 B
_3RD_PLT_318 = {318} -- [P] [27,39] [112007] ARVN Infantry Platoon 55 B
_60MM_MORTARS_320 = {320} -- [P] [] []
...



Note by the '[] []' where the _60MM_MORTARS_314 and _60MM_MORTARS_320 are not present in the scenario, hence the first '[]' empty of any hex coordinates. Using '-p', you would instead see:



...
_2ND_58TH_INF_COY_55_B_309 = {310,311,312,313} -- [C] [1102239] 2nd/58th Infantry Company 55 - B
_1ST_PLT_310 = {310} -- [P] [32,36] [112007] ARVN Infantry Platoon 55 B
_2ND_PLT_311 = {311} -- [P] [32,36] [112007] ARVN Infantry Platoon 55 B
_3RD_PLT_312 = {312} -- [P] [32,35] [112007] ARVN Infantry Platoon 55 B
_3RD_58TH_INF_COY_55_B_315 = {316,317,318,319} -- [C] [1102239] 3rd/58th Infantry Company 55 - B
_1ST_PLT_316 = {316} -- [P] [27,38] [112007] ARVN Infantry Platoon 55 B
_2ND_PLT_317 = {317} -- [P] [27,38] [112007] ARVN Infantry Platoon 55 B
_3RD_PLT_318 = {318} -- [P] [27,39] [112007] ARVN Infantry Platoon 55 B
...



Those two mortar units are not listed.

You will almost always want to use the '-p' option.

The option

  • [-r[everse]]

has the unit orgs listed in reverse, if for some strange reason you really need to do that.

The option

  • [-b[locks]]

creates, in the battle_plan functions, unit blocks like this:



...

-- _1ST_PARACHUTE_WEAPONS_COY_55_183 -- 1st Parachute Weapons Company 55
do local units = _1ST_PARACHUTE_WEAPONS_COY_55_183
if _1ST_PARACHUTE_BTN_55_A_169_READY_TURN then
if objective_owner(OBJECTIVES[9]) == BX_SIDE then
attack_way_point(units, {"50,21", "52,23", OBJECTIVES[9]}, NODIR, 2, 50, ATTACK_NORMAL)
elseif objective_owner(OBJECTIVES[10]) == BX_SIDE then
attack_way_point(units, {"52,27", OBJECTIVES[10]}, NODIR, 2, 50, ATTACK_NORMAL)
else -- no available water transports (see above), so just have them defend OBJECTIVES[10]
defend_way_point(units, {"51,25", "52,27", OBJECTIVES[10]}, NODIR, 1, 100, DEFEND_NORMAL)
end
end
end
-- _81MM_MORTAR_187 -- Parachute M1 81mm Mortars

...



'do local units = ... end' blocks are created for all company-sized units (the organization level best suited for SAI scripting) and unattached platoons and HQs, leaders, etc.

In set_org_lists(), the _1ST_PARACHUTE_WEAPONS_COY_55_183 is listed as:



_1ST_PARACHUTE_WEAPONS_COY_55_183 = {184,185,187} -- [C] [1102245] 1st Parachute Weapons Company 55
_ENGINEER_184 = {184} -- [P] [T1: 48,19] [112080] Parachute Engineer Platoon
_MMG_185 = {185} -- [P] [T1: 48,19] [112077] Parachute M1919A4 Machine Gun
_81MM_MORTAR_187 = {187} -- [P] [T1: 48,19] [111033] Parachute M1 81mm Mortars



In the battle_plan function, the mortar unit



-- _81MM_MORTAR_187 -- Parachute M1 81mm Mortars



is separated out into its own line. In the preceding 'do ... end' block, you will be giving orders to the _1ST_PARACHUTE_WEAPONS_COY_55_183 as a whole. Usually, the infantry, machine guns etc. will lead the charge; the mortars will stay back from the front-line action. The separate _81MM_MORTAR_187 line is there reminding you to, for the mortar unit, override its more general company orders with platoon-specific orders more suited to behind-the-lines support units. (This will become clearer in later, separate how-tos.)

Without the '-b' option, there would be no such blocks; the battle_plan functions would be generally empty. You would have to build your unit orders code from scratch. It is much more convenient for csmklua.pl to create the unit orders blocks framework. Also, with csmklua.pl '-b' accounting unerringly for each and every company and platoon etc., you will not miss anything. If you DIY (by not using '-p'), you might overlook one or more units, hence they might go without orders. So most often, be sure to use '-b'.

Note: After using csmklua.pl to make a scenario Lua file, it is good practice to immediately check the auto-generated .lua file using csluachk.pl. More on csluachk.pl elsewhere.

There is much, much more to say about CSEE/SAI scripting, much more to explain about fleshing out the starter scenario Lua scripts that csmklua.pl auto-generates for you. But the above should be enough to get you started.

If you have questions, just ask here in the Forum.

Good luck! Happy CSEE/SAI scripting!
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
berto
Posts: 21461
Joined: Wed Mar 13, 2002 1:15 am
Location: metro Chicago, Illinois, USA
Contact:

Re: CSlint How-To

Post by berto »

csluachk.pl


csluachk.pl is a Perl script (program) to check CSEE Lua (.lua) files for various issues.

(This will document how to use the csluachk.pl tool. It will not explore in detail the layout and organization of a scenario Lua file, much less how to flesh it out. That will be discussed elsewhere in other forum threads, and other documentation venues.)

(Note: In the course of preparing this, we discovered some csluachk.pl bugs in the currently available public CSlint release. The fixed csluachk.pl will be included in CSVN v1.20 and later. Until then, if you try the exercises following, your results might vary.)

Start by displaying the program help:



rober@Rob10rto ~/cslint
$ ./csluachk.pl -h

Usage: csluachk.pl [-h|-help] [{+|-}G|-debug] [{+|-}n] [{+|-}w] [{+|-}e] -g[ame] {me|vn|cw|ef|wf|pf} [-f <filename>]



Let's try checking the Vietnam Lua files, but initially only ERRORs:



rober@Rob10rto ~/cslint
$ ./csluachk.pl -n -w +e -g vn
[nil]



The output is '[nil]', meaning to say there is no output. This is good! No output indicates no ERRORs.

Recall that with every CSlint QA check utility, the basic options



+|-n show/don't show notices
+|-w show/don't show warnings
+|-e show/don't show errors



are to display, using '+' (plus), or not display (ignore), using '-' (minus)

  • NOTICE -- issues that may or may not be significant, mainly are not; maybe 1 in 100 notices are truly significant; there will be many false positives here!
  • WARNING -- issues that might be significant, but are not showstoppers; maybe 1 in 10 warnings are important
  • ERROR -- showstopper issues, outright errors; except for known false positives, every error will usually be important

Now let's try checking for WARNINGs (and ERRORs):



rober@Rob10rto ~/cslint
$ ./csluachk.pl -n +w +e -g vn
WARNING: in BC_670601_Bootcamp_01.lua, referenced just once: _101ST_LEADER_AND_PLATOON
WARNING: for BC_670601_Bootcamp_01.lua, possible missing or mistaken fired indicator
WARNING: for BC_670601_Bootcamp_01.lua, possible missing or mistaken arty fired indicator
WARNING: for BC_670601_Bootcamp_01.lua, possible missing or mistaken ammo level adjustment
WARNING: for BC_670601_Bootcamp_02.lua, possible missing or mistaken fired indicator
WARNING: for BC_670601_Bootcamp_02.lua, possible missing or mistaken arty fired indicator
WARNING: for BC_670601_Bootcamp_02.lua, possible missing or mistaken ammo level adjustment
WARNING: for BC_670601_Bootcamp_03.lua, possible missing or mistaken fired indicator
WARNING: for BC_670601_Bootcamp_03.lua, possible missing or mistaken arty fired indicator
WARNING: for BC_670601_Bootcamp_03.lua, possible missing or mistaken ammo level adjustment
[... output omitted for brevity ...]



Whoa! Hundreds of lines flood the terminal display. Let's output to the 'less' command to make that more manageable:



rober@Rob10rto ~/cslint
$ ./csluachk.pl -n +w +e -g vn | less



More typically, you would check a single .lua file. For instance, after revising a .lua file you are modding. (As developers of the game, we often check all of the .lua files en masse.)

Let's try checking the file VN_550921_Rung_Sat.lua:



rober@Rob10rto ~/cslint
$ ./csluachk.pl -n +w +e -g vn -f VN_550921_Rung_Sat.lua
WARNING: for VN_550921_Rung_Sat.lua:552: _LOGISTIC_55_LEVEL_2_263 possible orgtrk 263 track 266 mismatch
WARNING: for VN_550921_Rung_Sat.lua, possible missing or mistaken assault_attack_aggressiveness_effect adjustment



As WARNINGs, those may or may not be significant issues. Something to look at eventually, though.

Adding NOTICEs to the mix:



rober@Rob10rto ~/cslint
$ ./csluachk.pl +n +w +e -g vn -f VN_550921_Rung_Sat.lua
WARNING: for VN_550921_Rung_Sat.lua:552: _LOGISTIC_55_LEVEL_2_263 possible orgtrk 263 track 266 mismatch
NOTICE: in VN_550921_Rung_Sat.lua, referenced just twice: ARVN_COMMENDATIONS
NOTICE: in VN_550921_Rung_Sat.lua, referenced just twice: OBJECTIVES13_RECAPTURED
NOTICE: in VN_550921_Rung_Sat.lua, referenced just twice: OBJECTIVES21_CAPTURED
WARNING: for VN_550921_Rung_Sat.lua, possible missing or mistaken assault_attack_aggressiveness_effect adjustment



Not bad! Many scenario Lua files will have not a few WARNINGs, and very many NOTICEs. How many? Checking all 112 (current) scenario Lua files, there are



rober@Rob10rto ~/cslint
$ ./csluachk.pl -n +w -e -g vn | wc -l
935



935 WARNINGs reported, and



rober@Rob10rto ~/cslint
$ ./csluachk.pl +n -w -e -g vn | wc -l
3290



a whopping 3290 NOTICEs!

Many false positives there. For technical reasons, it is difficult to effectively impossible to raise a yellow caution flag unerringly. With practice and experience, you gain a better sense what is and is not worth paying closer attention to.

It just so happens that many of the WARNINGs and NOTICEs are instances of "referenced just once" or "referenced just twice". You can filter those out of the output by means of the Linux 'egrep' command, for example:



rober@Rob10rto ~/cslint
$ ./csluachk.pl +n +w -e -g vn | egrep -iv "referenced just"



You could use 'egrep' to filter in only certain things, for example:



rober@Rob10rto ~/cslint
$ ./csluachk.pl -n -w +e -g vn | egrep -i "undefined.*nil value"



And so on, in so many different variations and combinations of the standard Linux tools.

Here, without commentary, are some sample issues that csluachk.pl has reported recently (when CSVN was still under development and preceding release):



ERROR: for VN_550921_Rung_Sat.lua:763: mistaken side: US_SIDE
ERROR: for VN_550921_Rung_Sat.lua:766: mistaken side: US_SIDE
ERROR: for VN_550921_Rung_Sat.lua:768: mistaken side: US_SIDE
ERROR: for VN_650529_Ba_Gia_A.lua:521: mistaken side: VC_SIDE
ERROR: for VN_651205_Ap_Nha_Mat.lua:705: mistaken side: NVA_SIDE
ERROR: for VN_660309_A_Shau.lua:582: mistaken side: VC_SIDE
ERROR: for VN_670401_Week_in_Mekong.lua:4848: duplicate title: Day Five 3/60 Not Laager
ERROR: for VN_671104_Hill_1338.lua, scn trackid 862 not found in VN_671104_Hill_1338.lua
ERROR: for VN_671104_Hill_1338.lua:4442: duplicate title: Build Firebase



ERROR: for VN_660601_Week_In_Binh_Long.lua:27184: counter variable mismatch: TIME_LRRP_IN_CAMBODIA_NORTH = (TTIME_LRRP_IN_CAMBODIA_NORTH or 0) + 1
ERROR: for VN_660601_Week_In_Binh_Long.lua:27238: counter variable mismatch: TIME_LRRP_IN_CAMBODIA_CENTER_NORTH = (TTIME_LRRP_IN_CAMBODIA_NORTH or 0) + 1
ERROR: for VN_660601_Week_In_Binh_Long.lua:27292: counter variable mismatch: TIME_LRRP_IN_CAMBODIA_CENTER_SOUTH = (TTIME_LRRP_IN_CAMBODIA_SOUTH or 0) + 1
ERROR: for VN_660601_Week_In_Binh_Long.lua:27346: counter variable mismatch: TIME_LRRP_IN_CAMBODIA_SOUTH = (TTIME_LRRP_IN_CAMBODIA_SOUTH or 0) + 1
[... output omitted for brevity ...]
ERROR: for VN_660601_Week_In_Binh_Long.lua:28241: undefined (nil value) org name: _LRRP_TEAM_1_2350
ERROR: for VN_660601_Week_In_Binh_Long.lua:28255: undefined (nil value) org name: _LRRP_TEAM_1_2352
ERROR: for VN_660601_Week_In_Binh_Long.lua:28262: undefined (nil value) org name: _LRRP_TEAM_1_2351



ERROR: for IC_510530_DR2_Chaos.lua, scn trackid 23 not found in IC_510530_DR2_Chaos.lua
ERROR: for VN_640412_Kien_Long_PM.lua:228: _UMINH_VC_HEAVY_FIRE_SUPPORT_COY_64_151 track 151 not found in org file
ERROR: for VN_640412_Kien_Long_PM.lua:228: _UMINH_VC_HEAVY_FIRE_SUPPORT_COY_64_151 track 151 not found in scn file
ERROR: /usr/bin/luac: ...Games/Vietnam/vietnam/Scenarios/VN_660709_Minh_Thanh.lua:1904: 'then' expected near '='
ERROR: for VN_660709_Minh_Thanh.lua:1937: undefined (nil value) org name: _HQ_271
ERROR: for VN_660709_Minh_Thanh.lua:1937: undefined (nil value) org name: _HQ_302



ERROR: /usr/bin/luac: ...tnam/vietnam/Scenarios/IC_540410_DBP9_BRUNO_Grabs_E1.lua:828: ')' expected (to close '(' at line 825) near '"SITUATION:
ERROR:
ERROR: "'
ERROR: for IC_540506_DBP10_Castor_Dies.lua:1238: mistaken side: VM_SIDE
ERROR: for VN_640412_Kien_Long.lua:184: _LOGISTICS_COY_LEVEL_1_64_37 track 37 not found in org file
ERROR: for VN_640412_Kien_Long.lua:184: _LOGISTICS_COY_LEVEL_1_64_37 track 37 not found in scn file
ERROR: /usr/bin/luac: ...mes/Vietnam/vietnam/Scenarios/VN_640412_Kien_Long_PM.lua:1106: 'then' expected near 'defend_strong'



ERROR: /usr/bin/luac: ...ames/Vietnam/vietnam/Scenarios/VN_700708_FSB_Ripcord.lua:515: syntax error near 'do'



ERROR: /usr/bin/luac: ...ames/Vietnam/vietnam/Scenarios/VN_670601_Bootcamp_02.lua:272: ')' expected (to close '(' at line 259) near '" PHASE ONE: Your Infantry Company will remain at Dak To II Airfield, assist in building defences and secure it for future operations. "'



ERROR: /usr/bin/luac: /cygdrive/c/Games/Matrix Games/Vietnam/vietnam/init.lua:696: ')' expected near '&'
ERROR: for VN_670601_Bootcamp_02.lua:853: mistaken nation: US_NATION
ERROR: for VN_670601_Bootcamp_02.lua:853: mistaken nation parameter: set_morale_shift(US_NATION, ...)
ERROR: for VN_670601_Bootcamp_02.lua:865: mistaken nation: VC_NATION
ERROR: for VN_670601_Bootcamp_02.lua:865: mistaken nation parameter: set_morale_shift(VC_NATION, ...)
ERROR: for VN_670601_Bootcamp_02.lua:866: mistaken nation: US_NATION
ERROR: for VN_670601_Bootcamp_02.lua:866: mistaken nation parameter: set_morale_shift(US_NATION, ...)



ERROR: /usr/bin/luac: ...ames/Vietnam/vietnam/Scenarios/VN_670601_Bootcamp_01.lua:527: unexpected symbol near ')'
ERROR: for VN_670601_Bootcamp_01.lua:140: illegal space in luav index: "ALL_OBJECTIVES_TAKEN "



WARNING: for IC_510530_DR2_Chaos.lua, possible missing or mistaken fired indicator
WARNING: for IC_510530_DR2_Chaos.lua, possible missing or mistaken arty fired indicator
WARNING: for IC_510530_DR2_Chaos.lua, possible missing or mistaken ammo level adjustment
WARNING: for IC_510530_DR2_Chaos.lua, possible missing or mistaken attack on habitat hex malus
WARNING: for IC_510530_DR2_Chaos.lua, possible missing or mistaken assault_attack_aggressiveness_effect adjustment



WARNING: for IC_511113_HB2_KemPass.lua:200: _1ER_BATTERIE_8755 possible orgtrk 8755 track 8757 mismatch
WARNING: for IC_511113_HB2_KemPass.lua:204: _2E_BATTERIE_8760 possible orgtrk 8760 track 8762 mismatch
WARNING: for IC_511113_HB2_KemPass.lua:208: _3E_BATTERIE_8765 possible orgtrk 8765 track 8767 mismatch



WARNING: in IC_540404_PK15.lua, referenced just once: FRENCH_AIRSTRIKES_AVAILABILITY_TURN
WARNING: in IC_540404_PK15.lua, referenced just once: FRENCH_COYS



NOTICE: for VN_641230_Binh_Gia.lua:406: uninitialized local: local adj_ARVN
NOTICE: for VN_641230_Binh_Gia.lua:495: uninitialized local: local ownedd
NOTICE: for VN_641230_Binh_Gia.lua:542: uninitialized local: local ownedd
NOTICE: for VN_641231_Binh_Gia.lua:960: uninitialized local: local targetpt



NOTICE: for XP_671231_PBEM_Set_A02.lua:349: empty briefing line
NOTICE: for XP_671231_PBEM_Set_A02.lua:403: empty briefing line



NOTICE: in VN_620112_Huong_Viet_Con.lua, referenced just twice: NW_ZONE
NOTICE: in VN_620112_Huong_Viet_Con.lua, referenced just twice: NW_ZONE_SIDE_A_OWNED
NOTICE: in VN_620112_Huong_Viet_Con.lua, referenced just twice: OBJECTIVES_3_SIDE_A_CAPTURED
NOTICE: in VN_620112_Huong_Viet_Con.lua, referenced just twice: OBJECTIVES_5_SIDE_A_CAPTURED
NOTICE: in VN_620112_Huong_Viet_Con.lua, referenced just twice: PINEAPPLE_EAST_AREA



It is beyond the scope of the discussion right here to explain the (in)significance and (un)importance of each WARNING or NOTICE. That will be sorted out later, in separate discussions and venues.

It deserves emphasizing: Run csluachk.pl frequently on individual files, especially the one(s) you are currently modding. Better to find, and fix, issues sooner rather than later (like 20 turns into a scenario run). csluachk.pl is one of the biggest guns in the Dev Team's QA arsenal. Be sure to use it!

If you have questions, just ask here in the Forum.

Good luck! Happy CSEE/SAI scripting!
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
berto
Posts: 21461
Joined: Wed Mar 13, 2002 1:15 am
Location: metro Chicago, Illinois, USA
Contact:

Re: CSlint How-To

Post by berto »

csflgfix.pl


csflgfix.pl is a Perl script (program) to modify platoon*.oob unit flag values.

Start by displaying the program help:



rober@Rob10rto ~/cslint
$ ./csflgfix.pl -h

Usage: csflgfix.pl [-h|-help] [{+|-}G|-debug] [-s<char>|-separator<char>] -g[ame] {me|vn|cw|ef|wf|pf} <PID> {-move|-carry|-fire|-other|-more|-morefire} [+<flags>] [-<flags>|-ALL]



For Vietnam (or Middle East or ...) specific help, add the option '-g vn' (or '-g me' or ...):



rober@Rob10rto ~/cslint
$ ./csflgfix.pl -h -g vn

Usage: csflgfix.pl [-h|-help] [{+|-}G|-debug] [-s<char>|-separator<char>] -g[ame] {me|vn|cw|ef|wf|pf} <PID> {-move|-carry|-fire|-other|-more|-morefire} [+<flags>] [-<flags>|-ALL]

move flags: XTracked/XFoot/XHalftrack/XArmoredCar/XTruck/XNoLtBridge/XNoMedBridge/XAmphibious/XSki/XMotorcycle/XTrain/XHorse/XBoat/XWagon/XNoHvyBridge/XTunnel/XAir/XShip/XRaft

carry flags: XLoadable/XRidable/XTowable/XCarryAll/XCarryRider/XCarryTow/XTowOnly/XPortage/XCanMotor/XCanBicycle/XCanHorse/XHeavyGun/XCarryHorse/XCarryBicycle/XCarryMotor/XCarryBoat

fire flags: XHardTarget/XNormalAA/XReducedAA/XIndirectFire/XSmokeFiring/XFireWater/XWhiteP/XSAM/XATGM/XGunship/XSneaker/XATG/XAAA/XFFATG/XManSAM/XWideArea

other flags: XCanDigIn/XMineClearing/XFireHardAI/XFireSoftAI/XReconAI/XAssaultAI/XRetreatAI/XCanDamage/XCarryAny/XCarryVehicle/XPathfinder/XOffBoardAirPlane/XHelicopter/XOnBoardAirPlane/XRecovery/XBuildVehicleBridge/XBuildLightBridge/XSpecOps/XCommando/XHighFlying/XLowFlying/XBomber/XDiveBomber/XFastMover/XGroundAttack/XFAC/XMultistrike/XLoiter

more flags: XAssault/XOffAT/XDefAT/XInfSup/XFireHelo/XLayMines/XErectBarrier/XSuicide/XReconUnit/XFastUnit/XShovels/XRaider/XNightVision/XSetIED/XLayManyMines/XArtyAmmo/XGunshipAmmo/XSAMControl/XHighVis/XNoFireHelo/XFireHeloShort/XSupply

morefire flags: XGuns/XRockets/XBombs/XBombsII/XNapalm/XSmartMunitions/XFireForget/XDaisyCutter/XChemical/XTacticalNukes



Before we get to actual csflgfix.pl usage, let's review csoobrpt.pl (from an earlier post):



rober@Rob10rto ~/cslint
$ ./csoobrpt.pl -h -g vn

Usage: csoobrpt.pl [-h|-help] [{+|-}i|{+|-}insensitive] [{+|-}G|-debug] -g[ame] {me|vn|cw|ef|wf|pf} [{+|-}F|{+|-}show_files] [{+|-}N|{+|-}show_linenos] [-s<char>|-separator<char>] [-m "<string>"|-match "<string>"] [<parameters list>|-ALL]

parameters list:
-1 or -id
-2 or -strength
-3 or -assault
-4 or -defend
-5 or -firingcost
-6 or -loadingcost
-7 or -unloadingcost
-8 or -speed
-9 or -xcspeed
-10 or -weight
-11 or -pressure
-12 or -concealment
-13 or -movesound
-14 or -firesound
-15 or -countercell2d
-16 or -basecell3d
-17 or -animate
-18 or -type1d (NATO symbol)
-19 or -type2d (unit icon)
-20 or -bitmap3d
-21 or -points
-22 or -moveflags
-23 or -carryflags
-24 or -fireflags
-25 or -otherflags
-26 or -moreflags
-27 or -morefireflags
-28 or -startyear
-29 or -startmonth
-30 or -stopyear
-31 or -stopmonth
-32 or -frontmod
-33 or -sidemod
-34 or -rearmod
-35 or -name
-36 or -short
-37 or -nick



By using the -ALL switch, remember that we can show all of those 37 unit parameters, not just some of them. For instance:



rober@Rob10rto ~/cslint
$ ./csoobrpt.pl -g vn -F -N -m "dozer" -ALL
P007019 2 0 2 0 50 50 48 24 5 1 4 1 0 5 0 0 70 116 P007019 2 33 0 0 1217 4198465 0 48 1 85 12 0 0 0 BAT-M Dozers BAT-M Dozers
P007020 4 2 2 40 50 50 15 15 5 1 4 1 0 5 0 0 382 149 P007020 2 33 64 0 1217 4198465 0 55 1 85 12 1 1 1 Dozers Dozers
P088803 2 2 2 40 50 50 15 15 5 1 4 1 0 5 0 0 86 79 P088803 5 33 5 1 1217 4198465 0 48 1 85 12 3 1 1 Dozers Dozers
P100069 2 3 11 35 50 50 38 15 33 2 4 1 11 5 0 1 382 9 P100069 5 33 16 1 4211149 2097217 0 48 1 61 12 13 6 5 M4A3 Dozer M4A3 Dozers Sherman Dozer
P106811 4 2 2 40 50 50 15 15 5 1 4 1 0 5 0 0 86 141 P106811 2 33 5 1 1217 4198465 128 48 1 85 12 0 0 0 Dozers Dozers
P100570 2 3 11 35 50 50 38 15 33 2 4 1 11 29 1 1 382 9 P100570 5 33 16 1 4211149 2097217 0 48 1 61 12 13 6 5 M4A3 Dozer M4A3 Dozers Sherman Dozer - CAVALRY
P107463 2 2 2 40 50 50 15 15 5 1 4 1 0 29 1 0 86 141 P107463 2 33 5 1 1217 4198465 128 48 1 85 12 0 0 0 Dozers Dozers - CAVALRY
P100633 2 3 11 35 50 50 38 15 33 2 4 1 11 17 2 1 382 9 P100633 5 33 16 1 4211149 2097217 0 48 1 68 12 13 6 5 M4A3 Dozer M4A3 Dozers Sherman Dozer --- MARINE
P107568 2 2 2 45 50 50 15 15 5 1 4 1 0 17 2 0 86 141 P107568 2 33 5 1 1217 4198465 128 48 1 85 12 0 0 0 Dozers Dozers --- MARINE
P100843 2 3 11 35 50 50 38 15 33 2 4 1 11 41 3 1 382 9 P100843 5 33 16 1 4211149 2097217 0 48 1 61 12 13 6 5 M4A3 Dozer M4A3 Dozers Sherman Dozer --- AIRBORNE
P107762 2 2 2 40 50 50 15 15 5 1 4 1 0 41 3 0 86 141 P107762 2 33 5 1 1217 4198465 128 48 1 85 12 0 0 0 Dozers Dozers --- AIRBORNE
P117035 4 2 2 40 50 50 15 15 5 1 4 1 0 5 1 0 86 64 P117035 2 33 5 1 1217 4198465 0 48 1 75 12 2 1 1 Dozers Dozers
P127055 4 2 2 40 50 50 15 15 5 1 4 1 0 5 0 0 86 64 P127055 2 33 5 1 1217 4198465 0 48 1 85 12 2 1 1 Dozers Dozers
P130012 2 7 14 45 50 50 42 21 36 2 4 1 11 0 0 1 382 22 P130012 7 33 16 1 4211149 2097217 0 75 1 85 12 32 12 10 T-55 Dozer Tank T-55 BTU
P177035 4 2 2 40 50 50 15 15 5 1 4 1 0 5 0 0 86 143 P177035 2 33 5 1 1217 4198465 0 48 1 85 12 2 1 1 Dozers Dozers
P197048 2 2 2 40 50 50 15 15 5 1 4 1 0 5 0 0 86 143 P197048 2 33 5 1 1217 4198465 0 48 1 85 12 2 1 1 Dozers Dozers
P218802 2 2 5 40 50 50 48 24 34 3 5 1 3 5 0 0 86 143 P218802 2 33 5 1 1217 4198465 0 56 1 75 12 2 1 1 BAT-M Dozers Dozers
P218813 2 2 5 40 50 50 48 24 34 3 5 1 3 41 3 0 86 143 P218802 2 33 5 1 1217 4198465 0 75 1 85 12 2 1 1 BAT-M Dozers Dozers
P490016 2 7 14 45 50 50 42 21 36 2 4 1 11 5 0 1 70 22 P490016 7 33 16 1 1153 2113615 0 75 1 85 12 32 12 10 T-55 Dozer Tank T-55 BTU
P507060 2 2 2 40 50 50 15 15 5 1 4 1 0 5 0 0 86 64 P507060 5 33 5 1 1217 4198465 0 51 1 85 12 2 1 1 Dozers Dozers



In the above output, for the American M4A3 Dozer, I have highlighted the fields



-22 or -moveflags
-23 or -carryflags
-24 or -fireflags
-25 or -otherflags
-26 or -moreflags
-27 or -morefireflags



Let's use clflgfix.pl to modify some of those highlighted numbers.

For M4A3 Dozers, their Move flags, 33, signify:



rober@Rob10rto ~/cslint
$ ./csflags.pl -g vn -move 33
XTracked/XNoLtBridge



We will add the XNoMedBridge flag:



rober@Rob10rto ~/cslint
$ ./csflgfix.pl -g vn P100570 -move +XNoMedBridge
33 97



Note the use of +XNoMedBridg, where the '+' (plus) says to add flag(s).

The first value, 33, is the old value (as it currently shows in the .oob file), the second value, 97, is the new value with the XNoMedBridge flag applied. We would then hand edit the .oob file, substituting 33 -> 97.

For M4A3 Dozers, their Carry flags, 16, signify:



rober@Rob10rto ~/cslint
$ ./csflags.pl -g vn -carry 16
XCarryRider



We will add the XCarryTow flag:



rober@Rob10rto ~/cslint
$ ./csflgfix.pl -g vn P100570 -carry +XCarryTow
16 48



The first value, 16, is the old value (as it currently shows in the .oob file), the second value, 48, is the new value with the XCarryTow flag applied. We would then hand edit the .oob file, substituting 16 -> 48.

With csflgfix.pl, you can also remove flags.

For M4A3 Dozers, their Other flags, 4211149, signify:



rober@Rob10rto ~/cslint
$ ./csflags.pl -g vn -other 4211149
XCanDigIn/XFireHardAI/XFireSoftAI/XRetreatAI/XCanDamage/XCarryAny/XRecovery/XDiveBomber



We will remove the XRetreatAI flag:



rober@Rob10rto ~/cslint
$ ./csflgfix.pl -g vn P100570 -other -XRetreatAI
4211149 4211085



Note the use of -XRetreatAI, where the '-' (minus) says to remove flag(s).

The first value, 4211149, is the old value (as it currently shows in the .oob file), the second value, 4211085, is the new value with the XRetreatAI flag removed.

Before we move on, let's doublecheck that new, replacement parameter #:



rober@Rob10rto ~/cslint
$ ./csflags.pl -g vn -other 4211085
XCanDigIn/XFireHardAI/XFireSoftAI/XCanDamage/XCarryAny/XRecovery/XDiveBomber



Yup, looks right. See where XRetreatAI is removed from the Other flags. (Compare with the previous csflags.pl output above.)

Or maybe not right! See where the Other flags for the M4A3 Dozers include the XDiveBomber flag. Oops!

We will remove the XRetreatAI and the mistaken XDiveBomber flag:



rober@Rob10rto ~/cslint
$ ./csflgfix.pl -g vn P100570 -other -XRetreatAI/XDiveBomber
4211149 16781



Checking that new value:



rober@Rob10rto ~/cslint
$ ./csflags.pl -g vn -other 16781
XCanDigIn/XFireHardAI/XFireSoftAI/XCanDamage/XCarryAny/XRecovery



There. That's better! No more XDiveBomber (and XRetreatAI).

We can, in one go, both add and remove flags. For this unit, we will remove the XRetreatAI & XDiveBomber Other flags, and add the XMineClearing Other flag:



rober@Rob10rto ~/cslint
$ ./csflgfix.pl -g vn P100570 -other -XRetreatAI/XDiveBomber +XMineClearing
4211149 16783



Checking the new value:



rober@Rob10rto ~/cslint
$ ./csflags.pl -g vn -other 16783
XCanDigIn/XMineClearing/XFireHardAI/XFireSoftAI/XCanDamage/XCarryAny/XRecovery



There is no real need to use csflags.pl every time to double check the new values. We do it here merely to inspire confidence that csflgfix.pl is WAD. In ordinary use, you would invoke csflgfix.pl one command after another.

For instance:



rober@Rob10rto ~/cslint
$ ./csflgfix.pl -g vn P106762 -other +XOnBoardAirPlane
4096 12288

rober@Rob10rto ~/cslint
$ ./csflgfix.pl -g vn P106763 -other +XOnBoardAirPlane
4096 12288

rober@Rob10rto ~/cslint
$ ./csflgfix.pl -g vn P106764 -other +XOnBoardAirPlane
4096 12288

...



For all of those commands, they were not retyped, rather recalled by means of cursor up. (In Cygwin or WSL Linux, you can recall earlier commands by means of pressing the cursor up key.) Note where the PIDs differ, whether by copy/paste, or by hand editing the PID #s, in each of the recalled commands.


You can also ignore any previous flags, wipe the slate clean, by means of -ALL



rober@Rob10rto ~/cslint
$ ./csflgfix.pl -g vn P100570 -move -ALL +XTracked
33 1



Another example:



rober@Rob10rto ~/cslint
$ ./csflgfix.pl -g vn P100570 -other -ALL +XMineClearing
4211149 2



In both cases, the earlier Other flags were clean slated, and only the + adds were applied.

Try this:



rober@Rob10rto ~/cslint
$ ./csflgfix.pl P100570 -other -ALL +XMineClearing

please specify a game

Usage: csflgfix.pl [-h|-help] [{+|-}G|-debug] [-s<char>|-separator<char>] -g[ame] {me|vn|cw|ef|wf|pf} <PID> {-move|-carry|-fire|-other|-more|-morefire} [+<flags>] [-<flags>|-ALL]



We have failed to specify a game (as in '-g vn').

Try this:



rober@Rob10rto ~/cslint
$ ./csflgfix.pl -g vn -other -ALL +XMineClearing

missing unit PID

Usage: csflgfix.pl [-h|-help] [{+|-}G|-debug] [-s<char>|-separator<char>] -g[ame] {me|vn|cw|ef|wf|pf} <PID> {-move|-carry|-fire|-other|-more|-morefire} [+<flags>] [-<flags>|-ALL]

move flags: XTracked/XFoot/XHalftrack/XArmoredCar/XTruck/XNoLtBridge/XNoMedBridge/XAmphibious/XSki/XMotorcycle/XTrain/XHorse/XBoat/XWagon/XNoHvyBridge/XTunnel/XAir/XShip/XRaft

carry flags: XLoadable/XRidable/XTowable/XCarryAll/XCarryRider/XCarryTow/XTowOnly/XPortage/XCanMotor/XCanBicycle/XCanHorse/XHeavyGun/XCarryHorse/XCarryBicycle/XCarryMotor/XCarryBoat

fire flags: XHardTarget/XNormalAA/XReducedAA/XIndirectFire/XSmokeFiring/XFireWater/XWhiteP/XSAM/XATGM/XGunship/XSneaker/XATG/XAAA/XFFATG/XManSAM/XWideArea

other flags: XCanDigIn/XMineClearing/XFireHardAI/XFireSoftAI/XReconAI/XAssaultAI/XRetreatAI/XCanDamage/XCarryAny/XCarryVehicle/XPathfinder/XOffBoardAirPlane/XHelicopter/XOnBoardAirPlane/XRecovery/XBuildVehicleBridge/XBuildLightBridge/XSpecOps/XCommando/XHighFlying/XLowFlying/XBomber/XDiveBomber/XFastMover/XGroundAttack/XFAC/XMultistrike/XLoiter

more flags: XAssault/XOffAT/XDefAT/XInfSup/XFireHelo/XLayMines/XErectBarrier/XSuicide/XReconUnit/XFastUnit/XShovels/XRaider/XNightVision/XSetIED/XLayManyMines/XArtyAmmo/XGunshipAmmo/XSAMControl/XHighVis/XNoFireHelo/XFireHeloShort/XSupply

morefire flags: XGuns/XRockets/XBombs/XBombsII/XNapalm/XSmartMunitions/XFireForget/XDaisyCutter/XChemical/XTacticalNukes



We have failed to supply a unit PID (e.g., 'P100570').

One more to try:



rober@Rob10rto ~/cslint
$ ./csflgfix.pl P100570 -g vn -other -ALL +XMineClearing -carry +XCarryTow

only one category at a time

Usage: csflgfix.pl [-h|-help] [{+|-}G|-debug] [-s<char>|-separator<char>] -g[ame] {me|vn|cw|ef|wf|pf} <PID> {-move|-carry|-fire|-other|-more|-morefire} [+<flags>] [-<flags>|-ALL]

move flags: XTracked/XFoot/XHalftrack/XArmoredCar/XTruck/XNoLtBridge/XNoMedBridge/XAmphibious/XSki/XMotorcycle/XTrain/XHorse/XBoat/XWagon/XNoHvyBridge/XTunnel/XAir/XShip/XRaft

carry flags: XLoadable/XRidable/XTowable/XCarryAll/XCarryRider/XCarryTow/XTowOnly/XPortage/XCanMotor/XCanBicycle/XCanHorse/XHeavyGun/XCarryHorse/XCarryBicycle/XCarryMotor/XCarryBoat

fire flags: XHardTarget/XNormalAA/XReducedAA/XIndirectFire/XSmokeFiring/XFireWater/XWhiteP/XSAM/XATGM/XGunship/XSneaker/XATG/XAAA/XFFATG/XManSAM/XWideArea

other flags: XCanDigIn/XMineClearing/XFireHardAI/XFireSoftAI/XReconAI/XAssaultAI/XRetreatAI/XCanDamage/XCarryAny/XCarryVehicle/XPathfinder/XOffBoardAirPlane/XHelicopter/XOnBoardAirPlane/XRecovery/XBuildVehicleBridge/XBuildLightBridge/XSpecOps/XCommando/XHighFlying/XLowFlying/XBomber/XDiveBomber/XFastMover/XGroundAttack/XFAC/XMultistrike/XLoiter

more flags: XAssault/XOffAT/XDefAT/XInfSup/XFireHelo/XLayMines/XErectBarrier/XSuicide/XReconUnit/XFastUnit/XShovels/XRaider/XNightVision/XSetIED/XLayManyMines/XArtyAmmo/XGunshipAmmo/XSAMControl/XHighVis/XNoFireHelo/XFireHeloShort/XSupply

morefire flags: XGuns/XRockets/XBombs/XBombsII/XNapalm/XSmartMunitions/XFireForget/XDaisyCutter/XChemical/XTacticalNukes



A bit tricky. Be sure to get your command-line options right!

You will see many other examples of csflgfix.pl usage in this and other threads (including further explanation of using other WSL Linux tools). But the above should be enough to get you started.

If you have questions, just ask here in the Forum.

Good luck! Happy unit flag fixing/tweaking!
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
Post Reply

Return to “Scenario Design and Modding”