OpenXcom  1.0
Open-source clone of the original X-Com
Public Member Functions | List of all members
OpenXcom::Ufo Class Reference

Represents an alien UFO on the map. More...

#include <Ufo.h>

Inheritance diagram for OpenXcom::Ufo:
OpenXcom::MovingTarget OpenXcom::Target

Public Member Functions

 Ufo (const RuleUfo *rules)
 Creates a UFO of the specified type. More...
 
 ~Ufo ()
 Cleans up the UFO. More...
 
void load (const YAML::Node &node, const Mod &ruleset, SavedGame &game)
 Loads the UFO from YAML. More...
 
YAML::Node save (bool newBattle) const
 Saves the UFO to YAML. More...
 
std::string getType () const
 Gets the UFO's type. More...
 
const RuleUfogetRules () const
 Gets the UFO's ruleset. More...
 
void changeRules (const RuleUfo *rules)
 Sets the UFO's ruleset. More...
 
std::string getDefaultName (Language *lang) const
 Gets the UFO's default name. More...
 
std::string getMarkerName () const
 Gets the UFO's marker name. More...
 
int getMarker () const
 Gets the UFO's marker sprite. More...
 
int getDamage () const
 Gets the UFO's amount of damage. More...
 
void setDamage (int damage)
 Sets the UFO's amount of damage. More...
 
bool getDetected () const
 Gets the UFO's detection status. More...
 
void setDetected (bool detected)
 Sets the UFO's detection status. More...
 
size_t getSecondsRemaining () const
 Gets the UFO's seconds left on the ground. More...
 
void setSecondsRemaining (size_t seconds)
 Sets the UFO's seconds left on the ground. More...
 
std::string getDirection () const
 Gets the UFO's direction. More...
 
std::string getAltitude () const
 Gets the UFO's altitude. More...
 
int getAltitudeInt () const
 Gets the UFO's altitude. More...
 
void setAltitude (const std::string &altitude)
 Sets the UFO's altitude. More...
 
enum UfoStatus getStatus () const
 Gets the UFO status.
 
void setStatus (enum UfoStatus status)
 Set the UFO's status.
 
bool isCrashed () const
 Gets if the UFO has crashed. More...
 
bool isDestroyed () const
 Gets if the UFO has been destroyed. More...
 
void think ()
 Handles UFO logic. More...
 
void setInBattlescape (bool inbattle)
 Sets the UFO's battlescape status. More...
 
bool isInBattlescape () const
 Gets if the UFO is in battlescape. More...
 
const std::string & getAlienRace () const
 Gets the UFO's alien race. More...
 
void setShotDownByCraftId (const CraftId &craftId)
 Sets the ID of craft which shot down the UFO.
 
CraftId getShotDownByCraftId () const
 Gets the ID of craft which shot down the UFO.
 
int getVisibility () const
 Gets the UFO's visibility. More...
 
const std::string & getMissionType () const
 Gets the UFO's Mission type. More...
 
void setMissionInfo (AlienMission *mission, const UfoTrajectory *trajectory)
 Sets the UFO's mission information. More...
 
bool getHyperDetected () const
 Gets the UFO's hyper detection status. More...
 
void setHyperDetected (bool hyperdetected)
 Sets the UFO's hyper detection status. More...
 
size_t getTrajectoryPoint () const
 Gets the UFO's progress on the trajectory track.
 
void setTrajectoryPoint (size_t np)
 Sets the UFO's progress on the trajectory track.
 
const UfoTrajectorygetTrajectory () const
 Gets the UFO's trajectory.
 
AlienMissiongetMission () const
 Gets the UFO's mission object.
 
void setDestination (Target *dest)
 Sets the UFO's destination. More...
 
int getShootingAt () const
 Get which interceptor this ufo is engaging. More...
 
void setShootingAt (int target)
 Set which interceptor this ufo is engaging. More...
 
int getLandId () const
 Gets the UFO's landing site ID. More...
 
void setLandId (int id)
 Sets the UFO's landing site ID. More...
 
int getCrashId () const
 Gets the UFO's crash site ID. More...
 
void setCrashId (int id)
 Sets the UFO's crash site ID. More...
 
void setHitFrame (int frame)
 Sets the UFO's hit frame. More...
 
int getHitFrame () const
 Gets the UFO's hit frame. More...
 
void setFireCountdown (int time)
 Sets the number of ticks until the ufo fires its weapon. More...
 
int getFireCountdown () const
 Gets the number of ticks until the ufo is ready to fire. More...
 
