Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 9235 in orxonox.OLD for trunk/src/world_entities/creatures


Ignore:
Timestamp:
Jul 5, 2006, 4:39:02 PM (18 years ago)
Author:
bensch
Message:

merged the presentation back

Location:
trunk/src/world_entities/creatures
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/world_entities/creatures/fps_player.cc

    r9110 r9235  
    2929#include "weapons/cannon.h"
    3030#include "weapons/fps_sniper_rifle.h"
     31#include "weapons/aiming_system.h"
    3132
    3233#include "aabb.h"
     34
    3335
    3436#include "key_mapper.h"
     
    5759{
    5860  this->setPlayer(NULL);
     61
     62  if( this->aimingSystem)
     63    delete this->aimingSystem;
    5964}
    6065
     
    8186{
    8287  this->setClassID(CL_FPS_PLAYER, "FPSPlayer");
    83 
    8488
    8589  this->bLeft = false;
     
    8993  this->bJump = false;
    9094  this->bPosBut = false;
     95  this->bFire = false;
    9196
    9297  this->xMouse = 0.0f;
     
    125130
    126131//   this->addWeapon(wpLeft, 1, 0);
    127   this->addWeapon(wpRight,1, 0);
     132  if( State::isOnline())
     133    this->addWeapon(wpRight,1, 0);
    128134  this->getWeaponManager().changeWeaponConfig(1);
    129135
    130136  this->getWeaponManager().setSlotCount(2);
    131 //   this->getWeaponManager().setSlotDirection(0, Quaternion(M_PI_2, Vector(0,1,0)));
     137  this->getWeaponManager().setSlotDirection(0, Quaternion(M_PI_4*-0.55f, Vector(0,0,1)));
    132138  this->getWeaponManager().setSlotCapability(0, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL);
    133139  this->getWeaponManager().setSlotDirection(1, Quaternion(M_PI_4*.5, Vector(1,0,0)));
     
    135141  this->getWeaponManager().setSlotPosition(1, Vector(5.0, 0.0, 0.0));
    136142
     143//   this->getWeaponManager().getFixedTarget()->setRelDir(Quaternion(M_PI_4*-0.6f, Vector(0,0,1)));
     144
    137145
    138146  this->getWeaponManager().setParentNode(&this->cameraNode);
     
    141149  this->getWeaponManager().getFixedTarget()->setParent(&this->cameraNode);
    142150  this->getWeaponManager().getFixedTarget()->setRelCoor(1000,0,0);
     151
     152  this->aimingSystem = new AimingSystem(this);
     153  //this->addChild(this->aimingSystem);
     154  wpRight->addChild(this->aimingSystem);
     155//   this->getWeaponManager().sl
    143156
    144157
     
    148161  registerVar( new SynchronizeableBool( &bForward, &bForward, "bForward", PERMISSION_OWNER ) );
    149162  registerVar( new SynchronizeableBool( &bBackward, &bBackward, "bBackward", PERMISSION_OWNER ) );
     163  registerVar( new SynchronizeableBool( &bJump, &bJump, "bJump", PERMISSION_OWNER ) );
    150164  registerVar( new SynchronizeableFloat( &heading, &heading, "heading", PERMISSION_OWNER ) );
    151165  registerVar( new SynchronizeableFloat( &attitude, &attitude, "attitude", PERMISSION_OWNER ) );
     166
     167    //subscribe to collision reaction
     168  this->subscribeReaction(CREngine::CR_PHYSICS_FULL_WALK, CL_BSP_ENTITY);
     169
     170  this->initWeapon = false;
     171  this->damageTicker = 0.0f;
     172
     173  if( State::isOnline())
     174    toList( OM_PLAYERS );
    152175}
    153176
     
    192215  this->getWeaponManager().getFixedTarget()->setRelCoor(0,0,0);
    193216
    194 
    195   AABB* box = this->getModelAABB();
    196   if( box != NULL)
    197   {
    198     State::getCameraNode()->setRelCoor(0, box->halfLength[1] * 2.0f, 0);
    199     State::getCameraTargetNode()->setRelCoor(10, box->halfLength[1] * 2.0f, 0);
    200 
    201     this->getWeaponManager().setSlotPosition(0, Vector(1.5, box->halfLength[1] * 2.0f - 0.7, 1.1));
    202     this->getWeaponManager().setSlotPosition(1, Vector(5.0, box->halfLength[1] * 2.0f, 0.0));
     217  if ( !State::isOnline() )
     218  {
     219    this->respawn();
    203220  }
    204221}
     
    219236{
    220237
    221   if( this->bPosBut)
    222   {
    223     this->bPosBut = false;
    224     printf("mechanic2:walkTo( %f, mtheight, %f)\n",this->getAbsCoorX(),this->getAbsCoorZ());
    225   }
    226 
    227   Playable::tick( time );
     238  if ( !this->initWeapon )
     239  {
     240    this->initWeapon = true;
     241
     242    this->cameraNode.setParentMode(PNODE_ROTATE_AND_MOVE);
     243
     244    this->getWeaponManager().getParentNode()->setParentMode(PNODE_ROTATE_AND_MOVE);
     245    this->getWeaponManager().getFixedTarget()->setParent(&this->cameraNode);
     246    this->getWeaponManager().getFixedTarget()->setParentMode(PNODE_ROTATE_AND_MOVE);
     247
     248
     249    this->aimingSystem->toList(OM_GROUP_01);
     250    this->aimingSystem->setParent(&this->cameraNode);
     251//     this->aimingSystem->setParentMode(PNODE_ROTATE_AND_MOVE);
     252    this->aimingSystem->setRelDir(Quaternion(M_PI_4*-0.58f, Vector(0,0,1)));
     253    this->aimingSystem->setRelCoor(0, -1, -1);
     254
     255
     256    AABB* box = this->getModelAABB();
     257    if( box != NULL)
     258    {
     259      float f = 1.0;
     260      this->cameraNode.setRelCoor(0, box->halfLength[1] * f, 0);
     261//       this->cameraNode.setRelCoor(10, box->halfLength[1] * f, 0);
     262
     263      float v = 0.1f;
     264      this->getWeaponManager().setSlotPosition(0, Vector(-8.0, box->halfLength[1] * v, 1.1));
     265      this->getWeaponManager().setSlotPosition(1, Vector(5.0, box->halfLength[1] * v, 0.0));
     266    }
     267  }
     268
     269
     270  this->getWeaponManager().tick(time);
     271  if( this->bFire)
     272  {
     273    this->getWeaponManager().fire();
     274
     275//     WorldEntity* target = this->aimingSystem->getNearestTarget();
     276//     if( target != NULL)
     277//     {
     278//       PRINTF(0)("hit hit hit, got: %s\n", target->getClassName());
     279//     }
     280//     else
     281//     {
     282//       PRINTF(0)("nothing hit\n");
     283//     }
     284  }
     285
     286
     287  //dealing damage
     288
     289  if ( State::isOnline() && SharedNetworkData::getInstance()->isGameServer() )
     290  {
     291    this->damageTicker -= time;
     292
     293    if ( this->damageTicker <= 0.0f && this->beFire() )
     294    {
     295      this->damageTicker = 0.25;
     296
     297      WorldEntity * victim = aimingSystem->getNearestTarget();
     298
     299      if ( victim )
     300      {
     301        PRINTF(0)("FIRE: hit %s\n", victim->getClassName());
     302        victim->hit( 20, this );
     303      }
     304      else
     305      {
     306        PRINTF(0)("FIRE: nothing hit\n");
     307      }
     308    }
     309  }
     310
    228311
    229312  if( ( xMouse != 0 || yMouse != 0 ) && (this->getOwner() == SharedNetworkData::getInstance()->getHostID() || !State::isOnline() ) )
     
    235318    attitude-= yMouse;
    236319
    237     if ( attitude > 2.05 )
    238       attitude = 2.05;
    239 
    240     else if ( attitude < -1.15 )
    241       attitude = -1.15;
     320
     321    if ( attitude > 1.95 )
     322      attitude = 1.95;
     323    else if ( attitude < -1.07 )
     324      attitude = -1.07;
    242325
    243326    xMouse = yMouse = 0;
     
    304387    this->fallVelocity += 300.0f * time;
    305388    velocity -= Vector(0.0, 1.0, 0.0) * this->fallVelocity;
     389
     390//     PRINTF(0)("vel %f\n", this->fallVelocity);
    306391  }
    307392  else
     
    309394    this->fallVelocity = 0.0f;
    310395  }
    311 
    312396
    313397  this->shiftCoor( velocity*time );
     
    346430  }
    347431
     432  this->setOnGround(false);
     433  this->aimingSystem->flushList();
    348434}
    349435
     
    383469  }
    384470  else if( event.type == KeyMapper::PEV_JUMP)
     471  {
    385472    this->bJump = event.bPressed;
    386     this->bPosBut = event.bPressed;
    387 }
    388 
    389 
    390 
    391 
     473  }
     474  else if( event.type == KeyMapper::PEV_FIRE1)
     475  {
     476    this->bFire = event.bPressed;
     477  }
     478}
     479
     480
     481void FPSPlayer::respawn( )
     482{
     483  if( State::isOnline())
     484    toList( OM_PLAYERS );
     485
     486  this->damageTicker = 0.0f;
     487
     488  Playable::respawn();
     489}
     490
     491
     492void FPSPlayer::destroy( WorldEntity* killer )
     493{
     494  Playable::destroy( killer );
     495
     496  toList( OM_DEAD );
     497}
     498
  • trunk/src/world_entities/creatures/fps_player.h

    r9110 r9235  
    99
    1010#include "playable.h"
     11
     12
     13class AimingSystem;
    1114
    1215
     
    2730    virtual void reset();
    2831
     32    virtual void destroy(WorldEntity* killer);
     33    virtual void respawn();
    2934
    3035    virtual void tick(float time);
     
    4348    bool                  bJump;              //!< jumping
    4449    bool                  bPosBut;             //!< position button
     50    bool                  bFire;              //!< fire button
    4551
    4652    float                 xMouse;             //!< mouse moved in x-Direction
     
    5561    float                 fallVelocity;        //!< velocity for falling down
    5662    float                 jumpForce;           //!< the jump force
     63
     64    bool                  initWeapon;
     65
     66    AimingSystem*         aimingSystem;        //!< aiming system of the player
     67
     68    float                 damageTicker;        //!< ticker for dealing damage
    5769};
    5870
Note: See TracChangeset for help on using the changeset viewer.