Skip to content

CHK Functions

Game version: 1.32a

Human-readable names for the game's CHK functions — the chk(code, …) (alias che) calls that read or compute a value (skill rolls, counts, lookups, relations) in IF logic. Each maps to a raw CHK code; the full sortable catalog is below.

Each function is shown in two forms:

  • S&S Editor / CSV — the raw chk(code, …) (alias che(code, …)) you author directly in an IF column, a DECISION_IF, a SET-logic condition, or a <flag> substitution. The chk(249, …) gateway appears inline the same way.
  • ModBuildTool (coming soon) — the friendly, sigil-free name (e.g. SkillRoll, ZoneHexCount) that the forthcoming mod build tool will accept and compile to the raw form for you.

⭐ Gateway functions (most used)



What is a CHK function?

Shadow Empire's event/story/logic engine has two families of callable functions used inside logic strings (the IF columns, DECISION_IF, SET-logic conditions, <flag> substitutions, etc.):

Inline form Dispatcher Returns Purpose
chk(code, b, c, d, e) (alias che) EventRelatedClass.DoCheck(t1=code, …) a value IF/GET — read/compute something
exe(code, b, c, d, e) EventRelatedClass.DoExec(enr, t1=code, …) nothing (side effect) SET — do something (mutate game state)

The first argument (code / t1) selects the function. So chk(50, 4, 2) runs CHK code 50 (CheckRegimeRelation) with arguments (4, 2) and returns 0 (war), 1 (peace) or 2 (allied). chk and che are the same dispatcher — che is just the in-game alias.

DoCheck always returns a string (Strings.Trim(Conversion.Str(...))); the logic engine then parses it as a number or compares it as a string (dates, names) depending on context.

Each CHK code carries metadata in DataClass:

  • CheckTypeNames[code] — internal/display name (e.g. CheckRegimeRelation).
  • CheckTypeVarCount[code] — how many numeric arguments it consumes.
  • CheckTypeVarName[code, n] — the label of argument n (these are the column headers below).
  • CheckCategory[code] — grouping (see the category headers in §4); names from CheckCategoryName[].
  • CheckDesc[code] — free-text notes (shown verbatim in the Notes column when present).

Codes range 1–265; ~251 are defined, the rest are gaps/obsolete. Unlike EXE, there is no CheckTypeString array — CHK functions return a value rather than consuming a trailing text/DataString payload (although a few accept a string argument, e.g. CheckCompareString, by passing it through the normal numeric arg slots as text).


The chk(249, …) gateway — CheckHardcodedIF

CHK code 249 (CheckHardcodedIF, category 12 "Random Related") is the read-side counterpart to exe(346, …) (ExecHardcodedSet). It is a second-level dispatcher: its first argument selects a sub-function.

chk(249, fn, storyId, inst1, inst2 [, extra])
         │   └──────────┬──────────┘    │
         │              │               └─ optional 5th arg (extra1, default -1; only fn 4 uses it)
         │              └─ sub-function arguments (game labels: "Story Id", "Instance 1 Id", "Instance 2 Id")
         └─ CHK code 249 = "run a hardcoded check"

This is why shipped logic looks like che(249,1,CHARID,skillID) (a skill roll) or chk(249,4,ZONEID,REGID,1) (troop power in a zone). The sub-function table is not the same numbering as the top-level CHK catalog in §4 — it is internal to checkHardcodedIF.

The three generic arg slots are labelled Story Id, Instance 1 Id, Instance 2 Id in the editor, but their real meaning varies per sub-function (Char ID, Regime ID, Zone ID, …). The table below gives the real meaning per fn. An unmatched fn returns -1.

chk(249, fn, …) sub-function table

