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

Classes
unit.cpp File Reference
#include "stratagus.h"
#include "unit.h"
#include "action/action_attack.h"
#include "actions.h"
#include "ai.h"
#include "animation.h"
#include "commands.h"
#include "construct.h"
#include "game.h"
#include "editor.h"
#include "interface.h"
#include "luacallback.h"
#include "map.h"
#include "missile.h"
#include "network.h"
#include "pathfinder.h"
#include "player.h"
#include "script.h"
#include "settings.h"
#include "sound.h"
#include "sound_server.h"
#include "spells.h"
#include "tileset.h"
#include "translate.h"
#include "ui.h"
#include "unit_find.h"
#include "unit_manager.h"
#include "unitsound.h"
#include "unittype.h"
#include "upgrade.h"
#include "video.h"
#include <math.h>

Classes

class  _UnmarkUnitFieldFlags
 

unit.cpp - The units.

enum  { W_NORTH = 0x10, W_WEST = 0x20, W_SOUTH = 0x40, W_EAST = 0x80 }
 
bool EnableTrainingQueue
 Show unit's name for some time. More...
 
bool EnableBuildingCapture
 Config: training queues enabled. More...
 
bool RevealAttacker
 Config: capture buildings enabled. More...
 
int ResourcesMultiBuildersMultiplier = 0
 Config: reveal attacker enabled. More...
 
static unsigned long HelpMeLastCycle
 Config: spend resources for building with multiple workers. More...
 
static int HelpMeLastX
 Last cycle HelpMe sound played. More...
 
static int HelpMeLastY
 Last X coordinate HelpMe sound played. More...
 
static void RemoveUnitFromContainer (CUnit &unit)
 Last Y coordinate HelpMe sound played. More...
 
int ExtraDeathIndex (const char *death)
 Get the suitable animation frame depends of unit's damaged type. More...
 
CUnitMakeUnit (const CUnitType &type, CPlayer *player)
 Create a new unit. More...
 
static void MapMarkUnitSightRec (const CUnit &unit, const Vec2i &pos, int width, int height, MapMarkerFunc *f, MapMarkerFunc *f2)
 
CUnitGetFirstContainer (const CUnit &unit)
 
void MapMarkUnitSight (CUnit &unit)
 Mark on vision table the Sight of the unit. More...
 
void MapUnmarkUnitSight (CUnit &unit)
 Unmark on vision table the Sight of the unit. More...
 
void MapRefreshUnitsSight (const Vec2i &tilePos, const bool resetSight)
 Mark/Unmark on vision table the Sight for the units around the tilePos. More...
 
void MapRefreshUnitsSight (const bool resetSight)
 Mark/Unmark on vision table the Sight for all units on the map. More...
 
void UpdateUnitSightRange (CUnit &unit)
 Update unit->CurrentSightRange. More...
 
void MarkUnitFieldFlags (const CUnit &unit)
 currently selected units More...
 
void UnmarkUnitFieldFlags (const CUnit &unit)
 Unmark the field with the FieldFlags. More...
 
static void UnitInXY (CUnit &unit, const Vec2i &pos)
 
CUnitMakeUnitAndPlace (const Vec2i &pos, const CUnitType &type, CPlayer *player)
 Create a new unit and place on map. More...
 
void FindNearestDrop (const CUnitType &type, const Vec2i &goalPos, Vec2i &resPos, int heading)
 Find the nearest position at which unit can be placed. More...
 
void UnitLost (CUnit &unit)
 Handle the loss of a unit (food,...) More...
 
void UnitClearOrders (CUnit &unit)
 Remove the Orders of a Unit. More...
 
void UpdateForNewUnit (const CUnit &unit, int upgrade)
 
void NearestOfUnit (const CUnit &unit, const Vec2i &pos, Vec2i *dpos)
 
static void UnitFillSeenValues (CUnit &unit)
 
void CorrectWallDirections (CUnit &unit)
 Correct directions for placed wall. More...
 
void CorrectWallNeighBours (CUnit &unit)
 Correct the surrounding walls. More...
 
void UnitGoesUnderFog (CUnit &unit, const CPlayer &player)
 Call when an Unit goes under fog. More...
 
void UnitGoesOutOfFog (CUnit &unit, const CPlayer &player)
 Call when an Unit goes out of fog. More...
 
void UnitCountSeen (CUnit &unit)
 Does a recount for VisCount. More...
 
