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::RuleItem Class Reference

Represents a specific type of item. More...

#include <RuleItem.h>

Public Member Functions

 RuleItem (const std::string &type)
 Creates a blank item ruleset. More...
 
 ~RuleItem ()
 Cleans up the item ruleset.
 
void load (const YAML::Node &node, int modIndex, int listIndex)
 Loads item data from YAML. More...
 
std::string getType () const
 Gets the item's type. More...
 
std::string getName () const
 Gets the item's name. More...
 
const std::vector< std::string > & getRequirements () const
 Gets the item's requirements. More...
 
double getSize () const
 Gets the item's size. More...
 
int getBuyCost () const
 Gets the item's purchase cost. More...
 
int getSellCost () const
 Gets the item's sale cost. More...
 
int getTransferTime () const
 Gets the item's transfer time. More...
 
int getWeight () const
 Gets the item's weight. More...
 
int getBigSprite () const
 Gets the item's reference in BIGOBS.PCK for use in inventory. More...
 
int getFloorSprite () const
 Gets the item's reference in FLOOROB.PCK for use in inventory. More...
 
int getHandSprite () const
 Gets the item's reference in HANDOB.PCK for use in inventory. More...
 
bool isTwoHanded () const
 Gets if the item is two-handed. More...
 
bool isWaypoint () const
 Gets if the item is a launcher. More...
 
bool isFixed () const
 Gets if the item is fixed. More...
 
int getBulletSprite () const
 Gets the item's bullet sprite reference. More...
 
int getFireSound () const
 Gets the item's fire sound. More...
 
int getHitSound () const
 Gets the item's hit sound. More...
 
int getHitAnimation () const
 Gets the item's hit animation. More...
 
int getPower () const
 Gets the item's power. More...
 
int getAccuracySnap () const
 Gets the item's snapshot accuracy. More...
 
int getAccuracyAuto () const
 Gets the item's autoshot accuracy. More...
 
int getAccuracyAimed () const
 Gets the item's aimed shot accuracy. More...
 
int getAccuracyMelee () const
 Gets the item's melee accuracy. More...
 
int getTUSnap () const
 Gets the item's snapshot TU cost. More...
 
int getTUAuto () const
 Gets the item's autoshot TU cost. More...
 
int getTUAimed () const
 Gets the item's aimed shot TU cost. More...
 
int getTUMelee () const
 Gets the item's melee TU cost. More...
 
std::vector< std::string > * getCompatibleAmmo ()
 Gets list of compatible ammo. More...
 
ItemDamageType getDamageType () const
 Gets the item's damage type. More...
 
BattleType getBattleType () const
 Gets the item's type. More...
 
int getInventoryWidth () const
 Gets the item's inventory width. More...
 
int getInventoryHeight () const
 Gets the item's inventory height. More...
 
int getClipSize () const
 Gets the ammo amount. More...
 
void drawHandSprite (SurfaceSet *texture, Surface *surface) const
 Draws the item's hand sprite onto a surface. More...
 
int getHealQuantity () const
 Gets the medikit heal quantity. More...
 
int getPainKillerQuantity () const
 Gets the medikit pain killer quantity. More...
 
int getStimulantQuantity () const
 Gets the medikit stimulant quantity. More...
 
int getWoundRecovery () const
 Gets the medikit wound healed per shot. More...
 
int getHealthRecovery () const
 Gets the medikit health recovered per shot. More...
 
int getEnergyRecovery () const
 Gets the medikit energy recovered per shot. More...
 
int getStunRecovery () const
 Gets the medikit stun recovered per shot. More...
 
int getTUUse () const
 Gets the Time Unit use. More...
 
int getExplosionRadius () const
 Gets the max explosion radius. More...
 
int getRecoveryPoints () const
 Gets the recovery points score. More...
 
int getArmor () const
 Gets the item's armor. More...
 
bool isRecoverable () const
 Gets the item's recoverability. More...
 
int getTurretType () const
 Gets the item's turret type. More...
 
