Vehicle Class Reference

#include <vehicle.h>

Inheritance diagram for Vehicle:

Inheritance graph
[legend]
List of all members.

Public Member Functions

 Vehicle (const VehicleType *t, GameMap *actmap, int player)
int repairableDamage () const
 returns the amount of damate that can still be repaired this turn
bool isBuilding () const
const VehicleTypegetType () const
void setAttacked ()
 the the unit and all cargo to attacked = true
void setAttacked (bool recursive, const Context &context)
 the the unit and (optionally) all cargo to attacked = true
int getArmor () const
bool spawnMoveObjects (const MapCoordinate &start, const MapCoordinate &dest, const Context &context)
 add the objects like tracks or broken ice
int getHeight () const
 returns the bitmapped level of height. Only one bit will be set, of course
ASCString getName () const
 returns the units name or, if it does not exist, the unit type's name or description
int getAmmo (int type, int num, bool queryOnly)
int getAmmo (int type, int num) const
int putAmmo (int type, int num, bool queryOnly)
int maxAmmo (int type) const
int size (void)
 Returns the size of a unit. A size is equal to the weight of the unit without any cargo or carried resources.
void beginTurn ()
 hook that called when the turn for a player starts
void endOwnTurn (void)
 hook that is called when a player ends his turn
void endAnyTurn (void)
 hook that is called when any player (including owner) ends turn
void endRound (void)
 hook that is called the next round begins ( active player switching from player8 to player1 )
int getIdentification () const
void setnewposition (int x, int y)
 sets the unit (and its cargo) the a new position (the unit will not be chained to a field)
void setnewposition (const MapCoordinate &mc)
void setnewposition (const MapCoordinate &mc, const Context &context)
void convert (int player, bool recursive=true)
 converts the unit so it is owned by 'player'.
void registerForNewOwner (int player)
 this is a low level functions that changes the registration in the map. It's called by convert(int,bool)
void setGeneratorStatus (bool status)
 sets the status of the unit's energy generator
bool getGeneratorStatus () const
void postAttack (bool reactionFire, const Context &context)
 callback that is called after the unit has attacked
void postAttack (bool reactionFire)
void addview ()
 adds the units view to the map.
void removeview ()
 removes the units view to the map.
void resetview ()
 resets the internal view state, so that addview() can be executed again
bool isViewing () const
 returns true if the units view is currently added to the maps global visibility.
const SingleWeapongetWeapon (unsigned weaponNum) const
 Returns the SingleWeapon corresponding to the weaponNum for this vehicle.
MapCoordinate3D getPosition () const
 returns the units position
MapCoordinate3D getPosition3D () const
 returns the units position; if inside building then Height is -1
bool canRepair (const ContainerBase *item) const
 can the unit repair anything? This does not necessarily mean that the unit can repair other units, because a service weapon is additionally needed for that.
void fillMagically (bool ammo=true, bool resources=true)
 fills a unit with all resources it can carry This function should only be called in the mapeditor !
void read (tnstream &stream)
 replaces the parameters of the unit by the ones form the stream.
void write (tnstream &stream, bool includeLoadedUnits=true) const
void paint (Surface &s, SPoint pos, int shadowDist=-1) const
 displays the unit at position spos on s
void paint (Surface &s, SPoint pos, bool shaded, int shadowDist=-1) const
virtual Surface getImage () const
 returns an image for the Container.
int getValueType (int uheight) const
 For the AI: calculating the ValueType if the unit was on the height uheight.
int getValueType () const
 For the AI: calculating the ValueType.
void transform (const VehicleType *type)
 to be used with EXTREME caution, and only in the mapeditor !!
const VehicleType::HeightChangeMethodgetHeightChange (int dir, int height=0) const
 returns the method for changing the height in the specified direction, or none if there is none.
bool weapexist () const
 Is the unit able to shoot ?
void prepareForCleanRemove ()
 ~Vehicle ()
int getMemoryFootprint () const
Movement related functions
bool canMove (void) const
 can the unit move from its current position (does not check neighbouring fields)
int getMovement (bool checkFuel=true, bool checkRF=true) const
 returns the movement points the unit has left for this turn. CheckFuel should almost always be true.
void setMovement (int newmove, double cargoDivisor=-1)
 sets a new distance that the unit can move
bool hasMoved (void) const
 did the unit move this turn
int maxMovement () const
 the maximum distance that the unit can drive in a single turn on the current level of height
void decreaseMovement (int movement)
 reduces the movement by the given amount.
void resetMovement (void)
 resets a units movement. This is called at the beginning of each turn.
Resource related functions
int putResource (int amount, int resourcetype, bool queryonly, int scope=1, int player=-1)
 scope: 0 = local 1 = resource network 2 = global in all buildings 3 = map wide pool( used only internally! )
int getResource (int amount, int resourcetype, bool queryonly, int scope=1, int player=-1)
int getAvailableResource (int amount, int resourcetype, int scope=1) const
Resources getResource (const Resources &res) const
Resources putResource (const Resources &res, bool queryonly, int scope=1, int player=-1)
Resources getResource (const Resources &res, bool queryonly, int scope=1, int player=-1)
Resources getTank () const
 returns the resources that the unit is carrying
Cargo related functions
int weight (void) const
 weight of unit including cargo
int freeWeight ()
 returns the free weight that can be used for cargo
Construction related functions
bool vehicleconstructable (const VehicleType *tnk, int x, int y)
 checks whether the unit can construct a vehicle of the given type at the given position.
Resources getExternalVehicleConstructionCost (const VehicleType *tnk) const

Static Public Member Functions

static VehiclenewFromStream (GameMap *gamemap, tnstream &stream, int forceNetworkID=-1)
 generates a new unit, loads its parameters from the stream (where they have been previously written with write) and returns this new unit.

Public Attributes

const VehicleTypetyp
int ammo [16]
int weapstrength [16]
int experience
bool attacked
 did the unit already attack this turn
int height
 the current level of height ( BITMAPPED ! )
char direction
 the direction in which the unit is facing
int xpos
 the position on the map
int ypos
int connection
 if events are triggered by this unit (if it is lost for example), this will set connection != 0
int networkid
 a unique identification of the unit that is used everywhere in ASC (and not only the network protocols where is was first used, hence the name)
Vehicle::ReactionFire reactionfire
 The class that manages the reaction fire which causes a unit to attack approaching enemies even if it is not the unit's turn.
