OpenXcom  1.0
Open-source clone of the original X-Com
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Public Member Functions | List of all members
OpenXcom::BattleItem Class Reference

Represents a single item in the battlescape. More...

#include <BattleItem.h>

Public Member Functions

 BattleItem (RuleItem *rules, int *id)
 Creates a item of the specified type. More...
 
 ~BattleItem ()
 Cleans up the item.
 
void load (const YAML::Node &node)
 Loads the item from YAML. More...
 
YAML::Node save () const
 Saves the item to YAML. More...
 
RuleItemgetRules () const
 Gets the item's ruleset. More...
 
int getAmmoQuantity () const
 Gets the item's ammo quantity. More...
 
void setAmmoQuantity (int qty)
 Sets the item's ammo quantity. More...
 
int getFuseTimer () const
 Gets the turn until explosion. More...
 
void setFuseTimer (int turns)
 Sets the turns until explosion. More...
 
bool spendBullet ()
 Spend one bullet. More...
 
BattleUnitgetOwner () const
 Gets the item's owner. More...
 
BattleUnitgetPreviousOwner () const
 Gets the item's previous owner. More...
 
void setOwner (BattleUnit *owner)
 Sets the owner. More...
 
void moveToOwner (BattleUnit *owner)
 Removes the item from previous owner and moves to new owner. More...
 
RuleInventorygetSlot () const
 Gets the item's inventory slot. More...
 
void setSlot (RuleInventory *slot)
 Sets the item's inventory slot. More...
 
int getSlotX () const
 Gets the item's inventory X position. More...
 
void setSlotX (int x)
 Sets the item's inventory X position. More...
 
int getSlotY () const
 Gets the item's inventory Y position. More...
 
void setSlotY (int y)
 Sets the item's inventory Y position. More...
 
bool occupiesSlot (int x, int y, BattleItem *item=0) const
 Checks if the item is occupying a slot. More...
 
BattleItemgetAmmoItem ()
 Gets the item's ammo item. More...
 
bool needsAmmo () const
 Determines if this item uses ammo. More...
 
int setAmmoItem (BattleItem *item)
 Sets the item's ammo item. More...
 
TilegetTile () const
 Gets the item's tile. More...
 
void setTile (Tile *tile)
 Sets the tile. More...
 
int getId () const
 Gets it's unique id. More...
 
BattleUnitgetUnit () const
 Gets the corpse's unit. More...
 
void setUnit (BattleUnit *unit)
 Sets the corpse's unit. More...
 
void setHealQuantity (int heal)
 Set medikit Heal quantity. More...
 
int getHealQuantity () const
 Get medikit heal quantity. More...
 
void setPainKillerQuantity (int pk)
 Set medikit pain killers quantity. More...
 
int getPainKillerQuantity () const
 Get medikit pain killers quantity. More...
 
void setStimulantQuantity (int stimulant)
 Set medikit stimulant quantity. More...
 
int getStimulantQuantity () const
 Get medikit stimulant quantity. More...
 
void setXCOMProperty (bool flag)
 Set xcom property flag. More...
 
bool getXCOMProperty () const
 Get xcom property flag. More...
 
bool getTurnFlag () const
 get the flag representing "not dropped on player turn" More...
 
void setTurnFlag (bool flag)
 set the flag representing "not dropped on player turn" More...
 
void convertToCorpse (RuleItem *rules)
 Sets the item's ruleset. More...
 

Detailed Description

Represents a single item in the battlescape.

Contains battle-related info about an item like the position, ammo quantity, ...

See also
RuleItem
Item

Constructor & Destructor Documentation

OpenXcom::BattleItem::BattleItem ( RuleItem rules,
int *  id 
)

Creates a item of the specified type.

Initializes a item of the specified type.

Parameters
rulesPointer to ruleset.
idThe id of the item.

Member Function Documentation

void OpenXcom::BattleItem::convertToCorpse ( RuleItem rules)

Sets the item's ruleset.

Converts an unconscious body into a dead one.

Parameters
rulesthe rules of the corpse item to convert this item into.
BattleItem * OpenXcom::BattleItem::getAmmoItem ( )

Gets the item's ammo item.

Returns
The ammo item.
int OpenXcom::BattleItem::getAmmoQuantity ( ) const

Gets the item's ammo quantity.

Gets the quantity of ammo in this item.

Returns
Ammo quantity.
int OpenXcom::BattleItem::getFuseTimer ( ) const

Gets the turn until explosion.

Gets the turns until detonation.

-1 = unprimed grenade

Returns
turns until detonation.
int OpenXcom::BattleItem::getHealQuantity ( ) const

Get medikit heal quantity.

Gets the heal quantity of the item.

Returns
The new heal quantity.
int OpenXcom::BattleItem::getId ( ) const

Gets it's unique id.

Gets the item's id.

Returns
The item's id.
BattleUnit * OpenXcom::BattleItem::getOwner ( ) const

Gets the item's owner.

Returns
Pointer to Battleunit.
int OpenXcom::BattleItem::getPainKillerQuantity ( ) const

Get medikit pain killers quantity.

Gets the pain killer quantity of the item.

Returns
The new pain killer quantity.
BattleUnit * OpenXcom::BattleItem::getPreviousOwner ( ) const

Gets the item's previous owner.

