Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/gameimmersion/src/orxonox/worldentities/pawns/Pawn.h @ 8183

Last change on this file since 8183 was 8183, checked in by simonmie, 13 years ago

Added countdown time before shield reload starts

  • Property svn:eol-style set to native
File size: 7.4 KB
Line 
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"
33
34#include <string>
35#include "interfaces/PickupCarrier.h"
36#include "interfaces/RadarViewable.h"
37#include "worldentities/ControllableEntity.h"
38
39namespace orxonox // tolua_export
40{ // tolua_export
41    class _OrxonoxExport Pawn // tolua_export
42        : public ControllableEntity, public RadarViewable, public PickupCarrier
43    { // tolua_export
44        friend class WeaponSystem;
45
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///////////////////////////////// me
57            virtual void setReloadRate(float reloadrate);
58            inline float getReloadRate() const
59                { return this->reloadRate_; }
60
61            inline void addShieldHealth(float amount)
62            { this->setShieldHealth(this->shieldHealth_ + amount); }
63
64            inline bool hasShield()
65            { return (this->getShieldHealth() > 0); }
66
67            virtual void setReloadWaitTime(float reloadwaittime);
68            inline float getReloadWaitTime() const
69                { return this->reloadWaitTime_; }
70
71            inline void resetReloadCountdown()
72            { this->reloadWaitCountdown_ = 0; }
73
74            inline void startReloadCountdown()
75            { this->reloadWaitCountdown_ = this->getReloadWaitTime(); } //in projectile.cc einbauen!!!!!!1111!!111!
76
77            virtual void decreaseReloadCountdownTime(float dt);
78
79///////////////////////////////// end me
80
81            virtual void setHealth(float health);
82            inline void addHealth(float health)
83                { this->setHealth(this->health_ + health); }
84            inline void removeHealth(float health)
85                { this->setHealth(this->health_ - health); }
86            inline float getHealth() const
87                { return this->health_; }
88
89            inline void setMaxHealth(float maxhealth)
90                { this->maxHealth_ = maxhealth; this->setHealth(this->health_); }
91            inline float getMaxHealth() const
92                { return this->maxHealth_; }
93
94            inline void setInitialHealth(float initialhealth)
95                { this->initialHealth_ = initialhealth; this->setHealth(initialhealth); }
96            inline float getInitialHealth() const
97                { return this->initialHealth_; }
98
99            inline void setShieldHealth(float shieldHealth)
100            { this->shieldHealth_ = shieldHealth; }
101            inline float getShieldHealth()
102            { return this->shieldHealth_; }
103
104            inline void setShieldAbsorption(float shieldAbsorption)
105            { this->shieldAbsorption_ = shieldAbsorption; }
106            inline float getShieldAbsorption()
107            { return this->shieldAbsorption_; }
108
109            inline ControllableEntity* getLastHitOriginator() const
110                { return this->lastHitOriginator_; }
111
112            virtual void hit(Pawn* originator, const Vector3& force, float damage);
113            virtual void hit(Pawn* originator, btManifoldPoint& contactpoint, float damage);
114            virtual void kill();
115
116            virtual void fired(unsigned int firemode);
117            virtual void reload();
118            virtual void postSpawn();
119
120            void addWeaponSlot(WeaponSlot * wSlot);
121            WeaponSlot * getWeaponSlot(unsigned int index) const;
122            void addWeaponSet(WeaponSet * wSet);
123            WeaponSet * getWeaponSet(unsigned int index) const;
124            void addWeaponPack(WeaponPack * wPack);
125            void addWeaponPackXML(WeaponPack * wPack);
126            WeaponPack * getWeaponPack(unsigned int index) const;
127
128            virtual void addedWeaponPack(WeaponPack* wPack) {}
129
130            inline const WorldEntity* getWorldEntity() const
131                { return const_cast<Pawn*>(this); }
132
133            inline void setSpawnParticleSource(const std::string& source)
134                { this->spawnparticlesource_ = source; }
135            inline const std::string& getSpawnParticleSource() const
136                { return this->spawnparticlesource_; }
137
138            inline void setSpawnParticleDuration(float duration)
139                { this->spawnparticleduration_ = duration; }
140            inline float getSpawnParticleDuration() const
141                { return this->spawnparticleduration_; }
142
143            inline void setExplosionChunks(unsigned int chunks)
144                { this->numexplosionchunks_ = chunks; }
145            inline unsigned int getExplosionChunks() const
146                { return this->numexplosionchunks_; }
147
148            virtual void startLocalHumanControl();
149
150            void setAimPosition( Vector3 position )
151                { this->aimPosition_ = position; }
152            Vector3 getAimPosition()
153                { return this->aimPosition_; }
154
155            virtual const Vector3& getCarrierPosition(void) const
156                { return this->getWorldPosition(); };
157
158        protected:
159            virtual void preDestroy();
160
161            virtual void setPlayer(PlayerInfo* player);
162            virtual void removePlayer();
163
164            virtual void death();
165            virtual void goWithStyle();
166            virtual void deatheffect();
167            virtual void spawneffect();
168
169            virtual void damage(float damage, Pawn* originator = 0);
170
171            bool bAlive_;
172
173            virtual std::vector<PickupCarrier*>* getCarrierChildren(void) const
174                { return new std::vector<PickupCarrier*>(); }
175            virtual PickupCarrier* getCarrierParent(void) const
176                { return NULL; }
177
178/////////////////////////// me
179            float reloadRate_;
180            float reloadWaitTime_;
181            float reloadWaitCountdown_;
182
183////////////////////////// end me
184
185            float health_;
186            float maxHealth_;
187            float initialHealth_;
188            float shieldHealth_;
189            float shieldAbsorption_; // Has to be between 0 and 1
190
191            WeakPtr<Pawn> lastHitOriginator_;
192
193            WeaponSystem* weaponSystem_;
194            bool bReload_;
195
196            std::string spawnparticlesource_;
197            float spawnparticleduration_;
198            unsigned int numexplosionchunks_;
199
200        private:
201            void registerVariables();
202            inline void setWeaponSystem(WeaponSystem* weaponsystem)
203                { this->weaponSystem_ = weaponsystem; }
204
205            Vector3 aimPosition_;
206    }; // tolua_export
207} // tolua_export
208
209#endif /* _Pawn_H__ */
Note: See TracBrowser for help on using the repository browser.