AiParameteraiparam [8]

Protected Member Functions

const ResourceMatrixgetRepairEfficiency () const
 when a ContainerBase is repair by this ContainerBase, the default cost can be customized with this matrix.
virtual void postRepair (int oldDamage)
 is called after a repair is performed. Vehicles use this to reduce their experience.
vector< MapCoordinategetCoveredFields ()

Classes

class  ReactionFire
 The class that manages the reaction fire which causes a unit to attack approaching enemies even if it is not the unit's turn. More...

Detailed Description

Definition at line 46 of file vehicle.h.


Constructor & Destructor Documentation

Vehicle::Vehicle ( const VehicleType t,
GameMap actmap,
int  player 
)

Definition at line 61 of file vehicle.cpp.

References fatalError(), ContainerBase::gamemap, GameMap::IDManager::getNewNetworkID(), GameMap::idManager, networkid, GameMap::player, GameMap::IDManager::registerUnitNetworkID(), and Player::vehicleList.

Vehicle::~Vehicle (  ) 

Definition at line 100 of file vehicle.cpp.

References aiparam, GameMap::Destruction, ContainerBase::gamemap, removeview(), and GameMap::state.


Member Function Documentation

int Vehicle::repairableDamage (  )  const [inline, virtual]

returns the amount of damate that can still be repaired this turn

Implements ContainerBase.

Definition at line 79 of file vehicle.h.

References ContainerBase::damage.

bool Vehicle::isBuilding (  )  const [inline, virtual]

Implements ContainerBase.

Definition at line 81 of file vehicle.h.

const VehicleType* Vehicle::getType (  )  const [inline]

Definition at line 85 of file vehicle.h.

References typ.

void Vehicle::setAttacked (  ) 

the the unit and all cargo to attacked = true

Definition at line 933 of file vehicle.cpp.

References attacked, and ContainerBase::cargo.

void Vehicle::setAttacked ( bool  recursive,
const Context context 
)

the the unit and (optionally) all cargo to attacked = true

Definition at line 941 of file vehicle.cpp.

References ChangeUnitProperty::AttackedFlag, ContainerBase::cargo, ActionRegistry::ChangeUnitProperty, and GameAction::execute().

int Vehicle::getArmor (  )  const [virtual]

Implements ContainerBase.

Definition at line 1548 of file vehicle.cpp.

References VehicleType::armor, and typ.

Referenced by tmineattacksunit::setup().

bool Vehicle::canMove ( void   )  const

can the unit move from its current position (does not check neighbouring fields)

Definition at line 496 of file vehicle.cpp.

References Vehicle::ReactionFire::canMove(), cgp_movefrominvalidfields, ContainerBase::gamemap, ContainerBase::getCargo(), MapField::getContainer(), GameMap::getField(), ContainerBase::getMap(), getPosition(), reactionfire, terrainaccessible(), typ, MapField::unitHere(), ContainerBase::vehicleDocking(), and ContainerBase::vehicleUnloadable().

Referenced by MoveUnitCommand::avail(), CargoGuiFunctions::Movement::available(), CalculateThreat_Vehicle::calc_threat_vehicle(), AStar::findPath(), and paint().

int Vehicle::getMovement ( bool  checkFuel = true,
bool  checkRF = true 
) const

returns the movement points the unit has left for this turn. CheckFuel should almost always be true.

Definition at line 455 of file vehicle.cpp.

References Vehicle::ReactionFire::canMove(), Resources::fuel, VehicleType::fuelConsumption, minmalq, reactionfire, and typ.

Referenced by UnitHooveringLogic::calcFuelUsage(), trunreplay::execnextreplaymove(), StratAStar3D::getMoveCost(), StratAStar::getMoveCost(), MoveUnit::MoveUnit(), MoveUnit::runAction(), ChangeUnitMovement::runAction(), SaveUnitMovement::SaveUnitMovement(), MoveUnitCommand::searchFields(), DashboardPanel::showUnitData(), testActions(), testAttack1(), testCargoMovement(), testCargoMovementMax(), testMovement1(), ConstructUnitCommand::unitProductionPrerequisites(), and vehicleconstructable().

void Vehicle::setMovement ( int  newmove,
double  cargoDivisor = -1 
)

sets a new distance that the unit can move

Parameters:
cargoDivisor : the cargo of this unit gets 1/cargodivisor the change that this unit is getting; if 0 the cargo is not touched ; -1 is default

Definition at line 424 of file vehicle.cpp.

References ContainerBase::cargo, VehicleType::cargoMovementDivisor, ContainerBase::cargoNestingDepth(), getFirstBit(), height, max(), VehicleType::movement, and typ.

Referenced by UnitPropertyEditor::buttonpressed(), decreaseMovement(), Vehicle::ReactionFire::disable(), postAttack(), resetMovement(), SpawnUnit::runAction(), stu_height(), MoveUnit::undoAction(), and SaveUnitMovement::~SaveUnitMovement().

bool Vehicle::hasMoved ( void   )  const

did the unit move this turn

Definition at line 449 of file vehicle.cpp.

References getFirstBit(), height, VehicleType::movement, and typ.

Referenced by attackpossible2n(), DestructBuildingCommand::avail(), ConstructBuildingCommand::avail(), AttackCommand::avail(), and JumpDriveCommand::available().

int Vehicle::maxMovement (  )  const

the maximum distance that the unit can drive in a single turn on the current level of height

Definition at line 953 of file vehicle.cpp.

References getFirstBit(), height, VehicleType::movement, and typ.

Referenced by AStar3D::AStar3D(), UnitHooveringLogic::calcFuelUsage(), GuiFunctions::BuildVehicleCommand::execute(), AStar::findPath(), UnitHooveringLogic::getEndurance(), ConstructUnitCommand::go(), paint(), postAttack(), ChangeUnitMovement::runAction(), ConstructUnitCommand::unitProductionPrerequisites(), and vehicleconstructable().

void Vehicle::decreaseMovement ( int  movement  ) 

reduces the movement by the given amount.

Negative values are possible. Don't use something like "setmovement ( getmovement() - amount )", because getmovement may return a lower amount due to lack of fuel.

Definition at line 469 of file vehicle.cpp.

References getFirstBit(), height, VehicleType::movement, setMovement(), and typ.

Referenced by trunreplay::execnextreplaymove(), and postAttack().

void Vehicle::resetMovement ( void   ) 

