Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 9957 in orxonox.OLD for branches/playability


Ignore:
Timestamp:
Nov 24, 2006, 11:58:23 PM (18 years ago)
Author:
nicolasc
Message:

updated damage() to use tick
added collidesWith() to Projectile

Location:
branches/playability/src/world_entities
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/playability/src/world_entities/projectiles/projectile.cc

    r9953 r9957  
    122122
    123123
     124
     125void Projectile::collidesWith (WorldEntity* entity, const Vector& location)
     126{
     127  //if (entity->isA(CL_SPACE_SHIP)) /* FIXME make sure that entity is a spaceship*/
     128  //  entity->damage(this->physDamage, this->elecDamage); /* and do some damage*/
     129  this->destroy(entity);
     130}
     131
    124132/**
    125133 * signal tick, time dependent things will be handled here
     
    145153}
    146154
    147 
    148 
    149155int Projectile::getPhysDamage () { return this->physDamage; }
    150156
  • branches/playability/src/world_entities/projectiles/projectile.h

    r9953 r9957  
    4444    virtual void destroy (WorldEntity* killer);
    4545
     46    virtual void collidesWith (WorldEntity* entity, const Vector& location);   //!< collision handler as used in diverse weapons
     47
    4648    virtual void tick (float dt);
    4749    /** @brief convenience function
  • branches/playability/src/world_entities/space_ships/space_ship.cc

    r9953 r9957  
    521521
    522522
    523 int SpaceShip::getShieldCur () { return this->shieldCur; }
    524 int SpaceShip::getShieldMax () { return this->shieldMax; }
    525 
    526 int SpaceShip::getArmorCur () { return this->armorCur; }
    527 int SpaceShip::getArmorMax () { return this->armorMax; }
    528 
    529 int SpaceShip::getElectronicCur () { return this->electronicCur; }
    530 int SpaceShip::getElectronicMax () { return this->electronicMax; }
    531 
    532 void SpaceShip::damage(int pDamage, int eDamage){
     523void SpaceShip::damage(float pDamage, float eDamage){
    533524if( this->shieldActive) {
    534525    if( this->shieldCur > pDamage) {
     
    540531      pDamage = pDamage - this->shieldCur;
    541532      if( !this->shieldActive) {
    542         this->armorCur = pDamage / 2; // remaining damages hits armor at half rate
     533        this->armorCur -= pDamage / 2; // remaining damages hits armor at half rate
    543534        this->electronicCur -= eDamage;
    544535      }
     
    552543}
    553544
    554 void SpaceShip::regen(){
    555   int time = 1; // FIXME implement tick time calculation
    556   if (this->shieldCur == this->shieldMax){}
    557   else {
    558     if( this->shieldCur + this->shieldRegen * time > shieldMax)
     545void SpaceShip::regen(float time){
     546  float tmp;
     547  if (this->shieldCur != this->shieldMax){
     548    tmp =  this->shieldCur + this->shieldRegen * time;
     549    if( tmp > shieldMax)
    559550      this->shieldCur = this->shieldMax;
    560551    else
    561       this->shieldCur += this->shieldRegen * time;
    562     if( this->shieldCur > shieldTH)
    563       this->shieldActive = true;
    564   }
    565   if (this->electronicCur == this->electronicMax){}
    566   else{
    567     if (this->electronicCur + this->electronicRegen * time > electronicMax)
     552      this->shieldCur = tmp;
     553    this->shieldActive = ( this->shieldActive || this->shieldCur > shieldTH);
     554  }
     555  if (this->electronicCur != this->electronicMax){
     556    tmp = this->electronicCur + this->electronicRegen * time;
     557    if ( tmp > electronicMax)
    568558      this->electronicCur = this->electronicMax;
    569559    else
    570       this->electronicCur += this->electronicRegen * time;
    571   }
    572 }
    573 
     560      this->electronicCur = tmp;
     561  }
     562}
  • branches/playability/src/world_entities/space_ships/space_ship.h

    r9953 r9957  
    4848
    4949    //Functions for GUI
    50     virtual int getShieldCur();     //!< returns current shield value
    51     virtual int getShieldMax();     //!< returns maximum shield value
     50    inline float getShieldCur() { return this->shieldCur; };        //!< returns current shield value
     51    inline float getShieldMax() { return this->shieldMax; };        //!< returns maximum shield value
    5252
    53     virtual int getArmorCur();      //!< returns current armor value
    54     virtual int getArmorMax();      //!< returns current armor value
     53    inline float getArmorCur() { return this->armorCur; };          //!< returns current armor value
     54    inline float getArmorMax() { return this->armorMax; };          //!< returns current armor value
    5555
    56     virtual int getElectronicCur(); //!< returns current electronic value
    57     virtual int getElectronicMax(); //!< returns current electronic value
     56    inline float getElectronicCur() { return this->electronicCur; }; //!< returns current electronic value
     57    inline float getElectronicMax() { return this->electronicMax; }; //!< returns current electronic value
    5858
    5959    //damage handler
    60     virtual void damage(int pDamage, int eDamage);  //!< pDamage physical damage, eDamage electronic damage
     60    virtual void damage(float pDamage, float eDamage);  //!< pDamage physical damage, eDamage electronic damage
    6161
    6262  private:
     
    6565    void calculateVelocity(float time);
    6666
    67     void regen();  //!< handler for shield and electronic regeneration
     67    void regen(float time);  //!< handler for shield and electronic regeneration
    6868
    6969    //ship atributes
    70     int         shieldCur;          //!< current shield
    71     int         shieldMax;          //!< maximum shield
     70    float       shieldCur;          //!< current shield
     71    float       shieldMax;          //!< maximum shield
    7272    float       shieldEnergyShare;  //!< percentage of reactor output
    73     int         shieldRegen;        //!< shield regeneration rate
    74     int         shieldTH;           //!< shield threshhold for reactivation
     73    float       shieldRegen;        //!< shield regeneration rate per tick
     74    float       shieldTH;           //!< shield threshhold for reactivation
    7575    bool        shieldActive;       //!< wheather the shield is working
    7676
    77     int         armorCur;           //!< current armor
    78     int         armorMax;           //!< maximum armor
     77    float       armorCur;           //!< current armor
     78    float       armorMax;           //!< maximum armor
    7979
    80     int         electronicCur;      //!< current electronic
    81     int         electronicMax;      //!< maximum electronic
    82     int         electronicRegen;    //!< electronic regenration rate
     80    float       electronicCur;      //!< current electronic
     81    float       electronicMax;      //!< maximum electronic
     82    float       electronicRegen;    //!< electronic regenration rate per tick
    8383
    8484    int         engineSpeedCur;     //!< speed output
Note: See TracChangeset for help on using the changeset viewer.