Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 10708 in orxonox.OLD for branches


Ignore:
Timestamp:
Jun 16, 2007, 11:15:39 AM (18 years ago)
Author:
rennerc
Message:

improved damage handling for adm

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

Legend:

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

    r10705 r10708  
    157157    wpRight->toList( this->getOMListNumber() );
    158158    wpRight->setParent( this->cameraNode );
     159    wpRight->setForwardDamageToParent( true );
    159160    //wpRight->requestAction( WA_ACTIVATE );
    160161    //wpRight->addChild(this->aimingSystem);
  • branches/presentation/src/world_entities/npcs/adm_turret.cc

    r10704 r10708  
    242242void AdmTurret::addCannons( const TiXmlElement * root )
    243243{
    244   this->cannons = new WorldEntity();
     244  this->cannons = new DamageForwardingWorldEntity( this );
    245245        this->cannons->setParent(this);
    246246        this->cannons->loadParams( root );
     
    250250
    251251        this->cannons->toList( getOMListNumber() );
     252        this->cannons->setForwardDamageToParent( true );
    252253}
    253254
     
    260261        //this->weapon->setAbsCoor( this->cannons->getAbsCoor() );
    261262        this->weapon->setAbsDir( this->weapon->getAbsDir() * Quaternion( PI, Vector(0, 1, 0) ) );
     263       
     264        this->weapon->setForwardDamageToParent( true );
    262265}
    263266
    264267void AdmTurret::addSensor( const TiXmlElement * root )
    265268{
    266   this->sensor = new WorldEntity();
     269  this->sensor = new DamageForwardingWorldEntity( this );
    267270        this->sensor->setParent(this);
    268271        this->sensor->loadParams( root );
     
    270273        //this->sensor->addNodeFlags(PNODE_PROHIBIT_DELETE_WITH_PARENT);
    271274        //this->sensor->addNodeFlags(PNODE_PROHIBIT_CHILD_DELETE);
    272         this->sensor->toList( getOMListNumber() );
     275       
    273276}
    274277
  • branches/presentation/src/world_entities/npcs/adm_turret.h

    r10703 r10708  
    1212#include "world_entity.h"
    1313#include "weapons/bsp_weapon.h"
     14
     15class DamageForwardingWorldEntity: public WorldEntity
     16{
     17  public:
     18    DamageForwardingWorldEntity( WorldEntity* dfp ){ this->damPar = dfp; }
     19    virtual void hit(float damage, WorldEntity* killer){ this->damPar->hit(damage, killer); }
     20  private:
     21    WorldEntity* damPar;
     22};
    1423
    1524
  • branches/presentation/src/world_entities/world_entity.cc

    r10704 r10708  
    9797  this->entityTrack = NULL;
    9898  this->bDrawTrack = false;
     99 
     100  this->forwardDamageToParent = false;
    99101
    100102  // registering default reactions:
     
    179181  LoadParam(root, "drawTrack", this, WorldEntity, drawDebugTrack)
    180182      .describe("draws the track for debugging purposes");
     183 
     184  LoadParam(root, "forwardDamageToParent", this, WorldEntity, setForwardDamageToParent);
    181185
    182186  // Track
     
    980984void WorldEntity::hit(float damage, WorldEntity* killer)
    981985{
    982 
     986  PRINTF(0)("TESTS: %i %i %i\n", (forwardDamageToParent), (this->getParent() != NullParent::getNullParent()), (this->getParent()->isA( WorldEntity::staticClassID() )));
     987  if ( forwardDamageToParent && this->getParent() != NullParent::getNullParent() && this->getParent()->isA( WorldEntity::staticClassID() ) )
     988  {
     989    WorldEntity* pa = dynamic_cast<WorldEntity*>(this->getParent());
     990    pa->hit( damage, killer );
     991    return;
     992  }
     993 
     994  bool dead = this->getHealth()<=0;
     995 
    983996  this->decreaseHealth(damage);
    984997
     
    9911004  else
    9921005  {
    993     this->destroy( killer );
     1006    if ( !dead )
     1007      this->destroy( killer );
    9941008  }
    9951009}
  • branches/presentation/src/world_entities/world_entity.h

    r10698 r10708  
    6363  void unmount(int slot);
    6464
    65 
     65  void setForwardDamageToParent( bool val ){ this->forwardDamageToParent = val; }
    6666
    6767  /** @param visibility if the Entity should be visible (been draw) */
     
    262262  //!< started transfering shield/electronic/health from spaceship to WE! (nico, 4.Jun.07)
    263263
    264   float                   damage;             //!< the damage dealt to other objects by colliding.
    265   float                   health;             //!< The Energy of this Entity, if the Entity has any energy at all.
    266   float                   healthMax;          //!< The Maximal energy this entity can take.
     264
     265  float                   damage;                 //!< the damage dealt to other objects by colliding.
     266  float                   health;                 //!< The Energy of this Entity, if the Entity has any energy at all.
     267  bool                    forwardDamageToParent;  //!< if true, damage taken will be forwardet to parent
     268  float                   healthMax;              //!< The Maximal energy this entity can take.
    267269  float                                         implantEnergy;          //!< energy of implants
    268270  float                   healthRegen;        //!< Regeneration Rate of Health, mesured in units per second
Note: See TracChangeset for help on using the changeset viewer.