Changeset 6951 for code/branches/presentation3/src/modules/weapons
- Timestamp:
- May 21, 2010, 10:25:27 AM (15 years ago)
- Location:
- code/branches/presentation3
- Files:
-
- 4 edited
- 8 copied
Legend:
- Unmodified
- Added
- Removed
-
code/branches/presentation3
- Property svn:mergeinfo changed
/code/branches/rocket (added) merged: 6778-6781,6783-6785,6803,6809-6811,6813-6818,6827,6834,6863,6878,6900,6902-6905,6943,6948-6950
- Property svn:mergeinfo changed
-
code/branches/presentation3/src/modules/weapons/CMakeLists.txt
r5781 r6951 1 1 SET_SOURCE_FILES(WEAPONS_SRC_FILES 2 2 MuzzleFlash.cc 3 RocketController.cc 3 4 ) 4 5 -
code/branches/presentation3/src/modules/weapons/RocketController.cc
r6950 r6951 43 43 RocketController::RocketController(BaseObject* creator) : Controller(creator) 44 44 { 45 46 COUT(0)<< "RocketController constructed\n";45 RegisterObject(RocketController); 46 COUT(5)<< "RocketController constructed\n"; 47 47 48 48 49 50 51 52 49 this->rocket = new SimpleRocket(this); 50 this->rocket->setController(this); 51 this->setControllableEntity(dynamic_cast<ControllableEntity*> (rocket)); 52 this->haha=0; 53 53 } 54 54 … … 62 62 void RocketController::tick(float dt) 63 63 { 64 64 haha++; 65 65 66 67 68 69 70 71 72 73 66 //if (haha<30)this->rocket->setVelocity(rocket->getVelocity()*1.03); 67 if (this->target_) { 68 this->setTargetPosition(); 69 this->moveToTargetPosition(); 70 } 71 if (haha>500) rocket->setDestroy();; 72 73 } 74 74 75 75 76 RocketController::~RocketController() { 76 RocketController::~RocketController() 77 { 78 COUT(5)<< "RocketController destroyed\n"; 79 } 77 80 78 79 COUT(0)<< "RocketController destroyed\n"; 80 } 81 82 void RocketController::setTargetPosition() { 83 //this->targetPosition_=this->target_->getWorldPosition(); 84 this->targetPosition_ = getPredictedPosition(this->getControllableEntity()->getWorldPosition(),this->getControllableEntity()->getVelocity().length() , this->target_->getWorldPosition(), this->target_->getVelocity()); 85 } 86 void RocketController::moveToTargetPosition() { 87 this->moveToPosition(this->targetPosition_); 88 } 81 void RocketController::setTargetPosition() 82 { 83 //this->targetPosition_=this->target_->getWorldPosition(); 84 this->targetPosition_ = getPredictedPosition(this->getControllableEntity()->getWorldPosition(),this->getControllableEntity()->getVelocity().length() , this->target_->getWorldPosition(), this->target_->getVelocity()); 85 } 86 void RocketController::moveToTargetPosition() 87 { 88 this->moveToPosition(this->targetPosition_); 89 } 89 90 90 91 91 92 92 void RocketController::setTarget(WorldEntity* target) { 93 this->target_ = target; 94 COUT(0)<<"got target\n"; 95 } 93 void RocketController::setTarget(WorldEntity* target) 94 { 95 this->target_ = target; 96 COUT(0)<<"got target\n"; 97 } 96 98 97 99 void RocketController::moveToPosition(const Vector3& target) 98 100 { 99 if (!this->getControllableEntity())101 if (!this->getControllableEntity()) 100 102 return; 101 102 103 COUT(0)<<"\n diff: ";104 COUT(0)<<target-this->getControllableEntity()->getPosition() << endl;105 106 107 108 109 110 111 103 float dx = target.x-this->getControllableEntity()->getPosition().x; 104 float dy = target.y-this->getControllableEntity()->getPosition().y; 105 COUT(4)<<"\n diff: "; 106 COUT(4)<<target-this->getControllableEntity()->getPosition() << endl; 107 //COUT(0)<<"\n 2D view: "; 108 /* COUT(0)<<this->getControllableEntity()->getPosition().x; 109 COUT(0)<<" "; 110 COUT(0)<<this->getControllableEntity()->getPosition().y; 111 COUT(0)<<" "; 112 COUT(0)<<this->getControllableEntity()->getPosition().z; 113 COUT(0)<<"\n";*/ 112 114 Vector2 coord = get2DViewdirection(this->getControllableEntity()->getPosition(), this->getControllableEntity()->getOrientation() * WorldEntity::FRONT, this->getControllableEntity()->getOrientation() * WorldEntity::UP, target); 113 115 float distance = (target - this->getControllableEntity()->getPosition()).length(); 114 115 COUT(0) << "viewdirection: "<< coord << endl;116 117 116 //Vector3D diff =target-this->rocket->getPosition(); 117 COUT(4) << "viewdirection: "<< coord << endl; 118 //COUT(0)<<" "; 119 //COUT(0)<<coord.y; 118 120 this->getControllableEntity()->rotateYaw(-0.8f*sgn(coord.x)*coord.x*coord.x); 119 121 this->getControllableEntity()->rotatePitch(0.8f*sgn(coord.y)*coord.y*coord.y); 120 122 // this->getControllableEntity()->rotateYaw(10); 121 123 // this->getControllableEntity()->rotatePitch(0); 122 123 124 125 126 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); 127 129 // if (this->target_ || distance > 10) 128 130 // { 129 131 // // Multiply with 0.8 to make them a bit slower 130 132 //this->getControllableEntity()->rotateYaw(coord.x ); 131 133 // this->getControllableEntity()->rotatePitch(coord.y); 132 //133 134 // } 134 135 } -
code/branches/presentation3/src/modules/weapons/projectiles/CMakeLists.txt
r6417 r6951 5 5 LightningGunProjectile.cc 6 6 Rocket.cc 7 SimpleRocket.cc 7 8 ) -
code/branches/presentation3/src/modules/weapons/projectiles/SimpleRocket.cc
r6950 r6951 59 59 this->bDestroy_ = false; 60 60 this->lifetime_ = 100; 61 COUT(0)<< "simplerocket constructed\n";61 COUT(4) << "simplerocket constructed\n"; 62 62 63 63 … … 91 91 92 92 } 93 void SimpleRocket::tick(float dt) 93 94 void SimpleRocket::tick(float dt) 94 95 { 95 96 SUPER(SimpleRocket, tick, dt); … … 102 103 this->destroy(); 103 104 104 105 } 105 106 106 107 /**s … … 110 111 SimpleRocket::~SimpleRocket() 111 112 { 112 if (this->isInitialized()) { 113 this->getController()->destroy(); 114 COUT(0)<< "simplerocket destroyed\n"; 115 } 116 } 113 if (this->isInitialized()) 114 { 115 this->getController()->destroy(); 116 COUT(4)<< "simplerocket destroyed\n"; 117 } 118 } 117 119 118 120 /** … … 165 167 166 168 float dmg = this->damage_; 167 if (this->owner_)168 dmg = this->owner_->getPickups().processModifiers(ModifierType::Damage, dmg, false);169 // if (this->owner_) 170 // dmg = this->owner_->getPickups().processModifiers(ModifierType::Damage, dmg, false); 169 171 170 172 Pawn* victim = orxonox_cast<Pawn*>(otherObject); … … 182 184 } 183 185 } 184 void SimpleRocket::setDestroy() { 185 this->bDestroy_=true; 186 COUT(0)<<"trying to destroy"; 187 } 186 187 void SimpleRocket::setDestroy() 188 { 189 this->bDestroy_=true; 190 CCOUT(4)<<"trying to destroy"; 191 } 188 192 189 193 void SimpleRocket::fired(unsigned int firemode) -
code/branches/presentation3/src/modules/weapons/weaponmodes/CMakeLists.txt
r6417 r6951 6 6 LightningGun.cc 7 7 RocketFire.cc 8 SimpleRocketFire.cc 8 9 ) -
code/branches/presentation3/src/modules/weapons/weaponmodes/SimpleRocketFire.cc
r6950 r6951 61 61 void SimpleRocketFire::fire() 62 62 { 63 64 65 66 // 63 RocketController* con = new RocketController(this); 64 SimpleRocket* rocket = con->getRocket(); 65 this->computeMuzzleParameters(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn()->getAimPosition()); 66 // rocket->setOrientation(this->getMuzzleOrientation()); 67 67 rocket->setOrientation(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn()->getWorldOrientation()); 68 68 Vector3 pos = this->getMuzzlePosition(); 69 69 rocket->setPosition(pos); 70 // rocket->setAcceleration(20*rocket->getOrientation() * WorldEntity::FRONT); 71 rocket->setVelocity(this->getMuzzleDirection()*this->speed_); 72 rocket->setOwner(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn()); 73 rocket->setDamage(this->damage_); 74 WorldEntity* pawnn=this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn()->getTarget(); 75 if (pawnn) { 76 con->setTarget(pawnn); 77 } 70 // rocket->setAcceleration(20*rocket->getOrientation() * WorldEntity::FRONT); 71 rocket->setVelocity(this->getMuzzleDirection()*this->speed_); 72 rocket->setOwner(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn()); 73 rocket->setDamage(this->damage_); 74 WorldEntity* pawnn=static_cast<ControllableEntity*>(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn())->getTarget(); 75 if (pawnn) 76 { 77 con->setTarget(pawnn); 78 } 78 79 } 79 80 }
Note: See TracChangeset
for help on using the changeset viewer.