Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 10602 was 10437, checked in by fvultier, 10 years ago

Removed unnecessary output to console in kump minigame. Added a small description to some classes often used by PPS students: Pawn, StaticEntity, MobileEntity, ControllableEntity.

  • Property svn:eol-style set to native
File size: 9.6 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>
[6524]35#include "interfaces/PickupCarrier.h"
[3196]36#include "interfaces/RadarViewable.h"
[5735]37#include "worldentities/ControllableEntity.h"
[2072]38
[9939]39
[6711]40namespace orxonox // tolua_export
[10437]41{
42    /**
43    @brief
44        Everything in Orxonoy 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
[6711]54    class _OrxonoxExport Pawn // tolua_export
55        : public ControllableEntity, public RadarViewable, public PickupCarrier
56    { // tolua_export
[3053]57        friend class WeaponSystem;
58
[2072]59        public:
[9667]60            Pawn(Context* context);
[2072]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
[9016]69
[2072]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); }
[2662]75            inline float getHealth() const
[2072]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
[8706]88            virtual void setShieldHealth(float shieldHealth);
89
[7163]90            inline float getShieldHealth()
[8855]91                { return this->shieldHealth_; }
[7163]92
[8706]93            inline void addShieldHealth(float amount)
[8855]94                { this->setShieldHealth(this->shieldHealth_ + amount); }
[8706]95
96            inline bool hasShield()
[8855]97                { return (this->getShieldHealth() > 0); }
[8706]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
[7163]113            inline void setShieldAbsorption(float shieldAbsorption)
[8855]114                { this->shieldAbsorption_ = shieldAbsorption; }
[7163]115            inline float getShieldAbsorption()
[8855]116                { return this->shieldAbsorption_; }
[7163]117
[8706]118            // TODO: Rename to shieldRechargeRate
119            virtual void setReloadRate(float reloadrate);
120            inline float getReloadRate() const
121                { return this->reloadRate_; }
122
123            virtual void setReloadWaitTime(float reloadwaittime);
124            inline float getReloadWaitTime() const
125                { return this->reloadWaitTime_; }
126
127            inline void resetReloadCountdown()
[8855]128                { this->reloadWaitCountdown_ = 0; }
[8706]129
130            inline void startReloadCountdown()
[8855]131                { this->reloadWaitCountdown_ = this->getReloadWaitTime(); } // TODO: Implement in Projectile.cc
[8706]132
133            virtual void decreaseReloadCountdownTime(float dt);
134
[2072]135            inline ControllableEntity* getLastHitOriginator() const
136                { return this->lastHitOriginator_; }
137
[8706]138            //virtual void hit(Pawn* originator, const Vector3& force, float damage);
139            //virtual void hit(Pawn* originator, btManifoldPoint& contactpoint, float damage);
[10216]140            virtual void hit(Pawn* originator, const Vector3& force, const btCollisionShape* cs, float damage, float healthdamage = 0.0f, float shielddamage = 0.0f);
141            virtual void hit(Pawn* originator, btManifoldPoint& contactpoint, const btCollisionShape* cs, float damage, float healthdamage = 0.0f, float shielddamage = 0.0f);
[8706]142
[2072]143            virtual void kill();
144
[6417]145            virtual void fired(unsigned int firemode);
[3053]146            virtual void reload();
[2072]147            virtual void postSpawn();
148
[3053]149            void addWeaponSlot(WeaponSlot * wSlot);
[2662]150            WeaponSlot * getWeaponSlot(unsigned int index) const;
[3053]151            void addWeaponSet(WeaponSet * wSet);
[2662]152            WeaponSet * getWeaponSet(unsigned int index) const;
[3053]153            void addWeaponPack(WeaponPack * wPack);
[6417]154            void addWeaponPackXML(WeaponPack * wPack);
[3053]155            WeaponPack * getWeaponPack(unsigned int index) const;
[2662]156
[7163]157            virtual void addedWeaponPack(WeaponPack* wPack) {}
158
[2662]159            inline void setSpawnParticleSource(const std::string& source)
160                { this->spawnparticlesource_ = source; }
161            inline const std::string& getSpawnParticleSource() const
162                { return this->spawnparticlesource_; }
163
164            inline void setSpawnParticleDuration(float duration)
165                { this->spawnparticleduration_ = duration; }
166            inline float getSpawnParticleDuration() const
167                { return this->spawnparticleduration_; }
168
169            inline void setExplosionChunks(unsigned int chunks)
170                { this->numexplosionchunks_ = chunks; }
171            inline unsigned int getExplosionChunks() const
172                { return this->numexplosionchunks_; }
173
[9348]174            // These are used with the Damage Boost Pickup to use the damage multiplier.
175            inline void setDamageMultiplier(float multiplier)
176                { this->damageMultiplier_ = multiplier; }
177            inline float getDamageMultiplier() const
178                { return this->damageMultiplier_; }
179
180
[3089]181            virtual void startLocalHumanControl();
[2662]182
[6417]183            void setAimPosition( Vector3 position )
184                { this->aimPosition_ = position; }
185            Vector3 getAimPosition()
186                { return this->aimPosition_; }
[7163]187
[7547]188            virtual const Vector3& getCarrierPosition(void) const
[6540]189                { return this->getWorldPosition(); };
[6417]190
[9254]191            virtual void changedVisibility();
192
[9939]193            void setExplosionSound(const std::string& engineSound);
194            const std::string& getExplosionSound();
195
[2072]196        protected:
[7889]197            virtual void preDestroy();
198
[3038]199            virtual void setPlayer(PlayerInfo* player);
200            virtual void removePlayer();
201
[2072]202            virtual void death();
[9625]203            virtual bool hasSlaves();
204            virtual Controller* getSlave();
[3087]205            virtual void goWithStyle();
[2662]206            virtual void deatheffect();
207            virtual void spawneffect();
[2072]208
[8706]209            //virtual void damage(float damage, Pawn* originator = 0);
[10216]210            virtual void damage(float damage, float healthdamage = 0.0f, float shielddamage = 0.0f, Pawn* originator = NULL, const btCollisionShape* cs = NULL);
[6417]211
[2072]212            bool bAlive_;
213
[7547]214            virtual std::vector<PickupCarrier*>* getCarrierChildren(void) const
[6711]215                { return new std::vector<PickupCarrier*>(); }
[7547]216            virtual PickupCarrier* getCarrierParent(void) const
[6524]217                { return NULL; }
[2662]218
[9016]219
[2072]220            float health_;
221            float maxHealth_;
222            float initialHealth_;
[8891]223
[7163]224            float shieldHealth_;
[8706]225            float maxShieldHealth_;
226            float initialShieldHealth_;
[9348]227            float shieldAbsorption_; ///< Has to be between 0 and 1
[8706]228            float reloadRate_;
229            float reloadWaitTime_;
230            float reloadWaitCountdown_;
[2072]231
[9348]232            float damageMultiplier_; ///< Used by the Damage Boost Pickup.
233
[7655]234            WeakPtr<Pawn> lastHitOriginator_;
[2098]235
236            WeaponSystem* weaponSystem_;
[3053]237            bool bReload_;
[2662]238
239            std::string spawnparticlesource_;
240            float spawnparticleduration_;
241            unsigned int numexplosionchunks_;
[3053]242
243        private:
[7163]244            void registerVariables();
[3053]245            inline void setWeaponSystem(WeaponSystem* weaponsystem)
246                { this->weaponSystem_ = weaponsystem; }
[6417]247
248            Vector3 aimPosition_;
[9939]249
[9948]250            WorldSound* explosionSound_; // TODO: Does this really belong here? Maybe move it to BigExplosion?
[9939]251
[6711]252    }; // tolua_export
253} // tolua_export
[2072]254
255#endif /* _Pawn_H__ */
Note: See TracBrowser for help on using the repository browser.