Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 10000 was 9948, checked in by landauf, 11 years ago

comment

  • Property svn:eol-style set to native
File size: 9.1 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
39
40namespace orxonox // tolua_export
41{ // tolua_export
42    class _OrxonoxExport Pawn // tolua_export
43        : public ControllableEntity, public RadarViewable, public PickupCarrier
44    { // tolua_export
45        friend class WeaponSystem;
46
47        public:
48            Pawn(Context* context);
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
57
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); }
63            inline float getHealth() const
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
76            virtual void setShieldHealth(float shieldHealth);
77
78            inline float getShieldHealth()
79                { return this->shieldHealth_; }
80
81            inline void addShieldHealth(float amount)
82                { this->setShieldHealth(this->shieldHealth_ + amount); }
83
84            inline bool hasShield()
85                { return (this->getShieldHealth() > 0); }
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
101            inline void setShieldAbsorption(float shieldAbsorption)
102                { this->shieldAbsorption_ = shieldAbsorption; }
103            inline float getShieldAbsorption()
104                { return this->shieldAbsorption_; }
105
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()
116                { this->reloadWaitCountdown_ = 0; }
117
118            inline void startReloadCountdown()
119                { this->reloadWaitCountdown_ = this->getReloadWaitTime(); } // TODO: Implement in Projectile.cc
120
121            virtual void decreaseReloadCountdownTime(float dt);
122
123            inline ControllableEntity* getLastHitOriginator() const
124                { return this->lastHitOriginator_; }
125
126            //virtual void hit(Pawn* originator, const Vector3& force, float damage);
127            //virtual void hit(Pawn* originator, btManifoldPoint& contactpoint, float damage);
128            virtual void hit(Pawn* originator, const Vector3& force, float damage, float healthdamage = 0.0f, float shielddamage = 0.0f);
129            virtual void hit(Pawn* originator, btManifoldPoint& contactpoint, float damage, float healthdamage = 0.0f, float shielddamage = 0.0f);
130
131            virtual void kill();
132
133            virtual void fired(unsigned int firemode);
134            virtual void reload();
135            virtual void postSpawn();
136
137            void addWeaponSlot(WeaponSlot * wSlot);
138            WeaponSlot * getWeaponSlot(unsigned int index) const;
139            void addWeaponSet(WeaponSet * wSet);
140            WeaponSet * getWeaponSet(unsigned int index) const;
141            void addWeaponPack(WeaponPack * wPack);
142            void addWeaponPackXML(WeaponPack * wPack);
143            WeaponPack * getWeaponPack(unsigned int index) const;
144
145            virtual void addedWeaponPack(WeaponPack* wPack) {}
146
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
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
169            virtual void startLocalHumanControl();
170
171            void setAimPosition( Vector3 position )
172                { this->aimPosition_ = position; }
173            Vector3 getAimPosition()
174                { return this->aimPosition_; }
175
176            virtual const Vector3& getCarrierPosition(void) const
177                { return this->getWorldPosition(); };
178
179            virtual void changedVisibility();
180
181            void setExplosionSound(const std::string& engineSound);
182            const std::string& getExplosionSound();
183
184        protected:
185            virtual void preDestroy();
186
187            virtual void setPlayer(PlayerInfo* player);
188            virtual void removePlayer();
189
190            virtual void death();
191            virtual bool hasSlaves();
192            virtual Controller* getSlave();
193            virtual void goWithStyle();
194            virtual void deatheffect();
195            virtual void spawneffect();
196
197            //virtual void damage(float damage, Pawn* originator = 0);
198            virtual void damage(float damage, float healthdamage = 0.0f, float shielddamage = 0.0f, Pawn* originator = NULL);
199
200            bool bAlive_;
201
202            virtual std::vector<PickupCarrier*>* getCarrierChildren(void) const
203                { return new std::vector<PickupCarrier*>(); }
204            virtual PickupCarrier* getCarrierParent(void) const
205                { return NULL; }
206
207
208            float health_;
209            float maxHealth_;
210            float initialHealth_;
211
212            float shieldHealth_;
213            float maxShieldHealth_;
214            float initialShieldHealth_;
215            float shieldAbsorption_; ///< Has to be between 0 and 1
216            float reloadRate_;
217            float reloadWaitTime_;
218            float reloadWaitCountdown_;
219
220            float damageMultiplier_; ///< Used by the Damage Boost Pickup.
221
222            WeakPtr<Pawn> lastHitOriginator_;
223
224            WeaponSystem* weaponSystem_;
225            bool bReload_;
226
227            std::string spawnparticlesource_;
228            float spawnparticleduration_;
229            unsigned int numexplosionchunks_;
230
231        private:
232            void registerVariables();
233            inline void setWeaponSystem(WeaponSystem* weaponsystem)
234                { this->weaponSystem_ = weaponsystem; }
235
236            Vector3 aimPosition_;
237
238            WorldSound* explosionSound_; // TODO: Does this really belong here? Maybe move it to BigExplosion?
239
240    }; // tolua_export
241} // tolua_export
242
243#endif /* _Pawn_H__ */
Note: See TracBrowser for help on using the repository browser.