Template:Op agents and teams

Agents and teams
An agent represents of a single soldier on the 3D scene. Always keep this in mind when dealing with regular troops. A party may have 30 Swadian Knights. They will form a single troop stack in the party, and they will all be copies of the one and only Swadian Knight troop. However when the battle starts, this stack will spawn 30 distinct Agents.

Agents do not persist - they only exist in the game for the duration of the mission. As soon as the player returns to the world map, all agents who were present on the scene immediately disappear. If this was a battle during a normal game encounter, then the game will keep track of the battle results, and depending on the number of agents killed from all sides the engine will kill or wound some troops in the troop stacks of the parties who were participating in the battle.

During the mission, all agents are split into teams. By default player and his companions are placed into Team 0, but this may be changed in the mission template or by code. Player's enemies are usually team 1 (though again, this is not set in stone). Module System provides the modder with a great degree of control over teams composition, relation to each other (you can make hostile, allied or neutral teams, and you can have more than one team on the scene).

Conditional operations
agent_is_in_special_mode = 1693
 * Checks that the agent is currently in scripted mode.
 * Checks that the agent is currently in scripted mode.

agent_is_routed = 1699
 * Checks that the agent has fled from the map (i.e. reached the edge of the map in fleeing mode and then faded).
 * Checks that the agent has fled from the map (i.e. reached the edge of the map in fleeing mode and then faded).

agent_is_alive = 1702
 * Checks that the agent is alive. This will fail for dead or retreated agents (retreating counts from starting to fade out).
 * Checks that the agent is alive. This will fail for dead or retreated agents (retreating counts from starting to fade out).

agent_is_wounded = 1703
 * Checks that the agent has been knocked unconscious. Alive agents return 0 even with zero hit points.
 * Checks that the agent has been knocked unconscious. Alive agents return 0 even with zero hit points.

agent_is_human = 1704
 * Checks that the agent is human (i.e. not horse).
 * Checks that the agent is human (i.e. not horse).

