Include directive

From Dragon Age Toolset Wiki
Jump to: navigation, search

The include directive, #include, instructs the compiler to treat the contents of the specified file as if those contents had been inserted in the source script at the point where the directive appears.

#include "<script_resref>"

Remarks

Constants, functions and structs can be organised in separate scripts or code libraries, known as include files, to allow code to be reused in different scripts without having to retype the code multiple times.

Include files are not executable scripts, in other words they will not contain a void main() or a int StartingConditional() function. As a result include files do not compile and do not produce a .ncs file. In fact when saving or attempting to compile an include file the Toolset will post a warning entry in the log to this effect however this warning can be ignored. Sometimes an include file will have an empty main function commented out near the start or end of the script as the author may have used it during development to check for syntax errors.

Include files can be nested, that is, an #include directive can appear in a script which is itself referenced by another #include directive. For example core_h and log_h are included in events_h which in turn is included in ability_h. Including ability_h in a script provides access to all of the constants, functions and structs in each of these include files in the hierarchy.

An include file is automatically created and maintained for every plot resource even though it does not appear in the script resource palette. The naming convention for these include files is to prefix the plot's resref with plt_. The include file contains a string constant for the plot's GUID and int constants for each of the plot flags.