Changeset 6637 in orxonox.OLD for trunk/src/world_entities/weapons
- Timestamp:
- Jan 21, 2006, 1:27:29 AM (19 years ago)
- Location:
- trunk/src/world_entities/weapons
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/world_entities/weapons/aim.cc
r6512 r6637 73 73 this->source = NULL; 74 74 75 this->range = 0; 76 this->angle = 0; 75 77 this->anim = new tAnimation<Aim>(this, &Aim::setSize); 76 78 this->anim->setInfinity(ANIM_INF_CONSTANT); … … 101 103 } 102 104 103 void Aim::searchTarget( float range)105 void Aim::searchTarget() 104 106 { 105 107 std::list<WorldEntity*>::iterator entity; 106 108 Vector diffVec(0.0, 0.0, 0.0); 109 diffVec = ( this->getAbsCoor() - this->source->getAbsCoor() ); 110 111 //only look for target if the aim hasn`t locked a target yet or if the actual target is out of range 112 if( this == PNode::getNullParent() || diffVec.len() > range || ( acos( (this->source->getAbsDirX()).dot(diffVec)/(diffVec.len() * (this->source->getAbsDirX()).len() ) ) > angle)) 107 113 for (entity = State::getObjectManager()->getObjectList(OM_GROUP_00).begin(); 108 114 entity != State::getObjectManager()->getObjectList(OM_GROUP_00).end(); 109 115 entity ++) 110 116 { 111 if (this->source->getAbsCoor().x < (*entity)->getAbsCoor().x && (this->source->getAbsCoor() - (*entity)->getAbsCoor()).len() < range) 117 diffVec = ( (*entity)->getAbsCoor() - this->source->getAbsCoor() ); 118 119 if ( diffVec.len() < range && acos( (this->source->getAbsDirX()).dot(diffVec)/(diffVec.len() * (this->source->getAbsDirX()).len() ) ) < angle) 112 120 { 113 121 if (this->getParent() != (*entity)) … … 119 127 } 120 128 } 121 } 122 129 //if no target found: 130 this->setParent(PNode::getNullParent()); 131 } 123 132 124 133 … … 155 164 156 165 157 if (this->source->getAbsCoor().x > this->getAbsCoor().x )158 this->searchTarget(1000);166 // if (this->source->getAbsCoor().x > this->getAbsCoor().x ) 167 this->searchTarget(); 159 168 // float z = 0.0f; 160 169 // glReadPixels ((int)this->getAbsCoor2D().x, -
trunk/src/world_entities/weapons/aim.h
r6512 r6637 38 38 inline PNode* getTarget(PNode* target) { return this->getParent(); }; 39 39 40 void searchTarget(float range); 40 void searchTarget(); 41 42 void setRange(float range){this->range = range;}; 43 void setAngle(float angle){this->angle = angle;}; 41 44 42 45 void setSize(float size); … … 53 56 tAnimation<Aim>* anim; 54 57 58 float range; //!< 59 float angle; //!< 60 55 61 PNode* source; //!< Where this Shot has come from. 56 62 -
trunk/src/world_entities/weapons/aiming_turret.cc
r6512 r6637 98 98 this->target = new Aim(this); 99 99 this->target->setVisibility(false); 100 this->target->setRange(100); 101 this->target->setAngle(M_PI); 100 102 } 101 103 … … 146 148 pj->setAbsDir(this->getAbsDir()); 147 149 pj->activate(); 148 this->target->searchTarget( 100);150 this->target->searchTarget(); 149 151 } 150 152 -
trunk/src/world_entities/weapons/targeting_turret.cc
r6512 r6637 92 92 this->target = new Aim(this); 93 93 this->target->setVisibility(false); 94 94 this->target->setRange(100); 95 this->target->setAngle(M_PI_4/2); 96 this->lockedTime = 0; 97 this->neededLockTime = 2; 98 this->lockedTarget->setParent(PNode::getNullParent()); 95 99 this->loadModel("models/guns/turret2.obj"); 96 100 … … 119 123 void TargetingTurret::tick(float dt) 120 124 { 125 if( lockedTime >= neededLockTime ) 126 { 127 lockedTarget = this->target->getParent(); 128 lockedTime = 0; 129 } 121 130 122 131 this->target->tick(dt); 132 133 if(this->target->getParent() == PNode::getNullParent()) 134 lockedTime = 0; 135 else 136 lockedTime += dt; 137 123 138 } 124 139 … … 137 152 pj->setAbsDir(this->getAbsDir()); 138 153 pj->activate(); 139 this->target->searchTarget( 100);154 this->target->searchTarget(); 140 155 } 141 156 -
trunk/src/world_entities/weapons/targeting_turret.h
r6512 r6637 32 32 33 33 private: 34 Aim* target; 35 }; 34 Aim* target; 35 PNode* lockedTarget; 36 float lockedTime; 37 float neededLockTime; 38 }; 36 39 37 40 #endif /* _TARGETING_TURRET_H */
Note: See TracChangeset
for help on using the changeset viewer.