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 35 /** 36 * Represents a specific type of item. 37 * Contains constant info about an item like 38 * storage size, sell price, etc. 39 * @sa Item 40 */ 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: 72 /// Creates a blank item ruleset. 73 RuleItem(const std::string &type); 74 /// Cleans up the item ruleset. 75 ~RuleItem(); 76 /// Loads item data from YAML. 77 void load(const YAML::Node& node, int modIndex, int listIndex); 78 /// Gets the item's type. 79 std::string getType() const; 80 /// Gets the item's name. 81 std::string getName() const; 82 /// Gets the item's requirements. 83 const std::vector<std::string> &getRequirements() const; 84 /// Gets the item's size. 85 double getSize() const; 86 /// Gets the item's purchase cost. 87 int getBuyCost() const; 88 /// Gets the item's sale cost. 89 int getSellCost() const; 90 /// Gets the item's transfer time. 91 int getTransferTime() const; 92 /// Gets the item's weight. 93 int getWeight() const; 94 /// Gets the item's reference in BIGOBS.PCK for use in inventory. 95 int getBigSprite() const; 96 /// Gets the item's reference in FLOOROB.PCK for use in inventory. 97 int getFloorSprite() const; 98 /// Gets the item's reference in HANDOB.PCK for use in inventory. 99 int getHandSprite() const; 100 /// Gets if the item is two-handed. 101 bool isTwoHanded() const; 102 /// Gets if the item is a launcher. 103 bool isWaypoint() const; 104 /// Gets if the item is fixed. 105 bool isFixed() const; 106 /// Gets the item's bullet sprite reference. 107 int getBulletSprite() const; 108 /// Gets the item's fire sound. 109 int getFireSound() const; 110 /// Gets the item's hit sound. 111 int getHitSound() const; 112 /// Gets the item's hit animation. 113 int getHitAnimation() const; 114 /// Gets the item's power. 115 int getPower() const; 116 /// Gets the item's snapshot accuracy. 117 int getAccuracySnap() const; 118 /// Gets the item's autoshot accuracy. 119 int getAccuracyAuto() const; 120 /// Gets the item's aimed shot accuracy. 121 int getAccuracyAimed() const; 122 /// Gets the item's melee accuracy. 123 int getAccuracyMelee() const; 124 /// Gets the item's snapshot TU cost. 125 int getTUSnap() const; 126 /// Gets the item's autoshot TU cost. 127 int getTUAuto() const; 128 /// Gets the item's aimed shot TU cost. 129 int getTUAimed() const; 130 /// Gets the item's melee TU cost. 131 int getTUMelee() const; 132 /// Gets list of compatible ammo. 133 std::vector<std::string> *getCompatibleAmmo(); 134 /// Gets the item's damage type. 135 ItemDamageType getDamageType() const; 136 /// Gets the item's type. 137 BattleType getBattleType() const; 138 /// Gets the item's inventory width. 139 int getInventoryWidth() const; 140 /// Gets the item's inventory height. 141 int getInventoryHeight() const; 142 /// Gets the ammo amount. 143 int getClipSize() const; 144 /// Draws the item's hand sprite onto a surface. 145 void drawHandSprite(SurfaceSet *texture, Surface *surface) const; 146 /// Gets the medikit heal quantity. 147 int getHealQuantity () const; 148 /// Gets the medikit pain killer quantity. 149 int getPainKillerQuantity () const; 150 /// Gets the medikit stimulant quantity. 151 int getStimulantQuantity () const; 152 /// Gets the medikit wound healed per shot. 153 int getWoundRecovery () const; 154 /// Gets the medikit health recovered per shot. 155 int getHealthRecovery () const; 156 /// Gets the medikit energy recovered per shot. 157 int getEnergyRecovery () const; 158 /// Gets the medikit stun recovered per shot. 159 int getStunRecovery () const; 160 /// Gets the Time Unit use. 161 int getTUUse() const; 162 /// Gets the max explosion radius. 163 int getExplosionRadius() const; 164 /// Gets the recovery points score 165 int getRecoveryPoints() const; 166 /// Gets the item's armor. 167 int getArmor() const; 168 /// Gets the item's recoverability. 169 bool isRecoverable() const; 170 /// Gets the item's turret type. 171 int getTurretType() const; 172 /// Checks if this a live alien. 173 bool getAlien() const; 174 /// Should we charge a flat rate? 175 bool getFlatRate() const; 176 /// Should this weapon arc? 177 bool getArcingShot() const; 178 /// How much do aliens want this thing? 179 int getAttraction() const; 180 /// Get the list weight for this item. 181 int getListOrder() const; 182 /// How fast does a projectile fired from this weapon travel? 183 int getBulletSpeed() const; 184 /// How fast does the explosion animation play? 185 int getExplosionSpeed() const; 186 /// How many auto shots does this weapon fire. 187 int getAutoShots() const; 188 /// is this item a 2 handed weapon? 189 bool isRifle() const; 190 /// is this item a single handed weapon? 191 bool isPistol() const; 192 /// Get the max range of this weapon. 193 int getMaxRange() const; 194 /// Get the max range of aimed shots with this weapon. 195 int getAimRange() const; 196 /// Get the max range of snap shots with this weapon. 197 int getSnapRange() const; 198 /// Get the max range of auto shots with this weapon. 199 int getAutoRange() const; 200 /// Get the minimum effective range of this weapon. 201 int getMinRange() const; 202 /// Get the accuracy dropoff of this weapon. 203 int getDropoff() const; 204 /// Get the number of projectiles to trace. 205 int getShotgunPellets() const; 206 /// Gets the weapon's zombie unit. 207 std::string getZombieUnit() const; 208 /// Is strength applied to the damage of this weapon? 209 bool isStrengthApplied() const; 210 /// Is skill applied to the accuracy of this weapon? 211 bool isSkillApplied() const; 212 /// What sound does this weapon make when you swing this at someone? 213 int getMeleeAttackSound() const; 214 /// What sound does this weapon make when you punch someone in the face with it? 215 int getMeleeHitSound() const; 216 /// Ok, so this isn't a melee type weapon but we're using it for melee... how much damage should it do? 217 int getMeleePower() const; 218 /// Get the melee animation starting frame (comes from hit.pck). 219 int getMeleeAnimation() const; 220 /// Check if LOS is required to use this item (only applies to psionic type items) 221 bool isLOSRequired() const; 222 }; 223 224 } 225 226 #endif 227