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