Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/presentationHS15/src/orxonox/worldentities/pawns/Pawn.h @ 10962

Last change on this file since 10962 was 10962, checked in by maxima, 8 years ago

Merged presentation and exlposionChunks branches. Works fine. Added explosion parts to hovership.

  • Property svn:eol-style set to native
File size: 9.8 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 <vector>
36#include "interfaces/PickupCarrier.h"
37#include "interfaces/RadarViewable.h"
38#include "worldentities/ControllableEntity.h"
39#include "worldentities/ExplosionPart.h"
40
41
42namespace orxonox // tolua_export
43{
44    /**
45    @brief
46        Everything in Orxonox that has a health attribute is a Pawn. After a Pawn is spawned its health is set to
47        its initial health. In every call of the Pawns tick function the game checks whether the pawns health is at
48        or below zero. If it is, the pawn gets killed.
49
50        Pawns can carry pickups and fire weapons. They can also have shields.
51
52        Notice that every Pawn is a ControllableEntity.
53    */
54
55    // tolua_export
56    class _OrxonoxExport Pawn // tolua_export
57        : public ControllableEntity, public RadarViewable, public PickupCarrier
58    { // tolua_export
59        friend class WeaponSystem;
60
61        public:
62            Pawn(Context* context);
63            virtual ~Pawn();
64
65            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
66            virtual void tick(float dt);
67
68            inline bool isAlive() const
69                { return this->bAlive_; }
70
71
72            virtual void setHealth(float health);
73            inline void addHealth(float health)
74                { this->setHealth(this->health_ + health); }
75            inline void removeHealth(float health)
76                { this->setHealth(this->health_ - health); }
77            inline float getHealth() const
78                { return this->health_; }
79
80            inline void setMaxHealth(float maxhealth)
81                { this->maxHealth_ = maxhealth; this->setHealth(this->health_); }
82            inline float getMaxHealth() const
83                { return this->maxHealth_; }
84
85            inline void setInitialHealth(float initialhealth)
86                { this->initialHealth_ = initialhealth; this->setHealth(initialhealth); }
87            inline float getInitialHealth() const
88                { return this->initialHealth_; }
89
90            virtual void setShieldHealth(float shieldHealth);
91
92            inline float getShieldHealth()
93                { return this->shieldHealth_; }
94
95            inline void addShieldHealth(float amount)
96                { this->setShieldHealth(this->shieldHealth_ + amount); }
97
98            inline bool hasShield()
99                { return (this->getShieldHealth() > 0); }
100
101            virtual void setMaxShieldHealth(float maxshieldhealth);
102            inline float getMaxShieldHealth() const
103                { return this->maxShieldHealth_; }
104
105            inline void setInitialShieldHealth(float initialshieldhealth)
106                { this->initialShieldHealth_ = initialshieldhealth; this->setShieldHealth(initialshieldhealth); }
107            inline float getInitialShieldHealth() const
108                { return this->initialShieldHealth_; }
109
110            inline void restoreInitialShieldHealth()
111                { this->setShieldHealth(this->initialShieldHealth_); }
112            inline void restoreMaxShieldHealth()
113                { this->setShieldHealth(this->maxShieldHealth_); }
114
115            inline void setShieldAbsorption(float shieldAbsorption)
116                { this->shieldAbsorption_ = shieldAbsorption; }
117            inline float getShieldAbsorption()
118                { return this->shieldAbsorption_; }
119
120            virtual void setShieldRechargeRate(float shieldRechargeRate);
121            inline float getShieldRechargeRate() const
122                { return this->shieldRechargeRate_; }
123
124            virtual void setShieldRechargeWaitTime(float shieldRechargeWaitTime);
125            inline float getShieldRechargeWaitTime() const
126                { return this->shieldRechargeWaitTime_; }
127
128            inline void resetShieldRechargeCountdown()
129                { this->shieldRechargeWaitCountdown_ = 0; }
130
131            inline void startShieldRechargeCountdown()
132                { this->shieldRechargeWaitCountdown_ = this->getShieldRechargeWaitTime(); } // TODO: Implement in Projectile.cc
133
134            virtual void decreaseShieldRechargeCountdownTime(float dt);
135
136            inline ControllableEntity* getLastHitOriginator() const
137                { return this->lastHitOriginator_; }
138
139            virtual void hit(Pawn* originator, const Vector3& force, const btCollisionShape* cs, float damage, float healthdamage = 0.0f, float shielddamage = 0.0f);
140            virtual void hit(Pawn* originator, btManifoldPoint& contactpoint, const btCollisionShape* cs, float damage, float healthdamage = 0.0f, float shielddamage = 0.0f);
141
142            virtual void kill();
143
144            virtual void fired(unsigned int firemode);
145            virtual void postSpawn();
146
147            void addExplosionPart(ExplosionPart* ePart);
148            ExplosionPart * getExplosionPart();
149
150            void addWeaponSlot(WeaponSlot * wSlot);
151            WeaponSlot * getWeaponSlot(unsigned int index) const;
152            void addWeaponSet(WeaponSet * wSet);
153            WeaponSet * getWeaponSet(unsigned int index) const;
154            void addWeaponPack(WeaponPack * wPack);
155            void addWeaponPackXML(WeaponPack * wPack);
156            WeaponPack * getWeaponPack(unsigned int index) const;
157            std::vector<WeaponPack *> * getAllWeaponPacks();
158
159            void addMunitionXML(Munition* munition);
160            Munition* getMunitionXML() const;
161           
162            Munition* getMunition(SubclassIdentifier<Munition> * identifier);
163
164            virtual void addedWeaponPack(WeaponPack* wPack) {}
165
166            inline void setSpawnParticleSource(const std::string& source)
167                { this->spawnparticlesource_ = source; }
168            inline const std::string& getSpawnParticleSource() const
169                { return this->spawnparticlesource_; }
170
171            inline void setSpawnParticleDuration(float duration)
172                { this->spawnparticleduration_ = duration; }
173            inline float getSpawnParticleDuration() const
174                { return this->spawnparticleduration_; }
175
176            inline void setExplosionChunks(unsigned int chunks)
177                { this->numexplosionchunks_ = chunks; }
178            inline unsigned int getExplosionChunks() const
179                { return this->numexplosionchunks_; }
180
181            // These are used with the Damage Boost Pickup to use the damage multiplier.
182            inline void setDamageMultiplier(float multiplier)
183                { this->damageMultiplier_ = multiplier; }
184            inline float getDamageMultiplier() const
185                { return this->damageMultiplier_; }
186
187
188            virtual void startLocalHumanControl();
189
190            void setAimPosition( Vector3 position )
191                { this->aimPosition_ = position; }
192            Vector3 getAimPosition()
193                { return this->aimPosition_; }
194
195            virtual const Vector3& getCarrierPosition(void) const
196                { return this->getWorldPosition(); };
197
198            virtual void changedVisibility();
199
200            void setExplosionSound(const std::string& engineSound);
201            const std::string& getExplosionSound();
202
203        protected:
204            virtual void preDestroy();
205
206            virtual void setPlayer(PlayerInfo* player);
207            virtual void removePlayer();
208
209            virtual void death();
210            virtual bool hasSlaves();
211            virtual Controller* getSlave();
212            virtual void goWithStyle();
213            virtual void spawneffect();
214
215            virtual void damage(float damage, float healthdamage = 0.0f, float shielddamage = 0.0f, Pawn* originator = NULL, const btCollisionShape* cs = NULL);
216
217            bool bAlive_;
218
219            virtual std::vector<PickupCarrier*>* getCarrierChildren(void) const
220                { return new std::vector<PickupCarrier*>(); }
221            virtual PickupCarrier* getCarrierParent(void) const
222                { return NULL; }
223
224
225            float health_;
226            float maxHealth_;
227            float initialHealth_;
228
229            float shieldHealth_;
230            float maxShieldHealth_;
231            float initialShieldHealth_;
232            float shieldAbsorption_; ///< Has to be between 0 and 1
233            float shieldRechargeRate_;
234            float shieldRechargeWaitTime_;
235            float shieldRechargeWaitCountdown_;
236
237            float damageMultiplier_; ///< Used by the Damage Boost Pickup.
238
239            WeakPtr<Pawn> lastHitOriginator_;
240
241            WeaponSystem* weaponSystem_;
242
243            std::string spawnparticlesource_;
244            float spawnparticleduration_;
245            unsigned int numexplosionchunks_;
246
247            std::vector<ExplosionPart*> explosionPartList_;
248
249        private:
250            void registerVariables();
251            inline void setWeaponSystem(WeaponSystem* weaponsystem)
252                { this->weaponSystem_ = weaponsystem; }
253
254            Vector3 aimPosition_;
255
256            WorldSound* explosionSound_; // TODO: Does this really belong here? Maybe move it to BigExplosion?
257
258    }; // tolua_export
259} // tolua_export
260
261#endif /* _Pawn_H__ */
Note: See TracBrowser for help on using the repository browser.