Changeset 10694 in orxonox.OLD for branches/adm/src/world_entities/npcs
- Timestamp:
- Jun 14, 2007, 3:50:14 PM (18 years ago)
- Location:
- branches/adm/src/world_entities/npcs
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/adm/src/world_entities/npcs/adm_turret.cc
r10690 r10694 76 76 LoadParamXML(root, "Sensor", this, AdmTurret, addSensor) 77 77 .describe("add sensor to ADM"); 78 LoadParamXML(root, "Weapon", this, AdmTurret, addWeapon) 79 .describe("add weapon to ADM"); 78 80 79 81 } … … 137 139 this->range = 400; 138 140 this->isCeil = false; 139 this->bFire = false;140 141 this->playerVisible = false; 141 142 … … 146 147 { 147 148 WorldEntity::tick(dt); 148 149 this->weapon->fire(false); 149 150 this->updatePlayerVisible(); 150 151 … … 158 159 { 159 160 this->moveTowards( ds, dt); 160 161 //if target within +/- 2.5 degrees of aim -> fire162 Vector dv1 = ds;163 dv1.normalize();164 Vector dv2 = this->cannons->getAbsDir().apply( Vector(-1, 0, 0));165 dv2.normalize();166 float angle = dv1.dot(dv2);167 if (angle > 0.999)168 {169 this->fire();170 }161 162 //if target within +/- 2.5 degrees of aim -> fire 163 Vector dv1 = ds; 164 dv1.normalize(); 165 Vector dv2 = this->cannons->getAbsDir().apply( Vector(-1, 0, 0)); 166 dv2.normalize(); 167 float angle = dv1.dot(dv2); 168 if (angle > 0.999) 169 { 170 this->weapon->fire(true); 171 } 171 172 } 172 173 else … … 178 179 WorldEntity::draw(); 179 180 180 181 #if 0 181 182 glMatrixMode(GL_MODELVIEW); 182 183 glPushMatrix(); … … 212 213 glPopAttrib(); 213 214 glPopMatrix(); 214 215 #endif 215 216 } 216 217 … … 227 228 } 228 229 229 void AdmTurret::fire()230 {231 }232 233 230 void AdmTurret::addCannons( const TiXmlElement * root ) 234 231 { 235 232 this->cannons = new WorldEntity(); 236 233 this->cannons->setParent(this); 237 234 this->cannons->loadParams( root ); … … 242 239 this->cannons->toList( getOMListNumber() ); 243 240 241 242 } 243 244 void AdmTurret::addWeapon( const TiXmlElement * root ) 245 { 244 246 this->weapon = new BspWeapon(); 247 this->weapon->setParent( this->cannons ); 245 248 this->weapon->loadParams(root); 246 this->weapon->setParent( this->cannons );247 249 this->weapon->toList( getOMListNumber() ); 248 this->weapon->setAbsCoor( this->cannons->getAbsCoor() );250 //this->weapon->setAbsCoor( this->cannons->getAbsCoor() ); 249 251 this->weapon->setAbsDir( this->weapon->getAbsDir() * Quaternion( PI, Vector(0, 1, 0) ) ); 250 252 } … … 252 254 void AdmTurret::addSensor( const TiXmlElement * root ) 253 255 { 254 256 this->sensor = new WorldEntity(); 255 257 this->sensor->setParent(this); 256 258 this->sensor->loadParams( root ); … … 285 287 if ( isCeil ) 286 288 { 287 printf( "ceil\n" );288 289 baseRot = Quaternion( PI, Vector( 1, 0, 0 ) ); 289 290 } -
branches/adm/src/world_entities/npcs/adm_turret.h
r10689 r10694 37 37 WorldEntity* sensor; 38 38 WorldEntity* myTarget; 39 void fire();40 39 41 40 void addCannons(const TiXmlElement* root); 42 41 void addSensor(const TiXmlElement* root); 42 void addWeapon(const TiXmlElement* root); 43 43 44 44 void moveTowards( Vector targetDir, float dt ); … … 53 53 void setType( const std::string& type ); 54 54 55 bool bFire;56 55 bool playerVisible; 57 56 void updatePlayerVisible(); … … 61 60 62 61 #endif 62
Note: See TracChangeset
for help on using the changeset viewer.