OpenXcom  1.0
Open-source clone of the original X-Com
RuleItem.h
1 #pragma once
2 /*
3  * Copyright 2010-2016 OpenXcom Developers.
4  *
5  * This file is part of OpenXcom.
6  *
7  * OpenXcom is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * OpenXcom is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with OpenXcom. If not, see <http://www.gnu.org/licenses/>.
19  */
20 #include <string>
21 #include <vector>
22 #include <yaml-cpp/yaml.h>
23 
24 namespace OpenXcom
25 {
26 
27 enum ItemDamageType { DT_NONE, DT_AP, DT_IN, DT_HE, DT_LASER, DT_PLASMA, DT_STUN, DT_MELEE, DT_ACID, DT_SMOKE };
28 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 };
29 
30 class SurfaceSet;
31 class Surface;
32 class Mod;
33 
40 class RuleItem
41 {
42 private:
43  std::string _type, _name; // two types of objects can have the same name
44  std::vector<std::string> _requires;
45  double _size;
46  int _costBuy, _costSell, _transferTime, _weight;
47  int _bigSprite, _floorSprite, _handSprite, _bulletSprite;
48  int _fireSound, _hitSound, _hitAnimation;
49  int _power;
50  std::vector<std::string> _compatibleAmmo;
51  ItemDamageType _damageType;
52  int _accuracyAuto, _accuracySnap, _accuracyAimed, _tuAuto, _tuSnap, _tuAimed;
53  int _clipSize, _accuracyMelee, _tuMelee;
54  BattleType _battleType;
55  bool _twoHanded, _fixedWeapon;
56  int _waypoints, _invWidth, _invHeight;
57  int _painKiller, _heal, _stimulant;
58  int _woundRecovery, _healthRecovery, _stunRecovery, _energyRecovery;
59  int _tuUse;
60  int _recoveryPoints;
61  int _armor;
62  int _turretType;
63  bool _recover, _liveAlien;
64  int _blastRadius, _attraction;
65  bool _flatRate, _arcingShot;
66  int _listOrder, _maxRange, _aimRange, _snapRange, _autoRange, _minRange, _dropoff, _bulletSpeed, _explosionSpeed, _autoShots, _shotgunPellets;
67  std::string _zombieUnit;
68  bool _strengthApplied, _skillApplied, _LOSRequired, _underwaterOnly, _landOnly;
69  int _meleeSound, _meleePower, _meleeAnimation, _meleeHitSound, _specialType, _vaporColor, _vaporDensity, _vaporProbability;
70 public:
72  RuleItem(const std::string &type);
74  ~RuleItem();
76  void load(const YAML::Node& node, Mod *mod, int listIndex);
78  std::string getType() const;
80  std::string getName() const;
82  const std::vector<std::string> &getRequirements() const;
84  double getSize() const;
86  int getBuyCost() const;
88  int getSellCost() const;
90  int getTransferTime() const;
92  int getWeight() const;
94  int getBigSprite() const;
96  int getFloorSprite() const;
98  int getHandSprite() const;
100  bool isTwoHanded() const;
102  bool isFixed() const;
104  int getWaypoints() const;
106  int getBulletSprite() const;
108  int getFireSound() const;
110  int getHitSound() const;
112  int getHitAnimation() const;
114  int getPower() const;
116  int getAccuracySnap() const;
118  int getAccuracyAuto() const;
120  int getAccuracyAimed() const;
122  int getAccuracyMelee() const;
124  int getTUSnap() const;
126  int getTUAuto() const;
128  int getTUAimed() const;
130  int getTUMelee() const;
132  std::vector<std::string> *getCompatibleAmmo();
134  ItemDamageType getDamageType() const;
136  BattleType getBattleType() const;
138  int getInventoryWidth() const;
140  int getInventoryHeight() const;
142  int getClipSize() const;
144  void drawHandSprite(SurfaceSet *texture, Surface *surface) const;
146  int getHealQuantity() const;
148  int getPainKillerQuantity() const;
150  int getStimulantQuantity() const;
152  int getWoundRecovery() const;
154  int getHealthRecovery() const;
156  int getEnergyRecovery() const;
158  int getStunRecovery() const;
160  int getTUUse() const;
162  int getExplosionRadius() const;
164  int getRecoveryPoints() const;
166  int getArmor() const;
168  bool isRecoverable() const;
170  int getTurretType() const;
172  bool isAlien() const;
174  bool getFlatRate() const;
176  bool getArcingShot() const;
178  int getAttraction() const;
180  int getListOrder() const;
182  int getBulletSpeed() const;
184  int getExplosionSpeed() const;
186  int getAutoShots() const;
188  bool isRifle() const;
190  bool isPistol() const;
192  int getMaxRange() const;
194  int getAimRange() const;
196  int getSnapRange() const;
198  int getAutoRange() const;
200  int getMinRange() const;
202  int getDropoff() const;
204  int getShotgunPellets() const;
206  std::string getZombieUnit() const;
208  bool isStrengthApplied() const;
210  bool isSkillApplied() const;
212  int getMeleeAttackSound() const;
214  int getMeleeHitSound() const;
216  int getMeleePower() const;
218  int getMeleeAnimation() const;
220  bool isLOSRequired() const;
222  bool isWaterOnly() const;
224  bool isLandOnly() const;
226  int getSpecialType() const;
228  int getVaporColor() const;
230  int getVaporDensity() const;
232  int getVaporProbability() const;
233 
234 };
235 
236 }
bool isRifle() const
is this item a 2 handed weapon?
Definition: RuleItem.cpp:769
bool isPistol() const
is this item a single handed weapon?
Definition: RuleItem.cpp:778
int getSellCost() const
Gets the item&#39;s sale cost.
Definition: RuleItem.cpp:226
int getTUUse() const
Gets the Time Unit use.
Definition: RuleItem.cpp:557
RuleItem(const std::string &type)
Creates a blank item ruleset.
Definition: RuleItem.cpp:33
int getTUAuto() const
Gets the item&#39;s autoshot TU cost.
Definition: RuleItem.cpp:399
int getHealQuantity() const
Gets the medikit heal quantity.
Definition: RuleItem.cpp:494
int getStunRecovery() const
Gets the medikit stun recovered per shot.
Definition: RuleItem.cpp:548
int getAttraction() const
How much do aliens want this thing?
Definition: RuleItem.cpp:670
std::string getName() const
Gets the item&#39;s name.
Definition: RuleItem.cpp:186
int getHandSprite() const
Gets the item&#39;s reference in HANDOB.PCK for use in inventory.
Definition: RuleItem.cpp:272
int getMaxRange() const
Get the max range of this weapon.
Definition: RuleItem.cpp:688
Contains all the game-specific static data that never changes throughout the game, like rulesets and resources.
Definition: Mod.h:87
bool getFlatRate() const
Should we charge a flat rate?
Definition: RuleItem.cpp:652
int getExplosionRadius() const
Gets the max explosion radius.
Definition: RuleItem.cpp:567
int getAutoRange() const
Get the max range of auto shots with this weapon.
Definition: RuleItem.cpp:715
int getDropoff() const
Get the accuracy dropoff of this weapon.
Definition: RuleItem.cpp:733
bool isWaterOnly() const
Is this item restricted to underwater use?
Definition: RuleItem.cpp:869
int getArmor() const
Gets the item&#39;s armor.
Definition: RuleItem.cpp:614
int getTurretType() const
Gets the item&#39;s turret type.
Definition: RuleItem.cpp:634
int getPower() const
Gets the item&#39;s power.
Definition: RuleItem.cpp:345
int getInventoryHeight() const
Gets the item&#39;s inventory height.
Definition: RuleItem.cpp:462
int getTransferTime() const
Gets the item&#39;s transfer time.
Definition: RuleItem.cpp:236
int getListOrder() const
Get the list weight for this item.
Definition: RuleItem.cpp:679
bool getArcingShot() const
Should this weapon arc?
Definition: RuleItem.cpp:661
int getClipSize() const
Gets the ammo amount.
Definition: RuleItem.cpp:471
std::string getZombieUnit() const
Gets the weapon&#39;s zombie unit.
Definition: RuleItem.cpp:796
BattleType getBattleType() const
Gets the item&#39;s type.
Definition: RuleItem.cpp:444
std::string getType() const
Gets the item&#39;s type.
Definition: RuleItem.cpp:176
int getAccuracySnap() const
Gets the item&#39;s snapshot accuracy.
Definition: RuleItem.cpp:354
int getTUAimed() const
Gets the item&#39;s aimed shot TU cost.
Definition: RuleItem.cpp:408
int getExplosionSpeed() const
How fast does the explosion animation play?
Definition: RuleItem.cpp:751
int getMeleeAttackSound() const
What sound does this weapon make when you swing this at someone?
Definition: RuleItem.cpp:824
int getVaporDensity() const
Gets the vapor cloud density.
Definition: RuleItem.cpp:908
int getBulletSpeed() const
How fast does a projectile fired from this weapon travel?
Definition: RuleItem.cpp:742
Represents a specific type of item.
Definition: RuleItem.h:40
int getAccuracyAimed() const
Gets the item&#39;s aimed shot accuracy.
Definition: RuleItem.cpp:372
void drawHandSprite(SurfaceSet *texture, Surface *surface) const
Draws the item&#39;s hand sprite onto a surface.
Definition: RuleItem.cpp:482
Container of a set of surfaces.
Definition: SurfaceSet.h:35
int getVaporProbability() const
Gets the vapor cloud probability.
Definition: RuleItem.cpp:917
int getHitAnimation() const
Gets the item&#39;s hit animation.
Definition: RuleItem.cpp:336
int getAccuracyAuto() const
Gets the item&#39;s autoshot accuracy.
Definition: RuleItem.cpp:363
int getMinRange() const
Get the minimum effective range of this weapon.
Definition: RuleItem.cpp:724
int getFireSound() const
Gets the item&#39;s fire sound.
Definition: RuleItem.cpp:318
bool isSkillApplied() const
Is skill applied to the accuracy of this weapon?
Definition: RuleItem.cpp:815
bool isLOSRequired() const
Check if LOS is required to use this item (only applies to psionic type items)
Definition: RuleItem.cpp:851
int getWeight() const
Gets the item&#39;s weight.
Definition: RuleItem.cpp:245
int getMeleeAnimation() const
Get the melee animation starting frame (comes from hit.pck).
Definition: RuleItem.cpp:860
int getWoundRecovery() const
Gets the medikit wound healed per shot.
Definition: RuleItem.cpp:521
bool isRecoverable() const
Gets the item&#39;s recoverability.
Definition: RuleItem.cpp:624
int getTUMelee() const
Gets the item&#39;s melee TU cost.
Definition: RuleItem.cpp:417
int getPainKillerQuantity() const
Gets the medikit pain killer quantity.
Definition: RuleItem.cpp:503
int getMeleeHitSound() const
What sound does this weapon make when you punch someone in the face with it?
Definition: RuleItem.cpp:833
double getSize() const
Gets the item&#39;s size.
Definition: RuleItem.cpp:206
int getSpecialType() const
Get the associated special type of this item.
Definition: RuleItem.cpp:890
bool isFixed() const
Gets if the item is fixed.
Definition: RuleItem.cpp:300
int getAimRange() const
Get the max range of aimed shots with this weapon.
Definition: RuleItem.cpp:697
int getInventoryWidth() const
Gets the item&#39;s inventory width.
Definition: RuleItem.cpp:453
std::vector< std::string > * getCompatibleAmmo()
Gets list of compatible ammo.
Definition: RuleItem.cpp:426
~RuleItem()
Cleans up the item ruleset.
Definition: RuleItem.cpp:44
int getAutoShots() const
How many auto shots does this weapon fire.
Definition: RuleItem.cpp:760
int getBulletSprite() const
Gets the item&#39;s bullet sprite reference.
Definition: RuleItem.cpp:309
Element that is blit (rendered) onto the screen.
Definition: Surface.h:38
bool isStrengthApplied() const
Is strength applied to the damage of this weapon?
Definition: RuleItem.cpp:805
int getBuyCost() const
Gets the item&#39;s purchase cost.
Definition: RuleItem.cpp:216
int getMeleePower() const
Ok, so this isn&#39;t a melee type weapon but we&#39;re using it for melee... how much damage should it do...
Definition: RuleItem.cpp:842
int getSnapRange() const
Get the max range of snap shots with this weapon.
Definition: RuleItem.cpp:706
int getVaporColor() const
Get the color offset to use for the vapor trail.
Definition: RuleItem.cpp:899
int getHealthRecovery() const
Gets the medikit health recovered per shot.
Definition: RuleItem.cpp:530
int getHitSound() const
Gets the item&#39;s hit sound.
Definition: RuleItem.cpp:327
int getEnergyRecovery() const
Gets the medikit energy recovered per shot.
Definition: RuleItem.cpp:539
bool isAlien() const
Checks if this a live alien.
Definition: RuleItem.cpp:643
int getWaypoints() const
Gets if the item is a launcher.
Definition: RuleItem.cpp:290
int getStimulantQuantity() const
Gets the medikit stimulant quantity.
Definition: RuleItem.cpp:512
ItemDamageType getDamageType() const
Gets the item&#39;s damage type.
Definition: RuleItem.cpp:435
int getFloorSprite() const
Gets the item&#39;s reference in FLOOROB.PCK for use in inventory.
Definition: RuleItem.cpp:263
int getRecoveryPoints() const
Gets the recovery points score.
Definition: RuleItem.cpp:604
const std::vector< std::string > & getRequirements() const
Gets the item&#39;s requirements.
Definition: RuleItem.cpp:196
int getTUSnap() const
Gets the item&#39;s snapshot TU cost.
Definition: RuleItem.cpp:390
bool isTwoHanded() const
Gets if the item is two-handed.
Definition: RuleItem.cpp:281
int getShotgunPellets() const
Get the number of projectiles to trace.
Definition: RuleItem.cpp:787
int getBigSprite() const
Gets the item&#39;s reference in BIGOBS.PCK for use in inventory.
Definition: RuleItem.cpp:254
void load(const YAML::Node &node, Mod *mod, int listIndex)
Loads item data from YAML.
Definition: RuleItem.cpp:54
bool isLandOnly() const
Is this item restricted to land use?
Definition: RuleItem.cpp:878
int getAccuracyMelee() const
Gets the item&#39;s melee accuracy.
Definition: RuleItem.cpp:381
Definition: BaseInfoState.cpp:40