User:Windolon/PopExtensionsPlus Documentation/AddRobotTag
Jump to navigation
Jump to search
Note:The functionalities could be replicated by performing bot tag checks in the
Function description
void AddRobotTag(string tag, table hooks)
Adds game event hooks directly to robots with specified popfile Tag
. Hooks added via this function are exactly those found in game events, but instead of being fired every time such an event occurs, they are fired every time an event occurs on the robot itself.

OnGameEvent_
functions themselves and making your own callbacks, but this function wraps all of that up and removes the need to write boilerplate code.Hooks
To add a hook, insert functions with their specified signatures into the hooks
table. If a function supports a game event parameter table, you are able to access and possibly change its keys corresponding to the game event that the function is hooked to.
Signature | Corresponding game event | Notes |
---|---|---|
void OnSpawn(handle bot, string tag)
|
None | Called when the robot is spawned. The only hook that is not connected to a game event, hence no game event parameter table is supported. |
void OnDeath(handle bot, table params)
|
player_death
|
Called when the robot is killed. params may be null if the bot was forcefully changed to spectator team.
|
void OnKill(handle bot, table params)
|
player_death
|
Called when the robot kills someone. |
void OnTakeDamage(handle bot, table params)
|
OnScriptHook_OnTakeDamage
|
Called when the robot takes damage, but before the damage is calculated. |
void OnTakeDamagePost(handle bot, table params)
|
player_hurt
|
Called when the robot takes damage, after the damage is dealt. |
void OnDealDamage(handle bot, table params)
|
OnScriptHook_OnTakeDamage
|
Called when the robot deals damage, but before the damage is calculated. |
void OnDealDamagePost(handle bot, table params)
|
player_hurt
|
Called when the robot deals damage, after the damage is dealt. |
Example usage
// these hooks will only run on robots that have Tag my_robot_tag given in the popfile
PopExt.AddRobotTag("my_robot_tag",
{
OnSpawn = function(bot, tag)
{
// announce spawn in console
printl("A bot with tag " + tag + " has spawned!")
}
OnTakeDamage = function(bot, params)
{
// reduce 80% of incoming damage during taunting
if (bot.IsTaunting()) params.damage *= 0.2
}
OnKill = function(bot, params)
{
// announce kill in console
printl("Robot killed player with weapon name " + params.weapon)
}
})