static bool IsMineAssignedBy (const CUnit &mine, const CUnit &worker)
 
static void ChangePlayerOwner (CPlayer &oldplayer, CPlayer &newplayer)
 
void RescueUnits ()
 Check for rescue each second. More...
 
static int myatan (int val)
 
int DirectionToHeading (const Vec2i &delta)
 Convert direction (dx,dy) to heading (0-255) More...
 
int DirectionToHeading (const PixelDiff &delta)
 Convert direction (dx,dy) to heading (0-255) More...
 
void UnitUpdateHeading (CUnit &unit)
 Update frame from heading. More...
 
void UnitHeadingFromDeltaXY (CUnit &unit, const Vec2i &delta)
 Heading and frame from delta direction. More...
 
void DropOutOnSide (CUnit &unit, int heading, const CUnit *container)
 
void DropOutNearest (CUnit &unit, const Vec2i &goalPos, const CUnit *container)
 
void DropOutAll (const CUnit &source)
 Drop out all units in the unit. More...
 
CUnitUnitOnScreen (int x, int y)
 Get unit under cursor. More...
 
void LetUnitDie (CUnit &unit, bool suicide)
 Let a unit die. More...
 
void DestroyAllInside (CUnit &source)
 Destroy all units inside another unit. More...
 
int ThreatCalculate (const CUnit &unit, const CUnit &dest)
 Calculate some value to measure the unit's priority for AI. More...
 
int TargetPriorityCalculate (const CUnit *const attacker, const CUnit *const dest)
 
bool InReactRange (const CUnit &unit, const CUnit &target)
 Is target within reaction range of this unit? More...
 
bool InAttackRange (const CUnit &unit, const CUnit &target)
 Is target within attack range of this unit? More...
 
bool InAttackRange (const CUnit &unit, const Vec2i &tilePos)
 Is tile within attack range of this unit? More...
 
Vec2i GetRndPosInDirection (const Vec2i &srcPos, const CUnit &dirUnit, const bool dirFrom, const int minRange, const int devRadius, const int rangeDev)
 Return randomly selected position in direction (to/from) dirUnit from srcPos. More...
 
Vec2i GetRndPosInDirection (const Vec2i &srcPos, const Vec2i &dirPos, const bool dirFrom, const int minRange, const int devRadius, const int rangeDev)
 Return randomly selected position in direction (to/from) dirPos from srcPos. More...
 
static void HitUnit_LastAttack (const CUnit *attacker, CUnit &target)
 
static bool HitUnit_IsUnitWillDie (const CUnit *attacker, const CUnit &target, int damage)
 
static void HitUnit_IncreaseScoreForKill (CUnit &attacker, CUnit &target)
 
static void HitUnit_ApplyDamage (CUnit *attacker, CUnit &target, int damage)
 
static void HitUnit_BuildingCapture (CUnit *attacker, CUnit &target, int damage)
 
static void HitUnit_ShowDamageMissile (const CUnit &target, int damage)
 
static void HitUnit_ShowImpactMissile (const CUnit &target)
 
static void HitUnit_ChangeVariable (CUnit &target, const Missile &missile)
 
static void HitUnit_Burning (CUnit &target)
 
static void HitUnit_RunAway (CUnit &target, const CUnit &attacker)
 
static void HitUnit_AttackBack (CUnit &attacker, CUnit &target)
 
void HitUnit (CUnit *attacker, CUnit &target, int damage, const Missile *missile)
 Hit unit with damage, if destroyed give attacker the points. More...
 
int MapDistanceBetweenTypes (const CUnitType &src, const Vec2i &pos1, const CUnitType &dst, const Vec2i &pos2)
 Returns the map distance between to unittype as locations. More...
 
int ViewPointDistance (const Vec2i &pos)
 Calculate the distance from current view point to coordinate. More...
 
int ViewPointDistanceToUnit (const CUnit &dest)
 Calculate the distance from current view point to unit. More...
 
int CanTarget (const CUnitType &source, const CUnitType &dest)
 Can this unit-type attack the other (destination) More...
 
int CanTransport (const CUnit &transporter, const CUnit &unit)
 Can transporter transport the other unit. More...
 
void InitUnits ()
 Initialize unit module. More...
 
void CleanUnits ()
 Clean unit module. More...
 

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
W_NORTH 
W_WEST 
W_SOUTH 
W_EAST 

Function Documentation

◆ CanTarget()

int CanTarget ( const CUnitType source,
const CUnitType dest 
)

