/* orxonox - the future of 3D-vertical-scrollers Copyright (C) 2004-2006 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: Marc Schaerrer co-programmer: Benjamin Grauer, Nicolas Schlumberger */ #define DEBUG_SPECIAL_MODULE DEBUG_MODULE_WEAPON #include "plasma_pulse.h" #include "state.h" #include #include "debug.h" ObjectListDefinition(PlasmaPulse); CREATE_FAST_FACTORY_STATIC(PlasmaPulse); /** * standard constructor */ PlasmaPulse::PlasmaPulse () : Projectile() { this->registerObject(this, PlasmaPulse::_objectList); this->setMinEnergy(1); this->setHealthMax(0); this->lifeSpan = 2.0; this->grid = new Billboard(); this->grid->setSize(.2, .2); this->grid->setPulseMagnitude(.8); this->grid->setParent(this); this->grid->setVisibility(false); this->grid->setPulse(); this->grid->setTexture( "textures/plasma.png"); this->grid->toList(OM_ENVIRON); /* this->blink = new Blink(); this->grid->setParent(this); this->grid->setVisibility(false); this->blink->setSize(1.0 ); this->blink->setPeriod(.4); this->blink->setColor(10, 250, 150); this->blink->loadBlinkSequence( "66678998766" ); this->blink->toList(OM_ENVIRON);*/ } /** * standard deconstructor * */ PlasmaPulse::~PlasmaPulse () { this->grid->toList(OM_DEAD); // this->blink->toList(OM_DEAD); } void PlasmaPulse::activate() { this->origList = this->getOMListNumber(); this->toList(OM_ENVIRON); this->grid->setVisibility(true); // this->blink->setVisibility(true); this->setPhysDamage(10); this->setElecDamage(0); this->setHealth(0); } void PlasmaPulse::deactivate() { this->lifeCycle = 0.0; this->grid->setVisibility(false); // this->blink->setVisibility(false); this->lifeCycle = 0.0; this->toList(OM_NULL); // this->removeNode(); PlasmaPulse::fastFactory->kill(this); } /** * signal tick, time dependent things will be handled here * @param dt time since last tick */ void PlasmaPulse::tick (float dt) { Vector v = this->velocity * dt; this->shiftCoor(v); if (this->tickLifeCycle(dt)) this->deactivate(); this->grid->tick(dt); for( ObjectList::const_iterator eIterator = Playable::objectList().begin(); eIterator !=Playable::objectList().end(); eIterator++) { if( ((*eIterator)->getOMListNumber() != (this->origList -1)) && ((*eIterator)->getAbsCoor() - this->getAbsCoor()).len() <= 3) { (*eIterator)->hit (this->getDamage(),this); this->deactivate(); } } } /** * the function gets called, when the projectile is destroyed */ void PlasmaPulse::destroy (WorldEntity* killer) { this->deactivate(); Projectile::destroy( killer ); PRINTF(5)("DESTROY PlasmaPulse\n"); this->lifeCycle = .95; //!< @todo calculate this usefully. } void PlasmaPulse::draw () const { glPushMatrix(); glEnable( GL_ALPHA_TEST); glAlphaFunc( GL_GEQUAL, .5); this->grid->draw(); // this->blink->draw(); glPopMatrix(); }