Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/BossFight_FS19/src/modules/weapons/weaponmodes/SimpleRocketFire.cc @ 12394

Last change on this file since 12394 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
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->setFireSound("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        hudImageString_ = "Orxonox/WSHUD_WM_SimpleRocketFire";
68    }
69
70    SimpleRocketFire::~SimpleRocketFire()
71    {
72    }
73
74    /**
75    @brief
76        Fires the weapon. Creates the SimpleRocket and a RocketController to steer it and fires it.
77    */
78    void SimpleRocketFire::fire()
79    {
80        RocketController* controller = new RocketController(this->getContext());
81        SimpleRocket* rocket = controller->getRocket();
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_);
86        rocket->setShooter(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn());
87        rocket->scale(1.0f);
88
89        rocket->setDamage(this->damage_);
90        rocket->setShieldDamage(this->getShieldDamage());
91        rocket->setHealthDamage(this->getHealthDamage());
92
93        WorldEntity* pawn = static_cast<ControllableEntity*>(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn())->getTarget();
94        if (pawn)
95            controller->setTarget(pawn);
96    }
97}
Note: See TracBrowser for help on using the repository browser.