resets a units movement. This is called at the beginning of each turn.

Definition at line 415 of file vehicle.cpp.

References getFirstBit(), height, move(), VehicleType::movement, setMovement(), and typ.

bool Vehicle::spawnMoveObjects ( const MapCoordinate start,
const MapCoordinate dest,
const Context context 
)

add the objects like tracks or broken ice

Returns:
true if any objects were created

Definition at line 518 of file vehicle.cpp.

References MapField::checkForObject(), chfahrend, ContainerBase::gamemap, getdirection(), GameMap::getField(), ContainerBase::getMap(), height, VehicleType::objectLayedByMovement, objectTypeRepository, sidenum, ActionRegistry::SpawnObject, and typ.

int Vehicle::putResource ( int  amount,
int  resourcetype,
bool  queryonly,
int  scope = 1,
int  player = -1 
) [virtual]

scope: 0 = local 1 = resource network 2 = global in all buildings 3 = map wide pool( used only internally! )

Implements ContainerBase.

Definition at line 197 of file vehicle.cpp.

References GameMap::actplayer, ContainerBase::getMap(), ContainerBase::getOwner(), getResource(), ContainerBase::getStorageCapacity(), min(), PEACE, and Resources::resource().

Referenced by getResource().

int Vehicle::getResource ( int  amount,
int  resourcetype,
bool  queryonly,
int  scope = 1,
int  player = -1 
) [virtual]

Implements ContainerBase.

Definition at line 228 of file vehicle.cpp.

References GameMap::actplayer, getGeneratorStatus(), ContainerBase::getMap(), ContainerBase::getOwner(), min(), PEACE, putResource(), and Resources::resource().

Referenced by JumpDriveCommand::available(), ConstructBuildingCommand::buildingProductionPrerequisites(), GetResource::checkvehicle(), compareMapResources(), trunreplay::execnextreplaymove(), GuiFunctions::ConstructBuilding::execute(), putResource(), testAiService2(), and vehicleconstructable().

int Vehicle::getAvailableResource ( int  amount,
int  resourcetype,
int  scope = 1 
) const [virtual]

Implements ContainerBase.

Definition at line 256 of file vehicle.cpp.

References getGeneratorStatus(), min(), and Resources::resource().

Referenced by getResource().

Resources Vehicle::getResource ( const Resources res  )  const

Reimplemented from ContainerBase.

Definition at line 268 of file vehicle.cpp.

References getAvailableResource(), and Resources::resource().

Resources Vehicle::putResource ( const Resources res,
bool  queryonly,
int  scope = 1,
int  player = -1 
) [inline]

Reimplemented from ContainerBase.

Definition at line 210 of file vehicle.h.

References ContainerBase::putResource().

Resources Vehicle::getResource ( const Resources res,
bool  queryonly,
int  scope = 1,
int  player = -1 
) [inline]

Reimplemented from ContainerBase.

Definition at line 211 of file vehicle.h.

References ContainerBase::getResource().

Resources Vehicle::getTank (  )  const

returns the resources that the unit is carrying

Definition at line 278 of file vehicle.cpp.

Referenced by DestructBuildingCommand::avail(), copyVehicleData(), trunreplay::execnextreplaymove(), UnitHooveringLogic::getEndurance(), getUnitResourceCargo(), UnitInfoLayer::paintSingleField(), and DashboardPanel::showUnitData().

int Vehicle::getHeight (  )  const [inline, virtual]

returns the bitmapped level of height. Only one bit will be set, of course

Implements ContainerBase.

Definition at line 219 of file vehicle.h.

References height.

ASCString Vehicle::getName (  )  const [virtual]

returns the units name or, if it does not exist, the unit type's name or description

Implements ContainerBase.

Definition at line 1442 of file vehicle.cpp.

References VehicleType::getName(), ContainerBase::name, and typ.

Referenced by VehicleAttackAction::getDescription(), UnitFieldRegistration::getDescription(), TrainUnitCommand::getDescription(), RegisterUnitRFTarget::getDescription(), RecycleUnitCommand::getDescription(), ReactionFireSwitchCommand::getDescription(), PutObjectCommand::getDescription(), PutMineCommand::getDescription(), PowerGenerationSwitchCommand::getDescription(), MoveUnitCommand::getDescription(), MoveUnit::getDescription(), JumpDriveCommand::getDescription(), InternalAmmoTransferCommand::getDescription(), DestructBuildingCommand::getDescription(), ConstructBuildingCommand::getDescription(), ChangeUnitProperty::getDescription(), ChangeUnitMovement::getDescription(), CargoMoveCommand::getDescription(), AttackCommand::getDescription(), SpecificUnitEntersPolygon::getDetailledName(), VehicleBaseWidget::getName(), UnitTrigger::getName(), getUnitReference(), UnitInfoDialog::UnitInfoDialog(), and VehicleBaseWidget::VehicleBaseWidget().

int Vehicle::getAmmo ( int  type,
int  num,
bool  queryOnly 
) [virtual]

Implements ContainerBase.

Definition at line 1466 of file vehicle.cpp.

References ammo, SingleWeapon::canRefuel(), SingleWeapon::getScalarWeaponType(), min(), putAmmo(), typ, UnitWeapon::weapon, and VehicleType::weapons.

Referenced by putAmmo().

int Vehicle::getAmmo ( int  type,
int  num 
) const [virtual]

Implements ContainerBase.

Definition at line 1451 of file vehicle.cpp.

References ammo, SingleWeapon::getScalarWeaponType(), min(), typ, UnitWeapon::weapon, and VehicleType::weapons.

int Vehicle::putAmmo ( int  type,
int  num,
bool  queryOnly 
) [virtual]

Implements ContainerBase.

Definition at line 1503 of file vehicle.cpp.

References ammo, SingleWeapon::count, getAmmo(), SingleWeapon::getScalarWeaponType(), min(), SingleWeapon::shootable(), typ, UnitWeapon::weapon, and VehicleType::weapons.

Referenced by getAmmo().

int Vehicle::maxAmmo ( int  type  )  const [virtual]

Implements ContainerBase.

Definition at line 1537 of file vehicle.cpp.

References ammo, SingleWeapon::count, UnitWeapon::count, SingleWeapon::getScalarWeaponType(), typ, UnitWeapon::weapon, and VehicleType::weapons.

int Vehicle::weight ( void   )  const

weight of unit including cargo

