Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/presentationFS15merge/src/modules/weapons/weaponmodes/SimpleRocketFire.cc @ 10610

Last change on this file since 10610 was 9667, checked in by landauf, 11 years ago

merged core6 back to trunk

  • Property svn:eol-style set to native
File size: 3.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 *      Gabriel Nadler
24 *   Co-authors:
25 *      Oliver Scheuss
26 *      simonmie
27 *
28 */
29
30/**
31    @file BasicProjectile.h
32    @brief Implementation of the BasicProjectile class.
33*/
34
35#include "SimpleRocketFire.h"
36
37#include "core/CoreIncludes.h"
38#include "util/Math.h"
39
40#include "weaponsystem/Weapon.h"
41#include "weaponsystem/WeaponPack.h"
42#include "weaponsystem/WeaponSystem.h"
43#include "worldentities/pawns/Pawn.h"
44#include "sound/WorldSound.h"
45
46#include "weapons/RocketController.h"
47#include "weapons/projectiles/SimpleRocket.h"
48
49namespace orxonox
50{
51
52    RegisterClass(SimpleRocketFire);
53
54    SimpleRocketFire::SimpleRocketFire(Context* context) : WeaponMode(context)
55    {
56        RegisterObject(SimpleRocketFire);
57
58        this->reloadTime_ = 1.0f;
59        this->bParallelReload_ = false;
60        this->damage_ = 0.0f;
61        this->speed_ = 500.0f;
62
63        this->setMunitionName("RocketMunition");
64        this->setDefaultSoundWithVolume("sounds/Rocket_launch.ogg",0.4f);
65        // The firing sound of the Rocket is played in Rocket.cc (because of OpenAl sound positioning)
66    }
67
68    SimpleRocketFire::~SimpleRocketFire()
69    {
70    }
71
72    /**
73    @brief
74        Fires the weapon. Creates the SimpleRocket and a RocketController to steer it and fires it.
75    */
76    void SimpleRocketFire::fire()
77    {
78        RocketController* controller = new RocketController(this->getContext());
79        SimpleRocket* rocket = controller->getRocket();
80        this->computeMuzzleParameters(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn()->getAimPosition());
81        rocket->setOrientation(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn()->getWorldOrientation());
82        rocket->setPosition(this->getMuzzlePosition());
83        rocket->setVelocity(this->getMuzzleDirection()*this->speed_);
84        rocket->setShooter(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn());
85
86        rocket->setDamage(this->damage_);
87        rocket->setShieldDamage(this->getShieldDamage());
88        rocket->setHealthDamage(this->getHealthDamage());
89
90        WorldEntity* pawn = static_cast<ControllableEntity*>(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn())->getTarget();
91        if (pawn) controller->setTarget(pawn);
92    }
93}
Note: See TracBrowser for help on using the repository browser.