_________ __ __
/ _____// |_____________ _/ |______ ____ __ __ ______
\_____ \\ __\_ __ \__ \\ __\__ \ / ___\| | \/ ___/
/ \| | | | \// __ \| | / __ \_/ /_/ > | /\___ \
/_______ /|__| |__| (____ /__| (____ /\___ /|____//____ >
\/ \/ \//_____/ \/
______________________ ______________________
T H E W A R B E G I N S
Stratagus - A free fantasy real time strategy game engine
#include <limits.h>#include "stratagus.h"#include "unit_find.h"#include "actions.h"#include "map.h"#include "missile.h"#include "pathfinder.h"#include "player.h"#include "spells.h"#include "tileset.h"#include "unit.h"#include "unit_manager.h"#include "unittype.h"Classes | |
| class | TerrainFinder |
| class | BestDepotFinder< NEARLOCATION > |
| class | CResourceFinder |
| class | ResourceUnitFinder |
| class | IsADepositForResource |
| class | BestTargetFinder |
| class | BestRangeTargetFinder |
| class | BestRangeTargetFinder::FillBadGood |
| struct | CompareUnitDistance |
Functions | |
unit_find.cpp - The find/select for units. | |
| void | Select (const Vec2i <Pos, const Vec2i &rbPos, std::vector< CUnit * > &units) |
| void | SelectFixed (const Vec2i <Pos, const Vec2i &rbPos, std::vector< CUnit * > &units) |
| void | SelectAroundUnit (const CUnit &unit, int range, std::vector< CUnit * > &around) |
| bool | FindTerrainType (int movemask, int resmask, int range, const CPlayer &player, const Vec2i &startPos, Vec2i *terrainPos) |
| Find the neareast piece of terrain with specific flags. More... | |
| CUnit * | FindDepositNearLoc (CPlayer &p, const Vec2i &pos, int range, int resource) |
| CUnit * | UnitFindResource (const CUnit &unit, const CUnit &startUnit, int range, int resource, bool check_usage, const CUnit *deposit) |
| Find resource. More... | |
| CUnit * | FindDeposit (const CUnit &unit, int range, int resource) |
| Find nearest deposit. More... | |
| CUnit * | FindIdleWorker (const CPlayer &player, const CUnit *last) |
| Find the next idle worker. More... | |
| void | FindUnitsByType (const CUnitType &type, std::vector< CUnit * > &units, bool everybody) |
| void | FindPlayerUnitsByType (const CPlayer &player, const CUnitType &type, std::vector< CUnit * > &table, bool ai_active) |
| Find all units of this type of the player. More... | |
| CUnit * | UnitOnMapTile (const unsigned int index, unsigned int type) |
| CUnit * | UnitOnMapTile (const Vec2i &pos, unsigned int type) |
| Return any unit on that map tile. More... | |
| CUnit * | TargetOnMap (const CUnit &source, const Vec2i &pos1, const Vec2i &pos2) |
| Return possible attack target on that map area. More... | |
| CUnit * | ResourceOnMap (const Vec2i &pos, int resource, bool mine_on_top) |
| Return resource, if on map tile. More... | |
| CUnit * | ResourceDepositOnMap (const Vec2i &pos, int resource) |
| Return resource deposit, if on map tile. More... | |
| bool | CheckObstaclesBetweenTiles (const Vec2i &unitPos, const Vec2i &goalPos, unsigned short flags, int *distance) |
| Check map for obstacles in a line between 2 tiles. More... | |
| CUnit * | AttackUnitsInDistance (const CUnit &unit, int range, CUnitFilter pred) |
| Find best enemy in numeric range to attack. More... | |
| CUnit * | AttackUnitsInDistance (const CUnit &unit, int range) |
| CUnit * | AttackUnitsInRange (const CUnit &unit, CUnitFilter pred) |
| Find best enemy in attack range to attack. More... | |
| CUnit * | AttackUnitsInRange (const CUnit &unit) |
| CUnit * | AttackUnitsInReactRange (const CUnit &unit, CUnitFilter pred) |
| Find best enemy in reaction range to attack. More... | |
| CUnit * | AttackUnitsInReactRange (const CUnit &unit) |
| CUnit* AttackUnitsInDistance | ( | const CUnit & | unit, |
| int | range, | ||
| CUnitFilter | pred | ||
| ) |
Find best enemy in numeric range to attack.
Attack units in distance.
If the unit can attack must be handled by caller. Choose the best target, that can be attacked.
| unit | Find in distance for this unit. |
| range | Distance range to look. |
| onlyBuildings | Search only buildings (useful when attacking with AI force) |
| CUnit* AttackUnitsInRange | ( | const CUnit & | unit, |
| CUnitFilter | pred | ||
| ) |
Find best enemy in attack range to attack.
Attack units in attack range.
| unit | Find unit in attack range for this unit. |
| CUnit* AttackUnitsInReactRange | ( | const CUnit & | unit, |
| CUnitFilter | pred | ||
| ) |
Find best enemy in reaction range to attack.
Attack units in reaction range.
| unit | Find unit in reaction range for this unit. |
| bool CheckObstaclesBetweenTiles | ( | const Vec2i & | unitPos, |
| const Vec2i & | goalPos, | ||
| unsigned short | flags, | ||
| int * | distance | ||
| ) |
Check map for obstacles in a line between 2 tiles.
Check map for obstacles in a line between 2 tiles
This function uses Bresenham's line algorithm
| unit | First tile |
| goal | Second tile |
| flags | Terrain type to check |
Find nearest deposit.
Find deposit. This will find a deposit for a resource
| unit | The unit that wants to find a resource. |
| range | Maximum distance to the deposit. |
| resource | Resource to find deposit from. |
Find the next idle worker.
Find the next idle worker
| player | Player's units to search through |
| last | Previous idle worker selected |
| void FindPlayerUnitsByType | ( | const CPlayer & | player, |
| const CUnitType & | type, | ||
| std::vector< CUnit * > & | table, | ||
| bool | ai_active | ||
| ) |
Find all units of this type of the player.
Find all units of type.
| player | we're looking for the units of this player |
| type | type of unit requested |
| table | table in which we have to store the units |
| bool FindTerrainType | ( | int | movemask, |
| int | resmask, | ||
| int | range, | ||
| const CPlayer & | player, | ||
| const Vec2i & | startPos, | ||
| Vec2i * | terrainPos | ||
| ) |
Find the neareast piece of terrain with specific flags.
Find the closest piece of terrain with the given flags.
| movemask | The movement mask to reach that location. |
| resmask | Result tile mask. |
| range | Maximum distance for the search. |
| player | Only search fields explored by player |
| startPos | Map start position for the search. |
| terrainPos | OUT: Map position of tile. |
Find all units of type.
| type | type of unit requested |
| units | array in which we have to store the units |
| everybody | if true, include all units |
Return resource deposit, if on map tile.
Resource deposit on map tile
| pos | position on map, tile-based. |
| resource | resource type. |
Return resource, if on map tile.
Resource on map tile
| pos | position on map, tile-based. |
| resource | resource type. |
| mine_on_top | return mine or mining area. |
Return possible attack target on that map area.
Choose target on map area.
| source | Unit which want to attack. |
| pos1 | position on map, tile-based. |
| pos2 | position on map, tile-based. |
| CUnit* UnitFindResource | ( | const CUnit & | unit, |
| const CUnit & | startUnit, | ||
| int | range, | ||
| int | resource, | ||
| bool | check_usage, | ||
| const CUnit * | deposit | ||
| ) |
Find resource.
Find Resource.
| unit | The unit that wants to find a resource. |
| startUnit | Find closest unit from this location |
| range | Maximum distance to the resource. |
| resource | The resource id. |
| CUnit* UnitOnMapTile | ( | const unsigned int | index, |
| unsigned int | type | ||
| ) |
Unit on map tile.
| index | flat index position on map, tile-based. |
| type | UnitTypeType, (unsigned)-1 for any type. |
1.8.17
(C) Copyright 1998-2012 by The Stratagus Project under the GNU General Public License.