void setEscapeCountdown (int time)
 Sets the countdown timer for escaping a dogfight. More...
 
int getEscapeCountdown () const
 Gets the escape timer for dogfights. More...
 
void setInterceptionProcessed (bool processed)
 Sets a flag denoting that this ufo has had its timers decremented. More...
 
bool getInterceptionProcessed () const
 Gets if the ufo has had its timers decremented on this cycle of interception updates. More...
 
- Public Member Functions inherited from OpenXcom::MovingTarget
virtual ~MovingTarget ()
 Cleans up the moving target. More...
 
virtual void load (const YAML::Node &node)
 Loads the moving target from YAML. More...
 
virtual YAML::Node save () const
 Saves the moving target to YAML. More...
 
TargetgetDestination () const
 Gets the moving target's destination. More...
 
int getSpeed () const
 Gets the moving target's speed. More...
 
double getSpeedRadian () const
 Gets the moving target's radial speed. More...
 
void setSpeed (int speed)
 Sets the moving target's speed. More...
 
bool reachedDestination () const
 Has the moving target reached its destination? More...
 
void move ()
 Move towards the destination. More...
 
void calculateMeetPoint ()
 Calculate meeting point with the target.
 
double getMeetLatitude () const
 Returns the latitude of the meeting point. More...
 
double getMeetLongitude () const
 Returns the longitude of the meeting point. More...
 
void resetMeetPoint ()
 Reset meeting point calculation. More...
 
bool isMeetCalculated () const
 Returns if the meeting point was calculated.
 
- Public Member Functions inherited from OpenXcom::Target
virtual ~Target ()
 Cleans up the target. More...
 
YAML::Node saveId () const
 Saves the target's ID to YAML. More...
 
double getLongitude () const
 Gets the target's longitude. More...
 
void setLongitude (double lon)
 Sets the target's longitude. More...
 
double getLatitude () const
 Gets the target's latitude. More...
 
void setLatitude (double lat)
 Sets the target's latitude. More...
 
int getId () const
 Gets the target's ID. More...
 
void setId (int id)
 Sets the target's ID. More...
 
virtual std::string getName (Language *lang) const
 Gets the target's name. More...
 
void setName (const std::string &newName)
 Sets the target's name. More...
 
std::vector< MovingTarget * > * getFollowers ()
 Gets the target's followers. More...
 
std::vector< Craft * > getCraftFollowers () const
 Gets the target's craft followers. More...
 
double getDistance (const Target *target) const
 Gets the distance to another target. More...
 

Additional Inherited Members

- Protected Member Functions inherited from OpenXcom::MovingTarget
 MovingTarget ()
 Creates a moving target. More...
 
- Protected Member Functions inherited from OpenXcom::Target
 Target ()
 Creates a target. More...
 
- Static Protected Member Functions inherited from OpenXcom::MovingTarget
static double calculateRadianSpeed (int speed)
 Converts a speed to radians. More...
 

Detailed Description

Represents an alien UFO on the map.

Contains variable info about a UFO like position, damage, speed, etc.

See also
RuleUfo

Constructor & Destructor Documentation

◆ Ufo()

OpenXcom::Ufo::Ufo ( const RuleUfo rules)

Creates a UFO of the specified type.

Initializes a UFO of the specified type.

Parameters
rulesPointer to ruleset.

◆ ~Ufo()

OpenXcom::Ufo::~Ufo ( )

Cleans up the UFO.

Make sure our mission forget's us, and we only delete targets we own (waypoints).

Member Function Documentation

◆ changeRules()

void OpenXcom::Ufo::changeRules ( const RuleUfo rules)

Sets the UFO's ruleset.

Changes the ruleset for the UFO's type.

Parameters
rulesPointer to ruleset.
Warning
ONLY FOR NEW BATTLE USE!

◆ getAlienRace()

const std::string & OpenXcom::Ufo::getAlienRace ( ) const

Gets the UFO's alien race.

Returns the alien race currently residing in the UFO.

Returns
Alien race.

◆ getAltitude()

std::string OpenXcom::Ufo::getAltitude ( ) const

Gets the UFO's altitude.

Returns the current altitude of the UFO.

Returns
Altitude as string ID.

◆ getAltitudeInt()

int OpenXcom::Ufo::getAltitudeInt ( ) const

Gets the UFO's altitude.

Returns the current altitude of the UFO.

Returns
Altitude as integer (0-4).

◆ getCrashId()

int OpenXcom::Ufo::getCrashId ( ) const

