Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/fabienHS15/src/orxonox/worldentities/pawns/Pawn.h @ 10791

Last change on this file since 10791 was 10791, checked in by fvultier, 9 years ago

Munition may and must now be defined for each pawn separately. This way a heavy cruiser may carry more munition than a drone.

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