Advanced Strategic Command
Classes | Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | Protected Member Functions | List of all members
Vehicle Class Reference

#include <vehicle.h>

Inheritance diagram for Vehicle:
Inheritance graph
[legend]

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

Public Member Functions

 Vehicle (const VehicleType *t, GameMap *actmap, int player)
 
int getRepairExperienceValue (int oldDamage, int newDamage, bool offensive, int rountToResolution)
 
int repairableDamage () const
 returns the amount of damage that can still be repaired this turn More...
 
bool isBuilding () const
 
const VehicleTypegetType () const
 
int getExperience_offensive () const
 
int getExperience_defensive () const
 
void setExperience_offensive (int experience)
 
void setExperience_defensive (int experience)
 
int getExperience_offensive_raw () const
 
int getExperience_defensive_raw () const
 
void setExperience_offensive_raw (int experience)
 
void setExperience_defensive_raw (int experience)
 
void setAttacked ()
 the the unit and all cargo to attacked = true More...
 
void setAttacked (bool recursive, const Context &context)
 the the unit and (optionally) all cargo to attacked = true More...
 
int getArmor () const
 
bool spawnMoveObjects (const MapCoordinate &start, const MapCoordinate &dest, const Context &context)
 add the objects like tracks or broken ice More...
 
int getHeight () const
 returns the bitmapped level of height. Only one bit will be set, of course More...
 
ASCString getName () const
 returns the units name or, if it does not exist, the unit type's name or description More...
 
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. More...
 
void beginTurn ()
 hook that called when the turn for a player starts More...
 
void endOwnTurn (void)
 hook that is called when a player ends his turn More...
 
void endAnyTurn (void)
 hook that is called when any player (including owner) ends turn More...
 
void endRound (void)
 hook that is called the next round begins ( active player switching from player8 to player1 ) More...
 
int getIdentification () const
 
void setnewposition (int x, int y)
 checks whether the unit can construct a building of the given type. More...
 
void setnewposition (const MapCoordinate &mc)
 
void setnewposition (const MapCoordinate &mc, const Context &context)
 
void unregisterPosition ()
 unregisters the unit at its current position (e.g. from a map field, or inside a transport) More...
 
void convert (int player, bool recursive=true)
 converts the unit so it is owned by 'player'. More...
 
void registerForNewOwner (int player)
 this is a low level functions that changes the registration in the map. It's called by convert(int,bool) More...
 
void setGeneratorStatus (bool status)
 sets the status of the unit's energy generator More...
 
bool getGeneratorStatus () const
 
void postAttack (bool reactionFire, const Context &context)
 callback that is called after the unit has attacked More...
 
void postAttack (bool reactionFire)
 
void addview ()
 adds the units view to the map. More...
 
void removeview ()
 removes the units view to the map. More...
 
void resetview ()
 resets the internal view state, so that addview() can be executed again More...
 
bool isViewing () const
 returns true if the units view is currently added to the maps global visibility. More...
 
const SingleWeapongetWeapon (unsigned weaponNum) const
 Returns the SingleWeapon corresponding to the weaponNum for this vehicle. More...
 
MapCoordinate3D getPosition () const
 returns the units position More...
 
MapCoordinate3D getPosition3D () const
 returns the units position; if inside building then Height is -1 More...
 
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. More...
 
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 ! More...
 
void read (tnstream &stream)
 replaces the parameters of the unit by the ones form the stream. More...
 
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 More...
 
void paint (Surface &s, SPoint pos, bool shaded, int shadowDist=-1) const
 
virtual Surface getImage () const
 returns an image for the Container. More...
 
int getValueType (int uheight) const
 For the AI: calculating the ValueType if the unit was on the height uheight. More...
 
int getValueType () const
 For the AI: calculating the ValueType. More...
 
void transform (const VehicleType *type)
 to be used with EXTREME caution, and only in the mapeditor !! More...
 
const
VehicleType::HeightChangeMethod
getHeightChange (int dir, int height=0) const
 returns the method for changing the height in the specified direction, or none if there is none. More...
 
bool weapexist () const
 Is the unit able to shoot ? More...
 
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) More...
 
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. More...
 
void setMovement (int newmove, double cargoDivisor=-1)
 sets a new distance that the unit can move More...
 