Definition at line 295 of file vehicle.cpp.

References ContainerBase::cargoWeight(), typ, and VehicleType::weight.

Referenced by executeUserAction().

int Vehicle::freeWeight (  ) 

returns the free weight that can be used for cargo

Definition at line 855 of file vehicle.cpp.

References MapField::building, ContainerBase::gamemap, ContainerBase::getCargo(), GameMap::getField(), searchstackforfreeweight(), MapField::vehicle, xpos, and ypos.

const ResourceMatrix& Vehicle::getRepairEfficiency (  )  const [inline, protected, virtual]

when a ContainerBase is repair by this ContainerBase, the default cost can be customized with this matrix.

Note:
This effects both reparing another ContainerBase as well as self-repsir

Implements ContainerBase.

Definition at line 244 of file vehicle.h.

void Vehicle::postRepair ( int  oldDamage  )  [protected, virtual]

is called after a repair is performed. Vehicles use this to reduce their experience.

Implements ContainerBase.

Definition at line 323 of file vehicle.cpp.

References ContainerBase::damage, experience, experienceDecreaseDamageBoundaries, and experienceDecreaseDamageBoundaryNum.

int Vehicle::size ( void   ) 

Returns the size of a unit. A size is equal to the weight of the unit without any cargo or carried resources.

Definition at line 300 of file vehicle.cpp.

References typ, and VehicleType::weight.

void Vehicle::beginTurn (  ) 

hook that called when the turn for a player starts

Definition at line 332 of file vehicle.cpp.

References ContainerBase::getCarrier(), ContainerBaseType::height, height, VehicleType::movement, and typ.

void Vehicle::endOwnTurn ( void   )  [virtual]

hook that is called when a player ends his turn

Reimplemented from ContainerBase.

Definition at line 375 of file vehicle.cpp.

References VehicleType::autorepairrate, ContainerBase::damage, Vehicle::ReactionFire::endOwnTurn(), ContainerBase::endOwnTurn(), ContainerBase::gamemap, GameMap::getField(), getPosition(), height, ContainerBaseType::height, max(), VehicleType::movement, reactionfire, ContainerBase::repairItem(), typ, and MapField::unitHere().

void Vehicle::endAnyTurn ( void   )  [virtual]

hook that is called when any player (including owner) ends turn

Reimplemented from ContainerBase.

Definition at line 368 of file vehicle.cpp.

References Vehicle::ReactionFire::endAnyTurn(), ContainerBase::endAnyTurn(), and reactionfire.

void Vehicle::endRound ( void   )  [virtual]

hook that is called the next round begins ( active player switching from player8 to player1 )

Reimplemented from ContainerBase.

Definition at line 355 of file vehicle.cpp.

References ContainerBase::endRound(), Resources::energy, Resources::fuel, generatortruckefficiency, ContainerBase::getStorageCapacity(), ContainerBaseType::hasFunction(), ContainerBaseType::MatterConverter, and typ.

int Vehicle::getIdentification (  )  const [inline, virtual]

Implements ContainerBase.

Definition at line 271 of file vehicle.h.

References networkid.

bool Vehicle::vehicleconstructable ( const VehicleType tnk,
int  x,
int  y 
)

checks whether the unit can construct a vehicle of the given type at the given position.

Definition at line 761 of file vehicle.cpp.

References TechAdapterDependency::available(), beeline(), cgp_produceOnlyResearchedStuffExternally, chfahrend, ContainerBase::gamemap, getExternalVehicleConstructionCost(), GameMap::getField(), getFirstBit(), GameMap::getgameparameter(), getMovement(), ContainerBase::getOwner(), getResource(), height, ContainerBaseType::height, maxmalq, maxMovement(), GameMap::player, ContainerBaseType::techDependency, VehicleType::terrainaccess, terrainaccessible2(), typ, VehicleType::unitConstructionMoveCostPercentage, xpos, and ypos.

Resources Vehicle::getExternalVehicleConstructionCost ( const VehicleType tnk  )  const

Definition at line 784 of file vehicle.cpp.

References Resources::energy, Resources::fuel, Resources::material, and ContainerBaseType::productionCost.

Referenced by ConstructUnitCommand::getProduceableVehicles(), ConstructUnitCommand::unitProductionPrerequisites(), and vehicleconstructable().

void Vehicle::setnewposition ( int  x,
int  y 
)

sets the unit (and its cargo) the a new position (the unit will not be chained to a field)

This method does not check if there is enough space around the unit to place the building

Definition at line 705 of file vehicle.cpp.

References ContainerBase::cargo, xpos, and ypos.

Referenced by copyFieldStep2(), movebuilding(), VehicleItem::place(), ClipBoardBase::place(), tspfldloaders::readfields(), setnewposition(), and FindUnitPlacementPos::testfield().

void Vehicle::setnewposition ( const MapCoordinate mc  ) 

Definition at line 714 of file vehicle.cpp.

References setnewposition(), MapCoordinate::x, and MapCoordinate::y.

void Vehicle::setnewposition ( const MapCoordinate mc,
const Context context 
)

Definition at line 719 of file vehicle.cpp.

References ContainerBase::cargo, UnitFieldRegistration::Position, and ActionRegistry::UnitFieldRegistration.

void Vehicle::convert ( int  player,
bool  recursive = true 
)

converts the unit so it is owned by 'player'.

Note that the player is passed as parameter (values [0..8]) )

Definition at line 729 of file vehicle.cpp.

References ContainerBase::cargo, fatalError(), and registerForNewOwner().

Referenced by UnitPropertyEditor::buttonpressed(), trunreplay::execnextreplaymove(), and VehicleItem::place().

void Vehicle::registerForNewOwner ( int  player  )  [virtual]

this is a low level functions that changes the registration in the map. It's called by convert(int,bool)

Implements ContainerBase.

Definition at line 743 of file vehicle.cpp.

References ContainerBase::anyContainerConquered, ContainerBase::color, ContainerBase::conquered, ContainerBase::gamemap, ContainerBase::getOwner(), GameMap::player, and Player::vehicleList.

Referenced by convert().

void Vehicle::setGeneratorStatus ( bool  status  ) 

sets the status of the unit's energy generator

Definition at line 285 of file vehicle.cpp.

References ContainerBaseType::hasFunction(), ContainerBaseType::MatterConverter, and typ.

Referenced by trunreplay::execnextreplaymove().

