Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 27, 2015, 4:23:44 PM (9 years ago)
Author:
meggiman
Message:

Bugfix: Game crashed if a pawn was directly hit by the bomb. Changed Radar Color to red.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/weaponFS15/src/modules/weapons/projectiles/GravityBomb.cc

    r10455 r10502  
    1212        RegisterClass(GravityBomb);
    1313
    14         const float GravityBomb::LIFETIME = 5;  ///< The gravity bomb lifetime in seconds.
     14        const float GravityBomb::LIFETIME = 2.5;  ///< The gravity bomb lifetime in seconds.
    1515
    1616        GravityBomb::GravityBomb(Context* context):
     
    2222
    2323                        this->setMass(10.0);
    24                         this->isDetonated_ = false;
     24                        this->hasCollided_ = false;
    2525                        if (GameMode::isMaster())
    2626                        {
     
    6767        void GravityBomb::tick(float dt)
    6868        {
    69                         timeToLife_ -= dt;
    70                         if(timeToLife_ < 0)
    71                         {
    72                                 //orxout(debug_output) << "bomb has stoped moving" <<endl;
    73                                 setVelocity(Vector3::ZERO); //Stop the bomb.
    74                                 isDetonated_ = true;
    75                         }
    76                         else
    77                         {
    78                                 //orxout(debug_output)<< "Time to live:" << timeToLife_ <<endl;
    79                                 destroyCheck(); //Every BasicProjectil has to call this method in each tick.
    80                         }
    81                         if(isDetonated_) detonate();
    82                         else SUPER(GravityBomb, tick, dt);
     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                }
    8383        }
    8484
    8585        bool GravityBomb::collidesAgainst(WorldEntity* otherObject, const btCollisionShape* cs, btManifoldPoint& contactPoint)
    8686        {
    87                 if(otherObject != getShooter()) //Ensure that the bomb cannot collide with its shooter.
    88                 {
    89                         orxout(debug_output) << "collides" << endl;
    90                         processCollision(otherObject, contactPoint,cs);
    91                         isDetonated_ = true;
    92                         return true;
    93                 }
    94                 else{
    95                         //orxout(debug_output) << "collided with shooter. Has no effect..." << endl;
    96                         return false;
    97                 }
     87                hasCollided_ = processCollision(otherObject, contactPoint, cs);
     88                return hasCollided_;
    9889        }
    9990
     
    10697                //orxout(debug_output) << "detonating. Creating GravityBombField." <<endl;
    10798                //orxout(debug_output) << "Field is at Position: " << getPosition() << endl;
    108                 this->destroy();
    10999        }
    110100}
Note: See TracChangeset for help on using the changeset viewer.