Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 10698 in orxonox.OLD for trunk/src


Ignore:
Timestamp:
Jun 14, 2007, 5:33:43 PM (18 years ago)
Author:
snellen
Message:

merged adm, hud, vs-enhancements : beni's responsible for this commit. blame him!

Location:
trunk/src
Files:
58 edited
18 copied

Legend:

Unmodified
Added
Removed
  • trunk/src/ai/swarm_gorel.cc

    r10618 r10698  
    2323
    2424        //calculate  movement parameters..
    25         float averageRadius;
     25        float averageRadius = 0;
    2626        for (it=members.begin(); it!= members.end(); it++ ){
    2727                averageRadius+=it->second->getNPCRadius();
  • trunk/src/defs/include_paths.am

    r10376 r10698  
    3131
    3232AM_CXXFLAGS+=-I$(MAINSRCDIR)/../extern_libs
     33
     34AM_LDFLAGS+=-L$(MAINSRCDIR)/../extern_libs
  • trunk/src/defs/orxonox_globals.h

    r10638 r10698  
    7171#define   CONFIG_NAME_DEBUG_LEVEL          "Debug-Level"
    7272
    73 // evenets
     73// events
    7474#define   CONFIG_NAME_PLAYER_FORWARD       "Forward"
    7575#define   CONFIG_NAME_PLAYER_BACKWARD      "Backward"
     
    8383#define   CONFIG_NAME_PLAYER_STRAFE_RIGHT  "StrafeRight"
    8484#define   CONFIG_NAME_PLAYER_JUMP          "Jump"
     85#define   CONFIG_NAME_PLAYER_CROUCH        "Crouch"
    8586
    8687#define   CONFIG_NAME_PLAYER_ACTION        "Action"
  • trunk/src/lib/collision_detection/aabb_tree_node.cc

    r10013 r10698  
    740740
    741741  /* DRAW POLYGONS */
    742   if( drawMode & DRAW_BV_POLYGON || drawMode & DRAW_ALL || drawMode & DRAW_BV_BLENDED)
     742  if( (drawMode & DRAW_BV_POLYGON) || (drawMode & DRAW_ALL) || (drawMode & DRAW_BV_BLENDED))
    743743  {
    744744    if (top)
  • trunk/src/lib/event/key_mapper.cc

    r10638 r10698  
    4747int KeyMapper::PEV_JUMP              = EV_UNKNOWN;
    4848int KeyMapper::PEV_ACTION            = EV_UNKNOWN;
     49int KeyMapper::PEV_CROUCH            = EV_UNKNOWN;
    4950
    5051int KeyMapper::PEV_FIRE1             = EV_UNKNOWN;
     
    8788      {&KeyMapper::PEV_JUMP,                 CONFIG_NAME_PLAYER_JUMP,            SDLK_SPACE},
    8889      {&KeyMapper::PEV_ACTION,               CONFIG_NAME_PLAYER_ACTION,          SDLK_u},
     90      {&KeyMapper::PEV_CROUCH,               CONFIG_NAME_PLAYER_CROUCH,          SDLK_LCTRL},
     91
    8992
    9093      {&KeyMapper::PEV_FIRE1,                CONFIG_NAME_PLAYER_FIRE,            EV_MOUSE_BUTTON_LEFT},
  • trunk/src/lib/event/key_mapper.h

    r10638 r10698  
    5858  static int PEV_JUMP;              //!< jump
    5959  static int PEV_ACTION;            //!< the action (or use) key
     60  static int PEV_CROUCH;            //!< crouch
    6061
    6162  static int PEV_FIRE1;             //!< fire button 1
  • trunk/src/lib/graphics/importer/bsp/bsp_manager.cc

    r10643 r10698  
    173173  // erase alreadyVisible
    174174  for(int i = 0; i < this->bspFile->numFaces; i++) this->alreadyVisible[i] = false;
    175   float tmp = 0;
     175//   float tmp = 0;
    176176  //this->opal.clear();
    177177  //this->trasparent.clear();
     
    186186
    187187  this->viewDir=    State::getCamera()->getAbsDirX();
    188   float d = (cam.x*viewDir.x + cam.y*viewDir.y + cam.z * viewDir.z);
     188//   float d = (cam.x*viewDir.x + cam.y*viewDir.y + cam.z * viewDir.z);
    189189
    190190  BspTreeNode*  ActLeaf = this->getLeaf(this->bspFile->root, &ship);
     
    254254
    255255    for(int i = 0; i <  this->bspFile->numLeafs   ; ++i ) {
    256       leaf& camLeaf =  (this->bspFile->leaves)[ActLeaf->leafIndex] ;
     256//       leaf& camLeaf =  (this->bspFile->leaves)[ActLeaf->leafIndex] ;
    257257      leaf& curLeaf =  (this->bspFile->leaves)[i] ;
    258258      int& cluster =  curLeaf.cluster;
     
    16961696
    16971697
     1698float BspManager::checkCollisionRay(Vector StartPoint, Vector Direction, float length )
     1699{
     1700  Direction.normalize(); // Oder besser vor dem Fkt-Aufruf schon normalisieren
     1701  this->outputStartsOut = true;
     1702  this->outputAllSolid = false;
     1703  this->outputFraction = 1.0f;
     1704  this->inputStart =  StartPoint;
     1705  Vector End =   StartPoint + (Direction)*length;
     1706  this->inputEnd =   End;
     1707
     1708  this->checkCollisionRayN(this->root, 0.0f, 1.0f, &StartPoint, &(End) );
     1709
     1710  return (this->outputFraction * length);
     1711
     1712}
     1713
     1714
    16981715
    16991716/**
  • trunk/src/lib/graphics/importer/bsp/bsp_manager.h

    r10618 r10698  
    7777  void checkCollision(WorldEntity* worldEntity); /*!< WorldEntities use this function to check wheter they collided with the BspEntity.
    7878                                                      If a collision has been detected, the collides-function of worldEntity will be called.*/
     79  float checkCollisionRay(Vector StartPoint, Vector Direction, float length ) ;
    7980
    8081  int sortTransparency;              //!< sort transparent textures
  • trunk/src/lib/math/quaternion.h

    r10695 r10698  
    5050
    5151    /** @param q: the Quaternion to compare with this one. @returns true if the Quaternions are the same, false otherwise */
    52   inline bool operator== (const Quaternion& q) const { return (unlikely(this->v==q.v&&this->w==q.w))?true:false; };
     52    inline bool operator== (const Quaternion& q) const { return (unlikely(this->v==q.v&&this->w==q.w))?true:false; };
    5353    /** @param q: the Quaternion to compare with this one. @returns true if the Quaternions are the same, false otherwise */
    54   inline bool operator!= (const Quaternion& q) const { return (unlikely(this->v!=q.v||this->w!=q.w))?true:false; };
     54    inline bool operator!= (const Quaternion& q) const { return (unlikely(this->v!=q.v||this->w!=q.w))?true:false; };
    5555    /** @param f: a real value @return a Quaternion containing the quotient */
    5656    inline Quaternion operator/ (const float& f) const { return (unlikely(f==0.0)) ? Quaternion() : Quaternion(this->v/f, this->w/f); };
     
    118118
    119119
    120     inline void slerpTo(const Quaternion& toQuat, float t);
     120    void slerpTo(const Quaternion& toQuat, float t);
    121121    static Quaternion quatSlerp(const Quaternion& from, const Quaternion& to, float t);
    122122
  • trunk/src/lib/math/vector.h

    r10376 r10698  
    5151
    5252  /** @param index The index of the "array" @returns the x/y/z coordinate */
    53   inline float operator[] (float index) const {if( index == 0) return this->x; if( index == 1) return this->y; if( index == 2) return this->z; }
     53  inline float operator[] (float index) const {if( index == 0) return this->x; if( index == 1) return this->y; if( index == 2) return this->z; else return this->x; }
    5454  /** @param v The vector to add @returns the addition between two vectors (this + v) */
    5555  inline Vector operator+ (const Vector& v) const { return Vector(x + v.x, y + v.y, z + v.z); };
     
    6464  /** @param v The vector to substract  @returns the substraction between two vectors (this - v) */
    6565  inline Vector operator- (const sVec3D& v) const { return Vector(x - v[0], y - v[1], z - v[2]); }
     66  /** @returns the substraction between (0, 0, 0) and this (null-this) */
     67  inline Vector operator- () const { return Vector(-x, -y, -z); }
    6668  /** @param v The vector to substract  @returns the substraction between two vectors (this -= v) */
    6769  inline const Vector& operator-= (const Vector& v) { this->x -= v.x; this->y -= v.y; this->z -= v.z; return *this; };
  • trunk/src/story_entities/game_world.cc

    r10618 r10698  
    695695    AtmosphericEngine::getInstance()->draw();
    696696
     697    /* draw bounding boxes */
    697698    if( unlikely( this->showBV))
    698699    {
  • trunk/src/util/Makefile.am

    r10618 r10698  
    2626                        animation/animation_player.cc \
    2727                        \
    28                         track/track.cc
     28                        track/track.cc \
     29                        track/action_box.cc
    2930
    3031noinst_HEADERS =        \
     
    4950                        animation/t_animation.h \
    5051                        \
    51                         track/track.h
     52                        track/track.h \
     53                        track/action_box.h
  • trunk/src/util/hud.cc

    r10516 r10698  
    1111   ### File Specific:
    1212   main-programmer: Benjamin Grauer
    13    co-programmer: ...
     13   co-programmer: Benjamin Knecht
    1414*/
    1515
     
    5252  this->energyWidget = NULL;
    5353  this->shieldWidget = NULL;
    54   this->armorWidget = NULL;
    55   //this->leftRect = NULL;
    56   //this->rightRect = NULL;
     54  this->healthWidget = NULL;
     55  this->leftRect = NULL;
     56  this->rightRect = NULL;
    5757  this->resX = 1;
    5858  this->resY = 1;
     
    6262  this->rightRect = new OrxGui::GLGuiImage();
    6363  this->leftRect = new OrxGui::GLGuiImage();
     64  this->topRect = new OrxGui::GLGuiImage();
     65  this->bottomRect = new OrxGui::GLGuiImage();
     66  this->middleRect = new OrxGui::GLGuiImage();
    6467
    6568  this->inputLine = new OrxGui::GLGuiInputLine();
    66   this->inputLine->setParent2D(this);
     69  //this->inputLine->setParent2D(this);
    6770  this->notifier = new OrxGui::GLGuiNotifier();
    68   this->notifier->setParent2D(this);
    69   notifier->setAbsCoor2D(100,100);
     71  this->notifier->setParent2D(this->bottomRect);
     72  notifier->setRelCoor2D(5,5);
     73 
     74  this->barSocket = new OrxGui::GLGuiImage();
     75  this->barSocket->setParent2D(this->bottomRect);
    7076
    7177  this->_radar = new OrxGui::GLGuiRadar();
     
    8894
    8995  delete this->_radar;
     96  delete this->barSocket;
    9097  delete this->rightRect;
    9198  delete this->leftRect;
     99  delete this->topRect;
     100  delete this->bottomRect;
     101  delete this->middleRect;
     102
    92103  //if (this->shipValuesBox != NULL)
    93104    //delete this->shipValuesBox;
     
    135146  }
    136147
    137   this->updateResolution();
    138 }
    139 
    140 void Hud::setShiledWidget(OrxGui::GLGuiWidget* widget)
     148  this->updateResolution(); 
     149}
     150
     151void Hud::setShieldWidget(OrxGui::GLGuiWidget* widget)
    141152{
    142153  /*
     
    169180}
    170181
    171 void Hud::setArmorWidget(OrxGui::GLGuiWidget* widget)
    172 {
    173   /*
    174   if (this->shipValuesBox == NULL)
    175     this->createShipValuesBox();
    176   */
    177 
    178 // decopple old widget
    179   if (this->armorWidget != NULL)
    180   {
    181     this->armorWidget->hide();
    182   }
    183 
    184   this->armorWidget = widget;
    185   if (this->armorWidget != NULL)
    186   {
    187     //this->armorWidget->shiftDir2D(270);
    188     //this->shipValuesBox->pack(this->armorWidget);
    189     //dynamic_cast<OrxGui::GLGuiEnergyWidgetVertical*> (this->armorWidget)->setStandardSettings();
    190     this->armorWidget->setParent2D(this->leftRect);
    191     dynamic_cast<OrxGui::GLGuiEnergyWidgetVertical*> (this->armorWidget)->setDisplayedImage("textures/gui/gui_health_icon.png");
    192     this->armorWidget->show();
    193     /*    this->armorWidget->frontMaterial().setDiffuseMap("hud_energy_bar.png");
    194         this->armorWidget->frontMaterial().setBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);*/
     182void Hud::setHealthWidget(OrxGui::GLGuiWidget* widget)
     183{
     184        if( this->playmode == FirstPerson )
     185        {
     186                this->healthWidget = new OrxGui::GLGuiBar();
     187                dynamic_cast<OrxGui::GLGuiBar*> (this->healthWidget)->setMaximum(dynamic_cast<OrxGui::GLGuiEnergyWidgetVertical*> (widget)->getBarWidget()->maximum());
     188                dynamic_cast<OrxGui::GLGuiBar*> (this->healthWidget)->setValue(dynamic_cast<OrxGui::GLGuiEnergyWidgetVertical*> (widget)->getBarWidget()->value());
     189                this->healthWidget->setParent2D(this->barSocket);
     190        }
     191        else
     192        {
     193          /*
     194          if (this->shipValuesBox == NULL)
     195            this->createShipValuesBox();
     196          */
     197       
     198        // decopple old widget
     199          if (this->healthWidget != NULL)
     200          {
     201            this->healthWidget->hide();
     202          }
     203       
     204          this->healthWidget = widget;
     205          if (this->healthWidget != NULL)
     206          {
     207            //this->healthWidget->shiftDir2D(270);
     208            //this->shipValuesBox->pack(this->healthWidget);
     209            //dynamic_cast<OrxGui::GLGuiEnergyWidgetVertical*> (this->healthWidget)->setStandardSettings();
     210            this->healthWidget->setParent2D(this->leftRect);
     211            //dynamic_cast<OrxGui::GLGuiEnergyWidgetVertical*> (this->healthWidget)->setDisplayedImage("textures/gui/gui_health_icon.png");
     212            this->healthWidget->show();
     213            /*    this->healthWidget->frontMaterial().setDiffuseMap("hud_energy_bar.png");
     214                this->healthWidget->frontMaterial().setBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);*/
     215          }
     216        }
     217
     218  this->updateResolution();
     219}
     220
     221
     222void Hud::setImplantWidget(OrxGui::GLGuiWidget* widget)
     223{
     224  //if (this->shipValuesBox == NULL)
     225    //this->createShipValuesBox();
     226
     227  // decopple old widget
     228  if (this->implantWidget != NULL)
     229  {
     230    this->implantWidget->hide();
     231  }
     232
     233  this->implantWidget = widget;
     234  if (this->implantWidget != NULL)
     235  {
     236    //this->energyWidget->shiftDir2D(270);
     237    //dynamic_cast<OrxGui::GLGuiEnergyWidgetVertical*> (this->energyWidget)->setDisplayedName("Electronics");
     238    //this->shipValuesBox->pack(this->energyWidget);
     239    //dynamic_cast<OrxGui::GLGuiEnergyWidgetVertical*> (this->energyWidget)->setStandardSettings();
     240    this->implantWidget->setParent2D(this->leftRect);
     241    dynamic_cast<OrxGui::GLGuiEnergyWidgetVertical*> (this->implantWidget)->setDisplayedImage("textures/gui/gui_electronics_icon.png");
     242    this->implantWidget->show();
     243    /*    this->energyWidget->frontMaterial().setDiffuseMap("hud_energy_bar.png");
     244        this->energyWidget->frontMaterial().setBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);*/
    195245  }
    196246
     
    341391
    342392  this->setSize2D(.2 * this->resX, this->resY);
    343   this->notifier->setAbsCoor2D(0.7 * this->resX, 0.3 * this->resY);
    344   this->notifier->setWidgetSize(0.25 * this->resX, 0.6 * this->resY);
     393  if( this->playmode != FirstPerson )
     394  {
     395          this->notifier->setAbsCoor2D(0.7 * this->resX, 0.3 * this->resY);
     396          this->notifier->setWidgetSize(0.25 * this->resX, 0.6 * this->resY);
     397  }
    345398
    346399  int overlayWidth = 0;
     
    348401    overlayWidth = this->resX * (overlayPercentage)/(200);
    349402  else
    350     overlayWidth = this->resX * 0.1;
     403    overlayWidth = this->resX / 10; // fixed warning!
    351404  //if (overlayWidth < 100)
    352405    //overlayWidth = 100;
     
    354407  this->rightRect->hide();
    355408  this->leftRect->hide();
    356 
    357   this->leftRect->setParent2D(this);
    358   this->leftRect->setWidgetSize(float(overlayWidth), float(this->resY));
    359   this->leftRect->setAbsCoor2D(0,0);
    360   this->leftRect->setBackgroundTexture(Texture());
    361   this->leftRect->setBackgroundColor(Color(0,0,0.7,0.2));
    362   this->leftRect->setForegroundTexture(Texture());
    363   this->leftRect->setForegroundColor(Color(0,0,0,0));
    364 
    365   this->rightRect->setParent2D(this);
    366   this->rightRect->setWidgetSize(float(overlayWidth), float(this->resY));
    367   this->rightRect->setAbsCoor2D(this->resX - overlayWidth,0);
    368   this->rightRect->setBackgroundTexture(Texture());
    369   this->rightRect->setBackgroundColor(Color(0,0,0.7,0.2));
    370   this->rightRect->setForegroundTexture(Texture());
    371   this->rightRect->setForegroundColor(Color(0,0,0,0));
    372 
     409 
     410  if( this->playmode != FirstPerson )
     411  {
     412          this->leftRect->setParent2D(this);
     413          this->leftRect->setWidgetSize(float(overlayWidth), float(this->resY));
     414          this->leftRect->setAbsCoor2D(0,0);
     415          this->leftRect->setBackgroundTexture(Texture());
     416          this->leftRect->setBackgroundColor(Color(0,0,0.7,0.2));
     417          this->leftRect->setForegroundTexture(Texture());
     418          this->leftRect->setForegroundColor(Color(0,0,0,0));
     419       
     420          this->rightRect->setParent2D(this);
     421          this->rightRect->setWidgetSize(float(overlayWidth), float(this->resY));
     422          this->rightRect->setAbsCoor2D(this->resX - overlayWidth,0);
     423          this->rightRect->setBackgroundTexture(Texture());
     424          this->rightRect->setBackgroundColor(Color(0,0,0.7,0.2));
     425          this->rightRect->setForegroundTexture(Texture());
     426          this->rightRect->setForegroundColor(Color(0,0,0,0));
     427  }
     428  else
     429  {
     430          this->bottomRect->setParent2D(this);
     431          this->bottomRect->setWidgetSize(float(this->resX), float(overlayWidth));
     432          this->bottomRect->setAbsCoor2D(0, this->resY - overlayWidth);
     433          this->topRect->setParent2D(this);
     434          this->topRect->setWidgetSize(float(this->resX), float(overlayWidth));
     435          this->topRect->setAbsCoor2D(0, 0);
     436          this->middleRect->setParent2D(this);
     437          this->middleRect->setWidgetSize(float(this->resY)/2, float(this->resY)/2);
     438          this->middleRect->setAbsCoor2D(float(this->resX - this->resY/2)/2, float(this->resY)/4);
     439  }
    373440
    374441  if (this->overlayActive == true)
     
    382449  {
    383450    PRINTF(4)("UPDATING RADAR\n");
    384     this->_radar->setParent2D(this->leftRect);
     451    if( this->playmode != FirstPerson )
     452        this->_radar->setParent2D(this->leftRect);
     453    else
     454        this->_radar->setParent2D(this->topRect);
    385455    if (radarCenterNode == NULL)
    386456      this->_radar->setCenterNode(State::getPlayer()->getPlayable());
     
    397467   
    398468    int statWidgetsNumber = 0;
    399     float expectedArmorSizeX = 0;
    400     float expectedArmorSizeY = 0;
     469    float expectedHealthSizeX = 0;
     470    float expectedHealthSizeY = 0;
    401471    float newSizeY = 0; float newSizeX = 0;
    402472    float moduloWidth = 0;
    403473
    404     if (this->armorWidget != NULL)
    405     {
    406       expectedArmorSizeX = 150;
    407       expectedArmorSizeY = 50;
    408       statWidgetsNumber++;
    409     }
    410 
     474        if( this->playmode != FirstPerson )
     475        {
     476            if (this->healthWidget != NULL)
     477            {
     478              expectedHealthSizeX = 150;
     479              expectedHealthSizeY = 50;
     480              statWidgetsNumber++;
     481            }
     482
     483            if (this->shieldWidget != NULL)
     484              statWidgetsNumber++;
     485           
     486            if (this->energyWidget != NULL)
     487              statWidgetsNumber++;
     488       
     489            if (expectedHealthSizeY * statWidgetsNumber > overlayWidth)
     490            {
     491              newSizeY = overlayWidth / float(statWidgetsNumber);
     492              newSizeX = expectedHealthSizeX;
     493              PRINTF(0)("Statwidgets resized\n");
     494            }
     495            else
     496            {
     497              newSizeY = expectedHealthSizeY;
     498              newSizeX = expectedHealthSizeX;
     499              moduloWidth = int(overlayWidth) % int(expectedHealthSizeY * statWidgetsNumber);
     500            }
     501       
     502            float posY = overlayWidth + newSizeX;
     503       
     504            if (this->healthWidget != NULL)
     505            {
     506              this->healthWidget->setSize2D(newSizeX, newSizeY);
     507              this->healthWidget->setRelCoor2D((statWidgetsNumber - 1) * newSizeY + 3 * moduloWidth / (statWidgetsNumber + 1),posY);
     508            }
     509            if (this->shieldWidget != NULL)
     510            {
     511              this->shieldWidget->setSize2D(newSizeX, newSizeY);
     512              this->shieldWidget->setRelCoor2D((statWidgetsNumber - 2) * newSizeY + 2 *moduloWidth / (statWidgetsNumber + 1),posY);
     513            }
     514            if (this->energyWidget != NULL)
     515            {
     516              this->energyWidget->setSize2D(newSizeX, newSizeY);
     517              this->energyWidget->setRelCoor2D(moduloWidth / (statWidgetsNumber + 1),posY);
     518            }
     519        }
     520        else
     521        {
     522                this->barSocket->setParent2D(this->bottomRect);
     523                this->barSocket->setWidgetSize( float(overlayWidth), float(overlayWidth));
     524                this->barSocket->setRelCoor2D(0,this->resX - float(overlayWidth));
     525               
     526                this->healthWidget->setRelCoor2D(10,-20);
     527        }
     528       
     529
     530    /*
     531    if (this->healthWidget != NULL)
     532      this->healthWidget->setRelCoor2D(100,0.2*this->resY + this->healthWidget->getSizeX2D());
    411533    if (this->shieldWidget != NULL)
    412       statWidgetsNumber++;
    413    
     534      this->shieldWidget->setRelCoor2D(60,0.2*this->resY + this->healthWidget->getSizeX2D());
    414535    if (this->energyWidget != NULL)
    415       statWidgetsNumber++;
    416 
    417     if (expectedArmorSizeY * statWidgetsNumber > overlayWidth)
    418     {
    419       newSizeY = overlayWidth / float(statWidgetsNumber);
    420       newSizeX = expectedArmorSizeX;
    421       PRINTF(0)("Statwidgets resized\n");
    422     }
    423     else
    424     {
    425       newSizeY = expectedArmorSizeY;
    426       newSizeX = expectedArmorSizeX;
    427       moduloWidth = int(overlayWidth) % int(expectedArmorSizeY * statWidgetsNumber);
    428     }
    429 
    430     float posY = overlayWidth + newSizeX;
    431 
    432     if (this->armorWidget != NULL)
    433     {
    434       this->armorWidget->setSize2D(newSizeX, newSizeY);
    435       this->armorWidget->setRelCoor2D((statWidgetsNumber - 1) * newSizeY + 3 * moduloWidth / (statWidgetsNumber + 1),posY);
    436     }
    437     if (this->shieldWidget != NULL)
    438     {
    439       this->shieldWidget->setSize2D(newSizeX, newSizeY);
    440       this->shieldWidget->setRelCoor2D((statWidgetsNumber - 2) * newSizeY + 2 *moduloWidth / (statWidgetsNumber + 1),posY);
    441     }
    442     if (this->energyWidget != NULL)
    443     {
    444       this->energyWidget->setSize2D(newSizeX, newSizeY);
    445       this->energyWidget->setRelCoor2D(moduloWidth / (statWidgetsNumber + 1),posY);
    446     }
    447 
    448     /*
    449     if (this->armorWidget != NULL)
    450       this->armorWidget->setRelCoor2D(100,0.2*this->resY + this->armorWidget->getSizeX2D());
    451     if (this->shieldWidget != NULL)
    452       this->shieldWidget->setRelCoor2D(60,0.2*this->resY + this->armorWidget->getSizeX2D());
    453     if (this->energyWidget != NULL)
    454       this->energyWidget->setRelCoor2D(20,0.2*this->resY + this->armorWidget->getSizeX2D());
     536      this->energyWidget->setRelCoor2D(20,0.2*this->resY + this->healthWidget->getSizeX2D());
    455537    */
    456     //this->shieldWidget->setRelCoor2D(0.1*this->resX + this->armorWidget->getSizeX2D(),0);
    457     //this->energyWidget->setRelCoor2D(0.1*this->resX + this->armorWidget->getSizeX2D() + this->shieldWidget->getSizeX2D(),0);
     538    //this->shieldWidget->setRelCoor2D(0.1*this->resX + this->healthWidget->getSizeX2D(),0);
     539    //this->energyWidget->setRelCoor2D(0.1*this->resX + this->healthWidget->getSizeX2D() + this->shieldWidget->getSizeX2D(),0);
    458540  }
    459541
  • trunk/src/util/hud.h

    r10368 r10698  
    2828
    2929public:
     30
     31  typedef enum {
     32    Vertical         =  1,       //!< Vertical (seen from left or right/move in x-z)
     33    Horizontal       =  2,       //!< Horizontal (seet from the top/move in x-y)
     34    FromBehind       =  4,       //!< Seen from behind (move in z-y)
     35    Full3D           =  8,       //!< Full featured 3D-mode. (move in all directions x-y-z)
     36    FirstPerson      = 16,
     37
     38    PlaymodeCount    =  5,
     39  } Playmode;
     40 
    3041  Hud();
    3142  virtual ~Hud();
     
    3647  void notifyUser(const std::string& message);
    3748
     49  inline void setMode(Hud::Playmode playmode) {this->playmode = playmode;};
     50  inline Hud::Playmode getMode() {return this->playmode;};
    3851
    3952  void setBackGround();
    4053  void setEnergyWidget(OrxGui::GLGuiWidget* widget);
    41   void setShiledWidget(OrxGui::GLGuiWidget* widget);
    42   void setArmorWidget(OrxGui::GLGuiWidget* widget);
     54  void setShieldWidget(OrxGui::GLGuiWidget* widget);
     55  void setHealthWidget(OrxGui::GLGuiWidget* widget);
     56  void setImplantWidget(OrxGui::GLGuiWidget* widget);
     57
    4358  inline OrxGui::GLGuiWidget* getEnergyWidget() {return this->energyWidget;};
    4459  inline OrxGui::GLGuiWidget* getShieldWidget() {return this->shieldWidget;};
    45   inline OrxGui::GLGuiWidget* getArmorWidget() {return this->armorWidget;};
     60  inline OrxGui::GLGuiWidget* getHealthWidget() {return this->healthWidget;};
     61  inline OrxGui::GLGuiWidget* getImplantWidget() {return this->implantWidget;};
    4662
    4763  void setWeaponManager(WeaponManager* weaponMan, WeaponManager* weaponManSec = NULL);
     
    8298  unsigned int             resX;
    8399  unsigned int             resY;
     100 
     101  Hud::Playmode                         playmode;
    84102
    85103  float                    travelZoneWidth; //the percentage of the screen, the player has got for his movements. should always be a value between 0 and 1;
     
    87105  OrxGui::GLGuiWidget*     energyWidget;
    88106  OrxGui::GLGuiWidget*     shieldWidget;
    89   OrxGui::GLGuiWidget*     armorWidget;
     107  OrxGui::GLGuiWidget*     healthWidget;
     108  OrxGui::GLGuiWidget*     implantWidget;
    90109
    91110  OrxGui::GLGuiNotifier*   notifier;
     
    96115  OrxGui::GLGuiWidget*     rightRect;
    97116  OrxGui::GLGuiWidget*     leftRect;
     117  OrxGui::GLGuiWidget*          topRect;
     118  OrxGui::GLGuiWidget*          bottomRect;
     119  OrxGui::GLGuiWidget*          middleRect;
     120  OrxGui::GLGuiWidget*          barSocket;
    98121  bool                     overlayActive;
    99122  int                      overlayPercentage; //the percentage of the screen, the player has got for his movements. should always be a value between 0 and 1;
  • trunk/src/util/state.cc

    r10643 r10698  
    5656int State::menuID = -1;
    5757
     58ActionBox* State::actionBox = NULL;
    5859
    5960/**
  • trunk/src/util/state.h

    r10643 r10698  
    2020class CameraMan;
    2121class ScriptManager;
     22class ActionBox;
    2223
    2324
     
    130131  /** @returns the scroller-travelnode (center of the screen) */
    131132  static PNode* getTravelNode() { return State::travelNode; }
     133 
     134  /** sets the action box (this is where the fighting takes place) */
     135  static void setActionBox( ActionBox* ab ){ State::actionBox = ab; }
     136  /** @returns the action box (this is where the fighting takes place) */
     137  static ActionBox* getActionBox(){ return State::actionBox; }
    132138
    133139
     
    146152  static Player*                player;             //!< A reference to the Player
    147153  static PNode*                 travelNode;         //!< A reference to the scroller-travelnode
     154  static ActionBox*             actionBox;          //!< A reference to the action box
    148155
    149156  static SkyBox*                skyBox;            //!< The SkyBox used in the current world.
  • trunk/src/util/track/track.cc

    r10618 r10698  
    2929
    3030#include "debug.h"
     31#include "action_box.h"
    3132
    3233ObjectListDefinition(Track);
     
    6566  this->duration = 20;
    6667  this->endTime = 20;
    67   this->width = 10;
     68  this->width = 24;
     69  this->height = 18;
     70  this->depth = 200;
     71  this->stretch = 4;
    6872  this->curve = new BezierCurve();
    6973  this->trackNode = new PNode(PNode::getNullParent(), PNODE_ALL);
     
    7175  this->localTime = 0;
    7276  this->pause = false;
     77 
     78  this->actionBox = NULL;
    7379}
    7480
     
    94100     }
    95101     LOAD_PARAM_END_CYCLE(element);
     102
     103     LoadParam(root, "ActionBox", this, Track, addActionBox );
    96104}
    97105
     
    252260       {
    253261           Vector tmp = this->calcPos();
    254    
    255    
     262
     263
    256264           Vector dV = tmp - this->trackNode->getAbsCoor();
    257265           float dx = speed * dt;
    258266           float ratio = dx / dV.len();
    259    
     267
    260268           if( dt > 0.0f)
    261269           {
     
    264272           }
    265273           tmp = this->calcPos();
    266    
     274
    267275           Vector v(0.0, 1.0, 0.0);
    268276           Quaternion quat = Quaternion(this->calcDir(), v);
    269277           Quaternion q(-PI/2, v);
    270278           quat = quat * q;
    271    
     279
    272280           // move trackNode of the track
    273281           this->trackNode->shiftCoor(tmp - this->trackNode->getAbsCoor());
     
    331339    glPopMatrix();
    332340}
     341
     342/**
     343 * creates new action box and assignes it to this track
     344 * @param width_2 width/2 of near end
     345 * @param height_2 height/2 of near end
     346 * @param depth depth
     347 * @param stretch far end will be stretched with this factor
     348 */
     349void Track::addActionBox( float width_2, float height_2, float depth, float stretch )
     350{
     351  actionBox = new ActionBox( this, width_2, height_2, depth, stretch );
     352}
     353
     354
     355
  • trunk/src/util/track/track.h

    r10498 r10698  
    1212class PNode;
    1313class TiXmlElement;
     14class ActionBox;
    1415
    1516class Track : public BaseObject
     
    4243   float                 duration;             //!< The time used to cross this Track (curve).
    4344   float                 endTime;              //!< The time at which this Track ends.
    44    float                 width;                //!< Th width of the Path. This tells the Player(s), how far he(they) can go to the left/right.
     45   float                 width;                //!< The width of the action box, next to the player.
     46   float                 height;               //!< The Height of the action box, next to the player
     47   float                 depth;                //!< Depth of the action box
     48   float                 stretch;              //!< multiplyer between w/h at player and w/h at far end of the action box
    4549
    4650   int                   nodeCount;            //!< The count of points this Track has.
    4751   Curve*                curve;                //!< The Curve of this Track
     52   
     53   ActionBox*            getActionBox(){ return this->actionBox; }
    4854
    4955 private:
    5056   void init();
    51 
    52 
     57   
    5358 private:
    5459   CurveType            curveType;              //!< The CurveType the entire TrackSystem will have.
     
    5762   int                  mode;                   //!< Defines the behaviour of the Track.
    5863   bool                 pause;                  //!< Defines if the track runs (false) or not (true)
     64   
     65   ActionBox*           actionBox;
     66   
     67   void addActionBox( float width_2, float height_2, float depth, float stretch );
     68   
     69
    5970};
    6071
  • trunk/src/world_entities/WorldEntities.am

    r10695 r10698  
    1 
    21## THE SUBCLASSES. THESE MUST BE DYNAMICALLY LINKED OR COMPILED IN DIRECTLY
    32WorldEntities_SOURCES_ = \
     
    1211                world_entities/npcs/repair_station.cc \
    1312                world_entities/npcs/attractor_mine.cc \
     13                world_entities/npcs/actionbox_enemy.cc \
     14                world_entities/npcs/adm_turret.cc \
    1415                \
    1516                \
     
    3233                world_entities/weapons/spike_thrower.cc \
    3334                world_entities/weapons/acid_launcher.cc \
     35                world_entities/weapons/rf_cannon.cc \
     36                world_entities/weapons/disruptor.cc \
     37                world_entities/weapons/nadion_laser.cc \
     38                world_entities/weapons/bsp_weapon.cc \
    3439                \
    3540                world_entities/projectiles/lbolt.cc \
     
    4752                world_entities/projectiles/spike.cc \
    4853                world_entities/projectiles/acid_splash.cc \
     54                world_entities/projectiles/plasma_pulse.cc \
     55                world_entities/projectiles/nadion_blast.cc \
    4956                \
    5057                world_entities/projectiles/projectile_weapon.cc \
     
    158165                npcs/repair_station.h \
    159166                npcs/attractor_mine.h \
     167                npcs/actionbox_enemy.h \
     168                npcs/adm_turret.h \
    160169                \
    161170                environments/environment.h \
     
    196205                weapons/spike_thrower.h \
    197206                weapons/acid_launcher.h \
     207                weapons/rf_cannon.h \
     208                weapons/disruptor.h \
     209                weapons/nadion_laser.h \
     210                weapons/bsp_weapon.h \
    198211                \
    199212                projectiles/lbolt.h \
     
    212225                projectiles/spike_ball.h \
    213226                projectiles/acid_splash.h \
     227                projectiles/plasma_pulse.h \
     228                projectiles/nadion_blast.h \
    214229                \
    215230                projectiles/projectile_weapon.h \
  • trunk/src/world_entities/creatures/fps_player.cc

    r10618 r10698  
    1919#include "interactive_model.h"
    2020#include "state.h"
     21#include "tools/camera.h"
     22#include "player.h"
    2123
    2224#include "src/lib/util/loading/factory.h"
     
    5153                            ->addMethod("getAbsCoorY", Executor0ret<PNode, lua_State*, float>(&PNode::getAbsCoorY))
    5254                            ->addMethod("getAbsCoorZ", Executor0ret<PNode, lua_State*, float>(&PNode::getAbsCoorZ))
     55                            ->addMethod("displayHUDText", Executor1<FPSPlayer, lua_State*, const std::string&>(&FPSPlayer::displayHUDText))
    5356                       );
    5457
     
    9598  this->bPosBut = false;
    9699  this->bFire = false;
     100  this->bFire2 = false;
     101  this->changeZoom = true;
     102  this->inZoomMode = false;
     103  this->changingZoom = false;
    97104
    98105  this->xMouse = 0.0f;
     
    116123  registerEvent(KeyMapper::PEV_RIGHT);
    117124  registerEvent(KeyMapper::PEV_FIRE1);
     125  registerEvent(KeyMapper::PEV_FIRE2);
    118126  registerEvent(KeyMapper::PEV_JUMP);
     127  registerEvent(KeyMapper::PEV_CROUCH);
    119128  registerEvent(EV_MOUSE_MOTION);
    120129
     
    149158
    150159  this->getWeaponManager().getFixedTarget()->setParent(&this->cameraNode);
    151   this->getWeaponManager().getFixedTarget()->setRelCoor(1000,0,0);
     160  this->getWeaponManager().getFixedTarget()->setParentMode(PNODE_ALL);
     161  this->getWeaponManager().getFixedTarget()->setRelCoor(10,0,0);
    152162
    153163
     
    179189}
    180190
    181 
     191/**
     192 * was probabably designed for setting direction of FPSPlayer
     193 * but hey, this connot work like this, can it?
     194 */
    182195void FPSPlayer::setPlayDirection(const Quaternion& quat, float speed)
    183196{
     
    186199}
    187200
    188 
     201/**
     202 * Resets FPSPlayer stats and freezes its moving directions
     203 *
     204 */
    189205void FPSPlayer::reset()
    190206{
     
    195211  this->xMouse = 0.0f;
    196212  this->yMouse = 0.0f;
     213  this->inZoomMode = false;
    197214
    198215  this->setHealth(80);
    199216}
    200217
    201 
     218/**
     219 * Defines what happens to camera and other important elements when changing
     220 * into FPS-view
     221 */
    202222void FPSPlayer::enter()
    203223{
     
    206226  State::getCameraNode()->setParentSoft(&this->cameraNode);
    207227  State::getCameraTargetNode()->setParentSoft(&this->cameraNode);
    208 
    209   this->getWeaponManager().getFixedTarget()->setParent(State::getCameraTargetNode());
    210   this->getWeaponManager().getFixedTarget()->setRelCoor(0,0,0);
     228 
     229  State::getCamera()->setViewMode(Camera::ViewFPS);
     230 
     231  this->getWeaponManager().getFixedTarget()->setParent(&this->cameraNode);
     232  //this->getWeaponManager().getFixedTarget()->setParentMode(PNODE_ALL);
     233  //this->getWeaponManager().getFixedTarget()->setRelCoor(100,0,0);
    211234
    212235  if ( !State::isOnline() )
     
    216239}
    217240
     241/**
     242 * Defines what happens if active player leaves FPSPlayer
     243 * (basicly hides crosshair and frees camera)
     244 */
    218245void FPSPlayer::leave()
    219246{
     
    230257void FPSPlayer::tick (float time)
    231258{
    232 
     259     // Second init-step
    233260  if ( !this->initWeapon )
    234261  {
     
    239266    this->getWeaponManager().getParentNode()->setParentMode(PNODE_ROTATE_AND_MOVE);
    240267    this->getWeaponManager().getFixedTarget()->setParent(&this->cameraNode);
    241     this->getWeaponManager().getFixedTarget()->setParentMode(PNODE_ROTATE_AND_MOVE);
     268    //this->getWeaponManager().getFixedTarget()->setParentMode(PNODE_ROTATE_AND_MOVE);
     269    State::getCamera()->setViewMode(Camera::ViewFPS);
    242270
    243271
     
    251279    }
    252280
    253 
    254     AABB* box = this->getModelAABB();
    255     if( box != NULL)
    256     {
     281  }
     282  // end of second init-step
     283 
     284  // This box represents the dimension of the used model
     285  AABB* box = this->getModelAABB();
     286
     287  if( box != NULL)
     288  {
    257289      float f = 1.0;
     290      if( this->bCrouch )
     291          f = 0.3*f;
     292     
    258293      this->cameraNode.setRelCoor(0, box->halfLength[1] * f, 0);
    259 //       this->cameraNode.setRelCoor(10, box->halfLength[1] * f, 0);
    260 
    261       float v = 0.1f;
    262       this->getWeaponManager().setSlotPosition(0, Vector(-8.0, box->halfLength[1] * v, 1.1));
    263       this->getWeaponManager().setSlotPosition(1, Vector(5.0, box->halfLength[1] * v, 0.0));
    264     }
    265   }
    266 
     294//      this->cameraNode.setRelCoor(10, box->halfLength[1] * f, 0);
     295     float v = 0.1f;
     296     this->getWeaponManager().setSlotPosition(0, Vector(-8.0, box->halfLength[1] * v, 1.1));
     297     this->getWeaponManager().setSlotPosition(1, Vector(5.0, box->halfLength[1] * v, 0.0));
     298  }
     299 
     300  /*
     301  if( this->bFire2 )
     302  {
     303     
     304      // to change Zoom on click
     305      if( this->changeZoom )
     306      {
     307          this->changeZoom = false;
     308          if( this->inZoomMode )
     309          {
     310              State::getCamera()->setViewMode(Camera::ViewFPS);
     311              this->inZoomMode = false;
     312          }
     313          else
     314          {
     315              State::getCamera()->setViewMode(Camera::ViewFPSZoom);
     316              this->inZoomMode = true;
     317          }
     318         
     319      }
     320     
     321  }
     322  else
     323  {
     324      this->changeZoom = true;
     325  }*/
     326  if( this->bFire2 )
     327  {
     328      if( this->changeZoom )
     329      {
     330          if( !this->inZoomMode || this->changingZoom )
     331          {
     332              this->inZoomMode = true;
     333              this->changingZoom = true;
     334              float fovy = State::getCamera()->getFovy();
     335              if( fovy > 30 )
     336                  State::getCamera()->setFovy( fovy - 10*time );
     337          }
     338          else
     339          {
     340                State::getCamera()->setViewMode(Camera::ViewFPS);
     341                this->inZoomMode = false;
     342                this->changeZoom = false;
     343          }
     344      }
     345  }
     346  else
     347  {
     348      this->changeZoom = true;
     349      this->changingZoom = false;
     350  }
    267351
    268352  this->getWeaponManager().tick(time);
     
    301385    xMouse *= time ;
    302386    yMouse *= time ;
    303 
    304     heading -= xMouse/5.;
    305     attitude-= yMouse/5.;
     387   
     388    float amount;
     389   
     390    if( this->inZoomMode )
     391        amount = 2.;
     392    else
     393        amount = 5.;
     394
     395    heading -= xMouse/amount;
     396    attitude-= yMouse/amount;
    306397
    307398
     
    346437    }*/
    347438
    348   velocity *= 100;
     439  int speed;
     440  if( this->bCrouch )
     441      speed = 50;
     442  else
     443      speed = 100;
     444  velocity *= speed;
    349445
    350446  if( this->getModel( 0) != NULL && this->getModel(0)->isA(InteractiveModel::staticClassID()))
    351447  {
    352     if( this->bJump)
    353     {
    354       if( this->jumpAcceleration < 1.0f)
     448      if( this->bJump)
    355449      {
    356         this->jumpAcceleration = 300.0f;
    357 
    358         if( ((InteractiveModel*)this->getModel(0))->getAnimation() != JUMP)
    359           ((InteractiveModel*)this->getModel(0))->setAnimation(JUMP);
    360       }
    361     }
    362     else if(velocity.len() != 0.0f)
    363     {
    364       if( ((InteractiveModel*)this->getModel(0))->getAnimation() != RUN)
    365         ((InteractiveModel*)this->getModel(0))->setAnimation(RUN);
    366     }
    367     else
    368     {
    369       if( ((InteractiveModel*)this->getModel(0))->getAnimation() != STAND)
    370         ((InteractiveModel*)this->getModel(0))->setAnimation(STAND);
    371     }
     450          if( this->jumpAcceleration < 1.0f)
     451          {
     452              this->jumpAcceleration = 300.0f;
     453
     454              if( ((InteractiveModel*)this->getModel(0))->getAnimation() != JUMP)
     455                  ((InteractiveModel*)this->getModel(0))->setAnimation(JUMP);
     456          }
     457       }
     458       else if(velocity.len() != 0.0f)
     459       {
     460            if( this->bCrouch )
     461            {
     462                if( ((InteractiveModel*)this->getModel(0))->getAnimation() != CROUCH_WALK)
     463                    ((InteractiveModel*)this->getModel(0))->setAnimation(CROUCH_WALK);
     464            }
     465            else
     466            {
     467                if( ((InteractiveModel*)this->getModel(0))->getAnimation() != RUN)
     468                    ((InteractiveModel*)this->getModel(0))->setAnimation(RUN);
     469            }
     470                 
     471       }
     472       else
     473       {
     474           if( this->bCrouch )
     475           {
     476               if( ((InteractiveModel*)this->getModel(0))->getAnimation() != CROUCH_STAND)
     477                   ((InteractiveModel*)this->getModel(0))->setAnimation(CROUCH_STAND);
     478           }
     479           else
     480           {
     481               if( ((InteractiveModel*)this->getModel(0))->getAnimation() != STAND)
     482                   ((InteractiveModel*)this->getModel(0))->setAnimation(STAND);
     483           }
     484       }
     485       
     486       if( this->bFire )
     487       {
     488           if( this->bCrouch )
     489           {
     490               if( ((InteractiveModel*)this->getModel(0))->getAnimation() != CROUCH_ATTACK)
     491                   ((InteractiveModel*)this->getModel(0))->setAnimation(CROUCH_ATTACK);
     492           }
     493           else
     494           {
     495               if( ((InteractiveModel*)this->getModel(0))->getAnimation() != ATTACK)
     496                   ((InteractiveModel*)this->getModel(0))->setAnimation(ATTACK);
     497           }
     498       }
    372499  }
    373500
     
    390517    this->fallVelocity = 0.0f;
    391518  }
    392   if((velocity *time).len() < 10.0f) this->shiftCoor( velocity*time );
    393   else{ 
     519  if((velocity * time).len() < 10.0f) this->shiftCoor( velocity*time );
     520  else
     521  {     
    394522         velocity.normalize();
    395523         velocity *= 10.0f;
    396524         this->shiftCoor( velocity );
    397        }
    398 
    399 
     525  }
    400526
    401527
     
    409535  if( this->aimingSystem != NULL)
    410536    this->aimingSystem->flushList();
     537   
    411538}
    412539
     
    426553
    427554/**
    428  * process
     555 * checks events
    429556 */
    430557void FPSPlayer::process(const Event &event)
     
    440567  else if( event.type == KeyMapper::PEV_BACKWARD)
    441568    this->bBackward = event.bPressed; //this->shiftCoor(0,-.1,0);
     569  else if( event.type == KeyMapper::PEV_JUMP)
     570    this->bJump = event.bPressed;
     571  else if( event.type == KeyMapper::PEV_FIRE1)
     572    this->bFire = event.bPressed;
     573  else if( event.type == KeyMapper::PEV_FIRE2)
     574    this->bFire2 = event.bPressed;
     575  else if( event.type == KeyMapper::PEV_CROUCH)
     576    this->bCrouch = event.bPressed;
    442577  else if( event.type == EV_MOUSE_MOTION)
    443578  {
     
    445580    this->yMouse += event.yRel;
    446581  }
    447   else if( event.type == KeyMapper::PEV_JUMP)
    448   {
    449     this->bJump = event.bPressed;
    450   }
    451   else if( event.type == KeyMapper::PEV_FIRE1)
    452   {
    453     this->bFire = event.bPressed;
    454   }
    455 }
    456 
    457 
     582}
     583
     584/**
     585 * respawns FPSplayer
     586 */
    458587void FPSPlayer::respawn( )
    459588{
     
    466595}
    467596
    468 
     597/**
     598 * Kills the FPSplayer defining its killer
     599 */
    469600void FPSPlayer::destroy( WorldEntity* killer )
    470601{
     
    474605}
    475606
     607void FPSPlayer::displayHUDText( const std::string& message )
     608{
     609        State::getPlayer()->hud().notifyUser(message);
     610}
  • trunk/src/world_entities/creatures/fps_player.h

    r10566 r10698  
    3636    virtual void tick(float time);
    3737    virtual void draw() const;
     38   
     39    void displayHUDText( const std::string& message );
    3840
    3941
     
    4345    void init();
    4446
    45     bool                  bLeft;
    46     bool                  bRight;
    47     bool                  bForward;
    48     bool                  bBackward;
    49     bool                  bJump;              //!< jumping
    50     bool                  bPosBut;             //!< position button
    51     bool                  bFire;              //!< fire button
     47    bool                  bLeft;             //!< strafe left
     48    bool                  bRight;            //!< strafe right
     49    bool                  bForward;          //!< walk forward
     50    bool                  bBackward;         //!< walk backward
     51    bool                  bJump;             //!< jumping
     52    bool                  bPosBut;           //!< position button
     53    bool                  bFire;             //!< fire button
     54    bool                  bFire2;            //!< alternate fire button
     55    bool                  bCrouch;           //!< crouch button
    5256
    53     float                 xMouse;             //!< mouse moved in x-Direction
    54     float                 yMouse;             //!< mouse moved in y-Direction
     57    float                 xMouse;            //!< mouse moved in x-Direction
     58    float                 yMouse;            //!< mouse moved in y-Direction
    5559
    5660
    57     float                 heading;
    58     float                 attitude;
     61    float                 heading;           //!< the direction where the player heads to
     62    float                 attitude;          //!< defines the camera angle to the x-z-plane
    5963
    60     PNode                 cameraNode;
     64    PNode                 cameraNode;        //!< the "eyes" of the player (or call it head if you want)
    6165
    62     float                 fallVelocity;        //!< velocity for falling down
    63     float                 jumpAcceleration;    //!< the jump acceleration
     66    float                 fallVelocity;      //!< velocity for falling down
     67    float                 jumpAcceleration;  //!< the jump acceleration
    6468
    6569    bool                  initWeapon;
     70    bool                  changeZoom;        //!< zoom sight of player
     71    bool                  inZoomMode;        //!< zoomsight
     72    bool                  changingZoom;
    6673
    67     AimingSystem*         aimingSystem;        //!< aiming system of the player
     74    AimingSystem*         aimingSystem;      //!< aiming system of the player
    6875
    69     float                 damageTicker;        //!< ticker for dealing damage
     76    float                 damageTicker;      //!< ticker for dealing damage
     77   
    7078};
    7179
  • trunk/src/world_entities/effects/billboard.cc

    r10618 r10698  
    1111### File Specific:
    1212   main-programmer: David Hasenfratz
     13   co-programmer: Nicolas Schlumberger
    1314*/
    1415
     
    6970
    7071  this->texColor = NULL;
     72
     73  this->pulseMagnitude = .5;
     74  this->bPulse = false;
     75
     76  this->angularSpeed = M_2_PI; //360;
     77  this->angle = 0;
     78
     79  this->setUpdateFunction((*sinf));
    7180}
    7281
     
    113122void Billboard::tick(float dt)
    114123{
     124  this->angle += dt * this->angularSpeed;
     125  if (this->angle > M_2_PI)
     126    this->angle -= M_2_PI;
     127//   curMagnitude = updatePulse(this->angle);
    115128}
    116129
     
    145158  v.normalize();
    146159
    147   v *= sizeX;
    148   h *= sizeY;
     160  float tmp = 1;
     161  if (this->bPulse)
     162    tmp += this->pulseMagnitude * sinf(this->angle); //updatePulse(this->angle);
     163
     164  v *= sizeX * tmp;
     165  h *= sizeY * tmp;
    149166
    150167//v += this->getAbsCoor();
  • trunk/src/world_entities/effects/billboard.h

    r10433 r10698  
    2626    void colorTexture(const Color col);
    2727
     28    //!< Pulsing Capability, changes size of the grid
     29    inline void togglePluse () {this->bPulse = !bPulse; };
     30    inline void setPulse () { this->bPulse = true; };
     31    inline void setPulse ( bool state ) {this->bPulse = state; };
     32    inline float getPulse () { return this->bPulse; };
     33
     34    inline void setPulseMagnitude(float mag) {this->pulseMagnitude = mag; };
     35
    2836    virtual void tick(float dt);
    2937    virtual void draw() const;
    3038
     39    inline void setUpdateFunction(float (*updateFct)(float value)) { if( updateFct)  this->updatePulse = updateFct;};
     40
    3141  private:
     42
     43    float (*updatePulse)(float value);
     44
    3245    Material*        material;
    3346    Color*           texColor;
    3447    float sizeX;
    3548    float sizeY;
     49
     50    bool bPulse;
     51    float pulseMagnitude;
     52    float curMagnitude;
     53    float angle;
     54    float angularSpeed;
    3655};
    3756
  • trunk/src/world_entities/effects/blink.cc

    r10618 r10698  
    6767  this->bBoard->setTexture("textures/light/blink.png");
    6868
    69   /// Standard values
     69  //!< Standard values
    7070  this->bBoard->setAbsCoor(0, 0, 0);
    7171  // default position if not set in xml
  • trunk/src/world_entities/effects/explosion.h

    r10695 r10698  
    3232    virtual void tick (float time);
    3333
    34   private:
     34    void setLifeTime( float lifeTime ){ this->lifeTime = lifeTime; }
     35
     36  protected:
    3537    static FastFactory*        fastFactory;
    3638
  • trunk/src/world_entities/effects/wobblegrid.cc

    r10618 r10698  
    1010
    1111### File Specific:
    12    main-programmer: David Hasenfratz
     12   main-programmer: Marc Schärer
    1313*/
    1414
  • trunk/src/world_entities/npcs/adm_turret.cc

    r10694 r10698  
    140140        this->isCeil = false;
    141141        this->playerVisible = false;
     142        this->weapon = NULL;
    142143
    143144       
     
    147148{
    148149  WorldEntity::tick(dt);
    149   this->weapon->fire(false);
     150  if (this->weapon) this->weapon->fire(false);
    150151  this->updatePlayerVisible();
    151152
     
    167168    float angle = dv1.dot(dv2);
    168169    if (angle > 0.999)
    169           {
    170      this->weapon->fire(true);
    171           }
     170    {
     171        if (this->weapon) this->weapon->fire(true);
     172    }
    172173  }
    173174  else
  • trunk/src/world_entities/npcs/npc.cc

    r10618 r10698  
    407407      {
    408408        int slot = ws->getWeaponSlot();
    409         int side = ws->getWeaponSide();
     409//         int side = ws->getWeaponSide(); //FIXME / REMOVE: is not used
    410410        this->getWeaponManager().setSlotPosition(slot, (*it).second->getCenter());
    411411        this->getWeaponManager().setSlotDirection(slot, ws->getRelDir());
  • trunk/src/world_entities/playable.h

    r10368 r10698  
    3232  typedef enum {
    3333    Vertical         =  1,       //!< Vertical (seen from left or right/move in x-z)
    34     Horizontal       =  2,       //!< Horizontal (seet from the top/move in x-y)
     34    Horizontal       =  2,       //!< Horizontal (seen from the top/move in x-y)
    3535    FromBehind       =  4,       //!< Seen from behind (move in z-y)
    3636    Full3D           =  8,       //!< Full featured 3D-mode. (move in all directions x-y-z)
  • trunk/src/world_entities/player.cc

    r10516 r10698  
    1919
    2020#include "event_handler.h"
     21#include "creatures/fps_player.h"
    2122
    2223#include "state.h"
     
    7475    PRINTF(4)("Enter new Playable\n");
    7576    this->playable = playable;
    76     this->_hud.setArmorWidget(this->playable->getHealthWidget());
    77     if (dynamic_cast<SpaceShip*>(this->playable) != 0)
     77   
     78    if( playable->isA(FPSPlayer::staticClassID()) )
     79    {
     80        this->_hud.setMode(Hud::FirstPerson);
     81        this->_hud.setHealthWidget(this->playable->getHealthWidget());
     82    }
     83    else
     84    {
     85        this->_hud.setMode(Hud::Full3D);
     86        this->_hud.setHealthWidget(this->playable->getHealthWidget());
     87    }
     88    /*if (dynamic_cast<SpaceShip*>(this->playable) != 0)
    7889      this->_hud.setWeaponManager(&this->playable->getWeaponManager(), &dynamic_cast<SpaceShip*>(this->playable)->getWeaponManagerSecondary());
    7990    else
    80       this->_hud.setWeaponManager(&this->playable->getWeaponManager());
     91      this->_hud.setWeaponManager(&this->playable->getWeaponManager());*/
    8192
    8293    this->playable->setPlayer(this);
  • trunk/src/world_entities/projectiles/acid_splash.cc

    r10511 r10698  
    116116  this->toList(OM_NULL);
    117117  //this->toList(OM_DEAD);
    118   this->removeNode();
    119  
     118//   this->removeNode();
     119
    120120  AcidSplash::fastFactory->kill(this);
    121121}
  • trunk/src/world_entities/projectiles/hbolt.cc

    r10618 r10698  
    4646  this->setMinEnergy(10);
    4747  this->setHealthMax(0);
    48   this->lifeSpan = 2.0;
     48  this->lifeSpan = 3.0;
    4949
    5050  this->angle = 0;
     
    116116
    117117  this->toList(OM_DEAD);
    118   this->removeNode();
     118//   this->removeNode();
    119119  HBolt::fastFactory->kill(this);
    120120
     
    177177  glPushAttrib(GL_ENABLE_BIT);
    178178  glDisable(GL_LIGHTING);
    179 //   glDisable(GL_FOG);
     179  glDisable(GL_FOG);
    180180
    181181  glMatrixMode(GL_MODELVIEW);
     
    184184//     float matrix[4][4];
    185185    glTranslatef (this->getAbsCoor ().x, this->getAbsCoor ().y, this->getAbsCoor ().z);
     186    this->halo->draw();
     187
    186188    Vector tmpRot = this->getAbsDir().getSpacialAxis();
    187189    glRotatef (this->getAbsDir().getSpacialAxisAngle(), tmpRot.x, tmpRot.y, tmpRot.z );
     
    189191//     glMultMatrixf((float*)matrix);
    190192    this->getModel()->draw();
    191     this->halo->draw();
    192193
    193194  glPopMatrix();
  • trunk/src/world_entities/projectiles/laser.cc

    r10114 r10698  
    100100
    101101  this->toList(OM_NULL);
    102   this->removeNode();
     102//   this->removeNode();
    103103  Laser::fastFactory->kill(this);
    104104}
  • trunk/src/world_entities/projectiles/lbolt.cc

    r10618 r10698  
    6262  this->halo = new Billboard();
    6363  this->halo->setSize(.35, .35);
    64   this->halo->setTexture("hbolt_halo.png");
     64  this->halo->setTexture("hbolt_halo.jpg");
    6565  this->halo->setVisibility(false);
    6666
     67  this->halo->setPulse();
    6768
    6869}
     
    120121
    121122  this->toList(OM_DEAD);
    122   this->removeNode();
     123//   this->removeNode();
    123124  LBolt::fastFactory->kill(this);
    124125}
     
    148149
    149150  angle += LBolt::rotationSpeed * dt;
     151  if(angle > 360)
     152    angle -= 360;
    150153
    151154  for( ObjectList<NPC>::const_iterator eIterator = NPC::objectList().begin(); eIterator !=NPC::objectList().end(); eIterator++)
     
    183186    float matrix[4][4];
    184187    glTranslatef (this->getAbsCoor ().x, this->getAbsCoor ().y, this->getAbsCoor ().z);
    185     Vector tmpRot = this->getAbsDir().getSpacialAxis();
     188    this->halo->draw();
     189
     190    Vector tmpRot;
     191    tmpRot = this->flightDirection.getNormalized();
     192    glRotatef(this->angle, tmpRot.x, tmpRot.y, tmpRot.z);
     193    tmpRot = this->getAbsDir().getSpacialAxis();
    186194    glRotatef (this->getAbsDir().getSpacialAxisAngle(), tmpRot.x, tmpRot.y, tmpRot.z );
    187     glRotatef(this->angle, 1.0, 0.0, 0.0);
     195
    188196    this->getAbsDir().matrix (matrix);
    189197    glMultMatrixf((float*)matrix);
    190198    this->getModel()->draw();
    191199
    192     this->halo->draw();
    193 
    194200  glPopMatrix();
    195201  glPopAttrib();
  • trunk/src/world_entities/projectiles/mbolt.cc

    r10618 r10698  
    145145  this->toList(OM_NULL);
    146146  //this->toList(OM_DEAD);
    147   this->removeNode();
     147//   this->removeNode();
    148148  MBolt::fastFactory->kill(this);
    149149}
     
    212212  float matrix[4][4];
    213213  glTranslatef (this->getAbsCoor ().x, this->getAbsCoor ().y, this->getAbsCoor ().z);
    214   glRotatef(this->angle, 1.0f, 0.0f, 0.0f); //spinning missile
     214//   glRotatef(this->angle, 1.0f, 0.0f, 0.0f); //spinning missile
     215  glRotatef(this->angle, this->flightDirection.x, this->flightDirection.y, this->flightDirection.z);
    215216  this->getAbsDir().matrix (matrix);
    216217  glMultMatrixf((float*)matrix);
  • trunk/src/world_entities/projectiles/rail_projectile.cc

    r10114 r10698  
    9999
    100100  this->toList(OM_NULL);
    101   this->removeNode();
     101//   this->removeNode();
    102102  RailProjectile::fastFactory->kill(this);
    103103}
  • trunk/src/world_entities/projectiles/spike.cc

    r10368 r10698  
    111111
    112112  this->toList(OM_NULL);
    113   this->removeNode();
     113//   this->removeNode();
    114114  Spike::fastFactory->kill(this);
    115115}
  • trunk/src/world_entities/projectiles/spike_ball.cc

    r10511 r10698  
    149149
    150150  this->toList(OM_NULL);
    151   this->removeNode();
     151//   this->removeNode();
    152152  SpikeBall::fastFactory->kill(this);
    153153}
  • trunk/src/world_entities/projectiles/swarm_projectile.cc

    r10618 r10698  
    134134
    135135  this->toList(OM_DEAD);
    136   this->removeNode();
     136//   this->removeNode();
    137137  SwarmProjectile::fastFactory->kill(this);
    138138}
     
    200200    this->deactivate();
    201201
    202 
    203 
    204202/** old  guiding function*/
    205 
    206   float projectileVelocity = this->getVelocity().len();
     203  static float projectileVelocity = this->getVelocity().len();
    207204  if (target != NULL){
    208205    Vector estTargetDir = (this->target->getAbsCoor() - this->getAbsCoor()).getNormalized();
     
    225222
    226223  this->angle += this->rotationSpeed * time;
    227 
    228   while (this->angle > 360)
    229   {
    230     this->angle -= 360;
    231   }
     224  while (this->angle > 360) { this->angle -= 360; }
    232225
    233226  this->lastDir = this->curDir;
     
    240233    PRINTF(0)("Target was hit by Swarm Missile!\n");
    241234  }
    242   else if( this->target == NULL)
     235  if( this->target == NULL)
    243236    this->deactivate();
    244237}
  • trunk/src/world_entities/space_ships/space_ship.cc

    r10618 r10698  
    2222#include "util/loading/resource_manager.h"
    2323
     24#include "world_entities/weapons/weapon_manager.h"
     25
    2426#include "weapons/test_gun.h"
    2527#include "weapons/light_blaster.h"
    2628#include "weapons/medium_blaster.h"
    2729#include "weapons/heavy_blaster.h"
     30#include "weapons/rf_cannon.h"
     31#include "weapons/nadion_laser.h"
     32#include "weapons/disruptor.h"
    2833#include "weapons/swarm_launcher.h"
    2934#include "weapons/spike_thrower.h"
     
    6166#include "tools/cameraman.h"
    6267
     68#include "tools/mount_point.h"
     69#include "weapons/weapon_slot.h"
    6370
    6471#include "util/loading/load_param.h"
     
    6673
    6774#include "track/track.h"
    68 
    69 
    70 // #include "lib/gui/gl_gui/glgui_bar.h"
    71 // #include "lib/gui/gl_gui/glgui_pushbutton.h"
    72 
     75#include "track/action_box.h"
    7376
    7477
     
    156159  //weapons:
    157160
    158   Weapon* wpRight1 = new LightBlaster ();
    159   wpRight1->setName( "LightBlaster");
    160   Weapon* wpLeft1 = new LightBlaster ();
    161   wpLeft1->setName( "LightBlaster");
    162 
    163   Weapon* wpRight2 = new MediumBlaster ();
    164   wpRight2->setName( "MediumBlaster");
    165   Weapon* wpLeft2 = new MediumBlaster ();
    166   wpLeft2->setName( "MediumBlaster");
    167 
    168   Weapon* wpRight3 = new HeavyBlaster (1);
    169   wpRight3->setName( "HeavyBlaster");
    170   Weapon* wpLeft3 = new HeavyBlaster (0);
    171   wpLeft3->setName( "HeavyBlaster");
    172 
    173   Weapon* cannon = new SwarmLauncher();
    174   cannon->setName( "SwarmLauncher");
    175 /*
    176   Weapon* spike = new SpikeThrower();
    177   spike->setName( "SpikeThrower" );
    178 
    179 
    180   Weapon* acid0 = new AcidLauncher();
    181   acid0->setName( "AcidSplasher" );
    182 
    183   Weapon* acid1 = new AcidLauncher();
    184   acid1->setName( "AcidSplasher" );*/
    185 
    186 
    187   this->weaponMan.addWeapon( wpLeft1, 0, 0);
    188   this->weaponMan.addWeapon( wpRight1, 0, 1);
    189 
    190   this->weaponMan.addWeapon( wpLeft2, 1, 2);
    191   this->weaponMan.addWeapon( wpRight2, 1, 3);
    192 
    193   this->weaponMan.addWeapon( wpLeft3, 2, 4);
    194   this->weaponMan.addWeapon( wpRight3, 2, 5);
    195 
    196   this->weaponMan.addWeapon( wpLeft1, 3, 0);
    197   this->weaponMan.addWeapon( wpRight1, 3, 1);
    198 
    199   this->weaponMan.addWeapon( wpLeft2, 3, 2);
    200   this->weaponMan.addWeapon( wpRight2, 3, 3);
    201 
    202   this->weaponMan.addWeapon( wpLeft3, 3, 4);
    203   this->weaponMan.addWeapon( wpRight3, 3, 5);
    204 
    205 
    206 //   this->weaponMan.addWeapon( acid0, 3, 0);
    207 //   this->weaponMan.addWeapon( acid1, 3, 1);
    208 
    209 
    210   this->secWeaponMan.addWeapon( cannon, 0, 2);
    211 //   this->secWeaponMan.addWeapon( spike, 1, 3);
    212 //   this->secWeaponMan.addWeapon( acid0, 2, 2);
    213 //   this->secWeaponMan.addWeapon( acid1, 2, 3);
    214 
    215 
    216   this->weaponMan.changeWeaponConfig(3);
     161  this->weaponMan.setParentEntity( this);
     162  this->secWeaponMan.setParentEntity( this);
     163
     164  this->weaponMan.setSlotCount(8);
     165  this->secWeaponMan.setSlotCount(6);
     166
     167  this->weaponMan.createWeaponSlot(0, 3.270, 1.028, .155, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL);
     168  this->weaponMan.createWeaponSlot(1, 3.270, 1.028, -.155, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL);
     169  this->weaponMan.createWeaponSlot(2, 4.385, .063, .876, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL);
     170  this->weaponMan.createWeaponSlot(3, 4.385, -.063, -.876, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL);
     171  this->weaponMan.createWeaponSlot(4, 1.635, -.612, 2.691, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL);
     172  this->weaponMan.createWeaponSlot(5, 1.536, -.612, -2.691, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL);
     173  this->weaponMan.createWeaponSlot(6, 1.536, -.612, 3.254, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL);
     174  this->weaponMan.createWeaponSlot(7, 1.536, -.612, -3.254, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL);
     175
     176
     177  this->weaponMan.addWeaponToSlot(0, 0, "RFCannon");
     178  this->weaponMan.addWeaponToSlot(0, 1, "RFCannon");
     179  this->weaponMan.addWeaponToSlot(0, 2, "RFCannon");
     180  this->weaponMan.addWeaponToSlot(0, 3, "RFCannon");
     181  this->weaponMan.addWeaponToSlot(1, 0, "RFCannon");
     182  this->weaponMan.addWeaponToSlot(1, 1, "RFCannon");
     183  this->weaponMan.addWeaponToSlot(1, 2, "RFCannon");
     184  this->weaponMan.addWeaponToSlot(1, 3, "RFCannon");
     185
     186  this->weaponMan.addWeaponToSlot(0, 4, "NadionLaser");
     187  this->weaponMan.addWeaponToSlot(0, 5, "NadionLaser");
     188  this->weaponMan.addWeaponToSlot(2, 4, "NadionLaser");
     189  this->weaponMan.addWeaponToSlot(2, 5, "NadionLaser");
     190
     191  this->weaponMan.addWeaponToSlot(0, 6, "Disruptor");
     192  this->weaponMan.addWeaponToSlot(0, 7, "Disruptor");
     193  this->weaponMan.addWeaponToSlot(3, 6, "Disruptor");
     194  this->weaponMan.addWeaponToSlot(3, 7, "Disruptor");
     195
     196
     197  this->secWeaponMan.createWeaponSlot(0, 1.5, 3, 0, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL);
     198  this->secWeaponMan.createWeaponSlot(1, 2.6, 0, 3.0, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL);
     199  this->secWeaponMan.createWeaponSlot(2, 1.5, 0, -.5, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL);
     200  this->secWeaponMan.createWeaponSlot(3, 1.5, 0, .5, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL);
     201  this->secWeaponMan.createWeaponSlot(4, 1.5, 0, .5, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL);
     202  this->secWeaponMan.createWeaponSlot(5, 1.5, 0, -.5, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL);
     203
     204  this->secWeaponMan.addWeaponToSlot(0, 2, "SwarmLauncher");
     205
     206
     207  this->weaponMan.changeWeaponConfig(0);
    217208  this->secWeaponMan.changeWeaponConfig(0);
    218209
    219210
    220 //   curWeaponPrimary    = 3;
    221 //   curWeaponSecondary  = 0;
    222 
    223211  Playable::weaponConfigChanged();
    224212
    225   reactorOutput     = 10;
    226 
    227   weaponEnergyRegen = 10;       // 10 einheiten pro Sekunde
    228   engineSpeedBase   = 15;
    229   shieldRegen       = 2;
    230 
    231   shieldEnergyShare = 0.3;
    232   weaponEnergyShare = 0.3;
    233   engineEnergyShare = 0.4;
    234 
    235   shieldCur         = 100;
    236   shieldMax         = 100;
    237   shieldTH          = .2 * shieldMax;   // shield power must be 20% before shield kicks in again
    238 
    239   this->setHealth( 100);
    240   this->setHealthMax( 100);
    241 
    242   electronicCur = 50;
    243   electronicMax = 50;
    244   electronicRegen   = 3;
    245   electronicTH      = .7 * electronicMax; // 30% of eDamage can be handled by the ship
    246 
    247 
    248  this->loadModel("models/spaceships/human_spaceship_fighter.obj", .25);
     213  this->bInit = false;
     214
     215  loadEnergyShare(.3,.3,.4);
     216  loadShield(80, 100, .2, 2);
     217  loadHealth(100, 100);
     218  loadElectronic(40, 50, .7, 3.0);
     219  loadReactor(10);
     220  loadWeapon(10);
     221  loadEngine(15);
     222
     223//   this->loadModel("models/spaceships/fighter_redesign9.obj");
    249224  //this->setVisibiliy(false);
    250225
    251226  bForward = bBackward = bLeft = bRight = bAscend = bDescend = bRollL = bRollR = bFire = bSecFire = false;
    252227
    253   this->setHealthMax(shieldMax);
    254   this->setHealth(shieldCur);
     228//   this->setHealthMax(shieldMax);
     229//   this->setHealth(shieldCur);
    255230
    256231  this->travelNode = new PNode();
     
    260235  this->cameraNode.addNodeFlags(PNODE_PROHIBIT_CHILD_DELETE);
    261236
    262   // widget handling
    263   /*
    264   this->electronicWidget = new OrxGui::GLGuiEnergyWidgetVertical();
    265   this->electronicWidget->setDisplayedName(std::string(this->getClassName()) + " Electronics:");
    266   this->electronicWidget->setSize2D(30,400);
    267   this->electronicWidget->setAbsCoor2D(150,200);
    268   this->electronicWidget->shiftDir2D(270);
    269   this->updateElectronicWidget();
    270   this->shieldWidget = new OrxGui::GLGuiEnergyWidgetVertical();
    271   this->shieldWidget->setDisplayedName(std::string(this->getClassName()) + " Shield:");
    272   this->shieldWidget->setSize2D(30,400);
    273   this->shieldWidget->setAbsCoor2D(200,200);
    274   this->shieldWidget->shiftDir2D(270);
    275   this->updateShieldWidget();
    276   if (this->hasPlayer())
    277   {
    278     State::getPlayer()->hud().setShiledWidget(this->shieldWidget);
    279     State::getPlayer()->hud().setEnergyWidget(this->electronicWidget);
    280   }
    281   */
    282   this->electronicWidget = NULL;
    283   this->shieldWidget = NULL;
     237
     238//   this->electronicWidget = NULL;
     239//   this->shieldWidget = NULL;
    284240
    285241  //add events to the eventlist
     
    298254  registerEvent(EV_MOUSE_MOTION);
    299255
    300   this->weaponMan.setParentEntity( this);
    301   this->secWeaponMan.setParentEntity( this);
    302 
    303   this->weaponMan.setSlotCount(8);
    304 
    305   this->weaponMan.setSlotPosition(0, Vector(0.0, 0, -3.0));
    306   this->weaponMan.setSlotCapability(0, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL);
    307 
    308   this->weaponMan.setSlotPosition(1, Vector(0.0, 0, 3.0));
    309   this->weaponMan.setSlotCapability(1, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL);
    310 
    311   this->weaponMan.setSlotPosition(2, Vector(1.0, 0, -1.5));
    312   this->weaponMan.setSlotDirection(2, Quaternion(-M_PI_4*.5, Vector(1,0,0)));
    313 
    314   this->weaponMan.setSlotPosition(3, Vector(1.0, 0, 1.5));
    315   this->weaponMan.setSlotDirection(3, Quaternion(M_PI_4*.5, Vector(1,0,0)));
    316 
    317   this->weaponMan.setSlotPosition(4, Vector(1.5, 0, .5));
    318   this->weaponMan.setSlotDirection(4, Quaternion(-M_PI_4*.5+M_PI, Vector(1,0,0)));
    319 
    320   this->weaponMan.setSlotPosition(5, Vector(1.5, 0, -.5));
    321   this->weaponMan.setSlotDirection(5, Quaternion(+M_PI_4*.5-M_PI, Vector(1,0,0)));
    322 
    323   this->weaponMan.setSlotPosition(6, Vector(0.5, 0, 2.5));
    324   this->weaponMan.setSlotDirection(6, Quaternion(-M_PI_4*.5+M_PI, Vector(1,0,0)));
    325 
    326   this->weaponMan.setSlotPosition(7, Vector(0.5, 0, -2.5));
    327   this->weaponMan.setSlotDirection(7, Quaternion(+M_PI_4*.5-M_PI, Vector(1,0,0)));
    328 
    329   this->secWeaponMan.setSlotPosition(0, Vector(1.5, 0, 0));
    330   this->secWeaponMan.setSlotCapability(0, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL);
    331 
    332   this->secWeaponMan.setSlotPosition(1, Vector(2.6, 0, 3.0));
    333   this->secWeaponMan.setSlotCapability(1, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL);
    334 
    335   this->secWeaponMan.setSlotPosition(2, Vector(1.5, 0, -.5));
    336   this->secWeaponMan.setSlotDirection(2, Quaternion(-M_PI_4*.5, Vector(1,0,0)));
    337 
    338   this->secWeaponMan.setSlotPosition(3, Vector(1.5, 0, .5));
    339   this->secWeaponMan.setSlotDirection(3, Quaternion(M_PI_4*.5, Vector(1,0,0)));
    340 
    341   this->secWeaponMan.setSlotPosition(4, Vector(1.5, 0, .5));
    342   this->secWeaponMan.setSlotDirection(4, Quaternion(-M_PI_4*.5+M_PI, Vector(1,0,0)));
    343 
    344   this->secWeaponMan.setSlotPosition(5, Vector(1.5, 0, -.5));
    345   this->secWeaponMan.setSlotDirection(5, Quaternion(+M_PI_4*.5-M_PI, Vector(1,0,0)));
    346 
    347256
    348257  this->weaponMan.getFixedTarget()->setParent(this);
     
    384293  this->setSupportedPlaymodes(Playable::Horizontal | Playable::Vertical);
    385294
    386   /// FIXME
    387 //   this->trail = new Trail( 5, 10, .2, this);
    388 //   this->trail->setTexture( "textures/engine.png");
    389 //
    390 //   this->trailL = new Trail( 5, 10, .2, this);
    391 //   this->trailL->setTexture( "textures/engine.png");
    392 //
    393 //   this->trailR = new Trail( 5, 10, .2, this);
    394 //   this->trailR->setTexture( "textures/engine.png");
    395 
    396295
    397296  this->toList(OM_GROUP_00);
    398297
    399   //FIXME Just testaddition to show the wobblegrid
    400 /*
    401   this->test  = new Wobblegrid(5);
    402   test->setTexture("textures/blub.png");
    403 
    404   test->setAbsCoor( this->getAbsCoor() + Vector(0, 2, 0));
    405   test->setParent( this);
    406 */
    407 
     298
     299  dynamic_cast<WorldEntity*>(this)->createHealthWidget();
     300  dynamic_cast<WorldEntity*>(this)->createShieldWidget();
     301  dynamic_cast<WorldEntity*>(this)->createElectronicWidget();
     302
     303  if ( this->hasPlayer() ){
     304    State::getPlayer()->hud().setShieldWidget(this->getShieldWidget());
     305    State::getPlayer()->hud().setEnergyWidget(this->getElectronicWidget());
     306  }
    408307}
    409308
     
    415314void SpaceShip::loadParams(const TiXmlElement* root)
    416315{
     316  if(!root)
     317    return;
     318
    417319  Playable::loadParams(root);
    418320
     
    422324  LoadParam(root, "actionWidthPercentage", this, SpaceShip, setActionWidthPercentage);
    423325
    424   State::getCamera()->setViewMode(Camera::ViewTop);
     326  State::getCamera()->setViewMode(Camera::ViewNormal);
     327  State::getCameraTargetNode()->setParent(this);
     328  State::getCamera()->setParent(this);
     329
     330  LoadParam(root, "loadReactor", this, SpaceShip, loadReactor)
     331  .describe("set reactor output");
     332  LoadParam(root, "loadShield", this, WorldEntity, loadShield)
     333  .describe("set shield parameters: current strenght , max strenght, threshhold value (0..1), regeneration rate");
     334  LoadParam(root, "loadHealth", this, WorldEntity, loadHealth)
     335  .describe("set armor/health parameters: current strenght , max strenght");
     336  LoadParam(root, "loadElectronic", this, WorldEntity, loadElectronic)
     337  .describe("set electronics parameters: current strenght , max strenght, threshhold value (0..1), regeneration rate");
     338  LoadParam(root, "loadEngine", this, SpaceShip, loadEngine)
     339  .describe("set base speed");
     340  LoadParam(root, "loadEnergyShare", this, SpaceShip, loadEnergyShare)
     341  .describe("set energy partitioning: shield, weapons, engine (sum should be 1)");
     342  LoadParam(root, "loadWeapon", this, SpaceShip, loadWeapon)
     343  .describe("set weapon regeneration");
     344
     345/*
     346  LOAD_PARAM_START_CYCLE(root, element);
     347  {
     348    LoadParamXML_CYCLE(element, "weaponMan", this->weaponMan, WeaponManager, loadWeapons)
     349    .describe("loads Weapons");
     350  }
     351  LOAD_PARAM_END_CYCLE(element);
     352
     353  LOAD_PARAM_START_CYCLE(root, element);
     354  {
     355    LoadParamXML_CYCLE(element, "secWeaponMan", this->secWeaponMan, WeaponManager, loadWeapons)
     356    .describe("loads Weapons");
     357  }
     358  LOAD_PARAM_END_CYCLE(element);*/
    425359}
    426360
     
    435369  bForward = bBackward = bLeft = bRight = bAscend = bDescend = bRollL = bRollR = bFire = bSecFire = false;
    436370
    437   //xMouse = yMouse = 0;
    438 
    439   this->setHealth(80);
     371  this->resetHealth();
     372  this->resetShield();
     373  this->resetElectronic();
    440374  this->velocity = Vector(0.0, 0.0, 0.0);
    441375}
     
    448382  State::getPlayer()->hud().setRadarCenterNode(this->travelNode);
    449383  State::getPlayer()->hud().setOverlayActive(true);
    450   //dynamic_cast <OrxGui::GLGuiEnergyWidgetVertical*> (State::getPlayer()->hud().getArmorWidget())->setDisplayedName("Armor");
    451   //dynamic_cast<Element2D*>(this->secWeaponMan.getFixedTarget())->setVisibility( true);
    452   //this->attachCamera();
    453  // this->setPlaymode(Playable::Horizontal);
    454384}
    455385
     
    461391  State::getCamera()->setEventHandling(true);
    462392  State::getPlayer()->hud().setRadarCenterNode(NULL);
    463   //dynamic_cast<Element2D*>(this->secWeaponMan.getFixedTarget())->setVisibility( false);
    464   //this->detachCamera();
    465393}
    466394
     
    473401  if(this->hasPlayer())
    474402    Playable::postSpawn();
    475 
    476   //setCollision(new CollisionCluster(1.0, Vector(0,0,0)));
    477403}
    478404
     
    525451void SpaceShip::tick (float time)
    526452{
     453
     454//   if( !this->bInit)
     455//   {
     456//     // now get slots from the mount points
     457//     std::map<int, MountPoint*>::iterator it = this->mountPointMap.begin();
     458//     for( ;it != this->mountPointMap.end(); it++)
     459//     {
     460//       WeaponSlot* ws = dynamic_cast<WeaponSlot*>((*it).second->getMount());
     461//       if( ws != NULL && ws->isA(WeaponSlot::staticClassID()))
     462//       {
     463//         int slot = ws->getWeaponSlot();
     464// //         int side = ws->getWeaponSide(); //FIXME / REMOVE: is not used// HACK needed for some weapons (left/right)
     465//         this->getWeaponManager().setSlotPosition(slot, (*it).second->getCenter());
     466//         this->getWeaponManager().setSlotDirection(slot, ws->getRelDir());
     467// //         PRINTF(0)("setting slot %i\n", slot);
     468// //         (*it).second->getCenter().debug();
     469//       }
     470//     }
     471//   this->bInit = true;
     472//   }
     473
    527474  // Playable::tick(time);
    528475
     
    636583  if (!(State::getCamera()->getEventHandling()))
    637584  {
     585    //PRINTF(0)("\n\n\n\n\n\n\n\nSETCAMERA %x\n\n\n\n\n\n\n", State::getCamera());
    638586    if( event.type == KeyMapper::PEV_VIEW0)
    639587    {
     
    750698  PRINTF(5)("ship hit for (%f,%f) \n",pDamage,eDamage);
    751699
    752   if( this->shieldActive) {
    753     if( this->shieldCur > pDamage) {
    754       this->shieldCur = this->shieldCur - pDamage;
    755     }
    756     else { // shield <= pDamage
    757       this->shieldCur -=pDamage;
    758       this->shieldActive = false; //shield collapses
    759       pDamage += this->shieldCur;
    760       if( !this->shieldActive) {
    761         this->armorCur -= pDamage / 2; // remaining damages hits armor at half rate
    762         this->electronicCur -= eDamage;
    763       }
    764     }
    765   }
    766   else {
    767     this->armorCur = this->armorCur - pDamage;
    768     this->electronicCur = this->electronicCur - eDamage;
    769   }
    770   if( this->armorCur <= 0) { /* FIXME implement shipcrash*/ }
     700  static float tmp = this->decreaseShield(pDamage);
     701  if( tmp > 0)
     702  if ( this->decreaseHealth(tmp / 2) > 0)
    771703    this->destroy(this);
    772704
    773   updateElectronicWidget();
    774   updateShieldWidget();
    775 
    776   this->setHealth( this->armorCur);
    777 }
    778 
    779 
    780 void SpaceShip::regen(float time){
    781   float tmp;
    782   if (this->armorCur != this->armorMax || this->armorRegen != 0){
    783     tmp = this->armorCur + this->armorRegen * time;
    784     if ( tmp > electronicMax)
    785       this->armorCur = this->armorMax;
    786     else
    787       this->armorCur = tmp;
    788   }
    789   if (this->shieldCur != this->shieldMax || this->shieldRegen != 0){
    790     tmp =  this->shieldCur + (this->shieldRegen + this->reactorOutput * this->shieldEnergyShare) * time;
    791     if( tmp > shieldMax)
    792       this->shieldCur = this->shieldMax;
    793     else
    794       this->shieldCur = tmp;
    795     this->shieldActive = ( this->shieldActive || this->shieldCur > shieldTH);
    796 
    797     updateShieldWidget();
    798   }
    799 
    800   this->setHealth( this->shieldCur);      // FIXME currently just to test share system
    801 
    802   if (this->electronicCur != this->electronicMax || this->electronicRegen != 0){
    803     tmp = this->electronicCur + this->electronicRegen * time;
    804     if ( tmp > electronicMax)
    805       this->electronicCur = this->electronicMax;
    806     else
    807       this->electronicCur = tmp;
    808 
    809     updateElectronicWidget();
    810   }
    811 
    812 }
     705}
     706
    813707
    814708
     
    819713void SpaceShip::weaponRegen(float time)
    820714{
    821   float energy  = ( this->reactorOutput * this->weaponEnergyShare + this->weaponEnergyRegen) * time;
     715  float energy = ( this->reactorOutput * this->weaponEnergyShare + this->weaponEnergyRegen) * time ;
    822716  Weapon* weapon;
    823   for( unsigned int i=0; i < this->weaponMan.getSlotCount(); i++)
    824   {
     717  int weaponCount = 0;
     718  for( unsigned int i=0; i < this->weaponMan.getSlotCount(); i++) {
    825719    weapon = this->weaponMan.getWeapon(i);
    826     if( weapon != NULL && weapon->isActive())
    827     {
     720    if( weapon != NULL && weapon->isActive()) {
     721      weaponCount++;
     722    }
     723  }
     724
     725  if (weaponCount == 0)
     726    return;
     727  energy *= ( this->weaponMan.getSlotCount() / (float)weaponCount );
     728
     729  for( unsigned int i=0; i < this->weaponMan.getSlotCount(); i++) {
     730    weapon = this->weaponMan.getWeapon(i);
     731    if( weapon != NULL && weapon->isActive()) {
    828732      weapon->increaseEnergy( energy);
    829733    }
    830 
    831734  }
    832735  // weaponMan.increaseAmmunition( weapon, energy);
     
    834737
    835738
    836 void SpaceShip::enterPlaymode(Playable::Playmode playmode)
    837 {
     739void SpaceShip::enterPlaymode(Playable::Playmode playmode){
    838740  switch(playmode)
    839741  {
     
    895797      }
    896798      break;
     799
     800
     801    case Playable::Vertical:
     802    {
     803        this->travelNode->setAbsCoor(this->getAbsCoor());
     804        this->travelNode->updateNode(0.01f);
     805
     806        this->isTravelDistanceInit = false;
     807
     808        if(this->entityTrack)
     809           this->travelNode->setParent(this->entityTrack->getTrackNode());
     810
     811        this->setParent(this->travelNode);
     812        this->setRelCoor(0,0,0);
     813
     814        State::getCameraNode()->setParentSoft(this->travelNode);
     815        //State::getCameraNode()->setParentSoft(this);
     816        //State::getCameraNode()->setRelCoorSoft(-0.01, 40, 0);
     817        State::getCameraTargetNode()->setParentSoft(this->travelNode);
     818        //State::getCameraTargetNode()->setParentSoft(this);
     819        //State::getCameraTargetNode()->setRelCoorSoft(0,0,0);
     820        //this->setCameraMode(Camera::ViewNormal);
     821        State::getCamera()->setEventHandling(false);
     822
     823        PRINTF(0)("\n\n\n\n\n\n\n\nSETCAMERA %x\n\n\n\n\n\n\n", State::getCamera());
     824        State::getCamera()->setViewMode(Camera::ViewNormal);
     825        State::getCameraTargetNode()->setParent(this);
     826        State::getCamera()->setParent(this);
     827
     828
     829        registerEvent(KeyMapper::PEV_VIEW0);
     830        registerEvent(KeyMapper::PEV_VIEW1);
     831        registerEvent(KeyMapper::PEV_VIEW2);
     832        registerEvent(KeyMapper::PEV_VIEW3);
     833        registerEvent(KeyMapper::PEV_VIEW4);
     834        registerEvent(KeyMapper::PEV_VIEW5);
     835
     836        State::getCamera()->setParentMode(PNODE_ALL);
     837
     838      break;
     839    }
    897840
    898841    default:
     
    10581001    }
    10591002    case Playable::Vertical:
     1003    {
     1004      if ( !entityTrack || !entityTrack->getActionBox() )
     1005      {
     1006        break;
     1007      }
     1008      ActionBox * box = entityTrack->getActionBox();
     1009
     1010      this->travelVelocity = Vector(0, 0, 0);
     1011      float ssss = 50;
     1012      if ( this->bForward )
     1013      {
     1014        this->travelVelocity += Vector( 0, ssss, 0 );
     1015      }
     1016      if ( this->bBackward )
     1017      {
     1018        this->travelVelocity += Vector( 0, -ssss, 0 );
     1019      }
     1020      if ( this->bLeft )
     1021      {
     1022        this->travelVelocity += Vector( 0, 0, -ssss );
     1023      }
     1024      if ( this->bRight )
     1025      {
     1026        this->travelVelocity += Vector( 0, 0, ssss );
     1027      }
     1028
     1029      Vector ds = this->travelVelocity*dt;
     1030      Vector newPos = this->getRelCoor() + ds;
     1031      if ( newPos.y < -(box->getHeight_2()) || newPos.y > box->getHeight_2() )
     1032      {
     1033        this->travelVelocity.y = 0;
     1034      }
     1035      if ( newPos.z > box->getWidth_2() || newPos.z < -(box->getWidth_2()) )
     1036      {
     1037        this->travelVelocity.z = 0;
     1038      }
     1039    }
    10601040      break;
    10611041    default:
     
    10991079}
    11001080
    1101 void SpaceShip::updateElectronicWidget()
    1102 {
    1103   if (this->electronicWidget != NULL)
    1104   { //if it exists already: update it
    1105      this->electronicWidget->setMaximum(this->electronicMax);
    1106      this->electronicWidget->setValue(this->electronicCur);
    1107   }
    1108   else
    1109   { //create the widget
    1110     this->electronicWidget = new OrxGui::GLGuiEnergyWidgetVertical();
    1111     this->electronicWidget->getBarWidget()->setChangedValueColor(Color(1,0,0,1));
    1112     //this->electronicWidget->setDisplayedName("Electronics:");
    1113     //this->electronicWidget->setSize2D(100,20);
    1114     //this->electronicWidget->setAbsCoor2D(150,200);
    1115     this->updateElectronicWidget();
    1116     if (this->hasPlayer())
    1117       State::getPlayer()->hud().setEnergyWidget(this->electronicWidget);
    1118   }
    1119 }
    1120 
    1121 void SpaceShip::updateShieldWidget()
    1122 {
    1123   if (this->shieldWidget != NULL)
    1124   {
    1125     this->shieldWidget->setMaximum(this->shieldMax);
    1126     this->shieldWidget->setValue(this->shieldCur);;
    1127   }
    1128   else
    1129   {
    1130     this->shieldWidget = new OrxGui::GLGuiEnergyWidgetVertical();
    1131     this->shieldWidget->getBarWidget()->setChangedValueColor(Color(1,0,0,1));
    1132     //this->shieldWidget->setDisplayedName("Shield:");
    1133     //his->shieldWidget->setSize2D(100,20);
    1134     //this->shieldWidget->setAbsCoor2D(200,200);
    1135     this->updateShieldWidget();
    1136     if (this->hasPlayer())
    1137       State::getPlayer()->hud().setShiledWidget(this->shieldWidget);
    1138   }
    1139 }
     1081// void SpaceShip::updateElectronicWidget()
     1082// {
     1083//   if (this->electronicWidget != NULL)
     1084//   { //if it exists already: update it
     1085//      this->electronicWidget->setMaximum(this->electronicMax);
     1086//      this->electronicWidget->setValue(this->electronicCur);
     1087//   }
     1088//   else
     1089//   { //create the widget
     1090//     this->electronicWidget = new OrxGui::GLGuiEnergyWidgetVertical();
     1091//     this->electronicWidget->getBarWidget()->setChangedValueColor(Color(1,0,0,1));
     1092//     //this->electronicWidget->setDisplayedName("Electronics:");
     1093//     //this->electronicWidget->setSize2D(100,20);
     1094//     //this->electronicWidget->setAbsCoor2D(150,200);
     1095//     this->updateElectronicWidget();
     1096//     if (this->hasPlayer())
     1097//       State::getPlayer()->hud().setEnergyWidget(this->electronicWidget);
     1098//   }
     1099// }
     1100//
     1101// void SpaceShip::updateShieldWidget()
     1102// {
     1103//   if (this->shieldWidget != NULL)
     1104//   {
     1105//     this->shieldWidget->setMaximum(this->shieldMax);
     1106//     this->shieldWidget->setValue(this->shieldCur);;
     1107//   }
     1108//   else
     1109//   {
     1110//     this->shieldWidget = new OrxGui::GLGuiEnergyWidgetVertical();
     1111//     this->shieldWidget->getBarWidget()->setChangedValueColor(Color(1,0,0,1));
     1112//     //this->shieldWidget->setDisplayedName("Shield:");
     1113//     //his->shieldWidget->setSize2D(100,20);
     1114//     //this->shieldWidget->setAbsCoor2D(200,200);
     1115//     this->updateShieldWidget();
     1116//     if (this->hasPlayer())
     1117//       State::getPlayer()->hud().setShiledWidget(this->shieldWidget);
     1118//   }
     1119// }
     1120
    11401121
    11411122void SpaceShip::setCameraDistance(float dist)
     
    11761157
    11771158  State::getPlayer()->hud().setOverlayPercentage(100-int(100*this->actionWidthPercentage));
    1178   PRINTF(0)("TravelDistance has been updated\n");
     1159//   PRINTF(0)("TravelDistance has been updated\n");
    11791160  this->isTravelDistanceInit = true;
    11801161}
     
    11891170    this->isTravelDistanceInit = false;
    11901171};
     1172
     1173
  • trunk/src/world_entities/space_ships/space_ship.h

    r10531 r10698  
    1212#include "playable.h"
    1313#include "extendable.h"
     14#include "world_entity.h"
    1415
    1516// Forward Declaration
     
    6364    inline WeaponManager& getWeaponManagerSecondary() { return this->secWeaponMan; };
    6465
    65     //Functions for GUI
    66     inline float getShieldCur() { return this->shieldCur; };        //!< returns current shield value
    67     inline float getShieldMax() { return this->shieldMax; };        //!< returns maximum shield value
    68 
    69     inline float getArmorCur() { return this->armorCur; };          //!< returns current armor value
    70     inline float getArmorMax() { return this->armorMax; };          //!< returns current armor value
    71 
    72     inline float getElectronicCur() { return this->electronicCur; }; //!< returns current electronic value
    73     inline float getElectronicMax() { return this->electronicMax; }; //!< returns current electronic value
     66    //!< functions for XML loading
     67    void loadReactor(float output) {this->reactorOutput = output; };
     68    void loadEngine( float speedBase) {this->engineSpeedBase = speedBase; };
     69    void loadEnergyShare(float shield, float weapon, float engine)
     70        { float tmp = shield + weapon + engine; if (unlikely (tmp > 1)) { tmp = 1/tmp; }
     71          // HACK dirty safety hack, prevents total share being bigger than 1!!
     72          this->shieldEnergyShare = shield * tmp;
     73          this->weaponEnergyShare = weapon * tmp;
     74          this->engineEnergyShare = engine * tmp; };
     75    inline void loadWeapon(float regen) { this->weaponEnergyRegen = regen; };
     76
     77    void addWeaponToSlot(int wm, int config, int slot, const std::string& weaponName);
    7478
    7579    inline PNode* getTravelNode() { return this->travelNode; };
     
    8690    virtual void movement (float dt);
    8791
    88     //
     92
    8993
    9094    void nextWeaponConfig();
     
    9296
    9397    virtual void hit(float damage, WorldEntity* killer);
    94    
     98
    9599    void                  setCameraDistance(float dist);
    96100
     
    100104    //void calculateVelocity(float time);
    101105
    102     void regen(float time);  //!< handler for shield and electronic regeneration
     106//    void regen(float time);  //!< handler for shield and electronic regeneration
    103107
    104108    void weaponRegen(float time);   //!< weapon energy regeneration
    105109
    106     inline bool systemFailure() {  return (this->electronicCur < float(rand())/float(RAND_MAX) * this->electronicTH); };
    107 
    108     void updateElectronicWidget();
    109     void updateShieldWidget();
     110//     inline bool systemFailure() {  return (this->getElectronic() < float(rand())/float(RAND_MAX) * this->getElectronicTH()); };
     111
     112//     void updateElectronicWidget();
     113//     void updateShieldWidget();
    110114
    111115    //WeaponManager         weaponMan;      //!< the primary weapon manager: managing a list of energy weapons to wepaon-slot mapping
     
    115119
    116120    //ship atributes
    117     float       shieldCur;          //!< current shield
    118     float       shieldMax;          //!< maximum shield
    119     float       shieldEnergyShare;  //!< percentage of reactor output
    120     float       shieldRegen;        //!< shield regeneration rate per second
    121     float       shieldTH;           //!< shield threshhold for reactivation
    122     bool        shieldActive;       //!< wheather the shield is working
    123     OrxGui::GLGuiEnergyWidgetVertical* shieldWidget; //!< holds the widget that shows the shield bar
    124 
    125     float       armorCur;           //!< current armor
    126     float       armorMax;           //!< maximum armor
    127     float       armorRegen;         //!< armor regeneration per tick (usable on bioships?)
     121//    float       shieldCur;          //!< current shield
     122//    float       shieldMax;          //!< maximum shield
     123//    float       shieldRegen;        //!< shield regeneration rate per second
     124//    float       shieldTH;           //!< shield threshhold for reactivation
     125//    bool        shieldActive;       //!< wheather the shield is working
     126//    OrxGui::GLGuiEnergyWidgetVertical* shieldWidget; //!< holds the widget that shows the shield bar
     127
     128//    float       armorCur;           //!< current armor
     129//    float       armorMax;           //!< maximum armor
     130//    float       armorRegen;         //!< armor regeneration per tick (usable on bioships?)
    128131    //note that the armor widget is set on the health- widget in world- entity (see in player.cc)
    129132
    130     float       electronicCur;      //!< current electronic
    131     float       electronicMax;      //!< maximum electronic
    132     float       electronicRegen;    //!< electronic regenration rate per tick
    133     float       electronicTH;       //!< Threshhold for electronic failure
    134     OrxGui::GLGuiEnergyWidgetVertical* electronicWidget; //!< holds the widget that shows the electronic bar
     133//    float       electronicCur;      //!< current electronic
     134//    float       electronicMax;      //!< maximum electronic
     135//    float       electronicRegen;    //!< electronic regenration rate per tick
     136//    float       electronicTH;       //!< Threshhold for electronic failure
     137//    OrxGui::GLGuiEnergyWidgetVertical* electronicWidget; //!< holds the widget that shows the electronic bar
    135138
    136139    float       engineSpeedCur;     //!< speed output for movement = speed base + energy share part
     
    138141    int         enginePowerConsume; //!< energy needed
    139142    float       engineEnergyShare;  //!< percentage of reactor output
     143    float       shieldEnergyShare;  //!< percentage of reactor output
    140144
    141145    int         weaponEnergySlot;   //!< number of energy weapon slots
     
    147151
    148152    float       reactorOutput;      //!< reactor output
    149     float       reactorCapacity;    //!< reactor capacity
     153//    float       reactorCapacity;    //!< reactor capacity
    150154
    151155    int         curWeaponPrimary;   //!< current primary weapon config
    152156    int         curWeaponSecondary; //!< current secondary weapon config
    153157
    154     bool                  bForward;                //!< up button pressed.
    155     bool                  bBackward;              //!< down button pressed.
     158    bool                  bForward;           //!< up button pressed.
     159    bool                  bBackward;          //!< down button pressed.
    156160    bool                  bLeft;              //!< left button pressed.
    157161    bool                  bRight;             //!< right button pressed.
     
    161165    bool                  bRollR;             //!< rolling button pressed (right)
    162166    bool                  bSecFire;           //!< second fire button pressed
     167
     168    bool                  bInit;              //!< set true, if MP have been loaded
    163169
    164170    /*
     
    208214
    209215    byte                  oldMask;            //!< used for synchronisation
    210 
     216/*
    211217    Trail*                trail;              //!< Burst trail
    212218    Trail*                trailL;              //!< Burst trail
    213219    Trail*                trailR;              //!< Burst trail
    214 
     220*/
    215221
    216222};
  • trunk/src/world_entities/spectator.cc

    r10682 r10698  
    2828
    2929#include "player.h"
     30
     31#include "util/track/action_box.h"
    3032
    3133
     
    300302  else if( event.type == KeyMapper::PEV_BACKWARD)
    301303    this->bBackward = event.bPressed; //this->shiftCoor(0,-.1,0);
     304  else if ( event.type == KeyMapper::PEV_JUMP )
     305  {
     306    if ( State::getActionBox() && State::getActionBox()->isPointInBox( this->getAbsCoor() ) )
     307    {
     308      PRINTF(0)("IN BOX\n");
     309    }
     310    else
     311    {
     312      PRINTF(0)("NOT IN BOX\n");
     313    }
     314  }
    302315  else if( event.type == EV_MOUSE_MOTION)
    303316  {
  • trunk/src/world_entities/tools/camera.cc

    r10618 r10698  
    203203      this->setRelCoor(Vector(-0.05, this->viewTopDistance , 0));
    204204      this->target->setRelCoor(0,0,0);
     205      break;
     206    }
     207    case Camera::ViewFPS:
     208    {
     209      this->fovy = viewNormalFovy;
     210      this->toFovy = viewNormalFovy;
     211      this->setRelCoorSoft(this->viewFrontDistance, 0, 0, 5);
     212      this->target->setRelCoorSoft(Vector(10,0,0), 5);
     213      break;
     214    }
     215    case Camera::ViewFPSZoom:
     216    {
     217      this->fovy = viewNormalFovy;
     218      this->toFovy = 30;
     219      this->setRelCoorSoft(2, 0, 0, 5);
     220      this->target->setRelCoorSoft(Vector(10,0,0), 5);
    205221    }
    206222  }
  • trunk/src/world_entities/tools/camera.h

    r10618 r10698  
    3434    ViewLeft,
    3535    ViewRight,
    36     ViewTop
     36    ViewTop,
     37    ViewFPS,
     38    ViewFPSZoom
    3739  };
    3840  public:
  • trunk/src/world_entities/tools/mount_point.cc

    r10618 r10698  
    2222
    2323#include "weapons/weapon_slot.h"
     24#include "weapons/weapon.h"
    2425
    2526#include "particles/particle_system.h"
     
    3637 * construct
    3738 */
    38 MountPoint::MountPoint (const Vector& up, const Vector& forward, const Vector& center, const std::string& name)
     39MountPoint::MountPoint (const Vector& up, const Vector& forward, const Vector& center,  const std::string& name)
    3940{
    4041//   PRINTF(0)("Created mount point %s\n", name.c_str());
     
    153154                                    this->getRelDir()*Quaternion(M_PI, Vector(0,1,0)));
    154155    }
     156
    155157  }
    156158}
  • trunk/src/world_entities/weapons/aiming_system.cc

    r10013 r10698  
    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
  • trunk/src/world_entities/weapons/heavy_blaster.cc

    r10618 r10698  
    9898//  this->model = (Model*)ResourceManager::getInstance()->load("models/guns/test_gun.obj", OBJ, RP_CAMPAIGN);
    9999
    100   this->loadModel("models/guns/frag_cannon.obj", .4);
     100  this->loadModel("models/guns/frag_cannon2.obj", .4);
    101101
    102102
     
    131131    this->objComp[i] = new PNode* [this->getSegs()];
    132132    this->emissionPoint[i] = new PNode;
    133     this->emissionPoint[i]->setParent(this);             //< One EmissionPoint, that is a PNode connected to the weapon. You can set this to the exitting point of the Projectiles
     133    this->emissionPoint[i]->setParent(this);      //Parenting emissionPoint to Weapons
    134134    this->emissionPoint[i]->setName("EmissionPoint");
    135135    this->emissionPoint[i]->addNodeFlags(PNODE_PROHIBIT_DELETE_WITH_PARENT);
     
    156156
    157157
    158 //   Animation3D* animB0Shoot = this->getAnimation(WS_SHOOTING0, this->objComp[0][0]);
    159 //   Animation3D* animB1Shoot = this->getAnimation(WS_SHOOTING1, this->objComp2);
    160 //   Animation3D* animB2Shoot = this->getAnimation(WS_SHOOTING2, this->objComp3);
    161 //   Animation3D* animT0Shoot = this->getAnimation(WS_SHOOTING3, this->objComp[0][1]);
    162 //   Animation3D* animT1Shoot = this->getAnimation(WS_SHOOTING4, this->objComp5);
    163 //   Animation3D* animT2Shoot = this->getAnimation(WS_SHOOTING5, this->objComp6);
    164 
    165 
    166 //   this->shootAnim[0][0]->setInfinity(ANIM_INF_CONSTANT);
    167 //   animB1Shoot->setInfinity(ANIM_INF_CONSTANT);
    168 //   animB2Shoot->setInfinity(ANIM_INF_CONSTANT);
    169 //   animT0Shoot->setInfinity(ANIM_INF_CONSTANT);
    170 //   animT1Shoot->setInfinity(ANIM_INF_CONSTANT);
    171 //   animT2Shoot->setInfinity(ANIM_INF_CONSTANT);
    172 
    173158  for (int i = 0; i < this->getBarrels(); i++){
    174     this->shootAnim[i][0]->addKeyFrame(Vector(0.0, 0.0, 0.0), Quaternion(), 0.05, ANIM_LINEAR, ANIM_NULL);
     159    this->shootAnim[i][0]->addKeyFrame(Vector(0.0, 0.0, 0.0), Quaternion(), 0.01, ANIM_LINEAR, ANIM_NULL);
    175160    this->shootAnim[i][0]->addKeyFrame(Vector(-0.3, 0.0, 0.0), Quaternion(), 0.9, ANIM_LINEAR, ANIM_NULL);
    176     this->shootAnim[i][0]->addKeyFrame(Vector(0.0, 0.0, 0.0), Quaternion(), 0.55, ANIM_LINEAR, ANIM_NULL);
    177 
    178     this->shootAnim[i][1]->addKeyFrame(Vector(0.0, 0.0, 0.0), Quaternion(), 0.05, ANIM_LINEAR, ANIM_NULL);
     161    this->shootAnim[i][0]->addKeyFrame(Vector(0.0, 0.0, 0.0), Quaternion(), 0.5, ANIM_LINEAR, ANIM_NULL);
     162
     163    this->shootAnim[i][1]->addKeyFrame(Vector(0.0, 0.0, 0.0), Quaternion(), 0.1, ANIM_LINEAR, ANIM_NULL);
    179164    this->shootAnim[i][1]->addKeyFrame(Vector(-0.4, 0.0, 0.0), Quaternion(), 1.2, ANIM_LINEAR, ANIM_NULL);
    180     this->shootAnim[i][1]->addKeyFrame(Vector(0.0, 0.0, 0.0), Quaternion(), 0.25, ANIM_LINEAR, ANIM_NULL);
     165    this->shootAnim[i][1]->addKeyFrame(Vector(0.0, 0.0, 0.0), Quaternion(), 0.2, ANIM_LINEAR, ANIM_NULL);
    181166  }
    182167
     
    186171  animation2->setInfinity(ANIM_INF_CONSTANT);
    187172  animation3->setInfinity(ANIM_INF_CONSTANT);
    188 
    189 //   this->setEmissionPoint(3.8, 1.2, 0, 0);
    190173
    191174  animation2->addKeyFrame(Vector(0.0, -1.0, 0.0), Quaternion(), 0.3, ANIM_LINEAR, ANIM_NULL);
     
    207190  pj->setParent(PNode::getNullParent());
    208191
    209 //   pj->setVelocity(this->getAbsDir().apply(Vector(1,0,0))*250 + VECTOR_RAND(5));
    210 //   pj->setVelocity(this->getAbsDir().apply(Vector(1,0,0))*130 + VECTOR_RAND(1));
    211192  pj->setVelocity(this->getAbsDir().apply(Vector(1,0,0))*130 + VECTOR_RAND(1));
    212193
    213194  pj->setAbsCoor(this->emissionPoint[this->activeBarrel]->getAbsCoor());
    214 //   pj->setAbsCoor(this->getEmissionPoint(0));
    215195  pj->setAbsDir(this->getAbsDir());
    216 //   pj->toList(OM_GROUP_01_PROJ);
    217196  pj->activate();
    218197
  • trunk/src/world_entities/weapons/laser_cannon.cc

    r10415 r10698  
    5555  this->registerObject(this, LaserCannon::_objectList);
    5656
    57 //  this->model = (Model*)ResourceManager::getInstance()->load("models/guns/laser_cannon.obj", OBJ, RP_CAMPAIGN);
     57  this->setScaling (5);
    5858
    59   this->loadModel("models/guns/lasercannon.obj", 5.0f);
     59  this->loadModel("models/guns/lasercannon.obj", this->getScaling());
    6060
    6161  this->setStateDuration(WS_SHOOTING, .1);
     
    7575  this->setProjectileTypeC("RailProjectile");
    7676  this->prepareProjectiles(100);
    77   this->setEmissionPoint(Vector(2.8,0,0) * 5.0);
     77  this->setEmissionPoint(Vector(2.8,0,0) * this->getScaling());
    7878}
    7979
  • trunk/src/world_entities/weapons/light_blaster.cc

    r10618 r10698  
    9090  this->setCapability(WTYPE_ALLDIRS | WTYPE_DIRECTIONAL | WTYPE_LIGHT);
    9191  this->setProjectileTypeC("LBolt");
    92   this->prepareProjectiles(100);
     92  this->prepareProjectiles(25);
    9393
    9494  this->setBarrels(3);
     
    106106    this->emissionPoint[i]->setName("EmissionPoint");
    107107    this->emissionPoint[i]->addNodeFlags(PNODE_PROHIBIT_DELETE_WITH_PARENT);
    108 //     this->shootAnim[i] = new Animation3D* [this->getSegs()];
    109108    for(int j = 0; j < this->getSegs(); j++)
    110109    {
     
    114113    }
    115114  }
    116 /*
    117   this->emissionPoint[0]->setRelCoor(Vector(1.19, 0.0, 0.1));
    118   this->emissionPoint[1]->setRelCoor(Vector(1.19, -0.07, -0.05));
    119   this->emissionPoint[2]->setRelCoor(Vector(1.19, 0.07, -0.05));*/
    120115
    121116  this->emissionPoint[0]->setRelCoor(Vector(2.2, 0.0, 0.1));
     
    130125  animation2->setInfinity(ANIM_INF_CONSTANT);
    131126  animation3->setInfinity(ANIM_INF_CONSTANT);
    132 
    133 //   this->setEmissionPoint(3.8, 1.2, 0);
    134 
    135 //   for (int i = 0; i < this->getBarrels(); i++){
    136 //     this->shootAnim[i][0]->addKeyFrame(Vector(), Quaternion(i * 120, Vector(1.0, 0.0, 0.0)), 0.049, ANIM_NULL, ANIM_LINEAR);
    137 //     this->shootAnim[i][0]->addKeyFrame(Vector(), Quaternion((i+1)*120, Vector(1.0, 0.0, 0.0)), 0.001, ANIM_NULL, ANIM_LINEAR);
    138 //   }
    139127
    140128
  • trunk/src/world_entities/weapons/medium_blaster.cc

    r10618 r10698  
    6969void MediumBlaster::init()
    7070{
    71   this->loadModel("models/guns/blaster.obj", .33);
     71  this->setScaling(.3333);
     72
     73  this->loadModel("models/guns/blaster.obj", this->getScaling());
    7274
    7375  this->setStateDuration(WS_SHOOTING, 0.2);   // 5 Schuss pro Sekunde
     
    8284
    8385  this->setActionSound(WA_SHOOT, "sounds/guns/laser.wav");
    84   this->setActionSound(WA_ACTIVATE, "sounds/voices/lasers.wav");
     86//   this->setActionSound(WA_ACTIVATE, "sounds/voices/lasers.wav");
    8587  this->setActionSound(WA_RELOAD, "sounds/spawn/alien_generator.wav");
    8688
    8789  this->setCapability(WTYPE_ALLDIRS | WTYPE_DIRECTIONAL | WTYPE_LIGHT);
    88   this->setProjectileTypeC("MBolt");   // FIXME temp project type until the blaste class exist
    89   this->prepareProjectiles(100);
     90  this->setProjectileTypeC("MBolt");
     91  this->prepareProjectiles(10);
    9092
    9193
     
    9597
    9698  this->objComp = new PNode**[this->getBarrels()];
     99  this->emissionPoint = new PNode*[this->getBarrels()];
    97100  this->shootAnim = new Animation3D**[this->getBarrels()];
    98101  for (int i = 0; i < this->getBarrels(); i++)
    99102  {
    100103    this->objComp[i] = new PNode* [this->getSegs()];
     104    this->emissionPoint[i] = new PNode;
     105    this->emissionPoint[i]->setParent(this);  //Parenting emissionPoint to Weapon
     106    this->emissionPoint[i]->setName("EmissionPoint");
     107    this->emissionPoint[i]->addNodeFlags(PNODE_PROHIBIT_DELETE_WITH_PARENT);
    101108    this->shootAnim[i] = new Animation3D* [this->getSegs()];
    102109    for(int j = 0; j < this->getSegs(); j++)
     
    109116
    110117  for (int i = 0; i < this->getBarrels(); i++){
    111     this->shootAnim[i][0]->addKeyFrame(Vector(0.0, 0.0, 0.0), Quaternion(), 0.04, ANIM_LINEAR, ANIM_NULL);
    112     this->shootAnim[i][0]->addKeyFrame(Vector(-0.333, 0.0, 0.0), Quaternion(), 0.15, ANIM_LINEAR, ANIM_NULL);
    113     this->shootAnim[i][0]->addKeyFrame(Vector(0.0, 0.0, 0.0), Quaternion(), 0.01, ANIM_LINEAR, ANIM_NULL);
    114 
    115     this->shootAnim[i][1]->addKeyFrame(Vector(0.0, 0.0, 0.0), Quaternion(), 0.04, ANIM_LINEAR, ANIM_NULL);
    116     this->shootAnim[i][1]->addKeyFrame(Vector(.166, 0.0, 0.0), Quaternion(), 0.15, ANIM_LINEAR, ANIM_NULL);
    117     this->shootAnim[i][1]->addKeyFrame(Vector(0.0, 0.0, 0.0), Quaternion(), 0.01, ANIM_LINEAR, ANIM_NULL);
     118    this->shootAnim[i][0]->addKeyFrame(Vector(0.0, 0.0, 0.0) * this->getScaling(), Quaternion(), 0.04, ANIM_LINEAR, ANIM_NULL);
     119    this->shootAnim[i][0]->addKeyFrame(Vector(-1.0, 0.0, 0.0) * this->getScaling(), Quaternion(), 0.15, ANIM_LINEAR, ANIM_NULL);
     120    this->shootAnim[i][0]->addKeyFrame(Vector(0.0, 0.0, 0.0) * this->getScaling(), Quaternion(), 0.01, ANIM_LINEAR, ANIM_NULL);
     121
     122    this->shootAnim[i][1]->addKeyFrame(Vector(0.0, 0.0, 0.0) * this->getScaling(), Quaternion(), 0.04, ANIM_LINEAR, ANIM_NULL);
     123    this->shootAnim[i][1]->addKeyFrame(Vector(.5, 0.0, 0.0) * this->getScaling(), Quaternion(), 0.15, ANIM_LINEAR, ANIM_NULL);
     124    this->shootAnim[i][1]->addKeyFrame(Vector(0.0, 0.0, 0.0) * this->getScaling(), Quaternion(), 0.01, ANIM_LINEAR, ANIM_NULL);
    118125  }
    119126
     
    124131  animation3->setInfinity(ANIM_INF_CONSTANT);
    125132
    126 
    127   this->setEmissionPoint(1.3, 0, 0);
     133  this->emissionPoint[0]->setRelCoor(Vector(3.9, 0.0, 0.0) * this->getScaling());
    128134
    129135  animation2->addKeyFrame(Vector(0.0, -1.0, 0.0), Quaternion(), 0.3, ANIM_LINEAR, ANIM_NULL);
  • trunk/src/world_entities/weapons/medium_blaster.h

    r10516 r10698  
    3333    PNode*** objComp;
    3434    Animation3D*** shootAnim;
     35    PNode** emissionPoint;
    3536
    3637    int activeBarrel;
  • trunk/src/world_entities/weapons/weapon.cc

    r10529 r10698  
    134134  for(int i = 0; i < this->barrels; i++){
    135135    this->emissionPoint[i] = new PNode;
    136     this->emissionPoint[i]->setParent(this);             //< One EmissionPoint, that is a PNode connected to the weapon. You can set this to the exitting point of the Projectiles
     136    this->emissionPoint[i]->setParent(this);  //Parenting emissionPoint to Weapons
    137137    this->emissionPoint[i]->setName("EmissionPoint");
    138138    this->emissionPoint[i]->addNodeFlags(PNODE_PROHIBIT_DELETE_WITH_PARENT);
     
    158158  // set this object to be synchronized over network
    159159  //this->setSynchronized(true);
    160 }
    161 
    162 /**
    163  * needed, if there are more than one barrel or segments
    164  */
    165 void Weapon::init2()
    166 {
    167   if (this->barrels == 1 && this->segs == 1)
    168     return;
    169 
    170   delete this->emissionPoint[0];
    171   delete this->emissionPoint;
    172   delete this->shootAnim[0];
    173   delete this->shootAnim;
    174 
    175   this->shootAnim = new Animation3D**[this->barrels];
    176   this->emissionPoint = new PNode*[this->barrels];
    177   for(int i = 0; i < this->barrels; i++){
    178     this->emissionPoint[i] = new PNode;
    179     this->emissionPoint[i]->setParent(this);             //< One EmissionPoint, that is a PNode connected to the weapon. You can set this to the exitting point of the Projectiles
    180     this->emissionPoint[i]->setName("EmissionPoint");
    181     this->emissionPoint[i]->addNodeFlags(PNODE_PROHIBIT_DELETE_WITH_PARENT);
    182     this->shootAnim[i] = new Animation3D* [this->segs];
    183   }
    184 }
    185 
    186 /**
    187  * deconstructor for init2
    188  */
    189 void Weapon::deconstr()
    190 {
    191   for(int i = 0; i < this->barrels; i++) {
    192     delete this->emissionPoint[i];
    193     for (int j = 0; j < this->segs; j++)
    194       delete this->shootAnim[i][j];
    195     delete this->shootAnim[i];
    196   }
    197 
    198   delete this->emissionPoint;
    199   delete this->shootAnim;
    200160}
    201161
  • trunk/src/world_entities/weapons/weapon.h

    r10516 r10698  
    124124    Projectile* getProjectile();
    125125
     126    inline void setScaling(float scaling) { this->scaling = scaling; };
     127    inline float getScaling() { return this->scaling; };
    126128
    127129    // EMISSION
     
    181183    inline void setSegs(int segs) { this->segs = segs; };
    182184
    183     inline Animation3D* getShootAnim(int barrel, int seg) { return this->shootAnim[barrel][seg]; };
    184     inline void setShootAnim(int barrel, int seg, PNode* component) { this->shootAnim[barrel][seg] = this->getAnimation(barrel, seg, component); };
    185 
    186     void init2();
     185//     inline Animation3D* getShootAnim(int barrel, int seg) { return this->shootAnim[barrel][seg]; };
     186//     inline void setShootAnim(int barrel, int seg, PNode* component) { this->shootAnim[barrel][seg] = this->getAnimation(barrel, seg, component); };
     187
     188//     void init2();
    187189    void deconstr();
    188190
     
    248250    PNode*               defaultTarget;                    //!< A target for targeting Weapons.
    249251
     252    float                scaling;                          //!< Local scaling factor. any scaling will be done through this vector.
     253
    250254    ////////////
    251255    // PHASES //
  • trunk/src/world_entities/weapons/weapon_manager.cc

    r10544 r10698  
    1 
    21/*
    32   orxonox - the future of 3D-vertical-scrollers
     
    3635/**
    3736 * @brief this initializes the weaponManager for a given nnumber of weapon slots
    38  * @param number of weapon slots of the model/ship <= 8 (limitied)
     37 * @param number of weapon slots of the model/ship <= 10 (limitied)
    3938 */
    4039WeaponManager::WeaponManager(WorldEntity* parent)
     
    146145  BaseObject::loadParams(root);
    147146
    148   LoadParam(root, "slot-count", this, WeaponManager, setSlotCount)
     147  LoadParam(root, "slotCount", this, WeaponManager, setSlotCount)
    149148  .describe("how many slots(cannons) the WeaponManager can handle");
     149
    150150
    151151  LOAD_PARAM_START_CYCLE(root, element);
     
    156156  }
    157157  LOAD_PARAM_END_CYCLE(element);
     158
     159
    158160}
    159161
     
    357359 * @param slotCapability the capability @see WeaponSlotCapability
    358360 */
    359 void WeaponManager::setSlotCapability(int slot, long slotCapability)
     361void WeaponManager::setSlotCapability(int slot, unsigned long slotCapability)
    360362{
    361363  if (slot > slotCount)
  • trunk/src/world_entities/weapons/weapon_manager.h

    r10437 r10698  
    6060    // setting up the WeaponManager with the following functions
    6161    void setSlotPosition(int slot, const Vector& position, PNode* parent = NULL);
     62//     inline void setSlotPosition(float slot, float x, float y,float z) {setSlotPosition((int)slot, Vector(x,y,z));};
    6263    void setSlotDirection(int slot, const Quaternion& rotation);
    6364    /** @param slot the slot to get the relative position from @returns the relative position of the Carrier to the Slot */
    6465    const Vector& getSlotPosition(int slot) const;
    65     void setSlotCapability(int slot, long slotCapability);
     66    void setSlotCapability(int slot, unsigned long slotCapability);
    6667    /** @param slot the slot to get the capabilities from @returns the capabilies */
    6768    long getSlotCapability(int slot) const;
     
    7677    bool addWeapon(Weapon* weapon, int configID = -1, int slotID = -1);
    7778    void removeWeapon(Weapon* weapon, int configID = -1);
     79
     80    inline void createWeaponSlot(int slot, float x, float y, float z, long capability) {
     81        this->setSlotPosition(slot, Vector( x, y, z));
     82        this->setSlotCapability(slot, capability); };
     83
     84    inline void addWeaponToSlot(int config, int slot, const std::string& weaponName){
     85      this->addWeapon( Weapon::createWeapon( weaponName ), config, slot); };
     86
    7887
    7988    Weapon* getWeapon(int slotID) const;
  • trunk/src/world_entities/weapons/weapon_slot.cc

    r10534 r10698  
    4242
    4343WeaponSlot::~WeaponSlot()
    44 {}
     44{
     45}
    4546
    4647
     
    5556
    5657  LoadParam(root, "slot", this, WeaponSlot, setWeaponConfig)
    57       .describe("sets the weapon slot");
     58  .describe("sets the weapon slot");
     59
     60  LoadParam(root, "currentWeapon", this, WeaponSlot, setCurrentWeapon)
     61  .describe("creates and set next weapon");
     62
     63  LoadParam(root, "nextWeapon", this, WeaponSlot, setNextWeapon)
     64  .describe("creates and set next weapon");
    5865}
    5966
     
    6370void WeaponSlot::setWeaponClass()
    6471{
    65 
    6672}
    6773
  • trunk/src/world_entities/weapons/weapon_slot.h

    r10534 r10698  
    88
    99#include "p_node.h"
    10 
     10#include "weapon.h"
    1111
    1212class Weapon;
     
    3636  inline void setNextWeapon(Weapon* weapon) { this->nextWeapon = weapon; }
    3737
     38  inline void setNextWeapon(const std::string& weaponName){this->nextWeapon = Weapon::createWeapon(weaponName); };
     39  inline void setCurrentWeapon(const std::string& weaponName){ this->currentWeapon = Weapon::createWeapon(weaponName); };
     40
    3841
    3942  inline void setWeaponConfig(int slot, int side) { this->weaponSlot = slot; this->weaponSide = side; }
  • trunk/src/world_entities/world_entity.cc

    r10618 r10698  
    7575  this->aabbNode = NULL;
    7676  this->healthWidget = NULL;
     77  this->electronicWidget = NULL;
     78  this->shieldWidget = NULL;
    7779  this->healthMax = 1.0f;
    7880  this->health = 1.0f;
     
    128130
    129131  // Delete the obbTree
    130   if( this->obbTree != NULL)
     132  if( this->obbTree)
    131133    delete this->obbTree;
    132134
    133   if (this->healthWidget != NULL)
     135  if (this->healthWidget)
    134136    delete this->healthWidget;
     137
     138  if(this->shieldWidget)
     139    delete this->shieldWidget;
     140
     141  if( this->electronicWidget)
     142    delete this->electronicWidget;
    135143
    136144  this->unsubscribeReactions();
     
    776784  this->updateHealthWidget();
    777785  return 0.0;
    778 
    779 }
     786}
     787
    780788
    781789/**
     
    792800  this->updateHealthWidget();
    793801}
     802
     803
     804
     805/**
     806 * @param shiled the Shieldstength to add.
     807 * @returns the shield left (this->shieldMax - shiled + this->shield)
     808 */
     809float WorldEntity::increaseShield(float shiled)
     810{
     811  this->shield += shield;
     812  if (this->shield > this->shieldTH * this->shieldMax) { this->bShieldActive = true; }
     813  if (this->shield > this->shieldMax)
     814  {
     815    float retShield = this->shieldMax - this->shield;
     816    this->shield = this->shieldMax;
     817//     this->updateShieldWidget();
     818    return retShield;
     819  }
     820//   this->updateShieldWidget();
     821  return 0.0;
     822}
     823
     824/**
     825 * @param shield the Shieldstrength to be removed
     826 * @returns 0.0 or the rest, if the shield drops belew 0.0
     827 */
     828float WorldEntity::decreaseShield(float shield)
     829{
     830  this->shield -= shield;
     831
     832  if (this->shield <= 0)
     833  {
     834    float retShield = -this->shield;
     835//     this->updateShieldWidget();
     836    this->bShieldActive = false;
     837    return retShield;
     838  }
     839//   this->updateShieldWidget();
     840  return 0.0;
     841}
     842
     843
    794844
    795845/**
     
    813863}
    814864
     865
     866/**
     867 * @brief creates the ImplantWidget
     868 *
     869 * since not all entities need an ImpantWidget, it is only created on request.
     870 */
     871void WorldEntity::createImplantWidget()
     872{
     873  if (this->implantWidget == NULL)
     874  {
     875    this->implantWidget = new OrxGui::GLGuiEnergyWidgetVertical();
     876    //this->impantWidget->setDisplayedName("Implant");
     877    //this->impantWidget->setSize2D(100,20);
     878    //this->impantWidget->setAbsCoor2D(100,200);
     879
     880    //this->updateImplantWidget();
     881  }
     882  else
     883    PRINTF(3)("Allready created the ImlpantWidget for %s::%s\n", this->getClassCName(), this->getCName());
     884}
     885
     886
     887
     888void WorldEntity::createShieldWidget()
     889{
     890  if (this->shieldWidget == NULL)
     891  {
     892    this->shieldWidget = new OrxGui::GLGuiEnergyWidgetVertical();
     893    this->updateShieldWidget();
     894  }
     895  else
     896    PRINTF(3)("Allready created the ShieldWidget for %s::%s\n", this->getClassCName(), this->getCName());
     897}
     898
     899void WorldEntity::createElectronicWidget()
     900{
     901  if (this->electronicWidget == NULL)
     902  {
     903    this->electronicWidget = new OrxGui::GLGuiEnergyWidgetVertical();
     904    this->updateElectronicWidget();
     905  }
     906  else
     907    PRINTF(3)("Allready created the ElectronicWidget for %s::%s\n", this->getClassCName(), this->getCName());
     908}
     909
     910
     911
    815912void WorldEntity::increaseHealthMax(float increaseHealth)
    816913{
     
    822919OrxGui::GLGuiWidget* WorldEntity::getHealthWidget()
    823920{
    824   this->createHealthWidget();
     921  if ( this->healthWidget == NULL)
     922    this->createHealthWidget();
    825923  return this->healthWidget;
    826924}
     925
     926
     927
     928OrxGui::GLGuiWidget* WorldEntity::getImplantWidget()
     929{
     930  this->createImplantWidget();
     931  return this->implantWidget;
     932}
     933
     934
     935
     936OrxGui::GLGuiWidget* WorldEntity::getShieldWidget()
     937{
     938  if ( this->shieldWidget == NULL)
     939    this->createShieldWidget();
     940  return this->shieldWidget;
     941}
     942
     943
     944OrxGui::GLGuiWidget* WorldEntity::getElectronicWidget()
     945{
     946  if ( this->electronicWidget == NULL)
     947    this->createElectronicWidget();
     948  return this->electronicWidget;
     949}
     950
     951
     952
    827953
    828954/**
     
    830956 * (creates the widget if needed)
    831957 */
    832 void WorldEntity::setHealthWidgetVisibilit(bool visibility)
     958void WorldEntity::setHealthWidgetVisibility(bool visibility)
    833959{
    834960  if (visibility)
     
    8901016  }
    8911017}
     1018
     1019/**
     1020 * @brief updates the Electronic Widget
     1021 */
     1022//!< xferred from spaceship
     1023void WorldEntity::updateElectronicWidget(){
     1024  if (this->electronicWidget != NULL)
     1025  { //if it exists already: update it
     1026     this->electronicWidget->setMaximum(this->electronicMax);
     1027     this->electronicWidget->setValue(this->electronic);
     1028  }
     1029  else
     1030  { //create the widget
     1031    this->electronicWidget = new OrxGui::GLGuiEnergyWidgetVertical();
     1032    this->electronicWidget->getBarWidget()->setChangedValueColor(Color(1,0,0,1));
     1033    //this->electronicWidget->setDisplayedName("Electronics:");
     1034    //this->electronicWidget->setSize2D(100,20);
     1035    //this->electronicWidget->setAbsCoor2D(150,200);
     1036    this->updateElectronicWidget();
     1037//     if ( dynamic_cast<SpaceShip*>(this)->hasPlayer() )
     1038//       State::getPlayer()->hud().setEnergyWidget(this->electronicWidget);
     1039  }
     1040}
     1041
     1042/**
     1043 * @brief updates the ShieldWidget
     1044 */
     1045//!< xferred from spaceship
     1046void WorldEntity::updateShieldWidget()
     1047{
     1048  if (this->shieldWidget != NULL)
     1049  {
     1050    this->shieldWidget->setMaximum(this->shieldMax);
     1051    this->shieldWidget->setValue(this->shield);;
     1052  }
     1053  else
     1054  {
     1055    this->shieldWidget = new OrxGui::GLGuiEnergyWidgetVertical();
     1056    this->shieldWidget->getBarWidget()->setChangedValueColor(Color(1,0,0,1));
     1057    //this->shieldWidget->setDisplayedName("Shield:");
     1058    //his->shieldWidget->setSize2D(100,20);
     1059    //this->shieldWidget->setAbsCoor2D(200,200);
     1060    this->updateShieldWidget();
     1061//     if (dynamic_cast<SpaceShip*>(this)->hasPlayer())
     1062//       State::getPlayer()->hud().setShieldWidget(this->shieldWidget);
     1063  }
     1064}
     1065
    8921066
    8931067
     
    9851159}
    9861160
     1161
     1162void WorldEntity::regen(float time){
     1163  static float tmp;
     1164  increaseHealth(time * this->healthRegen);
     1165  increaseShield(time * this->shieldRegen);
     1166//   updateHealthWidget();
     1167//   updateShieldWidget();
     1168
     1169  //this->setHealth( this->shieldCur);      // FIXME currently just to test share system
     1170
     1171  if (this->electronic != this->electronicMax || this->electronicRegen != 0){
     1172    tmp = this->electronic + this->electronicRegen * time;
     1173    if ( tmp > electronicMax)
     1174      this->electronic = this->electronicMax;
     1175    else
     1176      this->electronic = tmp;
     1177
     1178    updateElectronicWidget();
     1179  }
     1180
     1181}
  • trunk/src/world_entities/world_entity.h

    r10540 r10698  
    161161  void increaseHealthMax(float increaseHealth);
    162162  OrxGui::GLGuiWidget* getHealthWidget();
     163  OrxGui::GLGuiWidget* getImplantWidget();
     164  OrxGui::GLGuiWidget* getShieldWidget();
     165  OrxGui::GLGuiWidget* getElectronicWidget();
    163166  bool hasHealthWidget() const { return this->healthWidget != NULL; };
     167
     168  float getShield() const { return this->shield; };
     169  float getShieldMax() const { return this->shieldMax; };
     170  float increaseShield(float shield);
     171  float decreaseShield(float shield);
     172  bool getShieldActive() { return this->bShieldActive; };
     173
     174  float getElectronic() const { return this->electronic; };
     175  float getElectronicMax() const { return this->electronicMax; };
     176  float increaseElectronic(float electronic);
     177  float decreaseElectronic(float electronic);
     178
     179  bool systemFailure() {  return (this->electronic < float(rand())/float(RAND_MAX) * this->electronicTH); };
     180
     181  void resetElectronic() { this->electronic = this->electronicMax; };
     182  void resetShield()  { this->shield = this->shieldMax; this->bShieldActive = true; };
     183  void resetHealth() { this->health = this->healthMax; };
     184
     185  void createHealthWidget();
     186  void createShieldWidget();
     187  void createElectronicWidget();
     188
     189  void regen(float time);
     190
     191  void loadShield(float cur, float max, float th, float regen)
     192      { this->setShield(cur); this->setShieldMax(max); this->setShieldTH(th); this->setShieldRegen(regen); };
     193  void loadHealth(float cur, float max, float regen = 0) { this->setHealth(cur); this->setHealthMax(max); this->setHealthRegen(regen); };
     194  void loadElectronic(float cur, float max, float th, float regen)
     195      { this->setElectronic(cur); this->setElectronicMax(max); this->setElectronicTH(th); this->setElectronicRegen(regen); };
     196
    164197
    165198  virtual void varChangeHandler( std::list<int> & id );
     
    181214  void pauseTrack(bool stop);
    182215
     216//   void updateHealthWidget();
     217//   void updateElectronicWidget();
     218//   void updateShieldWidget();
    183219
    184220protected:
    185   void setHealth(float health) { this->health = health; this->updateHealthWidget();};
    186   void setHealthWidgetVisibilit(bool visibility);
     221  inline void setHealth(float health) { this->health = health; this->updateHealthWidget();};
     222  void setHealthWidgetVisibility(bool visibility);
    187223  void setHealthMax(float healthMax);
    188   void createHealthWidget();
     224//   void createHealthWidget();
     225//   void createShieldWidget();
     226//   void createElectronicWidget();
     227  void setHealthRegen(float regen) { this->healthRegen = regen; };
     228  void createImplantWidget();
    189229    //  CharacterAttributes*    charAttr;         //!< the character attributes of a world_entity
     230
     231  void setShield(float shield) { this->shield = shield; };
     232  void setShieldMax(float shield) { this->shieldMax = shield; };
     233  void setShieldTH(float th) { this->shieldTH = th; };
     234  void setShieldRegen(float regen) { this->shieldRegen = regen; };
     235  void setShieldActive(bool active) { this->bShieldActive = active; };
     236
     237  void setElectronic(float electronic) { this->electronic = electronic; };
     238  void setElectronicMax(float electronic) { this->electronicMax = electronic; };
     239  void setElectronicTH(float th) { this->electronicTH = th; };
     240  void setElectronicRegen(float regen) { this->electronicRegen = regen; };
    190241
    191242  inline void drawDebugTrack(int flag) { this->bDrawTrack = (bool)flag; }
    192243  inline bool isDrawTrack() const { return this->bDrawTrack; }
    193244
    194 
    195245private:
    196246  void updateHealthWidget();
     247  void updateElectronicWidget();
     248  void updateShieldWidget();
    197249  void addTrack(const TiXmlElement* root);
    198250
    199251
    200252
    201   protected:
    202       std::vector<MountPoint*> mountPoints;       //!< A list with mount points for this model
    203       std::map<int, MountPoint*> mountPointMap;
     253protected:
     254  std::vector<MountPoint*> mountPoints;       //!< A list with mount points for this model
     255  std::map<int, MountPoint*> mountPointMap;
    204256
    205257
    206258
    207259private:
    208   /// TODO maybe we will move the following three entries and the corresponding functions to Playable AND NPC
     260
     261  //!< TODO maybe we will move the following three entries and the corresponding functions to Playable AND NPC
     262  //!< started transfering shield/electronic/health from spaceship to WE! (nico, 4.Jun.07)
     263
    209264  float                   damage;             //!< the damage dealt to other objects by colliding.
    210265  float                   health;             //!< The Energy of this Entity, if the Entity has any energy at all.
    211   float                   healthMax;          //!< The Maximal energy this entity can take.
     266  float                   healthMax;          //!< The Maximal energy this entity can take.
     267  float                                         implantEnergy;          //!< energy of implants
     268  float                   healthRegen;        //!< Regeneration Rate of Health, mesured in units per second
    212269  OrxGui::GLGuiEnergyWidgetVertical* healthWidget;    //!< The Slider (if wanted).
     270  OrxGui::GLGuiEnergyWidgetVertical* implantWidget;
     271
     272  float       shield;             //!< current shield
     273  float       shieldMax;          //!< maximum shield
     274  float       shieldRegen;        //!< shield regeneration rate per second
     275  float       shieldTH;           //!< shield threshhold for reactivation
     276  bool        bShieldActive;      //!< wheather the shield is working
     277  OrxGui::GLGuiEnergyWidgetVertical* shieldWidget; //!< holds the widget that shows the shield bar
     278
     279  float       electronic;         //!< current electronic
     280  float       electronicMax;      //!< maximum electronic
     281  float       electronicRegen;    //!< electronic regenration rate per tick
     282  float       electronicTH;       //!< Threshhold for electronic failure
     283  OrxGui::GLGuiEnergyWidgetVertical* electronicWidget; //!< holds the widget that shows the electronic bar
     284
    213285
    214286  std::vector<Model*>     models;             //!< The model that should be loaded for this entity.
     
    247319  float                   healthMax_write;
    248320  int                     healthMax_handle;
     321 
     322
    249323
    250324
Note: See TracChangeset for help on using the changeset viewer.