Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

File:
1 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    /**
Note: See TracChangeset for help on using the changeset viewer.