agent_is_ally = 1706
 * Checks that the agent is allied to the player (belongs to player's party or allied party in current encounter).
 * Fails if player agent hasn't spawned yet.
 * Fails if player agent hasn't spawned yet.

agent_is_non_player = 1707
 * Checks that the agent is not a player.
 * Checks that the agent is not a player.

agent_is_defender = 1708
 * Checks that the agent belongs to the defending side (see encounter operations for details).
 * Checks that the agent belongs to the defending side (see encounter operations for details).

agent_is_active = 1712
 * Checks that the  reference is active i.e. agent is valid. This will always succeed inside try_for_agents loop.
 * Checks that the  reference is active i.e. agent is valid. This will always succeed inside try_for_agents loop.

agent_has_item_equipped = 1729
 * Checks that the agent has a specific item equipped.
 * Checks that the agent has a specific item equipped.

agent_is_in_parried_animation = 1769
 * Checks that the agent is currently in parrying animation (defending from some attack).
 * Checks that the agent is currently in parrying animation (defending from some attack).

agent_is_alarmed = 1806
 * Checks that the agent is alarmed (in combat mode with weapon drawn).
 * Checks that the agent is alarmed (in combat mode with weapon drawn).

class_is_listening_order = 1775
 * Checks that the specified group of specified team is listening to player's orders.
 * Checks that the specified group of specified team is listening to player's orders.

teams_are_enemies = 1788
 * Checks that the two teams are hostile to each other.
 * Checks that the two teams are hostile to each other.

agent_is_in_line_of_sight = 1826
 * Version 1.153+. Checks that the agent can be seen from specified position. Rotation of position register is not used (i.e. agent will be seen even if position is "looking" the other way).
 * Is more expensive in performance than position_has_line_of_sight_to_position.
 * Is more expensive in performance than position_has_line_of_sight_to_position.

Team and agent slot operations
Team and agent slots reset every mission.

team_set_slot = 509
 * (team_set_slot, , , ),

team_get_slot = 529
 * (team_get_slot,, , ),

team_slot_eq = 549
 * (team_slot_eq, , , ),

team_slot_ge = 569
 * (team_slot_ge, , , ),

agent_set_slot = 505
 * (agent_set_slot, , , ),

agent_get_slot = 525
 * (agent_get_slot,, , ),

agent_slot_eq = 545
 * (agent_slot_eq, , , ),

agent_slot_ge = 565
 * (agent_slot_ge, <agent_id>, <slot_no>, ),

Agent spawning, removal and general operations
add_reinforcements_to_entry = 1930
 * (add_reinforcements_to_entry, <mission_template_entry_no>, <wave_size>),
 * For battle missions, adds reinforcement wave to the specified entry point. Additional parameter determines relative wave size. Agents in reinforcement wave are taken from all parties of the side that the entry point belongs to due to mtef_team_* flags.

set_spawn_position = 1970
 * (set_spawn_position, ),:: DUPLICATE ENTRY
 * Defines the position which will later be used by (spawn_scene_prop), (spawn_scene_item), (spawn_agent) and (spawn_horse) operations.

spawn_agent = 1972
 * (spawn_agent, <troop_id>),
 * Spawns a new troop in the specified position and saves the reference to the new agent in reg0.

spawn_horse = 1973
 * (spawn_horse, <item_kind_id>, <item_modifier>),
 * Spawns a new horse (with any modifier) in the specified position and saves the reference to the new agent in reg0.

remove_agent = 1755
 * (remove_agent, <agent_id>),
 * Instantly kills or wounds an agent (will emit dying sound).

agent_fade_out = 1749
 * (agent_fade_out, <agent_id>),
 * Fades out the agent from the scene (same effect as fleeing enemies when they get to the edge of map). They will be counted as alive for battle missions.

agent_play_sound = 1750
 * (agent_play_sound, <agent_id>, <sound_id>),
 * Makes the agent emit the specified sound.

agent_stop_sound = 1808
 * (agent_stop_sound, <agent_id>),
 * Stops whatever sound agent is currently performing. Only the reference to the last used sound channel is stored, it is impossible to know which ones were used before for a certain agent.

agent_set_visibility = 2096
 * (agent_set_visibility, <agent_id>, ),
 * Version 1.153+. Sets agent visibility. 0 for invisible, 1 for visible.

get_player_agent_no = 1700
 * (get_player_agent_no, ),
 * Retrieves the reference to the player-controlled agent. Singleplayer mode only.

agent_get_kill_count = 1723
 * (agent_get_kill_count,, <agent_id>, [get_wounded]),
 * Retrieves the total number of kills by the specified agent during this battle. Call with non-zero <get_wounded> parameter to retrieve the total number of enemies the agent has knocked down.

agent_get_position = 1710
 * (agent_get_position,, <agent_id>),
 * Retrieves the position of the specified agent on the scene.
 * X, Y, Z - fixed point values, rotation - integer values in degrees from 0 to 359.
 * Position is at ground level even when agent is jumping.
 * Sets X-rotation = 0, Y-rotation = 0. Y-rotation can change from 340 to 20 (aproximately) when turning mounted.
 * Horse and rider have the same position and speed-position.

agent_set_position = 1711
 * (agent_set_position, <agent_id>, ),
 * Teleports the agent to specified position on the scene, sets to ground level automatically if dynamics are not turned off before setting agent position (agent_set_no_dynamics). Be careful with riders - you must teleport the horse, not the rider for the operation to work correctly! Does not properly set the rotation of players in MP Warband as their mouse-look direction overrides it. Gets synchronized by game engine automatically if called on server. Each time you call this operation the game sends a network event to all clients. Too many calls will fresh or mess up the client completely, so the only solution is not calling them 20 times per frame.

agent_get_horse = 1714
 * (agent_get_horse,, <agent_id>),
 * Retrieves the reference to the horse agent that the specified agent is riding, or -1 if he's not riding a horse (or is a horse himself).

agent_get_rider = 1715
 * (agent_get_rider,, <horse_agent_id>),
 * Retrieves the reference to the rider agent who is riding the specified horse, or -1 if there's no rider or the specified agent is not a horse.

agent_get_party_id = 1716
 * (agent_get_party_id,, <agent_id>),
 * Retrieves the party that the specified agent belongs to (supposedly should only work in battle missions for agents spawned as starting/reinforcement waves).

agent_get_entry_no = 1717
 * (agent_get_entry_no,, <agent_id>),
 * Retrieves the entry point number where this agent has spawned. What does this return for agents spawned with (spawn_agent)? 4research.

agent_get_troop_id = 1718
 * (agent_get_troop_id,, <agent_id>),
 * Retrieves the troop type of the specified agent. Returns -1 for horses (because horses are items, not troops).

agent_get_item_id = 1719
 * (agent_get_item_id,, <horse_agent_id>),
 * Retrieves the item type of the specified horse agent. Returns -1 for humans.

Agent combat parameters and stats
store_agent_hit_points = 1720
 * Retrieves current agent health. Optional last parameter determines whether actual health (absolute = 1) or relative percentile health (absolute = 0) is returned. Default is relative.
 * Retrieves current agent health. Optional last parameter determines whether actual health (absolute = 1) or relative percentile health (absolute = 0) is returned. Default is relative.

agent_set_hit_points = 1721
 * Sets new value for agent health. Optional last parameter determines whether the value is interpreted as actual health (absolute = 1) or relative percentile health (absolute = 0). Default is relative.
 * Sets new value for agent health. Optional last parameter determines whether the value is interpreted as actual health (absolute = 1) or relative percentile health (absolute = 0). Default is relative.

agent_set_max_hit_points = 2090
 * Version 1.153+. Changes agent's max hit points. Optional flag [absolute] determines if is an absolute number of his points, or relative percentage (0..1000) of default value. Treated as percentage by default.
 * Official: range [0..100]
 * Official: range [0..100]

agent_deliver_damage_to_agent = 1722
 * Official:
 * damage value was optional?
 * Makes one agent deal damage to another. Parameter damage_amount is optional, if it is skipped or <= 0, then damage will be calculated using attacker's weapon item and stats (like a normal weapon attack). Optional parameter weapon_item_id was added in 1.153 and will force the game the calculate the damage using this weapon.
 * Makes one agent deal damage to another. Parameter damage_amount is optional, if it is skipped or <= 0, then damage will be calculated using attacker's weapon item and stats (like a normal weapon attack). Optional parameter weapon_item_id was added in 1.153 and will force the game the calculate the damage using this weapon.

agent_deliver_damage_to_agent_advanced = 1827
 * Version 1.153+. Same as (agent_deliver_damage_to_agent), but resulting damage is returned. Also operation takes relations between agents into account, which may result in no damage, or even damage to attacker due to friendly fire rules.
 * Official:
 * if value <= 0, then damage will be calculated using the weapon item.
 * item_id is the item that the damage is delivered. can be ignored.
 * this advanced mode of agent_deliver_damage_to_agent has 2 differences. 1- the delivered damage is returned. 2- the damage delivery is done after checking the relationship between agents. this might cause no damage, or even damage to the shooter agent because of a friendly fire.
 * this advanced mode of agent_deliver_damage_to_agent has 2 differences. 1- the delivered damage is returned. 2- the damage delivery is done after checking the relationship between agents. this might cause no damage, or even damage to the shooter agent because of a friendly fire.

add_missile = 1829
 * Version 1.153+. Creates a missile with specified parameters. Note that <starting_position> parameter also determines the direction in which missile flies.
 * Supposedly after execution gets pos1 of wielded item.
 * Supposedly after execution gets pos1 of wielded item.

agent_get_speed = 1689
 * Retrieves agent speed to (X,Y) coordinates of the position register. Speed is local position to agent.
 * X, Y - fixed point values. Sets Z = 0, rotation of doesn't affected.
 * Cavalry don't have x-coordinate. Their position-y-rotation leans to left o right.
 * Cavalry don't have x-coordinate. Their position-y-rotation leans to left o right.

agent_set_no_death_knock_down_only = 1733
 * Sets the agent as unkillable (value = 1) or normal (value = 0). Unkillable agents will drop on the ground instead of dying and will stand up afterwards.
 * Sets the agent as unkillable (value = 1) or normal (value = 0). Unkillable agents will drop on the ground instead of dying and will stand up afterwards.

agent_set_horse_speed_factor = 1734
 * Multiplies agent's horse speed (and maneuverability?) by the specified percentile value (using 100 will make the horse). Note that this is called on the rider, not on the horse! Supposedly will persist even if the agent changes horses. 4research.
 * Multiplies agent's horse speed (and maneuverability?) by the specified percentile value (using 100 will make the horse). Note that this is called on the rider, not on the horse! Supposedly will persist even if the agent changes horses. 4research.

agent_set_speed_limit = 1736
 * Limits agent speed by the specified value in kph. Use 5 for average walking speed. Affects only AI agents.
 * Setting to 0 will limit the speed to a minimum value wich is never equal to 0.
 * Setting to 0 will limit the speed to a minimum value wich is never equal to 0.

agent_get_damage_modifier = 2065
 * Version 1.157+. output value is in percentage, 100 is default, value can be between [0..1000]
 * Version 1.157+. output value is in percentage, 100 is default, value can be between [0..1000]

agent_set_damage_modifier = 2091
 * Version 1.153+. Changes the damage delivered by this agent. Value is in percentage, 100 is default, 1000 is max possible value.
 * Version 1.153+. Changes the damage delivered by this agent. Value is in percentage, 100 is default, 1000 is max possible value.

agent_get_accuracy_modifier = 2066
 * Version 1.157+. output value is in percentage, 100 is default, value can be between [0..1000]
 * Version 1.157+. output value is in percentage, 100 is default, value can be between [0..1000]

agent_set_accuracy_modifier = 2092
 * Version 1.153+. Changes agent's accuracy (with ranged weapons?). Value is in percentage, 100 is default, value can be between [0..1000]
 * Version 1.153+. Changes agent's accuracy (with ranged weapons?). Value is in percentage, 100 is default, value can be between [0..1000]

agent_get_speed_modifier = 2067
 * Version 1.157+. output value is in percentage, 100 is default, value can be between [0..1000]
 * Version 1.157+. output value is in percentage, 100 is default, value can be between [0..1000]

agent_set_speed_modifier = 2093
 * Version 1.153+. Changes agent's speed. Value is in percentage, 100 is default, value can be between [0..1000]
 * Version 1.153+. Changes agent's speed. Value is in percentage, 100 is default, value can be between [0..1000]

agent_get_reload_speed_modifier = 2068
 * Version 1.157+. output value is in percentage, 100 is default, value can be between [0..1000]
 * Version 1.157+. output value is in percentage, 100 is default, value can be between [0..1000]

agent_set_reload_speed_modifier = 2094
 * Version 1.153+. Changes agent's reload speed. Value is in percentage, 100 is default, value can be between [0..1000]
 * Version 1.153+. Changes agent's reload speed. Value is in percentage, 100 is default, value can be between [0..1000]

agent_get_use_speed_modifier = 2069
 * Version 1.157+. output value is in percentage, 100 is default, value can be between [0..1000]
 * Version 1.157+. output value is in percentage, 100 is default, value can be between [0..1000]

agent_set_use_speed_modifier = 2095
 * Version 1.153+. Changes agent's speed with using various scene props. Value is in percentage, 100 is default, value can be between [0..1000]
 * Version 1.153+. Changes agent's speed with using various scene props. Value is in percentage, 100 is default, value can be between [0..1000]

agent_set_ranged_damage_modifier = 2099
 * Version 1.157+. Changes agent's damage with ranged weapons. Value is in percentage, 100 is default, value can be between [0..1000]
 * Version 1.157+. Changes agent's damage with ranged weapons. Value is in percentage, 100 is default, value can be between [0..1000]

agent_get_time_elapsed_since_removed = 1760
 * Retrieves the number of seconds that have passed since agent's death. Native uses this only for multiplayer to track player's respawns. Can it be used in singleplayer too? 4research.
 * Retrieves the number of seconds that have passed since agent's death. Native uses this only for multiplayer to track player's respawns. Can it be used in singleplayer too? 4research.

str_store_agent_face_keys = 2749
 * Stores agent face code. Regular agents have random generated face from two face codes of the troop.
 * Stores agent face code. Regular agents have random generated face from two face codes of the troop.

Agent equipment
agent_refill_wielded_shield_hit_points = 1692
 * (agent_refill_wielded_shield_hit_points, <agent_id>),
 * Restores all hit points for the shield the agent is currently wielding.

agent_set_invulnerable_shield = 1725
 * (agent_set_invulnerable_shield, <agent_id>, ),
 * Makes the agent shield invulnerable to any damage (value = 1) or makes him vulnerable again (value = 0).

agent_get_wielded_item = 1726
 * (agent_get_wielded_item,, <agent_id>, <hand_no>),
 * Retrieves the item reference that the agent is currently wielding in his right hand (hand_no = 0) or left hand (hand_no = 1). Note that weapons are always wielded in right hand, and shield in left hand. When wielding a two-handed weapon (including bows and crossbows), this operation will return -1 for left hand.

agent_get_ammo = 1727
 * (agent_get_ammo,, <agent_id>, ),
 * Retrieves the current ammo amount agent has for his wielded item (value = 1) or all his items (value = 0).

agent_get_item_cur_ammo = 1977
 * (agent_get_item_cur_ammo,, <agent_id>, <slot_no>),
 * Version 1.153+. Returns remaining ammo for specified agent's item.

agent_refill_ammo = 1728
 * (agent_refill_ammo, <agent_id>),
 * Refills all ammo and throwing weapon stacks that the agent has in his equipment.

agent_set_wielded_item = 1747
 * (agent_set_wielded_item, <agent_id>, <item_id>),
 * Forces the agent to wield the specified item. Agent must have that item in his equipment for this to work. Use item_id = -1 to unwield any currently wielded item.

agent_equip_item = 1779
 * (agent_equip_item, <agent_id>, <item_id>, [weapon_slot_no]),
 * Adds the specified item to agent and forces him to equip it. Optional weapon_slot_no parameter is only used with weapons and will put the newly added item to that slot (range 1..4). If it is omitted with a weapon item, then the agent must have an empty weapon slot for the operation to succeed.

agent_unequip_item = 1774
 * (agent_unequip_item, <agent_id>, <item_id>, [weapon_slot_no]),
 * Removes the specified item from the agent. Optional parameter weapon_slot_no is in range 1..4 and determines what weapon slot to remove (item_id must still be set correctly).

agent_set_ammo = 1776
 * (agent_set_ammo, <agent_id>, <item_id>, ),
 * Sets current agent ammo amount to the specified value between 0 and maximum ammo. <item_id> means - ammo item (arrows, bullets, grenades).
 * When you have more than one "quiver" of the same type you must add the total value of all in order to set the correct ammo amount.

agent_get_item_slot = 1804
 * (agent_get_item_slot,, <agent_id>, ),
 * Retrieves item_id for specified agent's slot Possible slot values range in 0..7, order is weapon1, weapon2, weapon3, weapon4, head_armor, body_armor, leg_armor, hand_armor.

agent_get_ammo_for_slot = 1825
 * (agent_get_ammo_for_slot,, <agent_id>, <slot_no>),
 * Retrieves the amount of ammo agent has in the referenced slot (range 0..3).

Agent animations
agent_set_no_dynamics = 1762
 * (agent_set_no_dynamics, <agent_id>, ),
 * Makes the agent stand on the spot (value = 1) or move normally (value = 0). When frozen on the spot the agent can still turn around and fight if necessary. Used in Native for the wedding scene (required for cut-scenes).

agent_get_animation = 1768
 * (agent_get_animation,, <agent_id>, <body_part>),
 * Retrieves current agent animation for specified body part (0 = lower, 1 = upper).

agent_set_animation = 1740
 * (agent_set_animation, <agent_id>, <anim_id>, [channel_no]),
 * Forces the agent to perform the specified animation. Optional channel_no parameter determines whether upper body (value = 1) or lower body (value = 0, default) is affected by animation.

agent_set_stand_animation = 1741
 * (agent_set_stand_animation, <agent_id>, <anim_id>),
 * Defines the animation that this agent will use when standing still. Does not force the agent into actually doing this animation.

agent_set_walk_forward_animation = 1742
 * (agent_set_walk_forward_animation, <agent_id>, <anim_id>),
 * Defines the animation that this agent will use when walking forward. Only works for NPC agents.

agent_set_animation_progress = 1743
 * (agent_set_animation_progress, <agent_id>, <value_fixed_point>),
 * Allows to skip the agent to a certain point in the animation cycle, as specified by the fixed point value (0..fixed_point_multiplier).

agent_ai_set_can_crouch = 2083
 * (agent_ai_set_can_crouch, <agent_id>, ),
 * Version 1.153+. Allows or forbids the agent to crouch. 0 to forbid, 1 to allow.

agent_get_crouch_mode = 2097
 * (agent_get_crouch_mode,, <agent_id>),
 * Version 1.153+. Retrieves agent's crouch status (1 = crouching, 0 = standing).

agent_set_crouch_mode = 2098
 * (agent_set_crouch_mode, <agent_id>, ),
 * Version 1.153+. Sets agent's crouch status (1 = crouch, 0 = stand up).

agent_get_attached_scene_prop = 1756
 * (agent_get_attached_scene_prop,, <agent_id>),
 * Retrieves the reference to scene prop instance which is attached to the agent, or -1 if there isn't any.

agent_set_attached_scene_prop = 1757
 * (agent_set_attached_scene_prop, <agent_id>, <scene_prop_id>),
 * Attaches the specified prop instance to the agent. Used in multiplayer CTF missions to attach flags to players.

agent_set_attached_scene_prop_x = 1758
 * (agent_set_attached_scene_prop_x, <agent_id>, ),
 * Offsets the position of the attached scene prop in relation to agent, in centimeters, along the X axis (left/right).

agent_set_attached_scene_prop_y = 1809
 * (agent_set_attached_scene_prop_y, <agent_id>, ),
 * Offsets the position of the attached scene prop in relation to agent, in centimeters, along the Y axis (backwards/forward).

agent_set_attached_scene_prop_z = 1759
 * (agent_set_attached_scene_prop_z, <agent_id>, ),
 * Offsets the position of the attached scene prop in relation to agent, in centimeters, along the Z axis (down/up).

agent_get_bone_position = 2076
 * (agent_get_bone_position, <position_no>, <agent_no>, <bone_no>, [<local_or_global>]),
 * Version 1.161+. Returns current position for agent's bone. Examine skeletons.brf and horse_skeleton.brf in CommonRes folder to see hitboxes of these bones and their <bone_no>.
 * Pass 1 as optional <local_or_global> parameter to retrieve global bone coordinates.

Agent AI and scripted behavior
agent_ai_set_interact_with_player = 2077
 * (agent_ai_set_interact_with_player, <agent_no>, ),
 * Version 1.165+. Enables or disables agent AI interation with player. Will not turn to face player.

agent_set_is_alarmed = 1807
 * (agent_set_is_alarmed, <agent_id>, ),
 * Sets agent's status as alarmed (value = 1) or peaceful (value = 0).

agent_clear_relations_with_agents = 1802
 * (agent_clear_relations_with_agents, <agent_id>),
 * Clears any agent-to-agent relations for specified agent.

agent_add_relation_with_agent = 1803
 * (agent_add_relation_with_agent, <agent_id>, <agent_id>, ),
 * Changes relations between two agents on the scene to enemy (value = -1), neutral (value = 0), ally (value = 1). Note that neutral agents are immune to friendly fire.

agent_get_number_of_enemies_following = 1761
 * (agent_get_number_of_enemies_following,, <agent_id>),
 * Retrieves the total number of enemies who are currently attacking the specified agents. May be used for AI decision-making.

agent_ai_get_num_cached_enemies = 2670
 * (agent_ai_get_num_cached_enemies,, <agent_no>),
 * Version 1.165+. Returns total number of nearby enemies as has been cached by agent AI.
 * Every 2 seconds a cache created with enemies stored from nearest to farthest. Max slots are 16.

agent_ai_get_cached_enemy = 2671
 * (agent_ai_get_cached_enemy,, <agent_no>, <cache_index>),
 * Version 1.165+. Return agent reference from AI's list of cached enemies, from nearest to farthest.
 * Returns -1 if the cached enemy from index is not exist.

agent_get_attack_action = 1763
 * (agent_get_attack_action,, <agent_id>),
 * Retrieves agent's current attack action. Possible values: free = 0, readying_attack = 1, releasing_attack = 2, completing_attack_after_hit = 3, attack_parried = 4, reloading = 5, after_release = 6, cancelling_attack = 7.

agent_get_defend_action = 1764
 * (agent_get_defend_action,, <agent_id>),
 * Retrieves agent's current defend action. Possible values: free = 0, parrying = 1, blocking = 2.

agent_get_action_dir = 1767
 * Retrieves the direction of current agent's action.
 * Possible values at attacking: invalid = -1, ranged/thrust = 0, right swing = 1, left swing = 2, overswing = 3.
 * Possible values at defending: invalid = -1, forward/down = 0, right = 1, left = 2, up = 3, global/blocking with shield = 5.

agent_set_attack_action = 1745
 * (agent_set_attack_action, <agent_id>, <direction_value>, <action_value>),
 * Forces the agent to perform an attack action. Direction value: -2 = cancel any action (1.153+), 0 = thrust, 1 = slashright, 2 = slashleft, 3 = overswing. Action value: 0 = ready and release, 1 = ready and hold.

agent_set_defend_action = 1746
 * (agent_set_defend_action, <agent_id>,, <duration-in-1/1000-seconds>),
 * Forces the agent to perform a defend action. Possible values: -2 = cancel any action (1.153+), 0 = defend_down, 1 = defend_right, 2 = defend_left, 3 = defend_up. Does time value determine delay, speed or duration? 4research.

agent_set_scripted_destination = 1730
 * Official: (agent_set_scripted_destination, <agent_id>, <position_no>, <auto_set_z_to_ground_level>, <no_rethink>),
 * (agent_set_scripted_destination, <agent_id>,, [auto_set_z_to_ground_level], [no_rethink]),
 * Forces the agent to travel to specified position and stay there until new behavior is set or scripted mode cleared. First optional parameter determines whether the position Z coordinate will be automatically set to ground level (value = 1) or not (value = 0). Second optional parameter added in 1.165 patch, set it to 1 to save resources.

agent_set_scripted_destination_no_attack = 1748
 * (agent_set_scripted_destination_no_attack, <agent_id>,, <auto_set_z_to_ground_level>),
 * Same as above, but the agent will not attack his enemies.

agent_get_scripted_destination = 1731
 * (agent_get_scripted_destination,, <agent_id>),
 * Retrieves the position which is defined as agent's scripted destination, if any.

agent_force_rethink = 1732
 * (agent_force_rethink, <agent_id>),
 * Forces the agent to recalculate his current actions after setting him a new scripted destination or changing other factors affecting his behavior.

agent_clear_scripted_mode = 1735
 * (agent_clear_scripted_mode, <agent_id>),
 * Clears scripting mode from the agent, making him behave as usual again.

agent_ai_set_always_attack_in_melee = 1737
 * (agent_ai_set_always_attack_in_melee, <agent_id>, ),
 * Forces the agent to continuously attack in melee combat, instead of defending. Used in Native to prevent stalling at the top of the siege ladder. Use value = 0 to clear this mode.

agent_get_simple_behavior = 1738
 * (agent_get_simple_behavior,, <agent_id>),
 * Retrieves agent's current simple behavior (see aisb_* constants in header_mission_templates.py for details).

agent_ai_get_behavior_target = 2082
 * (agent_ai_get_behavior_target,, <agent_id>),
 * Version 1.153+. UNTESTED. Supposedly returns agent_id which is the target of current agent's behavior.

agent_get_combat_state = 1739
 * (agent_get_combat_state,, <agent_id>),
 * Retrieves agent's current combat state:
 * 0 = nothing special, this value is also always returned for player and for dead agents.
 * 1 = target in sight (for ranged units)
 * 2 = guarding (without a shield)
 * 3 = preparing a melee attack or firing a ranged weapon
 * 4 = releasing a melee attack or reloading a crossbow
 * 7 = recovering after being hit in melee OR blocking with a shield. Contradictory information, 4research.
 * 8 = target to the right (horse archers) OR no target in sight (ranged units). Contradictory information, 4research.

agent_ai_get_move_target = 2081
 * (agent_ai_get_move_target,, <agent_id>),
 * Version 1.153+. UNTESTED. Supposedly returns the enemy agent to whom the agent is currently moving to.

agent_get_look_position = 1709
 * (agent_get_look_position,, <agent_id>),
 * Retrieves the coordinates of the agent position and currently looking angles.

agent_set_look_target_position = 1744
 * (agent_set_look_target_position, <agent_id>, ),
 * Forces an agent to look at the specified position (turn his head as necessary). Non alarmed agents will look for a short amount of time. Not all alarmed agents will look continuesly at the point.

agent_ai_get_look_target = 2080
 * (agent_ai_get_look_target,, <agent_id>),
 * Version 1.153+. UNTESTED. Supposedly returns agent_id that the agent is currently looking at.

agent_set_look_target_agent = 1713
 * (agent_set_look_target_agent, <watcher_agent_id>, <observed_agent_id>),
 * Forces the agent to look at specified agent (track his movements). Alarmed agents will ignore this.

agent_start_running_away = 1751
 * (agent_start_running_away, <agent_id>, [<position_no>]),
 * Makes the agent flee the battlefield, ignoring everything else and not attacking. If the agent reaches the edge of map in this mode, he will fade out. Optional position_no parameter added in 1.153 and will make the agent flee to specified position instead (pos0 is not allowed and will be ignored). When used on a mounted horse makes the agent 'fall off' instantly and the horse will run away (works for player too). Falling off from horse doesn't fire ti_on_agent_dismount trigger.

agent_stop_running_away = 1752
 * (agent_stop_run_away, <agent_id>),
 * Cancels fleeing behavior for the agent, turning him back to combat state.

agent_ai_set_aggressiveness = 1753
 * (agent_ai_set_aggressiveness, <agent_id>, ),
 * Sets the aggressiveness parameter for agent AI to use. Default value is 100. Higher values make agent more aggressive. Actual game effects are not obvious, apparently used to speed up mob aggravation when previously neutral.

agent_set_kick_allowed = 1754
 * (agent_set_kick_allowed, <agent_id>, ),
 * Enables (value = 1) or disables (value = 0) kicking for the specified agent. Only makes sense for player-controlled agents as bots don't know how to kick anyway (if not scripted into the mod, kicking AI).

set_cheer_at_no_enemy = 2379
 * (set_cheer_at_no_enemy, ),
 * Version 1.153+. Determines whether the agents will cheer when no enemy remain on the map. 0 = do not cheer, 1 = cheer.

agent_add_offer_with_timeout = 1777
 * (agent_add_offer_with_timeout, <agent_id>, <offerer_agent_id>, <duration-in-1/1000-seconds>),
 * Esoteric stuff. Used in multiplayer duels. Second agent_id is offerer, 0 value for duration is an infinite offer.

agent_check_offer_from_agent = 1778
 * (agent_check_offer_from_agent, <agent_id>, <offerer_agent_id>),:second agent_id is offerer
 * Esoteric stuff. Used in multiplayer duels. Second agent_id is offerer.

Team operations
agent_get_group = 1765
 * In multiplayer: Retrieves reference to player who is currently the leader of specified bot agent.
 * In singleplayer: Retrieves agent group wich is the same as agent team.
 * In singleplayer: Retrieves agent group wich is the same as agent team.

agent_set_group = 1766
 * In multiplayer: Puts the bot agent under command of specified player.
 * In singleplayer: Change the group. Agent team is not changed. Use agent_set_team.
 * In singleplayer: Change the group. Agent team is not changed. Use agent_set_team.

agent_get_team = 1770
 * Retrieves the team that the agent belongs to.
 * Retrieves the team that the agent belongs to.

agent_set_team = 1771
 * Puts the agent to specified team number. Also copies "value" to agent group.
 * The max is 7. But the 7 team is hardcoded neutral to everyone. If you set team out of range (0, 6) than 7 team will be assigned.
 * The max is 7. But the 7 team is hardcoded neutral to everyone. If you set team out of range (0, 6) than 7 team will be assigned.

agent_get_class = 1772
 * Retrieves the agent class (see grc_* constants in header_mission_templates.py for reference). Note this operation returns the troop class that the game divines from troop equipment and flags, ignoring any custom troop class settings.
 * Retrieves the agent class (see grc_* constants in header_mission_templates.py for reference). Note this operation returns the troop class that the game divines from troop equipment and flags, ignoring any custom troop class settings.

agent_get_division = 1773
 * Retrieves the agent division (custom troop class number in 0..8 range).
 * Retrieves the agent division (custom troop class number in 0..8 range).

agent_set_division = 1783
 * Puts the agent into the specified division. This does not affect agent's troop class. Note that there's a bug in Warband: if an order is issued to agent's original division, the agent will immediately switch back to it's original division number. Therefore, if you want to manipulate agent divisions dynamically during the battle, you need to implement some workarounds for this bug.
 * Puts the agent into the specified division. This does not affect agent's troop class. Note that there's a bug in Warband: if an order is issued to agent's original division, the agent will immediately switch back to it's original division number. Therefore, if you want to manipulate agent divisions dynamically during the battle, you need to implement some workarounds for this bug.

team_get_hold_fire_order = 1784
 * Retrieves current status of hold fire order for specified team/division (see aordr_* constants in header_mission_templates.py for reference).
 * Retrieves current status of hold fire order for specified team/division (see aordr_* constants in header_mission_templates.py for reference).

team_get_movement_order = 1785
 * Retrieves current movement orders for specified team/division (see mordr_* constants in header_mission_templates.py for reference).
 * Retrieves current movement orders for specified team/division (see mordr_* constants in header_mission_templates.py for reference).

team_get_riding_order = 1786
 * Retrieves current status of riding order for specified team/division (see rordr_* constants in header_mission_templates.py for reference).
 * Retrieves current status of riding order for specified team/division (see rordr_* constants in header_mission_templates.py for reference).

team_get_weapon_usage_order = 1787
 * Retrieves current status of weapon usage order for specified team/division (see wordr_* constants in header_mission_templates.py for reference).
 * Retrieves current status of weapon usage order for specified team/division (see wordr_* constants in header_mission_templates.py for reference).

team_give_order = 1790
 * Issues an order to specified team/division. Non alarmed agents will ignore.
 * Issues an order to specified team/division. Non alarmed agents will ignore.

team_set_order_position = 1791
 * Defines the position for specified team/division when currently issued order requires one.
 * Defines the position for specified team/division when currently issued order requires one.

team_get_leader = 1792
 * Retrieves the reference to the agent who is the leader of specified team.
 * Retrieves the reference to the agent who is the leader of specified team.

team_set_leader = 1793
 * Sets the player agent as the new leader of specified team. Doesn't work with regular agent.
 * Sets the player agent as the new leader of specified team. Doesn't work with regular agent.

team_get_order_position = 1794
 * Retrieves position which is used for specified team/division current orders.
 * Retrieves position which is used for specified team/division current orders.

team_set_order_listener = 1795
 * Official:
 * merge with old listeners if value is non-zero
 * clear listeners if sub_class is less than zero
 * Set the specified division as the one which will be following orders issued by the player (assuming the player is on the same team). If optional parameter add_to_listeners is greater than 0, then the operation will instead *add* specified division to order listeners. If division number is -1, then list of order listeners is cleared. If division number is 9, then all divisions will listen to player's orders.
 * Set the specified division as the one which will be following orders issued by the player (assuming the player is on the same team). If optional parameter add_to_listeners is greater than 0, then the operation will instead *add* specified division to order listeners. If division number is -1, then list of order listeners is cleared. If division number is 9, then all divisions will listen to player's orders.

team_set_relation = 1796
 * Sets relations between two teams. Possible values: enemy (-1) (default), neutral (0) and friendly (1).
 * Doesn't work for 7 team. It's hardcoded neutral to everyone.
 * Doesn't work for 7 team. It's hardcoded neutral to everyone.

store_remaining_team_no = 2360
 * Retrieves the number of the last remaining team. Currently not used in Native, possibly deprecated.
 * Retrieves the number of the last remaining team. Currently not used in Native, possibly deprecated.

team_get_gap_distance = 1828
 * Version 1.153+. UNTESTED. Supposedly returns average gap between troops of a specified team/class (depends on how many Stand Closer/Spread Out orders were given).
 * Version 1.153+. UNTESTED. Supposedly returns average gap between troops of a specified team/class (depends on how many Stand Closer/Spread Out orders were given).

Combat statistics
store_enemy_count = 2380
 * (store_enemy_count, ),
 * No longer used in Native. Apparently stores total number of active enemy agents. Possibly deprecated. 4research.

store_friend_count = 2381
 * (store_friend_count, ),
 * No longer used in Native. Apparently stores total number of active friendly agents. Possibly deprecated. 4research.

store_ally_count = 2382
 * (store_ally_count, ),
 * No longer used in Native. Apparently stores total number of active allied agents (how is it different from friends?). Possibly deprecated. 4research.

store_defender_count = 2383
 * (store_defender_count, ),
 * No longer used in Native. Apparently stores total number of active agents on defender's side. Possibly deprecated. 4research.

store_attacker_count = 2384
 * (store_attacker_count, ),
 * No longer used in Native. Apparently stores total number of active agents on attacker's side. Possibly deprecated. 4research.

store_normalized_team_count = 2385
 * (store_normalized_team_count,, <team_no>),
 * Stores the number of agents belonging to specified team, normalized according to battle_size and advantage. Commonly used to calculate advantage and possibly reinforcement wave sizes.
 * 100% is equal to relative spawn agents count on mission start. For example if spawn point have 40 then 50% will be 20.