bool hasMoved (void) const
 did the unit move this turn More...
 
int maxMovement () const
 the maximum distance that the unit can drive in a single turn on the current level of height More...
 
void decreaseMovement (int movement)
 reduces the movement by the given amount. More...
 
void resetMovement (void)
 resets a units movement. This is called at the beginning of each turn. More...
 
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! ) More...
 
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 More...
 
Cargo related functions
int weight (void) const
 weight of unit including cargo More...
 
int freeWeight ()
 returns the free weight that can be used for cargo More...
 
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. More...
 
Resources getExternalVehicleConstructionCost (const VehicleType *tnk) const
 
- Public Member Functions inherited from ContainerBase
const ProductiongetProduction () const
 
Resources getProductionCost (const VehicleType *unit) const
 
void deleteProductionLine (const VehicleType *type)
 
void deleteAllProductionLines ()
 
void addProductionLine (const VehicleType *type)
 
bool hasProductionLine (const VehicleType *type)
 
void setProductionLines (const Production &production)
 
int getOwner () const
 returns the number of the player this vehicle/building belongs to More...
 
PlayergetOwningPlayer () const
 returns the player this vehicle/building belongs to More...
 
GameMapgetMap () const
 
ASCString getPrivateName () const
 
virtual void setName (const ASCString &name)
 
WorkspawnWorkClasses (bool justQuery)
 
virtual ~ContainerBase ()
 
int getMaxRepair (const ContainerBase *item) const
 returns the maximum amount of damage that the given item can be repaired More...
 
int getMaxRepair (const ContainerBase *item, int newDamage, Resources &cost, bool ignoreCost=false) const
 
int repairItem (ContainerBase *item, int newDamage=0, bool autoRepair=false)
 
const CargogetCargo () const
 
int getCargoCount () const
 
VehiclegetCargo (int i)
 returns the cargo slot with index i Warning: the cargo may contain NULL items. More...
 
void clearCargo ()
 removes ALL units from cargo More...
 
void addToCargo (Vehicle *veh, int position=-1)
 adds the unit to the cargo More...
 
void moveToCargo (Vehicle *veh)
 adds the unit to the cargo, and removes its from its current position More...
 
bool removeUnitFromCargo (Vehicle *veh, bool recursive=false)
 removes the given unit from the container. More...
 
bool removeUnitFromCargo (int nwid, bool recursive=false)
 
int vehiclesLoaded (void) const
 returns the number of loaded units More...
 
ContainerBasegetCarrier () const
 if this is a unit and it is inside a building or transport, returns the transport. NULL otherwise. More...
 
VehiclefindUnit (int nwid, bool recursive=true) const
 searches for a the unit in carrier and optionally all inner carriers More...
 
bool vehicleLoadable (const Vehicle *vehicle, int uheight=-1, const bool *attacked=NULL) const
 can the vehicle be loaded. More...
 
int vehicleUnloadable (const VehicleType *vehicleType, int carrierHeight=-1) const
 checks the unloading of a unit type More...
 
const
ContainerBaseType::TransportationIO
vehicleUnloadSystem (const VehicleType *vehicle, int height)
 returns the unloading system More...
 
int vehicleDocking (const Vehicle *vehicle, bool out) const
 returns the levels of height on which this unit can be transfered by docking; or 0 if no unloading is possible More...
 
bool doesVehicleFit (const Vehicle *vehicle) const
 Does the vehicle fit into the container? This does not include checking if it can reach the entry. More...
 
int cargoWeight () const
 weight of all loaded units More...
 
int cargoNestingDepth ()
 returns the nesting depth of the cargo. The unit standing on the field is 0, its cargo is 1, the cargo's cargo 2 ... More...
 
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 getResource (const Resources &res) const
 
Resources getResourceUsage ()
 returns the resource that the building consumes for its operation. More...
 
Resources getResourcePlus ()
 
Resources getStorageCapacity () const
 returns the local storage capacity for the given resource, which depends on the resource mode of the map. More...
 
Resources netResourcePlus () const
 returns the amount of resources that the net which the building is connected to produces each turn More...
 
void setInternalResourcePlus (const Resources &res)
 The ResourcePlus is used for different purposes by different building or vehicle functions, or not at all. More...
 