bool Vehicle::getGeneratorStatus (  )  const [inline]

Definition at line 303 of file vehicle.h.

Referenced by PowerGenerationSwitchCommand::avail(), getAvailableResource(), and getResource().

void Vehicle::postAttack ( bool  reactionFire,
const Context context 
)

callback that is called after the unit has attacked

Definition at line 903 of file vehicle.cpp.

References ChangeUnitProperty::AttackedFlag, attackmovecost, ActionRegistry::ChangeUnitMovement, ActionRegistry::ChangeUnitProperty, GameAction::execute(), ContainerBaseType::hasFunction(), maxMovement(), ContainerBaseType::MoveAfterAttack, and typ.

Referenced by tunitattacksobject::setresult(), tunitattacksbuilding::setresult(), and tunitattacksunit::setresult().

void Vehicle::postAttack ( bool  reactionFire  ) 

Definition at line 920 of file vehicle.cpp.

References attacked, attackmovecost, decreaseMovement(), Vehicle::ReactionFire::getStatus(), ContainerBaseType::hasFunction(), maxMovement(), ContainerBaseType::MoveAfterAttack, Vehicle::ReactionFire::off, reactionfire, setMovement(), and typ.

void Vehicle::addview (  )  [virtual]

adds the units view to the map.

The view must then be evaluated by functions like evaluateviewcalculation ( GameMap*, int)

See also:
viewcalculation.cpp

Implements ContainerBase.

Definition at line 874 of file vehicle.cpp.

References fatalError(), ContainerBase::gamemap, tcomputevehicleview::init(), and SearchFields::startsearch().

Referenced by trunreplay::execnextreplaymove(), FindUnitPlacementPos::testfield(), and DestructContainer::undoAction().

void Vehicle::removeview (  )  [virtual]

removes the units view to the map.

The view must then be evaluated by functions like evaluateviewcalculation ( GameMap*, int)

See also:
viewcalculation.cpp

Implements ContainerBase.

Definition at line 890 of file vehicle.cpp.

References fatalError(), ContainerBase::gamemap, tcomputevehicleview::init(), and SearchFields::startsearch().

Referenced by DestructContainer::runAction(), and ~Vehicle().

void Vehicle::resetview (  ) 

resets the internal view state, so that addview() can be executed again

Definition at line 885 of file vehicle.cpp.

bool Vehicle::isViewing (  )  const [inline]

returns true if the units view is currently added to the maps global visibility.

See also:
viewcalculation.cpp

Definition at line 322 of file vehicle.h.

Referenced by DestructContainer::runAction().

const SingleWeapon * Vehicle::getWeapon ( unsigned  weaponNum  )  const

Returns the SingleWeapon corresponding to the weaponNum for this vehicle.

Definition at line 1625 of file vehicle.cpp.

References typ, UnitWeapon::weapon, and VehicleType::weapons.

Referenced by InternalAmmoTransferCommand::avail(), InternalAmmoTransferHandler::getMaxAmmo(), InternalAmmoTransferHandler::getName(), InternalAmmoTransferHandler::InternalAmmoTransferHandler(), InternalAmmoTransferHandler::performTransfer(), and InternalAmmoTransferHandler::weaponAmmoTransferBuffer().

MapCoordinate3D Vehicle::getPosition (  )  const [virtual]

returns the units position

Implements ContainerBase.

Definition at line 1425 of file vehicle.cpp.

References height, xpos, and ypos.

Referenced by AStar3D::AStar3D(), tsearchreactionfireingunits::attack(), ReactionFireSwitchCommand::avail(), canMove(), compareMapResources(), MapDisplayPG::displayAddons(), endOwnTurn(), ConstructUnitCommand::externalConstructionAvail(), SpecificUnitEntersPolygon::fieldOperator(), getCoveredFields(), CargoMoveCommand::getDescription(), DestructBuildingCommand::getFields(), ConstructUnitCommand::getFields(), ConstructBuildingCommand::getFields(), PathFinder::getMovementFields(), getUnitReference(), AttackCommand::go(), tcomputevehicleview::init(), DashboardPanel::painter(), WeaponRange::run(), MoveUnit::runAction(), DestructContainer::runAction(), MoveUnitCommand::searchFields(), AttackCommand::searchTargets(), selectunit(), DestructContainer::undoAction(), and UnitAttacksUnit_FakeHemming::UnitAttacksUnit_FakeHemming().

MapCoordinate3D Vehicle::getPosition3D (  )  const

returns the units position; if inside building then Height is -1

Definition at line 1430 of file vehicle.cpp.

References ContainerBase::gamemap, GameMap::getField(), height, MapCoordinate3D::setnum(), MapField::unitHere(), xpos, and ypos.

Referenced by AStar3D::findPath().

bool Vehicle::canRepair ( const ContainerBase item  )  const [virtual]

can the unit repair anything? This does not necessarily mean that the unit can repair other units, because a service weapon is additionally needed for that.

It may be the case that the unit can only repair itself.

Implements ContainerBase.

Definition at line 190 of file vehicle.cpp.

References VehicleType::autorepairrate, ContainerBaseType::ExternalRepair, ContainerBaseType::hasFunction(), ContainerBaseType::InternalUnitRepair, and typ.

void Vehicle::fillMagically ( bool  ammo = true,
bool  resources = true 
)

fills a unit with all resources it can carry This function should only be called in the mapeditor !

Definition at line 959 of file vehicle.cpp.

References ammo, SingleWeapon::count, UnitWeapon::count, ContainerBase::getStorageCapacity(), SingleWeapon::maxstrength, typ, UnitWeapon::weapon, VehicleType::weapons, and weapstrength.

Referenced by VehicleItem::place().

Vehicle * Vehicle::newFromStream ( GameMap gamemap,
tnstream stream,
int  forceNetworkID = -1 
) [static]

generates a new unit, loads its parameters from the stream (where they have been previously written with write) and returns this new unit.

Definition at line 1592 of file vehicle.cpp.

References ContainerBase::color, ContainerBase::gamemap, GameMap::IDManager::getNewNetworkID(), GameMap::getUnit(), GameMap::getvehicletype_byid(), GameMap::idManager, networkid, tnstream::readChar(), readData(), tnstream::readInt(), tnstream::readWord(), and GameMap::IDManager::registerUnitNetworkID().

Referenced by Reinforcements::execute(), ClipBoardBase::pasteUnit(), tspfldloaders::readfields(), and DestructContainer::undoAction().

