Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 9703 was 9667, checked in by landauf, 11 years ago

merged core6 back to trunk

  • Property svn:eol-style set to native
File size: 8.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 "interfaces/PickupCarrier.h"
36#include "interfaces/RadarViewable.h"
37#include "worldentities/ControllableEntity.h"
38
39namespace orxonox // tolua_export
40{ // tolua_export
41    class _OrxonoxExport Pawn // tolua_export
42        : public ControllableEntity, public RadarViewable, public PickupCarrier
43    { // tolua_export
44        friend class WeaponSystem;
45
46        public:
47            Pawn(Context* context);
48            virtual ~Pawn();
49
50            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
51            virtual void tick(float dt);
52
53            inline bool isAlive() const
54                { return this->bAlive_; }
55
56
57            virtual void setHealth(float health);
58            inline void addHealth(float health)
59                { this->setHealth(this->health_ + health); }
60            inline void removeHealth(float health)
61                { this->setHealth(this->health_ - health); }
62            inline float getHealth() const
63                { return this->health_; }
64
65            inline void setMaxHealth(float maxhealth)
66                { this->maxHealth_ = maxhealth; this->setHealth(this->health_); }
67            inline float getMaxHealth() const
68                { return this->maxHealth_; }
69
70            inline void setInitialHealth(float initialhealth)
71                { this->initialHealth_ = initialhealth; this->setHealth(initialhealth); }
72            inline float getInitialHealth() const
73                { return this->initialHealth_; }
74
75            virtual void setShieldHealth(float shieldHealth);
76
77            inline float getShieldHealth()
78                { return this->shieldHealth_; }
79
80            inline void addShieldHealth(float amount)
81                { this->setShieldHealth(this->shieldHealth_ + amount); }
82
83            inline bool hasShield()
84                { return (this->getShieldHealth() > 0); }
85
86            virtual void setMaxShieldHealth(float maxshieldhealth);
87            inline float getMaxShieldHealth() const
88                { return this->maxShieldHealth_; }
89
90            inline void setInitialShieldHealth(float initialshieldhealth)
91                { this->initialShieldHealth_ = initialshieldhealth; this->setShieldHealth(initialshieldhealth); }
92            inline float getInitialShieldHealth() const
93                { return this->initialShieldHealth_; }
94
95            inline void restoreInitialShieldHealth()
96                { this->setShieldHealth(this->initialShieldHealth_); }
97            inline void restoreMaxShieldHealth()
98                { this->setShieldHealth(this->maxShieldHealth_); }
99
100            inline void setShieldAbsorption(float shieldAbsorption)
101                { this->shieldAbsorption_ = shieldAbsorption; }
102            inline float getShieldAbsorption()
103                { return this->shieldAbsorption_; }
104
105            // TODO: Rename to shieldRechargeRate
106            virtual void setReloadRate(float reloadrate);
107            inline float getReloadRate() const
108                { return this->reloadRate_; }
109
110            virtual void setReloadWaitTime(float reloadwaittime);
111            inline float getReloadWaitTime() const
112                { return this->reloadWaitTime_; }
113
114            inline void resetReloadCountdown()
115                { this->reloadWaitCountdown_ = 0; }
116
117            inline void startReloadCountdown()
118                { this->reloadWaitCountdown_ = this->getReloadWaitTime(); } // TODO: Implement in Projectile.cc
119
120            virtual void decreaseReloadCountdownTime(float dt);
121
122            inline ControllableEntity* getLastHitOriginator() const
123                { return this->lastHitOriginator_; }
124
125            //virtual void hit(Pawn* originator, const Vector3& force, float damage);
126            //virtual void hit(Pawn* originator, btManifoldPoint& contactpoint, float damage);
127            virtual void hit(Pawn* originator, const Vector3& force, float damage, float healthdamage = 0.0f, float shielddamage = 0.0f);
128            virtual void hit(Pawn* originator, btManifoldPoint& contactpoint, float damage, float healthdamage = 0.0f, float shielddamage = 0.0f);
129
130            virtual void kill();
131
132            virtual void fired(unsigned int firemode);
133            virtual void reload();
134            virtual void postSpawn();
135
136            void addWeaponSlot(WeaponSlot * wSlot);
137            WeaponSlot * getWeaponSlot(unsigned int index) const;
138            void addWeaponSet(WeaponSet * wSet);
139            WeaponSet * getWeaponSet(unsigned int index) const;
140            void addWeaponPack(WeaponPack * wPack);
141            void addWeaponPackXML(WeaponPack * wPack);
142            WeaponPack * getWeaponPack(unsigned int index) const;
143
144            virtual void addedWeaponPack(WeaponPack* wPack) {}
145
146            inline void setSpawnParticleSource(const std::string& source)
147                { this->spawnparticlesource_ = source; }
148            inline const std::string& getSpawnParticleSource() const
149                { return this->spawnparticlesource_; }
150
151            inline void setSpawnParticleDuration(float duration)
152                { this->spawnparticleduration_ = duration; }
153            inline float getSpawnParticleDuration() const
154                { return this->spawnparticleduration_; }
155
156            inline void setExplosionChunks(unsigned int chunks)
157                { this->numexplosionchunks_ = chunks; }
158            inline unsigned int getExplosionChunks() const
159                { return this->numexplosionchunks_; }
160
161            // These are used with the Damage Boost Pickup to use the damage multiplier.
162            inline void setDamageMultiplier(float multiplier)
163                { this->damageMultiplier_ = multiplier; }
164            inline float getDamageMultiplier() const
165                { return this->damageMultiplier_; }
166
167
168            virtual void startLocalHumanControl();
169
170            void setAimPosition( Vector3 position )
171                { this->aimPosition_ = position; }
172            Vector3 getAimPosition()
173                { return this->aimPosition_; }
174
175            virtual const Vector3& getCarrierPosition(void) const
176                { return this->getWorldPosition(); };
177
178            virtual void changedVisibility();
179
180        protected:
181            virtual void preDestroy();
182
183            virtual void setPlayer(PlayerInfo* player);
184            virtual void removePlayer();
185
186            virtual void death();
187            virtual bool hasSlaves();
188            virtual Controller* getSlave();
189            virtual void goWithStyle();
190            virtual void deatheffect();
191            virtual void spawneffect();
192
193            //virtual void damage(float damage, Pawn* originator = 0);
194            virtual void damage(float damage, float healthdamage = 0.0f, float shielddamage = 0.0f, Pawn* originator = NULL);
195
196            bool bAlive_;
197
198            virtual std::vector<PickupCarrier*>* getCarrierChildren(void) const
199                { return new std::vector<PickupCarrier*>(); }
200            virtual PickupCarrier* getCarrierParent(void) const
201                { return NULL; }
202
203
204            float health_;
205            float maxHealth_;
206            float initialHealth_;
207
208            float shieldHealth_;
209            float maxShieldHealth_;
210            float initialShieldHealth_;
211            float shieldAbsorption_; ///< Has to be between 0 and 1
212            float reloadRate_;
213            float reloadWaitTime_;
214            float reloadWaitCountdown_;
215
216            float damageMultiplier_; ///< Used by the Damage Boost Pickup.
217
218            WeakPtr<Pawn> lastHitOriginator_;
219
220            WeaponSystem* weaponSystem_;
221            bool bReload_;
222
223            std::string spawnparticlesource_;
224            float spawnparticleduration_;
225            unsigned int numexplosionchunks_;
226
227        private:
228            void registerVariables();
229            inline void setWeaponSystem(WeaponSystem* weaponsystem)
230                { this->weaponSystem_ = weaponsystem; }
231
232            Vector3 aimPosition_;
233    }; // tolua_export
234} // tolua_export
235
236#endif /* _Pawn_H__ */
Note: See TracBrowser for help on using the repository browser.