void setInternalResourceMaxPlus (const Resources &res)
 The ResourceMaxPlus is used for different purposes by different building or vehicle functions, or not at all. More...
 
Resources getInternalResourcePlus () const
 The ResourcePlus is used for different purposes by different building or vehicle functions, or not at all. More...
 
Resources getInternalResourceMaxPlus () const
 The ResourceMaxPlus is used for different purposes by different building or vehicle functions, or not at all. More...
 

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. More...
 
- Static Public Member Functions inherited from ContainerBase
static int calcShadowDist (int binaryHeight)
 
static bool registerWorkClassFactory (WorkClassFactory *wcf, bool ASCmode=true)
 

Public Attributes

const VehicleTypetyp
 
int ammo [16]
 
int weapstrength [16]
 
bool attacked
 did the unit already attack this turn More...
 
int height
 the current level of height ( BITMAPPED ! ) More...
 
Uint8 direction
 the direction in which the unit is facing More...
 
int xpos
 the position on the map More...
 
int ypos
 
int connection
 if events are triggered by this unit (if it is lost for example), this will set connection != 0 More...
 
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) More...
 
class Vehicle::ReactionFire reactionfire
 
AiParameteraiparam [8]
 
- Public Attributes inherited from ContainerBase
const ContainerBaseTypebaseType
 the type descriping all non-instance specific properties of the container More...
 
int damage
 Damage. 0 is no damage, when damage reaches 100 the container is destroyed. More...
 
int color
 The owner of the container. More...
 
sigc::signal< void > conquered
 
sigc::signal< void > destroyed
 
int researchpoints
 the current amount of research that the building conducts every turn More...
 
int maxresearchpoints
 
int view
 
sigc::signal< void > cargoChanged
 
ASCString name
 a name given by the user or the map creator More...
 
ASCString privateName
 a name given by the user which is only visible to him and his allies. More...
 
Resources plus
 the Resources that are produced each turn More...
 
Resources maxplus
 the maximum amount of Resources that the building can produce each turn in the ASC resource mode ; see also bi_resourceplus More...
 
Resources bi_resourceplus
 the maximum amount of Resources that the building can produce each turn in the BI resource mode ; see also maxplus More...
 

Static Public Attributes

static const int experienceResolution = 10
 
- Static Public Attributes inherited from ContainerBase
static sigc::signal< void,
ContainerBase * > 
anyContainerDestroyed
 
static sigc::signal< void,
ContainerBase * > 
anyContainerConquered
 

Protected Member Functions

const ResourceMatrixgetRepairEfficiency () const
 when a ContainerBase is repair by this ContainerBase, the default cost can be customized with this matrix. More...
 
virtual void postRepair (int oldDamage, bool autoRepair)
 is called after a repair is performed. Vehicles use this to reduce their experience. More...
 
vector< MapCoordinategetCoveredFields ()
 
- Protected Member Functions inherited from ContainerBase
void paintField (const Surface &src, Surface &dest, SPoint pos, int dir, bool shaded, int shadowDist=-1) const
 displays an image of this container on the surface. More...
 
 ContainerBase (const ContainerBaseType *bt, GameMap *map, int player)
 

Additional Inherited Members

- Public Types inherited from ContainerBase
typedef vector< const
VehicleType * > 
Production
 
typedef vector< Vehicle * > Cargo
 
- Protected Attributes inherited from ContainerBase
int repairedThisTurn
 the percantage that this container has already been repaired this turn. More...
 
GameMapgamemap
 the map that this container is placed on More...
 
ContainerBasecargoParent
 if this container is transported inside a carrier, this is carrier More...
 
Production internalUnitProduction
 
Cargo cargo
 

Detailed Description

Definition at line 46 of file vehicle.h.

Constructor & Destructor Documentation

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

Member Function Documentation

void Vehicle::addview ( void  )
virtual
void Vehicle::beginTurn ( )

hook that called when the turn for a player starts

Definition at line 435 of file vehicle.cpp.

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

bool Vehicle::canMove ( void  ) const
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 198 of file vehicle.cpp.

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

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 843 of file vehicle.cpp.

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

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

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 572 of file vehicle.cpp.

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

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

void Vehicle::endAnyTurn ( void  )
virtual

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

Reimplemented from ContainerBase.

Definition at line 471 of file vehicle.cpp.

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

