Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/gameimmersion/src/modules/weapons/projectiles/Projectile.cc @ 8538

Last change on this file since 8538 was 8538, checked in by simonmie, 13 years ago

some comments in test-Weaponsettings made

  • Property svn:eol-style set to native
File size: 5.3 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#include "Projectile.h"
30
31#include "core/CoreIncludes.h"
32#include "core/ConfigValueIncludes.h"
33#include "core/GameMode.h"
34#include "core/command/Executor.h"
35#include "objects/collisionshapes/SphereCollisionShape.h"
36#include "worldentities/pawns/Pawn.h"
37#include "graphics/ParticleSpawner.h"
38
39namespace orxonox
40{
41    CreateFactory(Projectile);
42
43    Projectile::Projectile(BaseObject* creator) : MovableEntity(creator), BasicProjectile()
44    {
45        RegisterObject(Projectile);
46
47        this->setConfigValues();
48//        this->bDestroy_ = false;
49//        this->owner_ = 0;
50//        this->damage_ = 115;
51///////////////////me
52//        this->healthdamage_ = 0;
53//        this->shielddamage_ = 0;
54///////////////////end me
55
56        // Get notification about collisions
57
58        if (GameMode::isMaster())
59        {
60            this->setMass(1.0);
61            this->enableCollisionCallback();
62            this->setCollisionResponse(false);
63            this->setCollisionType(Kinematic);
64
65            SphereCollisionShape* shape = new SphereCollisionShape(this);
66            shape->setRadius(20);
67            this->attachCollisionShape(shape);
68
69            this->destroyTimer_.setTimer(this->lifetime_, false, createExecutor(createFunctor(&Projectile::destroyObject, this)));
70        }
71    }
72
73    Projectile::~Projectile()
74    {
75    }
76
77    void Projectile::setConfigValues()
78    {
79        SetConfigValue(lifetime_, 4.0).description("The time in seconds a projectile stays alive");
80    }
81
82
83    void Projectile::tick(float dt)
84    {
85        SUPER(Projectile, tick, dt);
86
87        if (!this->isActive())
88            return;
89
90        if (this->getBDestroy())
91            this->destroy(); // TODO: use a scheduler instead of deleting the object right here in tick()
92    }
93
94    void Projectile::destroyObject()
95    {
96        if (GameMode::isMaster())
97            this->destroy();
98    }
99
100    bool Projectile::collidesAgainst(WorldEntity* otherObject, btManifoldPoint& contactPoint)
101    {
102        return BasicProjectile::basicCollidesAgainst(otherObject,contactPoint,this->getOwner(),this);
103    }
104
105//////////////////////////me edit
106/*    bool Projectile::collidesAgainst(WorldEntity* otherObject, btManifoldPoint& contactPoint)
107    {
108        if (!this->bDestroy_ && GameMode::isMaster())
109        {
110            if (otherObject == this->owner_)
111                return false;
112
113            this->bDestroy_ = true;
114
115            Pawn* victim = orxonox_cast<Pawn*>(otherObject); //if otherObject isn't a Pawn, then victim is NULL
116
117            if (this->owner_)
118            {
119                if (!victim || (victim && !victim->hasShield())) //same like below
120                {
121                    ParticleSpawner* effect = new ParticleSpawner(this->owner_->getCreator());
122                    effect->setPosition(this->getPosition());
123                    effect->setOrientation(this->getOrientation());
124                    effect->setDestroyAfterLife(true);
125                    effect->setSource("Orxonox/explosion3");
126                    effect->setLifetime(2.0f);
127                }
128                if (!victim || (victim && !victim->hasShield())) //same like above
129                {
130                    ParticleSpawner* effect = new ParticleSpawner(this->owner_->getCreator());
131                    effect->setPosition(this->getPosition());
132                    effect->setOrientation(this->getOrientation());
133                    effect->setDestroyAfterLife(true);
134                    effect->setSource("Orxonox/smoke4");
135                    effect->setLifetime(3.0f);
136                }
137                if (victim && victim->hasShield())
138                {
139                    ParticleSpawner* effect = new ParticleSpawner(this->owner_->getCreator());
140                    effect->setPosition(this->getPosition());
141                    effect->setOrientation(this->getOrientation());
142                    effect->setDestroyAfterLife(true);
143                    effect->setSource("Orxonox/engineglow");
144                    effect->setLifetime(0.5f);
145                }
146            }
147
148            if (victim)
149            {
150                victim->hit(this->owner_, contactPoint, this->damage_, this->healthdamage_, this->shielddamage_);
151                victim->startReloadCountdown();
152            }
153        }
154        return false;
155    }
156//////////////////////////////////////////////////////////////////////end edit
157*/
158    void Projectile::setOwner(Pawn* owner)
159    {
160        this->owner_ = owner;
161    }
162}
Note: See TracBrowser for help on using the repository browser.