Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/src/modules/weapons/weaponmodes/HsW01.cc @ 7496

Last change on this file since 7496 was 7284, checked in by landauf, 14 years ago

merged consolecommands3 branch back to trunk.

note: the console command interface has changed completely, but the documentation is not yet up to date. just copy an existing command and change it to your needs, it's pretty self-explanatory. also the include files related to console commands are now located in core/command/. in the game it should work exactly like before, except for some changes in the auto-completion.

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