void Vehicle::read ( tnstream stream  )  [virtual]

replaces the parameters of the unit by the ones form the stream.

The VehicleType on the stream and the current one must be the same!

Implements ContainerBase.

Definition at line 1177 of file vehicle.cpp.

References fatalError(), ContainerBaseType::id, tnstream::readChar(), tnstream::readInt(), tnstream::readWord(), and typ.

void Vehicle::write ( tnstream stream,
bool  includeLoadedUnits = true 
) const [virtual]

Implements ContainerBase.

Definition at line 1005 of file vehicle.cpp.

References aiparam, ammo, attacked, ContainerBase::bi_resourceplus, ContainerBase::cargo, cem_aiparam, cem_ammunition2, cem_attacked, cem_damage, cem_direction, cem_energy, cem_experience, cem_fuel, cem_height, cem_loading, cem_material, cem_movement, cem_name, cem_networkid, cem_position, cem_poweron, cem_reactionfire, cem_version, cem_weapstrength2, chfahrend, ContainerBase::color, SingleWeapon::count, UnitWeapon::count, ContainerBase::damage, direction, Resources::energy, experience, Resources::fuel, height, ContainerBaseType::id, ContainerBase::internalUnitProduction, Resources::material, ContainerBase::maxplus, ContainerBase::maxresearchpoints, SingleWeapon::maxstrength, min(), ContainerBase::name, networkid, Vehicle::ReactionFire::nonattackableUnits, ContainerBase::plus, ContainerBase::privateName, reactionfire, ContainerBase::researchpoints, Vehicle::ReactionFire::status, typ, UNITVERSIONLIMIT, ContainerBase::view, UnitWeapon::weapon, VehicleType::weapons, Vehicle::ReactionFire::weaponShots, weapstrength, Resources::write(), tnstream::writeChar(), writeClassContainer(), tnstream::writeInt(), tnstream::writeString(), tnstream::writeWord(), xpos, and ypos.

Referenced by ClipBoardBase::addUnit(), and tspfldloaders::writefields().

void Vehicle::paint ( Surface s,
SPoint  pos,
int  shadowDist = -1 
) const

displays the unit at position spos on s

Definition at line 1554 of file vehicle.cpp.

References GameMap::actplayer, attacked, canMove(), ContainerBase::color, UnitWeapon::count, direction, ContainerBase::gamemap, VehicleType::getImage(), CGameOptions::Instance(), maxMovement(), ContainerBase::paintField(), typ, CGameOptions::units_gray_after_move, and VehicleType::weapons.

Referenced by MapDisplayPG::displayAddons(), MapDisplayPG::displayMovementStep(), StoringPosition::eventMouseMotion(), getImage(), and MapRenderer::paintSingleField().

void Vehicle::paint ( Surface s,
SPoint  pos,
bool  shaded,
int  shadowDist = -1 
) const

Definition at line 1565 of file vehicle.cpp.

References direction, VehicleType::getImage(), ContainerBase::paintField(), and typ.

Surface Vehicle::getImage (  )  const [virtual]

returns an image for the Container.

Note:
Buildings have a size of several fields. The image returned here is therefore not suited to be painted on the map, as map-painting is done on a per-field basis

Implements ContainerBase.

Definition at line 1570 of file vehicle.cpp.

References Surface::createSurface(), fieldsizex, fieldsizey, paint(), and Surface::transparent.

Referenced by InternalAmmoTransferWindow::InternalAmmoTransferWindow().

int Vehicle::getValueType ( int  uheight  )  const [inline]

For the AI: calculating the ValueType if the unit was on the height uheight.

Definition at line 369 of file vehicle.h.

References getFirstBit().

int Vehicle::getValueType (  )  const [inline]

For the AI: calculating the ValueType.

Definition at line 372 of file vehicle.h.

References getFirstBit(), and height.

void Vehicle::transform ( const VehicleType type  ) 

to be used with EXTREME caution, and only in the mapeditor !!

Definition at line 305 of file vehicle.cpp.

References ammo, SingleWeapon::count, UnitWeapon::count, Resources::energy, ContainerBase::getStorageCapacity(), SingleWeapon::maxstrength, typ, UnitWeapon::weapon, VehicleType::weapons, and weapstrength.

const VehicleType::HeightChangeMethod * Vehicle::getHeightChange ( int  dir,
int  height = 0 
) const

returns the method for changing the height in the specified direction, or none if there is none.

Parameters:
dir +1 is up; -1 is down
height if != 0: assume this level of height instead of the actual one

Definition at line 674 of file vehicle.cpp.

References Vehicle::ReactionFire::canMove(), getFirstBit(), ContainerBaseType::height, VehicleType::heightChangeMethod, VehicleType::heightChangeMethodNum, reactionfire, and typ.

Referenced by MoveUnitCommand::ascendAvail(), calcMoveMalus(), MoveUnitCommand::descendAvail(), and MoveUnitCommand::searchFields().

bool Vehicle::weapexist (  )  const

Is the unit able to shoot ?

Definition at line 693 of file vehicle.cpp.

References ammo, UnitWeapon::count, SingleWeapon::offensive(), SingleWeapon::shootable(), typ, UnitWeapon::weapon, and VehicleType::weapons.

Referenced by ReactionFireSwitchCommand::avail(), and AttackCommand::avail().

void Vehicle::prepareForCleanRemove (  )  [inline]

Definition at line 386 of file vehicle.h.

int Vehicle::getMemoryFootprint (  )  const

Definition at line 1586 of file vehicle.cpp.

vector< MapCoordinate > Vehicle::getCoveredFields (  )  [protected, virtual]

Implements ContainerBase.

Definition at line 1578 of file vehicle.cpp.

References getPosition().


Member Data Documentation

const VehicleType* Vehicle::typ

Definition at line 81 of file vehicle.h.

