/* 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 "laser_cannon.h" #include "world_entities/projectiles/projectile.h" #include "world_entity.h" #include "static_model.h" #include "weapon_manager.h" #include "util/loading/factory.h" #include "animation3d.h" #include "loading/fast_factory.h" #include "class_id.h" NewObjectListDefinitionID(LaserCannon, CL_LASER_CANNON); CREATE_FACTORY(LaserCannon); LaserCannon::LaserCannon(const TiXmlElement* root) { this->init(); if (root != NULL) this->loadParams(root); } /** * standard deconstructor */ LaserCannon::~LaserCannon () { // model will be deleted from WorldEntity-destructor } void LaserCannon::init() { this->registerObject(this, LaserCannon::_objectList); // this->model = (Model*)ResourceManager::getInstance()->load("models/guns/laser_cannon.obj", OBJ, RP_CAMPAIGN); this->loadModel("models/guns/lasercannon.obj", 5.0f); this->setStateDuration(WS_SHOOTING, .1); this->setStateDuration(WS_RELOADING, .1); this->setStateDuration(WS_ACTIVATING, .4); this->setStateDuration(WS_DEACTIVATING, .4); this->setEnergyMax(10000); this->increaseEnergy(10000); //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->setProjectileTypeC("RailProjectile"); this->prepareProjectiles(100); this->setEmissionPoint(Vector(2.8,0,0) * 5.0); } void LaserCannon::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 LaserCannon::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 LaserCannon::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 LaserCannon::fire() { Projectile* pj = this->getProjectile(); if (pj == NULL) return; // make this to let the onKill(...) fuction get the stuff pj->setOwner(this->getOwner()); 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(); }