Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 10293


Ignore:
Timestamp:
Mar 1, 2015, 8:59:15 PM (10 years ago)
Author:
landauf
Message:

avoid collisions between projectiles of a turret and the parent-pawn to which the turret is attached

Location:
code/trunk/src/modules/weapons/projectiles
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/trunk/src/modules/weapons/projectiles/BasicProjectile.cc

    r10287 r10293  
    8282        if (!this->bDestroy_ && GameMode::isMaster())
    8383        {
    84             if (otherObject == this->getShooter() || otherObject->isA(Class(BasicProjectile))) // Prevents you from shooting yourself or other projectiles
     84            if (this->isObjectRelatedToShooter(otherObject) || otherObject->isA(Class(BasicProjectile))) // Prevents you from shooting yourself or other projectiles
    8585                return false;
    8686
     
    141141    }
    142142
     143    /**
     144     * Returns true if otherObject is equal to the shooter or if one of otherObject's parents is equal to the shooter or if one of the shooter's parent is equal to otherObject.
     145     */
     146    bool BasicProjectile::isObjectRelatedToShooter(WorldEntity* otherObject)
     147    {
     148        for (WorldEntity* shooter = this->getShooter(); shooter != NULL; shooter = shooter->getParent())
     149            if (otherObject == shooter)
     150                return true;
     151        for (WorldEntity* object = otherObject; object != NULL; object = object->getParent())
     152            if (otherObject == this->getShooter())
     153                return true;
     154
     155        return false;
     156    }
    143157
    144158    /**
  • code/trunk/src/modules/weapons/projectiles/BasicProjectile.h

    r10216 r10293  
    123123
    124124        private:
     125            bool isObjectRelatedToShooter(WorldEntity* otherObject);
     126
    125127            WeakPtr<Pawn> shooter_; //!< The entity that fired the projectile.
    126128
Note: See TracChangeset for help on using the changeset viewer.