Referenced by AStar3D::AStar3D(), attackpossible(), attackpossible28(), attackpossible2n(), attackpossible2u(), Mine::attacksunit(), TrainUnitCommand::avail(), ReactionFireSwitchCommand::avail(), PutObjectCommand::avail(), PutMineCommand::avail(), PowerGenerationSwitchCommand::avail(), InternalAmmoTransferCommand::avail(), DestructBuildingCommand::avail(), ConstructBuildingCommand::avail(), AttackCommand::avail(), JumpDriveCommand::available(), CargoGuiFunctions::OpenContainer::available(), RepairUnitCommand::availExternally(), beginTurn(), UnitPropertyEditor::buttonpressed(), CalculateThreat_Vehicle::calc_threat_vehicle(), UnitHooveringLogic::calcFuelUsage(), calcMoveMalus(), Vehicle::ReactionFire::canMove(), canMove(), canRepair(), SearchReconquerBuilding::canUnitCapture(), Vehicle::ReactionFire::checkData(), compareMapResources(), copyFieldStep2(), decreaseMovement(), Vehicle::ReactionFire::disable(), VehicleBaseWidget::display(), ReplayMapDisplay::displayMovingUnit(), Vehicle::ReactionFire::enable(), endOwnTurn(), endRound(), trunreplay::execnextreplaymove(), GuiFunctions::BuildVehicleCommand::execute(), CargoGuiFunctions::UnitInfo::execute(), executeUserAction(), ConstructUnitCommand::externalConstructionAvail(), fieldAccessible(), fillMagically(), getAmmo(), getArmor(), AStar::getDistance(), UnitHooveringLogic::getEndurance(), ConstructUnitCommand::getFields(), getHeightChange(), getmaxwindspeedforunit(), AStar3D::getMoveCost(), MapField::getmovemalus(), getMovement(), getName(), RecycleUnitCommand::getOutput(), ConstructBuildingCommand::getProduceableBuildings(), ConstructUnitCommand::getProduceableVehicles(), ServiceChecker::getServiceWeapon(), AStar::getTravelTime(), getType(), UnitCommand::getUnitTypeID(), getWeapon(), ReactionFireSwitchCommand::go(), PutMineCommand::go(), JumpDriveCommand::go(), InternalAmmoTransferCommand::go(), DestructUnitCommand::go(), ConstructUnitCommand::go(), hasMoved(), tcomputevehicleview::init(), UnitPropertyEditor::init(), InternalAmmoTransferHandler::InternalAmmoTransferHandler(), log(), maxAmmo(), maxMovement(), UnitInfoPanel::onClick(), paint(), DashboardPanel::painter(), InternalAmmoTransferHandler::performTransfer(), SelectionHolder::pickup(), VehicleItem::place(), postAttack(), putAmmo(), PutMineCommand::PutMineCommand(), Vehicle::ReactionFire::ReactionFire(), read(), resetMovement(), WeaponRange::run(), MoveUnit::runAction(), DestructContainer::runAction(), ConsumeAmmo::runAction(), AttackCommand::searchTargets(), setGeneratorStatus(), setMovement(), tunitattacksobject::setresult(), tunitattacksbuilding::setresult(), tunitattacksunit::setresult(), tmineattacksunit::setup(), AI::showFieldInformation(), DashboardPanel::showUnitData(), size(), spawnMoveObjects(), StatisticsCalculator::strength(), stu_height(), terrainaccessible2(), transform(), SpawnUnit::undoAction(), ConsumeAmmo::undoAction(), UnitInfoDialog::UnitInfoDialog(), ConstructUnitCommand::unitProductionPrerequisites(), VehicleBaseWidget::VehicleBaseWidget(), vehicleconstructable(), ContainerBase::vehicleDocking(), viewterraininfo(), BattleSoundPlayer::visit(), GetTargetImage::visit(), weapexist(), weight(), WindMovement::WindMovement(), and write().

int Vehicle::ammo[16]

Definition at line 85 of file vehicle.h.

Referenced by attackpossible(), attackpossible28(), attackpossible2n(), attackpossible2u(), TrainUnitCommand::avail(), copyVehicleData(), trunreplay::execnextreplaymove(), fillMagically(), getAmmo(), CalculateThreat_Vehicle::getammunition(), InternalAmmoTransferCommand::go(), UnitPropertyEditor::init(), InternalAmmoTransferHandler::InternalAmmoTransferHandler(), maxAmmo(), ConsumeAmmo::postCheck(), putAmmo(), PutMineCommand::PutMineCommand(), ConsumeAmmo::runAction(), AttackCommand::searchTargets(), tunitattacksobject::setresult(), tunitattacksbuilding::setresult(), tunitattacksunit::setresult(), DashboardPanel::showUnitData(), transform(), ConsumeAmmo::undoAction(), weapexist(), WeaponInfoPanel::WeaponInfoPanel(), and write().

int Vehicle::weapstrength[16]

Definition at line 88 of file vehicle.h.

Referenced by attackpossible(), attackpossible28(), attackpossible2n(), attackpossible2u(), fillMagically(), transform(), and write().

int Vehicle::experience

Definition at line 89 of file vehicle.h.

Referenced by TrainUnitCommand::avail(), copyVehicleData(), CalculateThreat_Vehicle::getexpirience(), TrainUnitCommand::go(), ConstructUnitCommand::go(), UnitPropertyEditor::init(), log(), DashboardPanel::painter(), UnitTrainingLayer::paintSingleField(), postRepair(), tmineattacksunit::setup(), StatisticsCalculator::strength(), testAiHeliMovement1(), and write().

bool Vehicle::attacked

did the unit already attack this turn

Definition at line 92 of file vehicle.h.

Referenced by attackpossible2n(), TrainUnitCommand::avail(), PutObjectCommand::avail(), PutMineCommand::avail(), DestructBuildingCommand::avail(), ConstructBuildingCommand::avail(), AttackCommand::avail(), JumpDriveCommand::available(), RepairUnitCommand::availExternally(), ConstructUnitCommand::externalConstructionAvail(), ServiceTargetSearcher::externallyAvailable(), ConstructUnitCommand::go(), paint(), postAttack(), SaveUnitMovement::SaveUnitMovement(), AttackCommand::searchTargets(), setAttacked(), testJumpdrive(), ContainerBase::vehicleLoadable(), write(), and SaveUnitMovement::~SaveUnitMovement().

int Vehicle::height

the current level of height ( BITMAPPED ! )

Definition at line 101 of file vehicle.h.

