Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 10601 for code


Ignore:
Timestamp:
Sep 27, 2015, 10:03:53 PM (9 years ago)
Author:
landauf
Message:

cleanup: empty level is empty again & tabs→spaces.

Location:
code/branches/weaponFS15
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • code/branches/weaponFS15/data/levels/emptyLevel.oxw

    r10369 r10601  
    1313
    1414<?lua
    15   include("templates/spaceshipAssff.oxt")
     15  include("templates/spaceshipAssff2.oxt")
    1616  include("templates/spaceshipPirate.oxt")
    1717  include("templates/spaceshipEscort.oxt")
     
    3030
    3131    <Light type=directional position="0,0,0" direction="0.253, 0.593, -0.765" diffuse="1.0, 0.9, 0.9, 1.0" specular="1.0, 0.9, 0.9, 1.0"/>
    32     <SpawnPoint team=0 position="-200,0,0" lookat="0,0,0" spawnclass=SpaceShip pawndesign=spaceshipassff />
     32    <SpawnPoint team=0 position="-200,0,0" lookat="0,0,0" spawnclass=SpaceShip pawndesign=spaceshipescort />
    3333   
    3434  </Scene>
  • code/branches/weaponFS15/data/levels/includes/weaponSettingsAssff.oxi

    r10369 r10601  
    1111    </weaponsets>
    1212    <weapons>
    13          
    1413      <WeaponPack>
    1514        <links>
     
    5251        </links>
    5352        <Weapon>
    54           <!EnergyDrink mode=3 munitionpershot=0 delay=0  material="Flares/point_lensflare"muzzleoffset="2,-0.2,-1" /-->
     53          <!--EnergyDrink mode=3 munitionpershot=0 delay=0  material="Flares/point_lensflare"muzzleoffset="2,-0.2,-1" /-->
    5554        </Weapon>
    5655      </WeaponPack>
  • code/branches/weaponFS15/src/modules/objects/ForceField.h

    r10341 r10601  
    161161
    162162            static const std::string modeTube_s;
    163                         static const std::string modeSphere_s;
    164                         static const std::string modeInvertedSphere_s;
    165                         static const std::string modeNewtonianGravity_s;
     163            static const std::string modeSphere_s;
     164            static const std::string modeInvertedSphere_s;
     165            static const std::string modeNewtonianGravity_s;
    166166
    167                         static const std::string modeHomogen_s;
     167            static const std::string modeHomogen_s;
    168168
    169169        private:
  • code/branches/weaponFS15/src/modules/weapons/munitions/GravityBombMunition.cc

    r10455 r10601  
    1212RegisterClass(GravityBombMunition);
    1313
    14         GravityBombMunition::GravityBombMunition(Context* context) : Munition(context)
    15         {
    16                 RegisterObject(GravityBombMunition);
    17                 this->maxMunitionPerMagazine_ = 1;
    18                 this->maxMagazines_ = 30;
    19                 this->magazines_ = 15;
     14    GravityBombMunition::GravityBombMunition(Context* context) : Munition(context)
     15    {
     16        RegisterObject(GravityBombMunition);
     17        this->maxMunitionPerMagazine_ = 1;
     18        this->maxMagazines_ = 30;
     19        this->magazines_ = 15;
    2020
    21                 this->bUseSeparateMagazines_ = false;
    22                 this->bStackMunition_ = true;
     21        this->bUseSeparateMagazines_ = false;
     22        this->bStackMunition_ = true;
    2323
    24                 this->bAllowMunitionRefilling_ = true;
    25                 this->bAllowMultiMunitionRemovementUnderflow_ = false;
    26         }
     24        this->bAllowMunitionRefilling_ = true;
     25        this->bAllowMultiMunitionRemovementUnderflow_ = false;
     26    }
    2727
    2828}
  • code/branches/weaponFS15/src/modules/weapons/munitions/GravityBombMunition.h

    r10455 r10601  
    1414namespace orxonox
    1515{
    16         /**
    17          * @class       GravityBombMunition
    18         *
    19          * @brief       This class is used to set the behaviour of various
    20          *                      munition specific attributes of the GravityBomb like max count of munition per magazine.
    21         *
    22          * @author      Manuel
    23          * @date        23.05.2015
    24         */
    25         class _WeaponsExport GravityBombMunition : public Munition
     16    /**
     17     * @class   GravityBombMunition
     18    *
     19     * @brief   This class is used to set the behaviour of various
     20     *          munition specific attributes of the GravityBomb like max count of munition per magazine.
     21    *
     22     * @author  Manuel
     23     * @date    23.05.2015
     24    */
     25    class _WeaponsExport GravityBombMunition : public Munition
    2626    {
    2727        public:
    28                         GravityBombMunition(Context* context);
     28            GravityBombMunition(Context* context);
    2929            virtual ~GravityBombMunition() {}
    3030    };
  • code/branches/weaponFS15/src/modules/weapons/projectiles/GravityBomb.cc

    r10502 r10601  
    1010
    1111namespace orxonox{
    12         RegisterClass(GravityBomb);
     12    RegisterClass(GravityBomb);
    1313
    14         const float GravityBomb::LIFETIME = 2.5;  ///< The gravity bomb lifetime in seconds.
     14    const float GravityBomb::LIFETIME = 2.5;  ///< The gravity bomb lifetime in seconds.
    1515
    16         GravityBomb::GravityBomb(Context* context):
    17                                 BasicProjectile(),
    18                                 MovableEntity(context),
    19                                 RadarViewable(this,static_cast<WorldEntity*>(this))
    20                 {
    21                         RegisterObject(GravityBomb);
     16    GravityBomb::GravityBomb(Context* context):
     17                BasicProjectile(),
     18                MovableEntity(context),
     19                RadarViewable(this,static_cast<WorldEntity*>(this))
     20        {
     21            RegisterObject(GravityBomb);
    2222
    23                         this->setMass(10.0);
    24                         this->hasCollided_ = false;
    25                         if (GameMode::isMaster())
    26                         {
    27                                 //Define CollisionType of the bomb
    28                                 this->timeToLife_= LIFETIME;
    29                                 this->setCollisionResponse(false);
    30                                 this->setCollisionType(WorldEntity::Dynamic);
    31                                 this->enableCollisionCallback();
     23            this->setMass(10.0);
     24            this->hasCollided_ = false;
     25            if (GameMode::isMaster())
     26            {
     27                //Define CollisionType of the bomb
     28                this->timeToLife_= LIFETIME;
     29                this->setCollisionResponse(false);
     30                this->setCollisionType(WorldEntity::Dynamic);
     31                this->enableCollisionCallback();
    3232
    33                                 //Add Collision Shape
    34                                 SphereCollisionShape* collisionShape = new SphereCollisionShape(context);
    35                                 collisionShape->setRadius(1.0);
    36                                 this->attachCollisionShape(collisionShape);
     33                //Add Collision Shape
     34                SphereCollisionShape* collisionShape = new SphereCollisionShape(context);
     35                collisionShape->setRadius(1.0);
     36                this->attachCollisionShape(collisionShape);
    3737
    38                                 //Create Bomb Model
    39                     Model* rocketModel = new Model(this->getContext());
    40                     rocketModel->setMeshSource("GravityBombRocket.mesh"); //Demo Model from SimpleRocket
    41                     rocketModel->scale(3.0f);
    42                     this->attach(rocketModel);
    43                                 //Add second model because the bomb consists of the bomb and attached rockets (2 separate models)
    44                     Model* bombModel =  new Model(this->getContext());
    45                     bombModel->setMeshSource("GravityBomb.mesh"); //Demo Model from SimpleRocket
    46                                 bombModel->scale(3.0f);
    47                                 this->attach(bombModel);
     38                //Create Bomb Model
     39                Model* rocketModel = new Model(this->getContext());
     40                rocketModel->setMeshSource("GravityBombRocket.mesh"); //Demo Model from SimpleRocket
     41                rocketModel->scale(3.0f);
     42                this->attach(rocketModel);
     43                //Add second model because the bomb consists of the bomb and attached rockets (2 separate models)
     44                Model* bombModel =  new Model(this->getContext());
     45                bombModel->setMeshSource("GravityBomb.mesh"); //Demo Model from SimpleRocket
     46                bombModel->scale(3.0f);
     47                this->attach(bombModel);
    4848
    49                                 //Add particle effect to the flying rockets.
    50                                 ParticleEmitter* fire = new ParticleEmitter(this->getContext());
    51                                 fire->setOrientation(this->getOrientation());
    52                                 fire->setSource("Orxonox/simplerocketfire");
    53                                 this->attach(fire);
     49                //Add particle effect to the flying rockets.
     50                ParticleEmitter* fire = new ParticleEmitter(this->getContext());
     51                fire->setOrientation(this->getOrientation());
     52                fire->setSource("Orxonox/simplerocketfire");
     53                this->attach(fire);
    5454
    55                                 //Add sound effect while the bomb is flying.
    56                                 WorldSound* bombSound = new WorldSound(context);
    57                                 bombSound->setSource("sounds/GravityBombFlight.ogg");
    58                                 bombSound->setLooping(true);
    59                                 bombSound->setVolume(1.0);
    60                                 this->attach(bombSound);
    61                                 bombSound->play();
    62                         }
    63                 }
     55                //Add sound effect while the bomb is flying.
     56                WorldSound* bombSound = new WorldSound(context);
     57                bombSound->setSource("sounds/GravityBombFlight.ogg");
     58                bombSound->setLooping(true);
     59                bombSound->setVolume(1.0);
     60                this->attach(bombSound);
     61                bombSound->play();
     62            }
     63        }
    6464
    65         GravityBomb::~GravityBomb(){}
     65    GravityBomb::~GravityBomb(){}
    6666
    67         void GravityBomb::tick(float dt)
    68         {
    69                 SUPER(GravityBomb, tick, dt);
    70                 timeToLife_ -= dt;
    71                 if (timeToLife_ < 0)
    72                 {
    73                         //orxout(debug_output) << "bomb has stoped moving" <<endl;
    74                         setVelocity(Vector3::ZERO); //Stop the bomb.
    75                         detonate();
    76                         this->destroy();
    77                 }
    78                 else
    79                 {
    80                         if (hasCollided_) detonate();
    81                         destroyCheck(); //Bomb is going to be destroyed by destroyCheck(). As written in BasicProectile, this Method should be called by every Projectile.
    82                 }
    83         }
     67    void GravityBomb::tick(float dt)
     68    {
     69        SUPER(GravityBomb, tick, dt);
     70        timeToLife_ -= dt;
     71        if (timeToLife_ < 0)
     72        {
     73            //orxout(debug_output) << "bomb has stoped moving" <<endl;
     74            setVelocity(Vector3::ZERO); //Stop the bomb.
     75            detonate();
     76            this->destroy();
     77        }
     78        else
     79        {
     80            if (hasCollided_) detonate();
     81            destroyCheck(); //Bomb is going to be destroyed by destroyCheck(). As written in BasicProectile, this Method should be called by every Projectile.
     82        }
     83    }
    8484
    85         bool GravityBomb::collidesAgainst(WorldEntity* otherObject, const btCollisionShape* cs, btManifoldPoint& contactPoint)
    86         {
    87                 hasCollided_ = processCollision(otherObject, contactPoint, cs);
    88                 return hasCollided_;
    89         }
     85    bool GravityBomb::collidesAgainst(WorldEntity* otherObject, const btCollisionShape* cs, btManifoldPoint& contactPoint)
     86    {
     87        hasCollided_ = processCollision(otherObject, contactPoint, cs);
     88        return hasCollided_;
     89    }
    9090
    91         void GravityBomb::detonate()
    92         {
    93                 //Create the GravityBombField and destroy the Projectil.
    94                 GravityBombField* field = new GravityBombField(this->getContext());
    95                 field->setShooter(this->getShooter());
    96                 field->setPosition(getPosition());
    97                 //orxout(debug_output) << "detonating. Creating GravityBombField." <<endl;
    98                 //orxout(debug_output) << "Field is at Position: " << getPosition() << endl;
    99         }
     91    void GravityBomb::detonate()
     92    {
     93        //Create the GravityBombField and destroy the Projectil.
     94        GravityBombField* field = new GravityBombField(this->getContext());
     95        field->setShooter(this->getShooter());
     96        field->setPosition(getPosition());
     97        //orxout(debug_output) << "detonating. Creating GravityBombField." <<endl;
     98        //orxout(debug_output) << "Field is at Position: " << getPosition() << endl;
     99    }
    100100}
    101101
  • code/branches/weaponFS15/src/modules/weapons/projectiles/GravityBomb.h

    r10502 r10601  
    2626namespace orxonox
    2727{
    28         /**
    29          * @class       GravityBomb
    30         *
    31          * @brief       This class implements how long the bomb flies before it places the GravityField at it's last possition.
    32          *                      The field will be created either because the timelimit of the bomb expired or it hit something. After creation of the field,
    33          *                      the projectile (this object) is destroyed.
    34         *
    35          * @author      Manuel Eggimann
    36          * @date        23.05.2015
    37         */
    38         class _WeaponsExport GravityBomb : public BasicProjectile , public MovableEntity, public RadarViewable
    39         {
    40                 public:
    41                         GravityBomb(Context* context);
    42                         virtual ~GravityBomb();
    43                         virtual void tick(float dt);
     28    /**
     29     * @class   GravityBomb
     30    *
     31     * @brief   This class implements how long the bomb flies before it places the GravityField at it's last possition.
     32     *          The field will be created either because the timelimit of the bomb expired or it hit something. After creation of the field,
     33     *          the projectile (this object) is destroyed.
     34    *
     35     * @author  Manuel Eggimann
     36     * @date    23.05.2015
     37    */
     38    class _WeaponsExport GravityBomb : public BasicProjectile , public MovableEntity, public RadarViewable
     39    {
     40        public:
     41            GravityBomb(Context* context);
     42            virtual ~GravityBomb();
     43            virtual void tick(float dt);
    4444
    45                         virtual bool collidesAgainst(WorldEntity* otherObject, const btCollisionShape* cs, btManifoldPoint& contactPoint);
    46                         void detonate();
    47                 private:
    48                 static const float LIFETIME;
     45            virtual bool collidesAgainst(WorldEntity* otherObject, const btCollisionShape* cs, btManifoldPoint& contactPoint);
     46            void detonate();
     47        private:
     48        static const float LIFETIME;
    4949
    50                 bool hasCollided_;
    51                 float timeToLife_; //Time the bomb flies before it explodes.
    52                 WorldSound* bombSound_;
    53         };
     50        bool hasCollided_;
     51        float timeToLife_; //Time the bomb flies before it explodes.
     52        WorldSound* bombSound_;
     53    };
    5454}
    5555#endif /* GravityBOMB_H_ */
  • code/branches/weaponFS15/src/modules/weapons/projectiles/GravityBombField.cc

    r10502 r10601  
    1010
    1111namespace orxonox{
    12         RegisterClass(GravityBombField);
     12    RegisterClass(GravityBombField);
    1313
    14         //Change these constants to alter the behaviour of the field.
    15        
    16         const float GravityBombField::FORCE_FIELD_LIFETIME = 15;
    17         const float GravityBombField::FORCE_SPHERE_START_RADIUS = 250;
    18         const float GravityBombField::FORCE_SPHERE_START_STRENGTH = -700;
    19         const float GravityBombField::PEAK_EXPLOSION_FORCE = 5e4;
    20         const float GravityBombField::FORCE_FIELD_EXPLOSION_DAMMAGE = 100;
    21         const float GravityBombField::EXPLOSION_DURATION = 1;
    22         const float GravityBombField::EXPLOSION_RADIUS = 600;
    23         const float GravityBombField::PEAK_ANGULAR_VELOCITY = 20;
    24         const float GravityBombField::CENTRE_MODEL_END_SIZE = 1.5;
     14    //Change these constants to alter the behaviour of the field.
     15   
     16    const float GravityBombField::FORCE_FIELD_LIFETIME = 15;
     17    const float GravityBombField::FORCE_SPHERE_START_RADIUS = 250;
     18    const float GravityBombField::FORCE_SPHERE_START_STRENGTH = -700;
     19    const float GravityBombField::PEAK_EXPLOSION_FORCE = 5e4;
     20    const float GravityBombField::FORCE_FIELD_EXPLOSION_DAMMAGE = 100;
     21    const float GravityBombField::EXPLOSION_DURATION = 1;
     22    const float GravityBombField::EXPLOSION_RADIUS = 600;
     23    const float GravityBombField::PEAK_ANGULAR_VELOCITY = 20;
     24    const float GravityBombField::CENTRE_MODEL_END_SIZE = 1.5;
    2525
    26         GravityBombField::GravityBombField(Context* context) : ForceField(context),RadarViewable(this, static_cast<WorldEntity*>(this))
    27         {
    28                 RegisterObject(GravityBombField);
    29                 //Initialize variable with their initial values.
    30                 lifetime_=FORCE_FIELD_LIFETIME;
    31                 forceStrength_ = FORCE_SPHERE_START_STRENGTH;
    32                 forceSphereRadius_ = FORCE_SPHERE_START_RADIUS;
    33                 modelScaling_ = 1;
    34                 fieldExploded_ = false;
     26    GravityBombField::GravityBombField(Context* context) : ForceField(context),RadarViewable(this, static_cast<WorldEntity*>(this))
     27    {
     28        RegisterObject(GravityBombField);
     29        //Initialize variable with their initial values.
     30        lifetime_=FORCE_FIELD_LIFETIME;
     31        forceStrength_ = FORCE_SPHERE_START_STRENGTH;
     32        forceSphereRadius_ = FORCE_SPHERE_START_RADIUS;
     33        modelScaling_ = 1;
     34        fieldExploded_ = false;
    3535
    36                 setVelocity(FORCE_SPHERE_START_STRENGTH);
    37                 setDiameter(2*FORCE_SPHERE_START_RADIUS);
    38                 setMode(modeSphere_s);
    39                 setCollisionResponse(false);
     36        setVelocity(FORCE_SPHERE_START_STRENGTH);
     37        setDiameter(2*FORCE_SPHERE_START_RADIUS);
     38        setMode(modeSphere_s);
     39        setCollisionResponse(false);
    4040
    41                 //Make the Field visible on Radar and minimap.
    42                 this->setRadarObjectColour(ColourValue(1.0, 0.0, 0.2,1)); // Red
    43                 this->setRadarObjectShape(RadarViewable::Dot);
    44                 this->setRadarObjectScale(1.0f);
    45                
     41        //Make the Field visible on Radar and minimap.
     42        this->setRadarObjectColour(ColourValue(1.0, 0.0, 0.2,1)); // Red
     43        this->setRadarObjectShape(RadarViewable::Dot);
     44        this->setRadarObjectScale(1.0f);
     45       
    4646
    47                 //Attach Model
    48                 Model* model = new Model(this->getContext());
    49                 model->setMeshSource("GravityBomb.mesh"); //Demo Model from SimpleRocket
    50                 model->scale(2.5f);
    51                 bombModel_ = new MovableEntity(context);
    52                 bombModel_->attach(model);
    53                 this->attach(bombModel_);
     47        //Attach Model
     48        Model* model = new Model(this->getContext());
     49        model->setMeshSource("GravityBomb.mesh"); //Demo Model from SimpleRocket
     50        model->scale(2.5f);
     51        bombModel_ = new MovableEntity(context);
     52        bombModel_->attach(model);
     53        this->attach(bombModel_);
    5454
    55                 //Add a Backlight to the centre.
    56                 centreLight_ = new Backlight(context);
    57                 centreLight_->setColour(ColourValue(0.2,0.9,0.2,1));
    58                 centreLight_->setScale(0.3);
    59                 centreLight_->setTrailMaterial("Trail/backlighttrail");
    60                 centreLight_->setMaterial("Examples/Flare");
    61                 centreLight_->setLifetime(20);
    62                 bombModel_->attach(centreLight_);
     55        //Add a Backlight to the centre.
     56        centreLight_ = new Backlight(context);
     57        centreLight_->setColour(ColourValue(0.2,0.9,0.2,1));
     58        centreLight_->setScale(0.3);
     59        centreLight_->setTrailMaterial("Trail/backlighttrail");
     60        centreLight_->setMaterial("Examples/Flare");
     61        centreLight_->setLifetime(20);
     62        bombModel_->attach(centreLight_);
    6363
    64                 //Let the Bomb Modell in the centre rotate in a random direction.
    65                 Vector3 randomRotation;
    66                 srand(time(NULL));
    67                 randomRotation.x = rand();
    68                 randomRotation.y = rand();
    69                 randomRotation.y = rand();
    70                 randomRotation.normalise();
    71                 bombModel_->setAngularAcceleration(randomRotation*(PEAK_ANGULAR_VELOCITY/FORCE_FIELD_LIFETIME));
     64        //Let the Bomb Modell in the centre rotate in a random direction.
     65        Vector3 randomRotation;
     66        srand(time(NULL));
     67        randomRotation.x = rand();
     68        randomRotation.y = rand();
     69        randomRotation.y = rand();
     70        randomRotation.normalise();
     71        bombModel_->setAngularAcceleration(randomRotation*(PEAK_ANGULAR_VELOCITY/FORCE_FIELD_LIFETIME));
    7272
    73                 //Add Collision Shape
    74                 SphereCollisionShape* collisionShape = new SphereCollisionShape(context);
    75                 collisionShape->setRadius(10.0);
    76                 this->attachCollisionShape(collisionShape);
     73        //Add Collision Shape
     74        SphereCollisionShape* collisionShape = new SphereCollisionShape(context);
     75        collisionShape->setRadius(10.0);
     76        this->attachCollisionShape(collisionShape);
    7777
    78                 //Add particle effect to visualize the force field.
    79                 this->particleSphere_ = new ParticleEmitter(this->getContext());
    80                 this->attach(this->particleSphere_);
    81                 particleSphere_->setSource("Orxonox/GravityBombField");
     78        //Add particle effect to visualize the force field.
     79        this->particleSphere_ = new ParticleEmitter(this->getContext());
     80        this->attach(this->particleSphere_);
     81        particleSphere_->setSource("Orxonox/GravityBombField");
    8282
    83                 //Add a sound effect to the field.
    84                 WorldSound* fieldSound = new WorldSound(context);
    85                 fieldSound->setSource("sounds/GravityField.ogg");
    86                 fieldSound->setLooping(true);
    87                 fieldSound->setVolume(1.0);
    88                 this->attach(fieldSound);
    89                 fieldSound->play();
    90         }
     83        //Add a sound effect to the field.
     84        WorldSound* fieldSound = new WorldSound(context);
     85        fieldSound->setSource("sounds/GravityField.ogg");
     86        fieldSound->setLooping(true);
     87        fieldSound->setVolume(1.0);
     88        this->attach(fieldSound);
     89        fieldSound->play();
     90    }
    9191
    92         GravityBombField::~GravityBombField(){}
     92    GravityBombField::~GravityBombField(){}
    9393
    94        
    95         void GravityBombField::tick(float dt)
    96         {
    97                 SUPER(GravityBombField,tick,dt);
    98                 lifetime_-=dt;
     94   
     95    void GravityBombField::tick(float dt)
     96    {
     97        SUPER(GravityBombField,tick,dt);
     98        lifetime_-=dt;
    9999
    100                 if(lifetime_ > EXPLOSION_DURATION)//If field is still alive, make it smaller and stronger.
    101                 {
    102                         modelScaling_ += ((CENTRE_MODEL_END_SIZE-1) / FORCE_FIELD_LIFETIME)*dt;
    103                         forceStrength_ *= (1+dt/10);
    104                         forceSphereRadius_ = FORCE_SPHERE_START_RADIUS*(1-((FORCE_FIELD_LIFETIME-lifetime_)/FORCE_FIELD_LIFETIME)*((FORCE_FIELD_LIFETIME-lifetime_)/FORCE_FIELD_LIFETIME)*((FORCE_FIELD_LIFETIME-lifetime_)/FORCE_FIELD_LIFETIME));
    105                 }
    106                 else if(lifetime_ > 0)
    107                 {
    108                         if (!fieldExploded_) // Start the field explosion if it has not been started yet.
    109                         {
    110                                 forceStrength_ = pow((EXPLOSION_DURATION + lifetime_),4)/EXPLOSION_DURATION * PEAK_EXPLOSION_FORCE;
    111                                 fieldExploded_ = true;
     100        if(lifetime_ > EXPLOSION_DURATION)//If field is still alive, make it smaller and stronger.
     101        {
     102            modelScaling_ += ((CENTRE_MODEL_END_SIZE-1) / FORCE_FIELD_LIFETIME)*dt;
     103            forceStrength_ *= (1+dt/10);
     104            forceSphereRadius_ = FORCE_SPHERE_START_RADIUS*(1-((FORCE_FIELD_LIFETIME-lifetime_)/FORCE_FIELD_LIFETIME)*((FORCE_FIELD_LIFETIME-lifetime_)/FORCE_FIELD_LIFETIME)*((FORCE_FIELD_LIFETIME-lifetime_)/FORCE_FIELD_LIFETIME));
     105        }
     106        else if(lifetime_ > 0)
     107        {
     108            if (!fieldExploded_) // Start the field explosion if it has not been started yet.
     109            {
     110                forceStrength_ = pow((EXPLOSION_DURATION + lifetime_),4)/EXPLOSION_DURATION * PEAK_EXPLOSION_FORCE;
     111                fieldExploded_ = true;
    112112
    113                                 //Add particle effect to visualize explosion
    114                                 explosionCross_ = new ParticleEmitter(this->getContext());
    115                                 explosionCross_->setSource("Orxonox/FieldExplosion");
    116                                 explosionCross_->setOrientation(rand(), rand(), rand(), rand());
    117                                 explosionCross_->setScale(0.7);
    118                                 this->attach(explosionCross_);
     113                //Add particle effect to visualize explosion
     114                explosionCross_ = new ParticleEmitter(this->getContext());
     115                explosionCross_->setSource("Orxonox/FieldExplosion");
     116                explosionCross_->setOrientation(rand(), rand(), rand(), rand());
     117                explosionCross_->setScale(0.7);
     118                this->attach(explosionCross_);
    119119
    120                                 //Add explosion sound effect.
    121                                 explosionSound_ = new WorldSound(getContext());
    122                                 explosionSound_->setSource("sounds/GravityFieldExplosion.ogg");
    123                                 explosionSound_->setVolume(1.0);
    124                                 explosionSound_->play();
    125                         }
     120                //Add explosion sound effect.
     121                explosionSound_ = new WorldSound(getContext());
     122                explosionSound_->setSource("sounds/GravityFieldExplosion.ogg");
     123                explosionSound_->setVolume(1.0);
     124                explosionSound_->play();
     125            }
    126126
    127                         //Check if any pawn is inside the shockwave and hit it with dammage proportional to the distance between explosion centre and pawn. Make sure, the same pawn is damaged only once.
    128                         for (ObjectList<Pawn>::iterator it = ObjectList<Pawn>::begin(); it != ObjectList<Pawn>::end(); ++it)
    129                         {
    130                                 Vector3 distanceVector = it->getWorldPosition()-this->getWorldPosition();
    131                                 //orxout(debug_output) << "Found Pawn:" << it->getWorldPosition() << endl;
    132                                 if(distanceVector.length()< forceSphereRadius_)
    133                                 {
    134                                         //orxout(debug_output) << "Force sphere radius is: " << forceSphereRadius_ << " Distance to Pawn is: " << distanceVector.length();
    135                                         if (std::find(victimsAlreadyDamaged_.begin(),victimsAlreadyDamaged_.end(),*it) == victimsAlreadyDamaged_.end())
    136                                         {
    137                                                 //orxout(debug_output) << "Found Pawn to damage: " << it->getWorldPosition() << endl;
    138                                                 float damage = FORCE_FIELD_EXPLOSION_DAMMAGE*(1-distanceVector.length()/EXPLOSION_RADIUS);
    139                                                 //orxout(debug_output) << "Damage: " << damage << endl;
    140                                                 it->hit(shooter_, it->getWorldPosition(), NULL, damage, 0,0);
    141                                                 victimsAlreadyDamaged_.push_back(*it);
    142                                         }
    143                                 }
    144                         }
     127            //Check if any pawn is inside the shockwave and hit it with dammage proportional to the distance between explosion centre and pawn. Make sure, the same pawn is damaged only once.
     128            for (ObjectList<Pawn>::iterator it = ObjectList<Pawn>::begin(); it != ObjectList<Pawn>::end(); ++it)
     129            {
     130                Vector3 distanceVector = it->getWorldPosition()-this->getWorldPosition();
     131                //orxout(debug_output) << "Found Pawn:" << it->getWorldPosition() << endl;
     132                if(distanceVector.length()< forceSphereRadius_)
     133                {
     134                    //orxout(debug_output) << "Force sphere radius is: " << forceSphereRadius_ << " Distance to Pawn is: " << distanceVector.length();
     135                    if (std::find(victimsAlreadyDamaged_.begin(),victimsAlreadyDamaged_.end(),*it) == victimsAlreadyDamaged_.end())
     136                    {
     137                        //orxout(debug_output) << "Found Pawn to damage: " << it->getWorldPosition() << endl;
     138                        float damage = FORCE_FIELD_EXPLOSION_DAMMAGE*(1-distanceVector.length()/EXPLOSION_RADIUS);
     139                        //orxout(debug_output) << "Damage: " << damage << endl;
     140                        it->hit(shooter_, it->getWorldPosition(), NULL, damage, 0,0);
     141                        victimsAlreadyDamaged_.push_back(*it);
     142                    }
     143                }
     144            }
    145145
    146                         forceSphereRadius_ = EXPLOSION_RADIUS*(1-lifetime_/EXPLOSION_DURATION);
    147                         explosionCross_->setScale(forceSphereRadius_/FORCE_SPHERE_START_RADIUS);
    148                 }
    149                 else if (lifetime_ > -6) //The field has to exist for 6 more seconds for the particles of the particle effect to vanish smoothly.
    150                 {
    151                         //Make the bomb model invisible, let the strength of the field be zero and remove all particle emitters so the particle effect will slowly vanish.
    152                         bombModel_->setVisible(false);
    153                         this->setRadarVisibility(false);
    154                         forceStrength_ = 0;
    155                         forceSphereRadius_ = 0.00001;
    156                         particleSphere_->getParticleInterface()->removeAllEmitters();
    157                         explosionCross_->getParticleInterface()->removeAllEmitters();
    158                 }
    159                
    160                 setDiameter(forceSphereRadius_*2);
    161                 setVelocity(forceStrength_);
    162                 if(lifetime_>0) particleSphere_->setScale(forceSphereRadius_/FORCE_SPHERE_START_RADIUS);
    163                 bombModel_->setScale(modelScaling_);
     146            forceSphereRadius_ = EXPLOSION_RADIUS*(1-lifetime_/EXPLOSION_DURATION);
     147            explosionCross_->setScale(forceSphereRadius_/FORCE_SPHERE_START_RADIUS);
     148        }
     149        else if (lifetime_ > -6) //The field has to exist for 6 more seconds for the particles of the particle effect to vanish smoothly.
     150        {
     151            //Make the bomb model invisible, let the strength of the field be zero and remove all particle emitters so the particle effect will slowly vanish.
     152            bombModel_->setVisible(false);
     153            this->setRadarVisibility(false);
     154            forceStrength_ = 0;
     155            forceSphereRadius_ = 0.00001;
     156            particleSphere_->getParticleInterface()->removeAllEmitters();
     157            explosionCross_->getParticleInterface()->removeAllEmitters();
     158        }
     159       
     160        setDiameter(forceSphereRadius_*2);
     161        setVelocity(forceStrength_);
     162        if(lifetime_>0) particleSphere_->setScale(forceSphereRadius_/FORCE_SPHERE_START_RADIUS);
     163        bombModel_->setScale(modelScaling_);
    164164
    165                 if (lifetime_ <= -4)
    166                 {
    167                         orxout(debug_output) << "Timeout. Destroying field." << endl;
    168                         this->destroy();
    169                 }
    170         }
     165        if (lifetime_ <= -4)
     166        {
     167            orxout(debug_output) << "Timeout. Destroying field." << endl;
     168            this->destroy();
     169        }
     170    }
    171171
    172         void GravityBombField::destroy()
    173         {
    174                 ForceField::destroy();
    175         }
     172    void GravityBombField::destroy()
     173    {
     174        ForceField::destroy();
     175    }
    176176
    177177}
  • code/branches/weaponFS15/src/modules/weapons/projectiles/GravityBombField.h

    r10455 r10601  
    2727
    2828/**
    29  * @class       GravityBombField
     29 * @class   GravityBombField
    3030 *
    31  * @brief       This class is used by GravityBomb to place the ForceField and Visual effect to the environment.
    32  *                      The field has a maximum lifetime and gets smaller and stronger the more time passes. In the end, the field explodes and damages all pawns nearby.
     31 * @brief   This class is used by GravityBomb to place the ForceField and Visual effect to the environment.
     32 *          The field has a maximum lifetime and gets smaller and stronger the more time passes. In the end, the field explodes and damages all pawns nearby.
    3333 *
    34  * @author      Manuel Eggimann
    35  * @date        23.05.2015
     34 * @author  Manuel Eggimann
     35 * @date    23.05.2015
    3636 */
    3737class GravityBombField: public ForceField, public RadarViewable {
    3838public:
    39         GravityBombField(Context* context);
    40         virtual ~GravityBombField();
    41         virtual void tick(float dt);
    42         virtual void destroy();
     39    GravityBombField(Context* context);
     40    virtual ~GravityBombField();
     41    virtual void tick(float dt);
     42    virtual void destroy();
    4343
    44         /**
    45          * @fn  void GravityBombField::setShooter(Pawn* shooter)
    46         *
    47          * @brief       This function is used to determine save the pawn who created the field and is used inside the GravityBomb class.
    48         *
    49          * @author      Manuel Eggimann
    50          * @date        23.05.2015
    51         *
    52          * @param [in,out]      the Pawn that created the field.
    53         */
    54         void setShooter(Pawn* shooter)
    55         { this->shooter_ = shooter; }
     44    /**
     45     * @fn  void GravityBombField::setShooter(Pawn* shooter)
     46    *
     47     * @brief   This function is used to determine save the pawn who created the field and is used inside the GravityBomb class.
     48    *
     49     * @author  Manuel Eggimann
     50     * @date    23.05.2015
     51    *
     52     * @param [in,out]  the Pawn that created the field.
     53    */
     54    void setShooter(Pawn* shooter)
     55    { this->shooter_ = shooter; }
    5656
    57         Pawn* getShooter()
    58         { return this->shooter_; }
     57    Pawn* getShooter()
     58    { return this->shooter_; }
    5959
    6060private:
    61         //Set these constants inside GravityBombField.cc to alter the behaviour of the field.
    62        
    63         static const float FORCE_FIELD_LIFETIME;        ///< The lifetime of the ForceField in seconds. After lifetime seconds, has already exploded and the particle effects will start to vanish.
    64         static const float FORCE_SPHERE_START_RADIUS;   ///< The initial sphere radius of the Force Field. The forcefield gets smaller by time.
    65         static const float FORCE_SPHERE_START_STRENGTH; ///< The initial Force the Field exerts on every object with non-zero mass.
    66         static const float FORCE_FIELD_EXPLOSION_DAMMAGE;   ///< The maximum dammage a pawn gets nearby an exploding field. The farer away from explosion center the smaller the dammage.
    67         static const float EXPLOSION_DURATION;  ///< Determines how fast the shockwave of the Explosion expands. It takes GravityBombField::EXPLOSION_DURATION seconds for the field to expand from 0 radius to GravityBombField::EXPLOSION_RADIUS.
    68         static const float EXPLOSION_RADIUS;    ///< How far does the shockwave reach. All pawns which outside of a sphere witch this radius rest unharmed by the explosion.
    69         static const float PEAK_ANGULAR_VELOCITY;   ///< The model of the bomb in the center of the Field does rotate faster and faster as time passes until it reaches PEAK_ANGULAR_VELOCITY at the fields end of life.
    70         static const float PEAK_EXPLOSION_FORCE;        ///< The peak force the explosion exerts on the pawns nearby.
    71         static const float CENTRE_MODEL_END_SIZE;   ///< Size of the 3d-model of the bomb in the fields centre.
     61    //Set these constants inside GravityBombField.cc to alter the behaviour of the field.
     62   
     63    static const float FORCE_FIELD_LIFETIME;    ///< The lifetime of the ForceField in seconds. After lifetime seconds, has already exploded and the particle effects will start to vanish.
     64    static const float FORCE_SPHERE_START_RADIUS;   ///< The initial sphere radius of the Force Field. The forcefield gets smaller by time.
     65    static const float FORCE_SPHERE_START_STRENGTH; ///< The initial Force the Field exerts on every object with non-zero mass.
     66    static const float FORCE_FIELD_EXPLOSION_DAMMAGE;   ///< The maximum dammage a pawn gets nearby an exploding field. The farer away from explosion center the smaller the dammage.
     67    static const float EXPLOSION_DURATION;  ///< Determines how fast the shockwave of the Explosion expands. It takes GravityBombField::EXPLOSION_DURATION seconds for the field to expand from 0 radius to GravityBombField::EXPLOSION_RADIUS.
     68    static const float EXPLOSION_RADIUS;    ///< How far does the shockwave reach. All pawns which outside of a sphere witch this radius rest unharmed by the explosion.
     69    static const float PEAK_ANGULAR_VELOCITY;   ///< The model of the bomb in the center of the Field does rotate faster and faster as time passes until it reaches PEAK_ANGULAR_VELOCITY at the fields end of life.
     70    static const float PEAK_EXPLOSION_FORCE;    ///< The peak force the explosion exerts on the pawns nearby.
     71    static const float CENTRE_MODEL_END_SIZE;   ///< Size of the 3d-model of the bomb in the fields centre.
    7272
    73         float forceSphereRadius_;
    74         float forceStrength_;
    75         float lifetime_;
    76         float modelScaling_;
    77         Vector3 rotationVector_;
    78         bool fieldExploded_;
    79         ParticleEmitter * particleSphere_;
    80         ParticleEmitter * explosionCross_;
    81         std::vector<Pawn*> victimsAlreadyDamaged_;
    82         MovableEntity * bombModel_;
    83         Pawn* shooter_;
    84         Backlight* centreLight_;
    85         WorldSound* explosionSound_;
     73    float forceSphereRadius_;
     74    float forceStrength_;
     75    float lifetime_;
     76    float modelScaling_;
     77    Vector3 rotationVector_;
     78    bool fieldExploded_;
     79    ParticleEmitter * particleSphere_;
     80    ParticleEmitter * explosionCross_;
     81    std::vector<Pawn*> victimsAlreadyDamaged_;
     82    MovableEntity * bombModel_;
     83    Pawn* shooter_;
     84    Backlight* centreLight_;
     85    WorldSound* explosionSound_;
    8686};
    8787
  • code/branches/weaponFS15/src/modules/weapons/weaponmodes/GravityBombFire.cc

    r10503 r10601  
    1717namespace orxonox
    1818{
    19         RegisterClass(GravityBombFire);
     19    RegisterClass(GravityBombFire);
    2020
    21         const float GravityBombFire::BOMB_VELOCITY = 600.0; ///< The velocity of the bomb after launch
     21    const float GravityBombFire::BOMB_VELOCITY = 600.0; ///< The velocity of the bomb after launch
    2222
    23         GravityBombFire::GravityBombFire(Context* context) : WeaponMode(context)
    24         {
    25                 RegisterObject(GravityBombFire);
     23    GravityBombFire::GravityBombFire(Context* context) : WeaponMode(context)
     24    {
     25        RegisterObject(GravityBombFire);
    2626
    27                 this->reloadTime_ = 0.50f;
    28                 this->bParallelReload_ = false;
    29                 this->damage_ = 20.0f;  ///< The damage of the Bomb if it hits a pawn.
     27        this->reloadTime_ = 0.50f;
     28        this->bParallelReload_ = false;
     29        this->damage_ = 20.0f;  ///< The damage of the Bomb if it hits a pawn.
    3030
    31                 this->setMunitionName("GravityBombMunition");
    32                 this->setDefaultSoundWithVolume("sounds/Rocket_launch.ogg",0.8);        ///< sets sound of the bomb as it is fired.
    33         }
     31        this->setMunitionName("GravityBombMunition");
     32        this->setDefaultSoundWithVolume("sounds/Rocket_launch.ogg",0.8);    ///< sets sound of the bomb as it is fired.
     33    }
    3434
    35         GravityBombFire::~GravityBombFire(){};
     35    GravityBombFire::~GravityBombFire(){};
    3636
    37         void GravityBombFire::fire()
    38         {
    39                 GravityBomb* bomb = new GravityBomb(this->getContext());
     37    void GravityBombFire::fire()
     38    {
     39        GravityBomb* bomb = new GravityBomb(this->getContext());
    4040        //Create a new Bomb in 3D-Space and set the right direction speed and orientation.
    41                 this->computeMuzzleParameters(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn()->getAimPosition());
     41        this->computeMuzzleParameters(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn()->getAimPosition());
    4242        bomb->setOrientation(this->getMuzzleOrientation());
    4343        bomb->setPosition(this->getMuzzlePosition());
    4444        bomb->setVelocity(this->getMuzzleDirection() * (this->BOMB_VELOCITY+this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn()->getVelocity().length()));
    4545
    46                 //Set the shooter of the bomb so it is possible to determine the pawn that killed another one and define damage to shield and healt the bomb does.
     46        //Set the shooter of the bomb so it is possible to determine the pawn that killed another one and define damage to shield and healt the bomb does.
    4747        bomb->setShooter(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn());
    48                 bomb->setDamage(this->getDamage());
    49                 bomb->setShieldDamage(this->getShieldDamage());
    50                 bomb->setHealthDamage(this->getHealthDamage());
    51         }
     48        bomb->setDamage(this->getDamage());
     49        bomb->setShieldDamage(this->getShieldDamage());
     50        bomb->setHealthDamage(this->getHealthDamage());
     51    }
    5252
    5353
Note: See TracChangeset for help on using the changeset viewer.