Scripting 101
Moderator: MOD_GGWaW_2
-
kirkgregerson
- Posts: 497
- Joined: Wed Apr 09, 2008 2:21 pm
Scripting 101
Can anybody give me an example script that would add some units to a region once and enemy gain control of a certain region. I'd probably be adding a date criteria to that as well. Like if it were > 1943 or something.
That would be a great start to my knowledge base.. Thanks!
That would be a great start to my knowledge base.. Thanks!
-
WanderingHead
- Posts: 2134
- Joined: Wed Sep 22, 2004 8:12 am
- Location: GMT-8
RE: Scripting 101
ORIGINAL: kirkgregerson
Can anybody give me an example script that would add some units to a region once and enemy gain control of a certain region. I'd probably be adding a date criteria to that as well. Like if it were > 1943 or something.
The only way this is possible is as a random political event.
Look at the random political events in any of the wawgoldscendat*.txt files. You would want something like this
Code: Select all
// ----------------------------
// --- Russians garrison Kiev after Rumania goes German ---
// ----------------------------
EVENT_POLI,2,Russia,0,1,Russia garrisons Kiev
EVENT_POLI_IGNORE_PRIOR,1
EVENT_POLI_DESCR,Russians garrison Kiev after Rumania goes German
EVENT_POLI_NOTICE,Russians garrison Kiev after Rumania goes German
// event pre-requisites
EVENT_POLI_PLYR_NOT_SURR,PLAYER_GER
// player control requirements
EVENT_PLAYERCTL_MINNUM,1
EVENT_PLAYERCTL_PLYR_LIST,PLAYER_GER
EVENT_PLAYERCTL_REG_LIST,91 // region 91 (Rumania) must be German controlled
// event probability
EVENT_BASE_PROB,100 // prob=100%, always happens if pre-requisites satisfied
// event effects
EVENT_ADD_UNITS,106,PLAYER_SOV,INFANTRY,2,end // 106=Kiev, add 2 infantry
EVENT_ADD_UNITS,106,PLAYER_SOV,ARTILLERY,1,end // 106=Kiev, add 1 artilleryThere are comments in wawgoldscendat39_gg.txt which describe all of the political events syntax, you can look there for more details and additional capabilities.
(caveat - the above should work, but it is untested, there could be syntax errors that would cause a problem)
-
kirkgregerson
- Posts: 497
- Joined: Wed Apr 09, 2008 2:21 pm
RE: Scripting 101
Thanks!!! Yes, I did find the file that has some good documentation for how to script events.
-
kirkgregerson
- Posts: 497
- Joined: Wed Apr 09, 2008 2:21 pm
RE: Scripting 101
I wrote some scripts to help the Chinese a bit and to reflect some US aid that was historic.
// ----------------------------
// --- Changsha falls and USA sends aid to China ---
// ----------------------------
EVENT_POLI,40,China,0,1,USA sends China aid
EVENT_POLI_IGNORE_PRIOR,1
EVENT_POLI_DESCR,Changsha falls and USA sends aid to China
EVENT_POLI_NOTICE,Changsha falls and USA sends aid to China
// event pre-requisites
EVENT_POLI_PLYR_NOT_SURR,PLAYER_UN
EVENT_POLI_PLYR_NOT_SURR,PLAYER_CHI
// player control requirements
EVENT_PLAYERCTL_MINNUM,1
EVENT_PLAYERCTL_PLYR_LIST,PLAYER_JAP
EVENT_PLAYERCTL_REG_LIST,197 // region 197 (Changsha) must be Japanese controlled
EVENT_PLAYERCTL_MINNUM,1
EVENT_PLAYERCTL_PLYR_LIST,PLAYER_CHI
EVENT_PLAYERCTL_REG_LIST,344 // region 344 (Chunking) must be Chinese controlled
// event probability
EVENT_BASE_PROB,100 // prob=100%, always happens if pre-requisites satisfied
// event effects
EVENT_ADD_UNITS,344,PLAYER_CHI,INFANTRY,1,end // 344=Chunking, add 1 infantry
EVENT_ADD_UNITS,344,PLAYER_CHI,MILITIA,1,end // 344=Chunking, add 1 militia
EVENT_ADD_UNITS,344,PLAYER_CHI,SUPPLY,2,end // 344=Chunking, add 2 Supplies
// ----------------------------
// --- Kunming falls and USA sends aid to China ---
// ----------------------------
EVENT_POLI,41,China,0,1,USA sends China aid
EVENT_POLI_IGNORE_PRIOR,1
EVENT_POLI_DESCR,Kunming falls and USA sends aid to China
EVENT_POLI_NOTICE,Kunming falls and USA sends aid to China
// event pre-requisites
EVENT_POLI_PLYR_NOT_SURR,PLAYER_UN
EVENT_POLI_PLYR_NOT_SURR,PLAYER_CHI
// player control requirements
EVENT_PLAYERCTL_MINNUM,1
EVENT_PLAYERCTL_PLYR_LIST,PLAYER_JAP
EVENT_PLAYERCTL_REG_LIST,169 // region 169 (Kunming) must be Japanese controlled
EVENT_PLAYERCTL_MINNUM,1
EVENT_PLAYERCTL_PLYR_LIST,PLAYER_CHI
EVENT_PLAYERCTL_REG_LIST,344 // region 344 (Chunking) must be Chinese controlled
// event probability
EVENT_BASE_PROB,100 // prob=100%, always happens if pre-requisites satisfied
// event effects
EVENT_ADD_UNITS,344,PLAYER_CHI,INFANTRY,1,end // 344=Chunking, add 1 infantry
EVENT_ADD_UNITS,344,PLAYER_CHI,MILITIA,1,end // 344=Chunking, add 1 militia
EVENT_ADD_UNITS,344,PLAYER_CHI,SUPPLY,2,end // 344=Chunking, add 2 Supplies
// ----------------------------
// --- Lanchow falls and USA sends aid to China ---
// ----------------------------
EVENT_POLI,42,China,0,1,USA sends China aid
EVENT_POLI_IGNORE_PRIOR,1
EVENT_POLI_DESCR,Lanchow falls and USA sends aid to China
EVENT_POLI_NOTICE,Lanchow falls and USA sends aid to China
// event pre-requisites
EVENT_POLI_PLYR_NOT_SURR,PLAYER_UN
EVENT_POLI_PLYR_NOT_SURR,PLAYER_CHI
// player control requirements
EVENT_PLAYERCTL_MINNUM,1
EVENT_PLAYERCTL_PLYR_LIST,PLAYER_JAP
EVENT_PLAYERCTL_REG_LIST,167 // region 167 (Lanchow) must be Japanese controlled
EVENT_PLAYERCTL_MINNUM,1
EVENT_PLAYERCTL_PLYR_LIST,PLAYER_CHI
EVENT_PLAYERCTL_REG_LIST,344 // region 344 (Chunking) must be Chinese controlled
// event probability
EVENT_BASE_PROB,100 // prob=100%, always happens if pre-requisites satisfied
// event effects
EVENT_ADD_UNITS,344,PLAYER_CHI,INFANTRY,1,end // 344=Chunking, add 1 infantry
EVENT_ADD_UNITS,344,PLAYER_CHI,MILITIA,1,end // 344=Chunking, add 1 militia
EVENT_ADD_UNITS,344,PLAYER_CHI,SUPPLY,2,end // 344=Chunking, add 2 Supplies
// ----------------------------
// --- Chunking falls and USA sends aid to China ---
// ----------------------------
EVENT_POLI,43,China,0,1,USA sends China aid
EVENT_POLI_IGNORE_PRIOR,1
EVENT_POLI_DESCR,Chunking falls and USA sends aid to China
EVENT_POLI_NOTICE,Chunking falls and USA sends aid to China
// event pre-requisites
EVENT_POLI_PLYR_NOT_SURR,PLAYER_UN
EVENT_POLI_PLYR_NOT_SURR,PLAYER_CHI
// player control requirements
EVENT_PLAYERCTL_MINNUM,1
EVENT_PLAYERCTL_PLYR_LIST,PLAYER_JAP
EVENT_PLAYERCTL_REG_LIST,344 // region 344 (Chunking) must be Japanese controlled
EVENT_PLAYERCTL_MINNUM,1
EVENT_PLAYERCTL_PLYR_LIST,PLAYER_CHI
EVENT_PLAYERCTL_REG_LIST,161 // region 161 (Sinking) must be Chinese controlled
// event probability
EVENT_BASE_PROB,100 // prob=100%, always happens if pre-requisites satisfied
// event effects
EVENT_ADD_UNITS,344,PLAYER_CHI,INFANTRY,1,end // 161=Sinking, add 1 infantry
EVENT_ADD_UNITS,344,PLAYER_CHI,MILITIA,1,end // 161=Sinking, add 1 militia
EVENT_ADD_UNITS,344,PLAYER_CHI,Flak,1,end // 161=Sinking, add 1 flak
EVENT_ADD_UNITS,344,PLAYER_CHI,SUPPLY,1,end // 161=Sinking, add 1 Supplies
// ----------------------------
// --- Changsha falls and USA sends aid to China ---
// ----------------------------
EVENT_POLI,40,China,0,1,USA sends China aid
EVENT_POLI_IGNORE_PRIOR,1
EVENT_POLI_DESCR,Changsha falls and USA sends aid to China
EVENT_POLI_NOTICE,Changsha falls and USA sends aid to China
// event pre-requisites
EVENT_POLI_PLYR_NOT_SURR,PLAYER_UN
EVENT_POLI_PLYR_NOT_SURR,PLAYER_CHI
// player control requirements
EVENT_PLAYERCTL_MINNUM,1
EVENT_PLAYERCTL_PLYR_LIST,PLAYER_JAP
EVENT_PLAYERCTL_REG_LIST,197 // region 197 (Changsha) must be Japanese controlled
EVENT_PLAYERCTL_MINNUM,1
EVENT_PLAYERCTL_PLYR_LIST,PLAYER_CHI
EVENT_PLAYERCTL_REG_LIST,344 // region 344 (Chunking) must be Chinese controlled
// event probability
EVENT_BASE_PROB,100 // prob=100%, always happens if pre-requisites satisfied
// event effects
EVENT_ADD_UNITS,344,PLAYER_CHI,INFANTRY,1,end // 344=Chunking, add 1 infantry
EVENT_ADD_UNITS,344,PLAYER_CHI,MILITIA,1,end // 344=Chunking, add 1 militia
EVENT_ADD_UNITS,344,PLAYER_CHI,SUPPLY,2,end // 344=Chunking, add 2 Supplies
// ----------------------------
// --- Kunming falls and USA sends aid to China ---
// ----------------------------
EVENT_POLI,41,China,0,1,USA sends China aid
EVENT_POLI_IGNORE_PRIOR,1
EVENT_POLI_DESCR,Kunming falls and USA sends aid to China
EVENT_POLI_NOTICE,Kunming falls and USA sends aid to China
// event pre-requisites
EVENT_POLI_PLYR_NOT_SURR,PLAYER_UN
EVENT_POLI_PLYR_NOT_SURR,PLAYER_CHI
// player control requirements
EVENT_PLAYERCTL_MINNUM,1
EVENT_PLAYERCTL_PLYR_LIST,PLAYER_JAP
EVENT_PLAYERCTL_REG_LIST,169 // region 169 (Kunming) must be Japanese controlled
EVENT_PLAYERCTL_MINNUM,1
EVENT_PLAYERCTL_PLYR_LIST,PLAYER_CHI
EVENT_PLAYERCTL_REG_LIST,344 // region 344 (Chunking) must be Chinese controlled
// event probability
EVENT_BASE_PROB,100 // prob=100%, always happens if pre-requisites satisfied
// event effects
EVENT_ADD_UNITS,344,PLAYER_CHI,INFANTRY,1,end // 344=Chunking, add 1 infantry
EVENT_ADD_UNITS,344,PLAYER_CHI,MILITIA,1,end // 344=Chunking, add 1 militia
EVENT_ADD_UNITS,344,PLAYER_CHI,SUPPLY,2,end // 344=Chunking, add 2 Supplies
// ----------------------------
// --- Lanchow falls and USA sends aid to China ---
// ----------------------------
EVENT_POLI,42,China,0,1,USA sends China aid
EVENT_POLI_IGNORE_PRIOR,1
EVENT_POLI_DESCR,Lanchow falls and USA sends aid to China
EVENT_POLI_NOTICE,Lanchow falls and USA sends aid to China
// event pre-requisites
EVENT_POLI_PLYR_NOT_SURR,PLAYER_UN
EVENT_POLI_PLYR_NOT_SURR,PLAYER_CHI
// player control requirements
EVENT_PLAYERCTL_MINNUM,1
EVENT_PLAYERCTL_PLYR_LIST,PLAYER_JAP
EVENT_PLAYERCTL_REG_LIST,167 // region 167 (Lanchow) must be Japanese controlled
EVENT_PLAYERCTL_MINNUM,1
EVENT_PLAYERCTL_PLYR_LIST,PLAYER_CHI
EVENT_PLAYERCTL_REG_LIST,344 // region 344 (Chunking) must be Chinese controlled
// event probability
EVENT_BASE_PROB,100 // prob=100%, always happens if pre-requisites satisfied
// event effects
EVENT_ADD_UNITS,344,PLAYER_CHI,INFANTRY,1,end // 344=Chunking, add 1 infantry
EVENT_ADD_UNITS,344,PLAYER_CHI,MILITIA,1,end // 344=Chunking, add 1 militia
EVENT_ADD_UNITS,344,PLAYER_CHI,SUPPLY,2,end // 344=Chunking, add 2 Supplies
// ----------------------------
// --- Chunking falls and USA sends aid to China ---
// ----------------------------
EVENT_POLI,43,China,0,1,USA sends China aid
EVENT_POLI_IGNORE_PRIOR,1
EVENT_POLI_DESCR,Chunking falls and USA sends aid to China
EVENT_POLI_NOTICE,Chunking falls and USA sends aid to China
// event pre-requisites
EVENT_POLI_PLYR_NOT_SURR,PLAYER_UN
EVENT_POLI_PLYR_NOT_SURR,PLAYER_CHI
// player control requirements
EVENT_PLAYERCTL_MINNUM,1
EVENT_PLAYERCTL_PLYR_LIST,PLAYER_JAP
EVENT_PLAYERCTL_REG_LIST,344 // region 344 (Chunking) must be Japanese controlled
EVENT_PLAYERCTL_MINNUM,1
EVENT_PLAYERCTL_PLYR_LIST,PLAYER_CHI
EVENT_PLAYERCTL_REG_LIST,161 // region 161 (Sinking) must be Chinese controlled
// event probability
EVENT_BASE_PROB,100 // prob=100%, always happens if pre-requisites satisfied
// event effects
EVENT_ADD_UNITS,344,PLAYER_CHI,INFANTRY,1,end // 161=Sinking, add 1 infantry
EVENT_ADD_UNITS,344,PLAYER_CHI,MILITIA,1,end // 161=Sinking, add 1 militia
EVENT_ADD_UNITS,344,PLAYER_CHI,Flak,1,end // 161=Sinking, add 1 flak
EVENT_ADD_UNITS,344,PLAYER_CHI,SUPPLY,1,end // 161=Sinking, add 1 Supplies
-
kirkgregerson
- Posts: 497
- Joined: Wed Apr 09, 2008 2:21 pm
RE: Scripting 101
Is there a way to change a region to a fort after a certain date on unit # conditions too? Would like to write a script to make Western France and Lowlands a fort=1 region on a turn when
- date >= spr 44
- axis have >= 8 infantry or militia units (workers really)
- 10 supplies (supplies would be removed after end event)
- date >= spr 44
- axis have >= 8 infantry or militia units (workers really)
- 10 supplies (supplies would be removed after end event)
-
WanderingHead
- Posts: 2134
- Joined: Wed Sep 22, 2004 8:12 am
- Location: GMT-8
RE: Scripting 101
ORIGINAL: kirkgregerson
Is there a way to change a region to a fort after a certain date on unit # conditions too? Would like to write a script to make Western France and Lowlands a fort=1 region on a turn when
It is not possible.
I think this one would be undesirable. Amphibious landings are hard enough as it is.
-
kirkgregerson
- Posts: 497
- Joined: Wed Apr 09, 2008 2:21 pm
RE: Scripting 101
Thanks. You're probably right. But it would still be nice to build forts or entrenchments at maybe a high cost? Would allow shifting more forces to another theater.
On a side note is there such thing as a fort = 2? How did they get the fort icon to show for the Maginot? Where to toggle if a fort stays or is destroyed upon enemy capture?
On a side note is there such thing as a fort = 2? How did they get the fort icon to show for the Maginot? Where to toggle if a fort stays or is destroyed upon enemy capture?
-
WanderingHead
- Posts: 2134
- Joined: Wed Sep 22, 2004 8:12 am
- Location: GMT-8
RE: Scripting 101
ORIGINAL: kirkgregerson
Thanks. You're probably right. But it would still be nice to build forts or entrenchments at maybe a high cost? Would allow shifting more forces to another theater.
Well, if we were designing an in development game, I might propose that supplies could be expended to turn units into "fortified" units. In wouldf cost 5 or 10 or 15 supplies to get this status (would have to play with it to settle). It would be indicated with a little graphic on the unit chip, and would be removed if the unit were moved (i.e. corresponds to a static implacement for that unit).
Probably it would just increase evasion by 1 or some such.
ORIGINAL: kirkgregerson
On a side note is there such thing as a fort = 2? How did they get the fort icon to show for the Maginot? Where to toggle if a fort stays or is destroyed upon enemy capture?
You'll have to try it and see. I think that if you create a fort in the regions*.txt file then it should show the graphic.
E France loses its fort status if/when France surrenders. If you set fort=2 for E France, then it will *not* be removed when France surrenders. This is the only significance of fort=2 (I actually added this feature for Lebatron, who wanted to do exactly that in UV2.0+, so that the Germans could defend E France better ... personally I don't think it is warranted, I prefer it as it is).
-
kirkgregerson
- Posts: 497
- Joined: Wed Apr 09, 2008 2:21 pm
RE: Scripting 101
Hmm, I can't seem to decipher what is a fort region for non port regions? The icon for the maginot must be a special case, hard coded? Setting fort = 2 (don't destroy?) doesn't show the icon and there's no visiual on the UI to determine non-port regions are forts? I know it will say in combat, but would be nice to see that on the map? Am I missing something?
Thanks...
Thanks...
-
WanderingHead
- Posts: 2134
- Joined: Wed Sep 22, 2004 8:12 am
- Location: GMT-8
RE: Scripting 101
ORIGINAL: kirkgregerson
Hmm, I can't seem to decipher what is a fort region for non port regions? The icon for the maginot must be a special case, hard coded? Setting fort = 2 (don't destroy?) doesn't show the icon and there's no visiual on the UI to determine non-port regions are forts? I know it will say in combat, but would be nice to see that on the map? Am I missing something?
Blast it, I can't figure it out either. It should work.
I looked through the code and it is strangely (very strangely) impossible to find. Frankly, I just can't find any of the code that deals with the E France fort icon.
Very odd, I am confused, but I am also giving up. I am afraid that your attempt may not be successful.