Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/src/modules/weapons/weaponmodes/EnergyDrink.cc @ 8788

Last change on this file since 8788 was 8706, checked in by dafrick, 13 years ago

Merging presentation branch back into trunk.
There are many new features and also a lot of other changes and bugfixes, if you want to know, digg through the svn log.
Not everything is yet working as it should, but it should be fairly stable. If you habe any bug reports, just send me an email.

  • Property svn:eol-style set to native
File size: 3.7 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 *      Hagen Seifert
24 *   Co-authors:
25 *      simonmie
26 *
27 */
28
29#include "EnergyDrink.h"
30
31#include "core/CoreIncludes.h"
32#include "core/XMLPort.h"
33#include "core/command/Executor.h"
34#include "graphics/Model.h"
35
36#include "weapons/projectiles/Projectile.h"
37#include "weapons/MuzzleFlash.h"
38#include "weaponsystem/Weapon.h"
39#include "weaponsystem/WeaponPack.h"
40#include "weaponsystem/WeaponSystem.h"
41#include "worldentities/pawns/Pawn.h"
42
43namespace orxonox
44{
45    CreateFactory(EnergyDrink);
46
47    EnergyDrink::EnergyDrink(BaseObject* creator) : WeaponMode(creator)
48    {
49        RegisterObject(EnergyDrink);
50
51        this->reloadTime_ = 0.25;
52        this->damage_ = 0; //default 15
53        this->speed_ = 2500;
54        this->delay_ = 0;
55        this->setMunitionName("FusionMunition");
56
57        this->delayTimer_.setTimer(1.0f, false, createExecutor(createFunctor(&EnergyDrink::shot, this)));
58        this->delayTimer_.stopTimer();
59    }
60
61    void EnergyDrink::XMLPort(Element& xmlelement, XMLPort::Mode mode)
62    {
63        SUPER(EnergyDrink, XMLPort, xmlelement, mode);
64
65        XMLPortParam(EnergyDrink, "delay", setDelay, getDelay, xmlelement, mode);
66        XMLPortParam(EnergyDrink, "material", setMaterial, getMaterial, xmlelement, mode);
67
68    }
69
70    void EnergyDrink::setMaterial(const std::string& material)
71    {
72        this->material_ = material;
73    }
74
75    void EnergyDrink::setDelay(float d)
76    {
77        this->delay_ = d;
78        this->delayTimer_.setInterval(this->delay_);
79    }
80
81    float EnergyDrink::getDelay() const
82    {
83        return this->delay_;
84    }
85
86    void EnergyDrink::fire()
87    {
88        this->delayTimer_.startTimer();
89    }
90
91    void EnergyDrink::muendungsfeuer()
92    {
93        MuzzleFlash *muzzleFlash = new MuzzleFlash(this);
94        this->getWeapon()->attach(muzzleFlash);
95        muzzleFlash->setPosition(this->getMuzzleOffset());
96        muzzleFlash->setMaterial(this->material_);
97    }
98
99    /* Creates the projectile object, sets its properties to the EnergyDrink properties, calls muendungsfeuer()
100     */
101    void EnergyDrink::shot()
102    {
103        Projectile* projectile = new Projectile(this);
104        Model* model = new Model(projectile);
105        model->setMeshSource("can.mesh");
106        model->setCastShadows(false);
107        projectile->attach(model);
108        model->setScale(5);
109
110        projectile->setOrientation(this->getMuzzleOrientation());
111        projectile->setPosition(this->getMuzzlePosition());
112        projectile->setVelocity(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn()->getVelocity() + this->getMuzzleDirection() * this->speed_);
113
114        projectile->setOwner(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn());
115        projectile->setDamage(this->getDamage());
116        projectile->setShieldDamage(this->getShieldDamage());
117        projectile->setHealthDamage(this->getHealthDamage());
118
119        EnergyDrink::muendungsfeuer();
120    }
121}
Note: See TracBrowser for help on using the repository browser.