$treeview $search $mathjax
Stratagus  2.2.7
$projectbrief
$projectbrief
$searchbox
-->
         _________ __                 __
        /   _____//  |_____________ _/  |______     ____  __ __  ______
        \_____  \\   __\_  __ \__  \\   __\__  \   / ___\|  |  \/  ___/
        /        \|  |  |  | \// __ \|  |  / __ \_/ /_/  >  |  /\___ \
       /_______  /|__|  |__|  (____  /__| (____  /\___  /|____//____  >
               \/                  \/          \//_____/            \/
    ______________________                           ______________________
                          T H E   W A R   B E G I N S
                   Stratagus - A free fantasy real time strategy game engine

src/include/unit_find.h File Reference

#include "map.h"
#include "pathfinder.h"
#include "unit.h"
#include "unittype.h"

Go to the source code of this file.


Classes

class  HasSameTypeAs
class  HasSamePlayerAs
class  HasNotSamePlayerAs
class  IsAlliedWith
class  IsEnemyWith
class  HasSamePlayerAndTypeAs
class  IsNotTheSameUnitAs
class  IsBuildingType
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 &ltPos, const Vec2i &rbPos, std::vector< CUnit * > &units)
void SelectFixed (const Vec2i &ltPos, const Vec2i &rbPos, std::vector< CUnit * > &units)
void SelectAroundUnit (const CUnit &unit, int range, std::vector< CUnit * > &around)
template<typename Pred>
void SelectFixed (const Vec2i &ltPos, const Vec2i &rbPos, std::vector< CUnit * > &units, Pred pred)
template<typename Pred>
void SelectAroundUnit (const CUnit &unit, int range, std::vector< CUnit * > &around, Pred pred)
template<typename Pred>
void Select (const Vec2i &ltPos, const Vec2i &rbPos, std::vector< CUnit * > &units, Pred pred)
template<typename Pred>
CUnitFindUnit_IfFixed (const Vec2i &ltPos, const Vec2i &rbPos, Pred pred)
template<typename Pred>
CUnitFindUnit_If (const Vec2i &ltPos, const Vec2i &rbPos, Pred pred)
CUnitUnitFindResource (const CUnit &unit, const CUnit &startUnit, int range, int resource, bool check_usage=false, const CUnit *deposit=NULL)
 Find resource.
CUnitFindDeposit (const CUnit &unit, int range, int resource)
 Find nearest deposit.
CUnitFindIdleWorker (const CPlayer &player, const CUnit *last)
 Find the next idle worker.
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.
void FindUnitsByType (const CUnitType &type, std::vector< CUnit * > &units)
void FindPlayerUnitsByType (const CPlayer &player, const CUnitType &type, std::vector< CUnit * > &units)
 Find all units of this type of the player.
CUnitUnitOnMapTile (const Vec2i &pos, unsigned int type)
 Return any unit on that map tile.
CUnitTargetOnMap (const CUnit &unit, const Vec2i &pos1, const Vec2i &pos2)
 Return possible attack target on that map area.
CUnitResourceOnMap (const Vec2i &pos, int resource, bool mine_on_top=true)
 Return resource, if on map tile.
CUnitResourceDepositOnMap (const Vec2i &pos, int resource)
 Return resource deposit, if on map tile.
CUnitAttackUnitsInDistance (const CUnit &unit, int range, bool onlyBuildings=false)
 Find best enemy in numeric range to attack.
CUnitAttackUnitsInRange (const CUnit &unit)
 Find best enemy in attack range to attack.
CUnitAttackUnitsInReactRange (const CUnit &unit)
 Find best enemy in reaction range to attack.

Function Documentation

CUnit* AttackUnitsInDistance ( const CUnit unit,
int  range,
bool  onlyBuildings 
)

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.

Parameters:
unit Find in distance for this unit.
range Distance range to look.
onlyBuildings Search only buildings (useful when attacking with AI force)
Returns:
Unit to be attacked.

CUnit* AttackUnitsInRange ( const CUnit unit  ) 

Find best enemy in attack range to attack.

Attack units in attack range.

Parameters:
unit Find unit in attack range for this unit.
Returns:
Pointer to unit which should be attacked.

CUnit* AttackUnitsInReactRange ( const CUnit unit  ) 

Find best enemy in reaction range to attack.

Attack units in reaction range.

Parameters:
unit Find unit in reaction range for this unit.
Returns:
Pointer to unit which should be attacked.

CUnit* FindDeposit ( const CUnit unit,
int  range,
int  resource 
)

Find nearest deposit.

Find deposit. This will find a deposit for a resource

Parameters:
unit The unit that wants to find a resource.
x Closest to x
y Closest to y
range Maximum distance to the deposit.
resource Resource to find deposit from.
Note:
This will return a reachable allied depot.
Returns:
NULL or deposit unit

CUnit* FindIdleWorker ( const CPlayer player,
const CUnit last 
)

Find the next idle worker.

Find the next idle worker

Parameters:
player Player's units to search through
last Previous idle worker selected
Returns:
NULL or next idle worker

void FindPlayerUnitsByType ( const CPlayer player,
const CUnitType type,
std::vector< CUnit * > &  table 
)

Find all units of this type of the player.

Find all units of type.

Parameters:
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 pos 
)

