[3053] | 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 | * Hagen Seifert |
---|
| 24 | * Co-authors: |
---|
[8580] | 25 | * simonmie |
---|
[3053] | 26 | * |
---|
| 27 | */ |
---|
| 28 | |
---|
| 29 | #include "EnergyDrink.h" |
---|
| 30 | |
---|
| 31 | #include "core/CoreIncludes.h" |
---|
| 32 | #include "core/XMLPort.h" |
---|
[7284] | 33 | #include "core/command/Executor.h" |
---|
[5737] | 34 | #include "graphics/Model.h" |
---|
[3196] | 35 | |
---|
[5724] | 36 | #include "weapons/projectiles/Projectile.h" |
---|
| 37 | #include "weapons/MuzzleFlash.h" |
---|
[5735] | 38 | #include "weaponsystem/Weapon.h" |
---|
| 39 | #include "weaponsystem/WeaponPack.h" |
---|
| 40 | #include "weaponsystem/WeaponSystem.h" |
---|
[6732] | 41 | #include "worldentities/pawns/Pawn.h" |
---|
[3053] | 42 | |
---|
| 43 | namespace orxonox |
---|
| 44 | { |
---|
| 45 | CreateFactory(EnergyDrink); |
---|
| 46 | |
---|
| 47 | EnergyDrink::EnergyDrink(BaseObject* creator) : WeaponMode(creator) |
---|
| 48 | { |
---|
| 49 | RegisterObject(EnergyDrink); |
---|
| 50 | |
---|
| 51 | this->reloadTime_ = 0.25; |
---|
[8580] | 52 | this->damage_ = 0; //default 15 |
---|
[3053] | 53 | this->speed_ = 2500; |
---|
| 54 | this->delay_ = 0; |
---|
| 55 | this->setMunitionName("FusionMunition"); |
---|
| 56 | |
---|
[5929] | 57 | this->delayTimer_.setTimer(1.0f, false, createExecutor(createFunctor(&EnergyDrink::shot, this))); |
---|
[3053] | 58 | this->delayTimer_.stopTimer(); |
---|
| 59 | } |
---|
| 60 | |
---|
| 61 | void EnergyDrink::XMLPort(Element& xmlelement, XMLPort::Mode mode) |
---|
| 62 | { |
---|
| 63 | SUPER(EnergyDrink, XMLPort, xmlelement, mode); |
---|
| 64 | |
---|
| 65 | XMLPortParam(EnergyDrink, "delay", setDelay, getDelay, xmlelement, mode); |
---|
| 66 | XMLPortParam(EnergyDrink, "material", setMaterial, getMaterial, xmlelement, mode); |
---|
| 67 | |
---|
| 68 | } |
---|
| 69 | |
---|
| 70 | void EnergyDrink::setMaterial(const std::string& material) |
---|
| 71 | { |
---|
| 72 | this->material_ = material; |
---|
| 73 | } |
---|
| 74 | |
---|
| 75 | void EnergyDrink::setDelay(float d) |
---|
| 76 | { |
---|
| 77 | this->delay_ = d; |
---|
| 78 | this->delayTimer_.setInterval(this->delay_); |
---|
| 79 | } |
---|
| 80 | |
---|
| 81 | float EnergyDrink::getDelay() const |
---|
| 82 | { |
---|
| 83 | return this->delay_; |
---|
| 84 | } |
---|
| 85 | |
---|
| 86 | void EnergyDrink::fire() |
---|
| 87 | { |
---|
| 88 | this->delayTimer_.startTimer(); |
---|
| 89 | } |
---|
| 90 | |
---|
| 91 | void EnergyDrink::muendungsfeuer() |
---|
| 92 | { |
---|
| 93 | MuzzleFlash *muzzleFlash = new MuzzleFlash(this); |
---|
| 94 | this->getWeapon()->attach(muzzleFlash); |
---|
| 95 | muzzleFlash->setPosition(this->getMuzzleOffset()); |
---|
| 96 | muzzleFlash->setMaterial(this->material_); |
---|
| 97 | } |
---|
| 98 | |
---|
[8580] | 99 | /* Creates the projectile object, sets its properties to the EnergyDrink properties, calls muendungsfeuer() |
---|
| 100 | */ |
---|
[3053] | 101 | void EnergyDrink::shot() |
---|
| 102 | { |
---|
| 103 | Projectile* projectile = new Projectile(this); |
---|
| 104 | Model* model = new Model(projectile); |
---|
| 105 | model->setMeshSource("can.mesh"); |
---|
| 106 | model->setCastShadows(false); |
---|
| 107 | projectile->attach(model); |
---|
| 108 | model->setScale(5); |
---|
| 109 | |
---|
| 110 | projectile->setOrientation(this->getMuzzleOrientation()); |
---|
| 111 | projectile->setPosition(this->getMuzzlePosition()); |
---|
[6732] | 112 | projectile->setVelocity(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn()->getVelocity() + this->getMuzzleDirection() * this->speed_); |
---|
[3053] | 113 | |
---|
| 114 | projectile->setOwner(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn()); |
---|
| 115 | projectile->setDamage(this->getDamage()); |
---|
[8580] | 116 | projectile->setShieldDamage(this->getShieldDamage()); |
---|
| 117 | projectile->setHealthDamage(this->getHealthDamage()); |
---|
[3053] | 118 | |
---|
| 119 | EnergyDrink::muendungsfeuer(); |
---|
| 120 | } |
---|
| 121 | } |
---|