Verified against checkHardcodedIF (EventRelatedClass.cs ~131574–132599). arg2/arg3/arg4 are the 2nd/3rd/4th args of the chk(249,…) call (the game's storyID/instance1id/instance2id); arg5 is the optional extra1.

fn What it returns arg2 arg3 arg4 Impl.
1 Skill roll (1d100 + bonuses vs skill) Char ID Skill Type ID 1 = just return skill level (no roll) CheckHardcoded_SkillRoll
2 Stratagem/card count in regime hand Card/Stratagem ID (skill filter) — CheckHardcoded_CardIdCount
3 Inverse percentage — (100-x)*y/100 capped Original value Percentage Maximum Helper_GetInversePercentage
4 Troop power points of a regime in a zone Zone ID Regime ID mode CheckHardcoded_PowerPointsInZone (uses arg5 = only-OHQ unit nr)
5 Who made the roll (leader vs advisor char ID) Char ID Skill Type ID — CheckHardcoded_SkillRoll_WhoMadeRoll
6 Org count for a regime (or PP-cost tier for next org) Regime ID 0 = count, ≠0 = PP-cost tier — org stringlist (184); tier 1→4,2→8,3→16,4→28,5→44,6→52,7→56,8+→60
7 Random city zone ID of a regime Regime ID 0 = must have city, 1 = any closest-to-current / neighbour CheckHardcoded_RandomCityZone
8 Random binary tech type ID Regime ID 0 = any, 1 = already discovered — CheckHardcoded_RandomBinaryTech
9 Random mining asset ID in a zone Zone ID Max easy level Max reserves left CheckHardcoded_RandomMineAsset
10 Asset info value Asset ID Info type (1 = mining ease) (extra) CheckHardcoded_AssetInfo
11 Asset family level in a zone Zone ID Asset Family ID — CheckHardcoded_AssetFamilyLevel
12 Has leader feat? (0/1) Char ID Leader Feat ID — CheckHardHasFeat
13 Highest char ID in the game — — — CheckHighestCharId
14 Total spies of a regime in a target's zones Spying regime ID Target regime ID — CheckHardcoded_TotalSpies
15 Faction ID by size rank Regime ID Rank (1 = biggest, 2 = 2nd…) — CheckHardcoded_FactionId
16 Diplomatic difficulty modifier Regime ID Target regime ID — CheckHardcoded_DiplomaticModifier
17 Zone hex count Zone ID — — CheckHardcoded_ZoneHexCount
18 Zone perk count Zone ID Perk category ID or 0 Perk ID or 0 CheckHardcoded_ZoneHexPerks
19 Unit feat count Unit His ID Unit Feat ID — CheckHardcoded_UnitFeatCount
20 Unit sub-formation count Unit His ID — — CheckHardcoded_UnitSubCount
21 Random tech to discover Regime ID 0 = any, 1 = must be discoverable — CheckHardcoded_RandomDiscoveryTech
22 Make prospect discovery (returns mining type or <1) Zone ID — — CheckHardcoded_MakeProspectDisvoery
23 Make archaeological discovery (returns rarity or <1) Zone ID — — CheckHardcoded_MakeArcheologyDisvoery
24 3rd-party character creation (returns new Char ID) Language ID Sex (1=M, 2=F) Final Career ID CheckHardcoded_3rdPartyCharRecruit
25 Destroy assets (returns levels removed) Zone ID Asset-type stringlist col# (>0) Levels to destroy CheckHardcoded_AssetDecreaseLevel
26 Find leader by job (returns Char ID) Jobtype ID Specific job (zone/org ID) Regime ID CheckHardcoded_JobLeader
27 Profile relation roll Char ID Profile number — CheckHardcoded_ProfileRelationRoll
28 Char's zone ID Char ID — — CheckHardcoded_CharZoneId
29 Seniority rank (0–100) Regime ID Char ID — Helper_GetCharacterSeniorityRanking
30 Has regime feat? (>0 = yes) Regime ID Regime Feat ID — CheckHardHasRegimeFeat
31 Random neighbouring zone Zone ID 0 = any, 1 = excl hostile, 2 = excl friendly — CheckRandomZoneNeighbour
32 His-unit's zone ID Unit His ID — — CheckHardcoded_HistoricalUnitZoneId
33 Loc ID of a regime Regime ID 0 = capitol, 1 = random city — CheckLocIDofRegimeId
34 Coord (XY) of a Loc ID Loc ID — — CheckCoordOfLocId
35 Set a promise (returns Promise ID) Demand ID XY Deadline CheckSetPromiseXY
36 Check a promise (0=ongoing,1=success,2=failure,3=refused) Promise ID — — CheckPromiseId
37 Free space for hex feat (returns XY or 0) Zone ID — — CheckFreeHexFeatXY
38 Free space for free folk (returns XY or 0) Zone ID — — CheckFreeFreeFolkXY
39 Job/cabinet feat count Jobtype (999 = any cabinet) Leader Feat Type ID — CheckJobOrCabinetFeatCount
40 # of majors at war with Regime ID — — CheckAtWarWithMajor
41 Coord (XY) of a zone's loc Zone ID — — CheckCoordOfZoneId
42 Trade-house borders check Regime ID (inst1) (inst2) CheckTradeHouseBorders
43 Market/Trade-Hub auction check (param) (param) — CheckMTHAuction
44 Coastal hex of a zone (returns XY) Zone ID (mode) — CheckCoastHexXY
45 Random leader for Market/Trade Hub (param) (param) — CheckRandomLeaderForMTH
46 Item qty in a zone's city-HQ unit Zone ID Item Type ID — inline (Zones 123 col6 → Loc → HQ unit items)
47 Trader credits (adds arg3 if >0) Trader-zone ID amount to add (+) — inline (SE_Trade 252 col1)
48 Zone count of a regime Regime ID — — CheckHardcoded_ZoneCount
49 Mine extend result Zone ID Regime ID — CheckHardcoded_MineExtend
50 Asset sub-type levels % in a zone Zone ID Sub-type nr — CheckHardcoded_AssetSubTypesLevelsPerc
51 Item qty in a zone (city loc + HQ unit combined) Zone ID Item Type ID — inline
52 Random differing-culture neighbour zone Zone ID (mode) — CheckCultureZoneNeighbour
53 Computer/Compu leader char ID — — — CheckComputerLeader
54 Random leader-feat (SSF) of a regime by job filter Regime ID JobType (0=any, 999=any w/ initial.cust) — inline (feat 376 / type 377)
55 Sell a leader feat (SSF) — removes it, returns price Char ID Char Feat Type ID — inline
56 Has char feat (SSF)? (1/0) Char ID Char Feat Type ID — inline
60 Republica card — general IF (politics only) Card — — republicaObj.CheckRepublicaCard_GeneralIF
61 Republica card — target-logic IF (politics only) Card Target — republicaObj.CheckRepublicaCard_TargetLogicIF
62 Republica card — general weight (politics only) Card — — republicaObj.CheckRepublicaCard_GeneralWEIGHT
63 Faction popularity of a char's faction (politics) Char ID — — inline (faction 200 col15)
64 Most-popular cabinet char of a regime (politics) Regime ID — — inline (job 2–10, popularity − seniority)
65 Highest-popularity faction-leader in a regime (politics) Regime ID — — inline
66 Faction ID of a char Char ID — — inline (char 196 col13)
67 Promise count — — — CheckPromiseCount
68 Zone ID of an asset Asset ID — — inline (assets 148 GetData(9,…))
69 Char job-specific value lookup Char ID (job-spec key) — inline (char 196 GetData2(6,…,7,…))
70 Remove a char feat (SSF) by force — returns price Char ID Feat ID — inline
71 Org ID of a given org type for a regime Regime ID Org Type ID — inline (org 184 GetData2(2,…,1,…))
72 Random feudal faction-leader char Regime ID — — inline (needs feudalLevel≥1)
73 Has active dip pact & non-trivial system? (1/0) Regime ID Target regime ID — inline (regreg 275)
74 Relation below dip-pact threshold? (1/0) Regime ID Target regime ID — inline (regreg 275)
75 Capital-zone derived value of a regime Regime ID — — inline (regimes 143 col12 → zones 123)
76 Unit sub-count incl. HQ Unit His ID — — CheckHardcoded_UnitSubCountHQ
77 Random neighbour zone with a given relation Regime ID Zone ID Relation (RegimeRel value) inline
78 Random other cabinet char in same zone Char ID — — inline (jobs 3/4, same zone via fn 28)
79 Faction support of a char's faction Char ID — — inline (faction 200 col17)
80 Zone of a leader-feat placement (cf. fn 54) Regime ID JobType filter — inline (returns zone via asset)
81 Election — weighted random cabinet char Regime ID — — inline (seniority × social × faction vote × job prestige)
82 Regime has law? (1/0) Regime ID Law ID — inline (SE_Politics 573)
83 Sum of research/applied-science org task % Regime ID — — inline (org 184 / task 185)
84 AI: pick a target zone weighted by unrest/hunger/danger Regime ID — — inline (only majors you have recon on)
85 Job prestige of a char's current job Char ID 0 = use storyId scope — inline (Helper_Get_Job_Prestige)
101 New-org story IF Regime/context inst1 inst2 CheckHardcodedIF_NewOrg
102 Appoint-director story IF … … … CheckHardcodedIF_AppointDirector
104 Research-objective story IF … … … CheckHardcodedIF_ResearchObjective
105 OOB-objective story IF … … … CheckHardcodedIF_OobObjective
106 Set-model-for-org story IF … … … CheckHardcodedIF_SetModelForOrg
203 Org-overview story IF … … … CheckHardcodedIF_OrgOverview
601 Appoint-commander story IF … … … CheckHardcodedIF_AppointCommander
602 Appoint-governor story IF … … … CheckHardcodedIF_AppointGov
603 Council-budget story IF … … … CheckHardcodedIF_CouncilBudget
604 Zone-orders story IF … … … CheckHardcodedIF_ZoneOrders
605 Appoint-advisor story IF … … … CheckHardcodedIF_AppointAdvisor
801 Make-demand story IF … … … CheckHardcodedIF_Demand_Make
803 Resolve-demand story IF … … … CheckHardcodedIF_Demand_Resolve
831 Faction-job story IF … … … CheckHardcodedIF_Faction_Job
910 Make-speech story IF … … … CheckHardcodedIF_Speech_Make
916 Create-custom-OOB story IF … … … CheckHardcodedIF_CreateCustomOOB

Sub-functions 101+ are the DC-management "story IF" helpers used internally by the vanilla Org/Council/Diplomacy/Politics story systems (Story_Complex1, SE_Corporate, etc.). They take the same (storyId, inst1, inst2) slots but operate over multi-stage story state; the slot meanings are context-specific and best read from each CheckHardcodedIF_* implementation. Numbers not listed (e.g. 57–59, 86–100, 103, 107–202, …) are not handled by checkHardcodedIF and return -1.

Skill-roll guide (fn = 1)

che(249,1,CHARID,skillID) (chk ≡ che) is the workhorse used throughout unrest and diplomacy stories. Passing arg4 = 1 (instance2id == 1) makes it return the raw skill level instead of rolling.

The 4-tier roll result is evaluated against a DIFF threshold you choose:

Result Condition
Critical Success ROLL ≥ DIFF + 50
Success ROLL ≥ DIFF
Failure ROLL < DIFF
Critical Failure ROLL < DIFF − 50

Modifiers the engine adds to ROLL: secondary/bonus skills via che(249,1,CHARID,skillID,1); zone security/health/education ÷ 5; troops in zone (chk(249,4,ZONEID,REGID,1)) ÷ 3, capped at 20; enforcement profile above 40 adds the excess; player PP support adds +50.

Common skill IDs used in rolls: 1 Admin · 2 Diplomacy · 3 Leadership · 6 Oratory · 7 Survival · 9 Intimidation · 19 Investigation · 21 Technician · 22 Medicine · 23 Demolitions · 25 Science · 26 Prospecting · 27 Scavenging · 28 Interrogation · 36 Offensive Tactics · 37 Defensive Tactics · 41 Ecology.

Authoring pattern (Delta story format): stash the roll and threshold in result_set, then branch in after_dec_logic:

result_set:      ROLL=che(249,1,CHARID,skillID); DIFF=100
after_dec_logic: { check: ROLL>=DIFF, set: REGKEY.$var$=1, text: "Rolled <ROLL> vs <DIFF>. Success!" }
                 { check: ROLL<DIFF,  set: REGKEY.$var$=2, text: "Rolled <ROLL> vs <DIFF>. Failure!" }

<ROLL>, <DIFF> and <CHARNAME> auto-substitute in UDS text, and the decision preview shows "SkillName Roll 1d100 +bonus vs. Diff=X". Keep ZONEKEY out of after_dec_logic — it triggers Mid() errors.


Companion: exe(346,…) / the SET side

The write side mirrors this: exe(code,…) → DoExec. The most-used gateway there is exe(346,fn,…) (ExecHardcodedSet) — add hex perk, give tech, declare war, etc. Its sub-function table (1–65) is documented in EXE Functions.

CHK categories (CheckCategoryName): 1 Game & Map globals · 2 Regimes · 3 Logic & Calculations · 4 Hex & Areaslots · 5 Unit · 6 Stringlist · 7 SFType/ItemTypes · 8 DC1 AI · 9 DC2 AI · 10 Library Checks · 11 UDS · 12 Random Related. (Category 9 has no defined codes in this build.)


Full CHK code catalog

Every defined chk(code,…) function. Name is the internal CheckXxx name (the Check prefix stripped); Arguments are the game's own argument labels in order; Notes is the game's own description where present. Click a column header to sort — by Code for numeric order.

Code Category Name Arguments Notes
1 Game & Map globals Turn (none)
3 Game & Map globals Round (none)
5 Game & Map globals Winner (none)
14 Game & Map globals MapWidth (none)
15 Game & Map globals MapHeight (none)
16 Game & Map globals Year (none)
17 Game & Map globals Month (none)
18 Game & Map globals Day (none)
37 Game & Map globals RegimeCount (none)
148 Game & Map globals DrawGame (none) Returns 0 if not. Returns 1 if this is a draw game.
152 Game & Map globals RuleVar 1. RuleVar#; 2. Mulitply by 100? 0=no 1=yes Multiply option is there because some rulevar have single values like 0.4 or 0.03. And the scripting sytem can only handle integers.
192 Game & Map globals FOW (none) Returns 1 if fow is on. 0 if off.
4 Regimes RegimeMorale 1. RegimeNr
6 Regimes War 1. RegimeNr in Question; 2. Relation with RegimeNr
7 Regimes Peace 1. RegimeNr in Question; 2. Relation with RegimeNr
19 Regimes IfAI 1. Regime#
20 Regimes PolPts 1. Regime#
21 Regimes VP 1. Regime#
23 Regimes SupplyNeeded 1. Regime
27 Regimes ActionCard 1. Regime Owner; 2. Card Nr
28 Regimes DipBlock 1. Regime#
29 Regimes Sleep 1. Regime#
30 Regimes HistoricActionCard 1. Regime Owner; 2. Card Nr
34 Regimes RegimeKills 1. Regime; 2. SFType (-1=all, 1000-10XX = SFTypeGroups 0-XX); 3. Round (-1=all rounds); 4. Report 0=qty, 1=power pts
35 Regimes RegimeLosses 1. Regime; 2. SFType (-1=all, 1000-100X = SFTypeGroups 0-XX); 3. Round (-1=all rounds); 4. Report 0=qty, 1=power pts
36 Regimes RegimeProduction 1. Regime; 2. SFType (-1=all); 3. Round (-1=all rounds); 4. Report 0=qty, 1=power pts
42 Regimes AIThinkSpeed 1. Regime Gives back the AI think speed level. 0=Normal, 100=Slow, 250=Very Slow. (in old AT this was the production bonus- if ever merge keep this in mind)
50 Regimes RegimeRelation 1. Reg1; 2. Reg2 Returns 0 for war, 1 for peace, 2 for alliance
60 Regimes RegimeVar 1. Regime Nr; 2. Var Nr
71 Regimes RegimeUnitsMorale 1. Reg Returns the average morale of all units on map for this regime
72 Regimes RegimeUnitsExperience 1. Reg Returns the average experience of all units on map for this regime
95 Regimes RegimePeople 1. Regime
99 Regimes DipOffer 1. From Regime; 2. Too Regime
104 Regimes NonSleepingRegimesToCome (none) Returns the number of regimes that are still to be played in this round that are not put to sleep.
145 Regimes TotalSupplyUse 1. Regime # Returns the BasicSupplyUse of all troops on the map added up.
147 Regimes PbemPlayer 1. Regime# Expert use only! Returns either 1 for pbem player 1 (challenger), 2 for pbem player 2(opponent) or 0 if not set (not a started pbem++ game for example)
149 Regimes TotalActioncards 1. Regime #; 2. Category # (-1=all); 3. Color # (-1=all) Returns the total number of action cards the regime has in hand. However if you set regime=-1 it returns the top action card slot in the actioncard list. This is usefull if your manually adding actioncards through events.
150 Regimes AICombatMod 1. Regime Gives back the AI combat modifier. 0=none, >0 is the percentual bonus. (This is the AI difficulty in the scenario setup screen)
186 Regimes RegimeName 1. RegimeNr
195 Regimes ActionCardPPCost 1. Card slot # Returns the PP cost of the action card specified.
197 Regimes ActionCardTempVar 1. Card slot #; 2. Tempvar 0 or 1 Returns the tempvar number selected.
233 Regimes FirstActionCardWith 1. Regime # (or -1 for all actioncards); 2. Tempvar0 (or -1 if ignore); 3. Tempvar1 (or -1 if ignore); 4. Library name (or empty for ignore) Returns the actioncard slot# of the first card in the hand of specified regime with those exact tempvar values. If not found returns -1.
238 Regimes RegimeID 1. RegimeSlot#
241 Regimes RegimeSlot 1. Regime ID
10 Logic & Calculations RandomPercent (none)
22 Logic & Calculations DifferenceInDays 1. Year; 2. Month; 3. Day
38 Logic & Calculations IfNeighbour 1. X; 2. Y; 3. X2; 4. Y2
39 Logic & Calculations Distance 1. X; 2. Y; 3. X2; 4. Y2
69 Logic & Calculations ReturnCRLF (none)
79 Logic & Calculations DistanceClosestEnemyHex 1. Minimum (AI)VP value? 0=any; 2. from X; 3. from Y; 4. Max distance (-1=no maximum) Returns the distance. Max distance can be set to keep processing time down if necc.
80 Logic & Calculations EnemyTroopsCloseBy 1. Max Distance; 2. from X; 3. from Y; 4. Distance divider modifier (0=none) Max distance sets circle in which too look. Distance divider modifier set by what the power points of a unit are divided. if 0 they are not divided. if 1 they are divided by distance. if 2 by double distance.. etc..
93 Logic & Calculations GameVar 1. Nr
94 Logic & Calculations TempVar 1. Nr
101 Logic & Calculations DefinedAreaID 1. Slot#(0-9); 2. Value# Returns first Defined area with that slot&value coupled to it.
108 Logic & Calculations CalcGetPercent 1. Var X; 2. of Var Y Returns the percentage that var X makes up of var Y.
109 Logic & Calculations LocCounter (none) Returns the number of locations. remember counting starts at 0.
110 Logic & Calculations LocX 1. Location# Returns the number of locations. remember counting starts at 0.
111 Logic & Calculations LocY 1. Location# Returns the number of locations. remember counting starts at 0.
120 Logic & Calculations StringLength 1. String Return of 0 means an empty string has been tested.
140 Logic & Calculations CompareString 1. String1; 2. String2; 3. Mode Case insensitive. Mode=1 means it looks if the strings are exactly alike. Mode=2 same but all spaces are removed. Mode=3 means it looks if part of string1 is equal to string 2. Function returns 1 if equal or 0 if not.
141 Logic & Calculations Min 1. Value1; 2. Value2; 3. Mode Returns the lowest of the 2 values entered
142 Logic & Calculations Max 1. Value1; 2. Value2; 3. Mode Returns the highest of the 2 values entered
158 Logic & Calculations ForLocationProperty 1. X; 2. Y; 3. 1=airbase, 2=port(and sea next door) Returns 1 if property is available, Returns 0 if not.
163 Logic & Calculations GetCurrentDateString (none) Returns a string thats date formatted. Keep in mind that strings when compared using <,>,=, etc.. are compared as if they were dates.
164 Logic & Calculations GetDateString 1. Day; 2. Month; 3. Year; 4. Hour Returns a string thats date formatted. Keep in mind that strings when compared using <,>,=, etc.. are compared as if they were dates.
189 Logic & Calculations TempString 1. TempString #
190 Logic & Calculations PopupSkipped (none) Returns 1 if popup skipped otherwise returns 0.
191 Logic & Calculations ForUnitVisibleToPlayer 1. Unit Number; 2. Player Number Returns 1,2,3 if unit is visible. Returns 0 if it is not. 1=?mark counter, 2=fuzzy info, 3=exact strength known
200 Logic & Calculations Modulo 1. Number; 2. Divider Return (number) modulo (divider)... For example 4 modulo 3 = 1
204 Logic & Calculations Abs 1. Number Return the absolute of the number passed
205 Logic & Calculations SubString 1. String; 2. Position; 3. Length For example. If string='abcdef' then position 2, length 2 will return 'bc'
207 Logic & Calculations AppendString 1. String; 2. Position; 3. String to Insert; 4. Mode Mode 0 = Insert, Mode 1 = Overwrite. Example: string 'abcdef', pos=2, stringToInsert='123', mode=0 results in 'a123bcdef'
208 Logic & Calculations Capitalise 1. String; 2. Mode Mode 0 = Cap. 1st char of phrase, Mode 1 = Cap 1st char each word, Mode 2 = Cap all, Mode 3 = lowercase all
218 Logic & Calculations Sqrt 1. Number Returns the square root of the number.
219 Logic & Calculations RandomNumber 1. Number1; 2. Number2 Returns a random number including and between number1 and number2
222 Logic & Calculations Percentage 1. Number 1 (part); 2. Number 2 (total) Returns how much percentage points number 1 if of number 2.
224 Logic & Calculations StringPart 1. String; 2. Part # Returns the stringpart specified. Remember @ is used as a seperator.
225 Logic & Calculations StringPartCounter 1. String Returns the number of string parts in the string. Remember @ is used as a seperator.
226 Logic & Calculations Sqrt2 1. Number; 2. Number square roots; 3. Multiply result by Returns the square root of the number. Allow for betting calculation of floating point numbers.
227 Logic & Calculations Decimal 1. Number; 2. Divided by number; 3. Maximum decimals Returns a text string with the decimal number.
228 Logic & Calculations LogicPart 1. String; 2. Part # (1-3) Returns the logicpart specified as string. Remember <,>,=,/,*,+,- is used as a seperator as well as logic part 2.
230 Logic & Calculations DynamicElementHeight 1. Full Element Text Returns the number of pixels of height
231 Logic & Calculations ReplaceFlags 1. String; 2. Stringlist ID for Flags Returns a string equal to the string passed but with any [flags] removed. Flag name will be looked for in stringlist col0 and replaced by value in col1.
232 Logic & Calculations LookupValue 1. LookupString Returns string or number on a hardcoded basis. If hardcoded LookupString is not found original String is returned. See documentation.
234 Logic & Calculations MultiplyByVerySmallNumber 1. Value as string; 2. Multiplier; 3. Number of comma shifts Value as string allows you to work with long numbers. Number of comma shifts is applied to multiplier and then the value is multiplied by the multiplier. For exame value=1000, multiplier=5 and comma shift 2 results in 0.05*1000=50. Maximum 10 comma shifts.
235 Logic & Calculations Sqrt3 1. Number a; 2. Divide by number b; 3. Number of square roots; 4. Multiply by number c Returns (the square root of (the number a / number b)) multiplied by number c. Allow for betting calculation of floating point numbers.
236 Logic & Calculations PowerLong 1. Number Returns the power of the number as as string, allowing you to work with long numbers.
263 Logic & Calculations GetDateStringForRoundX 1. Round Returns a string thats date formatted.
2 Hex & Areaslots HexOwner 1. X; 2. Y
8 Hex & Areaslots UnitsFrom 1. AreaSlot; 2. AreaCode; 3. RegimeNr; 4. Not From PeopleNr
11 Hex & Areaslots LandscapeType 1. X; 2. Y
12 Hex & Areaslots LandscapeSprite 1. X; 2. Y
13 Hex & Areaslots Slot 1. X; 2. Y; 3. Slot#
24 Hex & Areaslots HQFor 1. X; 2. Y
31 Hex & Areaslots SFTypeInArea 1. AreaSlot; 2. AreaCode (-1=all hexes); 3. SFType; 4. Regime
32 Hex & Areaslots PowerPointsInArea 1. AreaSlot; 2. AreaCode; 3. Regime; 4. Land only (0=no check, 1=land theater only)
33 Hex & Areaslots SFTypeInXY 1. X; 2. Y; 3. SFType (-1=all); 4. Regime
40 Hex & Areaslots SFTypeGroupInXY 1. X; 2. Y; 3. SFType Group (-1=all); 4. Regime
55 Hex & Areaslots LocTypeXY 1. X; 2. Y
56 Hex & Areaslots StrucPtsXY 1. X; 2. Y
76 Hex & Areaslots SpecialType 1. X; 2. Y
77 Hex & Areaslots SpecialSprite 1. X; 2. Y
98 Hex & Areaslots HexVP 1. X; 2. Y
102 Hex & Areaslots HexPeople 1. X; 2. Y Returns people number of location here. if any. if not returns -1.
115 Hex & Areaslots HexName 1. X; 2. Y
116 Hex & Areaslots LocName 1. LocNr
117 Hex & Areaslots HexLocNr 1. X; 2. Y Returns -1 if no Location in hex. 0 or higher if present.
124 Hex & Areaslots RoadType 1. X; 2. Y; 3. Direction Direction: 0=n, 1=ne, 2=se, 3=s, 4=sw, 5=nw. Use direction -1 to test for all directions: first type found is returned. -1 is returned if none.
125 Hex & Areaslots RiverType 1. X; 2. Y; 3. Direction Direction: 0=n, 1=ne, 2=se, 3=s, 4=sw, 5=nw. Use direction -1 to test for all directions: first type found is returned. -1 is returned if none.
126 Hex & Areaslots Bridge 1. X; 2. Y; 3. Direction Direction: 0=n, 1=ne, 2=se, 3=s, 4=sw, 5=nw. Use direction -1 to test for all directions. Returns 0 for no bridge and 1 for yes bridge.
129 Hex & Areaslots RoadTypeSpecific 1. X; 2. Y; 3. Specific Road Type Check is specied roadtype is present in this hex. Returns 1 if is. Returns 0 if not.
193 Hex & Areaslots MoveOriginX 1. X; 2. Y You should only call this function if ExecSetMoveMatrix or ExecSetSupplyMatrix has been called before it. Any hex that has a moveable score (<9999) and that is not the source hex of the matrix called will have an origin. These 2 functions (x and y) will return that origin coordinate. -1 is returned if no origin hex is available.
194 Hex & Areaslots MoveOriginY 1. X; 2. Y You should only call this function if ExecSetMoveMatrix or ExecSetSupplyMatrix has been called before it. Any hex that has a moveable score (<9999) and that is not the source hex of the matrix called will have an origin. These 2 functions (x and y) will return that origin coordinate. -1 is returned if no origin hex is available.
201 Hex & Areaslots SlotOwnerPercentage 1. AreaSlot#; 2. Startval (>=); 3. Endval (<=); 4. Owner Returns a percentage of the specified areaslots between start and endvalue occupied by owner regime slot#
202 Hex & Areaslots SlotNotInAIList 1. AreaSlot#; 2. Startval (>=); 3. Endval (<=); 4. Max Dist Within areaslot returns a value out of the range between start and endvalue occupied by current regime owner slot# closest to SetAreaXY specified. Returns -1 if nothing found. Function only looks within supply range of SetAreaXY and only within MaxDist.
203 Hex & Areaslots SlotValueFirstXY 1. AreaSlot#; 2. Value; 3. What? 1=x,2=y,3=reg Within areaslot returns the x,y coordinate first found with the value given (x or y). Only values >= 1 work.
223 Hex & Areaslots Neighbour 1. X; 2. Y; 3. Direction; 4. Mode Direction=1-6. Mode=1 returns X. Mode=2 returns Y. Returns -1 if neighbour is off-map.
239 Hex & Areaslots LocationID 1. LocationSlot#
240 Hex & Areaslots LocationSlot 1. Location ID
257 Hex & Areaslots HexLocNr2 1. X; 2. Y Only use of Supply Bases and Sources. Returns -1 if no Location in hex. 0 or higher if present.
258 Hex & Areaslots LocTypeXY2 1. X; 2. Y
43 Unit TotalUnits (none)
44 Unit UnitOwner 1. Unit Nr
45 Unit UnitHQ 1. Unit Nr
46 Unit UnitX 1. Unit Nr
47 Unit UnitY 1. Unit Nr
48 Unit UnitHistoricalID 1. Unit Nr
49 Unit UnitIsHQ 1. Unit Nr
51 Unit UnitInHQChain 1. Unit Nr; 2. HQ Nr
52 Unit UnitCommanderStaffPercent 1. Unit Nr
53 Unit UnitHQPower 1. Unit Nr
54 Unit FirstUnitWithHistoricalID 1. Historical ID
57 Unit ClosestCommanderUnit 1. X; 2. Y; 3. Regime
61 Unit HistoricalUnitTempVar 1. Unit Nr (or -1 to use hist.); 2. TempVar Nr (1-5), 6=AiZoneListNr; 3. Use Historical Unit ID
62 Unit CommanderDescript/Name 1. Unit Nr; 2. 0=Descript, 1=Name; 3. HisUnit ID overrule (<=0 is no overrule)
63 Unit CommanderXP 1. Unit Nr (or -1); 2. Overrule His Unit ID (or -1); 3. 0=Xp, 1=Total Cards, 2=Specific Card, 3=Total Ev, 4=Spec Ev; 4. Opt: card or ev#
67 Unit UnitRdn 1. Unit#
68 Unit UnitSFType 1. Unit #; 2. SFType Group (-1 for none); 3. Specific SFType (-1 for none) Returns the number of individuals in this unit
70 Unit UnitName 1. Unit#
73 Unit UnitTempOwner 1. Unit Nr Returns the real owner. If this is a subregime it will actually give back the subregime regime # instead of the uberregime which the normal CheckUnitOwner will return.
75 Unit UnitPower 1. Unit Nr Returns the real total power points in the unit.
78 Unit UnitSelectable 1. Unit Nr Returns 0 if not selectable. returns 1 if selectable.
81 Unit UnitMor 1. Unit# Keep in mind this is an average of the subformations.
118 Unit HexUnitCounter 1. X; 2. Y Returns -1 if no units. Returns 0 is one unit (in slot 0). Returns 1 if two units present (one in slot 0, one in slot1), etc..
119 Unit HexUnit 1. X; 2. Y; 3. Unit Slot You should use CheckHexUnitCounter to determine the number of units on the hex. Start with slot=0!
121 Unit UnitStaffPercent 1. Unit Nr; 2. CheckMode=0,1,2 Return the staff % of the unit... you might want to use this check in combination with CheckUnitHqPower since distance is not checked for in this event. Check Mode 0 returns staff%. Check Mode 1 returns combat mod%, Check Mode 2 returns morale mod%.
127 Unit HisVar 1. His Unit ID#; 2. Type# Returns value if type is present. If type is not present it returns 0.
128 Unit UnitRecon 1. Unit#; 2. Include land theater 0=no, 1=yes; 3. Include sea theater 0=no, 1=yes; 4. Include air theater 0=no, 1=yes Returns total recon points in the unit.
130 Unit HistoricalUnitAverageXP 1. Unit# Will look up other units on map with the same historical unit and return average xp
133 Unit TotalHistoricalUnits (none)
134 Unit GetHistoricalUnitID 1. Slot# Keep in mind that this function should be used to scroll through all historical units using a looper from 0 to CheckTotalHistoricalUnits. Use this function to get the actual ID to be used in other functions.
135 Unit GetHistoricalUnitRegime 1. Historical Unit ID#
136 Unit PeopleUnderHQ 1. HQ level to check; 2. Troop people; 3. HQ people; 4. regime# A complicated function. HQ level 1 is HQs with historical unit set to Corps. HQ level 2 is only HQs with historical HQ set to Army, 3=armygroup, 4=high command.. Function returns % of total power points of people on map is under a hq whose historical unit people is set to hqppl. This function could for example be used to check if axis minor are under wehrmacht HQs or under their own.
137 Unit GetHistoricalUnitPeople 1. Historical Unit ID#
138 Unit GetHistoricalUnitType 1. Historical Unit ID# Returns the type. 5=corps, 6=army, etc..
139 Unit GetHistoricalUnitOfficer 1. Historical Unit ID# returns 1 if officer, returns 0 if not. Basicly the length of officer name is checked.
143 Unit GetHistoricalUnitName 1. Historical Unit ID#
144 Unit GetHistoricalSubparts 1. Historical Unit ID#
146 Unit UnitAP 1. Unit# Keep in mind this is the lowest AP subformations.
151 Unit IsUnitAPreDef 1. Unr# Returns -1 if not a predef. Returns the predef ID # if it is a predef.
153 Unit UnitXP 1. Unit#; 2. Only if staff (0=no,1=yes) Keep in mind that it returns the highest XP found in any subformation.
154 Unit GetHistoricalUnitCommanderName 1. Historical Unit ID# Returns the commandername (not the his.unit name!). If no commander empty string is returned.
155 Unit FindHistoricalUnitWithCommanderName 1. Commander Name Returns the first historical unit ID number of a unit ON the map with this commander name present. -1= none find.
156 Unit UnitHQChanged 1. Unit Nr Returns 1 if the unit HQ has been changed in this turn. Returns 0 if not.
157 Unit HistoricalUnitAirAndNavy 1. His Unit ID#; 2. Check for air theater troops? 0=no,1=yes; 3. Check for navy theater troops? 0=no,1=yes Returns 1 if those troops are present. 0 if not.
185 Unit HistoricalUnitMaster 1. Historical Unit ID Returns the historical unit model ID
187 Unit UnitActivity 1. Unit Nr; 2. Activity Data Type These stats are reset after lateTurn events are executed. Activity Data Types are 1=Offensive combat AP spent, 2=Defensive combat AP spent, 3=Move AP spent, 4=Off+Def AP spent, 5=Off+Def+Move AP spent. 6=Did unit spent move AP or moved (0=no, 1=yes)
196 Unit GetHistoricalUnitSlot 1. ID# Supply the historical unit ID# and get the slot# in return. If not found it will return -1.
199 Unit GetCommanderPoolValue 1. ID# Returns 1 if in pool. Returns 0 if not.
209 Unit UnitEntrench 1. Unit# Keep in mind this is an average of the subformations.
211 Unit UnitIntegrity 1. Unit# Returns a percentage between 0-100.
212 Unit UnitSupplyConsumption 1. Unit#; 2. Mode Mode<=1 : Returns a percentage between 0-100. Mode 2: Returns missing supply, Mode 3: Returns missing fuel
58 Stringlist StringList 1. Stringlist ID; 2. Row; 3. Col
59 Stringlist StringReplace 1. From String; 2. Which substring; 3. Replace with what
64 Stringlist StringListRows 1. StringList ID
65 Stringlist StringListCols 1. StringList ID
66 Stringlist StringListLastID (none)
131 Stringlist RandomRowStringList 1. Stringlist ID; 2. Col used as weight (-1=none)
132 Stringlist FindInStringList 1. Stringlist ID; 2. In Col; 3. Find Value Returns row# where value is found or -1 if not.
206 Stringlist RandomRowStringList2 1. Stringlist ID; 2. Col used as weight (-1=none); 3. Col used as block (-1=none) Concerning the block column. <= 0 will be considered NOT blocked. >= 1 will be considered blocked. Returns -1 if no suitable row found.
210 Stringlist ImportStringList 1. Stringlist ID; 2. Filename Will replace said stringlist with the contents of the filename. This will be a full replacement and nothing of old contents will remain. Directory used is the 'metadata' directory. Please include a file extension in the filename like .txt. Returns 1 on succes. Returns -1 on file not found. Returns -2 on data corruption of file.
213 Stringlist Key 1. Stringlist ID; 2. Key name Presumes key names in column 0 and values in column 1
220 Stringlist StringListQuick 1. Stringlist ID; 2. Row where col0 has value..; 3. Col
229 Stringlist KeyExists 1. Stringlist ID; 2. Key name If key exists returns 1 otherwise 0
237 Stringlist StringListTotal 1. Stringlist ID; 2. Col#; 3. Must have value; 4. Add up values in col2# If you put -1 for Col# than all values will be added up.
242 Stringlist FindInStringList2 1. Stringlist ID; 2. In Col; 3. Find Value; 4. Col # must have value >0 Returns row# where value is found or -1 if not.
245 Stringlist DoubleKey 1. Stringlist ID; 2. Col 0 value; 3. Col 1 Key name Presumes an ID value in col 0 and key names in column 1 and values to look up in column 2
246 Stringlist DoubleKeyExists 1. Stringlist ID; 2. Col 0 value; 3. Col 1 Key name If key exists returns 1 otherwise 0
83 SFType/ItemTypes SFTypePower 1. SFType#; 2. SFType Targetgroup; 3. 1=attack score, 2=defend score
84 SFType/ItemTypes SFTypeDescription 1. SFType#
85 SFType/ItemTypes SFTypeHP 1. SFType#; 2. SFType Targetgroup; 3. 1=attack hp, 2=defend hp
86 SFType/ItemTypes SFTypeMoveType 1. SFType#
87 SFType/ItemTypes SFTypeMoveRedux 1. SFType#
88 SFType/ItemTypes SFTypeModelLastState 1. SFType#; 2. Research#
89 SFType/ItemTypes SFTypeLogo 1. SFType#; 2. Logo#
92 SFType/ItemTypes SFTypeFuelUse 1. SFtype#; 2. 1=ForMovement, 2=ForCombat
96 SFType/ItemTypes SFTypeVar 1. SFType; 2. Var#
97 SFType/ItemTypes SFTypeItem 1. SFType#
122 SFType/ItemTypes SFTypeRatio 1. SFType#
123 SFType/ItemTypes SFTypeName 1. SFType#
182 SFType/ItemTypes Visible 1. SFType# Returns 1 if visible (dont show in list=false), returns 0 if not (dont show in list=true). Invisible SFTypes are used as base models in the Intermediate TroopType editor.
183 SFType/ItemTypes SFTypeCounter (none) Returns the highest SFType slot.
184 SFType/ItemTypes SFTypeTheaterOrGroup 1. SFType#; 2. 1=Check Theater, 2=CheckUnitGroup Theater codes are: 0=land, 1=sea, 2=air.
251 SFType/ItemTypes ChecSFTypeFav 1. SfType #; 2. Targetgroup#; 3. Type 1=favscore for regular attack, 2=for artillery attack
252 SFType/ItemTypes ChecSFTypeArtPower 1. SfType #; 2. Targetgroup#
253 SFType/ItemTypes ChecSFTypeStat 1. SfType #; 2. StatNumber Stat Numbers: 1=weight, 2=carrycap, 3=canDoParadrop(0/1), 4=EP, 5=BlowBridgPts, 6=BasicSupNeed, 7=SupCarry, 8=ReconPts, 9=HidePts, 10=AntiSupplyPts, 11=AntiSupplyRange, 12=AnitSupplySea, 13=InitiativeAtt, 14=InitiativeDef, 15=Attacks, 16=StackPts, 17=RearArea(0/1), 18=ArtRange, 19=Fav.Target tries, 20=AA-range, 21=HitKill%, 22=HitRetreat%, 23=ArtilleryModSfTypeNr, 24=maxAttacked, 25=moveRedux
254 SFType/ItemTypes ChecSFTypeLandscapeMod 1. SfType #; 2. LandscapeType#; 3. Type 1=offMod %, 2=defMod %.. 100=noMod, 50=half, 200=double
113 DC1 AI MaxFuelUse 1. Regime (-1=all); 2. Fuel Type (-1=all)
159 Library Checks GetStringlistID 1. Library Name; 2. Stringlist ID Use when writing library events to get correct stringlist when library is used. This Check returns always the correct ID of the stringlist.
160 Library Checks LibVarGlobal 1. Library Name; 2. Variable Name Returns the value of specified global libvar.
161 Library Checks GetEventPic 1. Library Name; 2. Orig eventPic SlotNr Returns the current eventPic Nr. If you are writing library events that use eventpics you should always call this check first.
162 Library Checks GetSmallPic 1. Library Name; 2. Orig smallPic SlotNr Returns the current smallPic Nr. If you are writing library events that use small pics you should always call this check first.
165 Library Checks GetHistoricalIDByLib 1. Library Name; 2. ID Returns the ID of the historical unit/historical model in the current scenario.
166 Library Checks GetHistoricalIDForCommanderByLib 1. Library Name; 2. ID Returns the ID of the commander in the current scenario.
167 Library Checks GetPeopleByLib 1. Library Name; 2. ID Returns the slot of the people in the current scenario.
168 Library Checks GetRegimeByLib 1. Library Name; 2. ID Returns the slot of the regime in the current scenario.
169 Library Checks GetSFTypeByLib 1. Library Name; 2. ID Returns the slot of the SFType in the current scenario.
170 Library Checks GetEventByLib 1. Library Name; 2. ID Returns the slot of the event in the current scenario.
171 Library Checks GetCardByLib 1. Library Name; 2. Library Slot Returns the slot of the actioncard in the current scenario.
172 Library Checks LibVarHistorical 1. Historical Unit Slot (in this scenario); 2. Library Name; 3. LibVar Name Returns the value of specified Libvar for historical unit or historical model.
173 Library Checks LibVarLandscape 1. Landscape Slot (in this scenario); 2. Library Name; 3. LibVar Name Returns the value of specified Libvar.
174 Library Checks LibVarPeople 1. People Slot (in this scenario); 2. Library Name; 3. LibVar Name Returns the value of specified Libvar.
175 Library Checks LibVarRegime 1. Regime Slot (in this scenario); 2. Library Name; 3. LibVar Name Returns the value of specified Libvar.
176 Library Checks LibVarRiver 1. River Slot (in this scenario); 2. Library Name; 3. LibVar Name Returns the value of specified Libvar.
177 Library Checks LibVarRoad 1. Road Slot (in this scenario); 2. Library Name; 3. LibVar Name Returns the value of specified Libvar.
178 Library Checks LibVarSFType 1. SFType Slot (in this scenario); 2. Library Name; 3. LibVar Name Returns the value of specified Libvar.
179 Library Checks LibVarLocType 1. LocType Slot (in this scenario); 2. Library Name; 3. LibVar Name Returns the value of specified Libvar.
180 Library Checks LibVarHex 1. X; 2. Y; 3. Library Name; 4. LibVar Name Returns the value of specified libvar of that hex. No value set returns 0.
181 Library Checks LibVarCommander 1. Commanders Historical Unit Slot; 2. Library Name; 3. LibVar Name Returns the value of specified Libvar for historical commander.
188 Library Checks GetPreDefIDByLib 1. Library Name; 2. PreDefID Returns the preDefID in the current scenario for a the PreDefID inside a specific library.
198 Library Checks LibraryOfCard 1. Action Card Slot Returns a string with the library name.
250 Library Checks GetReinfTypeByLib 1. Library Name; 2. ID Returns the ID of the Reinf.Type in the current scenario.
260 Library Checks LibraryOfSFType 1. SFType Slot Returns a string with the library name.
261 Library Checks DLC 1. DLC ID Code Not documented. Usage by other than Vic is not advised.
262 Library Checks LibraryOfThisEvent 1. Returns a string with the library name.
265 Library Checks SubVersion (none) Returns SubVersion (product6: 1=dc5 for example) if exists and 0/-1 if not
214 UDS TextHeight 1. Full Element Text Returns the number of pixels
215 UDS UDSInput 1. Key name Returns value for key
255 UDS TextWidth 1. Full Element Text Returns the number of pixels
256 UDS SuperAdmin (none) Returns 0 if normal player, Returns 1 is super admin
259 UDS TempUDSInput 1. TEMP Key name Returns TEMP UdsKey value for key
264 UDS TempUDSInputExists 1. TEMP Key name Returns 1 if exists and 0 if not
216 Random Related AreaslotWaterLevel 1. Height Map Areaslot#; 2. Avg water points per hex Expects an areaslot with height values that use the same scale as the avg water points. If you would use earth heigh map in meters and specify 2000 meters of water per hex you'll get the real earth seas as a result.
217 Random Related AreaslotSpecial 1. Areaslot#; 2. SpecialType; 3. Second Areaslot#; 4. Second Areaslot Value SpecialType 1 is highest, 2 is lowest, 3 is average. You can specify -1 to not use optional second areaslot. If you do however you can limit the hexes being read to those with the specified value
221 Random Related AreaCount 1. Areaslot#; 2. From; 3. Too Returns the number of hex equal or between FROM and TOO.
243 Random Related LocationLISitem 1. Location Slot#; 2. LIS Item ID#
244 Random Related UnitLISitem 1. Unit Slot#; 2. LIS Item ID#
247 Random Related LogicString 1. Stringlist ID for Flags; 2. Stringlist ID for Flag Instructions; 3. Logic String
248 Random Related LIS 1. Loc nr; 2. To X; 3. To Y
249 Random Related HardcodedIF 1. Hardcoded Number; 2. Story Id; 3. Instance 1 Id; 4. Instance 2 Id Second-level gateway — see §2 for the full sub-function table.
82 — OBSOLETE 1. SFType#

This doc was generated from extracting data from Shadow Empire version 1.32a on 2026-06-05 06:56 UTC.