OpenXcom  1.0
Open-source clone of the original X-Com
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
RuleItem.h
1 /*
2  * Copyright 2010-2014 OpenXcom Developers.
3  *
4  * This file is part of OpenXcom.
5  *
6  * OpenXcom is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * OpenXcom is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with OpenXcom. If not, see <http://www.gnu.org/licenses/>.
18  */
19 #ifndef OPENXCOM_RULEITEM_H
20 #define OPENXCOM_RULEITEM_H
21 
22 #include <string>
23 #include <vector>
24 #include <yaml-cpp/yaml.h>
25 
26 namespace OpenXcom
27 {
28 
29 enum ItemDamageType { DT_NONE, DT_AP, DT_IN, DT_HE, DT_LASER, DT_PLASMA, DT_STUN, DT_MELEE, DT_ACID, DT_SMOKE };
30 enum BattleType { BT_NONE, BT_FIREARM, BT_AMMO, BT_MELEE, BT_GRENADE, BT_PROXIMITYGRENADE, BT_MEDIKIT, BT_SCANNER, BT_MINDPROBE, BT_PSIAMP, BT_FLARE, BT_CORPSE };
31 
32 class SurfaceSet;
33 class Surface;
34 
41 class RuleItem
42 {
43 private:
44  std::string _type, _name; // two types of objects can have the same name
45  std::vector<std::string> _requires;
46  double _size;
47  int _costBuy, _costSell, _transferTime, _weight;
48  int _bigSprite, _floorSprite, _handSprite, _bulletSprite;
49  int _fireSound, _hitSound, _hitAnimation;
50  int _power;
51  std::vector<std::string> _compatibleAmmo;
52  ItemDamageType _damageType;
53  int _accuracyAuto, _accuracySnap, _accuracyAimed, _tuAuto, _tuSnap, _tuAimed;
54  int _clipSize, _accuracyMelee, _tuMelee;
55  BattleType _battleType;
56  bool _twoHanded, _waypoint, _fixedWeapon;
57  int _invWidth, _invHeight;
58  int _painKiller, _heal, _stimulant;
59  int _woundRecovery, _healthRecovery, _stunRecovery, _energyRecovery;
60  int _tuUse;
61  int _recoveryPoints;
62  int _armor;
63  int _turretType;
64  bool _recover, _liveAlien;
65  int _blastRadius, _attraction;
66  bool _flatRate, _arcingShot;
67  int _listOrder, _maxRange, _aimRange, _snapRange, _autoRange, _minRange, _dropoff, _bulletSpeed, _explosionSpeed, _autoShots, _shotgunPellets;
68  std::string _zombieUnit;
69  bool _strengthApplied, _skillApplied, _LOSRequired;
70  int _meleeSound, _meleePower, _meleeAnimation, _meleeHitSound;
71 public:
73  RuleItem(const std::string &type);
75  ~RuleItem();
77  void load(const YAML::Node& node, int modIndex, int listIndex);
79  std::string getType() const;
81  std::string getName() const;
83  const std::vector<std::string> &getRequirements() const;
85  double getSize() const;
87  int getBuyCost() const;
89  int getSellCost() const;
91  int getTransferTime() const;
93  int getWeight() const;
95  int getBigSprite() const;
97  int getFloorSprite() const;
99  int getHandSprite() const;
101  bool isTwoHanded() const;
103  bool isWaypoint() const;
105  bool isFixed() const;
107  int getBulletSprite() const;
109  int getFireSound() const;
111  int getHitSound() const;
113  int getHitAnimation() const;
115  int getPower() const;
117  int getAccuracySnap() const;
119  int getAccuracyAuto() const;
121  int getAccuracyAimed() const;
123  int getAccuracyMelee() const;
125  int getTUSnap() const;
127  int getTUAuto() const;
129  int getTUAimed() const;
131  int getTUMelee() const;
133  std::vector<std::string> *getCompatibleAmmo();
135  ItemDamageType getDamageType() const;
137  BattleType getBattleType() const;
139  int getInventoryWidth() const;
141  int getInventoryHeight() const;
143  int getClipSize() const;
145  void drawHandSprite(SurfaceSet *texture, Surface *surface) const;
147  int getHealQuantity () const;
149  int getPainKillerQuantity () const;
151  int getStimulantQuantity () const;
153  int getWoundRecovery () const;
155  int getHealthRecovery () const;
157  int getEnergyRecovery () const;
159  int getStunRecovery () const;
161  int getTUUse() const;
163  int getExplosionRadius() const;
165  int getRecoveryPoints() const;
167  int getArmor() const;
169  bool isRecoverable() const;
171  int getTurretType() const;
173  bool getAlien() const;
175  bool getFlatRate() const;
177  bool getArcingShot() const;
179  int getAttraction() const;
181  int getListOrder() const;
183  int getBulletSpeed() const;
185  int getExplosionSpeed() const;
187  int getAutoShots() const;
189  bool isRifle() const;
191  bool isPistol() const;
193  int getMaxRange() const;
195  int getAimRange() const;
197  int getSnapRange() const;
199  int getAutoRange() const;
201  int getMinRange() const;
203  int getDropoff() const;
205  int getShotgunPellets() const;
207  std::string getZombieUnit() const;
209  bool isStrengthApplied() const;
211  bool isSkillApplied() const;
213  int getMeleeAttackSound() const;
215  int getMeleeHitSound() const;
217  int getMeleePower() const;
219  int getMeleeAnimation() const;
221  bool isLOSRequired() const;
222 };
223 
224 }
225 
226 #endif
void load(const YAML::Node &node, int modIndex, int listIndex)
Loads item data from YAML.
Definition: RuleItem.cpp:55
int getRecoveryPoints() const
Gets the recovery points score.
Definition: RuleItem.cpp:624
RuleItem(const std::string &type)
Creates a blank item ruleset.
Definition: RuleItem.cpp:31
int getExplosionRadius() const
Gets the max explosion radius.
Definition: RuleItem.cpp:587
int getPower() const
Gets the item's power.
Definition: RuleItem.cpp:365
int getInventoryWidth() const
Gets the item's inventory width.
Definition: RuleItem.cpp:473
int getAccuracyMelee() const
Gets the item's melee accuracy.
Definition: RuleItem.cpp:401
int getTUUse() const
Gets the Time Unit use.
Definition: RuleItem.cpp:577
BattleType getBattleType() const
Gets the item's type.
Definition: RuleItem.cpp:464
bool getAlien() const
Checks if this a live alien.
Definition: RuleItem.cpp:663
int getPainKillerQuantity() const
Gets the medikit pain killer quantity.
Definition: RuleItem.cpp:523
int getHitSound() const
Gets the item's hit sound.
Definition: RuleItem.cpp:347
int getFloorSprite() const
Gets the item's reference in FLOOROB.PCK for use in inventory.
Definition: RuleItem.cpp:283
std::string getZombieUnit() const
Gets the weapon's zombie unit.
Definition: RuleItem.cpp:816
int getTUAimed() const
Gets the item's aimed shot TU cost.
Definition: RuleItem.cpp:428
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...
Definition: RuleItem.cpp:862
int getDropoff() const
Get the accuracy dropoff of this weapon.
Definition: RuleItem.cpp:753
bool getArcingShot() const
Should this weapon arc?
Definition: RuleItem.cpp:681
int getTUAuto() const
Gets the item's autoshot TU cost.
Definition: RuleItem.cpp:419
int getTransferTime() const
Gets the item's transfer time.
Definition: RuleItem.cpp:256
int getBulletSpeed() const
How fast does a projectile fired from this weapon travel?
Definition: RuleItem.cpp:762
int getFireSound() const
Gets the item's fire sound.
Definition: RuleItem.cpp:338
int getMeleeAnimation() const
Get the melee animation starting frame (comes from hit.pck).
Definition: RuleItem.cpp:880
double getSize() const
Gets the item's size.
Definition: RuleItem.cpp:226
int getBulletSprite() const
Gets the item's bullet sprite reference.
Definition: RuleItem.cpp:329
int getWoundRecovery() const
Gets the medikit wound healed per shot.
Definition: RuleItem.cpp:541
int getAutoRange() const
Get the max range of auto shots with this weapon.
Definition: RuleItem.cpp:735
bool isRifle() const
is this item a 2 handed weapon?
Definition: RuleItem.cpp:789
const std::vector< std::string > & getRequirements() const
Gets the item's requirements.
Definition: RuleItem.cpp:216
int getShotgunPellets() const
Get the number of projectiles to trace.
Definition: RuleItem.cpp:807
int getHandSprite() const
Gets the item's reference in HANDOB.PCK for use in inventory.
Definition: RuleItem.cpp:292
bool isStrengthApplied() const
Is strength applied to the damage of this weapon?
Definition: RuleItem.cpp:825
Represents a specific type of item.
Definition: RuleItem.h:41
Container of a set of surfaces.
Definition: SurfaceSet.h:38
int getAutoShots() const
How many auto shots does this weapon fire.
Definition: RuleItem.cpp:780
int getAccuracySnap() const
Gets the item's snapshot accuracy.
Definition: RuleItem.cpp:374
int getSellCost() const
Gets the item's sale cost.
Definition: RuleItem.cpp:246
bool isRecoverable() const
Gets the item's recoverability.
Definition: RuleItem.cpp:644
bool isTwoHanded() const
Gets if the item is two-handed.
Definition: RuleItem.cpp:301
int getHitAnimation() const
Gets the item's hit animation.
Definition: RuleItem.cpp:356
bool isPistol() const
is this item a single handed weapon?
Definition: RuleItem.cpp:798
int getMaxRange() const
Get the max range of this weapon.
Definition: RuleItem.cpp:708
int getBigSprite() const
Gets the item's reference in BIGOBS.PCK for use in inventory.
Definition: RuleItem.cpp:274
bool getFlatRate() const
Should we charge a flat rate?
Definition: RuleItem.cpp:672
int getMeleeHitSound() const
What sound does this weapon make when you punch someone in the face with it?
Definition: RuleItem.cpp:853
std::string getName() const
Gets the item's name.
Definition: RuleItem.cpp:206
bool isFixed() const
Gets if the item is fixed.
Definition: RuleItem.cpp:320
int getMinRange() const
Get the minimum effective range of this weapon.
Definition: RuleItem.cpp:744
bool isSkillApplied() const
Is skill applied to the accuracy of this weapon?
Definition: RuleItem.cpp:835
std::vector< std::string > * getCompatibleAmmo()
Gets list of compatible ammo.
Definition: RuleItem.cpp:446
~RuleItem()
Cleans up the item ruleset.
Definition: RuleItem.cpp:45
void drawHandSprite(SurfaceSet *texture, Surface *surface) const
Draws the item's hand sprite onto a surface.
Definition: RuleItem.cpp:502
int getHealthRecovery() const
Gets the medikit health recovered per shot.
Definition: RuleItem.cpp:550
int getTUMelee() const
Gets the item's melee TU cost.
Definition: RuleItem.cpp:437
std::string getType() const
Gets the item's type.
Definition: RuleItem.cpp:196
Element that is blit (rendered) onto the screen.
Definition: Surface.h:39
bool isLOSRequired() const
Check if LOS is required to use this item (only applies to psionic type items)
Definition: RuleItem.cpp:871
int getTUSnap() const
Gets the item's snapshot TU cost.
Definition: RuleItem.cpp:410
int getArmor() const
Gets the item's armor.
Definition: RuleItem.cpp:634
int getWeight() const
Gets the item's weight.
Definition: RuleItem.cpp:265
int getListOrder() const
Get the list weight for this item.
Definition: RuleItem.cpp:699
int getAccuracyAimed() const
Gets the item's aimed shot accuracy.
Definition: RuleItem.cpp:392
int getSnapRange() const
Get the max range of snap shots with this weapon.
Definition: RuleItem.cpp:726
int getStunRecovery() const
Gets the medikit stun recovered per shot.
Definition: RuleItem.cpp:568
int getAttraction() const
How much do aliens want this thing?
Definition: RuleItem.cpp:690
int getHealQuantity() const
Gets the medikit heal quantity.
Definition: RuleItem.cpp:514
int getTurretType() const
Gets the item's turret type.
Definition: RuleItem.cpp:654
int getEnergyRecovery() const
Gets the medikit energy recovered per shot.
Definition: RuleItem.cpp:559
int getBuyCost() const
Gets the item's purchase cost.
Definition: RuleItem.cpp:236
int getAccuracyAuto() const
Gets the item's autoshot accuracy.
Definition: RuleItem.cpp:383
int getAimRange() const
Get the max range of aimed shots with this weapon.
Definition: RuleItem.cpp:717
int getClipSize() const
Gets the ammo amount.
Definition: RuleItem.cpp:491
bool isWaypoint() const
Gets if the item is a launcher.
Definition: RuleItem.cpp:310
int getStimulantQuantity() const
Gets the medikit stimulant quantity.
Definition: RuleItem.cpp:532
int getInventoryHeight() const
Gets the item's inventory height.
Definition: RuleItem.cpp:482
int getExplosionSpeed() const
How fast does the explosion animation play?
Definition: RuleItem.cpp:771
int getMeleeAttackSound() const
What sound does this weapon make when you swing this at someone?
Definition: RuleItem.cpp:844
ItemDamageType getDamageType() const
Gets the item's damage type.
Definition: RuleItem.cpp:455