Changeset 6943 for code/branches/rocket/src/modules
- Timestamp:
- May 20, 2010, 9:04:46 PM (14 years ago)
- Location:
- code/branches/rocket/src/modules/weapons
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/rocket/src/modules/weapons/RocketController.cc
r6905 r6943 63 63 { 64 64 haha++; 65 66 65 67 SimpleRocket *rocket = static_cast<SimpleRocket*>(this->getControllableEntity()); 68 if (haha<30)rocket->setVelocity(rocket->getVelocity()*1.03); 66 //if (haha<30)this->rocket->setVelocity(rocket->getVelocity()*1.03); 69 67 if (this->target_) { 70 68 this->setTargetPosition(); 71 69 this->moveToTargetPosition(); 72 73 70 } 74 75 71 if (haha>500) rocket->setDestroy();; 76 72 … … 85 81 86 82 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());83 //this->targetPosition_=this->target_->getWorldPosition(); 84 this->targetPosition_ = getPredictedPosition(this->getControllableEntity()->getPosition(),this->getControllableEntity()->getVelocity().length() , this->target_->getPosition(), this->target_->getVelocity()); 89 85 } 90 86 void RocketController::moveToTargetPosition() { … … 103 99 if (!this->getControllableEntity()) 104 100 return; 105 106 COUT(0)<<"moving"; 107 101 float dx = target.x-this->getControllableEntity()->getPosition().x; 102 float dy = target.y-this->getControllableEntity()->getPosition().y; 103 COUT(0)<<"\n diff: "; 104 COUT(0)<<target.x-this->getControllableEntity()->getPosition().x; 105 COUT(0)<<" "; 106 COUT(0)<<target.y-this->getControllableEntity()->getPosition().y; 107 COUT(0)<<" "; 108 COUT(0)<<target.z-this->getControllableEntity()->getPosition().z; 109 //COUT(0)<<"\n 2D view: "; 110 /* COUT(0)<<this->getControllableEntity()->getPosition().x; 111 COUT(0)<<" "; 112 COUT(0)<<this->getControllableEntity()->getPosition().y; 113 COUT(0)<<" "; 114 COUT(0)<<this->getControllableEntity()->getPosition().z; 115 COUT(0)<<"\n";*/ 108 116 Vector2 coord = get2DViewdirection(this->getControllableEntity()->getPosition(), this->getControllableEntity()->getOrientation() * WorldEntity::FRONT, this->getControllableEntity()->getOrientation() * WorldEntity::UP, target); 109 117 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 //Vector3D diff =target-this->rocket->getPosition(); 119 //COUT(0)<<coord.x; 120 //COUT(0)<<" "; 121 //COUT(0)<<coord.y; 122 this->getControllableEntity()->rotateYaw(coord.x*coord.x*coord.x*coord.x); 123 this->getControllableEntity()->rotatePitch(coord.y*coord.y* coord.y*coord.y); 124 //this->getControllableEntity()->rotatePitch(rotation.getPitch().valueRadians()); 125 //this->getControllableEntity()->rotateYaw(rotation.getYaw().valueRadians()); 126 //this->getControllableEntity()->moveUpDown(coord.y); 127 //this->getControllableEntity()->moveRightLeft(coord.x); 128 //this->getControllableEntity()->rotatePitch(coord); 129 // if (this->target_ || distance > 10) 130 // { 131 // // Multiply with 0.8 to make them a bit slower 132 //this->getControllableEntity()->rotateYaw(coord.x ); 133 // this->getControllableEntity()->rotatePitch(coord.y); 134 // 135 // } 118 136 } 119 137 -
code/branches/rocket/src/modules/weapons/weaponmodes/SimpleRocketFire.cc
r6905 r6943 49 49 this->bParallelReload_ = false; 50 50 this->damage_ = 100; 51 this->speed_ = 50;51 this->speed_ = 1; 52 52 53 53 this->setMunitionName("LaserMunition"); … … 67 67 Vector3 pos = this->getMuzzlePosition() + (this->getMuzzleOrientation()* Vector3(-2, -3, -2)); 68 68 rocket->setPosition(pos); 69 rocket->setAcceleration(20*rocket->getOrientation() * WorldEntity::FRONT); 69 70 rocket->setVelocity(this->getMuzzleDirection()*this->speed_); 70 71 rocket->setOwner(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn()); 71 72 rocket->setDamage(this->damage_); 72 WorldEntity* pawnn= (this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn()->getTarget());73 WorldEntity* pawnn=this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn()->getTarget(); 73 74 if (pawnn) { 74 75 con->setTarget(pawnn);
Note: See TracChangeset
for help on using the changeset viewer.