Gets the UFO's crash site ID.

Returns
the UFO's crash site ID.

◆ getDamage()

int OpenXcom::Ufo::getDamage ( ) const

Gets the UFO's amount of damage.

Returns the amount of damage this UFO has taken.

Returns
Amount of damage.

◆ getDefaultName()

std::string OpenXcom::Ufo::getDefaultName ( Language lang) const
virtual

Gets the UFO's default name.

Returns the UFO's unique default name.

Parameters
langLanguage to get strings from.
Returns
Full name.

Reimplemented from OpenXcom::Target.

◆ getDetected()

bool OpenXcom::Ufo::getDetected ( ) const

Gets the UFO's detection status.

Returns whether this UFO has been detected by radars.

Returns
Detection status.

◆ getDirection()

std::string OpenXcom::Ufo::getDirection ( ) const

Gets the UFO's direction.

Returns the current direction the UFO is heading in.

Returns
Direction.

◆ getEscapeCountdown()

int OpenXcom::Ufo::getEscapeCountdown ( ) const

Gets the escape timer for dogfights.

Returns
how many ticks until the ship tries to leave.

◆ getFireCountdown()

int OpenXcom::Ufo::getFireCountdown ( ) const

Gets the number of ticks until the ufo is ready to fire.

Returns
ticks until weapon is ready.

◆ getHitFrame()

int OpenXcom::Ufo::getHitFrame ( ) const

Gets the UFO's hit frame.

Returns
the hit frame.

◆ getHyperDetected()

bool OpenXcom::Ufo::getHyperDetected ( ) const

Gets the UFO's hyper detection status.

Returns whether this UFO has been detected by hyper-wave.

Returns
Detection status.

◆ getInterceptionProcessed()

bool OpenXcom::Ufo::getInterceptionProcessed ( ) const

Gets if the ufo has had its timers decremented on this cycle of interception updates.

Returns
if this ufo has already been processed.

◆ getLandId()

int OpenXcom::Ufo::getLandId ( ) const

Gets the UFO's landing site ID.

Returns
landing site ID.

◆ getMarker()

int OpenXcom::Ufo::getMarker ( ) const
virtual

Gets the UFO's marker sprite.

Returns the globe marker for the UFO.

Returns
Marker sprite, -1 if none.

Implements OpenXcom::Target.

◆ getMarkerName()

std::string OpenXcom::Ufo::getMarkerName ( ) const
virtual

Gets the UFO's marker name.

Returns the name on the globe for the UFO.

Returns
String ID.

Reimplemented from OpenXcom::Target.

◆ getMissionType()

const std::string & OpenXcom::Ufo::getMissionType ( ) const

Gets the UFO's Mission type.

Returns the Mission type of the UFO.

Returns
Mission.

◆ getRules()

const RuleUfo * OpenXcom::Ufo::getRules ( ) const

Gets the UFO's ruleset.

Returns the ruleset for the UFO's type.

Returns
Pointer to ruleset.

◆ getSecondsRemaining()

size_t OpenXcom::Ufo::getSecondsRemaining ( ) const

Gets the UFO's seconds left on the ground.

Returns the amount of remaining seconds the UFO has left on the ground.

After this many seconds thet UFO will take off, if landed, or disappear, if crashed.

Returns
Amount of seconds.

◆ getShootingAt()

int OpenXcom::Ufo::getShootingAt ( ) const

Get which interceptor this ufo is engaging.

Gets which interception window the UFO is active in.

Returns
which interception window the UFO is active in.

◆ getType()

std::string OpenXcom::Ufo::getType ( ) const
virtual

Gets the UFO's type.

Returns the UFO's unique type used for savegame purposes.

Returns
ID.

Implements OpenXcom::Target.

◆ getVisibility()

int OpenXcom::Ufo::getVisibility ( ) const

Gets the UFO's visibility.

Returns a UFO's visibility to radar detection.

The UFO's size and altitude affect the chances of it being detected by radars.

Returns
Visibility modifier.

◆ isCrashed()

bool OpenXcom::Ufo::isCrashed ( ) const

Gets if the UFO has crashed.

Returns if this UFO took enough damage to cause it to crash.

Returns
Crashed status.

◆ isDestroyed()

bool OpenXcom::Ufo::isDestroyed ( ) const

Gets if the UFO has been destroyed.

Returns if this UFO took enough damage to cause it to crash.

Returns
Crashed status.

◆ isInBattlescape()