Can this unit-type attack the other (destination)

Can the source unit attack the destination unit?

Parameters
sourceUnit type pointer of the attacker.
destUnit type pointer of the target.
Returns
0 if attacker can't target the unit, else a positive number.

◆ CanTransport()

int CanTransport ( const CUnit transporter,
const CUnit unit 
)

Can transporter transport the other unit.

Can the transporter transport the other unit.

Parameters
transporterUnit which is the transporter.
unitUnit which wants to go in the transporter.
Returns
1 if transporter can transport unit, 0 else.

◆ ChangePlayerOwner()

static void ChangePlayerOwner ( CPlayer oldplayer,
CPlayer newplayer 
)
static

Change the owner of all units of a player.

Parameters
oldplayerOld owning player.
newplayerNew owning player.

◆ CleanUnits()

void CleanUnits ( )

Clean unit module.

Clean up unit module.

◆ CorrectWallDirections()

void CorrectWallDirections ( CUnit unit)

Correct directions for placed wall.

Correct direction for placed wall.

Parameters
unitThe wall unit.

◆ CorrectWallNeighBours()

void CorrectWallNeighBours ( CUnit unit)

Correct the surrounding walls.

Correct the surrounding walls.

Parameters
unitThe wall unit.

◆ DestroyAllInside()

void DestroyAllInside ( CUnit source)

Destroy all units inside another unit.

Destroy all units inside unit.

Parameters
sourcecontainer.

◆ DirectionToHeading() [1/2]

int DirectionToHeading ( const PixelDiff delta)

Convert direction (dx,dy) to heading (0-255)

Convert direction to heading.

Parameters
deltaDelta.
Returns
Angle (0..255)

◆ DirectionToHeading() [2/2]

int DirectionToHeading ( const Vec2i delta)

Convert direction (dx,dy) to heading (0-255)

Convert direction to heading.

Parameters
deltaDelta.
Returns
Angle (0..255)

◆ DropOutAll()

void DropOutAll ( const CUnit source)

Drop out all units in the unit.

Drop out all units inside unit.

Parameters
sourceAll units inside source are dropped out.

◆ DropOutNearest()

void DropOutNearest ( CUnit unit,
const Vec2i goalPos,
const CUnit container 
)

Place a unit on the map nearest to goalPos.

Parameters
unitUnit to drop out.
goalPosGoal map tile position.
addxTile width of unit it's dropping out of.
addyTile height of unit it's dropping out of.

◆ DropOutOnSide()

void DropOutOnSide ( CUnit unit,
int  heading,
const CUnit container 
)

Place a unit on the map to the side of a unit.

Parameters
unitUnit to drop out.
headingDirection in which the unit should appear.
containerUnit "containing" unit to drop (may be different of unit.Container).

◆ ExtraDeathIndex()

int ExtraDeathIndex ( const char *  death)

Get the suitable animation frame depends of unit's damaged type.

Find the index of a extra death type

◆ FindNearestDrop()

void FindNearestDrop ( const CUnitType type,
const Vec2i goalPos,
Vec2i resPos,
int  heading 
)

Find the nearest position at which unit can be placed.

Find the nearest position at which unit can be placed.

Parameters
typeType of the dropped unit.
goalPosGoal map tile position.
resPosHolds the nearest point.
headingpreferense side to drop out of.

◆ GetFirstContainer()

CUnit* GetFirstContainer ( const CUnit unit)

Return the unit not transported, by viewing the container recursively.

Parameters
unitunit from where look the first conatiner.
Returns
Container of container of ... of unit. It is not null.

◆ GetRndPosInDirection() [1/2]

Vec2i GetRndPosInDirection ( const Vec2i srcPos,
const CUnit dirUnit,
const bool  dirFrom,
const int  minRange,
const int  devRadius,
const int  rangeDev 
)

Return randomly selected position in direction (to/from) dirUnit from srcPos.

Returns end position of randomly generated vector form srcPos in direction to/from dirUnit

Parameters
srcPosVector origin
dirUnitPosition to determine vector direction
dirFromDirection of src-dir. True if "from" dirPos, false if "to" dirPos
minRangeMinimal range to new position
devRadiusDiviation radius
rangeDevRange deviation
Returns
Position

◆ GetRndPosInDirection() [2/2]

Vec2i GetRndPosInDirection ( const Vec2i srcPos,
const Vec2i dirPos,
const bool  dirFrom,
const int  minRange,
const int  devRadius,
const int  rangeDev 
)

