SDI title

  Current News
  Archive News



  Random Tip:
13. Always try to use the waypoint paths as attack paths - instead of just setting a team to hunt. There are usually three waypoint paths for you to use : Center, Flank and Backdoor
  View All Tips

  Contact Us

  Atomic Wiener Dog
  CNC Reneclips
  Project Perfect Mod
  The Finest Hour
  Warhammer40k: DoW SDI
  YR Argentina

Adding New Units

Title: Adding new units
Difficulty: Novice AI Scripter
Author(s): SDI Team
Game Type: Zero Hour

For this scenario, we will assume that we want to add a new unit to America, the Patriot Tank.

What is a Team?

The AI in Generals uses its units by the use of Teams. A "Team" in World Builder is basically one or more units that have been assigned specific behavior. This behavior is defined by faction scripts.

Let's get started - run World Builder.

Go to Edit > Player List. In the new window, locate the "Add Skirmish Players" button and click it.
Click "OK" and go to Edit > Scripts. Uncheck the "Auto Verify" checkbox, find the "Import Scripts" button, and import the (usually located in your Command and Conquer Generals\Data\Scripts\ directory).

Don't worry if it looks like nothing has happened, if you click one of those folders you'll see a '+' sign.

Now that you have imported the scripts (the teams import with the scripts), click "Ok" and go to Edit > Edit Teams.

Click "Skirmish America", and you'll see a big list of teams.

This is where the AI gets all the team data from. Here is a list of things that the Teams Editor defines :

  • Build Conditions

  • On Create Behavior (what the team is supposed to do once it is created)

  • Magnitude of teams (which unit(s), and how many of them)

  • Build Priority (sets whether this team is to be built before any others or not)

  • On Destroyed Behavior (what the team is supposed to do when it is destroyed, the percentage value next to it defines
    when it should consider itself "destroyed"

  • Generic Scripts (you can attach any scripts here, some of the more used ones in ZH are the Attack Sequence and "Join my Team" scripts.

  • Common Object Properties which has the same properties as the "Object dialog" that appears when you select an object in WB.
Now, to add the Patriot Tank to the USA AI, we need to choose specific teams.

The Zero Hour AI mainly attacks with "Waves", the magnitude and cost of which is determined by a timed counter and the difficulty level. Some scripts in the "Escalation" folder in the Script Editor add 1 to a counter when a few seconds have passed. So basically the Zero Hour AI uses time as an expansive counter.

The "CT" stands for Complimentary Team - those are teams that have the specific function to combat a specific unit type, e.g.
the "USA CT - Air 1" team is specifically used against aircraft, the "USA CT - Tank 1" specifically against tanks, and so on.

Since we want to make the USA use the Patriot Tank early, we will choose the first waves on the easy difficulty setting- otherwise we won't be able to test this effectively.

For now, find and double click "USA E 1ST Wave".
Stay with me now while you wait for your brain to make sense of it:

1) The Team's name, the "E" stands for "Easy".

2) How many instances of this team can exist simultaneously

3) The Owner, which is defined by the players in the Player List

4) Mainly used for map missions, this sets where the team is initially, waypoints must be chosen

5) The Build Condition. The "_USA_1ST_WAVE_E" is a script that checks whether 100 seconds have passed - and if the player
has a barracks.

6) Execute the actions in the "Actions if true" tab in the Scripts editor - will get to that later

7) Build priority, 100 is a bit low overall, we'll change that further down. If one or more teams have the same priority and
build conditions then they will be built randomly.

8) Increase this team's priority if they succeed in their orders, (On Create, will get to that)

9) Build for this many frames, after that, start executing your initial orders. Note that the Skirmish AI does not recognize this -
the AIData.ini handles that. This is only for singleplayer

10) Value by which the team's priority will be decreased if they fail with their orders - so they won't be built again

11) The unit list. Any units can go there, they do not necessarily have to be in a specific faction, only in the CommandSet of a factory.

12) Automatically build reinforcement teams, defined in the Reinforcement tab. This function reinforces the team on a unit only basis..
it doesn't replace the entire team. It also has the nasty habit of robbing units from one team that has the AIRecuitable box checked,
causing that team to be broken.

13) This team can be recruited from another team when the "Recruit a team" script command is used

14) This team can only be created once, will never be rebuilt even if the build conditions allow that.

Now, the Reinforcement tab is mostly used on map missions, the only "interesting" ones at this time are the other
two: Behavior and Generic.

Behavior first:

1) "USA Guard Base" is a script that tells the team to guard the base for now. Note that this is overriden for attack later on

2) Execute this script when you see an enemy, the sight distance is defined in the object INI "VisionRange" line

3) Execute this script when you see no enemies

4) Execute this script when the team has been destroyed. The box with the percentage next to it defines when a team should
consider itself "destroyed". The "USA CT-Buildable" script makes it possible to build this team again after it is destroyed

5) Execute this script when you are idle

6) Execute this script when this team has lost a unit

7) and 8) These seem to have been disabled

9) Sets the attitude of the team. "Aggressive" is often the most effective. NOTE: If the team is to load into a transport
DO NOT set it to AGGRESSIVE...they won't load

10) Focus fire, pretty obvious I think

Now lets move on to Generic:

Note: The number of scripts you can add will change when you add them

1) "USA Attack Sequence Center" is a sequential script that tells the team to follow the "Center" path of a map and attack any
enemies there. Note that in the regular Generals scripts this script was in the "On Create" condition - the ZH scripts have the Guard Base script first

2) "USA CT-Join my Team" is a script that tells a "Complimentary Team" to join this team - the CT is a team with no units.
If another team joins the Complimentary Team then the AI effectively makes larger attack groups. Well "effective" is relative...

The Common Object Properties are quite straight forward and all map makers (especially mission makers) should know well enough what those settings mean.

Now that you know more about the teams tabs, lets get back to our original scenario.

Go back to the "Identity" tab, and in the Unit List, (below AmericaInfantryRanger), add the Patriot Tank (or your new unit)
and set the minimum and maximum numbers both to 1.

Now set it's Priority to 5000 for this scenario so that the AI builds this and only this first.

Fire up the game and see if it works. (playing on Easy difficulty level of course)

Again, note that the more teams you add the unit to, the higher is the chance of that unit being built.

Also note that the new unit must be in the faction's building commandset somewhere, else the AI won't "find" it
(for example, if you take off the ChinaTankGattling from the Chinese Warfactory, the AI will not build the Gattling Tank anymore, so the AI needs the CommandSet and CommandButton entries)

Thats it, you're done. It's just about the same as the Regular Generals "Adding New Units" tutorial but some info has been added here and there..

SDI is part of the Revora Creative Network.
Orange Block design created by Detail 2004 Revora Creative Network.
Content Revora Creative Network 2004 - 2008