Find the neareast piece of terrain with specific flags.

template<typename Pred>
CUnit* FindUnit_If ( const Vec2i ltPos,
const Vec2i rbPos,
Pred  pred 
) [inline]

template<typename Pred>
CUnit* FindUnit_IfFixed ( const Vec2i ltPos,
const Vec2i rbPos,
Pred  pred 
) [inline]

void FindUnitsByType ( const CUnitType type,
std::vector< CUnit * > &  units 
)

Find all units of type.

Parameters:
type type of unit requested
units array in which we have to store the units

template<typename Pred1, typename Pred2>
AndPredicate<Pred1, Pred2> MakeAndPredicate ( Pred1  pred1,
Pred2  pred2 
) [inline]

template<typename Pred>
NotPredicate<Pred> MakeNotPredicate ( Pred  pred  )  [inline]

CUnit* ResourceDepositOnMap ( const Vec2i pos,
int  resource 
)

Return resource deposit, if on map tile.

CUnit* ResourceOnMap ( const Vec2i pos,
int  resource,
bool  mine_on_top = true 
)

Return resource, if on map tile.

template<typename Pred>
void Select ( const Vec2i ltPos,
const Vec2i rbPos,
std::vector< CUnit * > &  units,
Pred  pred 
) [inline]

void Select ( const Vec2i ltPos,
const Vec2i rbPos,
std::vector< CUnit * > &  units 
)

template<typename Pred>
void SelectAroundUnit ( const CUnit unit,
int  range,
std::vector< CUnit * > &  around,
Pred  pred 
) [inline]

void SelectAroundUnit ( const CUnit unit,
int  range,
std::vector< CUnit * > &  around 
)

template<typename Pred>
void SelectFixed ( const Vec2i ltPos,
const Vec2i rbPos,
std::vector< CUnit * > &  units,
Pred  pred 
) [inline]

void SelectFixed ( const Vec2i ltPos,
const Vec2i rbPos,
std::vector< CUnit * > &  units 
)

CUnit* TargetOnMap ( const CUnit unit,
const Vec2i pos1,
const Vec2i pos2 
)

Return possible attack target on that map area.

CUnit* UnitFindResource ( const CUnit unit,
const CUnit startUnit,
int  range,
int  resource,
bool  check_usage,
const CUnit deposit 
)

Find resource.

Find Resource.

Parameters:
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.
Note:
This will return an usable resource building that doesn't belong to the player or one of his allies.
Returns:
NULL or resource unit

CUnit* UnitOnMapTile ( const Vec2i pos,
unsigned int  type 
)

Return any unit on that map tile.

(C) Copyright 1998-2012 by The Stratagus Project under the GNU General Public License.
All trademarks and copyrights on this page are owned by their respective owners.