Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/explosionChunksHS15/src/orxonox/worldentities/pawns/Pawn.h @ 10752

Last change on this file since 10752 was 10752, checked in by vaydin, 8 years ago

Deleted previously created VaydinExplosion class, created ExplosionPart class

  • 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 Orxonoy 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. The 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            // TODO: Rename to shieldRechargeRate
121            virtual void setReloadRate(float reloadrate);
122            inline float getReloadRate() const
123                { return this->reloadRate_; }
124
125            virtual void setReloadWaitTime(float reloadwaittime);
126            inline float getReloadWaitTime() const
127                { return this->reloadWaitTime_; }
128
129            inline void resetReloadCountdown()
130                { this->reloadWaitCountdown_ = 0; }
131
132            inline void startReloadCountdown()
133                { this->reloadWaitCountdown_ = this->getReloadWaitTime(); } // TODO: Implement in Projectile.cc
134
135            virtual void decreaseReloadCountdownTime(float dt);
136
137            inline ControllableEntity* getLastHitOriginator() const
138                { return this->lastHitOriginator_; }
139
140            //virtual void hit(Pawn* originator, const Vector3& force, float damage);
141            //virtual void hit(Pawn* originator, btManifoldPoint& contactpoint, float damage);
142            virtual void hit(Pawn* originator, const Vector3& force, const btCollisionShape* cs, float damage, float healthdamage = 0.0f, float shielddamage = 0.0f);
143            virtual void hit(Pawn* originator, btManifoldPoint& contactpoint, const btCollisionShape* cs, float damage, float healthdamage = 0.0f, float shielddamage = 0.0f);
144
145            virtual void kill();
146
147            virtual void fired(unsigned int firemode);
148            virtual void reload();
149            virtual void postSpawn();
150
151            void addExplosionPart(ExplosionPart* ePart);
152            ExplosionPart * getExplosionPart();
153
154            void addWeaponSlot(WeaponSlot * wSlot);
155            WeaponSlot * getWeaponSlot(unsigned int index) const;
156            void addWeaponSet(WeaponSet * wSet);
157            WeaponSet * getWeaponSet(unsigned int index) const;
158            void addWeaponPack(WeaponPack * wPack);
159            void addWeaponPackXML(WeaponPack * wPack);
160            WeaponPack * getWeaponPack(unsigned int index) const;
161
162            virtual void addedWeaponPack(WeaponPack* wPack) {}
163
164            inline void setSpawnParticleSource(const std::string& source)
165                { this->spawnparticlesource_ = source; }
166            inline const std::string& getSpawnParticleSource() const
167                { return this->spawnparticlesource_; }
168
169            inline void setSpawnParticleDuration(float duration)
170                { this->spawnparticleduration_ = duration; }
171            inline float getSpawnParticleDuration() const
172                { return this->spawnparticleduration_; }
173
174            inline void setExplosionChunks(unsigned int chunks)
175                { this->numexplosionchunks_ = chunks; }
176            inline unsigned int getExplosionChunks() const
177                { return this->numexplosionchunks_; }
178
179            // These are used with the Damage Boost Pickup to use the damage multiplier.
180            inline void setDamageMultiplier(float multiplier)
181                { this->damageMultiplier_ = multiplier; }
182            inline float getDamageMultiplier() const
183                { return this->damageMultiplier_; }
184
185
186            virtual void startLocalHumanControl();
187
188            void setAimPosition( Vector3 position )
189                { this->aimPosition_ = position; }
190            Vector3 getAimPosition()
191                { return this->aimPosition_; }
192
193            virtual const Vector3& getCarrierPosition(void) const
194                { return this->getWorldPosition(); };
195
196            virtual void changedVisibility();
197
198            void setExplosionSound(const std::string& engineSound);
199            const std::string& getExplosionSound();
200
201        protected:
202            virtual void preDestroy();
203
204            virtual void setPlayer(PlayerInfo* player);
205            virtual void removePlayer();
206
207            virtual void death();
208            virtual bool hasSlaves();
209            virtual Controller* getSlave();
210            virtual void goWithStyle();
211            virtual void deatheffect();
212            virtual void spawneffect();
213
214            //virtual void damage(float damage, Pawn* originator = 0);
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 reloadRate_;
234            float reloadWaitTime_;
235            float reloadWaitCountdown_;
236
237            float damageMultiplier_; ///< Used by the Damage Boost Pickup.
238
239            WeakPtr<Pawn> lastHitOriginator_;
240
241            WeaponSystem* weaponSystem_;
242            bool bReload_;
243
244            std::string spawnparticlesource_;
245            float spawnparticleduration_;
246            unsigned int numexplosionchunks_;
247
248            std::vector<ExplosionPart*> explosionPartList_;
249
250        private:
251            void registerVariables();
252            inline void setWeaponSystem(WeaponSystem* weaponsystem)
253                { this->weaponSystem_ = weaponsystem; }
254
255            Vector3 aimPosition_;
256
257            WorldSound* explosionSound_; // TODO: Does this really belong here? Maybe move it to BigExplosion?
258
259    }; // tolua_export
260} // tolua_export
261
262#endif /* _Pawn_H__ */
Note: See TracBrowser for help on using the repository browser.