| [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] | 49 | namespace 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"); | 
|---|
|  | 64 | this->setDefaultSoundWithVolume("sounds/Rocket_launch.ogg",0.4f); | 
|---|
| [7129] | 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 |  | 
|---|
| [8855] | 72 | /** | 
|---|
|  | 73 | @brief | 
|---|
|  | 74 | Fires the weapon. Creates the SimpleRocket and a RocketController to steer it and fires it. | 
|---|
|  | 75 | */ | 
|---|
| [7129] | 76 | void SimpleRocketFire::fire() | 
|---|
|  | 77 | { | 
|---|
| [9667] | 78 | RocketController* controller = new RocketController(this->getContext()); | 
|---|
| [8855] | 79 | SimpleRocket* rocket = controller->getRocket(); | 
|---|
| [7129] | 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_); | 
|---|
| [8855] | 84 | rocket->setShooter(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn()); | 
|---|
| [8706] | 85 |  | 
|---|
| [7129] | 86 | rocket->setDamage(this->damage_); | 
|---|
| [8706] | 87 | rocket->setShieldDamage(this->getShieldDamage()); | 
|---|
|  | 88 | rocket->setHealthDamage(this->getHealthDamage()); | 
|---|
|  | 89 |  | 
|---|
| [8855] | 90 | WorldEntity* pawn = static_cast<ControllableEntity*>(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn())->getTarget(); | 
|---|
|  | 91 | if (pawn) controller->setTarget(pawn); | 
|---|
| [7129] | 92 | } | 
|---|
|  | 93 | } | 
|---|