Returns
Pointer to Battleunit.
RuleItem * OpenXcom::BattleItem::getRules ( ) const

Gets the item's ruleset.

Gets the ruleset for the item's type.

Returns
Pointer to ruleset.
RuleInventory * OpenXcom::BattleItem::getSlot ( ) const

Gets the item's inventory slot.

Returns
The slot id.
int OpenXcom::BattleItem::getSlotX ( ) const

Gets the item's inventory X position.

Returns
X position.
int OpenXcom::BattleItem::getSlotY ( ) const

Gets the item's inventory Y position.

Returns
Y position.
int OpenXcom::BattleItem::getStimulantQuantity ( ) const

Get medikit stimulant quantity.

Gets the stimulant quantity of the item.

Returns
The new stimulant quantity.
Tile * OpenXcom::BattleItem::getTile ( ) const

Gets the item's tile.

Returns
The tile.
bool OpenXcom::BattleItem::getTurnFlag ( ) const

get the flag representing "not dropped on player turn"

Gets the "dropped on non-player turn" flag.

This is to determine whether or not aliens should attempt to pick this item up, as items dropped by the player may be "honey traps".

Returns
True if the aliens dropped the item.
BattleUnit * OpenXcom::BattleItem::getUnit ( ) const

Gets the corpse's unit.

Returns
Pointer to BattleUnit.
bool OpenXcom::BattleItem::getXCOMProperty ( ) const

Get xcom property flag.

Gets the XCom property flag.

This is to determine at debriefing what goes into the base/craft.

Returns
True if it's XCom property.
void OpenXcom::BattleItem::load ( const YAML::Node &  node)

Loads the item from YAML.

Loads the item from a YAML file.

Parameters
nodeYAML node.
void OpenXcom::BattleItem::moveToOwner ( BattleUnit owner)

Removes the item from previous owner and moves to new owner.

Removes the item from the previous owner and moves it to the new owner.

Parameters
ownerPointer to Battleunit.
bool OpenXcom::BattleItem::needsAmmo ( ) const

Determines if this item uses ammo.

Determines if the item uses ammo.

Returns
True if ammo is used.
bool OpenXcom::BattleItem::occupiesSlot ( int  x,
int  y,
BattleItem item = 0 
) const

Checks if the item is occupying a slot.

Checks if the item is covering certain inventory slot(s).

Parameters
xSlot X position.
ySlot Y position.
itemItem to check for overlap, or NULL if none.
Returns
True if it is covering.
YAML::Node OpenXcom::BattleItem::save ( ) const

Saves the item to YAML.

Saves the item to a YAML file.

Returns
YAML node.
int OpenXcom::BattleItem::setAmmoItem ( BattleItem item)

Sets the item's ammo item.

Parameters
itemThe ammo item.
Returns
-2 when ammo doesn't fit, or -1 when weapon already contains ammo.
void OpenXcom::BattleItem::setAmmoQuantity ( int  qty)

Sets the item's ammo quantity.

Changes the quantity of ammo in this item.

Parameters
qtyAmmo quantity.
void OpenXcom::BattleItem::setFuseTimer ( int  turns)

Sets the turns until explosion.

Sets the turn to explode on.

Parameters
turnsTurns until detonation (player/alien turns, not game turns).
void OpenXcom::BattleItem::setHealQuantity ( int  heal)

Set medikit Heal quantity.

Sets the heal quantity of the item.

Parameters
healThe new heal quantity.
void OpenXcom::BattleItem::setOwner ( BattleUnit owner)

Sets the owner.

Sets the item's owner.

Parameters
ownerPointer to Battleunit.
void OpenXcom::BattleItem::setPainKillerQuantity ( int  pk)

Set medikit pain killers quantity.

Sets the pain killer quantity of the item.

Parameters
pkThe new pain killer quantity.
void OpenXcom::BattleItem::setSlot ( RuleInventory slot)

Sets the item's inventory slot.

Parameters
slotThe slot id.
void OpenXcom::BattleItem::setSlotX ( int  x)

Sets the item's inventory X position.

Parameters
xX position.
void OpenXcom::BattleItem::setSlotY ( int  y)

Sets the item's inventory Y position.

Parameters
yY position.
void OpenXcom::BattleItem::setStimulantQuantity ( int  stimulant)

Set medikit stimulant quantity.

Sets the stimulant quantity of the item.

Parameters
stimulantThe new stimulant quantity.
void OpenXcom::BattleItem::setTile ( Tile tile)

Sets the tile.

Sets the item's tile.

Parameters
tileThe tile.
void OpenXcom::BattleItem::setTurnFlag ( bool  flag)

set the flag representing "not dropped on player turn"

Sets the "dropped on non-player turn" flag.

This is set when the item is dropped in the battlescape or picked up in the inventory screen.

Parameters
flagTrue if the aliens dropped the item.
void OpenXcom::BattleItem::setUnit ( BattleUnit unit)

Sets the corpse's unit.

Parameters
unitPointer to BattleUnit.
void OpenXcom::BattleItem::setXCOMProperty ( bool  flag)

Set xcom property flag.

Sets the XCom property flag.

This is to determine at debriefing what goes into the base/craft.

Parameters
flagTrue if it's XCom property.
bool OpenXcom::BattleItem::spendBullet ( )

Spend one bullet.

Spends a bullet from the ammo in this item.

Returns
True if there are bullets left.

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