bool OpenXcom::Ufo::isInBattlescape ( ) const

Gets if the UFO is in battlescape.

Gets the UFO's battlescape status.

Returns
Is the UFO currently in battle?

◆ load()

void OpenXcom::Ufo::load ( const YAML::Node &  node,
const Mod mod,
SavedGame game 
)

Loads the UFO from YAML.

Loads the UFO from a YAML file.

Parameters
nodeYAML node.
modThe game mod. Use to access the trajectory rules.
gameThe game data. Used to find the UFO's mission.

◆ save()

YAML::Node OpenXcom::Ufo::save ( bool  newBattle) const

Saves the UFO to YAML.

Saves the UFO to a YAML file.

Returns
YAML node.

◆ setAltitude()

void OpenXcom::Ufo::setAltitude ( const std::string &  altitude)

Sets the UFO's altitude.

Changes the current altitude of the UFO.

Parameters
altitudeAltitude.

◆ setCrashId()

void OpenXcom::Ufo::setCrashId ( int  id)

Sets the UFO's crash site ID.

Parameters
idthe UFO's crash site ID.

◆ setDamage()

void OpenXcom::Ufo::setDamage ( int  damage)

Sets the UFO's amount of damage.

Changes the amount of damage this UFO has taken.

Parameters
damageAmount of damage.

◆ setDestination()

void OpenXcom::Ufo::setDestination ( Target dest)
virtual

Sets the UFO's destination.

Handle destination changes, making sure to delete old waypoint destinations.

Parameters
destPointer to the new destination.

Reimplemented from OpenXcom::MovingTarget.

◆ setDetected()

void OpenXcom::Ufo::setDetected ( bool  detected)

Sets the UFO's detection status.

Changes whether this UFO has been detected by radars.

Parameters
detectedDetection status.

◆ setEscapeCountdown()

void OpenXcom::Ufo::setEscapeCountdown ( int  time)

Sets the countdown timer for escaping a dogfight.

Parameters
timehow many ticks until the ship attempts to escape.

◆ setFireCountdown()

void OpenXcom::Ufo::setFireCountdown ( int  time)

Sets the number of ticks until the ufo fires its weapon.

Parameters
timenumber of ticks until refire.

◆ setHitFrame()

void OpenXcom::Ufo::setHitFrame ( int  frame)

Sets the UFO's hit frame.

Parameters
framethe hit frame.

◆ setHyperDetected()

void OpenXcom::Ufo::setHyperDetected ( bool  hyperdetected)

Sets the UFO's hyper detection status.

Changes whether this UFO has been detected by hyper-wave.

Parameters
hyperdetectedDetection status.

◆ setInBattlescape()

void OpenXcom::Ufo::setInBattlescape ( bool  inbattle)

Sets the UFO's battlescape status.

Parameters
inbattleTrue if it's in battle, False otherwise.

◆ setInterceptionProcessed()

void OpenXcom::Ufo::setInterceptionProcessed ( bool  processed)

Sets a flag denoting that this ufo has had its timers decremented.

prevents multiple interceptions from decrementing or resetting an already running timer. this flag is reset in advance each time the geoscape processes the dogfights.

Parameters
processedwhether or not we've had our timers processed.

◆ setLandId()

void OpenXcom::Ufo::setLandId ( int  id)

Sets the UFO's landing site ID.

Parameters
idlanding site ID.

◆ setMissionInfo()

void OpenXcom::Ufo::setMissionInfo ( AlienMission mission,
const UfoTrajectory trajectory 
)

Sets the UFO's mission information.

Sets the mission information of the UFO.

The UFO will start at the first point of the trajectory. The actual UFO information is not changed here, this only sets the information kept on behalf of the mission.

Parameters
missionPointer to the actual mission object.
trajectoryPointer to the actual mission trajectory.

◆ setSecondsRemaining()

void OpenXcom::Ufo::setSecondsRemaining ( size_t  seconds)

Sets the UFO's seconds left on the ground.

Changes the amount of remaining seconds the UFO has left on the ground.

After this many seconds thet UFO will take off, if landed, or disappear, if crashed.

Parameters
secondsAmount of seconds.

◆ setShootingAt()

void OpenXcom::Ufo::setShootingAt ( int  target)

Set which interceptor this ufo is engaging.

Sets which interception window the UFO is active in.

Parameters
targetthe window the UFO is active in.

◆ think()

void OpenXcom::Ufo::think ( )

Handles UFO logic.

Moves the UFO to its destination.


The documentation for this class was generated from the following files: