Explore GameReplays...

Worldbuilder

[CNC3] Worldbuilder Scriping Guide

Reply to this topic Start new topic
# 1Marauder709 Jul 5 2007, 20:47 PM
Worldbuilder Scripting Guide

IPB Image


So you want to learn to script. Well, bear in mind that scripting is the hardest aspect of the Worldbuilder program. This tutorial will help beginning and advanced mappers alike to do so. I made the guide with the CnC3 Worldbuilder but the BFME series is virtually identicle so it should apply there as well smile.gif

Contents
Scripting Overview
Terms and Tools
Waypoints and Polygons
Players and Teams
The Scripting Tool
Scripts
Script Conditions
Actions if True or False

This post has been edited by Marauder709: Jul 5 2007, 21:15 PM

Posts: 3,118

Game: Battlefield 3


+
# 2Marauder709 Jul 5 2007, 20:51 PM
An Overview of Scripting


In short scripting in Worldbuilder is the maps "language" for preforming actions. Just like C++ and Java, Worldbuilder script is used by the game to do custom functions in certain orders. Each custom map has a default script that includes build orders, Troop Deployment and so on, these units will be built, and then mill around aimlessly.

Thats where the AI comes in. The AI controls actions outside of that of the default script including, where to move, were to hunt, where to defend, and so on. Virtually everything can be done through scripts although in many cases it is not necessary.

The scripting language follows his format

CODE
If Script Condition is True then fire True Action.  If Script Condition is False the fire False Action.


This post has been edited by Marauder709: Jul 5 2007, 21:08 PM

Posts: 3,118

Game: Battlefield 3


+
# 3Marauder709 Jul 5 2007, 20:53 PM

Terms and Tools


There are a few different terms and tools that are used in scripting. This will give you an overview of how to use them.

Player: A player is a faction to which a unit can belong. Players are the easiest way to assign ownership of an Item.

Team: A team is a subdivision of a Player meaning that there can be multiple teams under the same player. You should never use teams as the same goals can be accomplished with players.