bool getAlien () const
 Checks if this a live alien. More...
 
bool getFlatRate () const
 Should we charge a flat rate? More...
 
bool getArcingShot () const
 Should this weapon arc? More...
 
int getAttraction () const
 How much do aliens want this thing? More...
 
int getListOrder () const
 Get the list weight for this item. More...
 
int getBulletSpeed () const
 How fast does a projectile fired from this weapon travel? More...
 
int getExplosionSpeed () const
 How fast does the explosion animation play? More...
 
int getAutoShots () const
 How many auto shots does this weapon fire. More...
 
bool isRifle () const
 is this item a 2 handed weapon? More...
 
bool isPistol () const
 is this item a single handed weapon? More...
 
int getMaxRange () const
 Get the max range of this weapon. More...
 
int getAimRange () const
 Get the max range of aimed shots with this weapon. More...
 
int getSnapRange () const
 Get the max range of snap shots with this weapon. More...
 
int getAutoRange () const
 Get the max range of auto shots with this weapon. More...
 
int getMinRange () const
 Get the minimum effective range of this weapon. More...
 
int getDropoff () const
 Get the accuracy dropoff of this weapon. More...
 
int getShotgunPellets () const
 Get the number of projectiles to trace. More...
 
std::string getZombieUnit () const
 Gets the weapon's zombie unit. More...
 
bool isStrengthApplied () const
 Is strength applied to the damage of this weapon? More...
 
bool isSkillApplied () const
 Is skill applied to the accuracy of this weapon? More...
 
int getMeleeAttackSound () const
 What sound does this weapon make when you swing this at someone? More...
 
int getMeleeHitSound () const
 What sound does this weapon make when you punch someone in the face with it? More...
 
int getMeleePower () const
 Ok, so this isn't a melee type weapon but we're using it for melee... how much damage should it do? More...
 
int getMeleeAnimation () const
 Get the melee animation starting frame (comes from hit.pck). More...
 
bool isLOSRequired () const
 Check if LOS is required to use this item (only applies to psionic type items) More...
 

Detailed Description

Represents a specific type of item.

Contains constant info about an item like storage size, sell price, etc.

See also
Item

Constructor & Destructor Documentation

OpenXcom::RuleItem::RuleItem ( const std::string &  type)

Creates a blank item ruleset.

Creates a blank ruleset for a certain type of item.

Parameters
typeString defining the type.

Member Function Documentation

void OpenXcom::RuleItem::drawHandSprite ( SurfaceSet texture,
Surface surface 
) const

Draws the item's hand sprite onto a surface.

Draws and centers the hand sprite on a surface according to its dimensions.

Parameters
texturePointer to the surface set to get the sprite from.
surfacePointer to the surface to draw to.
int OpenXcom::RuleItem::getAccuracyAimed ( ) const

Gets the item's aimed shot accuracy.

Gets the item's accuracy for aimed shots.

Returns
The aimed accuracy.
int OpenXcom::RuleItem::getAccuracyAuto ( ) const

Gets the item's autoshot accuracy.

Gets the item's accuracy for autoshots.

Returns
The autoshot accuracy.
int OpenXcom::RuleItem::getAccuracyMelee ( ) const

Gets the item's melee accuracy.

Gets the item's accuracy for melee attacks.

Returns
The melee accuracy.
int OpenXcom::RuleItem::getAccuracySnap ( ) const

Gets the item's snapshot accuracy.

Gets the item's accuracy for snapshots.

Returns
The snapshot accuracy.
int OpenXcom::RuleItem::getAimRange ( ) const

Get the max range of aimed shots with this weapon.

Gets the maximum effective range of this weapon when using Aimed Shot.

Returns
The maximum range.
bool OpenXcom::RuleItem::getAlien ( ) const

Checks if this a live alien.

Returns if this is a live alien.

Returns
True if this is a live alien.
bool OpenXcom::RuleItem::getArcingShot ( ) const

Should this weapon arc?

Returns if this weapon should arc its shots.

