Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/gamecontent/src/orxonox/worldentities/pawns/Pawn.h @ 8942

Last change on this file since 8942 was 8942, checked in by jo, 13 years ago

Pawn&SpaceShip Colouring via XML works. Quick&Dirty implementation though. A clean version is going to follow.

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