Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/src/orxonox/worldentities/pawns/Pawn.h @ 10368

Last change on this file since 10368 was 10216, checked in by landauf, 10 years ago

merged branch presentationFS14 back to trunk

  • Property svn:eol-style set to native
File size: 9.2 KB
RevLine 
[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
[9939]39
[6711]40namespace orxonox // tolua_export
41{ // tolua_export
42    class _OrxonoxExport Pawn // tolua_export
43        : public ControllableEntity, public RadarViewable, public PickupCarrier
44    { // tolua_export
[3053]45        friend class WeaponSystem;
46
[2072]47        public:
[9667]48            Pawn(Context* context);
[2072]49            virtual ~Pawn();
50
51            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
52            virtual void tick(float dt);
53
54            inline bool isAlive() const
55                { return this->bAlive_; }
56
[9016]57
[2072]58            virtual void setHealth(float health);
59            inline void addHealth(float health)
60                { this->setHealth(this->health_ + health); }
61            inline void removeHealth(float health)
62                { this->setHealth(this->health_ - health); }
[2662]63            inline float getHealth() const
[2072]64                { return this->health_; }
65
66            inline void setMaxHealth(float maxhealth)
67                { this->maxHealth_ = maxhealth; this->setHealth(this->health_); }
68            inline float getMaxHealth() const
69                { return this->maxHealth_; }
70
71            inline void setInitialHealth(float initialhealth)
72                { this->initialHealth_ = initialhealth; this->setHealth(initialhealth); }
73            inline float getInitialHealth() const
74                { return this->initialHealth_; }
75
[8706]76            virtual void setShieldHealth(float shieldHealth);
77
[7163]78            inline float getShieldHealth()
[8855]79                { return this->shieldHealth_; }
[7163]80
[8706]81            inline void addShieldHealth(float amount)
[8855]82                { this->setShieldHealth(this->shieldHealth_ + amount); }
[8706]83
84            inline bool hasShield()
[8855]85                { return (this->getShieldHealth() > 0); }
[8706]86
87            virtual void setMaxShieldHealth(float maxshieldhealth);
88            inline float getMaxShieldHealth() const
89                { return this->maxShieldHealth_; }
90
91            inline void setInitialShieldHealth(float initialshieldhealth)
92                { this->initialShieldHealth_ = initialshieldhealth; this->setShieldHealth(initialshieldhealth); }
93            inline float getInitialShieldHealth() const
94                { return this->initialShieldHealth_; }
95
96            inline void restoreInitialShieldHealth()
97                { this->setShieldHealth(this->initialShieldHealth_); }
98            inline void restoreMaxShieldHealth()
99                { this->setShieldHealth(this->maxShieldHealth_); }
100
[7163]101            inline void setShieldAbsorption(float shieldAbsorption)
[8855]102                { this->shieldAbsorption_ = shieldAbsorption; }
[7163]103            inline float getShieldAbsorption()
[8855]104                { return this->shieldAbsorption_; }
[7163]105
[8706]106            // TODO: Rename to shieldRechargeRate
107            virtual void setReloadRate(float reloadrate);
108            inline float getReloadRate() const
109                { return this->reloadRate_; }
110
111            virtual void setReloadWaitTime(float reloadwaittime);
112            inline float getReloadWaitTime() const
113                { return this->reloadWaitTime_; }
114
115            inline void resetReloadCountdown()
[8855]116                { this->reloadWaitCountdown_ = 0; }
[8706]117
118            inline void startReloadCountdown()
[8855]119                { this->reloadWaitCountdown_ = this->getReloadWaitTime(); } // TODO: Implement in Projectile.cc
[8706]120
121            virtual void decreaseReloadCountdownTime(float dt);
122
[2072]123            inline ControllableEntity* getLastHitOriginator() const
124                { return this->lastHitOriginator_; }
125
[8706]126            //virtual void hit(Pawn* originator, const Vector3& force, float damage);
127            //virtual void hit(Pawn* originator, btManifoldPoint& contactpoint, float damage);
[10216]128            virtual void hit(Pawn* originator, const Vector3& force, const btCollisionShape* cs, float damage, float healthdamage = 0.0f, float shielddamage = 0.0f);
129            virtual void hit(Pawn* originator, btManifoldPoint& contactpoint, const btCollisionShape* cs, float damage, float healthdamage = 0.0f, float shielddamage = 0.0f);
[8706]130
[2072]131            virtual void kill();
132
[6417]133            virtual void fired(unsigned int firemode);
[3053]134            virtual void reload();
[2072]135            virtual void postSpawn();
136
[3053]137            void addWeaponSlot(WeaponSlot * wSlot);
[2662]138            WeaponSlot * getWeaponSlot(unsigned int index) const;
[3053]139            void addWeaponSet(WeaponSet * wSet);
[2662]140            WeaponSet * getWeaponSet(unsigned int index) const;
[3053]141            void addWeaponPack(WeaponPack * wPack);
[6417]142            void addWeaponPackXML(WeaponPack * wPack);
[3053]143            WeaponPack * getWeaponPack(unsigned int index) const;
[2662]144
[7163]145            virtual void addedWeaponPack(WeaponPack* wPack) {}
146
[2662]147            inline void setSpawnParticleSource(const std::string& source)
148                { this->spawnparticlesource_ = source; }
149            inline const std::string& getSpawnParticleSource() const
150                { return this->spawnparticlesource_; }
151
152            inline void setSpawnParticleDuration(float duration)
153                { this->spawnparticleduration_ = duration; }
154            inline float getSpawnParticleDuration() const
155                { return this->spawnparticleduration_; }
156
157            inline void setExplosionChunks(unsigned int chunks)
158                { this->numexplosionchunks_ = chunks; }
159            inline unsigned int getExplosionChunks() const
160                { return this->numexplosionchunks_; }
161
[9348]162            // These are used with the Damage Boost Pickup to use the damage multiplier.
163            inline void setDamageMultiplier(float multiplier)
164                { this->damageMultiplier_ = multiplier; }
165            inline float getDamageMultiplier() const
166                { return this->damageMultiplier_; }
167
168
[3089]169            virtual void startLocalHumanControl();
[2662]170
[6417]171            void setAimPosition( Vector3 position )
172                { this->aimPosition_ = position; }
173            Vector3 getAimPosition()
174                { return this->aimPosition_; }
[7163]175
[7547]176            virtual const Vector3& getCarrierPosition(void) const
[6540]177                { return this->getWorldPosition(); };
[6417]178
[9254]179            virtual void changedVisibility();
180
[9939]181            void setExplosionSound(const std::string& engineSound);
182            const std::string& getExplosionSound();
183
[2072]184        protected:
[7889]185            virtual void preDestroy();
186
[3038]187            virtual void setPlayer(PlayerInfo* player);
188            virtual void removePlayer();
189
[2072]190            virtual void death();
[9625]191            virtual bool hasSlaves();
192            virtual Controller* getSlave();
[3087]193            virtual void goWithStyle();
[2662]194            virtual void deatheffect();
195            virtual void spawneffect();
[2072]196
[8706]197            //virtual void damage(float damage, Pawn* originator = 0);
[10216]198            virtual void damage(float damage, float healthdamage = 0.0f, float shielddamage = 0.0f, Pawn* originator = NULL, const btCollisionShape* cs = NULL);
[6417]199
[2072]200            bool bAlive_;
201
[7547]202            virtual std::vector<PickupCarrier*>* getCarrierChildren(void) const
[6711]203                { return new std::vector<PickupCarrier*>(); }
[7547]204            virtual PickupCarrier* getCarrierParent(void) const
[6524]205                { return NULL; }
[2662]206
[9016]207
[2072]208            float health_;
209            float maxHealth_;
210            float initialHealth_;
[8891]211
[7163]212            float shieldHealth_;
[8706]213            float maxShieldHealth_;
214            float initialShieldHealth_;
[9348]215            float shieldAbsorption_; ///< Has to be between 0 and 1
[8706]216            float reloadRate_;
217            float reloadWaitTime_;
218            float reloadWaitCountdown_;
[2072]219
[9348]220            float damageMultiplier_; ///< Used by the Damage Boost Pickup.
221
[7655]222            WeakPtr<Pawn> lastHitOriginator_;
[2098]223
224            WeaponSystem* weaponSystem_;
[3053]225            bool bReload_;
[2662]226
227            std::string spawnparticlesource_;
228            float spawnparticleduration_;
229            unsigned int numexplosionchunks_;
[3053]230
231        private:
[7163]232            void registerVariables();
[3053]233            inline void setWeaponSystem(WeaponSystem* weaponsystem)
234                { this->weaponSystem_ = weaponsystem; }
[6417]235
236            Vector3 aimPosition_;
[9939]237
[9948]238            WorldSound* explosionSound_; // TODO: Does this really belong here? Maybe move it to BigExplosion?
[9939]239
[6711]240    }; // tolua_export
241} // tolua_export
[2072]242
243#endif /* _Pawn_H__ */
Note: See TracBrowser for help on using the repository browser.