Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

some comments in test-Weaponsettings made

File size: 5.1 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 *      simonmie
24 *   Co-authors:
25 *      ...
26 *
27 */
28
29#include "BasicProjectile.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#include "core/OrxonoxClass.h"
39
40namespace orxonox
41{
42    /**
43    @brief
44        Constructor. Registers the object and initializes some default values.
45    */
46    BasicProjectile::BasicProjectile() : OrxonoxClass()
47    {
48        RegisterRootObject(BasicProjectile);// - register the BasicProjectile class to the core
49
50        this->bDestroy_ = false;
51
52        this->damage_ = 0;
53        this->healthdamage_ = 0;
54        this->shielddamage_ = 0;
55    }
56
57    BasicProjectile::~BasicProjectile()
58    {
59    }
60
61    bool BasicProjectile::basicCollidesAgainst(WorldEntity* otherObject, btManifoldPoint& contactPoint, Pawn* owner, BasicProjectile* this_)
62    {
63        if (!this_->getBDestroy() && GameMode::isMaster())
64        {
65            if (otherObject == /*this->*/owner/*_*/) //prevents you from shooting yourself
66                return false;
67
68            this_->setBDestroy(true); //if something is hit, the object is destroyed and can't hit something else
69// instead of returning false, bDestroy is returned
70
71            Pawn* victim = orxonox_cast<Pawn*>(otherObject); //if otherObject isn't a Pawn, then victim is NULL
72
73            WorldEntity* entity = orxonox_cast<WorldEntity*>(this_);
74            assert(entity); //entity must not be null
75
76
77            // if visual effects after destruction cause problems, put this block below the effects code block
78            if (victim)
79            {
80                victim->hit(/*this->*/owner/*_*/, contactPoint, this_->getDamage(), this_->getHealthDamage(), this_->getShieldDamage());
81                victim->startReloadCountdown();
82            }
83
84            // visual effects for being hit, depending on whether the shield is hit or not
85            if (/*this->*/owner/*_*/) //if the owner does not exist (anymore??), no effects are displayed.
86            {
87                if (!victim || (victim && !victim->hasShield())) //same like below
88                {
89                    {
90                        ParticleSpawner* effect = new ParticleSpawner(/*this->*/owner/*_*/->getCreator());
91                        effect->setPosition(entity->getPosition());
92                        effect->setOrientation(entity->getOrientation());
93                        effect->setDestroyAfterLife(true);
94                        effect->setSource("Orxonox/explosion3");
95                        effect->setLifetime(2.0f);
96                    }
97                        // second effect with same condition
98                    {
99                        ParticleSpawner* effect = new ParticleSpawner(/*this->*/owner/*_*/->getCreator());
100                        effect->setPosition(entity->getPosition());
101                        effect->setOrientation(entity->getOrientation());
102                        effect->setDestroyAfterLife(true);
103                        effect->setSource("Orxonox/smoke4");
104                        effect->setLifetime(3.0f);
105                    }
106                }
107                        // victim->isAlive() is not false until the next tick, so getHealth() is used instead
108                if (victim && victim->hasShield() && (this_->getDamage() > 0 || this_->getShieldDamage() > 0) && victim->getHealth() > 0)
109                {
110                    ParticleSpawner* effect = new ParticleSpawner(/*this->*/owner/*_*/->getCreator());
111                    effect->setPosition(entity->getPosition());
112                    effect->setOrientation(entity->getOrientation());
113                    effect->setDestroyAfterLife(true);
114                    effect->setSource("Orxonox/Shield");
115                    effect->setLifetime(0.5f);
116                }
117            }
118
119//            if (victim)
120//            {
121//                victim->hit(/*this->*/owner/*_*/, contactPoint, this_->getDamage(), this_->getHealthDamage(), this_->getShieldDamage());
122//                victim->startReloadCountdown();
123//            }
124        }
125        return false;
126    }
127
128/*    void BasicProjectile::destroyObject()
129    {
130        if (GameMode::isMaster())
131            this->destroy();
132    }
133*/
134}
Note: See TracBrowser for help on using the repository browser.