_________ __ __ / _____// |_____________ _/ |______ ____ __ __ ______ \_____ \\ __\_ __ \__ \\ __\__ \ / ___\| | \/ ___/ / \| | | | \// __ \| | / __ \_/ /_/ > | /\___ \ /_______ /|__| |__| (____ /__| (____ /\___ /|____//____ > \/ \/ \//_____/ \/ ______________________ ______________________ T H E W A R B E G I N S Stratagus - A free fantasy real time strategy game engine
Go to the source code of this file.
Classes | |
class | CUnitFilter |
class | NoFilter |
class | HasSameTypeAs |
class | HasSamePlayerAs |
class | HasNotSamePlayerAs |
class | IsAlliedWith |
class | IsEnemyWith |
class | HasSamePlayerAndTypeAs |
class | IsNotTheSameUnitAs |
class | IsBuildingType |
class | IsAggresiveUnit |
class | OutOfMinRange |
class | NotPredicate< Pred > |
class | AndPredicate< Pred1, Pred2 > |
class | CUnitTypeFinder |
class | UnitFinder |
Functions | |
unit.h - The unit headerfile. | |
template<typename Pred > | |
NotPredicate< Pred > | MakeNotPredicate (Pred pred) |
template<typename Pred1 , typename Pred2 > | |
AndPredicate< Pred1, Pred2 > | MakeAndPredicate (Pred1 pred1, Pred2 pred2) |
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) |
template<int selectMax = 0, typename Pred > | |
void | SelectFixed (const Vec2i <Pos, const Vec2i &rbPos, std::vector< CUnit * > &units, Pred pred) |
template<int selectMax = 0, typename Pred > | |
void | Select (const Vec2i <Pos, const Vec2i &rbPos, std::vector< CUnit * > &units, Pred pred) |
template<int selectMax = 0, typename Pred > | |
void | SelectAroundUnit (const CUnit &unit, int range, std::vector< CUnit * > &around, Pred pred) |
template<typename Pred > | |
CUnit * | FindUnit_IfFixed (const Vec2i <Pos, const Vec2i &rbPos, Pred pred) |
template<typename Pred > | |
CUnit * | FindUnit_If (const Vec2i <Pos, const Vec2i &rbPos, Pred pred) |
CUnit * | UnitFindResource (const CUnit &unit, const CUnit &startUnit, int range, int resource, bool check_usage=false, const CUnit *deposit=NULL) |
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... | |
bool | FindTerrainType (int movemask, int resmask, int range, const CPlayer &player, const Vec2i &startPos, Vec2i *pos) |
Find the neareast piece of terrain with specific flags. More... | |
void | FindUnitsByType (const CUnitType &type, std::vector< CUnit * > &units, bool everybody=false) |
void | FindPlayerUnitsByType (const CPlayer &player, const CUnitType &type, std::vector< CUnit * > &units, bool ai_active=false) |
Find all units of this type of the player. More... | |
CUnit * | UnitOnMapTile (const Vec2i &pos, unsigned int type) |
Return any unit on that map tile. More... | |
CUnit * | TargetOnMap (const CUnit &unit, 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=true) |
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=NULL) |
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. |
CUnit* FindUnit_IfFixed | ( | const Vec2i & | ltPos, |
const Vec2i & | rbPos, | ||
Pred | pred | ||
) |
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 |
AndPredicate<Pred1, Pred2> MakeAndPredicate | ( | Pred1 | pred1, |
Pred2 | pred2 | ||
) |
NotPredicate<Pred> MakeNotPredicate | ( | Pred | pred | ) |
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. |
void Select | ( | const Vec2i & | ltPos, |
const Vec2i & | rbPos, | ||
std::vector< CUnit * > & | units, | ||
Pred | pred | ||
) |
void SelectAroundUnit | ( | const CUnit & | unit, |
int | range, | ||
std::vector< CUnit * > & | around, | ||
Pred | pred | ||
) |
void SelectFixed | ( | const Vec2i & | ltPos, |
const Vec2i & | rbPos, | ||
std::vector< CUnit * > & | units, | ||
Pred | pred | ||
) |
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. |