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
RevLine 
[2072]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"
[3196]33
34#include <string>
[10962]35#include <vector>
[6524]36#include "interfaces/PickupCarrier.h"
[3196]37#include "interfaces/RadarViewable.h"
[5735]38#include "worldentities/ControllableEntity.h"
[10962]39#include "worldentities/ExplosionPart.h"
[2072]40
[9939]41
[6711]42namespace orxonox // tolua_export
[10437]43{
44    /**
45    @brief
[10961]46        Everything in Orxonox that has a health attribute is a Pawn. After a Pawn is spawned its health is set to
[10437]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
[10961]50        Pawns can carry pickups and fire weapons. They can also have shields.
[10437]51
52        Notice that every Pawn is a ControllableEntity.
53    */
54
55    // tolua_export
[6711]56    class _OrxonoxExport Pawn // tolua_export
57        : public ControllableEntity, public RadarViewable, public PickupCarrier
58    { // tolua_export
[3053]59        friend class WeaponSystem;
60
[2072]61        public:
[9667]62            Pawn(Context* context);
[2072]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
[9016]71
[2072]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); }
[2662]77            inline float getHealth() const
[2072]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
[8706]90            virtual void setShieldHealth(float shieldHealth);
91
[7163]92            inline float getShieldHealth()
[8855]93                { return this->shieldHealth_; }
[7163]94
[8706]95            inline void addShieldHealth(float amount)
[8855]96                { this->setShieldHealth(this->shieldHealth_ + amount); }
[8706]97
98            inline bool hasShield()
[8855]99                { return (this->getShieldHealth() > 0); }
[8706]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
[7163]115            inline void setShieldAbsorption(float shieldAbsorption)
[8855]116                { this->shieldAbsorption_ = shieldAbsorption; }
[7163]117            inline float getShieldAbsorption()
[8855]118                { return this->shieldAbsorption_; }
[7163]119
[10961]120            virtual void setShieldRechargeRate(float shieldRechargeRate);
121            inline float getShieldRechargeRate() const
122                { return this->shieldRechargeRate_; }
[8706]123
[10961]124            virtual void setShieldRechargeWaitTime(float shieldRechargeWaitTime);
125            inline float getShieldRechargeWaitTime() const
126                { return this->shieldRechargeWaitTime_; }
[8706]127
[10961]128            inline void resetShieldRechargeCountdown()
129                { this->shieldRechargeWaitCountdown_ = 0; }
[8706]130
[10961]131            inline void startShieldRechargeCountdown()
132                { this->shieldRechargeWaitCountdown_ = this->getShieldRechargeWaitTime(); } // TODO: Implement in Projectile.cc
[8706]133
[10961]134            virtual void decreaseShieldRechargeCountdownTime(float dt);
[8706]135
[2072]136            inline ControllableEntity* getLastHitOriginator() const
137                { return this->lastHitOriginator_; }
138
[10216]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);
[8706]141
[2072]142            virtual void kill();
143
[6417]144            virtual void fired(unsigned int firemode);
[2072]145            virtual void postSpawn();
146
[10962]147            void addExplosionPart(ExplosionPart* ePart);
148            ExplosionPart * getExplosionPart();
149
[3053]150            void addWeaponSlot(WeaponSlot * wSlot);
[2662]151            WeaponSlot * getWeaponSlot(unsigned int index) const;
[3053]152            void addWeaponSet(WeaponSet * wSet);
[2662]153            WeaponSet * getWeaponSet(unsigned int index) const;
[3053]154            void addWeaponPack(WeaponPack * wPack);
[6417]155            void addWeaponPackXML(WeaponPack * wPack);
[3053]156            WeaponPack * getWeaponPack(unsigned int index) const;
[10961]157            std::vector<WeaponPack *> * getAllWeaponPacks();
[2662]158
[10961]159            void addMunitionXML(Munition* munition);
160            Munition* getMunitionXML() const;
161           
162            Munition* getMunition(SubclassIdentifier<Munition> * identifier);
163
[7163]164            virtual void addedWeaponPack(WeaponPack* wPack) {}
165
[2662]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
[9348]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
[3089]188            virtual void startLocalHumanControl();
[2662]189
[6417]190            void setAimPosition( Vector3 position )
191                { this->aimPosition_ = position; }
192            Vector3 getAimPosition()
193                { return this->aimPosition_; }
[7163]194
[7547]195            virtual const Vector3& getCarrierPosition(void) const
[6540]196                { return this->getWorldPosition(); };
[6417]197
[9254]198            virtual void changedVisibility();
199
[9939]200            void setExplosionSound(const std::string& engineSound);
201            const std::string& getExplosionSound();
202
[2072]203        protected:
[7889]204            virtual void preDestroy();
205
[3038]206            virtual void setPlayer(PlayerInfo* player);
207            virtual void removePlayer();
208
[2072]209            virtual void death();
[9625]210            virtual bool hasSlaves();
211            virtual Controller* getSlave();
[3087]212            virtual void goWithStyle();
[2662]213            virtual void spawneffect();
[2072]214
[10216]215            virtual void damage(float damage, float healthdamage = 0.0f, float shielddamage = 0.0f, Pawn* originator = NULL, const btCollisionShape* cs = NULL);
[6417]216
[2072]217            bool bAlive_;
218
[7547]219            virtual std::vector<PickupCarrier*>* getCarrierChildren(void) const
[6711]220                { return new std::vector<PickupCarrier*>(); }
[7547]221            virtual PickupCarrier* getCarrierParent(void) const
[6524]222                { return NULL; }
[2662]223
[9016]224
[2072]225            float health_;
226            float maxHealth_;
227            float initialHealth_;
[8891]228
[7163]229            float shieldHealth_;
[8706]230            float maxShieldHealth_;
231            float initialShieldHealth_;
[9348]232            float shieldAbsorption_; ///< Has to be between 0 and 1
[10961]233            float shieldRechargeRate_;
234            float shieldRechargeWaitTime_;
235            float shieldRechargeWaitCountdown_;
[2072]236
[9348]237            float damageMultiplier_; ///< Used by the Damage Boost Pickup.
238
[7655]239            WeakPtr<Pawn> lastHitOriginator_;
[2098]240
241            WeaponSystem* weaponSystem_;
[2662]242
243            std::string spawnparticlesource_;
244            float spawnparticleduration_;
245            unsigned int numexplosionchunks_;
[3053]246
[10962]247            std::vector<ExplosionPart*> explosionPartList_;
248
[3053]249        private:
[7163]250            void registerVariables();
[3053]251            inline void setWeaponSystem(WeaponSystem* weaponsystem)
252                { this->weaponSystem_ = weaponsystem; }
[6417]253
254            Vector3 aimPosition_;
[9939]255
[9948]256            WorldSound* explosionSound_; // TODO: Does this really belong here? Maybe move it to BigExplosion?
[9939]257
[6711]258    }; // tolua_export
259} // tolua_export
[2072]260
261#endif /* _Pawn_H__ */
Note: See TracBrowser for help on using the repository browser.