Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/src/modules/weapons/weaponmodes/SimpleRocketFire.cc @ 11822

Last change on this file since 11822 was 11108, checked in by fvultier, 9 years ago

A few modifications in the weapon system: WeaponModes may play a reload sound now. Fireing Sounds of WeaponModes may overlap now. New weapon: FlameGun, a flame thrower for close combat (e.g. for the FPS player)

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