General Scripting Q/A

Please post here for questions and discussion about modding for Strategic Command.
User avatar
mroyer
Posts: 1185
Joined: Sun Mar 06, 2016 12:27 pm

General Scripting Q/A

Post by mroyer »


I have started grappling with SC3 scripting and have made some descent progress in actually getting a couple scripts to execute as planned. Overall, the commentary at the top of each standard script file is pretty good - especially considering the smallish development team involved (kudos to them) - we can't possibly expect a Microsoft level documentation [;)]

But, it certainly comes to pass, items are either under-documented or simply unclear to the reader. Since I know I'll have a bunch of niggling scripting questions, I figured I'd start a "General Scripting Q/A" topic to gather this sort of info in one place rather than strewn about many separate threads.

-Mark R.

P.S. Or, does a topic like this already exist and I've just missed it??

User avatar
mroyer
Posts: 1185
Joined: Sun Mar 06, 2016 12:27 pm

RE: General Scripting Q/A

Post by mroyer »

Question 1:
How would one translate the following script line into plain English?
#CONDITION_POSITION= 52,6 [5,10] [2,3] [1] [0]

My guess:
The condition is true if 2 or 3 Axis units are within 5 to 10 hexes of hex location (52,6)

So, will the following examples evaluate true or false?
Example 1: 4 Axis units are 7 hexes from (52,6) - I think false
Example 2: 3 Axis units are 1 hex from (52,6) - I think false

User avatar
mroyer
Posts: 1185
Joined: Sun Mar 06, 2016 12:27 pm

RE: General Scripting Q/A

Post by mroyer »

Question 2:
Is it possible to convert a town or city to a capital city for a newly formed nation?

My specific case is this:
Japan captures Peiping and Tientsin (Chinese cities)
This triggers a Mongolian expeditionary force to join Japan
The Mongolians need a capital city to exist (I think)
I want to convert a town in northern Chahar (an Inner Mongolian province) to their territory and make it their capital
The expeditionary force will be formed there
Eventually, this new nation will become the puppet government of Mengjiang

Thanks for any thoughts on this,
-Mark R.
User avatar
mroyer
Posts: 1185
Joined: Sun Mar 06, 2016 12:27 pm

RE: General Scripting Q/A

Post by mroyer »

Question 3:
What is a good way to debug a script? Anyone develop any good techniques for this?


I can imagine it becoming quite onerous to have to play-through a game to a specific date to see if a script triggers as expected - especially for low likelihood events.

-Mark R.
User avatar
sPzAbt653
Posts: 9936
Joined: Thu May 03, 2007 7:11 am
Location: east coast, usa

RE: General Scripting Q/A

Post by sPzAbt653 »

Question 2:
You will be using a Territory Script to do this, and the first location in your list will become the capital.
What is a good way to debug a script?
Set it up to happen in the first few turns, then start a hotseat test and see if it all works, then go back and reset it all to happen when it should.
User avatar
mroyer
Posts: 1185
Joined: Sun Mar 06, 2016 12:27 pm

RE: General Scripting Q/A

Post by mroyer »

ORIGINAL: sPzAbt653
Question 3:
What is a good way to debug a script?

Set it up to happen in the first few turns, then start a hotseat test and see if it all works, then go back and reset it all to happen when it should.

Really? So what do you do if the territory ownership and unit positions early in the scenario are nothing like what they need to be to trigger the event? Do you jury-rig the at-start positions or something like that?

Thanks for the responses,
-Mark R.
User avatar
sPzAbt653
Posts: 9936
Joined: Thu May 03, 2007 7:11 am
Location: east coast, usa

RE: General Scripting Q/A

Post by sPzAbt653 »

If your conditions are so complex that they can't be rigged for a test, then you need to play it out. I've been tinkering with the Middle East myself, and between all the countries and all the possible situations, there is nothing to do but repeatedly play it thru.
User avatar
mroyer
Posts: 1185
Joined: Sun Mar 06, 2016 12:27 pm

RE: General Scripting Q/A

Post by mroyer »

ORIGINAL: sPzAbt653

If your conditions are so complex that they can't be rigged for a test, then you need to play it out. I've been tinkering with the Middle East myself, and between all the countries and all the possible situations, there is nothing to do but repeatedly play it thru.

Understood. Thanks. Just wanted to make sure there wasn't an easier way before I dived in.
-Mark R.

