____ _ __
/ __ )____ _____ | | / /___ ___________
/ __ / __ \/ ___/ | | /| / / __ `/ ___/ ___/
/ /_/ / /_/ (__ ) | |/ |/ / /_/ / / (__ )
/_____/\____/____/ |__/|__/\__,_/_/ /____/
A futuristic real-time strategy game.
This file is part of Bos Wars.
(C) Copyright 2001-2007 by the Bos Wars and Stratagus Project.
Distributed under the "GNU General Public License"
#include <vector>
#include "SDL.h"
#include "upgrade_structs.h"
Go to the source code of this file.
Classes | |
| class | COrder |
| class | CUnit |
| struct | CUnit::_unit_seen_ |
| struct | CUnit::_unit_anim_ |
| union | CUnit::_order_data_ |
| struct | CUnit::_order_data_::_order_move_ |
| struct | CUnit::_order_data_::_order_built_ |
| struct | CUnit::_order_data_::_order_harvest_ |
| struct | CUnit::_order_data_::_order_train_ |
| struct | CUnit::_order_data_::_order_repair_ |
| class | CPreference |
Defines | |
| #define | NextDirection 32 |
| Next direction N->NE->E... | |
| #define | UnitNotSeen 0x7fffffff |
| Unit not seen, used by CUnit::SeenFrame. | |
| #define | MAX_PATH_LENGTH 28 |
| max length of precalculated path | |
| #define | NoUnitP (CUnit *)0 |
| return value: for no unit found | |
| #define | InfiniteDistance INT_MAX |
| the distance is unreachable | |
| #define | FlushCommands 1 |
| Flush commands in queue. | |
| #define | MAX_UNIT_SLOTS 65535 |
| Maximal number of used slots. | |
| #define | UnitNumber(unit) ((unit)->Slot) |
| #define | NUM_GROUPS 10 |
| #define | IsOnlySelected(unit) (NumSelected == 1 && Selected[0] == (unit)) |
| < Check if unit is the currently only selected | |
Typedefs | |
| typedef unsigned short | UnitRef |
| typedef enum _unit_action_ | UnitAction |
Enumerations | |
| enum | _unit_action_ { UnitActionNone, UnitActionStill, UnitActionStandGround, UnitActionFollow, UnitActionMove, UnitActionAttack, UnitActionAttackGround, UnitActionDie, UnitActionSpellCast, UnitActionTrain, UnitActionBuilt, UnitActionBoard, UnitActionUnload, UnitActionPatrol, UnitActionBuild, UnitActionRepair, UnitActionResource } |
| enum | UnitVoiceGroup { VoiceSelected, VoiceAcknowledging, VoiceReady, VoiceHelpMe, VoiceDying, VoiceWorkCompleted, VoiceBuilding, VoiceDocking, VoiceRepairing, VoiceHarvesting } |
| enum | _directions_ { LookingN = 0 * 32, LookingNE = 1 * 32, LookingE = 2 * 32, LookingSE = 3 * 32, LookingS = 4 * 32, LookingSW = 5 * 32, LookingW = 6 * 32, LookingNW = 7 * 32 } |
Functions | |
| void | SelectedUnitChanged (void) |
| Called whenever the selected unit was updated. | |
| void | DrawUnitSelection (const CUnit *) |
| void | DrawSelection (Uint32 color, int x1, int y1, int x2, int y2) |
| void | MarkUnitFieldFlags (const CUnit *unit) |
| < Mark the field with the FieldFlags. | |
| void | UnmarkUnitFieldFlags (const CUnit *unit) |
| Update unit->CurrentSightRange. | |
| void | UpdateUnitSightRange (CUnit *unit) |
| Create a new unit. | |
| CUnit * | MakeUnit (CUnitType *type, CPlayer *player) |
| Create a new unit and place on map. | |
| CUnit * | MakeUnitAndPlace (int x, int y, CUnitType *type, CPlayer *player) |
| Handle the loss of a unit (food,...). | |
| void | UnitLost (CUnit *unit) |
| Remove the Orders of a Unit. | |
| void | UnitClearOrders (CUnit *unit) |
| void | UpdateForNewUnit (const CUnit *unit, int upgrade) |
| void | NearestOfUnit (const CUnit *unit, int tx, int ty, int *dx, int *dy) |
| Call when an Unit goes under fog. | |
| void | UnitGoesUnderFog (CUnit *unit, const CPlayer *player) |
| Call when an Unit goes out of fog. | |
| void | UnitGoesOutOfFog (CUnit *unit, const CPlayer *player) |
| Marks a unit as seen. | |
| void | UnitsOnTileMarkSeen (const CPlayer *player, int x, int y) |
| Unmarks a unit as seen. | |
| void | UnitsOnTileUnmarkSeen (const CPlayer *player, int x, int y) |
| Does a recount for VisCount. | |
| void | UnitCountSeen (CUnit *unit) |
| Check for rescue each second. | |
| void | RescueUnits (void) |
| Convert direction (dx,dy) to heading (0-255). | |
| int | DirectionToHeading (int, int) |
| Update frame from heading. | |
| void | UnitUpdateHeading (CUnit *unit) |
| Heading and frame from delta direction x,y. | |
| void | UnitHeadingFromDeltaXY (CUnit *unit, int x, int y) |
| void | DropOutOnSide (CUnit *unit, int heading, int addx, int addy) |
| void | DropOutNearest (CUnit *unit, int x, int y, int addx, int addy) |
| Drop out all units in the unit. | |
| void | DropOutAll (const CUnit *unit) |
| Return the rule used to build this building. | |
| CBuildRestrictionOnTop * | OnTopDetails (const CUnit *unit, const CUnitType *parent) |
| CUnit * | CanBuildHere (const CUnit *unit, const CUnitType *type, int x, int y) |
| bool | CanBuildOn (int x, int y, int mask) |
| FIXME: more docu. | |
| CUnit * | CanBuildUnitType (const CUnit *unit, const CUnitType *type, int x, int y, int real) |
| Holds resources. | |
| bool | UnitHoldsResources (const CUnit *unit) |
| Find resource. | |
| CUnit * | UnitFindResource (const CUnit *unit, int x, int y, int range, int resource=-1) |
| Find the next idle worker. | |
| CUnit * | FindIdleWorker (const CPlayer *player) |
| CUnit * | UnitOnScreen (int x, int y) |
| Check if a unit should be removed from UnitsConsumingResources. | |
| void | UnitRemoveConsumingResources (CUnit *unit) |
| Let a unit die. | |
| void | LetUnitDie (CUnit *unit) |
| Destory all units inside another unit. | |
| void | DestroyAllInside (CUnit *source) |
| Hit unit with damage, if destroyed give attacker the points. | |
| void | HitUnit (CUnit *attacker, CUnit *target, int damage) |
| Returns the map distance between two points. | |
| int | MapDistance (int x1, int y1, int x2, int y2) |
| Returns the map distance between two points with unit-type. | |
| int | MapDistanceToType (int x1, int y1, const CUnitType *type, int x2, int y2) |
| Returns the map distance to unit. | |
| int | MapDistanceToUnit (int x, int y, const CUnit *dest) |
| Returns the map diestance between to unittype as locations. | |
| int | MapDistanceBetweenTypes (const CUnitType *src, int x1, int y1, const CUnitType *dst, int x2, int y2) |
| Returns the map distance between two units. | |
| int | MapDistanceBetweenUnits (const CUnit *src, const CUnit *dst) |
| Calculate the distance from current view point to coordinate. | |
| int | ViewPointDistance (int x, int y) |
| Calculate the distance from current view point to unit. | |
| int | ViewPointDistanceToUnit (const CUnit *dest) |
| Can this unit-type attack the other (destination). | |
| int | CanTarget (const CUnitType *type, const CUnitType *dest) |
| Can transporter transport the other unit. | |
| int | CanTransport (const CUnit *transporter, const CUnit *unit) |
| Check if unit can move. | |
| bool | CanMove (const CUnit *unit) |
| Generate a unit reference, a printable unique string for unit. | |
| std::string | UnitReference (const CUnit *unit) |
| Save an order. | |
| void | SaveOrder (const COrder *order, CFile *file) |
| save unit-structure | |
| void | SaveUnit (const CUnit *unit, CFile *file) |
| save all units | |
| void | SaveUnits (CFile *file) |
| Initialize unit module. | |
| void | InitUnits (void) |
| Clean unit module. | |
| void | CleanUnits (void) |
| void | DecorationCclRegister (void) |
| < Register CCL decorations features | |
| void | LoadDecorations (void) |
| Clean the decorations (health,mana) of units. | |
| void | CleanDecorations (void) |
| Draw unit's shadow. | |
| void | DrawShadow (const CUnit *unit, const CUnitType *type, int frame, int x, int y) |
| Draw all units visible on map in viewport. | |
| int | FindAndSortUnits (const CViewport *vp, CUnit **table, int tablesize) |
| Show a unit's orders. | |
| void | ShowOrder (const CUnit *unit) |
| int | FindUnitsByType (const CUnitType *type, CUnit **table, int tablesize) |
| < Find all units of this type | |
| int | FindPlayerUnitsByType (const CPlayer *, const CUnitType *, CUnit **, int) |
| Return any unit on that map tile. | |
| CUnit * | UnitOnMapTile (int tx, int ty, unsigned type=(unsigned)-1) |
| Return possible attack target on that map area. | |
| CUnit * | TargetOnMap (const CUnit *unit, int x1, int y1, int x2, int y2) |
| Return resource, if on map tile. | |
| CUnit * | ResourceOnMap (int tx, int ty, int resource=-1) |
| Find best enemy in numeric range to attack. | |
| CUnit * | AttackUnitsInDistance (const CUnit *unit, int range) |
| Find best enemy in attack range to attack. | |
| CUnit * | AttackUnitsInRange (const CUnit *unit) |
| Find best enemy in reaction range to attack. | |
| CUnit * | AttackUnitsInReactRange (const CUnit *unit) |
| void | InitGroups (void) |
| < Initialize data structures for groups | |
| void | SaveGroups (CFile *file) |
| Cleanup groups. | |
| void | CleanGroups (void) |
| int | GetNumberUnitsOfGroup (int num) |
| < Get the number of units in a particular group | |
| CUnit ** | GetUnitsOfGroup (int num) |
| Remove all units from a group. | |
| void | ClearGroup (int num) |
| Add the array of units to the group. | |
| void | AddToGroup (CUnit **units, int nunits, int num) |
| Set the contents of a particular group with an array of units. | |
| void | SetGroup (CUnit **units, int nunits, int num) |
| Remove a unit from a group. | |
| void | RemoveUnitFromGroups (CUnit *unit) |
| Register CCL group features. | |
| void | GroupCclRegister (void) |
| void | SaveSelection (void) |
| Restore selection. | |
| void | RestoreSelection (void) |
| Clear current selection. | |
| void | UnSelectAll (void) |
| Select group as selection. | |
| void | ChangeSelectedUnits (CUnit **units, int num_units) |
| Changed TeamUnit Selection. | |
| void | ChangeTeamSelectedUnits (CPlayer *player, CUnit **units, int adjust, int count) |
| Add a unit to selection. | |
| int | SelectUnit (CUnit *unit) |
| Select one unit as selection. | |
| void | SelectSingleUnit (CUnit *unit) |
| Remove a unit from selection. | |
| void | UnSelectUnit (CUnit *unit) |
| Add a unit to selected if not already selected, remove it otherwise. | |
| int | ToggleSelectUnit (CUnit *unit) |
| Select units from the same type (if selectable by rectangle). | |
| int | SelectUnitsByType (CUnit *base) |
| Toggle units from the same type (if selectable by rectangle). | |
| int | ToggleUnitsByType (CUnit *base) |
| Select the units belonging to a particular group. | |
| int | SelectGroup (int group_number) |
| Add the units from the same group as the one in parameter. | |
| int | AddGroupFromUnitToSelection (CUnit *unit) |
| Select the units from the same group as the one in parameter. | |
| int | SelectGroupFromUnit (CUnit *unit) |
| Select the units in the selection rectangle. | |
| int | SelectUnitsInRectangle (int tx, int ty, int w, int h) |
| Select ground units in the selection rectangle. | |
| int | SelectGroundUnitsInRectangle (int tx, int ty, int w, int h) |
| Select flying units in the selection rectangle. | |
| int | SelectAirUnitsInRectangle (int tx, int ty, int w, int h) |
| Add the units in the selection rectangle to the current selection. | |
| int | AddSelectedUnitsInRectangle (int tx, int ty, int w, int h) |
| Add ground units in the selection rectangle to the current selection. | |
| int | AddSelectedGroundUnitsInRectangle (int tx, int ty, int w, int h) |
| Add flying units in the selection rectangle to the current selection. | |
| int | AddSelectedAirUnitsInRectangle (int tx, int ty, int w, int h) |
| Init selections. | |
| void | InitSelections (void) |
| Save current selection state. | |
| void | SaveSelections (CFile *file) |
| Clean up selections. | |
| void | CleanSelections (void) |
| Register CCL selection features. | |
| void | SelectionCclRegister (void) |
| void | CclParseOrder (lua_State *l, COrder *order) |
| < Parse order | |
| void | UnitCclRegister (void) |
Variables | |
| CPreference | Preference |
| CUnit * | Units [MAX_UNIT_SLOTS] |
| Units used. | |
| int | NumUnits |
| Number of units used. | |
| unsigned long | ShowOrdersCount |
| Show orders for some time. | |
| bool | EnableBuildingCapture |
| Config: building capture enabled. | |
| const CViewport * | CurrentViewport |
| CurrentViewport. | |
| int | MaxSelectable |
| How many units could be selected. | |
| CUnit ** | Selected |
| currently selected units | |
| CUnit ** | TeamSelected [PlayerMax] |
| teams currently selected units | |
| int | NumSelected |
| how many units selected | |
| int | TeamNumSelected [PlayerMax] |
| Number of Units a team member has selected. | |
Definition in file unit.h.
| #define FlushCommands 1 |
Flush commands in queue.
Definition at line 743 of file unit.h.
Referenced by AiAssignHarvester(), AiAttackWithForce(), AiAttackWithForceAt(), AiBuildBuilding(), AiForceAttacks(), AiMoveUnitInTheWay(), AiRepairBuilding(), AiSendExplorers(), AiTrainUnit(), AutoAttack(), AutoCastSpell(), AutoRepair(), CommandStopUnit(), CreateGame(), HandleActionFollow(), HandleActionPatrol(), HitUnit(), InputKey(), ParseCommand(), ParseNetworkCommand(), SendCommandAutoRepair(), SendCommandAutoSpellCast(), SendCommandCancelTraining(), SendCommandDismiss(), and SendCommandStopUnit().
| #define IsOnlySelected | ( | unit | ) | (NumSelected == 1 && Selected[0] == (unit)) |
< Check if unit is the currently only selected
Save selection to restore after.
Definition at line 974 of file unit.h.
Referenced by EnterTransporter(), FindIdleWorker(), HandleActionBuilt(), HandleActionTrain(), HandleUnitAction(), and LeaveTransporter().
| #define MAX_PATH_LENGTH 28 |
| #define MAX_UNIT_SLOTS 65535 |
Maximal number of used slots.
Definition at line 745 of file unit.h.
Referenced by CUnitManager::Init().
| #define NextDirection 32 |
| #define NoUnitP (CUnit *)0 |
return value: for no unit found
Definition at line 740 of file unit.h.
Referenced by CUnit::AddInContainer(), AiForceAttacks(), AiRepairBuilding(), CUnitManager::AllocUnit(), AttackTarget(), AttackUnitsInDistance(), AutoAttack(), AutoRepair(), Summon::Cast(), CclCreateUnit(), ChangeTeamSelectedUnits(), CheckForDeadGoal(), CheckForTargetInRange(), CleanCursors(), CreateGame(), CButtonPanel::DoClicked(), DoNextReplay(), DoRightButton(), DrawBuildingCursor(), DrawMapArea(), EditorActionPlaceUnit(), EnemyOnMapTile(), EnterTransporter(), FindIdleWorker(), FindNewResource(), FindRangeAttack(), GatherResource(), HandleActionAttack(), HandleActionBoard(), HandleActionBuilt(), HandleActionFollow(), HandleActionMove(), HandleActionPatrol(), HandleActionSpellCast(), HandleActionTrain(), HandleRegenerations(), HitUnit(), InputKey(), LeaveTransporter(), MakeUnit(), MakeUnitAndPlace(), MissileHit(), MoveToLocation(), MoveToTarget(), ParseCommand(), ParseExtendedCommand(), ParseNetworkCommand(), ReleaseOrder(), RemoveUnitFromContainer(), RepairUnit(), ResourceOnMap(), RestoreSavedOrder(), SendCommandAttackGround(), SendCommandAutoRepair(), SendCommandAutoSpellCast(), SendCommandBuildBuilding(), SendCommandCancelTraining(), SendCommandDiplomacy(), SendCommandMove(), SendCommandPatrol(), SendCommandSharedVision(), SendCommandStandGround(), SendCommandStopUnit(), SendCommandTrainUnit(), SendUnload(), SpellMoveToTarget(), StartBuilding(), StartGathering(), TargetOnMap(), UiFindIdleWorker(), UnitClearOrders(), UnitFindResource(), UnitLost(), UnitOnMapTile(), UnitToRepairInRange(), UnSelectAll(), UnSelectUnit(), and WaitForTransporter().
| #define NUM_GROUPS 10 |
How many groups supported
Definition at line 755 of file unit.h.
Referenced by AddToGroup(), CleanGroups(), InitGroups(), SaveGroups(), SelectGroup(), and SetGroup().
| #define UnitNotSeen 0x7fffffff |
Unit not seen, used by CUnit::SeenFrame.
The big unit structure
Definition at line 486 of file unit.h.
Referenced by CclUnit(), CUnit::Draw(), CUnit::Init(), and SaveUnit().
| #define UnitNumber | ( | unit | ) | ((unit)->Slot) |
Returns unit number (unique to this unit)
Definition at line 750 of file unit.h.
Referenced by AiCanNotBuild(), AiCheckRepair(), AiHelpMe(), AiPlanAttack(), AiRepairBuilding(), AiTrainingComplete(), AiUnitKilled(), AiWorkComplete(), AttackTarget(), CommandLog(), CommandSpellCast(), HandleActionNone(), HandleActionPatrol(), NetworkSendSelection(), ParseCommand(), SaveAiPlayer(), SaveUnit(), SaveViewports(), ShowUnitInfo(), UnitActions(), UnitLost(), and UnitReference().
| typedef enum _unit_action_ UnitAction |
All possible unit actions.
| typedef unsigned short UnitRef |
| enum _directions_ |
Unit/Missile headings. N NW NE W E SW SE S
| enum _unit_action_ |
All possible unit actions.
| enum UnitVoiceGroup |
Voice groups for a unit
| int AddGroupFromUnitToSelection | ( | CUnit * | unit | ) |
Select the units from the same group as the one in parameter.
Add units from group of a particular unit to selection.
| unit | unit belonging to the group to be selected. |
Definition at line 531 of file selection.cpp.
References CUnit::LastGroup, MaxSelectable, NumSelected, NumUnits, SelectUnit(), and Units.
Referenced by DoSelectionButtons(), SelectGroupFromUnit(), and UIHandleButtonUp().
| int AddSelectedAirUnitsInRectangle | ( | int | sx0, | |
| int | sy0, | |||
| int | sx1, | |||
| int | sy1 | |||
| ) |
Init selections.
Add the air units in the rectangle to the current selection
| sx0 | X start of selection rectangle in tile coordinates | |
| sy0 | Y start of selection rectangle in tile coordinates | |
| sx1 | X start of selection rectangle in tile coordinates | |
| sy1 | Y start of selection rectangle in tile coordinates |
Definition at line 1007 of file selection.cpp.
References CanSelectMultipleUnits, CUnit::IsUnusable(), MaxSelectable, NumSelected, CUnit::Player, CUnitCache::Select(), CUnitType::SelectableByRectangle, SelectAirUnitsInRectangle(), SelectSpritesInsideRectangle(), SelectUnit(), CUnit::TeamSelected, TileSizeX, TileSizeY, CUnit::Type, UnitCache, UnitMax, CUnitType::UnitType, and UnitTypeFly.
Referenced by UIHandleButtonUp().
| int AddSelectedGroundUnitsInRectangle | ( | int | sx0, | |
| int | sy0, | |||
| int | sx1, | |||
| int | sy1 | |||
| ) |
Add flying units in the selection rectangle to the current selection.
Add the ground units in the rectangle to the current selection
| sx0 | X start of selection rectangle in tile coordinates | |
| sy0 | Y start of selection rectangle in tile coordinates | |
| sx1 | X start of selection rectangle in tile coordinates | |
| sy1 | Y start of selection rectangle in tile coordinates |
Definition at line 933 of file selection.cpp.
References CanSelectMultipleUnits, CUnit::IsUnusable(), MaxSelectable, NumSelected, CUnit::Player, CUnitCache::Select(), CUnitType::SelectableByRectangle, SelectGroundUnitsInRectangle(), SelectSpritesInsideRectangle(), SelectUnit(), CUnit::TeamSelected, TileSizeX, TileSizeY, CUnit::Type, UnitCache, UnitMax, CUnitType::UnitType, and UnitTypeFly.
Referenced by UIHandleButtonUp().
| int AddSelectedUnitsInRectangle | ( | int | x0, | |
| int | y0, | |||
| int | x1, | |||
| int | y1 | |||
| ) |
Add ground units in the selection rectangle to the current selection.
Add the units in the rectangle to the current selection
| x0 | X start of selection rectangle in tile coordinates | |
| y0 | Y start of selection rectangle in tile coordinates | |
| x1 | X start of selection rectangle in tile coordinates | |
| y1 | Y start of selection rectangle in tile coordinates |
Definition at line 668 of file selection.cpp.
References CanSelectMultipleUnits, MaxSelectable, NumSelected, CUnitCache::Select(), SelectOrganicUnitsInTable(), SelectSpritesInsideRectangle(), SelectUnit(), SelectUnitsInRectangle(), TileSizeX, TileSizeY, UnitCache, and UnitMax.
Referenced by UIHandleButtonUp().
| void AddToGroup | ( | CUnit ** | units, | |
| int | nunits, | |||
| int | num | |||
| ) |
Set the contents of a particular group with an array of units.
Add units to group num contents from unit array "units"
| units | Array of units to place into group. | |
| nunits | Number of units in array. | |
| num | Group number for storage. |
Definition at line 160 of file groups.cpp.
References Assert, CUnit::GroupId, CPlayer::IsTeamed(), MaxSelectable, NUM_GROUPS, CUnitGroup::NumUnits, CUnitType::SelectableByRectangle, ThisPlayer, CUnit::Type, and CUnitGroup::Units.
Referenced by SetGroup(), and UiAddToGroup().
Find best enemy in attack 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. |
Definition at line 559 of file unit_find.cpp.
References ATTACKRANGE_INDEX, CANATTACK_BONUS, CanTarget(), CompareUnitDistance(), DISTANCE_FACTOR, FindRangeAttack(), HEALTH_FACTOR, HP_INDEX, INRANGE_BONUS, INRANGE_FACTOR, CPlayer::IsEnemy(), CUnit::IsVisibleAsGoal(), MapDistanceBetweenUnits(), CVariable::Max, CUnitType::MinAttackRange, MissileConfig::Missile, CUnitType::Missile, NoUnitP, CUnit::Player, CUnitType::Priority, PRIORITY_FACTOR, MissileType::Range, CUnitCache::Select(), CUnit::Stats, CUnitType::TileHeight, CUnitType::TileWidth, CUnit::Type, UnitCache, UnitMax, UnitReachable(), CVariable::Value, CUnit::Variable, CUnitStats::Variables, CUnit::X, CUnit::Y, and y.
Referenced by AiAttackWithForce(), AiForceAttacks(), AttackUnitsInRange(), and AttackUnitsInReactRange().
Find best enemy in reaction range to attack.
Attack units in attack range.
| unit | Find unit in attack range for this unit. |
Definition at line 677 of file unit_find.cpp.
References Assert, ATTACKRANGE_INDEX, AttackUnitsInDistance(), CUnitType::CanAttack, CVariable::Max, CUnit::Stats, CUnit::Type, and CUnitStats::Variables.
Referenced by AutoAttack().
Attack units in reaction range.
| unit | Find unit in reaction range for this unit. |
Definition at line 690 of file unit_find.cpp.
References Assert, AttackUnitsInDistance(), CUnitType::CanAttack, CUnit::Player, PlayerPerson, CUnitType::ReactRangeComputer, CUnitType::ReactRangePerson, CPlayer::Type, and CUnit::Type.
Referenced by AiForceManager(), AttackTarget(), AutoAttack(), CheckForTargetInRange(), HandleActionFollow(), HandleActionPatrol(), and HitUnit().
| unit | Unit doing the building | |
| type | unit-type to be checked. | |
| x | Map X position. | |
| y | Map Y position. |
Definition at line 239 of file build.cpp.
References CUnitType::BuildingRules, CMap::Field(), CMapField::Flags, CMap::Info, Map, MapFieldCoastAllowed, CMapInfo::MapHeight, CMapInfo::MapWidth, CUnitType::ShoreBuilding, CUnitType::TileHeight, and CUnitType::TileWidth.
Referenced by CanBuildUnitType(), and DrawBuildingCursor().
| bool CanBuildOn | ( | int | x, | |
| int | y, | |||
| int | mask | |||
| ) |
FIXME: more docu.
Can build on this point.
| x | X tile map position. | |
| y | Y tile map position. | |
| mask | terrain mask |
Definition at line 301 of file build.cpp.
References CMap::Field(), CMapField::Flags, CMap::Info, Map, CMapInfo::MapHeight, and CMapInfo::MapWidth.
Referenced by CanBuildUnitType(), and DrawBuildingCursor().
Holds resources.
Can build unit-type at this point.
| unit | Worker that want to build the building or NULL. | |
| type | Building unit-type. | |
| x | X tile map position. | |
| y | Y tile map position. | |
| real | Really build, or just placement |
Definition at line 320 of file build.cpp.
References CanBuildHere(), CanBuildOn(), CMap::IsFieldExplored(), Map, MapFogFilterFlags(), MarkUnitFieldFlags(), CUnitType::MovementMask, CUnit::Player, PlayerPerson, CUnitType::TileHeight, CUnitType::TileWidth, CPlayer::Type, and UnmarkUnitFieldFlags().
Referenced by AiFindBuildingPlace2(), CclCreateUnit(), CheckCanBuild(), EditorCallbackButtonDown(), EditorCallbackMouse(), and UIHandleButtonDown().
| bool CanMove | ( | const CUnit * | unit | ) |
Generate a unit reference, a printable unique string for unit.
Test if unit can move. For the moment only check for move animation.
| unit | unit to test if it can move. |
Definition at line 68 of file action_move.cpp.
References CUnitType::Animations, Assert, CAnimations::Move, and CUnit::Type.
Referenced by AiMoveUnitInTheWay(), AiSendExplorers(), AutoAttack(), CommandFollow(), CommandMove(), CommandPatrolUnit(), DoActionMove(), CButtonPanel::DoClicked(), DoRightButton(), HandleActionAttack(), HandleActionMove(), HandleActionUnload(), HitUnit(), IsButtonAllowed(), MoveToTarget(), SendAttack(), SendResource(), ShowOrder(), and SpellMoveToTarget().
Can transporter transport the other unit.
Can the source unit attack the destination unit.
| source | Unit type pointer of the attacker. | |
| dest | Unit type pointer of the target. |
Definition at line 2425 of file unit.cpp.
References CUnitType::CanTarget, CanTargetAir, CanTargetLand, CanTargetSea, CUnitType::ShoreBuilding, CUnitType::UnitType, UnitTypeFly, UnitTypeLand, and UnitTypeNaval.
Referenced by AiEnemyUnitsInDistance(), AttackUnitsInDistance(), DoRightButton(), EnemyOnMapTile(), FindRangeAttack(), HitUnit(), MissileHit(), SendAttack(), and TargetOnMap().
Check if unit can move.
Can the transporter transport the other unit.
| transporter | Unit which is the transporter. | |
| unit | Unit which wants to go in the transporter. |
Definition at line 2450 of file unit.cpp.
References CUnit::BoardCount, CUnitType::CanTransport, CUnit::IsTeamed(), CUnitType::MaxOnBoard, CUnit::Orders, CUnitType::Organic, CUnit::Type, UnitActionBuilt, CUnitType::UnitType, and UnitTypeLand.
Referenced by DoRightButton(), SendMove(), and WaitForTransporter().
| void CclParseOrder | ( | lua_State * | l, | |
| COrder * | order | |||
| ) |
< Parse order
register CCL units features
Parse order
| l | Lua state. | |
| order | OUT: resulting order. |
Definition at line 98 of file script_unit.cpp.
References _C_, COrder::Action, COrder::Arg1, DebugPrint, COrder::Goal, COrder::Height, LuaError, LuaToNumber(), LuaToString(), COrder::MinRange, COrder::Patrol, COrder::Range, COrder::Spell, SpellTypeByIdent(), COrder::Type, UnitActionAttack, UnitActionAttackGround, UnitActionBoard, UnitActionBuild, UnitActionBuilt, UnitActionDie, UnitActionFollow, UnitActionMove, UnitActionNone, UnitActionPatrol, UnitActionRepair, UnitActionResource, UnitActionSpellCast, UnitActionStandGround, UnitActionStill, UnitActionTrain, UnitActionUnload, UnitSlots, UnitTypeByIdent(), COrder::Width, COrder::X, and COrder::Y.
Referenced by CclDefineAiPlayer(), CclParseOrders(), and CclUnit().
| void ChangeSelectedUnits | ( | CUnit ** | units, | |
| int | count | |||
| ) |
Changed TeamUnit Selection.
Replace a group of selected units by an other group of units.
| units | Array of units to be selected. | |
| count | Number of units in array to be selected. |
Definition at line 143 of file selection.cpp.
References Assert, GroupId, CUnit::LastGroup, MaxSelectable, NetworkSendSelection(), NumSelected, CUnit::Selected, and UnSelectAll().
Referenced by SelectAirUnitsInRectangle(), SelectGroundUnitsInRectangle(), SelectGroup(), SelectSingleUnit(), and SelectUnitsInRectangle().
Add a unit to selection.
Change A Unit Selection from my Team
| player | The Player who is selecting the units | |
| units | The Units to add/remove | |
| adjust | 0 = reset, 1 = remove units, 2 = add units | |
| count | the number of units to be adjusted |
Definition at line 173 of file selection.cpp.
References Assert, CPlayer::Index, MaxSelectable, NoUnitP, TeamNumSelected, and CUnit::TeamSelected.
Referenced by CommandQuit(), and NetworkProcessSelection().
| void CleanDecorations | ( | void | ) |
Draw unit's shadow.
Clean decorations.
Definition at line 300 of file unit_draw.cpp.
References CGraphic::Free(), DecoSpriteType::Name, and DecoSpriteType::SpriteArray.
Referenced by CleanModules().
| void CleanGroups | ( | void | ) |
Clean up group part.
Definition at line 102 of file groups.cpp.
References NUM_GROUPS, CUnitGroup::NumUnits, and CUnitGroup::Units.
Referenced by CleanGame(), and CleanModules().
| void CleanSelections | ( | void | ) |
Register CCL selection features.
Clean up the selection module.
Definition at line 1110 of file selection.cpp.
References _TeamNumSelected, GroupId, NumSelected, PlayerMax, and TeamNumSelected.
Referenced by CleanGame(), and CleanModules().
| void CleanUnits | ( | void | ) |
Clean up unit module.
Definition at line 2611 of file unit.cpp.
References HelpMeLastCycle, CUnitManager::Init(), NumUnits, and UnitManager.
Referenced by CleanGame(), and CleanModules().
| void ClearGroup | ( | int | num | ) |
Add the array of units to the group.
Clear contents of group num
| num | Group number. |
Definition at line 140 of file groups.cpp.
References Assert, CUnit::Destroyed, CUnit::GroupId, CUnitGroup::NumUnits, and CUnitGroup::Units.
Referenced by SetGroup().
| void DecorationCclRegister | ( | void | ) |
< Register CCL decorations features
Load the decorations (health,mana) of units
Register CCL features for decorations.
Definition at line 279 of file unit_draw.cpp.
References CclDefineSprites(), and Lua.
Referenced by InitCcl().
| void DestroyAllInside | ( | CUnit * | source | ) |
Hit unit with damage, if destroyed give attacker the points.
Destroy all units inside unit.
| source | container. |
Definition at line 2027 of file unit.cpp.
References DestroyAllInside(), CUnit::InsideCount, CUnit::NextContained, CUnit::Release(), UnitClearOrders(), CUnit::UnitInside, and UnitLost().
Referenced by DestroyAllInside(), and LetUnitDie().
| int DirectionToHeading | ( | int | delta_x, | |
| int | delta_y | |||
| ) |
Update frame from heading.
Convert direction to heading.
| delta_x | Delta X. | |
| delta_y | Delta Y. |
Definition at line 1424 of file unit.cpp.
References myatan().
Referenced by MissileNewHeadingFromXY(), StartBuilding(), and UnitHeadingFromDeltaXY().
| void DrawSelection | ( | Uint32 | color, | |
| int | x1, | |||
| int | y1, | |||
| int | x2, | |||
| int | y2 | |||
| ) |
Draw selected corners around the unit.
| color | Color to draw corners. | |
| x1,y1 | Coordinates of the top left corner. | |
| x2,y2 | Coordinates of the bottom right corner. |
Definition at line 172 of file unit_draw.cpp.
References CVideo::DrawHLineClip(), CVideo::DrawVLineClip(), and Video.
Referenced by DrawUnitSelection(), and ShowSingleOrder().
Draw all units visible on map in viewport.
Draw unit's shadow.
| unit | Pointer to the unit. | |
| type | Pointer to the unit type. | |
| frame | Frame number | |
| x | Screen X position of the unit. | |
| y | Screen Y position of the unit. |
Definition at line 410 of file unit_draw.cpp.
References Assert, CGraphic::DrawFrameClip(), CGraphic::DrawFrameClipX(), CUnitType::Flip, CUnitType::NumDirections, CUnitType::OffsetX, CUnitType::OffsetY, CUnit::Orders, CUnitType::ShadowHeight, CUnitType::ShadowOffsetX, CUnitType::ShadowOffsetY, CUnitType::ShadowSprite, CUnitType::ShadowWidth, CUnitType::TileHeight, TileSizeX, TileSizeY, CUnitType::TileWidth, CUnit::Type, and UnitActionDie.
Referenced by CUnit::Draw(), and DrawBuildingCursor().
| void DrawUnitSelection | ( | const CUnit * | unit | ) |
Show selection marker around a unit.
| unit | Pointer to unit. |
Definition at line 113 of file unit_draw.cpp.
References CUnit::Blink, CUnitType::BoxHeight, CUnitType::BoxWidth, CUnitType::Building, CPlayer::Color, ColorGray, ColorGreen, ColorRed, ColorWhite, ColorYellow, CursorBuilding, DrawSelection(), Editor, EditorSelecting, CGraphic::Height, CUnitType::Height, CPlayer::Index, CPlayer::IsEnemy(), CPlayer::IsTeamed(), CUnit::IX, CUnit::IY, CViewport::Map2ViewportX(), CViewport::Map2ViewportY(), CUnit::Orders, CUnit::Player, PlayerMax, PlayerNumNeutral, Players, CEditor::Running, CUnit::Selected, CUnitType::Sprite, CEditor::State, CUnit::TeamSelected, ThisPlayer, CUnitType::TileHeight, TileSizeX, TileSizeY, CUnitType::TileWidth, CUnit::Type, UnitActionDie, UnitUnderCursor, CGraphic::Width, CUnitType::Width, CUnit::X, CUnit::Y, and y.
Referenced by CUnit::Draw().
| void DropOutAll | ( | const CUnit * | source | ) |
Return the rule used to build this building.
Drop out all units inside unit.
| source | All units inside source are dropped out. |
Definition at line 1663 of file unit.cpp.
References Assert, DropOutOnSide(), CUnit::InsideCount, LookingW, CUnit::NextContained, CUnit::Orders, CUnit::SubAction, CUnitType::TileHeight, CUnitType::TileWidth, CUnit::Type, UnitActionStill, and CUnit::UnitInside.
| void DropOutNearest | ( | CUnit * | unit, | |
| int | gx, | |||
| int | gy, | |||
| int | addx, | |||
| int | addy | |||
| ) |
Drop out all units in the unit.
Place a unit on the map nearest to x, y.
| unit | Unit to drop out. | |
| gx | Goal X map tile position. | |
| gy | Goal Y map tile position. | |
| addx | Tile width of unit it's dropping out of. | |
| addy | Tile height of unit it's dropping out of. |
Definition at line 1578 of file unit.cpp.
References Assert, CUnit::Container, MapDistance(), CUnit::Place(), CUnit::Removed, UnitCanBeAt(), CUnit::X, CUnit::Y, and y.
| void DropOutOnSide | ( | CUnit * | unit, | |
| int | heading, | |||
| int | addx, | |||
| int | addy | |||
| ) |
| unit | Unit to drop out. | |
| heading | Direction in which the unit should appear. | |
| addx | Tile width of unit it's dropping out of. | |
| addy | Tile height of unit it's dropping out of. |
Definition at line 1502 of file unit.cpp.
References CUnit::Container, LookingNW, LookingSE, LookingSW, CUnit::Place(), UnitCanBeAt(), CUnit::X, CUnit::Y, and y.
Referenced by Summon::Cast(), CclCreateUnit(), CclMoveUnit(), DropOutAll(), HandleActionBuilt(), and HandleActionTrain().
Show a unit's orders.
Find all units to draw in viewport.
| vp | Viewport to be drawn. | |
| table | Table of units to return in sorted order | |
| tablesize | Size of table array |
Definition at line 930 of file unit_draw.cpp.
References DrawLevelCompare(), CUnit::IsVisibleInViewport(), CViewport::MapHeight, CViewport::MapWidth, CViewport::MapX, CViewport::MapY, CUnitCache::Select(), and UnitCache.
Referenced by CViewport::Draw().
| player | Player's units to search through |
Definition at line 1816 of file unit.cpp.
References CUnitType::Harvester, IsOnlySelected, NoUnitP, CUnit::Orders, CUnit::Removed, CPlayer::TotalNumUnits, CUnit::Type, UnitActionStill, and CPlayer::Units.
Referenced by UiFindIdleWorker().
| int FindPlayerUnitsByType | ( | const CPlayer * | player, | |
| const CUnitType * | type, | |||
| CUnit ** | table, | |||
| int | tablesize | |||
| ) |
Return any unit on that map tile.
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 | |
| tablesize | size of table array |
Definition at line 108 of file unit_find.cpp.
References CUnit::IsUnusable(), CUnitType::Slot, CPlayer::TotalNumUnits, CUnit::Type, CPlayer::Units, and CPlayer::UnitTypesCount.
Referenced by AiBuildBuilding(), AiRepairBuilding(), and AiTrainUnit().
< Find all units of this type
Find all units of this type of the player
Find all units of type.
| type | type of unit requested | |
| table | table in which we have to store the units | |
| tablesize | size of table array |
Definition at line 85 of file unit_find.cpp.
References CUnit::IsUnusable(), NumUnits, CUnit::Type, and Units.
Referenced by CclIfNearUnit(), and CclIfRescuedNearUnit().
| int GetNumberUnitsOfGroup | ( | int | num | ) |
< Get the number of units in a particular group
Get the array of units of a particular group
Return the number of units of group num
| num | Group number. |
Definition at line 118 of file groups.cpp.
References CUnitGroup::NumUnits.
Referenced by SelectGroup(), UiAddGroupToSelection(), and UiCenterOnGroup().
| CUnit** GetUnitsOfGroup | ( | int | num | ) |
Remove all units from a group.
Return the units of group num
| num | Group number. |
Definition at line 130 of file groups.cpp.
References CUnitGroup::Units.
Referenced by SelectGroup(), UiAddGroupToSelection(), and UiCenterOnGroup().
| void GroupCclRegister | ( | void | ) |
Register CCL features for groups.
Definition at line 271 of file groups.cpp.
References CclGroup(), and Lua.
Referenced by InitCcl().
Returns the map distance between two points.
Unit is hit by missile or other damage.
| attacker | Unit that attacks. | |
| target | Unit that is hit. | |
| damage | How many damage to take. |
Definition at line 2056 of file unit.cpp.
References _, COrder::Action, CPlayer::AiEnabled, AiHelpMe(), Assert, CUnit::Attacked, AttackUnitsInReactRange(), CUnitType::Building, CUnit::Burning, CUnitType::CanAttack, CanMove(), CanTarget(), CUnit::ChangeOwner(), CommandAttack(), CommandMove(), CommandStopUnit(), CUnitType::Coward, CYCLES_PER_SECOND, Missile::Damage, DamageMissile, DebugPrint, CVariable::Enable, EnableBuildingCapture, FlushCommands, GameCycle, GodMode, HelpMeLastCycle, HelpMeLastX, HelpMeLastY, HP_INDEX, CUnitType::Indestructible, CMap::Info, CUnit::IsEnemy(), isqrt(), CUnit::IsVisibleOnMap(), KILL_INDEX, LetUnitDie(), MakeLocalMissile(), MakeMissile(), Map, CMapInfo::MapHeight, CMapInfo::MapWidth, CVariable::Max, MissileBurningBuilding(), MissileTypeByIdent(), CUnitType::Name, CPlayer::Notify(), NotifyRed, NoUnitP, CUnit::Orders, CUnitType::Organic, CUnit::Player, PlayUnitSound(), CUnitType::Points, CUnit::RefsIncrease(), CUnit::Removed, CUnitType::RepairRange, ReplayRevealMap, CUnit::SavedOrder, CPlayer::Score, Missile::SourceUnit, SyncRand(), ThisPlayer, CUnitType::TileHeight, TileSizeX, TileSizeY, CUnitType::TileWidth, CPlayer::TotalKills, CPlayer::TotalRazings, CUnit::Type, UnitActionDie, UnitActionStill, CVariable::Value, CUnitType::Vanishes, CUnit::Variable, VoiceHelpMe, CUnit::X, y, and CUnit::Y.
Referenced by Capture::Cast(), AdjustVitals::Cast(), AreaAdjustVitals::Cast(), Demolish::Cast(), FireMissile(), HandleRegenerations(), and MissileHitsGoal().
| void InitGroups | ( | void | ) |
< Initialize data structures for groups
Save groups
Initialize group part.
Definition at line 71 of file groups.cpp.
References MaxSelectable, NUM_GROUPS, CUnitGroup::Units, and Units.
Referenced by CclGroup(), CreateGame(), and InitModules().
| void InitSelections | ( | void | ) |
Save current selection state.
Initialize the selection module.
Definition at line 1074 of file selection.cpp.
References MaxSelectable, and PlayerMax.
Referenced by CclSelection(), CreateGame(), and InitModules().
| void InitUnits | ( | void | ) |
Clean unit module.
Initialize unit module.
Definition at line 2600 of file unit.cpp.
References CUnitManager::Init(), NumUnits, SaveGameLoading, and UnitManager.
Referenced by InitModules().
| void LetUnitDie | ( | CUnit * | unit | ) |
Destory all units inside another unit.
Let a unit die.
| unit | Unit to be destroyed. |
Definition at line 1927 of file unit.cpp.
References CUnit::Anim, CUnitType::Animations, CUnit::_order_data_::Built, CUnitType::CanHarvestFrom, CUnitType::CorpseType, CUnit::CurrentSightRange, CUnit::Data, CAnimations::Death, CUnitType::DeathExplosion, DebugPrint, DestroyAllInside(), CUnitType::ExplodeWhenKilled, CUnitType::Explosion, CGraphic::Height, CUnitType::Height, CPlayer::Index, CUnitCache::Insert(), CUnit::IX, CUnit::IY, MakeMissile(), MapMarkUnitSight(), CVariable::Max, MaxCosts, MissileConfig::Missile, CUnit::Moving, CUnit::Orders, CUnit::Player, PlayUnitSound(), CUnit::ProductionEfficiency, CUnitType::ProductionRate, CPlayer::ProductionRate, LuaCallback::pushInteger(), LuaCallback::pushPreamble(), CUnit::Release(), CUnit::Remove(), CUnit::Removed, CUnit::ResourcesHeld, LuaCallback::run(), SIGHTRANGE_INDEX, CUnitType::Sprite, CUnit::State, CUnitType::Stats, CUnitType::StorageCapacity, CPlayer::StorageCapacity, CPlayer::StoredResources, CUnit::SubAction, CUnitType::TileHeight, TileSizeX, TileSizeY, CUnitType::TileWidth, CUnit::TTL, CUnit::Type, CUnit::_unit_anim_::Unbreakable, UnitActionBuilt, UnitActionDie, UnitCache, UnitClearOrders(), CUnit::UnitInside, UnitLost(), UnitRemoveConsumingResources(), CUnitStats::Variables, VoiceDying, CGraphic::Width, CUnitType::Width, CUnit::_order_data_::_order_built_::Worker, CUnit::X, and CUnit::Y.
Referenced by CclKillUnit(), CclKillUnitAt(), CommandDismiss(), GatherResource(), HandleActionBuilt(), HandleBuffs(), and HitUnit().
| void LoadDecorations | ( | void | ) |
Clean the decorations (health,mana) of units.
Load decoration.
Definition at line 287 of file unit_draw.cpp.
References CGraphic::New(), ShowLoadProgress(), and DecoSpriteType::SpriteArray.
Referenced by CreateGame(), and LoadModules().
Create a new unit and place on map.
Create a new unit.
| type | Pointer to unit-type. | |
| player | Pointer to owning player. |
Definition at line 302 of file unit.cpp.
References _C_, CUnitManager::AllocUnit(), CUnit::AssignToPlayer(), DebugPrint, CUnit::Init(), NoUnitP, NumUnits, UnitManager, and UnitMax.
Referenced by Summon::Cast(), CclCreateUnit(), HandleActionTrain(), MakeUnitAndPlace(), and StartBuilding().
Handle the loss of a unit (food,...).
Create new unit and place on map.
| x | X map tile position. | |
| y | Y map tile position. | |
| type | Pointer to unit-type. | |
| player | Pointer to owning player. |
Definition at line 636 of file unit.cpp.
References MakeUnit(), NoUnitP, and CUnit::Place().
Referenced by Polymorph::Cast(), SpawnPortal::Cast(), EditorActionPlaceUnit(), and UnitLost().
| int MapDistance | ( | int | x1, | |
| int | y1, | |||
| int | x2, | |||
| int | y2 | |||
| ) |
Returns the map distance between two points with unit-type.
Returns the map distance between two points.
| x1 | X map tile position. | |
| y1 | Y map tile position. | |
| x2 | X map tile position. | |
| y2 | Y map tile position. |
Definition at line 2272 of file unit.cpp.
References isqrt().
Referenced by DropOutNearest(), MissileInitMove(), NextMissileFrame(), and ViewPointDistance().
| int MapDistanceBetweenTypes | ( | const CUnitType * | src, | |
| int | x1, | |||
| int | y1, | |||
| const CUnitType * | dst, | |||
| int | x2, | |||
| int | y2 | |||
| ) |
Returns the map distance between two units.
Returns the map distance between two points with unit type.
| src | src unittype | |
| x1 | X map tile position of src (upperleft). | |
| y1 | Y map tile position of src. | |
| dst | Unit type to take into account. | |
| x2 | X map tile position of dst. | |
| y2 | Y map tile position of dst. |
Definition at line 2354 of file unit.cpp.
References isqrt(), CUnitType::TileHeight, and CUnitType::TileWidth.
Referenced by CBuildRestrictionDistance::Check(), and MapDistanceBetweenUnits().
Calculate the distance from current view point to coordinate.
Returns the map distance between two units.
| src | Distance from this unit. | |
| dst | Distance to this unit. |
Definition at line 2336 of file unit.cpp.
References MapDistanceBetweenTypes(), CUnit::Type, CUnit::X, and CUnit::Y.
Referenced by AttackTarget(), AttackUnitsInDistance(), CompareUnitDistance(), FindRangeAttack(), FireMissile(), HandleActionAttack(), MoveToLocation(), MoveToTarget(), RepairUnit(), SpellMoveToTarget(), StartGathering(), and WaitForTransporter().
| int MapDistanceToType | ( | int | x1, | |
| int | y1, | |||
| const CUnitType * | type, | |||
| int | x2, | |||
| int | y2 | |||
| ) |
Returns the map distance to unit.
Returns the map distance between two points with unit type.
| x1 | X map tile position. | |
| y1 | Y map tile position. | |
| type | Unit type to take into account. | |
| x2 | X map tile position. | |
| y2 | Y map tile position. |
Definition at line 2288 of file unit.cpp.
References isqrt(), CUnitType::TileHeight, and CUnitType::TileWidth.
Referenced by MapDistanceToUnit().
| int MapDistanceToUnit | ( | int | x, | |
| int | y, | |||
| const CUnit * | dest | |||
| ) |
Returns the map diestance between to unittype as locations.
Returns the map distance to unit.
| x | X map tile position. | |
| y | Y map tile position. | |
| dest | Distance to this unit. |
Definition at line 2323 of file unit.cpp.
References MapDistanceToType(), CUnit::Type, CUnit::X, and CUnit::Y.
Referenced by Demolish::Cast(), MissileHit(), MoveToTarget(), SpellMoveToTarget(), and ViewPointDistanceToUnit().
| void MarkUnitFieldFlags | ( | const CUnit * | unit | ) |
< Mark the field with the FieldFlags.
Unmark the field with the FieldFlags.
Mark the field with the FieldFlags.
| unit | unit to mark. |
Definition at line 467 of file unit.cpp.
References CMap::Field(), CUnitType::FieldFlags, CMapField::Flags, Map, CUnitType::TileHeight, CUnitType::TileWidth, CUnit::Type, CUnit::X, and CUnit::Y.
Referenced by CanBuildUnitType(), DoActionMove(), CUnit::MoveToXY(), and CUnit::Place().
| void NearestOfUnit | ( | const CUnit * | unit, | |
| int | tx, | |||
| int | ty, | |||
| int * | dx, | |||
| int * | dy | |||
| ) |
Call when an Unit goes under fog.
Find nearest point of unit.
| unit | Pointer to unit. | |
| tx | X tile map postion. | |
| ty | Y tile map postion. | |
| dx | Out: nearest point X tile map postion to (tx,ty). | |
| dy | Out: nearest point Y tile map postion to (tx,ty). |
Definition at line 828 of file unit.cpp.
References CUnitType::TileHeight, CUnitType::TileWidth, CUnit::Type, CUnit::X, CUnit::Y, and y.
Referenced by FireMissile().
| CBuildRestrictionOnTop* OnTopDetails | ( | const CUnit * | unit, | |
| const CUnitType * | parent | |||
| ) |
| unit | the unit that is "OnTop" | |
| parent | the parent unit if known. (guess otherwise) |
Definition at line 55 of file build.cpp.
References CBuildRestrictionAnd::_or_list, CUnitType::BuildingRules, CBuildRestrictionOnTop::Parent, and CUnit::Type.
Referenced by EditorActionPlaceUnit(), StartBuilding(), and UnitLost().
| void RemoveUnitFromGroups | ( | CUnit * | unit | ) |
Register CCL group features.
Remove unit from its groups
| unit | Unit to remove from group. |
Definition at line 207 of file groups.cpp.
References Assert, CUnit::GroupId, CUnitGroup::NumUnits, NumUnits, and CUnitGroup::Units.
Referenced by UnitLost().
| void RescueUnits | ( | void | ) |
Convert direction (dx,dy) to heading (0-255).
Rescue units.
Look through all rescueable players, if they could be rescued.
Definition at line 1310 of file unit.cpp.
References CUnit::Blink, CUnit::ChangeOwner(), GameSounds, CUnit::IsAllied(), MaxSampleVolume, NoRescueCheck, NumPlayers, CUnit::Player, PlayerRescueActive, PlayerRescuePassive, Players, PlayGameSound(), CUnit::Removed, GameSound::Rescue, CUnit::RescuedFrom, CUnitCache::Select(), SoundConfig::Sound, CUnitType::TileHeight, CUnitType::TileWidth, CUnit::Type, UnitCache, UnitMax, CUnitType::UnitType, UnitTypeLand, CUnit::X, and CUnit::Y.
Referenced by GameMainLoop().
| CUnit* ResourceOnMap | ( | int | tx, | |
| int | ty, | |||
| int | resource | |||
| ) |
Find best enemy in numeric range to attack.
Resource on map tile
| tx | X position on map, tile-based. | |
| ty | Y position on map, tile-based. | |
| resource | Resource number or -1 for any. |
Definition at line 211 of file unit_find.cpp.
References NoUnitP, CUnitCache::Select(), UnitCache, UnitHoldsResources(), and UnitMax.
Referenced by UnitFindResource().
| void RestoreSelection | ( | void | ) |
Clear current selection.
Restore selection.
Definition at line 99 of file selection.cpp.
References _NumSelected, _TeamNumSelected, NumSelected, PlayerMax, CUnit::Selected, TeamNumSelected, CUnit::TeamSelected, and UnSelectAll().
| void SaveGroups | ( | CFile * | file | ) |
Cleanup groups.
Save groups.
| file | Output file. |
Definition at line 85 of file groups.cpp.
References NUM_GROUPS, CUnitGroup::NumUnits, NumUnits, CFile::printf(), UnitReference(), and Units.
Referenced by SaveGame().
save unit-structure
Save an order.
| order | Order who should be saved. | |
| file | Output file. |
Definition at line 69 of file unit_save.cpp.
References COrder::Action, COrder::Arg1, DebugPrint, CUnit::Destroyed, COrder::Goal, COrder::Height, SpellType::Ident, CUnitType::Ident, COrder::MinRange, COrder::Patrol, CFile::printf(), COrder::Range, COrder::Spell, COrder::Type, UnitActionAttack, UnitActionAttackGround, UnitActionBoard, UnitActionBuild, UnitActionBuilt, UnitActionDie, UnitActionFollow, UnitActionMove, UnitActionNone, UnitActionPatrol, UnitActionRepair, UnitActionResource, UnitActionSpellCast, UnitActionStandGround, UnitActionStill, UnitActionTrain, UnitActionUnload, UnitReference(), COrder::Width, COrder::X, and COrder::Y.
Referenced by SaveAiPlayer(), and SaveUnit().
| void SaveSelection | ( | void | ) |
Restore selection.
Save selection to restore after.
Definition at line 79 of file selection.cpp.
References _NumSelected, _TeamNumSelected, NumSelected, PlayerMax, and TeamNumSelected.
| void SaveSelections | ( | CFile * | file | ) |
Clean up selections.
Save current selection state.
| file | Output file. |
Definition at line 1094 of file selection.cpp.
References GroupId, NumSelected, CFile::printf(), and UnitReference().
Referenced by SaveGame().
save all units
Save the state of a unit to file.
| unit | Unit pointer to be saved. | |
| file | Output file. |
Definition at line 174 of file unit_save.cpp.
References CUnit::_unit_anim_::Anim, CUnit::Anim, AnimationsArray, Assert, CUnit::Attacked, CUnit::AutoCastSpell, CUnit::AutoRepair, CUnit::Blink, CUnit::BoardCount, CUnit::Boarded, CUnit::_order_data_::Built, CUnit::Burning, CUnit::_unit_seen_::ByPlayer, CUnit::_order_data_::_order_built_::Cancel, CUnit::_unit_seen_::CFrame, CUnit::_unit_seen_::Constructed, CUnit::Constructed, CUnitType::Construction, CUnit::Container, CUnit::_unit_anim_::CurrAnim, CUnit::_order_data_::_order_harvest_::CurrentProduction, CUnit::CurrentSightRange, CUnit::Data, CUnit::_unit_seen_::Destroyed, CUnit::Destroyed, CUnit::Direction, CVariable::Enable, CUnit::_order_data_::_order_move_::Fast, CUnit::_order_data_::_order_built_::Frame, CUnit::_unit_seen_::Frame, CUnit::Frame, CConstruction::Frames, CUnit::Goal, CUnit::GroupId, CUnit::_order_data_::Harvest, CUnitType::Ident, CVariable::Increase, CPlayer::Index, CUnit::InsideCount, CUnit::_unit_seen_::IX, CUnit::IX, CUnit::_unit_seen_::IY, CUnit::IY, CUnit::LastGroup, CUnit::_order_data_::_order_move_::Length, CVariable::Max, MaxCosts, CUnit::_order_data_::Move, CUnit::Moving, CUnit::NewOrder, CConstructionFrame::Next, CUnit::Next, NumAnimations, CUnitTypeVar::NumberVariable, CUnit::OrderCount, CUnit::OrderFlush, CUnit::Orders, CUnit::_order_data_::_order_move_::Path, CUnit::Player, PlayerMax, CUnit::PrevContained, CFile::printf(), CUnit::ProductionEfficiency, CUnit::_order_data_::_order_built_::Progress, CUnit::ReCast, CUnit::Refs, CUnit::Removed, CUnit::RescuedFrom, CUnit::ResourcesHeld, CUnit::SavedOrder, SaveOrder(), CUnit::Seen, CUnit::Selected, SpellTypeTable, CUnit::State, CUnit::_unit_seen_::State, CUnit::Stats, CUnitType::Stats, CUnit::SubAction, CUnit::_order_data_::_order_train_::Ticks, CUnitType::TileHeight, CUnitType::TileWidth, CUnit::_order_data_::Train, CUnit::TTL, CUnit::_unit_seen_::Type, CUnit::Type, CUnit::_unit_anim_::Unbreakable, UnitActionBuilt, UnitActionResource, UnitActionStill, UnitActionTrain, CUnit::UnitInside, UnitNotSeen, UnitNumber, UnitReference(), UnitTypeVar, CVariable::Value, CUnit::Variable, CUnitTypeVar::VariableName, CUnit::_unit_anim_::Wait, CUnit::Wait, CUnit::_order_data_::_order_built_::Worker, CUnit::_unit_seen_::X, CUnit::X, CUnit::_unit_seen_::Y, and CUnit::Y.
Referenced by SaveUnits().
| void SaveUnits | ( | CFile * | file | ) |
Initialize unit module.
Save state of units to file.
| file | Output file. |
Definition at line 429 of file unit_save.cpp.
References NumUnits, CUnitManager::Save(), SaveUnit(), UnitManager, and Units.
Referenced by SaveGame().
| int SelectAirUnitsInRectangle | ( | int | sx0, | |
| int | sy0, | |||
| int | sx1, | |||
| int | sy1 | |||
| ) |
Add the units in the selection rectangle to the current selection.
Select own air units in a rectangle.
| sx0 | X start of selection rectangle in tile coordinates | |
| sy0 | Y start of selection rectangle in tile coordinates | |
| sx1 | X start of selection rectangle in tile coordinates | |
| sy1 | Y start of selection rectangle in tile coordinates |
Definition at line 878 of file selection.cpp.
References CanSelectMultipleUnits, ChangeSelectedUnits(), CUnit::IsUnusable(), MaxSelectable, CUnit::Player, CUnitCache::Select(), CUnitType::SelectableByRectangle, SelectSpritesInsideRectangle(), CUnit::TeamSelected, TileSizeX, TileSizeY, CUnit::Type, UnitCache, UnitMax, CUnitType::UnitType, and UnitTypeFly.
Referenced by AddSelectedAirUnitsInRectangle(), and UIHandleButtonUp().
| void SelectedUnitChanged | ( | void | ) |
Called whenever the selected unit was updated.
The selected unit has been altered.
Definition at line 897 of file script_ui.cpp.
References CUserInterface::ButtonPanel, UI, and CButtonPanel::Update().
| int SelectGroundUnitsInRectangle | ( | int | sx0, | |
| int | sy0, | |||
| int | sx1, | |||
| int | sy1 | |||
| ) |
Select flying units in the selection rectangle.
Select own ground units in a rectangle.
| sx0 | X start of selection rectangle in tile coordinates | |
| sy0 | Y start of selection rectangle in tile coordinates | |
| sx1 | X start of selection rectangle in tile coordinates | |
| sy1 | Y start of selection rectangle in tile coordinates |
Definition at line 823 of file selection.cpp.
References CanSelectMultipleUnits, ChangeSelectedUnits(), CUnit::IsUnusable(), MaxSelectable, CUnit::Player, CUnitCache::Select(), CUnitType::SelectableByRectangle, SelectSpritesInsideRectangle(), CUnit::TeamSelected, TileSizeX, TileSizeY, CUnit::Type, UnitCache, UnitMax, CUnitType::UnitType, and UnitTypeFly.
Referenced by AddSelectedGroundUnitsInRectangle(), and UIHandleButtonUp().
| int SelectGroup | ( | int | group_number | ) |
Add the units from the same group as the one in parameter.
Change selected units to units from group group_number Doesn't change the selection if the group has no unit.
| group_number | number of the group to be selected. |
Definition at line 509 of file selection.cpp.
References Assert, ChangeSelectedUnits(), GetNumberUnitsOfGroup(), GetUnitsOfGroup(), NUM_GROUPS, and NumSelected.
Referenced by UiSelectGroup().
| int SelectGroupFromUnit | ( | CUnit * | unit | ) |
Select the units in the selection rectangle.
Select units from group of a particular unit. Doesn't change the selection if the group has no unit, or the unit doesn't belong to any group.
| unit | unit belonging to the group to be selected. |
Definition at line 561 of file selection.cpp.
References AddGroupFromUnitToSelection(), CUnit::LastGroup, and UnSelectAll().
Referenced by DoSelectionButtons(), and UIHandleButtonUp().
| void SelectionCclRegister | ( | void | ) |
Register CCL features for selections.
Definition at line 1182 of file selection.cpp.
References CclSelection(), CclSetGroupId(), and Lua.
Referenced by InitCcl().
| void SelectSingleUnit | ( | CUnit * | unit | ) |
Remove a unit from selection.
Select a single unit, unselecting the previous ones
| unit | Pointer to unit to be selected. |
Definition at line 260 of file selection.cpp.
References ChangeSelectedUnits().
Referenced by DoSelectionButtons(), SelectUnitsInRectangle(), UiFindIdleWorker(), and UIHandleButtonUp().
| int SelectUnit | ( | CUnit * | unit | ) |
Select one unit as selection.
Add a unit to the other selected units.
| unit | Pointer to unit to add. |
Definition at line 223 of file selection.cpp.
References DebugPrint, GameRunning, GroupId, CUnitType::IsNotSelectable, CUnit::LastGroup, MaxSelectable, NumSelected, CUnit::Removed, CUnitType::Revealer, CUnit::Selected, and CUnit::Type.
Referenced by AddGroupFromUnitToSelection(), AddSelectedAirUnitsInRectangle(), AddSelectedGroundUnitsInRectangle(), AddSelectedUnitsInRectangle(), ToggleSelectUnit(), ToggleUnitsByType(), and UiAddGroupToSelection().
| int SelectUnitsByType | ( | CUnit * | base | ) |
Toggle units from the same type (if selectable by rectangle).
Select units from a particular type and belonging to the local player.
The base is included in the selection and defines the type of the other units to be selected.
| base | Select all units of same type. |
FIXME: should always select the nearest 9 units to the base!
Definition at line 346 of file selection.cpp.
References Assert, CanSelectMultipleUnits, GameRunning, GroupId, CUnitType::IsNotSelectable, CUnit::IsUnusable(), CUnit::LastGroup, CViewport::MapHeight, CViewport::MapWidth, CViewport::MapX, CViewport::MapY, MaxSelectable, CUserInterface::MouseViewport, NetworkSendSelection(), NumSelected, CUnit::Orders, CUnit::Player, CUnit::Removed, CUnitCache::Select(), CUnitType::SelectableByRectangle, CUnit::Selected, CUnit::TeamSelected, CUnit::Type, UI, UnitActionDie, UnitCache, UnitMax, and UnSelectAll().
Referenced by DoSelectionButtons(), and UIHandleButtonUp().
| int SelectUnitsInRectangle | ( | int | sx0, | |
| int | sy0, | |||
| int | sx1, | |||
| int | sy1 | |||
| ) |
Select ground units in the selection rectangle.
Select units in a rectangle. Proceed in order in none found:
| sx0 | X start of selection rectangle in tile coordinates | |
| sy0 | Y start of selection rectangle in tile coordinates | |
| sx1 | X start of selection rectangle in tile coordinates | |
| sy1 | Y start of selection rectangle in tile coordinates |
Definition at line 727 of file selection.cpp.
References CUnitType::Building, CUnitType::CanHarvestFrom, CanSelectMultipleUnits, ChangeSelectedUnits(), CUnit::IsVisibleInViewport(), CUnit::IsVisibleOnMap(), CUnit::Orders, CUnit::Player, CUnit::Removed, CUnitCache::Select(), CUserInterface::SelectedViewport, SelectOrganicUnitsInTable(), SelectSingleUnit(), SelectSpritesInsideRectangle(), ThisPlayer, TileSizeX, TileSizeY, CUnit::Type, UI, UnitActionDie, UnitCache, and UnitMax.
Referenced by AddSelectedUnitsInRectangle(), and UIHandleButtonUp().
| void SetGroup | ( | CUnit ** | units, | |
| int | nunits, | |||
| int | num | |||
| ) |
Remove a unit from a group.
Set group num contents to unit array "units"
| units | Array of units to place into group. | |
| nunits | Number of units in array. | |
| num | Group number for storage. |
Definition at line 194 of file groups.cpp.
References AddToGroup(), Assert, ClearGroup(), MaxSelectable, and NUM_GROUPS.
Referenced by UiDefineGroup().
| void ShowOrder | ( | const CUnit * | unit | ) |
Show the current order of a unit.
| unit | Pointer to the unit. |
Definition at line 613 of file unit_draw.cpp.
References CanMove(), CUnit::Destroyed, GetOrderPosition(), CUnit::IX, CUnit::IY, CViewport::Map2ViewportX(), CViewport::Map2ViewportY(), CUnit::NewOrder, CUnit::OrderCount, CUnit::OrderFlush, CUnit::Orders, ShowSingleOrder(), CUnitType::TileHeight, TileSizeX, TileSizeY, CUnitType::TileWidth, CUnit::Type, CUnit::X, and CUnit::Y.
Referenced by CViewport::Draw().
Return resource, if on map tile.
Choose target on map area.
| source | Unit which want to attack. | |
| x1 | X position on map, tile-based. | |
| y1 | Y position on map, tile-based. | |
| x2 | X position on map, tile-based. | |
| y2 | Y position on map, tile-based. |
Definition at line 168 of file unit_find.cpp.
References CanTarget(), CUnit::IsVisibleAsGoal(), NoUnitP, CUnit::Player, CUnitType::Priority, CUnitCache::Select(), CUnitType::TileHeight, CUnitType::TileWidth, CUnit::Type, UnitCache, UnitMax, CUnit::X, and CUnit::Y.
Referenced by CclOrderUnit().
| int ToggleSelectUnit | ( | CUnit * | unit | ) |
Select units from the same type (if selectable by rectangle).
Toggle the selection of a unit in a group of selected units
| unit | Pointer to unit to be toggled. |
Definition at line 322 of file selection.cpp.
References CUnit::Selected, SelectUnit(), and UnSelectUnit().
Referenced by DoSelectionButtons(), and UIHandleButtonUp().
| int ToggleUnitsByType | ( | CUnit * | base | ) |
Select the units belonging to a particular group.
Toggle units from a particular type and belonging to the local player.
The base is included in the selection and defines the type of the other units to be selected.
| base | Toggle all units of same type. |
Definition at line 440 of file selection.cpp.
References CanSelectMultipleUnits, CUnit::IsUnusable(), CViewport::MapHeight, CViewport::MapWidth, CViewport::MapX, CViewport::MapY, CUserInterface::MouseViewport, NetworkSendSelection(), NumSelected, CUnit::Orders, CUnit::Player, CUnit::Removed, CUnitCache::Select(), CUnitType::SelectableByRectangle, SelectUnit(), CUnit::TeamSelected, CUnit::Type, UI, UnitActionDie, UnitCache, and UnitMax.
Referenced by DoSelectionButtons(), and UIHandleButtonUp().
| void UnitCclRegister | ( | void | ) |
Register CCL features for unit.
Definition at line 1252 of file script_unit.cpp.
References CclCreateUnit(), CclGetUnits(), CclGetUnitVariable(), CclKillUnit(), CclKillUnitAt(), CclMoveUnit(), CclOrderUnit(), CclSetBuildingCapture(), CclSetResourcesHeld(), CclSetUnitVariable(), CclSlotUsage(), CclUnit(), and Lua.
Referenced by InitCcl().
| void UnitClearOrders | ( | CUnit * | unit | ) |
| unit | The unit that will have all its orders cleared |
Definition at line 770 of file unit.cpp.
References COrder::Goal, CUnit::NewOrder, NoUnitP, CUnit::OrderCount, CUnit::Orders, CUnit::RefsDecrease(), CUnit::SavedOrder, CUnit::State, CUnit::SubAction, and UnitActionStill.
Referenced by Capture::Cast(), Polymorph::Cast(), DestroyAllInside(), EditorActionPlaceUnit(), EditorActionRemoveUnit(), LetUnitDie(), and StartBuilding().
| void UnitCountSeen | ( | CUnit * | unit | ) |
Check for rescue each second.
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.
| unit | pointer to the unit to check if seen |
Definition at line 1013 of file unit.cpp.
References CMap::Field(), CUnit::IsVisible(), Map, CMap::NoFogOfWar, PlayerMax, PlayerNobody, Players, CUnitType::TileHeight, CUnitType::TileWidth, CUnit::Type, UnitGoesOutOfFog(), UnitGoesUnderFog(), CUnit::VisCount, CMapField::Visible, CUnit::X, CUnit::Y, and y.
Referenced by CUnit::MoveToXY(), CUnit::Place(), CMap::Reveal(), and UpdateFogOfWarChange().
Find the next idle worker.
Find Resource.
| unit | The unit that wants to find a resource. | |
| x | Closest to x | |
| y | Closest to y | |
| range | Maximum distance to the resource. | |
| resource | The resource id. |
Definition at line 1696 of file unit.cpp.
References CUnitType::CanHarvestFrom, CanMoveToMask(), CreateMatrix(), CMap::Info, CMap::IsFieldExplored(), Map, MapFieldAirUnit, MapFieldLandUnit, MapFieldSeaUnit, CMapInfo::MapHeight, CMapInfo::MapWidth, CUnitType::MovementMask, NoUnitP, CUnit::Player, PlayerNeutral, ResourceOnMap(), CPlayer::Type, CUnit::Type, CUnit::X, and CUnit::Y.
Referenced by AiAssignHarvester(), FindNewResource(), and StartGathering().
Marks a unit as seen.
This function should get called when a unit goes out of fog of war.
| unit | The unit that goes out of fog. | |
| player | The player the unit goes out of fog for. |
Definition at line 923 of file unit.cpp.
References CUnit::_unit_seen_::ByPlayer, CUnit::_unit_seen_::Destroyed, CPlayer::Index, PlayerPerson, CUnit::RefsDecrease(), CUnit::Seen, CPlayer::Type, CUnit::Type, and CUnitType::VisibleUnderFog.
Referenced by CMap::Reveal(), UnitCountSeen(), and UnitsOnTileMarkSeen().
Call when an Unit goes out of fog.
This function should get called when a unit goes under fog of war.
| unit | The unit that goes under fog. | |
| player | The player the unit goes out of fog for. |
Definition at line 882 of file unit.cpp.
References CUnit::_unit_seen_::Destroyed, CUnit::Destroyed, CPlayer::Index, PlayerPerson, CUnit::RefsIncrease(), CUnit::Seen, ThisPlayer, CPlayer::Type, CUnit::Type, UnitFillSeenValues(), and CUnitType::VisibleUnderFog.
Referenced by CMap::Reveal(), UnitCountSeen(), and UnitsOnTileUnmarkSeen().
| void UnitHeadingFromDeltaXY | ( | CUnit * | unit, | |
| int | dx, | |||
| int | dy | |||
| ) |
| unit | Unit for new direction looking. | |
| dx | X map tile delta direction. | |
| dy | Y map tile delta direction. |
Definition at line 1484 of file unit.cpp.
References CUnit::Direction, DirectionToHeading(), and UnitUpdateHeading().
Referenced by AttackTarget(), AutoAttack(), DoActionMove(), HandleActionAttack(), MoveToLocation(), MoveToTarget(), SpellMoveToTarget(), and StartGathering().
| bool UnitHoldsResources | ( | const CUnit * | unit | ) |
Find resource.
Check if a unit holds any resources
| unit | Unit to check |
Definition at line 1377 of file unit.cpp.
References MaxCosts, and CUnit::ResourcesHeld.
Referenced by GatherResource(), ResourceOnMap(), and UnitLost().
| void UnitLost | ( | CUnit * | unit | ) |
Remove the Orders of a Unit.
Update information for lost units.
| unit | Pointer to unit. |
Definition at line 703 of file unit.cpp.
References _C_, CPlayer::AiEnabled, AiUnitKilled(), Assert, CUnitType::Building, CUnitType::CanHarvestFrom, DebugPrint, CUnit::GroupId, CUnitType::Ident, MakeUnitAndPlace(), NoUnitP, CPlayer::NumBuildings, OnTopDetails(), CUnit::Orders, CBuildRestrictionOnTop::Parent, CUnit::Player, PlayerNumNeutral, Players, CUnit::PlayerSlot, RemoveUnitFromGroups(), CBuildRestrictionOnTop::ReplaceOnDie, CUnit::ResourcesHeld, CUnitType::Slot, CPlayer::TotalNumUnits, CUnit::Type, UnitActionBuilt, UnitHoldsResources(), UnitMax, UnitNumber, CPlayer::Units, CPlayer::UnitTypesCount, CUnitType::Vanishes, CUnit::X, and CUnit::Y.
Referenced by Capture::Cast(), Polymorph::Cast(), CUnit::ChangeOwner(), DestroyAllInside(), EditorActionPlaceUnit(), EditorActionRemoveUnit(), LetUnitDie(), and StartBuilding().
| CUnit* UnitOnMapTile | ( | int | tx, | |
| int | ty, | |||
| unsigned | type | |||
| ) |
Return possible attack target on that map area.
Unit on map tile.
| tx | X position on map, tile-based. | |
| ty | Y position on map, tile-based. | |
| type | UnitTypeType, (unsigned)-1 for any type. |
Definition at line 136 of file unit_find.cpp.
References NoUnitP, CUnitCache::Select(), UnitCache, and UnitMax.
Referenced by ClosestFreeCoast(), CostMoveTo(), EditorRedoAction(), EditorUndoAction(), UIHandleButtonDown(), and UIHandleMouseMove().
| CUnit* UnitOnScreen | ( | int | x, | |
| int | y | |||
| ) |
Check if a unit should be removed from UnitsConsumingResources.
Select unit on screen. (x, y are in pixels relative to map 0,0).
| x | X pixel position. | |
| y | Y pixel position. |
Definition at line 1865 of file unit.cpp.
References CUnitType::BoxHeight, CUnitType::BoxWidth, CUnitType::DrawLevel, CUnit::IsVisibleAsGoal(), CUnit::IX, CUnit::IY, NumUnits, ReplayRevealMap, ThisPlayer, CUnitType::TileHeight, TileSizeX, TileSizeY, CUnitType::TileWidth, CUnit::Type, CUnit::X, and CUnit::Y.
Referenced by EditorCallbackMouse(), UIHandleButtonUp(), and UIHandleMouseMove().
| std::string UnitReference | ( | const CUnit * | unit | ) |
Save an order.
Generate a unit reference, a printable unique string for unit.
Definition at line 55 of file unit_save.cpp.
References UnitNumber.
Referenced by SaveGroups(), Missile::SaveMissile(), SaveOrder(), SaveSelections(), and SaveUnit().
| void UnitRemoveConsumingResources | ( | CUnit * | unit | ) |
Let a unit die.
Check if a unit should be removed from UnitsConsumingResources
Definition at line 1908 of file unit.cpp.
References CUnitType::BuilderOutside, CUnit::_order_data_::_order_harvest_::CurrentProduction, CUnit::Data, CUnit::_order_data_::Harvest, MaxCosts, CUnit::Orders, CUnit::Player, CPlayer::ProductionRate, CPlayer::RemoveFromUnitsConsumingResources(), CUnit::SubAction, CUnit::Type, UnitActionBuild, UnitActionRepair, UnitActionResource, and UnitActionTrain.
Referenced by HandleUnitAction(), and LetUnitDie().
| void UnitsOnTileMarkSeen | ( | const CPlayer * | player, | |
| int | x, | |||
| int | y | |||
| ) |
Unmarks a unit as seen.
Mark all units on a tile as now visible.
| player | The player this is for. | |
| x | x location to check | |
| y | y location to check |
Definition at line 944 of file unit.cpp.
References CPlayer::Index, CPlayer::IsBothSharedVision(), CUnit::IsVisible(), PlayerMax, Players, CUnitCache::Select(), UnitCache, UnitGoesOutOfFog(), UnitMax, and CUnit::VisCount.
Referenced by MapMarkTileSight().
| void UnitsOnTileUnmarkSeen | ( | const CPlayer * | player, | |
| int | x, | |||
| int | y | |||
| ) |
Does a recount for VisCount.
This function unmarks units on x, y as seen. It uses a reference count.
| player | The player to mark for. | |
| x | x location to check if building is on, and mark as seen | |
| y | y location to check if building is on, and mark as seen |
Definition at line 975 of file unit.cpp.
References Assert, CPlayer::Index, CPlayer::IsBothSharedVision(), CUnit::IsVisible(), PlayerMax, Players, CUnitCache::Select(), CUnitType::TileHeight, CUnitType::TileWidth, CUnit::Type, UnitCache, UnitGoesUnderFog(), UnitMax, CUnit::VisCount, CUnit::X, and CUnit::Y.
Referenced by MapUnmarkTileSight().
| void UnitUpdateHeading | ( | CUnit * | unit | ) |
Heading and frame from delta direction x,y.
Update sprite frame for new heading.
Definition at line 1448 of file unit.cpp.
References CUnitType::Building, CUnit::Direction, CUnit::Frame, LookingS, CUnitType::NumDirections, and CUnit::Type.
Referenced by DoActionMove(), HandleActionBuilt(), HandleActionDie(), HandleActionFollow(), CUnit::Init(), StartBuilding(), UnitHeadingFromDeltaXY(), UnitRotate(), and UnitShowAnimationScaled().
| void UnmarkUnitFieldFlags | ( | const CUnit * | unit | ) |
Update unit->CurrentSightRange.
Mark the field with the FieldFlags.
| unit | unit to mark. |
Definition at line 483 of file unit.cpp.
References CMap::Field(), CUnitType::FieldFlags, CMapField::Flags, Map, CUnit::Orders, CUnitCache::Select(), CUnitType::TileHeight, CUnitType::TileWidth, CUnit::Type, UnitActionDie, UnitCache, UnitMax, CUnit::X, and CUnit::Y.
Referenced by CanBuildUnitType(), DoActionMove(), CUnit::MoveToXY(), and CUnit::Remove().
| void UnSelectAll | ( | void | ) |
Select group as selection.
Unselect all the units in the current selection
Definition at line 122 of file selection.cpp.
References GroupId, NoUnitP, NumSelected, and CUnit::Selected.
Referenced by ChangeSelectedUnits(), RestoreSelection(), SelectGroupFromUnit(), SelectUnitsByType(), and UiUnselectAll().
| void UnSelectUnit | ( | CUnit * | unit | ) |
Add a unit to selected if not already selected, remove it otherwise.
Unselect unit
| unit | Pointer to unit to be unselected. |
Definition at line 270 of file selection.cpp.
References Assert, GroupId, CUnit::LastGroup, NoUnitP, NumSelected, PlayerMax, CUnit::Selected, TeamNumSelected, and CUnit::TeamSelected.
Referenced by DoActionMove(), CUnit::Remove(), and ToggleSelectUnit().
| void UpdateForNewUnit | ( | const CUnit * | unit, | |
| int | upgrade | |||
| ) |
| unit | New unit pointer. | |
| upgrade | True unit was upgraded. |
Definition at line 805 of file unit.cpp.
References MaxCosts, CUnit::Player, CUnit::ProductionEfficiency, CUnitType::ProductionRate, CPlayer::ProductionRate, CUnitType::StorageCapacity, CPlayer::StorageCapacity, and CUnit::Type.
Referenced by CclCreateUnit(), CclUnit(), CUnit::ChangeOwner(), HandleActionBuilt(), and HandleActionTrain().
| void UpdateUnitSightRange | ( | CUnit * | unit | ) |
Create a new unit.
Update the Unit Current sight range to good value and transported units inside.
| unit | unit to update SightRange |
Definition at line 435 of file unit.cpp.
References Assert, CUnit::Constructed, CUnit::Container, CUnit::CurrentSightRange, CUnit::InsideCount, CVariable::Max, CUnit::NextContained, SaveGameLoading, SIGHTRANGE_INDEX, CUnit::Stats, CUnit::UnitInside, UpdateUnitSightRange(), and CUnitStats::Variables.
Referenced by CUnit::ChangeOwner(), CUnit::Place(), CUnit::Remove(), and UpdateUnitSightRange().
| int ViewPointDistance | ( | int | x, | |
| int | y | |||
| ) |
Calculate the distance from current view point to unit.
Compute the distance from the view point to a given point.
| x | X map tile position. | |
| y | Y map tile position. |
Definition at line 2391 of file unit.cpp.
References MapDistance(), CViewport::MapHeight, CViewport::MapWidth, CViewport::MapX, CViewport::MapY, CUserInterface::SelectedViewport, and UI.
Referenced by ViewPointDistanceToMissile().
| int ViewPointDistanceToUnit | ( | const CUnit * | dest | ) |
Can this unit-type attack the other (destination).
Compute the distance from the view point to a given unit.
| dest | Distance to this unit. |
Definition at line 2410 of file unit.cpp.
References MapDistanceToUnit(), CViewport::MapHeight, CViewport::MapWidth, CViewport::MapX, CViewport::MapY, CUserInterface::SelectedViewport, and UI.
Referenced by PlayUnitSound().
| const CViewport* CurrentViewport |
CurrentViewport.
Definition at line 104 of file unit_draw.cpp.
Referenced by CViewport::Draw(), and Missile::DrawMissile().
Config: building capture enabled.
Definition at line 73 of file unit.cpp.
Referenced by CclSetBuildingCapture(), and HitUnit().
| int MaxSelectable |
How many units could be selected.
Definition at line 61 of file selection.cpp.
Referenced by AddGroupFromUnitToSelection(), AddSelectedAirUnitsInRectangle(), AddSelectedGroundUnitsInRectangle(), AddSelectedUnitsInRectangle(), AddToGroup(), CclSetMaxSelectable(), ChangeSelectedUnits(), ChangeTeamSelectedUnits(), InitGroups(), InitSelections(), SelectAirUnitsInRectangle(), SelectGroundUnitsInRectangle(), SelectOrganicUnitsInTable(), SelectUnit(), SelectUnitsByType(), and SetGroup().
| int NumSelected |
how many units selected
Definition at line 59 of file selection.cpp.
Referenced by AddGroupFromUnitToSelection(), AddSelectedAirUnitsInRectangle(), AddSelectedGroundUnitsInRectangle(), AddSelectedUnitsInRectangle(), CclSelection(), ChangeSelectedUnits(), CleanSelections(), DoActionMove(), CButtonPanel::DoClicked(), DoRightButton(), DoSelectionButtons(), CViewport::Draw(), CInfoPanel::Draw(), CButtonPanel::Draw(), DrawBuildingCursor(), DrawInfoPanelMultipleSelected(), DrawInformations(), DrawUnitInfo(), GetButtonStatus(), HandleMouseOn(), CUnit::Remove(), RestoreSelection(), SaveSelection(), SaveSelections(), SelectGroup(), SelectUnit(), SelectUnitsByType(), SendAttack(), SendAttackGround(), SendCommand(), SendMove(), SendPatrol(), SendRepair(), SendResource(), SendSpellCast(), SendUnload(), ToggleUnitsByType(), UiAddToGroup(), UiCenterOnSelected(), UiDefineGroup(), UIHandleButtonDown(), UIHandleButtonUp(), UnSelectAll(), UnSelectUnit(), CButtonPanel::Update(), and UpdateButtonPanelMultipleUnits().
| int NumUnits |
Number of units used.
Definition at line 71 of file unit.cpp.
Referenced by AddGroupFromUnitToSelection(), AiMoveUnitInTheWay(), CclGetUnits(), CclKillUnit(), CPlayer::CheckLimits(), CleanUnits(), CommandSharedVision(), CreateGame(), FindUnitsByType(), HandleActionTrain(), CUnit::Init(), InitUnits(), LoadGame(), MakeUnit(), CUnit::Release(), RemoveUnitFromGroups(), CMap::Reveal(), SaveGroups(), SaveUnits(), UiAddGroupToSelection(), UnitActions(), UnitOnScreen(), CMinimap::Update(), UpdateFogOfWarChange(), and WriteMapSetup().
Definition at line 63 of file script_ui.cpp.
Referenced by DoRightButton(), CViewport::Draw(), DrawInformations(), SendCommand(), tolua_get_Preference(), tolua_set_Preference(), and UIHandleButtonDown().
currently selected units
Definition at line 62 of file selection.cpp.
Referenced by CUnit::ClearAction(), CButtonPanel::DoClicked(), DoRightButton(), DoSelectionButtons(), CViewport::Draw(), CButtonPanel::Draw(), DrawBuildingCursor(), DrawInfoPanelMultipleSelected(), DrawInfoPanelSingleSelected(), DrawPieMenu(), DrawUnitInfo(), GetButtonStatus(), HandleMouseOn(), CUnit::Init(), IsButtonAllowed(), SendAttack(), SendAttackGround(), SendCommand(), SendMove(), SendPatrol(), SendRepair(), SendResource(), SendSpellCast(), SendUnload(), UiAddGroupToSelection(), UiAddToGroup(), UiCenterOnSelected(), UiDefineGroup(), UiFindIdleWorker(), UIHandleButtonDown(), UIHandleButtonUp(), UiTrackUnit(), CButtonPanel::Update(), and UpdateButtonPanelMultipleUnits().
| unsigned long ShowOrdersCount |
Show orders for some time.
Definition at line 90 of file unit_draw.cpp.
Referenced by DoRightButton(), CViewport::Draw(), and SendCommand().
| int TeamNumSelected[PlayerMax] |
Number of Units a team member has selected.
Definition at line 60 of file selection.cpp.
Referenced by ChangeTeamSelectedUnits(), CleanSelections(), RestoreSelection(), SaveSelection(), and UnSelectUnit().
| CUnit** TeamSelected[PlayerMax] |
teams currently selected units
Definition at line 63 of file selection.cpp.
Referenced by CUnit::Init().
Units used.
Definition at line 70 of file unit.cpp.
Referenced by AddGroupFromUnitToSelection(), AiMoveUnitInTheWay(), CclGetUnits(), CclKillUnit(), CommandSharedVision(), CreateGame(), FindUnitsByType(), InitGroups(), LoadGame(), NetworkProcessSelection(), CMap::Reveal(), SaveGroups(), SaveUnits(), UnitActions(), CMinimap::Update(), UpdateFogOfWarChange(), and WriteMapSetup().
1.5.6