Return randomly selected position in direction (to/from) dirPos from srcPos.

Returns end position of randomly generated vector form srcPos in direction to/from dirPos

Parameters
srcPosVector origin
dirPosPosition to determine vector direction
dirFromDirection of src-dir. True if "from" dirPos, false if "to" dirPos
minRangeMinimal range to new position
devRadiusDiviation radius
rangeDevRange deviation
Returns
Position

◆ HitUnit()

void HitUnit ( CUnit attacker,
CUnit target,
int  damage,
const Missile missile 
)

Hit unit with damage, if destroyed give attacker the points.

Unit is hit by missile or other damage.

Parameters
attackerUnit that attacks.
targetUnit that is hit.
damageHow many damage to take.
missileWhich missile took the damage.

◆ HitUnit_ApplyDamage()

static void HitUnit_ApplyDamage ( CUnit attacker,
CUnit target,
int  damage 
)
static

◆ HitUnit_AttackBack()

static void HitUnit_AttackBack ( CUnit attacker,
CUnit target 
)
static

allow target to ignore non aggressive targets while searching attacker

Wait for timer expires for preventing frequent switching of attack-move positions

allow target to ignore non aggressive targets while searching attacker

◆ HitUnit_BuildingCapture()

static void HitUnit_BuildingCapture ( CUnit attacker,
CUnit target,
int  damage 
)
static

◆ HitUnit_Burning()

static void HitUnit_Burning ( CUnit target)
static

◆ HitUnit_ChangeVariable()

static void HitUnit_ChangeVariable ( CUnit target,
const Missile missile 
)
static

◆ HitUnit_IncreaseScoreForKill()

static void HitUnit_IncreaseScoreForKill ( CUnit attacker,
CUnit target 
)
static

◆ HitUnit_IsUnitWillDie()

static bool HitUnit_IsUnitWillDie ( const CUnit attacker,
const CUnit target,
int  damage 
)
static

◆ HitUnit_LastAttack()

static void HitUnit_LastAttack ( const CUnit attacker,
CUnit target 
)
static

◆ HitUnit_RunAway()

static void HitUnit_RunAway ( CUnit target,
const CUnit attacker 
)
static

Attack-move to pos

Run away to pos

◆ HitUnit_ShowDamageMissile()

static void HitUnit_ShowDamageMissile ( const CUnit target,
int  damage 
)
static

◆ HitUnit_ShowImpactMissile()

static void HitUnit_ShowImpactMissile ( const CUnit target)
static

◆ InAttackRange() [1/2]

bool InAttackRange ( const CUnit unit,
const CUnit target 
)

Is target within attack range of this unit?

Returns true, if target is in attack range of the unit and there are no obstacles between them (when inside caves)

Parameters
unitUnit to check for.
targetChecked target.
Returns
True if in attack range, false otherwise.

◆ InAttackRange() [2/2]

bool InAttackRange ( const CUnit unit,
const Vec2i tilePos 
)

Is tile within attack range of this unit?

Returns true, if tile is in attack range of the unit and there are no obstacles between them (when inside caves)

Parameters
unitUnit to check for.
posChecked position.
Returns
True if in attack range, false otherwise.

◆ InitUnits()

void InitUnits ( )

Initialize unit module.

Initialize unit module.

◆ InReactRange()

bool InReactRange ( const CUnit unit,
const CUnit target 
)

Is target within reaction range of this unit?

Returns true, if target is in reaction range of the unit

Todo:
: Do we have to check range from unit.Container pos if unit is bunkered or in transport?
Parameters
unitUnit to check for.
targetChecked target.
Returns
True if within react range, false otherwise.

◆ IsMineAssignedBy()

static bool IsMineAssignedBy ( const CUnit mine,
const CUnit worker 
)
static

◆ LetUnitDie()

void LetUnitDie ( CUnit unit,
bool  suicide 
)

Let a unit die.

Let an unit die.

Parameters
unitUnit to be destroyed.

◆ MakeUnit()

CUnit* MakeUnit ( const CUnitType type,
CPlayer player 
)

Create a new unit.

Create a new unit.

Parameters
typePointer to unit-type.
playerPointer to owning player.
Returns
Pointer to created unit.

◆ MakeUnitAndPlace()

CUnit* MakeUnitAndPlace ( const Vec2i pos,
const CUnitType type,
CPlayer player 
)

Create a new unit and place on map.

Create new unit and place on map.