edit: The hotseat idea is really good. Much better than what I was doing; playing one side vs the AI. In retrospect it seems obvious [:(] - thanks for pointing it out.
User avatar
BillRunacre
Posts: 5778
Joined: Mon Jul 22, 2013 2:57 pm
Contact:

RE: General Scripting Q/A

Post by BillRunacre »

ORIGINAL: mroyer


Question 1:
How would one translate the following script line into plain English?
#CONDITION_POSITION= 52,6 [5,10] [2,3] [1] [0]

My guess:
The condition is true if 2 or 3 Axis units are within 5 to 10 hexes of hex location (52,6)

So, will the following examples evaluate true or false?
Example 1: 4 Axis units are 7 hexes from (52,6) - I think false
Example 2: 3 Axis units are 1 hex from (52,6) - I think false


Example 1 will be true some of the time, as the engine will randomly be looking for Axis units within 5,6,7,8,9 or 10 hexes of 52,6. If it finds them then it will fire, and units being closer than the relevant distance will still count.

Example 2 will therefore be true all of the time, as they are within the 5-10 hex range.

Bill
Follow us on Twitter: https://twitter.com/FurySoftware

We're also on Facebook! https://www.facebook.com/FurySoftware/
User avatar
BillRunacre
Posts: 5778
Joined: Mon Jul 22, 2013 2:57 pm
Contact:

RE: General Scripting Q/A

Post by BillRunacre »

ORIGINAL: mroyer

ORIGINAL: sPzAbt653
Question 3:
What is a good way to debug a script?

Set it up to happen in the first few turns, then start a hotseat test and see if it all works, then go back and reset it all to happen when it should.

Really? So what do you do if the territory ownership and unit positions early in the scenario are nothing like what they need to be to trigger the event? Do you jury-rig the at-start positions or something like that?

Thanks for the responses,
-Mark R.

It's best to have a test campaign with just the scripts you're testing in it, with them set to fire at the start date and with a trigger of 100%.

If they fire in those circumstances, then care is needed in porting them back into the real campaign but at least you'll know that the concept works.
Follow us on Twitter: https://twitter.com/FurySoftware

We're also on Facebook! https://www.facebook.com/FurySoftware/
User avatar
mroyer
Posts: 1185
Joined: Sun Mar 06, 2016 12:27 pm

RE: General Scripting Q/A

Post by mroyer »

Thank for the additional answers Bill! I appreciate the help.
ORIGINAL: Bill Runacre
ORIGINAL: mroyer

Question 1:
How would one translate the following script line into plain English?
#CONDITION_POSITION= 52,6 [5,10] [2,3] [1] [0]

My guess:
The condition is true if 2 or 3 Axis units are within 5 to 10 hexes of hex location (52,6)

So, will the following examples evaluate true or false?
Example 1: 4 Axis units are 7 hexes from (52,6) - I think false
Example 2: 3 Axis units are 1 hex from (52,6) - I think false

Example 2 will therefore be true all of the time, as they are within the 5-10 hex range.

This answer confuses me however - my guess is exactly wrong [X(]. I must be misunderstanding something basic. What is the point of having a min ( e.g., the 5 in [5,10] ) if axis units closer than the min 5 will trigger the event?

-Mark R.
User avatar
BillRunacre
Posts: 5778
Joined: Mon Jul 22, 2013 2:57 pm
Contact:

RE: General Scripting Q/A

Post by BillRunacre »

Hi Mark

What this means is that the engine will sometimes check for the relevant number of units being within 5 hexes, sometimes further.

So at the minimum it is looking for units between 1-5 hexes away, while at other times it might be searching as far as 10 hexes away.

I hope that's clearer?

Bill
Follow us on Twitter: https://twitter.com/FurySoftware

We're also on Facebook! https://www.facebook.com/FurySoftware/
User avatar
mroyer
Posts: 1185
Joined: Sun Mar 06, 2016 12:27 pm

RE: General Scripting Q/A

Post by mroyer »

Oh HO!! So, that's perfectly clear now and about 105% different than what I was thinking :)

Thanks for explaining Bill.

-Mark R.
p.s. the more I think about it, the more I like how it's implemented - it can be implemented such that neither side can know exactly what distance or exactly how many units will trigger the event. Nicely done.
User avatar
mroyer
Posts: 1185
Joined: Sun Mar 06, 2016 12:27 pm

RE: General Scripting Q/A

Post by mroyer »

Question 4:
Is it possible to script a change to terrain?

I'm thinking of two situations in China where this could be useful.
(1) The 1938 blowing of the Hwang Ho (Yellow River) levies that diverted the course of the major river by hundreds of miles and flooded thousands of square miles of agricultural land.
(2) The building of the Burma and later Ledo Roads
(3) The building of the Lanchow Rail

I'm sure there are other cases.

-Mark R.
User avatar
mroyer
Posts: 1185
Joined: Sun Mar 06, 2016 12:27 pm

RE: General Scripting Q/A

Post by mroyer »

Question 5:
Is it possible to eliminate a unit via scripting?

-Mark R.
User avatar
mroyer
Posts: 1185
Joined: Sun Mar 06, 2016 12:27 pm

RE: General Scripting Q/A

Post by mroyer »

Question 6:

Is it possible to have "free" units at the start of a game (i.e., they exist before the first turn)?

My case: The remnants of the Manchurian Army is operating in China under the Nationalist government command. Manchuria had "surrendered" and became Manchukuo in 1932.
User avatar
mroyer
Posts: 1185
Joined: Sun Mar 06, 2016 12:27 pm

RE: General Scripting Q/A

Post by mroyer »

Question 7:
Is it possible to move a nation's capital?

E.g., China moved it's government seat twice, the first time from Nanking to Hankow at the end of 1937 and then a second time to Chungking in late 1938.

-Mark R.


P.S.
Found this answer myself:
This is not a scripted event. On the 'Country Data' dialog in the Editor, multiple capitals can be defined for a nation and those capitals are used in succession.
User avatar
mroyer
Posts: 1185
Joined: Sun Mar 06, 2016 12:27 pm

RE: General Scripting Q/A

Post by mroyer »

Question 8:
Is it possible to activate units of a neutral nation to fight for a side with out the nation itself becoming non-neutral.

I'm thinking along the Spanish Blue division that fought for Germany in the east.
For China, the Soviets (neutral in 1937) sent a strong aviation group (the VVS) to fight against Japan. In game terms it might be a fighter and a bomber unit.

-Mark R.
User avatar
BillRunacre
Posts: 5778
Joined: Mon Jul 22, 2013 2:57 pm
Contact:

RE: General Scripting Q/A

Post by BillRunacre »

ORIGINAL: mroyer

Question 4:
Is it possible to script a change to terrain?

I'm thinking of two situations in China where this could be useful.
(1) The 1938 blowing of the Hwang Ho (Yellow River) levies that diverted the course of the major river by hundreds of miles and flooded thousands of square miles of agricultural land.
(2) The building of the Burma and later Ledo Roads
(3) The building of the Lanchow Rail

I'm sure there are other cases.

-Mark R.

Hi Mark

Sorry for the delay in replying.

These sorts of things take some lateral thinking, as they cannot be directly done, but sometimes the effects can be replicated in other ways, e.g. RESOURCE scripts to switch a previously inactive resource to producing MPPs and providing supply, or SUPPLY scripts to reduce the MPP value and supply of resources.
Follow us on Twitter: https://twitter.com/FurySoftware

We're also on Facebook! https://www.facebook.com/FurySoftware/
User avatar
BillRunacre
Posts: 5778
Joined: Mon Jul 22, 2013 2:57 pm
Contact:

RE: General Scripting Q/A

Post by BillRunacre »

ORIGINAL: mroyer

Question 5:
Is it possible to eliminate a unit via scripting?

-Mark R.

Not directly. A STRENGTH script can be used to reduce a unit to strength 1.

That said, a LOOP script could be used to remove a unit, but the scripting will have to be very precise to ensure that only the right unit at the right time and place is removed. So it depends on what you're thinking as to whether this could ever be useful.

As an example, in my 1870 Franco-Prussian War campaign (which is available as part of the Strategic Command Classic WWI package) I used LOOP scripts triggered by DECISION scripts to represent the surrender of Metz. If the conditions were met, i.e. lots of Prussians surrounding Metz, then the defenders might surrender and be removed from the map. Not good for the French.

It worked in that circumstance, but it is very dependent on the circumstance being applicable to something like that.
Follow us on Twitter: https://twitter.com/FurySoftware

We're also on Facebook! https://www.facebook.com/FurySoftware/
Post Reply

Return to “Scenario Design and Modding”