1 | /* |
---|
2 | * GravityBombFire.cc |
---|
3 | * |
---|
4 | * Created on: Apr 16, 2015 |
---|
5 | * Author: Manuel Eggimann |
---|
6 | */ |
---|
7 | #include "GravityBombFire.h" |
---|
8 | |
---|
9 | #include "core/CoreIncludes.h" |
---|
10 | #include "weaponsystem/Weapon.h" |
---|
11 | #include "weaponsystem/WeaponPack.h" |
---|
12 | #include "weaponsystem/WeaponSystem.h" |
---|
13 | #include "worldentities/pawns/Pawn.h" |
---|
14 | |
---|
15 | #include "weapons/projectiles/GravityBomb.h" |
---|
16 | |
---|
17 | namespace orxonox |
---|
18 | { |
---|
19 | RegisterClass(GravityBombFire); |
---|
20 | |
---|
21 | const float GravityBombFire::BOMB_VELOCITY = 600.0; ///< The velocity of the bomb after launch |
---|
22 | |
---|
23 | GravityBombFire::GravityBombFire(Context* context) : WeaponMode(context) |
---|
24 | { |
---|
25 | RegisterObject(GravityBombFire); |
---|
26 | |
---|
27 | this->reloadTime_ = 0.50f; |
---|
28 | this->bParallelReload_ = false; |
---|
29 | this->damage_ = 20.0f; ///< The damage of the Bomb if it hits a pawn. |
---|
30 | |
---|
31 | this->setMunitionName("GravityBombMunition"); |
---|
32 | this->setDefaultSoundWithVolume("sounds/Rocket_launch.ogg",0.8); ///< sets sound of the bomb as it is fired. |
---|
33 | } |
---|
34 | |
---|
35 | GravityBombFire::~GravityBombFire(){}; |
---|
36 | |
---|
37 | void GravityBombFire::fire() |
---|
38 | { |
---|
39 | GravityBomb* bomb = new GravityBomb(this->getContext()); |
---|
40 | //Create a new Bomb in 3D-Space and set the right direction speed and orientation. |
---|
41 | this->computeMuzzleParameters(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn()->getAimPosition()); |
---|
42 | bomb->setOrientation(this->getMuzzleOrientation()); |
---|
43 | bomb->setPosition(this->getMuzzlePosition()); |
---|
44 | bomb->setVelocity(this->getMuzzleDirection() * (this->BOMB_VELOCITY+this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn()->getVelocity().length())); |
---|
45 | |
---|
46 | //Set the shooter of the bomb so it is possible to determine the pawn that killed another one and define damage to shield and healt the bomb does. |
---|
47 | bomb->setShooter(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn()); |
---|
48 | bomb->setDamage(this->getDamage()); |
---|
49 | bomb->setShieldDamage(this->getShieldDamage()); |
---|
50 | bomb->setHealthDamage(this->getHealthDamage()); |
---|
51 | } |
---|
52 | |
---|
53 | |
---|
54 | } |
---|
55 | |
---|
56 | |
---|