Changeset 6905 for code/branches/rocket/src/modules/weapons
- Timestamp:
- May 15, 2010, 6:12:13 PM (15 years ago)
- Location:
- code/branches/rocket/src/modules/weapons
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/rocket/src/modules/weapons/RocketController.cc
r6904 r6905 63 63 { 64 64 haha++; 65 65 66 66 67 SimpleRocket *rocket = static_cast<SimpleRocket*>(this->getControllableEntity()); 68 if (haha<30)rocket->setVelocity(rocket->getVelocity()*1.03); 67 69 if (this->target_) { 68 rocket->rotatePitch(0.5); 69 rocket->rotateYaw(0.5); 70 this->setTargetPosition(); 71 this->moveToTargetPosition(); 72 70 73 } 71 rocket->setVelocity(rocket->getVelocity()*1.03); 74 75 if (haha>500) rocket->setDestroy();; 72 76 73 77 } … … 80 84 } 81 85 86 void RocketController::setTargetPosition() { 87 this->targetPosition_=this->target_->getPosition(); 88 //this->targetPosition_ = getPredictedPosition(this->getControllableEntity()->getPosition(),this->getControllableEntity()->getVelocity().length() , this->target_->getPosition(), this->target_->getVelocity()); 89 } 90 void RocketController::moveToTargetPosition() { 91 this->moveToPosition(this->targetPosition_); 92 } 82 93 83 void RocketController::setTarget(Pawn* target) { 94 95 96 void RocketController::setTarget(WorldEntity* target) { 84 97 this->target_ = target; 98 COUT(0)<<"got target\n"; 85 99 } 100 101 void RocketController::moveToPosition(const Vector3& target) 102 { 103 if (!this->getControllableEntity()) 104 return; 105 106 COUT(0)<<"moving"; 107 108 Vector2 coord = get2DViewdirection(this->getControllableEntity()->getPosition(), this->getControllableEntity()->getOrientation() * WorldEntity::FRONT, this->getControllableEntity()->getOrientation() * WorldEntity::UP, target); 109 float distance = (target - this->getControllableEntity()->getPosition()).length(); 110 111 if (this->target_ || distance > 10) 112 { 113 // Multiply with 0.8 to make them a bit slower 114 this->getControllableEntity()->rotateYaw(-0.2f * sgn(coord.x) * coord.x*coord.x); 115 this->getControllableEntity()->rotatePitch(0.2f * sgn(coord.y) * coord.y*coord.y); 116 117 } 118 } 86 119 87 120 -
code/branches/rocket/src/modules/weapons/RocketController.h
r6903 r6905 53 53 virtual void tick(float dt); 54 54 SimpleRocket* getRocket(){return this->rocket;}; 55 void setTarget( Pawn* target);55 void setTarget(WorldEntity* target); 56 56 protected: 57 57 void moveToPosition(const Vector3& target); 58 void setTargetPosition(); 59 void moveToTargetPosition(); 58 60 59 61 private: 60 62 SimpleRocket* rocket; 63 Vector3 targetPosition_; 61 64 WeakPtr<PlayerInfo> player_; 62 65 int haha; 63 WeakPtr< Pawn> target_;66 WeakPtr<WorldEntity> target_; 64 67 65 68 -
code/branches/rocket/src/modules/weapons/projectiles/SimpleRocket.cc
r6902 r6905 180 180 } 181 181 } 182 void SimpleRocket::setDestroy() { 183 this->bDestroy_=true; 184 COUT(0)<<"trying to destroy"; 185 } 182 186 183 187 void SimpleRocket::fired(unsigned int firemode) -
code/branches/rocket/src/modules/weapons/projectiles/SimpleRocket.h
r6900 r6905 64 64 virtual void rotatePitch(const Vector2& value); 65 65 virtual void rotateRoll(const Vector2& value); 66 void setDestroy(); 66 67 67 68 /** … … 95 96 */ 96 97 inline void rotatePitch(float value) 97 { this->rotatePitch(Vector2(value, 0)); } 98 { COUT(0)<<"rotated rocket yaw"; 99 this->rotatePitch(Vector2(value, 0)); } 98 100 /** 99 101 @brief Rotates the SimpleRocket around the z-axis by the specifed amount. … … 101 103 */ 102 104 inline void rotateRoll(float value) 103 { this->rotateRoll(Vector2(value, 0)); } 105 { 106 COUT(0)<<"rotated rocket roll"; 107 this->rotateRoll(Vector2(value, 0)); } 104 108 105 109 void setOwner(Pawn* owner); -
code/branches/rocket/src/modules/weapons/weaponmodes/SimpleRocketFire.cc
r6900 r6905 69 69 rocket->setVelocity(this->getMuzzleDirection()*this->speed_); 70 70 rocket->setOwner(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn()); 71 rocket->setDamage(this->damage_); 72 WorldEntity* pawnn=(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn()->getTarget()); 73 if (pawnn) { 74 con->setTarget(pawnn); 75 } 71 76 } 72 77 }
Note: See TracChangeset
for help on using the changeset viewer.