Working with FGD files.
The FGD file is what Worldcraft uses to define its entities. It is a scripting language that sets up what entities will be available to you, what flags and keyvalues will be present in each entity, and what default values the flags and keyvalues will have.
FGD Format
Base, Color, Size ... Variable Types ... Comments
//
// descriptive comments
//
// anything between [ ... ] is optional
//
// The worldspawn entity is present in every FGD.
//Normally it is the first thing defined.
@SolidClass = worldspawn : "World entity"
[
variable1(variable_type) : "Description" [: default_value]
variable2(variable_type) : "Description" [: default_value]
...
]
// comments
@BaseClass [base( )] [color( )] [size( )] = base_name
[
variable1(variable_type) : "Description" [: default_value]
variable2(variable_type) : "Description" [: default_value]
...
]
// comments
@PointClass [base( )] [color( )] [size( )] = entity_name : "Description"
[
variable1(variable_type) : "Description" [: default_value]
variable2(variable_type) : "Description" [: default_value]
...
]
// comments
@SolidClass [base( )] [color( )] = entity_name : "Description"
[
variable1(variable_type) : "Description" [: default_value]
variable2(variable_type) : "Description" [: default_value]
...
]
...
...
...
base, color, size
FGD Format ... Variable Types ... Comments
size( ) = size(x y z[, x y z])
- This sets the size of the entity as it appears in Worldcraft's 3D and 2D views.
- The size is based on the actual model size of the entity (in cases where the entity is associated with a model).
- If this value is incorrect, it is difficult to accurately place the entity in the level.
- If you only specify the first set of values, it will be assumed that the entity origin is in the center. For example, "(-8 -8 -8, 8 8 8)" is equal to "(16 16 16)".
- In the case of non-model entities, a size of (-8 -8 -8, 8 8 8) is fine.
color( ) = color(r{0 .. 255} g{0 .. 255} b{0 .. 255})
- This sets the color of the entity as it appears in Worldcraft's 2D views.
- This has no effect in the game.
base ( ) = base(base_1[, base_2 ... base_n])
- This allows you to use inheritance when you define your entities. For example, if you define the following BaseClass...
@BaseClass color(128 255 128) = Door
[
targetname(target_source) : "Name"
target(target_destination) : "Target"
wait(integer) : "Wait" : 0
delay(integer) : "Delay" : 0
]
...and define the following entity...
@SolidClass base(Door) = func_door : "normal door"
[
message(string) : "Message"
]
...it will be equivalent to defining the following...
@SolidClass color(128 255 128) = func_door : "normal door"
[
targetname(target_source) : "Name"
target(target_destination) : "Target"
wait(integer) : "Wait" : 0
delay(integer) : "Delay" : 0
message(string) : "Message"
]
...the advantage being that you can now use the BaseClass reference to define a number of entities with the same basic characteristics.
- Any part of the BaseClass can be overridden in the new entity simply by redefining the specific part. In the above example, if you wanted to use the Door BaseClass for func_slowdoor, but the func_slowdoor is supposed to have a default delay of "4", you would define it like this...
@SolidClass base(Door) = func_slowdoor : "slow door"
[
delay(string) : "Delay" : 4
]
...the same can be done for color( ) and size( ) as well.
Variable Types
FGD Format ... Base, Color, Size ... Comments
flags
- Flags let you enable or disable a certain feature of an entity. Flags always follow a fairly strict setup, they are always defined like this...
spawnflags(flags) =
[
flag_value : "description" : on_off_value
...
]
- The only variation from the above will be in the flag_value, description, and on_off_value.
- flag_value must be one in the range of {1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048}
- {256, 512, 1024, 2056} are usually reserved for the the Appeargflag flags, which determine whether or not an entity will appear at a given skill level.
- on_off_value is either 1 or 0.
target_source
target_destination
- These two variable types denote a relationship between one entity and another. This type is most often associated with the target and targetname variables...
targetname(target_source) : "Name"
target(target_destination) : "Target"
...where typically there will be an entity with a target value, and an entity that has a matching targetname value.
integer
- The integer type is used for variables that hold a number...
delay(integer) : "Delay before activation" : 0
- The value is not limited to integers only, any number can be used. For example, "4" and "4.5" are both valid values for an integer type variable.
string
- The string can be used where an alphanumeric value is needed, or where a compound value is needed.
message(string) : "Message when triggered"
mangle(string) : "mAngle (x y z)" : "0 0 0"
- The string type is fairly multipurpose...it can be used as a substitute for target_source, target_destination, and integer.
choices
- The choices type allows you to setup a list of integer choices for a variable that can have a number of different values. Like flags, the choices type follows a fairly standard formula, but its nowhere near as strict.
variable_name(choices) : "Description" : default_value =
[
choice_value : "Description"
...
]
- The variations from the above will be variable_name, default_value, choice_value, and the descriptions.
- the default_value is typically the same as one of the choice_values, the default choice_value. it must be an integer value.
- the choice_value is an integer value, and should be accompanied by a description.
gravity(choices) : "Gravity Level" : 800 =
[
400 : "Low"
800 : "Normal"
1000 : "High"
]
color1
- This variable type is mostly a time saving utility. When a color value is needed in the format of...
{0.000 .. 0.100} {0.000 .. 0.100} {0.000 .. 0.100}
...like "0.000 0.500 1.000" (which results in this color), it is much easier to calculate the color value when using this type, as it brings up a color dialog which allows you to pick the actual color.
Comments
FGD Format ... Base, Color, Size ... Variable Types
You can place comments anywhere throughout the FGD file. They are useful for keeping track of where you've made changes to the FGD, and for things like contact and support information. Comments have no effect on how the FGD is used within Worldcraft. I like to follow the following format with comments...
At the top of the file...
//
// game / mod identification
// for what version of worldcraft?
// date last updated?
//
// contact info for author
// support information (email, web sites, etc)
//
// credits
//
...and throughout the file...
// comments on entity usage
//
// mmdd (month / day) - revision information - this is useful for keeping
//track of what changes you've made and when you've made them
// 0421 - i did something today.
// 0422 - i changed something again.
- This is most useful when you are developing for a mod or porting another game's information into an FGD where you may have to make many changes before it is finished.
|