Changeset 10293 for code/trunk
- Timestamp:
- Mar 1, 2015, 8:59:15 PM (10 years ago)
- Location:
- code/trunk/src/modules/weapons/projectiles
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk/src/modules/weapons/projectiles/BasicProjectile.cc
r10287 r10293 82 82 if (!this->bDestroy_ && GameMode::isMaster()) 83 83 { 84 if ( otherObject == this->getShooter() || otherObject->isA(Class(BasicProjectile))) // Prevents you from shooting yourself or other projectiles84 if (this->isObjectRelatedToShooter(otherObject) || otherObject->isA(Class(BasicProjectile))) // Prevents you from shooting yourself or other projectiles 85 85 return false; 86 86 … … 141 141 } 142 142 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 } 143 157 144 158 /** -
code/trunk/src/modules/weapons/projectiles/BasicProjectile.h
r10216 r10293 123 123 124 124 private: 125 bool isObjectRelatedToShooter(WorldEntity* otherObject); 126 125 127 WeakPtr<Pawn> shooter_; //!< The entity that fired the projectile. 126 128
Note: See TracChangeset
for help on using the changeset viewer.