Waypoint Tool: This is a set point on the map which can be used as a flag for scripting. It is also important for assigning starting locations for multiplayer players (for more info on this see this guide. Waypoints can also be used to set rally points for pre-built structures. Do not use them for creating unit paths as this is better suited for the polygon tool

Polygon Tool: This tool is used to create waypoint paths for pre-existing units to follow. I can also create a 2d shape in which units can hunt, defend, and attack within. This is one of the most useful tool when scripting an AI.

Edit Player Tool:
This nifty little tool adds, deletes and modifies players. You can acess it by going to Edit>Edit Player list

Edit Teams Tool: This does exactly the same thing as the player editor except it edits teams

Scripts Tool: This is the they tool you use to script. Its so important it has a section all its own smile.gif

This post has been edited by Marauder709: Jul 5 2007, 21:13 PM

Posts: 3,118

Game: Battlefield 3


+
# 4Marauder709 Jul 5 2007, 20:54 PM
Waypoint and Polygons


Waypoints and Polygons are markers for scripting. If you want to move a unit to a certain location, you would script them to move to waypoint x. If you want them to move and then hunt in a location then the script would be hunt in polygon y.

Waypoints

-Creating waypoints is very simple. Its a point and click were you want the waypoint to go.
This is the Waypoint Properties Window:

IPB Image

Make sure you input a name as it will be very important when designating which waypoint you want to choose. The waypoint type should not change unless the waypoint is a portal (ie universal mineshaft or a wormhole)

Polygons

Polygons are exactly like the waypoint tool except they make 2d figures. These can be great for creating areas for unit to hunt and defend. If you do not complete the shape and click to another tool, the polygon will automatically complete itself from the last point to the first point. Each point is movable so the shape you create can be modified in almost evry single way.
Here is the Polygon Options aka the (Area Trigger Options)

IPB Image

Again always remember to label the polygon.

This post has been edited by Marauder709: Jul 5 2007, 20:55 PM

Posts: 3,118

Game: Battlefield 3


+
# 5Marauder709 Jul 5 2007, 20:58 PM
Players and Teams


Players
Players are the side that a player plays on.
There are two types of players, Multiplayer Players and Skirmish Players

Multiplayer Players are controlled by a human player. In a skirmish match, there is only one Multiplayer Player, in Network or Online matches, there is usually more than one Multiplayer Player. Multiplayer Players are denoted by this script: Player_1

Skirmish Players are computer controlled players known as AIs. In skirmish matches, these are the players you play with and against. They are not as common in online or network matches but can be seen in comp stomp matches. Skirmish players are also used in campaign missions and mission maps.

The Edit Player List window is the Worldbuilder tool for editing players. The window looks like this:

IPB Image

If you get a screen that looks like this hit the "Add Skirmish Players" button in the bottom left.

IPB Image

Teams

There is only one type of team, a team (well duh man WTF.gif ). Teams are a subdivision of players, ie there can be multiple teams per player. In this sense, you could, theoretically, make a MULTIPLAYER map with one player and however many teams. I don't recommend this as it is time consuming and confusing and a pain to explain. If you with to do so then the string you enter is Player_Inherit where Player is the name of player you want the team to belong to. If you want to create a Multiplayer Team, make sure you make them belong to PlyrCivilian. The string you would enter would be: Player_1_Inherit, Player_2_Inherit and so on
To do all this use the Edit Teams tool accessible from the Edit Menu

IPB Image

This post has been edited by Marauder709: Jul 5 2007, 21:11 PM

Posts: 3,118

Game: Battlefield 3


+
# 6Marauder709 Jul 5 2007, 20:59 PM
The Scripting Tool


Ok, here it is, the big cheese, the scripting tool. This place is, in short, very scary, similar to the feeling you get when you manually alter your registry. This is the most complex tool Worldbuider offers and is the hardest to understand and use. Even I haven't fully mastered it yet. It is accessible through the Edit Menu and has its own little button on the tool bar. This is the Scripting Editor:

IPB Image

Most of the buttons are self explanatory. Make sure that every time you finish with the scripting tool, you hit Apply before you hit OK, otherwise the scripts won't be enabled.

Each team has its own folder. While these have no relevance as far as the execution of scripts are concerned they are good for keeping your scripts in organized. If for instance you are spawning a unit for Player_1, it would do well for the script to be placed in the folder Player_1.

This post has been edited by Marauder709: Jul 5 2007, 21:11 PM

Posts: 3,118

Game: Battlefield 3


+
# 7Marauder709 Jul 5 2007, 21:03 PM
Scripts


When you create a new script, The script creation window will pop up. In it there are four tabs: Script Properties, Script Conditions, Actions if True, Actions if False.

IPB Image

Script Properties
These are a selection of how the script will be applied.
Scripting Flags should be left as is. The only one that can really be played with is the deactivate when successful option. This is especially when the Script in question conditions contain an "OR" or an Action if False.
The Active in section only applies to the AI and weather the script is active in Easy, Medium, and Hard AI settings (note that it is always active in brutal settings).
Sequel Scripts are annoying and VERY difficult to coordinate effectivly. It would be better to Copy and paste rather than try to sequence.
evaIuating the script time is a personal choice, by frame gives the fastest possible reaction to a script trigger while a pre-set delay can produced a delayed action but never one faster than "Every Frame".

Script Conditions


IPB Image

These are the things that must happen in order for a script to be enabled. To a create a new situation simply click New... and a list of possible scenarios will pop up. There are a vast amount of scenarios that I will detail later in th guide. If you wish to create another scenario, you must choose "Or" or "And"

"And" and "Or" Describe the way a set of triggers must occur. Here is an example script: "Script A Spawns unit A when Structure A "And" Structure B are destroyed". This means that both Structure A AND B must be destroyed to enable the script. If however, the script read: "Script A Spawns unit A when Structure A "Or" Structure B are destroyed". It would mean the destruction of ether Structure A, Structure B or both at the same time would enable the script.

Actions if True/Actions if False


IPB ImageIPB Image

These tabs is actually self explanatory. They are the way to create what will happen if the if the Script Conditions are met or not met. To create a new action simply click on "New...". I will detail all of the selections Later in the guide. Remember, If you have the "deactivate when successful" option checked in Script Properties then the script will more than likely not be successful as If ANY action happens, the script will automatically de-activate

This post has been edited by Marauder709: Jul 5 2007, 21:12 PM

Posts: 3,118

Game: Battlefield 3


+
# 8Marauder709 Jul 5 2007, 21:05 PM

Script Conditions


Script Conditions or Triggers are what Worldbuilder uses to set off a script. The default script is "If True". This means that the script will fire at the very beginning of the game. If you want the script fire at a specific time, for example, If you want Gandalf to shout "No matter what comes through that gate you will stand your ground" when the Minas Tirith Gate falls down then you would set the condition to "When Unit(whatever you named the gate) is destroyed, then fire GandalfAudio1 (this is hypothetical, the actual sound is not called GandalfAudio1).

This is the Script Conditions selection menu:

IPB Image

Here is the breakdown o f what they mean:

Audio is used to set of a script when a certain sound file has finished playing. It can only be used in conjunction with another script.

Base is used to set off a build order or unit action inside a selected area (I think). I have never used this feature and have never had a mind to.

Camera triggers scripts when the camera has preformed a certain movement or command. For instance it the camera has been re-set or the camera has been rotated X number of degrees.

Campaign has no use within Worldbuilder itself and can only be used in conjunction with a
campaign mission and the mod SDK.

Game Type is pretty self explanatory. It sets off scripts by evaIuating weather the game is a multiplayer match or a skirmish match. This is good for adapting a mission map for multiplayer matches.

Interface is used to set off scripts with changes in the game interface (ie the Palantir or Control Bar)

Living World
only applies to the BFME series and can only be used in conjunction with the Mod SDK.

Map_ is used to set off a script when the map is changed in some way. For instance, a script can be triggered if an area of the map is on fire.

Player and Player_
are used to set off a script based on an object belonging to a certain player preforming a function. For instance, If all unit producing buildings belonging to Player_X are destroyed then... or If Player_X has units inside Building X then...

Scripting basically the Miscellaneous triggers. they include Conter triggers, True and False, and distance comparisons.

Teamis virtually the same as Player

Unit(includes structures) and Unit_ trigger scripts based on a unit fuunction. For instance if Unit X is destroyed then... or Unit_X is under attack.

UNUSEDis self-explanatory

Win & Loss triggers scripts based on weather a certain PLAYER wins or loses a game. If Player_X is defeated then...

This post has been edited by Marauder709: Jul 5 2007, 21:12 PM

Posts: 3,118

Game: Battlefield 3


+
# 9Marauder709 Jul 5 2007, 21:07 PM
Actions if True or False


These are the actions a script will preform is it meets the script conditions. Actions if True and Actions if False are exactly the same. Here is the Actions Menu

IPB Image

Audio plays a certain sound from a customizable location.

Base is another anomaly to me. I have no clear notion of what it does and to the best of my scripting knowledge it does nothing.

Camera allows you to do almost anything with the in-game camera including following a unit, zoom in and out, and have it change pitch, yaw and focus.

Campaign can only be used in conjunction with the Mod SDK

Interface changes the game controls and allows a mapper to play movies in the Plantir/Control Bar, set countdown timers (called counters), Display text across the screen, or play movies in-game.

Living World and Living World_ is only for the BFME series and can be used in conjunction with War of th Ring and campaigns. Again however, it requires to Mod SDK to work.

Map and Map_ are ways to change the map like pulling back Fog of War or the shroud in a selected area or burning the ground at a certain waypoint.

Player and Player_
are actions that can happen to a player like increasing command point limit or money at the start of a game. It is also how you can move or build units belonging to a certain player.

PlayMovie is pretty self explanatory. it plays a movie in game.

Scene dims and brightens global lighting, it is good for maps that require a change from night to day or vise-versa.

Scripting and Scripting_ are the Miscellaneous of the script actions and can do everything from start a timer or counter to freeze and unfreeze time smilie_naughty.gif .

SkirmishAI is a way to define the special ability perimeters of an AI for instance weather they can repair structures and units.

Team -- Action, Team -- Other, and Team_ are scripts pertaining to different teams. Team -- Action allows a player to move units belonging to a specific team. Team -- Other is a miscellaneous compilation of things that can be done with a team like changing allegance and merging teams.

Unit, Unit -- Actions, Unit -- Other, and Unit_
are a compilation of all the actions that a single unit or object can preform. They range from giving units upgrades and experience to changing their allegiance and hunting them.

The two UNUSEDs are again, self explanatory.

Win & Loss can be used to announce defeat or victory for all players.

This post has been edited by Marauder709: Jul 5 2007, 21:12 PM

Posts: 3,118

Game: Battlefield 3


+
# 10Marauder709 Jul 5 2007, 21:11 PM
Congratulations


You know know the basics of scripting. If you have a question or need clarification on some point, do not hesitate to ask.

Regards, Marauder709
CnC3 Map Reviewer

This post has been edited by Marauder709: Jul 5 2007, 21:12 PM

Posts: 3,118

Game: Battlefield 3


+
# 11Critchy Feb 5 2016, 22:25 PM
How Do You Acsses The Player Tool?

Posts: 1


+
# 12M0nkfish Apr 10 2016, 16:18 PM
i know this probably goes beyond the basics which you have outlined, but I'm working on a Map where i have limited each factions Tech tree in various ways, this scripting works fine but how would i go about disabling the ability to research certain unit special powers; i'd like to lock research that wont be useful so you cant mis-click and waste cash.

Limiting special powers in script will only prevent individual units from using specific ability, i was thinking perhaps the answer lies in a script something like this:- Player --> Set Science Ability-->[manually type in the research to be locked]--> set to hidden but as i dont know if the names of the research are equivalent to the names of the SP which they enable, i'm not sure what to type or whether this approach would work. Perhaps i could find the appropriate names in some of the games files? Am I on the right track? Any help would be much appreciated.

Posts: 1


+
# 13mineme May 2 2016, 16:00 PM
I hope to have a detail description of each script effect. Some are easily to understan by the sentences, some ain't. I also want to learn if there are programming languages applying in the script textbox or .xml map folder included.

Posts: 5

Game: Kings and Castles


+
# 14ProdavecAL Jul 22 2016, 16:32 PM
How do I get unit(s) with specific type that placed inside the area? For example player creates a Militant Squad, how can I get it via scripts to change the parameters of that unnamed squad?

Posts: 18

Game: Kanes Wrath


+
# 15Stab Dec 23 2016, 20:17 PM
What i want to know is if its possible to keep a script or 2 on a repeating loop, like giving every player 5k-10k$ every so often. can anyone answer that for me?

Posts: 1


+

1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)