Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 10704 in orxonox.OLD for branches/presentation


Ignore:
Timestamp:
Jun 15, 2007, 11:12:29 AM (17 years ago)
Author:
rennerc
Message:

FPSSniperRifle uses BspWeapon now

Location:
branches/presentation/src/world_entities
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • branches/presentation/src/world_entities/creatures/fps_player.cc

    r10698 r10704  
    6363{
    6464  this->setPlayer(NULL);
    65 
    66   if( this->aimingSystem)
    67     delete this->aimingSystem;
    6865}
    6966
     
    126123  registerEvent(KeyMapper::PEV_JUMP);
    127124  registerEvent(KeyMapper::PEV_CROUCH);
     125  registerEvent(KeyMapper::PEV_FIRE1);
    128126  registerEvent(EV_MOUSE_MOTION);
    129 
    130   this->aimingSystem = NULL;
    131127
    132128  // weapon manager for the fps
    133129  dynamic_cast<Element2D*>(this->getWeaponManager().getFixedTarget())->setVisibility( false);
    134130
    135   if( State::isOnline())
    136   {
    137     Weapon* wpRight = new FPSSniperRifle(0);
    138     wpRight->setName("testGun Right");
    139     this->addWeapon(wpRight,1, 0);
    140     wpRight->addChild(this->aimingSystem);
    141 
    142     this->toList( OM_PLAYERS );
    143   }
    144 
    145   this->aimingSystem = new AimingSystem(this);
    146 
    147 
     131 
     132
     133  //this->aimingSystem = new AimingSystem(this);
     134
     135#if 0
    148136  this->getWeaponManager().changeWeaponConfig(1);
    149137  this->getWeaponManager().setSlotCount(2);
     
    160148  this->getWeaponManager().getFixedTarget()->setParentMode(PNODE_ALL);
    161149  this->getWeaponManager().getFixedTarget()->setRelCoor(10,0,0);
     150 
     151  if( true /*State::isOnline()*/ )
     152  {
     153    FPSSniperRifle* wpRight = new FPSSniperRifle(0);
     154    wpRight->setName("testGun Right");
     155    this->addWeapon(wpRight,1, 0);
     156    wpRight->toList( this->getOMListNumber() );
     157    wpRight->setParent( &this->cameraNode );
     158    wpRight->requestAction( WA_ACTIVATE );
     159    //wpRight->addChild(this->aimingSystem);
     160
     161    //this->toList( OM_PLAYERS );
     162  }
     163#endif
     164                         
     165  FPSSniperRifle* wpRight = new FPSSniperRifle(0);
     166  wpRight->setName("testGun Right");
     167  wpRight->toList( this->getOMListNumber() );
     168  wpRight->setParent( &this->cameraNode );
     169 
     170  this->weaponMan.setParentEntity( this );
     171  this->weaponMan.setSlotCount(1);
     172  this->weaponMan.createWeaponSlot(0, this->cameraNode.getRelCoor().x, this->cameraNode.getRelCoor().y, this->cameraNode.getRelCoor().z, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL);
     173  this->weaponMan.addWeapon(wpRight, 0, 0);
     174  this->weaponMan.changeWeaponConfig(0);
     175  Playable::weaponConfigChanged();
     176  this->weaponMan.getFixedTarget()->setParent(&this->cameraNode );
     177  this->weaponMan.getFixedTarget()->setRelCoor( 100000,0,0 );
    162178
    163179
     
    269285    State::getCamera()->setViewMode(Camera::ViewFPS);
    270286
    271 
    272     if( this->aimingSystem != NULL)
    273     {
    274       this->aimingSystem->toList(OM_GROUP_01);
    275       this->aimingSystem->setParent(&this->cameraNode);
    276   //     this->aimingSystem->setParentMode(PNODE_ROTATE_AND_MOVE);
    277       this->aimingSystem->setRelDir(Quaternion(M_PI_4*-0.58f, Vector(0,0,1)));
    278       this->aimingSystem->setRelCoor(0, -1, -1);
    279     }
    280287
    281288  }
     
    353360  if( this->bFire)
    354361  {
     362    PRINTF(0)("FPSPLAYER FIRE %d\n", this->getOMListNumber() );
    355363    this->getWeaponManager().fire();
    356   }
    357 
    358 
    359   //dealing damage
    360   if ( State::isOnline() && (SharedNetworkData::getInstance()->isMasterServer() /*|| SharedNetworkData::getInstance()->isProxyServerActive()*/))
    361   {
    362     this->damageTicker -= time;
    363 
    364     if ( this->damageTicker <= 0.0f && this->beFire() )
    365     {
    366       this->damageTicker = 0.25;
    367 
    368       WorldEntity * victim = aimingSystem->getNearestTarget();
    369 
    370       if ( victim )
    371       {
    372         PRINTF(0)("FIRE: hit %s\n", victim->getClassCName());
    373         victim->hit( 20, this );
    374       }
    375       else
    376       {
    377         PRINTF(0)("FIRE: nothing hit\n");
    378       }
    379     }
    380364  }
    381365
     
    533517
    534518  this->setOnGround(false);
    535   if( this->aimingSystem != NULL)
    536     this->aimingSystem->flushList();
    537519   
    538520}
  • branches/presentation/src/world_entities/creatures/fps_player.h

    r10698 r10704  
    1111
    1212
    13 class AimingSystem;
     13class FPSSniperRifle;
    1414
    1515
     
    7272    bool                  changingZoom;
    7373
    74     AimingSystem*         aimingSystem;      //!< aiming system of the player
    75 
    7674    float                 damageTicker;      //!< ticker for dealing damage
     75   
     76    FPSSniperRifle*       weapon;
    7777   
    7878};
  • branches/presentation/src/world_entities/npcs/adm_turret.cc

    r10703 r10704  
    254254void AdmTurret::addWeapon( const TiXmlElement * root )
    255255{
    256         this->weapon = new BspWeapon();
     256        this->weapon = new BspWeapon(getOMListNumber());
    257257        this->weapon->setParent( this->cannons );
    258258        this->weapon->loadParams(root);
  • branches/presentation/src/world_entities/weapons/bsp_weapon.cc

    r10698 r10704  
    3131*  Standard constructor
    3232*/
    33 BspWeapon::BspWeapon ()
    34 {
    35         this->init();
     33BspWeapon::BspWeapon ( OM_LIST list )
     34{
     35        this->init( list );
    3636}
    3737
     
    4949BspWeapon::BspWeapon (const  TiXmlElement* root)
    5050{
    51         this->init();
     51        this->init( OM_GROUP_00 );
    5252        if (root != NULL)
    5353        {
     
    9494void BspWeapon::tick( float dt )
    9595{
     96  PRINTF(0)("BSPWEAPON TICK: %d %f %f\n", bFire, bRate, dt );
    9697        if (bFire) {
    97                 if (bRate < 0) {
     98                if (bRate <= 0) {
    9899                        bRate += fireRate;
     100                        PRINTF(0)("BSPWEAPON SHOOT\n");
    99101                        this->shoot();
    100102                }
     
    111113}
    112114
    113 void BspWeapon::init()
    114 {
    115         bRate = 0;
     115void BspWeapon::init( OM_LIST list )
     116{
     117        bRate = 0.0;
    116118        bFire = false;
    117119        range = 1000;
     
    123125        this->aimingSystem = new AimingSystem( this );
    124126        this->aimingSystem->setParent( this );
    125         this->aimingSystem->toList(OM_GROUP_00);
     127        this->aimingSystem->toList(list);
    126128       
    127129}
     
    157159
    158160        bool hit = false;
     161       
     162        PRINTF(0)("groups: %d %d %d %d\n", this->getOMListNumber(), this->aimingSystem->getOMListNumber(), OM_GROUP_01, OM_GROUP_00);
    159163
    160164        if ( target == NULL )
     
    170174                                hit = true;
    171175                                printf( "HIT %s\n", target->getClassName().c_str() );
     176                                target->hit( this->damage, this );
    172177                        }
    173178                        else
     
    178183        }
    179184
    180         if ( !hit )
    181         {
    182                 //Vector explosionPos = this->getAbsCoor() + this->getAbsDir().apply( Vector( 1, 0, 0 ) )*shortestDist;
    183 
    184                 //TODO create explosion at explosionPos
    185         }
     185       
    186186       
    187187       
     
    196196    (*it)->draw();
    197197  }
    198 #if 0
     198#if 1
    199199  glMatrixMode(GL_MODELVIEW);
    200200  glPushMatrix();
  • branches/presentation/src/world_entities/weapons/bsp_weapon.h

    r10698 r10704  
    5151                ObjectListDeclaration(BspWeapon);
    5252        public:
    53                 BspWeapon ();
     53                BspWeapon ( OM_LIST list );
    5454                BspWeapon (const  TiXmlElement* root);
    5555                virtual ~BspWeapon();
    5656
    57                 void init();
     57                void init( OM_LIST list );
    5858                void loadParams(const TiXmlElement* root);
    59                 void fire(bool fire){ bFire = fire; }
     59                void fire(bool fire){ this->bFire = fire; }
    6060                virtual void tick(float dt);
    6161                virtual void draw() const;
    6262
    63 
     63                void setAlwaysHits( bool r ){ this->alwaysHits = r; }
     64                void setDamage( float d ){ this->damage = d; }
    6465        private:
    6566
     
    6869                void setRange( float r ){ this->range = r; }
    6970                float damage;
    70                 void setDamage( float d ){ this->damage = d; }
    7171                float fireRate;
    7272                void setFireRate( float r ){ this->fireRate = r; }
    7373                bool alwaysHits;
    74                 void setAlwaysHits( bool r ){ this->alwaysHits = r; }
    7574                void addPoint(float x, float y, float z);
    7675               
  • branches/presentation/src/world_entities/weapons/fps_sniper_rifle.cc

    r10317 r10704  
    2727#include "weapon_manager.h"
    2828#include "util/loading/factory.h"
     29#include "debug.h"
    2930
    3031
     
    4849   creates a new weapon
    4950*/
    50 FPSSniperRifle::FPSSniperRifle ( int leftRight)
     51FPSSniperRifle::FPSSniperRifle ( int leftRight, OM_LIST list)
    5152  : Weapon()
    5253{
    53   this->init();
     54  this->init(list);
    5455
    5556  this->leftRight = leftRight;
     
    5960FPSSniperRifle::FPSSniperRifle(const TiXmlElement* root)
    6061{
    61   this->init();
     62  this->init( OM_GROUP_01 );
    6263
    6364  if (root != NULL)
     
    7677
    7778
    78 void FPSSniperRifle::init()
     79void FPSSniperRifle::init(OM_LIST list)
    7980{
    8081  this->registerObject(this, FPSSniperRifle::_objectList);
     
    9596  //this->minCharge = 2;
    9697
    97   this->setActionSound(WA_SHOOT, "sounds/laser.wav");
    98   this->setActionSound(WA_ACTIVATE, "sounds/voices/lasers.wav");
     98  //this->setActionSound(WA_SHOOT, "sounds/laser.wav");
     99  //this->setActionSound(WA_ACTIVATE, "sounds/voices/lasers.wav");
    99100
    100101
    101102  this->setCapability(WTYPE_ALLDIRS | WTYPE_DIRECTIONAL);
    102   this->setProjectileTypeC("Laser");
    103   this->prepareProjectiles(20);
    104 
     103  //this->setProjectileTypeC("Laser");
     104  //this->prepareProjectiles(20);
     105  this->toList( list );
     106  this->weapon = new BspWeapon( this->getOMListNumber() );
     107  this->weapon->setAlwaysHits( true );
     108  this->weapon->setDamage( 35 );
     109  this->weapon->setParent( this );
     110  this->weapon->toList( list );
     111   
     112  this->bFire = false;
    105113}
    106114
     
    145153void FPSSniperRifle::fire()
    146154{
    147   Projectile* pj =  this->getProjectile();
    148   if (pj == NULL)
    149     return;
    150 
    151 //   Explosion::explode(this, Vector(0.1,0.1,0.1));
    152 
    153   pj->setParent(this);
    154   pj->setParentMode(PNODE_ROTATE_AND_MOVE);
    155 
    156   pj->setVelocity(this->getAbsDir().apply(Vector(1,0,0))*550 + VECTOR_RAND(5) );
    157 
    158   pj->setAbsCoor(this->getEmissionPoint() + this->getAbsDirX() * 25.0f);
    159   pj->setAbsDir(this->getAbsDir());
    160   pj->activate();
     155  PRINTF(0)("sniper fire\n");
     156  this->bFire = true;
    161157}
    162158
     
    190186}
    191187
    192 
    193 
     188void FPSSniperRifle::tick( float dt )
     189{
     190  Weapon::tick( dt );
     191  this->weapon->fire( bFire );
     192 
     193  if ( bFire ){
     194      PRINTF(0)("REAL FIRE\n");
     195  }
     196  bFire = false;
     197}
     198
     199
     200
  • branches/presentation/src/world_entities/weapons/fps_sniper_rifle.h

    r9869 r10704  
    2525
    2626#include "weapon.h"
     27#include "bsp_weapon.h"
    2728
    2829
     
    4243
    4344  public:
    44     FPSSniperRifle (int leftRight);
     45    FPSSniperRifle (int leftRight, OM_LIST list);
    4546    FPSSniperRifle (const TiXmlElement* root);
    4647    virtual ~FPSSniperRifle ();
    4748
    48     void init();
     49    void init(OM_LIST list);
    4950    virtual void loadParams(const TiXmlElement* root);
    5051
     
    5556
    5657    virtual void draw() const;
     58    virtual void tick( float dt );
    5759
    5860
     
    6163    int              leftRight;   //!< this will become an enum
    6264    Material*        material;    //!< material
     65   
     66    BspWeapon*       weapon;
     67    bool             bFire;
    6368
    6469  };
  • branches/presentation/src/world_entities/world_entity.cc

    r10698 r10704  
    983983  this->decreaseHealth(damage);
    984984
    985   PRINTF(5)("Hit me: %s::%s now only %f/%f health\n", this->getClassCName(), this->getCName(), this->getHealth(), this->getHealthMax());
     985  PRINTF(0)("Hit me: %s::%s now only %f/%f health\n", this->getClassCName(), this->getCName(), this->getHealth(), this->getHealthMax());
    986986
    987987  if( this->getHealth() > 0)
Note: See TracChangeset for help on using the changeset viewer.