Referenced by attackpossible(), attackpossible28(), attackpossible2n(), attackpossible2u(), Mine::attacksunit(), JumpDriveCommand::available(), beginTurn(), UnitPropertyEditor::buttonpressed(), UnitHooveringLogic::calcFuelUsage(), calcvisibilityfield(), copyVehicleData(), decreaseMovement(), MapDisplayPG::displayAddons(), MapDisplayPG::displayMovementStep(), PG_MapDisplay::displayMovingUnit(), Vehicle::ReactionFire::enable(), endOwnTurn(), trunreplay::execnextreplaymove(), fieldAccessible(), fieldvisiblenow(), AStar3D::findAllAccessibleFields(), UnitHooveringLogic::getEndurance(), DestructBuildingCommand::getFields(), getHeight(), CalculateThreat_Vehicle::getheight(), getmaxwindspeedforunit(), AStar::getMoveCost(), PathFinder::getMovementFields(), getPosition(), getPosition3D(), AStar::getTravelTime(), getValueType(), getwindheightforunit(), hasMoved(), tcomputevehicleview::init(), tsearchreactionfireingunits::init(), UnitPropertyEditor::init(), MoveUnitCommand::longDistAvailable(), maxMovement(), DashboardPanel::painter(), MapRenderer::paintSingleField(), UnitTrainingLayer::paintSingleField(), UnitInfoLayer::paintSingleField(), VehicleItem::place(), PutMineCommand::PutMineCommand(), AiParameter::reset(), resetMovement(), SpawnUnit::runAction(), MoveUnit::runAction(), SaveUnitMovement::SaveUnitMovement(), MoveUnitCommand::searchFields(), AttackCommand::searchTargets(), setMovement(), AiParameter::setNewHeight(), tmineattacksunit::setup(), spawnMoveObjects(), stu_height(), terrainaccessible2(), vehicleconstructable(), ContainerBase::vehicleLoadable(), write(), and SaveUnitMovement::~SaveUnitMovement().

char Vehicle::direction

the direction in which the unit is facing

Definition at line 104 of file vehicle.h.

Referenced by UnitPropertyEditor::buttonpressed(), copyFieldStep2(), MapDisplayPG::displayUnitMovement(), execaction(), paint(), DestructContainer::runAction(), and write().

int Vehicle::xpos

the position on the map

Definition at line 107 of file vehicle.h.

Referenced by tsearchreactionfireingunits::attack(), attackpossible(), beeline(), trunreplay::execnextreplaymove(), findPath(), AStar::findPath(), FindUnitPlacementPos::FindUnitPlacementPos(), freeWeight(), getmaxwindspeedforunit(), StratAStar3D::getMoveCost(), StratAStar::getMoveCost(), getPosition(), getPosition3D(), tcomputevehicleview::init(), UnitPropertyEditor::init(), movebuilding(), WeaponRange::run(), SpawnUnit::runAction(), SaveUnitMovement::SaveUnitMovement(), setnewposition(), tunitattacksobject::setup(), tunitattacksbuilding::setup(), tunitattacksunit::setup(), AttackFormula::strength_hemming(), stu_height(), vehicleconstructable(), write(), and SaveUnitMovement::~SaveUnitMovement().

int Vehicle::ypos

Definition at line 107 of file vehicle.h.

Referenced by tsearchreactionfireingunits::attack(), attackpossible(), beeline(), trunreplay::execnextreplaymove(), findPath(), AStar::findPath(), FindUnitPlacementPos::FindUnitPlacementPos(), freeWeight(), getmaxwindspeedforunit(), StratAStar3D::getMoveCost(), StratAStar::getMoveCost(), getPosition(), getPosition3D(), tcomputevehicleview::init(), UnitPropertyEditor::init(), movebuilding(), WeaponRange::run(), SpawnUnit::runAction(), SaveUnitMovement::SaveUnitMovement(), setnewposition(), tunitattacksobject::setup(), tunitattacksbuilding::setup(), tunitattacksunit::setup(), AttackFormula::strength_hemming(), stu_height(), vehicleconstructable(), write(), and SaveUnitMovement::~SaveUnitMovement().

int Vehicle::connection

if events are triggered by this unit (if it is lost for example), this will set connection != 0

Definition at line 116 of file vehicle.h.

Referenced by SpecificUnitEntersPolygon::arm().

int Vehicle::networkid

a unique identification of the unit that is used everywhere in ASC (and not only the network protocols where is was first used, hence the name)

Definition at line 123 of file vehicle.h.

Referenced by TrainUnitCommand::avail(), RecycleUnitCommand::avail(), Vehicle::ReactionFire::canPerformAttack(), trunreplay::execnextreplaymove(), SpecificUnitEntersPolygon::fieldOperator(), getIdentification(), GameMap::getUnit(), MoveUnitCommand::go(), ConstructUnitCommand::go(), newFromStream(), GameMap::IDManager::registerUnitNetworkID(), ContainerBase::removeUnitFromCargo(), SpawnUnit::runAction(), selectunit(), tunitattacksunit::setresult(), RepairUnitCommand::setTarget(), AttackCommand::setTarget(), CargoMoveCommand::setTargetCarrier(), TrainUnitCommand::setUnit(), RecycleUnitCommand::setUnit(), AI::showFieldInformation(), showUnitAiProperties(), UnitAction::UnitAction(), MapField::unitHere(), GameMap::IDManager::unregisterUnitNetworkID(), Vehicle(), viewterraininfo(), and write().

class Vehicle::ReactionFire Vehicle::reactionfire

The class that manages the reaction fire which causes a unit to attack approaching enemies even if it is not the unit's turn.

Referenced by tsearchreactionfireingunits::attack(), attackpossible2n(), ReactionFireSwitchCommand::avail(), JumpDriveCommand::available(), RepairUnitCommand::availExternally(), UnitPropertyEditor::buttonpressed(), canMove(), copyVehicleData(), endAnyTurn(), endOwnTurn(), trunreplay::execnextreplaymove(), ServiceTargetSearcher::externallyAvailable(), getHeightChange(), getMovement(), ReactionFireSwitchCommand::go(), UnitPropertyEditor::init(), ReactionFireLayer::paintSingleField(), postAttack(), RegisterUnitRFTarget::runAction(), AttackCommand::searchTargets(), setReactionFire(), RegisterUnitRFTarget::undoAction(), and write().

AiParameter* Vehicle::aiparam[8]

Definition at line 165 of file vehicle.h.

Referenced by UnitPropertyEditor::buttonpressed(), CalculateThreat_Vehicle::calc_threat_vehicle(), AI::showFieldInformation(), showUnitAiProperties(), write(), and ~Vehicle().


The documentation for this class was generated from the following files:
Generated on Mon Feb 6 01:48:40 2012 for Advanced Strategic Command by  doxygen 1.5.1