Game Development Reference
In-Depth Information
But if this same scenario is encountered in a game where the AI state machines
are written in script, it may be possible to reload the AI's script dynamically and
have the fix occur while the game is still running. This ability to dynamically re-
load scripts can be a huge productivity increase.
Returning to the C++ version of the AI behavior, suppose that there is a bug in a
guard's AI where sometimes a bad pointer is accessed. If you've programmed in
C++ before, you know that accessing a bad pointer will usually result in a crash. If
this bug keeps popping up all the time, the game will crash often. But if the state
machine was instead written in script, it would be possible to have only the AI for
that particular character stop functioning while the rest of the game continues to
run. This second scenario is far more preferable than the first.
Furthermore, because scripts are files that are separate from the executable, it
makes distributing changes much easier. On a large project, building the execut-
able can take several minutes, and the resultant file might approach 100MB. This
means that whenever there's a new version, whoever wants it might have to down-
loadthatentirefile.Ontheotherhand,ifascriptinglanguageisused,theusermay
only have to download a couple kilobytes of data, which is going to be a much
faster process. This is especially helpful when deploying patches in a retail scen-
ario, but it can also be useful during development.
Because of these productivity advantages, a good rule of thumb is that if the per-
formance of the system is not mission-critical, it may be beneficial to write the
system in script. There is, of course, the overhead of adding a scripting system to
the game itself, but the time spent on that can be easily reclaimed if it leads to in-
creased productivity for several members of the development team.
Types of Scripting Languages
If you decide to use a scripting language for some gameplay logic, the next logical
question is, which scripting language? Two different approaches need to be con-
sidered: using an existing scripting language, such as Lua or Python, and using a
custom scripting language designed specifically for the game engine in question.
Some examples of custom languages include UnrealScript and QuakeC.
The advantage of using an existing language is that it typically will be much less
work, because writing a script parser can be a time-consuming and error-prone en-
deavor, even when you're using tools that aid the process. Furthermore, because
a custom language has a much smaller number of users than existing languages,
there is a high likelihood of errors persisting in the language over long periods of
Search WWH ::




Custom Search