T_TFGateBot_Scout_Melee // Template taken from robot_gatebot.pop, a Valve-made robot template file, comments added by me.
{
Class Scout // "Name", "Class", "Health", "ClassIcon", and "Scale" all have to be defined outside of the EventChangeAttributes block; those attributes cannot be changed. Everything else, INCLUDING stuff you don't actually intend on changing, still needs to be included within EventChangeAttributes.
EventChangeAttributes // Within here, we can define the different "states" that this bot can have. Only one of these can be active at a time.
{
Default // This set of attributes is used before any gate(s) have been captured, to tell the bot to go capture the gate. As the name specifies, it is also the default state.
{
Tag bot_gatebot // This tag indicates that this bot is a gatebot. This is used by map entities to filter for gatebots, such as in func_nav_prerequisites. filter_tf_bot_has_tag can be used to filter by a bot's tag for any entity that does not natively support tag filtering.
Tag nav_prefer_gate1_flank // All Valve templates include this extra tag, which is referenced by func_nav_avoid entities to force gatebots towards the gate. I'm not sure why they didn't just reference the bot_gatebot tag; in my own map mvm_cargoship, which also has gatebots, I found this tag to be unnecessary.
BehaviorModifiers push // Tells the bot to make a beeline for its objective. Unless otherwise overridden by a func_nav_prerequisite entity, it will run towards and hang around the bomb hatch.
Attributes IgnoreFlag // Tells the bot to not chase after the flag.
Item "MvM GateBot Light Scout" // This is the glowy hat worn by gatebots to allow players to visually distinguish them from normal bomb-carrying robots.
Skill Normal // Although these attributes don't change, we still have to define them within each of the robot's "states".
WeaponRestrictions MeleeOnly
ItemAttributes
{
ItemName "TF_WEAPON_SCATTERGUN"
"damage penalty" 0.5
}
}
RevertGateBotsBehavior // This set of attributes is used after all gates are captured, to tell the bot to be a normal bot and try to deliver the bomb.
{
// Notice that the bot_gatebot tag, the BehaviorModifier, and IgnoreFlag are all gone. Those were the things causing the bot to attempt to capture gates; with those gone, the bot will now attempt to deliver the bomb. No extra stuff is necessary to make the bot go after the bomb, since that is the default objective for all bots.
Item "MvM GateBot Light Scout"
ItemAttributes // Gatebots keep their light hat, but the light turns off to indicate their reversion to normal behavior. The turned off light is simply another style of the hat; we override it with this.
{
ItemName "MvM GateBot Light Scout"
"item style override" 1
}
ItemAttributes
{
ItemName "TF_WEAPON_SCATTERGUN"
"damage penalty" 0.5
}
Skill Normal // Although these attributes don't change, we still have to define them within each of the robot's "states".
WeaponRestrictions MeleeOnly
}
}
}