Returns
True if this weapon should arc its shots.
int OpenXcom::RuleItem::getArmor ( ) const

Gets the item's armor.

Returns the item's armor.

The item is destroyed when an explosion power bigger than its armor hits it.

Returns
The armor.
int OpenXcom::RuleItem::getAttraction ( ) const

How much do aliens want this thing?

Gets the attraction value for this item (for AI).

Returns
The attraction value.
int OpenXcom::RuleItem::getAutoRange ( ) const

Get the max range of auto shots with this weapon.

Gets the maximim effective range of this weapon for Auto Shot.

Returns
The maximum range.
int OpenXcom::RuleItem::getAutoShots ( ) const

How many auto shots does this weapon fire.

Gets the amount of auto shots fired by this weapon.

Returns
The shots.
BattleType OpenXcom::RuleItem::getBattleType ( ) const

Gets the item's type.

Gets the item's battlye type.

Returns
The battle type.
int OpenXcom::RuleItem::getBigSprite ( ) const

Gets the item's reference in BIGOBS.PCK for use in inventory.

Gets the reference in BIGOBS.PCK for use in inventory.

Returns
The sprite reference.
int OpenXcom::RuleItem::getBulletSpeed ( ) const

How fast does a projectile fired from this weapon travel?

Gets the speed at which this bullet travels.

Returns
The speed.
int OpenXcom::RuleItem::getBulletSprite ( ) const

Gets the item's bullet sprite reference.

Returns
The sprite reference.
int OpenXcom::RuleItem::getBuyCost ( ) const

Gets the item's purchase cost.

Gets the amount of money this item costs to purchase (0 if not purchasable).

Returns
The buy cost.
int OpenXcom::RuleItem::getClipSize ( ) const

Gets the ammo amount.

Gets the item's ammo clip size.

Returns
The ammo clip size.
std::vector< std::string > * OpenXcom::RuleItem::getCompatibleAmmo ( )

Gets list of compatible ammo.

Gets a list of compatible ammo.

Returns
Pointer to a list of compatible ammo.
ItemDamageType OpenXcom::RuleItem::getDamageType ( ) const

Gets the item's damage type.

Returns
The damage type.
int OpenXcom::RuleItem::getDropoff ( ) const

Get the accuracy dropoff of this weapon.

Gets the accuracy dropoff value of this weapon.

Returns
The per-tile dropoff.
int OpenXcom::RuleItem::getEnergyRecovery ( ) const

Gets the medikit energy recovered per shot.

Gets the amount of energy added to a soldier's energy.

Returns
The amount of energy to add.
int OpenXcom::RuleItem::getExplosionRadius ( ) const

Gets the max explosion radius.

Returns the item's max explosion radius.

Small explosions don't have a restriction. Larger explosions are restricted using a formula, with a maximum of radius 10 no matter how large the explosion is.

Returns
The radius.
int OpenXcom::RuleItem::getExplosionSpeed ( ) const

How fast does the explosion animation play?

Gets the speed at which this bullet explodes.

Returns
The speed.
int OpenXcom::RuleItem::getFireSound ( ) const

Gets the item's fire sound.

Returns
The fire sound id.
bool OpenXcom::RuleItem::getFlatRate ( ) const

Should we charge a flat rate?

Returns whether this item charges a flat TU rate.

Returns
True if this item charges a flat TU rate.
int OpenXcom::RuleItem::getFloorSprite ( ) const

Gets the item's reference in FLOOROB.PCK for use in inventory.

Gets the reference in FLOOROB.PCK for use in inventory.

Returns
The sprite reference.
int OpenXcom::RuleItem::getHandSprite ( ) const

Gets the item's reference in HANDOB.PCK for use in inventory.

Gets the reference in HANDOB.PCK for use in inventory.

Returns
The sprite reference.
int OpenXcom::RuleItem::getHealQuantity ( ) const

Gets the medikit heal quantity.

Gets the heal quantity of the item.

Returns
The new heal quantity.
int OpenXcom::RuleItem::getHealthRecovery ( ) const

