Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 9217 in orxonox.OLD for branches


Ignore:
Timestamp:
Jul 5, 2006, 12:32:30 PM (18 years ago)
Author:
bensch
Message:

added boomerang gun

Location:
branches/presentation/src
Files:
2 edited
4 copied

Legend:

Unmodified
Added
Removed
  • branches/presentation/src/defs/class_id.h

    r9186 r9217  
    222222  CL_FPS_SNIPER_RIFLE           =    0x000003a7,
    223223  CL_FPS_LASER_RIFLE            =    0x000003a8,
     224  CL_BOOMERANG_GUN              =    0x00000309,
    224225
    225226  // Projectiles
     
    233234  CL_GUIDED_MISSILE             =    0x000003e7,
    234235  CL_HYPERBLAST                 =    0x000003e8,
     236  CL_BOOMERANG_PROJECTILE       =    0x00000309,
    235237
    236238  // NPC's
  • branches/presentation/src/world_entities/WorldEntities.am

    r9180 r9217  
    3333                world_entities/weapons/aiming_system.cc \
    3434                world_entities/weapons/fps_sniper_rifle.cc \
     35                world_entities/weapons/boomerang_gun.cc \
    3536                \
    3637                world_entities/projectiles/bomb.cc \
     
    4041                world_entities/projectiles/rocket.cc \
    4142                world_entities/projectiles/guided_missile.cc \
     43                world_entities/projectiles/boomerang_projectile.cc \
    4244                world_entities/projectiles/hyperblast.cc \
    4345                \
     
    100102                weapons/aiming_turret.h \
    101103                weapons/targeting_turret.h \
     104                weapons/boomerang_gun.h \
    102105                weapons/aim.h \
    103106                weapons/aiming_system.h \
     
    110113                projectiles/rocket.h \
    111114                projectiles/guided_missile.h \
     115                projectiles/boomerang_projectile.h \
    112116                projectiles/hyperblast.h \
    113117                \
  • branches/presentation/src/world_entities/projectiles/boomerang_projectile.cc

    r9206 r9217  
     1
    12/*
    23   orxonox - the future of 3D-vertical-scrollers
     
    1617#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_WEAPON
    1718
    18 #include "guided_missile.h"
     19#include "boomerang_projectile.h"
    1920
    2021#include "state.h"
     
    2627#include "debug.h"
    2728
    28 CREATE_FAST_FACTORY_STATIC(GuidedMissile, CL_GUIDED_MISSILE);
     29CREATE_FAST_FACTORY_STATIC(BoomerangProjectile, CL_BOOMERANG_PROJECTILE);
    2930
    3031/**
    3132 *  standard constructor
    3233*/
    33 GuidedMissile::GuidedMissile () : Projectile()
    34 {
    35   this->setClassID(CL_GUIDED_MISSILE, "GuidedMissile");
     34BoomerangProjectile::BoomerangProjectile () : Projectile()
     35{
     36  this->setClassID(CL_BOOMERANG_PROJECTILE, "BoomerangProjectile");
    3637
    3738  this->loadModel("models/projectiles/orx-rocket.obj", 2.0);
     
    5455 *  standard deconstructor
    5556*/
    56 GuidedMissile::~GuidedMissile ()
     57BoomerangProjectile::~BoomerangProjectile ()
    5758{
    5859  // delete this->emitter;
    5960
    6061  /* this is normaly done by World.cc by deleting the ParticleEngine */
    61   if (GuidedMissile::trailParticles != NULL && ClassList::getList(CL_GUIDED_MISSILE)->size() <= 1)
    62   {
    63     if (ClassList::exists(GuidedMissile::trailParticles, CL_PARTICLE_SYSTEM))
    64       delete GuidedMissile::trailParticles;
    65     GuidedMissile::trailParticles = NULL;
    66   }
    67   if (GuidedMissile::explosionParticles != NULL && ClassList::getList(CL_GUIDED_MISSILE)->size() <= 1)
    68   {
    69     if (ClassList::exists(GuidedMissile::explosionParticles, CL_PARTICLE_SYSTEM))
    70       delete GuidedMissile::explosionParticles;
    71     GuidedMissile::explosionParticles = NULL;
    72   }
    73 
    74 }
    75 
    76 SpriteParticles* GuidedMissile::trailParticles = NULL;
    77 SpriteParticles* GuidedMissile::explosionParticles = NULL;
    78 
    79 
    80 
    81 void GuidedMissile::activate()
    82 {
    83   if (unlikely(GuidedMissile::trailParticles == NULL))
    84   {
    85     GuidedMissile::trailParticles = new SpriteParticles(2000);
    86     GuidedMissile::trailParticles->setName("GuidedMissileTrailParticles");
    87     GuidedMissile::trailParticles->setMaterialTexture("maps/radial-trans-noise.png");
    88     GuidedMissile::trailParticles->setLifeSpan(1.0, .3);
    89     GuidedMissile::trailParticles->setRadius(0.0, .5);
    90     GuidedMissile::trailParticles->setRadius(0.2, 4.0);
    91     GuidedMissile::trailParticles->setRadius(.5, 1.5);
    92     GuidedMissile::trailParticles->setRadius(1.0, 1.5);
    93     GuidedMissile::trailParticles->setColor(0.0, 1,0,0,.7);
    94     GuidedMissile::trailParticles->setColor(0.2, .8,.8,0,.5);
    95     GuidedMissile::trailParticles->setColor(0.5, .8,.8,.8,.8);
    96     GuidedMissile::trailParticles->setColor(1.0, .8,.8,.8,.0);
    97   }
    98   if (unlikely(GuidedMissile::explosionParticles == NULL))
    99   {
    100     GuidedMissile::explosionParticles = new SpriteParticles(200);
    101     GuidedMissile::explosionParticles->setName("GuidedMissileExplosionParticles");
    102     GuidedMissile::explosionParticles->setMaterialTexture("maps/radial-trans-noise.png");
    103     GuidedMissile::explosionParticles->setLifeSpan(.5, .3);
    104     GuidedMissile::explosionParticles->setRadius(0.0, 10);
    105     GuidedMissile::explosionParticles->setRadius(.5, 15.0);
    106     GuidedMissile::explosionParticles->setRadius(1.0, 10.0);
    107     GuidedMissile::explosionParticles->setColor(0.0, 0,1,0,1);
    108     GuidedMissile::explosionParticles->setColor(0.5, .8,.8,0,.8);
    109     GuidedMissile::explosionParticles->setColor(0.8, .8,.8,.3,.8);
    110     GuidedMissile::explosionParticles->setColor(1.0, 1,1,1,.0);
    111   }
    112 
    113   this->emitter->setSystem(GuidedMissile::trailParticles);
     62  if (BoomerangProjectile::trailParticles != NULL && ClassList::getList(CL_BOOMERANG_PROJECTILE)->size() <= 1)
     63  {
     64    if (ClassList::exists(BoomerangProjectile::trailParticles, CL_PARTICLE_SYSTEM))
     65      delete BoomerangProjectile::trailParticles;
     66    BoomerangProjectile::trailParticles = NULL;
     67  }
     68  if (BoomerangProjectile::explosionParticles != NULL && ClassList::getList(CL_BOOMERANG_PROJECTILE)->size() <= 1)
     69  {
     70    if (ClassList::exists(BoomerangProjectile::explosionParticles, CL_PARTICLE_SYSTEM))
     71      delete BoomerangProjectile::explosionParticles;
     72    BoomerangProjectile::explosionParticles = NULL;
     73  }
     74
     75}
     76
     77SpriteParticles* BoomerangProjectile::trailParticles = NULL;
     78SpriteParticles* BoomerangProjectile::explosionParticles = NULL;
     79
     80
     81
     82void BoomerangProjectile::activate()
     83{
     84  if (unlikely(BoomerangProjectile::trailParticles == NULL))
     85  {
     86    BoomerangProjectile::trailParticles = new SpriteParticles(2000);
     87    BoomerangProjectile::trailParticles->setName("BoomerangProjectileTrailParticles");
     88    BoomerangProjectile::trailParticles->setMaterialTexture("maps/radial-trans-noise.png");
     89    BoomerangProjectile::trailParticles->setLifeSpan(1.0, .3);
     90    BoomerangProjectile::trailParticles->setRadius(0.0, .5);
     91    BoomerangProjectile::trailParticles->setRadius(0.2, 4.0);
     92    BoomerangProjectile::trailParticles->setRadius(.5, 1.5);
     93    BoomerangProjectile::trailParticles->setRadius(1.0, 1.5);
     94    BoomerangProjectile::trailParticles->setColor(0.0, 1,0,0,.7);
     95    BoomerangProjectile::trailParticles->setColor(0.2, .8,.8,0,.5);
     96    BoomerangProjectile::trailParticles->setColor(0.5, .8,.8,.8,.8);
     97    BoomerangProjectile::trailParticles->setColor(1.0, .8,.8,.8,.0);
     98  }
     99  if (unlikely(BoomerangProjectile::explosionParticles == NULL))
     100  {
     101    BoomerangProjectile::explosionParticles = new SpriteParticles(200);
     102    BoomerangProjectile::explosionParticles->setName("BoomerangProjectileExplosionParticles");
     103    BoomerangProjectile::explosionParticles->setMaterialTexture("maps/radial-trans-noise.png");
     104    BoomerangProjectile::explosionParticles->setLifeSpan(.5, .3);
     105    BoomerangProjectile::explosionParticles->setRadius(0.0, 10);
     106    BoomerangProjectile::explosionParticles->setRadius(.5, 15.0);
     107    BoomerangProjectile::explosionParticles->setRadius(1.0, 10.0);
     108    BoomerangProjectile::explosionParticles->setColor(0.0, 0,1,0,1);
     109    BoomerangProjectile::explosionParticles->setColor(0.5, .8,.8,0,.8);
     110    BoomerangProjectile::explosionParticles->setColor(0.8, .8,.8,.3,.8);
     111    BoomerangProjectile::explosionParticles->setColor(1.0, 1,1,1,.0);
     112  }
     113
     114  this->emitter->setSystem(BoomerangProjectile::trailParticles);
    114115
    115116  this->updateNode(0);
     
    121122
    122123
    123 void GuidedMissile::deactivate()
     124void BoomerangProjectile::deactivate()
    124125{
    125126  this->emitter->setSystem(NULL);
     
    128129  this->toList(OM_DEAD);
    129130  this->removeNode();
    130   GuidedMissile::fastFactory->kill(this);
    131 }
    132 
    133 
    134 void GuidedMissile::collidesWith(WorldEntity* entity, const Vector& location)
     131  BoomerangProjectile::fastFactory->kill(this);
     132}
     133
     134
     135void BoomerangProjectile::collidesWith(WorldEntity* entity, const Vector& location)
    135136{
    136137  if (this->hitEntity != entity)
     
    143144 * @param time since last tick
    144145*/
    145 void GuidedMissile::tick (float time)
    146 {
    147 
    148 
    149 if (this->target != NULL && this->target->getParent() != PNode::getNullParent())
    150    {
     146void BoomerangProjectile::tick (float time)
     147{
     148
     149  Vector targetFarFarAway = this->getAbsCoor() + Vector(100000, 0, 0);
     150
     151  {
    151152    speed = velocity.len();
    152     diffVector = ((target->getAbsCoor() - this->getAbsCoor()).getNormalized());
     153    diffVector = ((targetFarFarAway - this->getAbsCoor()).getNormalized());
    153154
    154155    if(velocity.dot(diffVector) != 0)
    155      {
    156      correctionVector = (( ( diffVector *  (speed * speed/( velocity.dot(diffVector ) ) )) - velocity).getNormalized()) * agility;
     156    {
     157      correctionVector = (( ( diffVector *  (speed * speed/( velocity.dot(diffVector ) ) )) - velocity).getNormalized()) * agility;
    157158
    158159      if( (diffVector *  (speed * speed/( velocity.dot(diffVector ) ) ) -velocity).len() < agility )
    159        velocity = ((diffVector *  (speed * speed/( velocity.dot(diffVector ) ) )).getNormalized())*agility;
     160        velocity = ((diffVector *  (speed * speed/( velocity.dot(diffVector ) ) )).getNormalized())*agility;
    160161      else if(velocity.dot(diffVector) > 0)
    161162        velocity += correctionVector;
    162163      else if (velocity.dot(diffVector) < 0)
    163164        velocity -= correctionVector;
    164      }
     165    }
    165166    else
    166167      velocity += diffVector * agility;
    167168
    168      this->setAbsDir(Quaternion(velocity, Vector(0,1,0)) * Quaternion ( -M_PI_2, Vector(0,1,0)));
    169    }
     169    this->setAbsDir(Quaternion(velocity, Vector(0,1,0)) * Quaternion ( -M_PI_2, Vector(0,1,0)));
     170  }
    170171
    171172  velocity *= maxVelocity/velocity.len();
     
    180181 *  the function gets called, when the projectile is destroyed
    181182 */
    182 void GuidedMissile::destroy (WorldEntity* killer)
     183void BoomerangProjectile::destroy (WorldEntity* killer)
    183184{
    184185
     
    186187
    187188  Projectile::destroy( killer );
    188   PRINTF(5)("DESTROY GuidedMissile\n");
     189  PRINTF(5)("DESTROY BoomerangProjectile\n");
    189190  this->lifeCycle = .95; //!< @todo calculate this usefully.
    190   this->emitter->setSystem(GuidedMissile::explosionParticles);
     191  this->emitter->setSystem(BoomerangProjectile::explosionParticles);
    191192
    192193  this->emitter->setEmissionRate(1000.0);
    193194  this->emitter->setEmissionVelocity(50.0);
    194 //  this->deactivate();
    195 
    196 }
    197 
    198 
    199 void GuidedMissile::draw () const
     195  //  this->deactivate();
     196
     197}
     198
     199
     200void BoomerangProjectile::draw () const
    200201{
    201202  glMatrixMode(GL_MODELVIEW);
  • branches/presentation/src/world_entities/projectiles/boomerang_projectile.h

    r9206 r9217  
    11/*!
    2  * @file guided_missile.h
    3  * @brief a GuidedMissile Projectile
     2 * @file boomerang_projectile.h
     3 * @brief a BoomerangProjectile Projectile
    44*/
    55
    6 #ifndef _GUIDED_MISSILE_H
    7 #define _GUIDED_MISSILE_H
     6#ifndef _BOOMERANG_PROJECTILE_H
     7#define _BOOMERANG_PROJECTILE_H
    88
    99#include "projectile.h"
     
    1515class Aim;
    1616
    17 class GuidedMissile : public Projectile
     17class BoomerangProjectile : public Projectile
    1818{
    1919  public:
    20     GuidedMissile ();
    21     virtual ~GuidedMissile ();
     20    BoomerangProjectile ();
     21    virtual ~BoomerangProjectile ();
    2222
    2323    virtual void activate();
     
    4848};
    4949
    50 #endif /* _GUIDED_MISSILE_H */
     50#endif /* _BOOMERANG_PROJECTILE_H */
  • branches/presentation/src/world_entities/weapons/boomerang_gun.cc

    r9206 r9217  
    1515#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_WEAPON
    1616
    17 #include "turret.h"
     17#include "boomerang_gun.h"
    1818
    1919#include "weapon_manager.h"
     
    2727#include "util/loading/factory.h"
    2828
    29 CREATE_FACTORY(Turret, CL_TURRET);
     29CREATE_FACTORY(BoomerangGun, CL_BOOMERANG_GUN);
    3030
    31 using namespace std;
    3231
    3332/**
    3433 *  standard constructor
    3534 *
    36  * creates a new Turret
     35 * creates a new BoomerangGun
    3736 */
    38 Turret::Turret ()
     37BoomerangGun::BoomerangGun ()
    3938  : Weapon()
    4039{
     
    4342
    4443/**
    45  * creates a new Turret from a TiXmlElement
     44 * creates a new BoomerangGun from a TiXmlElement
    4645 */
    47 Turret::Turret(const TiXmlElement* root)
     46BoomerangGun::BoomerangGun(const TiXmlElement* root)
    4847{
    4948  this->init();
     
    5554 *  standard deconstructor
    5655*/
    57 Turret::~Turret ()
     56BoomerangGun::~BoomerangGun ()
    5857{
    5958  // model will be deleted from WorldEntity-destructor
    6059}
    6160
    62 void Turret::init()
     61void BoomerangGun::init()
    6362{
    64   this->setClassID(CL_TURRET, "Turret");
     63  this->setClassID(CL_BOOMERANG_GUN, "BoomerangGun");
    6564
    6665
     
    8584  //this->minCharge = 2;
    8685
    87   this->setCapability(WTYPE_ALLDIRS | WTYPE_TURRET);
    88   this->setProjectileType(CL_ROCKET);
     86  this->setCapability(WTYPE_ALLDIRS | WTYPE_BOMMERANG_GUN);
     87  this->setProjectileType(CL_BOOMERANG_PROJECTILE);
    8988
    90   this->loadModel("models/guns/turret1.obj");
     89  this->loadModel("models/guns/turret1.obj", 5.0);
    9190
    9291  this->setEmissionPoint(1.684, 0.472, 0);
     
    9998}
    10099
    101 void Turret::loadParams(const TiXmlElement* root)
     100void BoomerangGun::loadParams(const TiXmlElement* root)
    102101{
    103102  Weapon::loadParams(root);
    104103}
    105104
    106 void Turret::activate()
     105void BoomerangGun::activate()
    107106{
    108107}
    109108
    110 void Turret::deactivate()
     109void BoomerangGun::deactivate()
    111110{
    112111}
    113112
    114 void Turret::tick(float dt)
     113void BoomerangGun::tick(float dt)
    115114{
    116115  if (!Weapon::tickW(dt))
     
    134133}
    135134
    136 void Turret::fire()
     135void BoomerangGun::fire()
    137136{
    138137  Projectile* pj = this->getProjectile();
  • branches/presentation/src/world_entities/weapons/boomerang_gun.h

    r9206 r9217  
    44
    55
    6 #ifndef _TURRET_H
    7 #define _TURRET_H
     6#ifndef _BOOMERANG_GUN_H
     7#define _BOOMERANG_GUN_H
    88
    99#include "weapon.h"
    1010
    11 class Turret : public Weapon
     11class BoomerangGun : public Weapon
    1212  {
    1313  public:
    14     Turret ();
    15     Turret(const TiXmlElement* root);
    16     virtual ~Turret ();
     14    BoomerangGun ();
     15    BoomerangGun(const TiXmlElement* root);
     16    virtual ~BoomerangGun ();
    1717
    1818    void init();
     
    2929  };
    3030
    31 #endif /* _TURRET_H */
     31#endif /* _BOOMERANG_GUN_H */
Note: See TracChangeset for help on using the changeset viewer.