Parameters
posmap tile position.
typePointer to unit-type.
playerPointer to owning player.
Returns
Pointer to created unit.

◆ MapDistanceBetweenTypes()

int MapDistanceBetweenTypes ( const CUnitType src,
const Vec2i pos1,
const CUnitType dst,
const Vec2i pos2 
)

Returns the map distance between to unittype as locations.

Returns the map distance between two points with unit type.

Parameters
srcsrc unittype
pos1map tile position of src (upperleft).
dstUnit type to take into account.
pos2map tile position of dst.
Returns
The distance between the types.

◆ MapMarkUnitSight()

void MapMarkUnitSight ( CUnit unit)

Mark on vision table the Sight of the unit.

Mark on vision table the Sight of the unit (and units inside for transporter)

Parameters
unitunit to unmark its vision.
See also
MapUnmarkUnitSight.

◆ MapMarkUnitSightRec()

static void MapMarkUnitSightRec ( const CUnit unit,
const Vec2i pos,
int  width,
int  height,
MapMarkerFunc f,
MapMarkerFunc f2 
)
static

(Un)Mark on vision table the Sight of the unit (and units inside for transporter (recursively))

Parameters
unitUnit to (un)mark.
poscoord of first container of unit.
widthWidth of the first container of unit.
heightHeight of the first container of unit.
fFunction to (un)mark for normal vision.
f2Function to (un)mark for cloaking vision.

◆ MapRefreshUnitsSight() [1/2]

void MapRefreshUnitsSight ( const bool  resetSight)

Mark/Unmark on vision table the Sight for all units on the map.

Mark/Unmark on vision table the Sight for all units on the map

Parameters
resetSightUnmark sight if True, Mark otherwise
See also
MapUnmarkUnitSight/MapMarkUnitSight

◆ MapRefreshUnitsSight() [2/2]

void MapRefreshUnitsSight ( const Vec2i tilePos,
const bool  resetSight 
)

Mark/Unmark on vision table the Sight for the units around the tilePos.

Mark/Unmark on vision table the Sight for the units around the tilePos (and units inside for transporter)

Parameters
tilePosPosition of the tile around which to update units vision for
resetSightUnmark sight if True, Mark otherwise
See also
MapUnmarkUnitSight/MapMarkUnitSight

◆ MapUnmarkUnitSight()

void MapUnmarkUnitSight ( CUnit unit)

Unmark on vision table the Sight of the unit.

Unmark on vision table the Sight of the unit (and units inside for transporter)

Parameters
unitunit to unmark its vision.
See also
MapMarkUnitSight.

◆ MarkUnitFieldFlags()

void MarkUnitFieldFlags ( const CUnit unit)

currently selected units

Mark the field with the FieldFlags.

Parameters
unitunit to mark.

◆ myatan()

static int myatan ( int  val)
static

Fast arc tangent function.

Parameters
valatan argument
Returns
atan(val)

◆ NearestOfUnit()

void NearestOfUnit ( const CUnit unit,
const Vec2i pos,
Vec2i dpos 
)

Find nearest point of unit.

Parameters
unitPointer to unit.
postile map position.
dposOut: nearest point tile map position to (tx,ty).

◆ RemoveUnitFromContainer()

static void RemoveUnitFromContainer ( CUnit unit)
static

Last Y coordinate HelpMe sound played.

Remove unit from a container. It only updates linked list stuff.

Parameters
unitPointer to unit.

◆ RescueUnits()

void RescueUnits ( )

Check for rescue each second.

Rescue units.

Look through all rescueable players, if they could be rescued.

◆ TargetPriorityCalculate()

int TargetPriorityCalculate ( const CUnit *const  attacker,
const CUnit *const  dest 
)

Check if target attacks us (or has us as goal for any action)

Unit can attack back.

◆ ThreatCalculate()

int ThreatCalculate ( const CUnit unit,
const CUnit dest 
)

Calculate some value to measure the unit's priority for AI.

◆ UnitClearOrders()

void UnitClearOrders ( CUnit unit)

Remove the Orders of a Unit.

Removes all orders from a unit.

Parameters
unitThe unit that will have all its orders cleared

◆ UnitCountSeen()

void UnitCountSeen ( CUnit unit)

Does a recount for VisCount.

Recalculates a units visiblity count. This happens really often, Like every time a unit moves. It's really fast though, since we have per-tile counts.

Parameters
unitpointer to the unit to check if seen