Gets the medikit health recovered per shot.

Gets the amount of health added to a wounded soldier's health.

Returns
The amount of health to add.
int OpenXcom::RuleItem::getHitAnimation ( ) const

Gets the item's hit animation.

Returns
The hit animation id.
int OpenXcom::RuleItem::getHitSound ( ) const

Gets the item's hit sound.

Returns
The hit sound id.
int OpenXcom::RuleItem::getInventoryHeight ( ) const

Gets the item's inventory height.

Gets the item's height in a soldier's inventory.

Returns
The height.
int OpenXcom::RuleItem::getInventoryWidth ( ) const

Gets the item's inventory width.

Gets the item's width in a soldier's inventory.

Returns
The width.
int OpenXcom::RuleItem::getListOrder ( ) const

Get the list weight for this item.

Gets the list weight for this research item.

Returns
The list weight.
int OpenXcom::RuleItem::getMaxRange ( ) const

Get the max range of this weapon.

Gets the maximum range of this weapon.

Returns
The maximum range.
int OpenXcom::RuleItem::getMeleeAnimation ( ) const

Get the melee animation starting frame (comes from hit.pck).

What is the starting frame offset in hit.pck to use for the animation?

Returns
the starting frame offset in hit.pck to use for the animation.
int OpenXcom::RuleItem::getMeleeAttackSound ( ) const

What sound does this weapon make when you swing this at someone?

Returns
The weapon's melee attack sound.
int OpenXcom::RuleItem::getMeleeHitSound ( ) const

What sound does this weapon make when you punch someone in the face with it?

Returns
The weapon's melee hit sound.
int OpenXcom::RuleItem::getMeleePower ( ) const

Ok, so this isn't a melee type weapon but we're using it for melee... how much damage should it do?

How much damage does this weapon do when you punch someone in the face with it?

Returns
The weapon's melee power.
int OpenXcom::RuleItem::getMinRange ( ) const

Get the minimum effective range of this weapon.

Gets the minimum effective range of this weapon.

Returns
The minimum effective range.
std::string OpenXcom::RuleItem::getName ( ) const

Gets the item's name.

Gets the language string that names this item.

This is not necessarily unique.

Returns
The item's name.
int OpenXcom::RuleItem::getPainKillerQuantity ( ) const

Gets the medikit pain killer quantity.

Gets the pain killer quantity of the item.

Returns
The new pain killer quantity.
int OpenXcom::RuleItem::getPower ( ) const

Gets the item's power.

Returns
The power.
int OpenXcom::RuleItem::getRecoveryPoints ( ) const

Gets the recovery points score.

Returns the item's recovery points.

This is used during the battlescape debriefing score calculation.

Returns
The recovery points.
const std::vector< std::string > & OpenXcom::RuleItem::getRequirements ( ) const

Gets the item's requirements.

Gets the list of research required to use this item.

Returns
The list of research IDs.
int OpenXcom::RuleItem::getSellCost ( ) const

Gets the item's sale cost.

Gets the amount of money this item is worth to sell.

Returns
The sell cost.
int OpenXcom::RuleItem::getShotgunPellets ( ) const

Get the number of projectiles to trace.

Gets the number of projectiles this ammo shoots at once.

Returns
The number of projectiles.
double OpenXcom::RuleItem::getSize ( ) const

Gets the item's size.

Gets the amount of space this item takes up in a storage facility.

Returns
The storage size.
int OpenXcom::RuleItem::getSnapRange ( ) const

Get the max range of snap shots with this weapon.

Gets the maximim effective range of this weapon for Snap Shot.

Returns
The maximum range.
int OpenXcom::RuleItem::getStimulantQuantity ( ) const

Gets the medikit stimulant quantity.

Gets the stimulant quantity of the item.

Returns
The new stimulant quantity.
int OpenXcom::RuleItem::getStunRecovery ( ) const

Gets the medikit stun recovered per shot.

Gets the amount of stun removed from a soldier's stun level.

Returns
The amount of stun removed.
int OpenXcom::RuleItem::getTransferTime ( ) const