void Vehicle::endOwnTurn ( void  )
virtual
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 458 of file vehicle.cpp.

References ContainerBase::endRound(), Resources::energy, Resources::fuel, generatortruckefficiency, ContainerBase::getStorageCapacity(), ContainerBaseType::hasFunction(), ContainerBaseType::MatterConverter, 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 1075 of file vehicle.cpp.

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

Referenced by CargoItemFactory::itemSelected(), and VehicleItem::place().

int Vehicle::freeWeight ( )

returns the free weight that can be used for cargo

Definition at line 971 of file vehicle.cpp.

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

int Vehicle::getAmmo ( int  type,
int  num,
bool  queryOnly 
)
virtual
int Vehicle::getAmmo ( int  type,
int  num 
) const
virtual
int Vehicle::getArmor ( ) const
virtual
int Vehicle::getAvailableResource ( int  amount,
int  resourcetype,
int  scope = 1 
) const
virtual

Implements ContainerBase.

Definition at line 356 of file vehicle.cpp.

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

Referenced by getResource().

vector< MapCoordinate > Vehicle::getCoveredFields ( )
protectedvirtual

Implements ContainerBase.

Definition at line 1714 of file vehicle.cpp.

References getPosition().

int Vehicle::getExperience_defensive ( ) const
int Vehicle::getExperience_defensive_raw ( ) const

Definition at line 268 of file vehicle.cpp.

Referenced by RepairUnitCommand::go(), and viewterraininfo().

int Vehicle::getExperience_offensive ( ) const
int Vehicle::getExperience_offensive_raw ( ) const

Definition at line 263 of file vehicle.cpp.

Referenced by RepairUnitCommand::go(), and viewterraininfo().

Resources Vehicle::getExternalVehicleConstructionCost ( const VehicleType tnk) const
bool Vehicle::getGeneratorStatus ( ) const
inline
int Vehicle::getHeight ( ) const
inlinevirtual

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

Implements ContainerBase.

Definition at line 236 of file vehicle.h.

References height.

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
heightif != 0: assume this level of height instead of the actual one

Definition at line 777 of file vehicle.cpp.

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

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

int Vehicle::getIdentification ( ) const
inlinevirtual

Implements ContainerBase.

Definition at line 288 of file vehicle.h.

References networkid.

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 1706 of file vehicle.cpp.

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

Referenced by InternalAmmoTransferWindow::InternalAmmoTransferWindow().

int Vehicle::getMemoryFootprint ( ) const

Definition at line 1722 of file vehicle.cpp.

int Vehicle::getMovement ( bool  checkFuel = true,
bool  checkRF = true 
) const
ASCString Vehicle::getName ( ) const
virtual
MapCoordinate3D Vehicle::getPosition ( void  ) const
virtual
MapCoordinate3D Vehicle::getPosition3D ( ) const

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

Definition at line 1557 of file vehicle.cpp.

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

Referenced by AStar3D::findPath(), and MoveUnitCommand::go().

const ResourceMatrix& Vehicle::getRepairEfficiency ( ) const
inlineprotectedvirtual

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 261 of file vehicle.h.

int Vehicle::getRepairExperienceValue ( int  oldDamage,
int  newDamage,
bool  offensive,
int  rountToResolution 
)

Definition at line 209 of file vehicle.cpp.

Referenced by RepairUnitCommand::go(), and postRepair().

int Vehicle::getResource ( int  amount,
int  resourcetype,
bool  queryonly,
int  scope = 1,
int  player = -1 
)
virtual
Resources Vehicle::getResource ( const Resources res) const

Definition at line 368 of file vehicle.cpp.

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

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

Definition at line 228 of file vehicle.h.

References ContainerBase::getResource().

Resources Vehicle::getTank ( ) const
const VehicleType* Vehicle::getType ( ) const
inline

Definition at line 87 of file vehicle.h.

References typ.

int Vehicle::getValueType ( int  uheight) const
inline

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

Definition at line 389 of file vehicle.h.

References getFirstBit().

int Vehicle::getValueType ( ) const
inline

For the AI: calculating the ValueType.

Definition at line 392 of file vehicle.h.

References getFirstBit(), and height.

