Jump to content

Script Basics


Recommended Posts

I thought I'd post a simple breakdown of how PLAN scripts work for those interested in doing a few tweaks to their game. Mind you I'm still learning a lot, and I'm sure Edwin can add to this (and/or correct me if I'm wrong on anything), so I'm going to keep to what I (pretty much) know so far.

Below is a sample PLAN taken from the game. I'm at work so I'm using one that has been posted somewhere on the forum already.

; Garrison script

{

#NAME= USSR Garrison - Stalingrad Defensive Line

#POPUP=

#FLAG= 1 (this basically turns it ON)

#TYPE= 2

#COUNTRY_ID= 4 (Which country this script is for)

#TRIGGER= 100 (% chance the script will activate)

#LEVEL= 0 (min difficulty level this script will fire)

#PLAN_ID= 0 (0=Garrison, 1=Offensive 2=Amphib 3=Transport)

#SIZE= 1 (# of units involved for the script. For example, the German attack on France calls for 8. This does not include HQ's, planes and bombers, which are, I believe, automatically assigned if available.)

#LENGTH= 1 (How many turns pass for the AI before the script goes into motion)

#GOAL_POSITION= 127,16 (Since this script is a Garrison script, the Goal_Position is the coordinate where the AI will place a unit to garrison. This is a good way to form defensive lines, as I'm doing here for Stalingrad. These coordinates are all behind the river around the city. Garrison scripts always default at #Size=1, but by placing multiple Goal_Positions it'll place 1 unit for each one you give).

#GOAL_POSITION= 126,16

#GOAL_POSITION= 127,17

#GOAL_POSITION= 125,15

#GOAL_POSITION= 126,18

#GOAL_POSITION= 124,15

#GOAL_POSITION= 125,18

#GOAL_POSITION= 123,14

#DATE= 1942/03/03 (Earliest date this script can be activated. If other conditions are required below, it'll wait until those are met.)

#STEAL= 0 (0=no and 1=yes. If other Plans are going on, this particular plan will 'steal' units from other plans in order to fulfill it's #Size requirement. Good for urgent/priority plans that absolutely must be done).

; Set friendly positions:

; 1st Line - Stalingrad

#FRIENDLY_POSITION= 127,16 (This line basically states that Stalingrad must be in friendly hands in order for this script to be true. If Stalingrad is in enemy hands, the script will no longer try to garrison the area around it).

; Set variable conditions:

; 1st Line - USSR politically aligned with Allies and not surrendered

#VARIABLE_CONDITION= 4 [2] [100] [0] (This is typically used to check to see which countries are aligned to whom, if they've surrendered and what their minimum war % needs to be.)

; Set tactical conditions:

; 1st Line - Sverdlovsk not tactically threatened (dummy condition)

#TACTICAL_CONDITION= 135,5 [3] (The tactical condition checks to see if a particular resource is threatened. In this case, if Sverdlovsk is threatened by Axis land forces (the 3) the script won't activate. So if you wanted to make a script where the UK invades Iraq from Alexandria, you could check to see if Alexandria and Cairo are threatened before the offensive takes place so they don't attack Iraq when a bunch of Axis units are about to capture Alexandria).

; Set activate position

; 1st Line - Axis within range of Moscow (About to Fall)

#ACTIVATE_POSITION= 112,10 [1,1] [2,2] [1] (Activate position is a condition that checks a specific criteria before the script is set into motion. In this case 112,10 is Moscow. [1,1] is the min/max range around Moscow that it checks. [2,2] is the min/max # of units that it looks for in the 1 tile radius. [1] is the political alignment of the units it is checking for. 1=Axis, 2=Allies. In this case, as soon as 2 Axis units are within 1 tile of Moscow, this script will activate (as long as the other conditions are true as well, such as Stalingrad not in enemy hands). So I'm having the AI abandon Moscow and beginning the Garrison of Stalingrad at that point).

; Set cancel position

; 1st Line - Axis within 1 tile of Stalingrad

; 2nd Line - No Axis units within range of Stalingrad (removed)

#CANCEL_POSITION= 127,16 [1,1] [3,3] [1] (The cancel position ENDS the particular script as soon as one of these are met. This script will continue to try and garrison the Goal_Positions above until 3 Axis units are within 1 tile range of Stalingrad. As soon as this is true, the AI will cease to try and garrison the goal positions listed above, essentially giving up further defense.)

}

Hope this helps a bit. As I'm at work I'm not able to reference the instructions Hubert left in the scripts detailing all of these lines, so it's going by memory.

[ April 26, 2006, 07:30 PM: Message edited by: Timskorn ]

Link to comment
Share on other sites

Great assessment Timskorn and looks 100% correct to me smile.gif

Mustang, the AI will read scripts in script order and in this case would try and fulfill the requirements of the first Garrison script followed by the second Garrison script for Stalingrad. In this case it would probably be better to just use one script, BUT the flexibility is there to script it as you prefer.

Link to comment
Share on other sites

Thanks! At first it was a little daunting to take in all of the info, but you did a good job in the structure of the scripts and the explanation of each section.

For the Stalingrad script I altered the existing one, no need to add a new one. If I want to add a whole new script though I usually just copy and paste a similar one and then start altering each line.

I've found it comes in handy to write down coordinates, especially when I was doing the Russian garrison scripts. Helps editing go quicker. I also recommend once you start getting a hang of the scripting, to open the .txt files separate of the editor. Anytime you open the scripts or save the scenario or update the scripts it has to verify there are no errors (which is awesome, thanks HC), but it takes a long time to finish. Working on the .txt files outside the editor saves a lot of time, as when you're done you only need to verify it once or twice.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...