_________ __ __
/ _____// |_____________ _/ |______ ____ __ __ ______
\_____ \\ __\_ __ \__ \\ __\__ \ / ___\| | \/ ___/
/ \| | | | \// __ \| | / __ \_/ /_/ > | /\___ \
/_______ /|__| |__| (____ /__| (____ /\___ /|____//____ >
\/ \/ \//_____/ \/
______________________ ______________________
T H E W A R B E G I N S
Stratagus - A free fantasy real time strategy game engine
#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 "sound.h"#include "sound_server.h"#include "spells.h"#include "translate.h"#include "ui.h"#include "unit_find.h"#include "unit_manager.h"#include "unitsound.h"#include "unittype.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... | |
| CUnit * | MakeUnit (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) |
| CUnit * | GetFirstContainer (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 | 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) |
| CUnit * | MakeUnitAndPlace (const Vec2i &pos, const CUnitType &type, CPlayer *player) |
| Create a new unit and place on map. 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... | |
| CUnit * | UnitOnScreen (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... | |
| 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... | |
Can this unit-type attack the other (destination)
Can the source unit attack the destination unit.
| source | Unit type pointer of the attacker. |
| dest | Unit type pointer of the target. |
Can transporter transport the other unit.
Can the transporter transport the other unit.
| transporter | Unit which is the transporter. |
| unit | Unit which wants to go in the transporter. |
Change the owner of all units of a player.
| oldplayer | Old owning player. |
| newplayer | New owning player. |
| void CleanUnits | ( | ) |
Clean unit module.
Clean up unit module.
| void CorrectWallDirections | ( | CUnit & | unit | ) |
Correct directions for placed wall.
Correct direction for placed wall.
| unit | The wall unit. |
| void CorrectWallNeighBours | ( | CUnit & | unit | ) |
Correct the surrounding walls.
Correct the surrounding walls.
| unit | The wall unit. |
| void DestroyAllInside | ( | CUnit & | source | ) |
Destroy all units inside another unit.
Destroy all units inside unit.
| source | container. |
| int DirectionToHeading | ( | const Vec2i & | delta | ) |
Convert direction (dx,dy) to heading (0-255)
Convert direction to heading.
| delta | Delta. |
| int DirectionToHeading | ( | const PixelDiff & | delta | ) |
Convert direction (dx,dy) to heading (0-255)
Convert direction to heading.
| delta | Delta. |
| void DropOutAll | ( | const CUnit & | source | ) |
Drop out all units in the unit.
Drop out all units inside unit.
| source | All units inside source are dropped out. |
Place a unit on the map nearest to goalPos.
| unit | Unit to drop out. |
| goalPos | Goal map tile position. |
| addx | Tile width of unit it's dropping out of. |
| addy | Tile height of unit it's dropping out of. |
Place a unit on the map to the side of a unit.
| unit | Unit to drop out. |
| heading | Direction in which the unit should appear. |
| container | Unit "containing" unit to drop (may be different of unit.Container). |
| int ExtraDeathIndex | ( | const char * | death | ) |
Get the suitable animation frame depends of unit's damaged type.
Find the index of a extra death type
Return the unit not transported, by viewing the container recursively.
| unit | unit from where look the first conatiner. |
Hit unit with damage, if destroyed give attacker the points.
Unit is hit by missile or other damage.
| attacker | Unit that attacks. |
| target | Unit that is hit. |
| damage | How many damage to take. |
| missile | Which missile took the damage. |
|
static |
|
static |
|
static |
|
static |
| void InitUnits | ( | ) |
Initialize unit module.
Initialize unit module.
| void LetUnitDie | ( | CUnit & | unit, |
| bool | suicide | ||
| ) |
Let a unit die.
Let an unit die.
| unit | Unit to be destroyed. |
Create a new unit.
Create a new unit.
| type | Pointer to unit-type. |
| player | Pointer to owning player. |
Create a new unit and place on map.
Create new unit and place on map.
| pos | map tile position. |
| type | Pointer to unit-type. |
| player | Pointer to owning player. |
| 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.
| src | src unittype |
| pos1 | map tile position of src (upperleft). |
| dst | Unit type to take into account. |
| pos2 | map tile position of dst. |
| 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)
| unit | unit to unmark its vision. |
|
static |
(Un)Mark on vision table the Sight of the unit (and units inside for transporter (recursively))
| unit | Unit to (un)mark. |
| pos | coord of first container of unit. |
| width | Width of the first container of unit. |
| height | Height of the first container of unit. |
| f | Function to (un)mark for normal vision. |
| f2 | Function to (un)mark for cloaking vision. |
| 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)
| unit | unit to unmark its vision. |
| void MarkUnitFieldFlags | ( | const CUnit & | unit | ) |
currently selected units
Mark the field with the FieldFlags.
| unit | unit to mark. |
|
static |
Fast arc tangent function.
| val | atan argument |
Find nearest point of unit.
| unit | Pointer to unit. |
| pos | tile map position. |
| dpos | Out: nearest point tile map position to (tx,ty). |
|
static |
Last Y coordinate HelpMe sound played.
Remove unit from a container. It only updates linked list stuff.
| unit | Pointer to unit. |
| void RescueUnits | ( | ) |
Check for rescue each second.
Rescue units.
Look through all rescueable players, if they could be rescued.
Calculate some value to measure the unit's priority for AI.
| void UnitClearOrders | ( | CUnit & | unit | ) |
Remove the Orders of a Unit.
Removes all orders from a unit.
| unit | The unit that will have all its orders cleared |
| 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.
| unit | pointer to the unit to check if seen |
|
static |
Copy the unit look in Seen variables. This should be called when buildings go under fog of war for ThisPlayer.
| unit | The unit to work on |
Call when an Unit goes out of fog.
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. |
Call when an Unit goes under 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. |
Heading and frame from delta direction.
Change unit heading/frame from delta direction x, y.
| unit | Unit for new direction looking. |
| delta | map tile delta direction. |
Affect Tile coord of a unit (with units inside) to tile (x, y).
| unit | unit to move. |
| pos | map tile position. |
| void UnitLost | ( | CUnit & | unit | ) |
Handle the loss of a unit (food,...)
Update information for lost units.
| unit | Pointer to unit. |
| 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.
| x | X pixel position. |
| y | Y pixel position. |
| void UnitUpdateHeading | ( | CUnit & | unit | ) |
Update frame from heading.
Update sprite frame for new heading.
| void UnmarkUnitFieldFlags | ( | const CUnit & | unit | ) |
Unmark the field with the FieldFlags.
Mark the field with the FieldFlags.
| unit | unit to mark. |
| void UpdateForNewUnit | ( | const CUnit & | unit, |
| int | upgrade | ||
| ) |
Update for new unit. Food and income ...
| unit | New unit pointer. |
| upgrade | True unit was upgraded. |
| void UpdateUnitSightRange | ( | CUnit & | unit | ) |
Update unit->CurrentSightRange.
Update the Unit Current sight range to good value and transported units inside.
| unit | unit to update SightRange |
| 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.
| pos | map tile position. |
| 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.
| dest | Distance to this unit. |
| bool EnableBuildingCapture |
Config: training queues enabled.
| bool EnableTrainingQueue |
Show unit's name for some time.
|
static |
Config: spend resources for building with multiple workers.
|
static |
Last cycle HelpMe sound played.
|
static |
Last X coordinate HelpMe sound played.
| int ResourcesMultiBuildersMultiplier = 0 |
Config: reveal attacker enabled.
| bool RevealAttacker |
Config: capture buildings enabled.
Config: building capture enabled.
1.8.9.1
(C) Copyright 1998-2012 by The Stratagus Project under the GNU General Public License.