Behavior Template using C++

Topics

  1. Creating a Bot Behavior Using The Behavior Template in C++
  2. Customizing Workspace Settings

Creating a Bot Behavior Using The Behavior Template in C++

The BotBehavior workspace contains everything needed in order to build a FlexBot behavior module in Microsoft Visual C++. The only code that needs to be edited by the user is in the file "npc.cpp". This file contains an empty function called update(), which is called by the FlexBot DLL on every think cycle in order to determine what action to take. The user defines what action will be taken by making calls to actuators. Information can be obtained about the bot's state and the bot's environment by making calls to sensors. Once the user has coded the bot's behavior, the project can be compiled and a Behavior DLL created. The resulting DLL must be placed in the "behavior_dlls" folder within the FlexBot MOD's "dlls" folder. Once the Behavior DLL has been placed here, it will appear the menu of behaviors available for loading or can be loaded from the console.


Customizing Workspace Settings

You might want to change some settings in the workspace. For example, by default the workspace compiles a file named BotBehavior.dll, you might want to change this to something else, especially if you're working in the public lab. Also, if your Half-Life is installed to some dir other than the default one, you'll also need to change the custom-build setting in the workspace, since it automatically copies the *.dll file to "c:\sierra\half-life\flexbot\dlls\behavior_dlls".