const SingleWeapon * Vehicle::getWeapon ( unsigned  weaponNum) const
bool Vehicle::hasMoved ( void  ) const
bool Vehicle::isBuilding ( ) const
inlinevirtual

Implements ContainerBase.

Definition at line 83 of file vehicle.h.

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 342 of file vehicle.h.

Referenced by trunreplay::execnextreplaymove(), MoveUnit::runAction(), and DestructContainer::runAction().

int Vehicle::maxAmmo ( int  type) const
virtual
int Vehicle::maxMovement ( void  ) const
Vehicle * Vehicle::newFromStream ( GameMap gamemap,
tnstream stream,
int  forceNetworkID = -1 
)
static
void Vehicle::paint ( Surface s,
SPoint  pos,
int  shadowDist = -1 
) const
void Vehicle::paint ( Surface s,
SPoint  pos,
bool  shaded,
int  shadowDist = -1 
) const
void Vehicle::postAttack ( bool  reactionFire,
const Context context 
)
void Vehicle::postAttack ( bool  reactionFire)
void Vehicle::postRepair ( int  oldDamage,
bool  autoRepair 
)
protectedvirtual

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

Implements ContainerBase.

Definition at line 423 of file vehicle.cpp.

References ContainerBase::damage, experienceResolution, and getRepairExperienceValue().

void Vehicle::prepareForCleanRemove ( )
inline

Definition at line 406 of file vehicle.h.

Referenced by trunreplay::execnextreplaymove().

int Vehicle::putAmmo ( int  type,
int  num,
bool  queryOnly 
)
virtual
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 297 of file vehicle.cpp.

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

Referenced by getResource().

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

Definition at line 227 of file vehicle.h.

References ContainerBase::putResource().

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 1291 of file vehicle.cpp.

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

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 857 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::removeview ( void  )
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 1006 of file vehicle.cpp.

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

Referenced by trunreplay::execnextreplaymove(), UnitFieldRegistration::runAction(), DestructContainer::runAction(), UnitFieldRegistration::undoAction(), and ~Vehicle().

int Vehicle::repairableDamage ( ) const
inlinevirtual

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

Implements ContainerBase.

Definition at line 81 of file vehicle.h.

References ContainerBase::damage.

void Vehicle::resetMovement ( void  )

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

Definition at line 518 of file vehicle.cpp.

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

Referenced by beginTurn(), endOwnTurn(), and VehicleItem::place().

void Vehicle::resetview ( )

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

Definition at line 1001 of file vehicle.cpp.

void Vehicle::setAttacked ( )

the the unit and all cargo to attacked = true

Definition at line 1049 of file vehicle.cpp.

References attacked, and ContainerBase::cargo.

Referenced by MoveUnit::runAction().

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

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

Definition at line 1057 of file vehicle.cpp.

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

void Vehicle::setExperience_defensive ( int  experience)

Definition at line 279 of file vehicle.cpp.

References experienceResolution.

Referenced by copyVehicleData().

void Vehicle::setExperience_defensive_raw ( int  experience)

Definition at line 290 of file vehicle.cpp.

void Vehicle::setExperience_offensive ( int  experience)

Definition at line 274 of file vehicle.cpp.

References experienceResolution.

Referenced by copyVehicleData(), and ConstructUnitCommand::go().

void Vehicle::setExperience_offensive_raw ( int  experience)

Definition at line 285 of file vehicle.cpp.

void Vehicle::setGeneratorStatus ( bool  status)

sets the status of the unit's energy generator

Definition at line 385 of file vehicle.cpp.

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

Referenced by trunreplay::execnextreplaymove().

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 527 of file vehicle.cpp.

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

Referenced by decreaseMovement(), postAttack(), resetMovement(), SpawnUnit::runAction(), stu_height(), MoveUnit::undoAction(), and SaveUnitMovement::~SaveUnitMovement().

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

checks whether the unit can construct a building of the given type.

This method does not check if there is enough space around the unit to place the building sets the unit (and its cargo) the a new position (the unit will not be chained to a field)

Definition at line 808 of file vehicle.cpp.

References ContainerBase::cargo, xpos, and ypos.

Referenced by ContainerBase::addToCargo(), copyFieldStep2(), trunreplay::execnextreplaymove(), CargoItemFactory::itemSelected(), movebuilding(), MapField::moveUnitHere(), ClipBoardBase::place(), VehicleItem::place(), tspfldloaders::readfields(), MoveUnit::runAction(), setnewposition(), and FindUnitPlacementPos::testfield().

