Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 10689 in orxonox.OLD


Ignore:
Timestamp:
Jun 13, 2007, 5:51:40 PM (17 years ago)
Author:
retolu
Message:

first shooting of the turret

Location:
branches/adm/src/world_entities
Files:
2 added
4 edited

Legend:

Unmodified
Added
Removed
  • branches/adm/src/world_entities/WorldEntities.am

    r10664 r10689  
    3434                world_entities/weapons/spike_thrower.cc \
    3535                world_entities/weapons/acid_launcher.cc \
     36                world_entities/weapons/bsp_weapon.cc \
    3637                \
    3738                world_entities/projectiles/lbolt.cc \
     
    187188                weapons/spike_thrower.h \
    188189                weapons/acid_launcher.h \
     190                weapons/bsp_weapon.h \
    189191                \
    190192                projectiles/lbolt.h \
  • branches/adm/src/world_entities/npcs/adm_turret.cc

    r10688 r10689  
    139139        this->bFire = false;
    140140        this->playerVisible = false;
     141
     142       
    141143}
    142144
     
    151153
    152154
    153   Vector playerPos = this->myTarget->getAbsCoor();
     155  Vector playerPos = this->myTarget->getAbsCoor() + Vector(0, 12, 0);
    154156  Vector ds = playerPos - ( this->cannons->getAbsCoor() );
    155   if ( isActive && ds.len() <= range )
     157  if ( isActive && ds.len() <= range && playerVisible )
     158  {
    156159    this->moveTowards( ds,  dt);
     160
     161  //if target within +/- 2.5 degrees of aim -> fire
     162  Vector dv1 = ds;
     163  dv1.normalize();
     164  Vector dv2 = this->cannons->getAbsDir().apply( Vector(-1, 0, 0));
     165  dv2.normalize();
     166  float angle = dv1.dot(dv2);
     167  if (angle > 0.999)
     168        {
     169        this->fire();
     170        }
     171  }
    157172  else
    158173    this->moveTowards( Vector(0, -1, 0), dt );
     
    212227}
    213228
    214 bool AdmTurret::isVisible(const WorldEntity myTarget)
    215 {
    216 return true;
    217 }
    218 
    219 float AdmTurret::aim(const WorldEntity Target)
    220 {
    221 return 0;
    222 }
    223 
    224229void AdmTurret::fire()
    225230{
    226         // Projectile* pj =  this->getProjectile();
    227         // if (pj == NULL) return;
    228 
    229         //pj->setOwner(this->getOwner());
    230         //pj->setParent(PNode::getNullParent());
    231         //pj->setVelocity(this->getAbsDir().apply(Vector( , , )) );
    232         //pj->setAbsCoor(this->getEmissionPoint());
    233         //pj->setAbsDir(this->getAbsDir());
    234         //pj->activate();
    235231}
    236232
     
    245241       
    246242        this->cannons->toList( getOMListNumber() );
     243
     244        this->weapon = new BspWeapon();
     245        this->weapon->setParent( this->cannons );
     246        this->weapon->toList( getOMListNumber() );
     247        this->weapon->setAbsCoor( this->cannons->getAbsCoor() );
     248        this->weapon->setAbsDir( this->weapon->getAbsDir() * Quaternion( PI, Vector(0, 1, 0) ) );
    247249}
    248250
     
    257259        this->sensor->toList( getOMListNumber() );
    258260}
    259 
    260261
    261262void AdmTurret::moveTowards( Vector targetDir, float dt )
     
    336337  Vector dir = this->myTarget->getAbsCoor() - pos;
    337338
     339
    338340  this->playerVisible = true;
    339341  for( ObjectList<BspEntity>::const_iterator bspIterator = BspEntity::objectList().begin();
  • branches/adm/src/world_entities/npcs/adm_turret.h

    r10688 r10689  
    1111
    1212#include "world_entity.h"
    13 #include "weapons/light_blaster.h"
     13#include "weapons/bsp_weapon.h"
    1414
    1515class AdmTurret : public WorldEntity
     
    3737                   WorldEntity* sensor;
    3838                   WorldEntity* myTarget;
    39                    bool isVisible(const WorldEntity myTarget);
    40                    float aim(const WorldEntity Target);
    4139                   void fire();
    4240
     
    5856                   bool playerVisible;
    5957                   void updatePlayerVisible();
     58
     59                BspWeapon* weapon;
    6060      };
    6161
  • branches/adm/src/world_entities/weapons/aiming_system.cc

    r10013 r10689  
    112112void AimingSystem::hit(float damage, WorldEntity* killer)
    113113{
    114   if( this->owner != killer)
     114  if( this->owner != killer && killer != this && !killer->isA( AimingSystem::staticClassID() ) )
    115115  {
    116116    //PRINTF(0)("real hit: %s\n", killer->getClassCName());
     
    127127void AimingSystem::tick(float dt)
    128128{
    129 
    130 
    131129}
    132130
Note: See TracChangeset for help on using the changeset viewer.