Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 10688 in orxonox.OLD for branches/adm/src


Ignore:
Timestamp:
Jun 13, 2007, 1:21:07 PM (18 years ago)
Author:
rennerc
Message:

visibility check for player in adm

Location:
branches/adm/src/world_entities/npcs
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/adm/src/world_entities/npcs/adm_turret.cc

    r10683 r10688  
    2424#include "loading/load_param_xml.h"
    2525
     26#include "environments/bsp_entity.h"
     27
    2628ObjectListDefinition(AdmTurret);
    2729CREATE_FACTORY(AdmTurret);
    28 
    2930
    3031/**
     
    136137        this->range = 400;
    137138        this->isCeil = false;
     139        this->bFire = false;
     140        this->playerVisible = false;
    138141}
    139142
     
    141144{
    142145  WorldEntity::tick(dt);
     146 
     147  this->updatePlayerVisible();
    143148
    144149  //rotate sensor 2PI/sec
     
    252257        this->sensor->toList( getOMListNumber() );
    253258}
     259
    254260
    255261void AdmTurret::moveTowards( Vector targetDir, float dt )
     
    322328  this->cannons->setAbsDir( bestBodyRot * bestCannonRot );
    323329}
     330
     331void AdmTurret::updatePlayerVisible( )
     332{
     333  std::list<WorldEntity*>::iterator entityIterator;
     334  // for all bsp managers check all entities
     335  Vector pos = this->cannons->getAbsCoor();
     336  Vector dir = this->myTarget->getAbsCoor() - pos;
     337
     338  this->playerVisible = true;
     339  for( ObjectList<BspEntity>::const_iterator bspIterator = BspEntity::objectList().begin();
     340       bspIterator != BspEntity::objectList().end();
     341       bspIterator++) {
     342      float res = (dynamic_cast<BspEntity*>(*bspIterator)->getBspManager())->checkCollisionRay( pos, dir, dir.len() + 1 );
     343     
     344      if ( res < dir.len() )
     345        this->playerVisible = false;
     346  }
     347}
  • branches/adm/src/world_entities/npcs/adm_turret.h

    r10681 r10688  
    1111
    1212#include "world_entity.h"
     13#include "weapons/light_blaster.h"
    1314
    1415class AdmTurret : public WorldEntity
     
    5354                   bool isCeil;
    5455                   void setType( const std::string& type );
    55                                            
     56                   
     57                   bool bFire;
     58                   bool playerVisible;
     59                   void updatePlayerVisible();
    5660      };
    5761
Note: See TracChangeset for help on using the changeset viewer.