- Timestamp:
- Dec 17, 2008, 2:10:11 AM (16 years ago)
- Location:
- code/branches/presentation
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/presentation
- Property svn:mergeinfo changed
/code/branches/weapon2 (added) merged: 2108,2145,2186,2203,2232,2272-2273,2288,2308,2319,2327,2331,2337,2347,2354,2366-2368,2379,2391,2393,2398,2410
- Property svn:mergeinfo changed
-
code/branches/presentation/src/orxonox/objects/controllers/AIController.cc
r2485 r2493 57 57 float random; 58 58 float maxrand = 100.0f / ACTION_INTERVAL; 59 /* 59 60 60 // search enemy 61 61 random = rnd(maxrand); … … 72 72 if (random < 10 && (this->target_)) 73 73 this->searchNewTarget(); 74 */ 74 75 75 // fly somewhere 76 76 random = rnd(maxrand); … … 87 87 if (random < 30 && (this->bHasTargetPosition_ && !this->target_)) 88 88 this->searchRandomTargetPosition(); 89 /* 89 90 90 // shoot 91 91 random = rnd(maxrand); … … 97 97 if (random < 25 && (this->bShooting_)) 98 98 this->bShooting_ = false; 99 */100 99 } 101 100 … … 112 111 113 112 if (this->getControllableEntity() && this->bShooting_ && this->isCloseAtTarget(500) && this->isLookingAtTarget(Ogre::Math::PI / 20.0)) 114 this->getControllableEntity()->fire( );113 this->getControllableEntity()->fire(WeaponMode::fire); 115 114 116 115 SUPER(AIController, tick, dt); -
code/branches/presentation/src/orxonox/objects/controllers/ArtificialController.cc
r2485 r2493 56 56 57 57 Vector2 coord = get2DViewdirection(this->getControllableEntity()->getPosition(), this->getControllableEntity()->getOrientation() * WorldEntity::FRONT, this->getControllableEntity()->getOrientation() * WorldEntity::UP, this->targetPosition_); 58 float distance = (this->targetPosition_ - this->getControllableEntity()->getPosition()).length(); 58 59 59 float distance = (this->targetPosition_ - this->getControllableEntity()->getPosition()).length(); 60 if (this->target_ || distance > 50) 60 if (this->target_ || distance > 10) 61 61 { 62 62 // Multiply with 0.8 to make them a bit slower 63 this->getControllableEntity()->rotateYaw( 0.8 * sgn(coord.x) * coord.x*coord.x);63 this->getControllableEntity()->rotateYaw(-0.8 * sgn(coord.x) * coord.x*coord.x); 64 64 this->getControllableEntity()->rotatePitch(0.8 * sgn(coord.y) * coord.y*coord.y); 65 65 } 66 66 67 if (this->target_ && distance < 1000 && this->getControllableEntity()->getVelocity().squaredLength() > this->target_->getVelocity().squaredLength())67 if (this->target_ && distance < 200 && this->getControllableEntity()->getVelocity().squaredLength() > this->target_->getVelocity().squaredLength()) 68 68 this->getControllableEntity()->moveFrontBack(-0.5); // They don't brake with full power to give the player a chance 69 69 else … … 73 73 void ArtificialController::searchRandomTargetPosition() 74 74 { 75 this->targetPosition_ = Vector3(rnd(- 5000,5000), rnd(-5000,5000), rnd(-5000,5000));75 this->targetPosition_ = Vector3(rnd(-2000,2000), rnd(-2000,2000), rnd(-2000,2000)); 76 76 this->bHasTargetPosition_ = true; 77 77 } … … 88 88 { 89 89 // if (it->getTeamNr() != this->getTeamNr()) 90 if ((ControllableEntity*)(*it) != this->getControllableEntity()) 90 91 { 91 92 float speed = this->getControllableEntity()->getVelocity().length(); … … 113 114 return; 114 115 115 static const float hardcoded_projectile_speed = 500;116 static const float hardcoded_projectile_speed = 1250; 116 117 117 this->targetPosition_ = getPredictedPosition(this->getControllableEntity()->getPosition(), hardcoded_projectile_speed, this->target_->getPosition(), this->target_->get Orientation() * this->target_->getVelocity());118 this->targetPosition_ = getPredictedPosition(this->getControllableEntity()->getPosition(), hardcoded_projectile_speed, this->target_->getPosition(), this->target_->getVelocity()); 118 119 this->bHasTargetPosition_ = (this->targetPosition_ != Vector3::ZERO); 119 120 } … … 138 139 } 139 140 140 void ArtificialController:: shipDied(Pawn* ship)141 void ArtificialController::destroyedPawn(Pawn* ship) 141 142 { 142 143 if (ship == this->target_) -
code/branches/presentation/src/orxonox/objects/controllers/ArtificialController.h
r2485 r2493 33 33 34 34 #include "Controller.h" 35 #include "objects/worldentities/pawns/Pawn.h" 35 36 #include "util/Math.h" 36 37 37 38 namespace orxonox 38 39 { 39 class _OrxonoxExport ArtificialController : public Controller 40 class _OrxonoxExport ArtificialController : public Controller, public PawnListener 40 41 { 41 42 public: … … 43 44 virtual ~ArtificialController(); 44 45 45 v oid shipDied(Pawn* ship);46 virtual void destroyedPawn(Pawn* pawn); 46 47 47 48 protected: -
code/branches/presentation/src/orxonox/objects/controllers/HumanController.cc
r2485 r2493 110 110 { 111 111 if (HumanController::localController_s && HumanController::localController_s->controllableEntity_) 112 HumanController::localController_s->controllableEntity_->fire( );112 HumanController::localController_s->controllableEntity_->fire(WeaponMode::fire); 113 113 } 114 114 … … 116 116 { 117 117 if (HumanController::localController_s && HumanController::localController_s->controllableEntity_) 118 HumanController::localController_s->controllableEntity_-> altFire();118 HumanController::localController_s->controllableEntity_->fire(WeaponMode::altFire); 119 119 } 120 120
Note: See TracChangeset
for help on using the changeset viewer.