Gets the item's transfer time.

Gets the amount of time this item takes to arrive at a base.

Returns
The time in hours.
int OpenXcom::RuleItem::getTUAimed ( ) const

Gets the item's aimed shot TU cost.

Gets the item's time unit percentage for aimed shots.

Returns
The aimed shot TU percentage.
int OpenXcom::RuleItem::getTUAuto ( ) const

Gets the item's autoshot TU cost.

Gets the item's time unit percentage for autoshots.

Returns
The autoshot TU percentage.
int OpenXcom::RuleItem::getTUMelee ( ) const

Gets the item's melee TU cost.

Gets the item's time unit percentage for melee attacks.

Returns
The melee TU percentage.
int OpenXcom::RuleItem::getTurretType ( ) const

Gets the item's turret type.

Returns the item's Turret Type.

Returns
The turret index (-1 for no turret).
int OpenXcom::RuleItem::getTUSnap ( ) const

Gets the item's snapshot TU cost.

Gets the item's time unit percentage for snapshots.

Returns
The snapshot TU percentage.
int OpenXcom::RuleItem::getTUUse ( ) const

Gets the Time Unit use.

Gets the number of Time Units needed to use this item.

Returns
The number of Time Units needed to use this item.
std::string OpenXcom::RuleItem::getType ( ) const

Gets the item's type.

Gets the item type.

Each item has a unique type.

Returns
The item's type.
int OpenXcom::RuleItem::getWeight ( ) const

Gets the item's weight.

Gets the weight of the item.

Returns
The weight in strength units.
int OpenXcom::RuleItem::getWoundRecovery ( ) const

Gets the medikit wound healed per shot.

Gets the amount of fatal wound healed per usage.

Returns
The amount of fatal wound healed.
std::string OpenXcom::RuleItem::getZombieUnit ( ) const

Gets the weapon's zombie unit.

Gets the unit that the victim is morphed into when attacked.

Returns
The weapon's zombie unit.
bool OpenXcom::RuleItem::isFixed ( ) const

Gets if the item is fixed.

Returns whether this item is a fixed weapon.

You can't move/throw/drop fixed weapons - e.g. HWP turrets.

Returns
True if it is a fixed weapon.
bool OpenXcom::RuleItem::isLOSRequired ( ) const

Check if LOS is required to use this item (only applies to psionic type items)

Is line of sight required for this psionic weapon to function?

Returns
If line of sight is required.
bool OpenXcom::RuleItem::isPistol ( ) const

is this item a single handed weapon?

is this item a pistol?

Returns
whether or not it is a pistol.
bool OpenXcom::RuleItem::isRecoverable ( ) const

Gets the item's recoverability.

Returns if the item should be recoverable from the battlescape.

Returns
True if it is recoverable.
bool OpenXcom::RuleItem::isRifle ( ) const

is this item a 2 handed weapon?

is this item a rifle?

Returns
whether or not it is a rifle.
bool OpenXcom::RuleItem::isSkillApplied ( ) const

Is skill applied to the accuracy of this weapon?

Is skill applied to the accuracy of this weapon? this only applies to melee weapons.

Returns
If we should apply skill.
bool OpenXcom::RuleItem::isStrengthApplied ( ) const

Is strength applied to the damage of this weapon?

Returns
If we should apply strength.
bool OpenXcom::RuleItem::isTwoHanded ( ) const

Gets if the item is two-handed.

Returns whether this item is held with two hands.

Returns
True if it is two-handed.
bool OpenXcom::RuleItem::isWaypoint ( ) const

Gets if the item is a launcher.

Returns whether this item uses waypoints.

Returns
True if it uses waypoints.
void OpenXcom::RuleItem::load ( const YAML::Node &  node,
int  modIndex,
int  listOrder 
)

Loads item data from YAML.

Loads the item from a YAML file.

Parameters
nodeYAML node.
modIndexOffsets the sounds and sprite values to avoid conflicts.
listOrderThe list weight for this item.

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