Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 13, 2006, 10:30:51 PM (17 years ago)
Author:
marcscha
Message:

Emitter Node implemented, first steps for swarm missile in

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/playability/src/world_entities/weapons/swarm_launcher.cc

    r10046 r10073  
    2525#include "animation3d.h"
    2626
     27#include <list>
     28#include <iterator>
     29#include "util/state.h"
     30
     31#include "math/quaternion.h"
     32
    2733#include "util/loading/factory.h"
    2834
    2935#include "class_id_DEPRECATED.h"
     36
     37using namespace std;
    3038
    3139ObjectListDefinitionID(SwarmLauncher, CL_SWARM_LAUNCHER);
     
    136144void SwarmLauncher::fire()
    137145{
    138   Projectile* pj = this->getProjectile();
    139   if (pj == NULL)
    140     return;
     146  Projectile* pj;
     147  int i = 0;
     148  std::list<WorldEntity*> eList  = State::getObjectManager()->getEntityList( OM_GROUP_00);
     149  list<WorldEntity*>::iterator eIterator;
     150  PRINTF(0)("Iterator output: %i\n",eList.size());
     151  for( eIterator = eList.begin(); eIterator != eList.end(); eIterator++);
     152  {
     153    PRINTF(0)("Iterator step: %i with content: %s\n",++i,*eIterator);
     154    if( (dynamic_cast<WorldEntity*>(*eIterator)->getAbsCoor() - this->getAbsCoor()).len() <= 50000.0)
     155    {
     156      pj  = this->getProjectile();
     157      if (pj == NULL)
     158        return;
    141159
    142   pj->setVelocity(this->getVelocity()+(this->getAbsDir().apply(Vector(1,0,0))*165.0 /*+ VECTOR_RAND(13) */
    143             /*target->getAbsCoor() - this->getAbsCoor()*/)*.5);//this->getVelocity());
    144 
    145   pj->setParent(PNode::getNullParent());
    146   pj->setAbsCoor(this->getEmissionPoint());
    147   pj->setAbsDir(this->getAbsDir());
    148   pj->activate();
     160          pj->setVelocity(this->getVelocity()+(this->getAbsDir().apply(Vector(1,0,0))*165.0 + VECTOR_RAND(20))*.5);
     161       
     162          pj->setParent(PNode::getNullParent());
     163          pj->setAbsCoor(this->getEmissionPoint());
     164          pj->setAbsDir(this->getAbsDir());
     165          pj->setTarget( *eIterator);
     166          pj->activate();
     167      this->increaseEnergy( pj->getMinEnergy());
     168    }
     169  }
     170  this->increaseEnergy( - pj->getMinEnergy());
    149171}
Note: See TracChangeset for help on using the changeset viewer.