AgentFinder version 2.00 released!
AgentFinder is a code library for tracking agents on the field, allowing developers to iterate through those agents using a number of filters (conditions match, distance from point, contains in rectangle, custom callback match).
This is a Module System alternative to corresponding WSE operation, made as efficient as possible.
The library splits the mission map into a grid of cells. Level of detail can be controlled by developer from mission to mission (so on battle mission you may want a 24x24 grid while for general town visit you are satisfied with 8x8 grid). Each grid cell tracks what agents are located inside, and the library tracks agents movement between cells, spawning and death, updating the grid accordingly.
For version 2.0 data storage model has been converted from arrays to lists. This means there are no longer any limits to number of agents tracked by a single cell, and almost no limit to the number of cells in the grid (up to 500x500 as far as I'm aware).
Download URL #1: http://www.nexusmods.com/mountandblade/mods/3103
Download URL #2: http://www.mbrepository.com/file.php?id=3103
AgentFinder is a code library for tracking agents on the field, allowing developers to iterate through those agents using a number of filters (conditions match, distance from point, contains in rectangle, custom callback match).
This is a Module System alternative to corresponding WSE operation, made as efficient as possible.
The library splits the mission map into a grid of cells. Level of detail can be controlled by developer from mission to mission (so on battle mission you may want a 24x24 grid while for general town visit you are satisfied with 8x8 grid). Each grid cell tracks what agents are located inside, and the library tracks agents movement between cells, spawning and death, updating the grid accordingly.
For version 2.0 data storage model has been converted from arrays to lists. This means there are no longer any limits to number of agents tracked by a single cell, and almost no limit to the number of cells in the grid (up to 500x500 as far as I'm aware).
Download URL #1: http://www.nexusmods.com/mountandblade/mods/3103
Download URL #2: http://www.mbrepository.com/file.php?id=3103
This is a script library which tracks agents on the mission map, allowing you to do the following:
1. Search effectively for all agents within specified radius of any map position, matching custom filter criteria. This is obviously less effective than WSE, but considerably more effective than direct iteration through all agents on the scene.
2. Library splits the map into a grid of smaller cells, each containing a number of agents. Library allows you to access both individual cells and rectangular sets of cells, extracting lists of agents present in those cells, filter those lists with custom filter criteria, counting number of agents matching criteria (when you don't need the list), or extracting an "agent presence" matrix for a cell range, containing the number of agents matching your filter in each cell.
Download URL: http://www.mbrepository.com/file.php?id=3103
Code usage examples:
These two are top-level functions, fully abstracting the internal workings of the library (grid and cell structure of the map etc). You just call them and voila - in the slots of the <agent_no>, starting from the <slot_id>, there's a list of agents who are located in the requested region and match the filter criteria (with list size stored in reg0).
Once you have a list of agents, you can further filter it either by filter criteria, or by physical location.
These functions allow you to get a list of agents in a rectangular area of the map (either a single cell, or a cell range). This list can then be filtered as necessary.
These functions allow you to calculate the number of agents matching the filter in the specified rectangular area of the map.
Same as above, but this function not only returns the total number of matching agents in the area, but also records a per-cell matrix of how many agents matching the filter are in each respective cell. This function was written with AI in mind. For example, your agent can easily scan a 5x5 area centered on himself, determining number of enemies and friends in each cell, then proceed to estimating his situation.
And the filters. They are quite expandable (this needs additional coding obviously, but nothing extreme).
1. Search effectively for all agents within specified radius of any map position, matching custom filter criteria. This is obviously less effective than WSE, but considerably more effective than direct iteration through all agents on the scene.
2. Library splits the map into a grid of smaller cells, each containing a number of agents. Library allows you to access both individual cells and rectangular sets of cells, extracting lists of agents present in those cells, filter those lists with custom filter criteria, counting number of agents matching criteria (when you don't need the list), or extracting an "agent presence" matrix for a cell range, containing the number of agents matching your filter in each cell.
Download URL: http://www.mbrepository.com/file.php?id=3103
Code usage examples:
Code:
(call_script, "script_agent_get_agents_near_self", <agent_no>, <slot_id_to_store_resulting_list>, <radius>, <filter_criteria>),
(call_script, "script_agent_get_agents_near_position", <agent_no>, <slot_id_to_store_resulting_list>, <position>, <radius>, <filter_criteria>),
Code:
(call_script, "script_agent_filter_agents_list", <agent_no>, <slot_id_where_list_starts>, <list_length>, <filter_criteria>),
(call_script, "script_agent_filter_agents_list_by_circle", <agent_no>, <slot_id_where_list_starts>, <list_length>, <position>, <radius>),
Code:
(call_script, "script_agent_get_agents_in_cell", <agent_no>, <slot_id_to_store_resulting_list>, <cell_x>, <cell_y>),
(call_script, "script_agent_get_agents_in_cellrange", <agent_no>, <slot_id_to_store_resulting_list>, <topleft_cell_x>, <topleft_cell_y>, <bottomright_cell_x>, <bottomright_cell_y>),
Code:
(call_script, "script_agent_count_agents_in_cell", <agent_no>, <cell_x>, <cell_y>, <filter_criteria>),
(call_script, "script_agent_count_agents_in_cellrange", <agent_no>, <topleft_cell_x>, <topleft_cell_y>, <bottomright_cell_x>, <bottomright_cell_y>, <filter_criteria>),
Code:
(call_script, "script_agent_get_agents_presence_matrix", <agent_no>, <slot_id_to_store_matrix>, <topleft_cell_x>, <topleft_cell_y>, <bottomright_cell_x>, <bottomright_cell_y>, <filter_criteria>),
And the filters. They are quite expandable (this needs additional coding obviously, but nothing extreme).
Code:
afinder_no_filter = 0
afinder_humans = 1 # human agents only
afinder_horses = 2 # horse agents only (includes horses with riders)
afinder_same_team = 4 # agents from same team only
afinder_friendly = 8 # agents from same or allied teams
afinder_hostile = 16 # agents from hostile teams
afinder_footed = 32 # implies afinder_humans
afinder_mounted = 64 # implies afinder_humans
afinder_ranged = 128 # implies afinder_humans
afinder_riderless = 256 # implies afinder_horses
afinder_exclude_self = 512 # will exclude the agent who is making the search
afinder_horsearchers = afinder_mounted | afinder_ranged
afinder_traitors = afinder_humans | afinder_same_team | afinder_hostile # No, this doesn't really work. :-)