/* orxonox - the future of 3D-vertical-scrollers Copyright (C) 2004 orx This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. ### File Specific main-programmer: Patrick Boenzli co-programmer: @todo: direction in which the projectile flights @todo: a target to set/hit */ #define DEBUG_SPECIAL_MODULE DEBUG_MODULE_WEAPON #include "world_entities/projectiles/projectile.h" #include "world_entity.h" #include "static_model.h" #include "weapon_manager.h" #include "util/loading/factory.h" #include "fast_factory.h" #include "fps_sniper_rifle.h" using namespace std; CREATE_FACTORY(FPSSniperRifle, CL_FPS_SNIPER_RIFLE); /** * standard constructor creates a new weapon */ FPSSniperRifle::FPSSniperRifle ( int leftRight) : Weapon() { this->init(); this->leftRight = leftRight; } FPSSniperRifle::FPSSniperRifle(const TiXmlElement* root) { this->init(); if (root != NULL) this->loadParams(root); } /** * standard deconstructor */ FPSSniperRifle::~FPSSniperRifle () { // model will be deleted from WorldEntity-destructor } void FPSSniperRifle::init() { this->setClassID(CL_FPS_SNIPER_RIFLE, "FPSSniperRifle"); this->loadModel("models/guns/fps_sniper_rifle.obj", 0.1); this->setStateDuration(WS_SHOOTING, .1); this->setStateDuration(WS_RELOADING, .1); this->setStateDuration(WS_ACTIVATING, .4); this->setStateDuration(WS_DEACTIVATING, .4); this->setEnergyMax(100000); this->increaseEnergy(100000); //this->minCharge = 2; this->setActionSound(WA_SHOOT, "sound/laser.wav"); this->setActionSound(WA_ACTIVATE, "sound/voices/lasers.wav"); this->setCapability(WTYPE_ALLDIRS | WTYPE_DIRECTIONAL); this->setProjectileType(CL_LASER); this->prepareProjectiles(20); } void FPSSniperRifle::loadParams(const TiXmlElement* root) { Weapon::loadParams(root); } /** * this activates the weapon This is needed, since there can be more than one weapon on a ship. the activation can be connected with an animation. for example the weapon is been armed out. */ void FPSSniperRifle::activate() { } /** * this deactivates the weapon This is needed, since there can be more than one weapon on a ship. the activation can be connected with an animation. for example the weapon is been armed out. */ void FPSSniperRifle::deactivate() { } /** * fires the weapon this is called from the player.cc, when fire-button is been pushed @todo: the ObjectManager deliveres Projectiles not TestBullets! this should be diffrent */ void FPSSniperRifle::fire() { Projectile* pj = this->getProjectile(); if (pj == NULL) return; pj->setParent(PNode::getNullParent()); pj->setVelocity(this->getAbsDir().apply(Vector(1,0,0))*250 + VECTOR_RAND(5)); pj->setAbsCoor(this->getEmissionPoint()); pj->setAbsDir(this->getAbsDir()); pj->activate(); }