◆ UnitFillSeenValues()

static void UnitFillSeenValues ( CUnit unit)
static

Copy the unit look in Seen variables. This should be called when buildings go under fog of war for ThisPlayer.

Parameters
unitThe unit to work on

◆ UnitGoesOutOfFog()

void UnitGoesOutOfFog ( CUnit unit,
const CPlayer player 
)

Call when an Unit goes out of fog.

This function should get called when a unit goes out of fog of war.

Parameters
unitThe unit that goes out of fog.
playerThe player the unit goes out of fog for.
Note
For units that are visible under fog (mostly buildings) we use reference counts, from the players that know about the building. When an building goes under fog it gets a refs increase, and when it shows up it gets a decrease. It must not get an decrease the first time it's seen, so we have to keep track of what player saw what units, with SeenByPlayer.

◆ UnitGoesUnderFog()

void UnitGoesUnderFog ( CUnit unit,
const CPlayer player 
)

Call when an Unit goes under fog.

This function should get called when a unit goes under fog of war.

Parameters
unitThe unit that goes under fog.
playerThe player the unit goes out of fog for.

◆ UnitHeadingFromDeltaXY()

void UnitHeadingFromDeltaXY ( CUnit unit,
const Vec2i delta 
)

Heading and frame from delta direction.

Change unit heading/frame from delta direction x, y.

Parameters
unitUnit for new direction looking.
deltamap tile delta direction.

◆ UnitInXY()

static void UnitInXY ( CUnit unit,
const Vec2i pos 
)
static

Affect Tile coord of a unit (with units inside) to tile (x, y).

Parameters
unitunit to move.
posmap tile position.

◆ UnitLost()

void UnitLost ( CUnit unit)

Handle the loss of a unit (food,...)

Update information for lost units.

Parameters
unitPointer to unit.
Note
Also called by ChangeUnitOwner

◆ UnitOnScreen()

CUnit* UnitOnScreen ( int  x,
int  y 
)

Get unit under cursor.

Unit on map screen.

Select units on screen. (x, y are in pixels relative to map 0,0). Not GAMEPLAY safe, uses ReplayRevealMap

More units on same position. Cycle through units. First take highest unit.

Parameters
xX pixel position.
yY pixel position.
Returns
An unit on x, y position.

◆ UnitUpdateHeading()

void UnitUpdateHeading ( CUnit unit)

Update frame from heading.

Update sprite frame for new heading.

◆ UnmarkUnitFieldFlags()

void UnmarkUnitFieldFlags ( const CUnit unit)

Unmark the field with the FieldFlags.

Mark the field with the FieldFlags.

Parameters
unitunit to mark.

◆ UpdateForNewUnit()

void UpdateForNewUnit ( const CUnit unit,
int  upgrade 
)

Update for new unit. Food and income ...

Parameters
unitNew unit pointer.
upgradeTrue unit was upgraded.

◆ UpdateUnitSightRange()

void UpdateUnitSightRange ( CUnit unit)

Update unit->CurrentSightRange.

Update the Unit Current sight range to good value and transported units inside.

Parameters
unitunit to update SightRange

◆ ViewPointDistance()

int ViewPointDistance ( const Vec2i pos)

Calculate the distance from current view point to coordinate.

Compute the distance from the view point to a given point.

Parameters
posmap tile position.
Todo:
FIXME: is it the correct place to put this function in?

◆ ViewPointDistanceToUnit()

int ViewPointDistanceToUnit ( const CUnit dest)

Calculate the distance from current view point to unit.

Compute the distance from the view point to a given unit.

Parameters
destDistance to this unit.
Todo:
FIXME: is it the correct place to put this function in?

Variable Documentation

◆ EnableBuildingCapture

bool EnableBuildingCapture

Config: training queues enabled.

◆ EnableTrainingQueue

bool EnableTrainingQueue

Show unit's name for some time.

◆ HelpMeLastCycle

unsigned long HelpMeLastCycle
static

Config: spend resources for building with multiple workers.

◆ HelpMeLastX

int HelpMeLastX
static

Last cycle HelpMe sound played.

◆ HelpMeLastY

int HelpMeLastY
static

Last X coordinate HelpMe sound played.

◆ ResourcesMultiBuildersMultiplier

int ResourcesMultiBuildersMultiplier = 0

Config: reveal attacker enabled.

◆ RevealAttacker

bool RevealAttacker

Config: capture buildings enabled.

Config: building capture enabled.

(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.