[2072] | 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 | * Fabian 'x3n' Landau |
---|
| 24 | * Co-authors: |
---|
| 25 | * ... |
---|
| 26 | * |
---|
| 27 | */ |
---|
| 28 | |
---|
| 29 | #ifndef _Pawn_H__ |
---|
| 30 | #define _Pawn_H__ |
---|
| 31 | |
---|
| 32 | #include "OrxonoxPrereqs.h" |
---|
[3196] | 33 | |
---|
| 34 | #include <string> |
---|
[6524] | 35 | #include "interfaces/PickupCarrier.h" |
---|
[3196] | 36 | #include "interfaces/RadarViewable.h" |
---|
[5735] | 37 | #include "worldentities/ControllableEntity.h" |
---|
[2072] | 38 | |
---|
[6711] | 39 | namespace orxonox // tolua_export |
---|
| 40 | { // tolua_export |
---|
| 41 | class _OrxonoxExport Pawn // tolua_export |
---|
| 42 | : public ControllableEntity, public RadarViewable, public PickupCarrier |
---|
| 43 | { // tolua_export |
---|
[3053] | 44 | friend class WeaponSystem; |
---|
| 45 | |
---|
[2072] | 46 | public: |
---|
| 47 | Pawn(BaseObject* creator); |
---|
| 48 | virtual ~Pawn(); |
---|
| 49 | |
---|
| 50 | virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); |
---|
| 51 | virtual void tick(float dt); |
---|
| 52 | |
---|
| 53 | inline bool isAlive() const |
---|
| 54 | { return this->bAlive_; } |
---|
| 55 | |
---|
| 56 | virtual void setHealth(float health); |
---|
| 57 | inline void addHealth(float health) |
---|
| 58 | { this->setHealth(this->health_ + health); } |
---|
| 59 | inline void removeHealth(float health) |
---|
| 60 | { this->setHealth(this->health_ - health); } |
---|
[2662] | 61 | inline float getHealth() const |
---|
[2072] | 62 | { return this->health_; } |
---|
| 63 | |
---|
| 64 | inline void setMaxHealth(float maxhealth) |
---|
| 65 | { this->maxHealth_ = maxhealth; this->setHealth(this->health_); } |
---|
| 66 | inline float getMaxHealth() const |
---|
| 67 | { return this->maxHealth_; } |
---|
| 68 | |
---|
| 69 | inline void setInitialHealth(float initialhealth) |
---|
| 70 | { this->initialHealth_ = initialhealth; this->setHealth(initialhealth); } |
---|
| 71 | inline float getInitialHealth() const |
---|
| 72 | { return this->initialHealth_; } |
---|
| 73 | |
---|
[8706] | 74 | virtual void setShieldHealth(float shieldHealth); |
---|
| 75 | |
---|
[7163] | 76 | inline float getShieldHealth() |
---|
[8855] | 77 | { return this->shieldHealth_; } |
---|
[7163] | 78 | |
---|
[8706] | 79 | inline void addShieldHealth(float amount) |
---|
[8855] | 80 | { this->setShieldHealth(this->shieldHealth_ + amount); } |
---|
[8706] | 81 | |
---|
| 82 | inline bool hasShield() |
---|
[8855] | 83 | { return (this->getShieldHealth() > 0); } |
---|
[8706] | 84 | |
---|
| 85 | virtual void setMaxShieldHealth(float maxshieldhealth); |
---|
| 86 | inline float getMaxShieldHealth() const |
---|
| 87 | { return this->maxShieldHealth_; } |
---|
| 88 | |
---|
| 89 | inline void setInitialShieldHealth(float initialshieldhealth) |
---|
| 90 | { this->initialShieldHealth_ = initialshieldhealth; this->setShieldHealth(initialshieldhealth); } |
---|
| 91 | inline float getInitialShieldHealth() const |
---|
| 92 | { return this->initialShieldHealth_; } |
---|
| 93 | |
---|
| 94 | inline void restoreInitialShieldHealth() |
---|
| 95 | { this->setShieldHealth(this->initialShieldHealth_); } |
---|
| 96 | inline void restoreMaxShieldHealth() |
---|
| 97 | { this->setShieldHealth(this->maxShieldHealth_); } |
---|
| 98 | |
---|
[7163] | 99 | inline void setShieldAbsorption(float shieldAbsorption) |
---|
[8855] | 100 | { this->shieldAbsorption_ = shieldAbsorption; } |
---|
[7163] | 101 | inline float getShieldAbsorption() |
---|
[8855] | 102 | { return this->shieldAbsorption_; } |
---|
[7163] | 103 | |
---|
[8706] | 104 | // TODO: Rename to shieldRechargeRate |
---|
| 105 | virtual void setReloadRate(float reloadrate); |
---|
| 106 | inline float getReloadRate() const |
---|
| 107 | { return this->reloadRate_; } |
---|
| 108 | |
---|
| 109 | virtual void setReloadWaitTime(float reloadwaittime); |
---|
| 110 | inline float getReloadWaitTime() const |
---|
| 111 | { return this->reloadWaitTime_; } |
---|
| 112 | |
---|
| 113 | inline void resetReloadCountdown() |
---|
[8855] | 114 | { this->reloadWaitCountdown_ = 0; } |
---|
[8706] | 115 | |
---|
| 116 | inline void startReloadCountdown() |
---|
[8855] | 117 | { this->reloadWaitCountdown_ = this->getReloadWaitTime(); } // TODO: Implement in Projectile.cc |
---|
[8706] | 118 | |
---|
| 119 | virtual void decreaseReloadCountdownTime(float dt); |
---|
| 120 | |
---|
[2072] | 121 | inline ControllableEntity* getLastHitOriginator() const |
---|
| 122 | { return this->lastHitOriginator_; } |
---|
| 123 | |
---|
[8706] | 124 | //virtual void hit(Pawn* originator, const Vector3& force, float damage); |
---|
| 125 | //virtual void hit(Pawn* originator, btManifoldPoint& contactpoint, float damage); |
---|
| 126 | virtual void hit(Pawn* originator, const Vector3& force, float damage, float healthdamage = 0.0f, float shielddamage = 0.0f); |
---|
| 127 | virtual void hit(Pawn* originator, btManifoldPoint& contactpoint, float damage, float healthdamage = 0.0f, float shielddamage = 0.0f); |
---|
| 128 | |
---|
[2072] | 129 | virtual void kill(); |
---|
| 130 | |
---|
[6417] | 131 | virtual void fired(unsigned int firemode); |
---|
[3053] | 132 | virtual void reload(); |
---|
[2072] | 133 | virtual void postSpawn(); |
---|
| 134 | |
---|
[3053] | 135 | void addWeaponSlot(WeaponSlot * wSlot); |
---|
[2662] | 136 | WeaponSlot * getWeaponSlot(unsigned int index) const; |
---|
[3053] | 137 | void addWeaponSet(WeaponSet * wSet); |
---|
[2662] | 138 | WeaponSet * getWeaponSet(unsigned int index) const; |
---|
[3053] | 139 | void addWeaponPack(WeaponPack * wPack); |
---|
[6417] | 140 | void addWeaponPackXML(WeaponPack * wPack); |
---|
[3053] | 141 | WeaponPack * getWeaponPack(unsigned int index) const; |
---|
[2662] | 142 | |
---|
[7163] | 143 | virtual void addedWeaponPack(WeaponPack* wPack) {} |
---|
| 144 | |
---|
[2662] | 145 | inline const WorldEntity* getWorldEntity() const |
---|
| 146 | { return const_cast<Pawn*>(this); } |
---|
| 147 | |
---|
| 148 | inline void setSpawnParticleSource(const std::string& source) |
---|
| 149 | { this->spawnparticlesource_ = source; } |
---|
| 150 | inline const std::string& getSpawnParticleSource() const |
---|
| 151 | { return this->spawnparticlesource_; } |
---|
| 152 | |
---|
| 153 | inline void setSpawnParticleDuration(float duration) |
---|
| 154 | { this->spawnparticleduration_ = duration; } |
---|
| 155 | inline float getSpawnParticleDuration() const |
---|
| 156 | { return this->spawnparticleduration_; } |
---|
| 157 | |
---|
| 158 | inline void setExplosionChunks(unsigned int chunks) |
---|
| 159 | { this->numexplosionchunks_ = chunks; } |
---|
| 160 | inline unsigned int getExplosionChunks() const |
---|
| 161 | { return this->numexplosionchunks_; } |
---|
| 162 | |
---|
[3089] | 163 | virtual void startLocalHumanControl(); |
---|
[2662] | 164 | |
---|
[6417] | 165 | void setAimPosition( Vector3 position ) |
---|
| 166 | { this->aimPosition_ = position; } |
---|
| 167 | Vector3 getAimPosition() |
---|
| 168 | { return this->aimPosition_; } |
---|
[7163] | 169 | |
---|
[7547] | 170 | virtual const Vector3& getCarrierPosition(void) const |
---|
[6540] | 171 | { return this->getWorldPosition(); }; |
---|
[8891] | 172 | virtual void changedActivity(void); //!< To enable radarviewability when the activity is changed |
---|
| 173 | virtual void changedVisibility(void); //!< To enable proper radarviewability when the visibility is changed |
---|
[6417] | 174 | |
---|
[2072] | 175 | protected: |
---|
[7889] | 176 | virtual void preDestroy(); |
---|
| 177 | |
---|
[3038] | 178 | virtual void setPlayer(PlayerInfo* player); |
---|
| 179 | virtual void removePlayer(); |
---|
| 180 | |
---|
[2072] | 181 | virtual void death(); |
---|
[3087] | 182 | virtual void goWithStyle(); |
---|
[2662] | 183 | virtual void deatheffect(); |
---|
| 184 | virtual void spawneffect(); |
---|
[2072] | 185 | |
---|
[8706] | 186 | //virtual void damage(float damage, Pawn* originator = 0); |
---|
| 187 | virtual void damage(float damage, float healthdamage = 0.0f, float shielddamage = 0.0f, Pawn* originator = NULL); |
---|
[6417] | 188 | |
---|
[2072] | 189 | bool bAlive_; |
---|
| 190 | |
---|
[7547] | 191 | virtual std::vector<PickupCarrier*>* getCarrierChildren(void) const |
---|
[6711] | 192 | { return new std::vector<PickupCarrier*>(); } |
---|
[7547] | 193 | virtual PickupCarrier* getCarrierParent(void) const |
---|
[6524] | 194 | { return NULL; } |
---|
[2662] | 195 | |
---|
[2072] | 196 | float health_; |
---|
| 197 | float maxHealth_; |
---|
| 198 | float initialHealth_; |
---|
[8891] | 199 | |
---|
[7163] | 200 | float shieldHealth_; |
---|
[8706] | 201 | float maxShieldHealth_; |
---|
| 202 | float initialShieldHealth_; |
---|
[7163] | 203 | float shieldAbsorption_; // Has to be between 0 and 1 |
---|
[8706] | 204 | float reloadRate_; |
---|
| 205 | float reloadWaitTime_; |
---|
| 206 | float reloadWaitCountdown_; |
---|
[2072] | 207 | |
---|
[7655] | 208 | WeakPtr<Pawn> lastHitOriginator_; |
---|
[2098] | 209 | |
---|
| 210 | WeaponSystem* weaponSystem_; |
---|
[3053] | 211 | bool bReload_; |
---|
[2662] | 212 | |
---|
| 213 | std::string spawnparticlesource_; |
---|
| 214 | float spawnparticleduration_; |
---|
| 215 | unsigned int numexplosionchunks_; |
---|
[3053] | 216 | |
---|
| 217 | private: |
---|
[7163] | 218 | void registerVariables(); |
---|
[3053] | 219 | inline void setWeaponSystem(WeaponSystem* weaponsystem) |
---|
| 220 | { this->weaponSystem_ = weaponsystem; } |
---|
[6417] | 221 | |
---|
| 222 | Vector3 aimPosition_; |
---|
[6711] | 223 | }; // tolua_export |
---|
| 224 | } // tolua_export |
---|
[2072] | 225 | |
---|
| 226 | #endif /* _Pawn_H__ */ |
---|