C&C Generals: World Builder: Tutorials: How to Make an AI Player Build Units

Command & Conquer Generals: Zero Hour: World BuilderTutorial by AdrianeMapMaker

This tutorial explains how to make an AI player build units in a mission. It assumes basic knowledge about how to use the World Builder program.

Table of Contents

Phase 1: Set up Scripts

  • A: Create Build Triggers
  • B: Learn how to make a script a "subroutine" and "active"
  • C: Create AI Scripts

Phase 2: Implementation

  • A: Create Teams
  • B: Use the Scripts


Phase 1: Set up Scripts

Phase 1-A: Create Build Tiggers

Open World Builder and create the following scripts:

ScriptName: FlagBuild

This will be the "on/off" trigger to tell your AI to build. The script is very useful if your mission is going to have an intro.

***If***
True
***Then***
Set Flag Named 'FlagBuild' To False
Set Player 'Gla' Unable To Build Units
Set Player 'Gla' Unable To Build Buildings
Set timer 'intro end' expire in _sec



ScriptName: AiBuildtrigger

This script triggers the AI to build after the intro has ended.

***If***
Timer named 'intro end' expired
***Then***
Set the Flag named 'FlagBuild' to true



ScriptName: AiBuildnow

This script allows the AI to build now.

***If***
Flag Named 'FlagBuild' Is True
***Then***
The Player 'Gla' is Able To Build Units
The Player 'Gla' Is Able To Build Buildings

 

 

Phase 1-B: Learn how to make a script a "subroutines" and "active"

We'll take a moment now to go over how to make a script a "subroutine", "active", or to make the script "deactivate upon success." You will use this knowledge later in the tutorial. If you already know how to do this, please feel free to skip this phase.

Here's how:

  1. Click Edit > Edit Scripts
  2. Click on a script. You are now in the Script Properties window.
  3. Look at the bottom of the window, and you will see the check boxes for: Subroutine, Active, and Deactivate Upon Success.

We will skip enabling these for now, but you will use this information in the next phase.

 

Phase 1-C: Create AI Scripts

Create the following scripts:

ScriptName: BuildCondition1 (set as Subroutine and Active)

This is the build condition for the AI teams.

***If***
True
***Then***
Null Operation (Does Nothing.)


ScriptName: Hunt (set as Subroutine and Active)

This defines the generic behavior for the AI teams.

***If***
True
***Then***
Team Named '<This Team>'Set To Hunt.



ScriptName: Hunt Idle (set as Subroutine and Active)

This defines the second behavior for the AI teams.

***If***
True
***Then***
Team Named '<This Team>'Set To Hunt.


We are now done the set up phase! On to implementing the build logic...

 

Phase 2: Implementation

Phase 2-A: Create Teams

First, you need to create teams for your AI player. To do so:

  1. Click Edit > Edit Teams
  2. Click the player that you want to have a team

Phase 2-B: Use the Scripts

Now, we will just use the scripts you created before to make the team build the units of your choice.

Click on the teams, and the follow the image below to set up the Production Condition, the Behavior Script Triggers, and Initial Team Behavior.

Dialog box showing how to configure Team Behaviors

That's it! Your AI Player will now build the units you have selected in the Identity tab.

 

Questions

Have questions about this tutorial? Ask in our forums!