[2918] | 1 | /* |
---|
| 2 | * ORXONOX - the hottest 3D action shooter ever to exist |
---|
| 3 | * > www.orxonox.net < |
---|
| 4 | * |
---|
| 5 | * |
---|
| 6 | * License notice: |
---|
| 7 | * |
---|
| 8 | * This program is free software; you can redistribute it and/or |
---|
| 9 | * modify it under the terms of the GNU General Public License |
---|
| 10 | * as published by the Free Software Foundation; either version 2 |
---|
| 11 | * of the License, or (at your option) any later version. |
---|
| 12 | * |
---|
| 13 | * This program is distributed in the hope that it will be useful, |
---|
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 16 | * GNU General Public License for more details. |
---|
| 17 | * |
---|
| 18 | * You should have received a copy of the GNU General Public License |
---|
| 19 | * along with this program; if not, write to the Free Software |
---|
| 20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
---|
| 21 | * |
---|
| 22 | * Author: |
---|
| 23 | * Martin Polak |
---|
| 24 | * Fabian 'x3n' Landau |
---|
| 25 | * Co-authors: |
---|
| 26 | * ... |
---|
| 27 | * |
---|
| 28 | */ |
---|
| 29 | |
---|
| 30 | #ifndef _WeaponMode_H__ |
---|
| 31 | #define _WeaponMode_H__ |
---|
| 32 | |
---|
| 33 | #include "OrxonoxPrereqs.h" |
---|
[3196] | 34 | |
---|
| 35 | #include <string> |
---|
| 36 | #include "util/Math.h" |
---|
[2918] | 37 | #include "core/BaseObject.h" |
---|
[9667] | 38 | #include "core/class/SubclassIdentifier.h" |
---|
[2918] | 39 | #include "tools/Timer.h" |
---|
| 40 | |
---|
| 41 | namespace orxonox |
---|
| 42 | { |
---|
[10650] | 43 | /** |
---|
| 44 | @brief |
---|
| 45 | A WeaponMode defines how a Weapon is used. It specifies what kind of @ref orxonox::Projectile is created when you fire it, how much time it takes to reload, what sound you hear while shooting, how much damage the projectile deals to a target, ... |
---|
| 46 | */ |
---|
[2918] | 47 | class _OrxonoxExport WeaponMode : public BaseObject |
---|
| 48 | { |
---|
| 49 | public: |
---|
[9667] | 50 | WeaponMode(Context* context); |
---|
[2918] | 51 | virtual ~WeaponMode(); |
---|
| 52 | |
---|
| 53 | virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); |
---|
| 54 | |
---|
| 55 | bool fire(float* reloadTime); |
---|
| 56 | bool reload(); |
---|
| 57 | |
---|
[6417] | 58 | // Interacting with the default Firing sound |
---|
| 59 | void setDefaultSound(const std::string& soundPath); |
---|
| 60 | const std::string& getDefaultSound(); |
---|
[7163] | 61 | void setDefaultSoundWithVolume(const std::string& soundPath, const float soundVolume); |
---|
[2918] | 62 | |
---|
| 63 | // Munition |
---|
| 64 | inline Munition* getMunition() const |
---|
| 65 | { return this->munition_; } |
---|
| 66 | |
---|
| 67 | void setMunitionType(Identifier* identifier); |
---|
| 68 | inline Identifier* getMunitionType() const |
---|
| 69 | { return this->munitiontype_; } |
---|
| 70 | |
---|
| 71 | void setMunitionName(const std::string& munitionname); |
---|
| 72 | inline const std::string& getMunitionName() const |
---|
| 73 | { return this->munitionname_; } |
---|
| 74 | |
---|
| 75 | inline void setInitialMunition(unsigned int amount) |
---|
| 76 | { this->initialMunition_ = amount; } |
---|
| 77 | inline unsigned int getInitialMunition() const |
---|
| 78 | { return this->initialMunition_; } |
---|
| 79 | |
---|
| 80 | inline void setInitialMagazines(unsigned int amount) |
---|
| 81 | { this->initialMagazines_ = amount; } |
---|
| 82 | inline unsigned int getInitialMagazines() const |
---|
| 83 | { return this->initialMagazines_; } |
---|
| 84 | |
---|
| 85 | inline void setMunitionPerShot(unsigned int amount) |
---|
| 86 | { this->munitionPerShot_ = amount; } |
---|
| 87 | inline unsigned int getMunitionPerShot() const |
---|
| 88 | { return this->munitionPerShot_; } |
---|
| 89 | |
---|
| 90 | |
---|
| 91 | // Reloading |
---|
| 92 | inline void setReloadTime(float time) |
---|
| 93 | { this->reloadTime_ = time; } |
---|
| 94 | inline float getReloadTime() const |
---|
| 95 | { return this->reloadTime_; } |
---|
| 96 | |
---|
| 97 | inline void setAutoReload(bool autoreload) |
---|
| 98 | { this->bAutoReload_ = autoreload; } |
---|
| 99 | inline bool getAutoReload() const |
---|
| 100 | { return this->bAutoReload_; } |
---|
| 101 | |
---|
| 102 | inline void setParallelReload(bool parallelreload) |
---|
| 103 | { this->bParallelReload_ = parallelreload; } |
---|
| 104 | inline bool getParallelReload() const |
---|
| 105 | { return this->bParallelReload_; } |
---|
| 106 | |
---|
| 107 | |
---|
| 108 | // Fire |
---|
| 109 | inline void setDamage(float damage) |
---|
[8706] | 110 | { this->damage_ = damage;} |
---|
[2918] | 111 | inline float getDamage() const |
---|
| 112 | { return this->damage_; } |
---|
[8706] | 113 | inline void setHealthDamage(float healthdamage) |
---|
| 114 | { this->healthdamage_ = healthdamage; } |
---|
| 115 | inline float getHealthDamage() const |
---|
| 116 | { return this->healthdamage_; } |
---|
[2918] | 117 | |
---|
[8706] | 118 | inline void setShieldDamage(float shielddamage) |
---|
| 119 | { this->shielddamage_ = shielddamage;} |
---|
| 120 | inline float getShieldDamage() const |
---|
| 121 | { return this->shielddamage_; } |
---|
| 122 | |
---|
[2918] | 123 | inline void setMuzzleOffset(const Vector3& offset) |
---|
| 124 | { this->muzzleOffset_ = offset; } |
---|
| 125 | inline const Vector3& getMuzzleOffset() const |
---|
| 126 | { return this->muzzleOffset_; } |
---|
| 127 | |
---|
[6417] | 128 | void computeMuzzleParameters(const Vector3& target); |
---|
| 129 | const Vector3& getMuzzlePosition() const |
---|
| 130 | { return this->muzzlePosition_; } |
---|
| 131 | const Quaternion& getMuzzleOrientation() const |
---|
| 132 | { return this->muzzleOrientation_; } |
---|
[2918] | 133 | Vector3 getMuzzleDirection() const; |
---|
| 134 | |
---|
| 135 | |
---|
| 136 | // Weapon |
---|
| 137 | inline void setWeapon(Weapon* weapon) |
---|
| 138 | { this->weapon_ = weapon; this->updateMunition(); } |
---|
| 139 | inline Weapon* getWeapon() const |
---|
| 140 | { return this->weapon_; } |
---|
| 141 | |
---|
| 142 | inline void setMode(unsigned int mode) |
---|
| 143 | { this->mode_ = mode; } |
---|
| 144 | inline unsigned int getMode() const |
---|
| 145 | { return this->mode_; } |
---|
| 146 | |
---|
[6417] | 147 | Vector3 getTarget(); |
---|
| 148 | |
---|
[2918] | 149 | protected: |
---|
| 150 | virtual void fire() = 0; |
---|
| 151 | |
---|
| 152 | unsigned int initialMunition_; |
---|
| 153 | unsigned int initialMagazines_; |
---|
| 154 | unsigned int munitionPerShot_; |
---|
| 155 | |
---|
| 156 | float reloadTime_; |
---|
| 157 | bool bAutoReload_; |
---|
| 158 | bool bParallelReload_; |
---|
| 159 | |
---|
| 160 | float damage_; |
---|
[8706] | 161 | float healthdamage_; |
---|
| 162 | float shielddamage_; |
---|
[2918] | 163 | Vector3 muzzleOffset_; |
---|
| 164 | |
---|
| 165 | private: |
---|
| 166 | void updateMunition(); |
---|
| 167 | void reloaded(); |
---|
| 168 | |
---|
| 169 | Weapon* weapon_; |
---|
| 170 | unsigned int mode_; |
---|
| 171 | |
---|
| 172 | Munition* munition_; |
---|
| 173 | SubclassIdentifier<Munition> munitiontype_; |
---|
| 174 | std::string munitionname_; |
---|
| 175 | |
---|
[5929] | 176 | Timer reloadTimer_; |
---|
[2918] | 177 | bool bReloading_; |
---|
[6417] | 178 | |
---|
| 179 | Vector3 muzzlePosition_; |
---|
| 180 | Quaternion muzzleOrientation_; |
---|
| 181 | |
---|
| 182 | WorldSound* defSndWpnFire_; |
---|
| 183 | bool bSoundAttached_; |
---|
[2918] | 184 | }; |
---|
| 185 | } |
---|
| 186 | |
---|
| 187 | #endif /* _WeaponMode_H__ */ |
---|