void Vehicle::setnewposition ( const MapCoordinate mc)

Definition at line 817 of file vehicle.cpp.

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

void Vehicle::setnewposition ( const MapCoordinate mc,
const Context context 
)
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 400 of file vehicle.cpp.

References typ, and VehicleType::weight.

bool Vehicle::spawnMoveObjects ( const MapCoordinate start,
const MapCoordinate dest,
const Context context 
)
void Vehicle::transform ( const VehicleType type)

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

Definition at line 405 of file vehicle.cpp.

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

void Vehicle::unregisterPosition ( )

unregisters the unit at its current position (e.g. from a map field, or inside a transport)

Definition at line 830 of file vehicle.cpp.

References ContainerBase::getCarrier(), GameMap::getField(), ContainerBase::getMap(), getPosition(), ContainerBase::removeUnitFromCargo(), and MapField::vehicle.

Referenced by ContainerBase::moveToCargo(), and MapField::moveUnitHere().

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

weight of unit including cargo

Definition at line 395 of file vehicle.cpp.

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

Referenced by ContainerBase::doesVehicleFit(), and executeUserAction().

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

Member Data Documentation

AiParameter* Vehicle::aiparam[8]
int Vehicle::ammo[16]
bool Vehicle::attacked
int Vehicle::connection

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

Definition at line 133 of file vehicle.h.

Referenced by SpecificUnitEntersPolygon::arm(), and MoveUnit::runAction().

Uint8 Vehicle::direction
const int Vehicle::experienceResolution = 10
static
int Vehicle::height

the current level of height ( BITMAPPED ! )

Definition at line 118 of file vehicle.h.

Referenced by attackpossible(), attackpossible28(), attackpossible2n(), attackpossible2u(), Mine::attacksunit(), JumpDriveCommand::available(), beginTurn(), UnitHooveringLogic::calcFuelUsage(), calcvisibilityfield(), Building::chainbuildingtofield(), checkunitsforremoval(), copyVehicleData(), decreaseMovement(), MapDisplayPG::displayAddons(), MapDisplayPG::displayMovementStep(), PG_MapDisplay::displayMovingUnit(), endOwnTurn(), GameMap::endTurn(), trunreplay::execnextreplaymove(), fieldAccessible(), fieldvisiblenow(), UnitHooveringLogic::getEndurance(), DestructBuildingCommand::getFields(), CalculateThreat_Vehicle::getheight(), getHeight(), getHeightChange(), getmaxwindspeedforunit(), PathFinder::getMovementFields(), getPosition(), getPosition3D(), getValueType(), getwindheightforunit(), JumpDriveCommand::go(), hasMoved(), tcomputevehicleview::init(), tsearchreactionfireingunits::init(), MoveUnitCommand::longDistAvailable(), maxMovement(), DashboardPanel::painter(), UnitInfoLayer::paintSingleField(), UnitTrainingLayer::paintSingleField(), MapRenderer::paintUnitOntoField(), VehicleItem::place(), PutMineCommand::PutMineCommand(), AiParameter::reset(), resetMovement(), MoveUnit::runAction(), UnitFieldRegistration::runAction(), SpawnUnit::runAction(), SaveUnitMovement::SaveUnitMovement(), MoveUnitCommand::searchFields(), AttackCommand::searchTargets(), setMovement(), AiParameter::setNewHeight(), tunitattacksunit::setup(), tunitattacksbuilding::setup(), tmineattacksunit::setup(), tunitattacksobject::setup(), spawnMoveObjects(), stu_height(), terrainaccessible2(), testHeightChangeAI(), testHeightChangeGUI(), UnitFieldRegistration::undoAction(), vehicleconstructable(), ContainerBase::vehicleLoadable(), VehiclePropertyEditor::VehiclePropertyEditor(), write(), and SaveUnitMovement::~SaveUnitMovement().

int Vehicle::networkid
class Vehicle::ReactionFire Vehicle::reactionfire
const VehicleType* Vehicle::typ

Definition at line 83 of file vehicle.h.

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

int Vehicle::weapstrength[16]
int Vehicle::xpos
int Vehicle::ypos

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