Changeset 9235 in orxonox.OLD for trunk/src/world_entities
- Timestamp:
- Jul 5, 2006, 4:39:02 PM (18 years ago)
- Location:
- trunk/src/world_entities
- Files:
-
- 46 edited
- 16 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/world_entities/WorldEntities.am
r9061 r9235 4 4 world_entities/npcs/npc_test.cc \ 5 5 world_entities/npcs/ground_turret.cc \ 6 world_entities/npcs/space_turret.cc \ 6 7 world_entities/npcs/generic_npc.cc \ 7 8 world_entities/npcs/door.cc \ 9 world_entities/npcs/gate.cc \ 8 10 world_entities/npcs/repair_station.cc \ 11 world_entities/npcs/attractor_mine.cc \ 9 12 \ 10 13 world_entities/environment.cc \ … … 22 25 \ 23 26 world_entities/weapons/test_gun.cc \ 27 world_entities/weapons/laser_cannon.cc \ 24 28 world_entities/weapons/turret.cc \ 25 29 world_entities/weapons/aiming_turret.cc \ … … 28 32 world_entities/weapons/hyperblaster.cc \ 29 33 world_entities/weapons/aim.cc \ 34 world_entities/weapons/aiming_system.cc \ 30 35 world_entities/weapons/fps_sniper_rifle.cc \ 36 world_entities/weapons/boomerang_gun.cc \ 31 37 \ 32 38 world_entities/projectiles/bomb.cc \ 33 39 world_entities/projectiles/laser.cc \ 40 world_entities/projectiles/rail_projectile.cc \ 34 41 world_entities/projectiles/test_bullet.cc \ 35 42 world_entities/projectiles/rocket.cc \ 36 43 world_entities/projectiles/guided_missile.cc \ 44 world_entities/projectiles/boomerang_projectile.cc \ 37 45 world_entities/projectiles/hyperblast.cc \ 38 46 \ … … 70 78 npcs/npc_test1.h \ 71 79 npcs/ground_turret.h \ 80 npcs/space_turret.h \ 72 81 npcs/door.cc \ 73 npcs/repair_station.cc \ 82 npcs/repair_station.h \ 83 npcs/attractor_mine.h \ 74 84 \ 75 85 environment.h \ … … 87 97 \ 88 98 weapons/test_gun.h \ 99 weapons/laser_cannon.cc \ 89 100 weapons/cannon.h \ 90 101 weapons/hyperblaster.h \ … … 92 103 weapons/aiming_turret.h \ 93 104 weapons/targeting_turret.h \ 105 weapons/boomerang_gun.h \ 94 106 weapons/aim.h \ 107 weapons/aiming_system.h \ 95 108 weapons/fps_sniper_rifle.h \ 96 109 \ 97 110 projectiles/bomb.h \ 98 111 projectiles/laser.h \ 112 projectiles/rail_projectile.h \ 99 113 projectiles/test_bullet.h \ 100 114 projectiles/rocket.h \ 101 115 projectiles/guided_missile.h \ 116 projectiles/boomerang_projectile.h \ 102 117 projectiles/hyperblast.h \ 103 118 \ -
trunk/src/world_entities/camera.cc
r7868 r9235 36 36 this->setFovy(90); 37 37 this->setAspectRatio(1.2f); 38 this->setClipRegion(.1, 2000);38 this->setClipRegion(.1, 10000); 39 39 40 40 this->setViewMode(Camera::ViewNormal); -
trunk/src/world_entities/creatures/fps_player.cc
r9110 r9235 29 29 #include "weapons/cannon.h" 30 30 #include "weapons/fps_sniper_rifle.h" 31 #include "weapons/aiming_system.h" 31 32 32 33 #include "aabb.h" 34 33 35 34 36 #include "key_mapper.h" … … 57 59 { 58 60 this->setPlayer(NULL); 61 62 if( this->aimingSystem) 63 delete this->aimingSystem; 59 64 } 60 65 … … 81 86 { 82 87 this->setClassID(CL_FPS_PLAYER, "FPSPlayer"); 83 84 88 85 89 this->bLeft = false; … … 89 93 this->bJump = false; 90 94 this->bPosBut = false; 95 this->bFire = false; 91 96 92 97 this->xMouse = 0.0f; … … 125 130 126 131 // this->addWeapon(wpLeft, 1, 0); 127 this->addWeapon(wpRight,1, 0); 132 if( State::isOnline()) 133 this->addWeapon(wpRight,1, 0); 128 134 this->getWeaponManager().changeWeaponConfig(1); 129 135 130 136 this->getWeaponManager().setSlotCount(2); 131 // this->getWeaponManager().setSlotDirection(0, Quaternion(M_PI_2, Vector(0,1,0)));137 this->getWeaponManager().setSlotDirection(0, Quaternion(M_PI_4*-0.55f, Vector(0,0,1))); 132 138 this->getWeaponManager().setSlotCapability(0, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL); 133 139 this->getWeaponManager().setSlotDirection(1, Quaternion(M_PI_4*.5, Vector(1,0,0))); … … 135 141 this->getWeaponManager().setSlotPosition(1, Vector(5.0, 0.0, 0.0)); 136 142 143 // this->getWeaponManager().getFixedTarget()->setRelDir(Quaternion(M_PI_4*-0.6f, Vector(0,0,1))); 144 137 145 138 146 this->getWeaponManager().setParentNode(&this->cameraNode); … … 141 149 this->getWeaponManager().getFixedTarget()->setParent(&this->cameraNode); 142 150 this->getWeaponManager().getFixedTarget()->setRelCoor(1000,0,0); 151 152 this->aimingSystem = new AimingSystem(this); 153 //this->addChild(this->aimingSystem); 154 wpRight->addChild(this->aimingSystem); 155 // this->getWeaponManager().sl 143 156 144 157 … … 148 161 registerVar( new SynchronizeableBool( &bForward, &bForward, "bForward", PERMISSION_OWNER ) ); 149 162 registerVar( new SynchronizeableBool( &bBackward, &bBackward, "bBackward", PERMISSION_OWNER ) ); 163 registerVar( new SynchronizeableBool( &bJump, &bJump, "bJump", PERMISSION_OWNER ) ); 150 164 registerVar( new SynchronizeableFloat( &heading, &heading, "heading", PERMISSION_OWNER ) ); 151 165 registerVar( new SynchronizeableFloat( &attitude, &attitude, "attitude", PERMISSION_OWNER ) ); 166 167 //subscribe to collision reaction 168 this->subscribeReaction(CREngine::CR_PHYSICS_FULL_WALK, CL_BSP_ENTITY); 169 170 this->initWeapon = false; 171 this->damageTicker = 0.0f; 172 173 if( State::isOnline()) 174 toList( OM_PLAYERS ); 152 175 } 153 176 … … 192 215 this->getWeaponManager().getFixedTarget()->setRelCoor(0,0,0); 193 216 194 195 AABB* box = this->getModelAABB(); 196 if( box != NULL) 197 { 198 State::getCameraNode()->setRelCoor(0, box->halfLength[1] * 2.0f, 0); 199 State::getCameraTargetNode()->setRelCoor(10, box->halfLength[1] * 2.0f, 0); 200 201 this->getWeaponManager().setSlotPosition(0, Vector(1.5, box->halfLength[1] * 2.0f - 0.7, 1.1)); 202 this->getWeaponManager().setSlotPosition(1, Vector(5.0, box->halfLength[1] * 2.0f, 0.0)); 217 if ( !State::isOnline() ) 218 { 219 this->respawn(); 203 220 } 204 221 } … … 219 236 { 220 237 221 if( this->bPosBut) 222 { 223 this->bPosBut = false; 224 printf("mechanic2:walkTo( %f, mtheight, %f)\n",this->getAbsCoorX(),this->getAbsCoorZ()); 225 } 226 227 Playable::tick( time ); 238 if ( !this->initWeapon ) 239 { 240 this->initWeapon = true; 241 242 this->cameraNode.setParentMode(PNODE_ROTATE_AND_MOVE); 243 244 this->getWeaponManager().getParentNode()->setParentMode(PNODE_ROTATE_AND_MOVE); 245 this->getWeaponManager().getFixedTarget()->setParent(&this->cameraNode); 246 this->getWeaponManager().getFixedTarget()->setParentMode(PNODE_ROTATE_AND_MOVE); 247 248 249 this->aimingSystem->toList(OM_GROUP_01); 250 this->aimingSystem->setParent(&this->cameraNode); 251 // this->aimingSystem->setParentMode(PNODE_ROTATE_AND_MOVE); 252 this->aimingSystem->setRelDir(Quaternion(M_PI_4*-0.58f, Vector(0,0,1))); 253 this->aimingSystem->setRelCoor(0, -1, -1); 254 255 256 AABB* box = this->getModelAABB(); 257 if( box != NULL) 258 { 259 float f = 1.0; 260 this->cameraNode.setRelCoor(0, box->halfLength[1] * f, 0); 261 // this->cameraNode.setRelCoor(10, box->halfLength[1] * f, 0); 262 263 float v = 0.1f; 264 this->getWeaponManager().setSlotPosition(0, Vector(-8.0, box->halfLength[1] * v, 1.1)); 265 this->getWeaponManager().setSlotPosition(1, Vector(5.0, box->halfLength[1] * v, 0.0)); 266 } 267 } 268 269 270 this->getWeaponManager().tick(time); 271 if( this->bFire) 272 { 273 this->getWeaponManager().fire(); 274 275 // WorldEntity* target = this->aimingSystem->getNearestTarget(); 276 // if( target != NULL) 277 // { 278 // PRINTF(0)("hit hit hit, got: %s\n", target->getClassName()); 279 // } 280 // else 281 // { 282 // PRINTF(0)("nothing hit\n"); 283 // } 284 } 285 286 287 //dealing damage 288 289 if ( State::isOnline() && SharedNetworkData::getInstance()->isGameServer() ) 290 { 291 this->damageTicker -= time; 292 293 if ( this->damageTicker <= 0.0f && this->beFire() ) 294 { 295 this->damageTicker = 0.25; 296 297 WorldEntity * victim = aimingSystem->getNearestTarget(); 298 299 if ( victim ) 300 { 301 PRINTF(0)("FIRE: hit %s\n", victim->getClassName()); 302 victim->hit( 20, this ); 303 } 304 else 305 { 306 PRINTF(0)("FIRE: nothing hit\n"); 307 } 308 } 309 } 310 228 311 229 312 if( ( xMouse != 0 || yMouse != 0 ) && (this->getOwner() == SharedNetworkData::getInstance()->getHostID() || !State::isOnline() ) ) … … 235 318 attitude-= yMouse; 236 319 237 if ( attitude > 2.05 ) 238 attitude = 2.05;239 240 else if ( attitude < -1. 15)241 attitude = -1. 15;320 321 if ( attitude > 1.95 ) 322 attitude = 1.95; 323 else if ( attitude < -1.07 ) 324 attitude = -1.07; 242 325 243 326 xMouse = yMouse = 0; … … 304 387 this->fallVelocity += 300.0f * time; 305 388 velocity -= Vector(0.0, 1.0, 0.0) * this->fallVelocity; 389 390 // PRINTF(0)("vel %f\n", this->fallVelocity); 306 391 } 307 392 else … … 309 394 this->fallVelocity = 0.0f; 310 395 } 311 312 396 313 397 this->shiftCoor( velocity*time ); … … 346 430 } 347 431 432 this->setOnGround(false); 433 this->aimingSystem->flushList(); 348 434 } 349 435 … … 383 469 } 384 470 else if( event.type == KeyMapper::PEV_JUMP) 471 { 385 472 this->bJump = event.bPressed; 386 this->bPosBut = event.bPressed; 387 } 388 389 390 391 473 } 474 else if( event.type == KeyMapper::PEV_FIRE1) 475 { 476 this->bFire = event.bPressed; 477 } 478 } 479 480 481 void FPSPlayer::respawn( ) 482 { 483 if( State::isOnline()) 484 toList( OM_PLAYERS ); 485 486 this->damageTicker = 0.0f; 487 488 Playable::respawn(); 489 } 490 491 492 void FPSPlayer::destroy( WorldEntity* killer ) 493 { 494 Playable::destroy( killer ); 495 496 toList( OM_DEAD ); 497 } 498 -
trunk/src/world_entities/creatures/fps_player.h
r9110 r9235 9 9 10 10 #include "playable.h" 11 12 13 class AimingSystem; 11 14 12 15 … … 27 30 virtual void reset(); 28 31 32 virtual void destroy(WorldEntity* killer); 33 virtual void respawn(); 29 34 30 35 virtual void tick(float time); … … 43 48 bool bJump; //!< jumping 44 49 bool bPosBut; //!< position button 50 bool bFire; //!< fire button 45 51 46 52 float xMouse; //!< mouse moved in x-Direction … … 55 61 float fallVelocity; //!< velocity for falling down 56 62 float jumpForce; //!< the jump force 63 64 bool initWeapon; 65 66 AimingSystem* aimingSystem; //!< aiming system of the player 67 68 float damageTicker; //!< ticker for dealing damage 57 69 }; 58 70 -
trunk/src/world_entities/effects/explosion.cc
r7120 r9235 40 40 this->toList(OM_DEAD_TICK); 41 41 42 this->emitter = new BoxEmitter(Vector(10,10,10), 500, 45, M_2_PI);42 this->emitter = new BoxEmitter(Vector(10,10,10), 200, 45, M_2_PI); 43 43 this->emitter->addNodeFlags(PNODE_PROHIBIT_DELETE_WITH_PARENT); 44 44 this->emitter->setParent(this); … … 83 83 Explosion::explosionParticles->setLifeSpan(1.5, .3); 84 84 Explosion::explosionParticles->setRadius(0.0, 10); 85 Explosion::explosionParticles->setRadius(.5, 15.0);85 Explosion::explosionParticles->setRadius(.5, 30.0); 86 86 Explosion::explosionParticles->setRadius(1.0, 10.0); 87 87 Explosion::explosionParticles->setColor(0.0, 1,0,0,1); … … 113 113 void Explosion::tick (float dt) 114 114 { 115 printf("%f %f\n", this->lifeCycle, this->lifeTime);116 115 this->lifeCycle += dt; 117 116 if(this->lifeTime < this->lifeCycle) -
trunk/src/world_entities/environments/mapped_water.cc
r9110 r9235 337 337 { 338 338 // it's not too nice, but it works fine 339 PRINTF(0)("\nMappedWater XML Code:\n<MappedWater>\n <waterpos>%f, %f, %f</waterpos>\n <watersize>%f, %f</watersize>\n <wateruv>%f</wateruv>\n <waterflow>%f</waterflow>\n <lightpos>%f, %f, %f</lightpos>\n <waterangle>%f</waterangle>\n <normalmapscale>%f</normalmapscale>\n <shinesize>%f</waterpos>\n <shinestrength>%f</shinestrength>\n <reflstrength>%f</reflstrength>\n <refraction>%f</refraction>\n <watercolor>%f, %f, %f</watercolor>\n</MappedWater>\n", this->waterVerts[0], this->waterHeight, this->waterVerts[1], this->xWidth, this->zWidth, this->waterUV, this->waterFlow, this->lightPos.x, this->lightPos.y, this->lightPos.z, this->waterAngle, this->kNormalMapScale, this->shineSize, this->shineStrength, this->reflStrength, this->refraction, this->waterColor.x, this->waterColor.y, this->waterColor.z); 339 PRINT(0)("\nMappedWater XML Code:\n<MappedWater>\n"); 340 341 PRINT(0)(" <waterpos>%f, %f, %f</waterpos>\n", this->waterVerts[0], this->waterHeight, this->waterVerts[1]); 342 PRINT(0)(" <watersize>%f, %f</watersize>\n", this->xWidth, this->zWidth); 343 PRINT(0)(" <wateruv>%f</wateruv>\n", this->waterUV); 344 PRINT(0)(" <waterflow>%f</waterflow>\n", this->waterFlow); 345 PRINT(0)(" <lightpos>%f, %f, %f</lightpos>\n", this->lightPos.x, this->lightPos.y, this->lightPos.z); 346 PRINT(0)(" <waterangle>%f</waterangle>\n", this->waterAngle); 347 PRINT(0)(" <normalmapscale>%f</normalmapscale>\n", this->kNormalMapScale); 348 PRINT(0)(" <shinesize>%f</shinesize>\n", this->shineSize); 349 PRINT(0)(" <shinestrength>%f</shinestrength>\n", this->shineStrength); 350 PRINT(0)(" <reflstrength>%f</reflstrength>\n", this->reflStrength); 351 PRINT(0)(" <refraction>%f</refraction>\n", this->refraction); 352 PRINT(0)(" <watercolor>%f, %f, %f</watercolor>\n", this->waterColor.x, this->waterColor.y, this->waterColor.z); 353 354 PRINT(0)("</MappedWater>\n"); 340 355 } 341 356 … … 475 490 476 491 OrxGui::GLGuiSlider* lightPosX = new OrxGui::GLGuiSlider(); 477 lightPosX->setRange(- 600, 600);492 lightPosX->setRange(-4000, 4000); 478 493 lightPosX->setValue(this->lightPos.x); 479 494 lightPosX->setStep(15); … … 482 497 483 498 OrxGui::GLGuiSlider* lightPosY = new OrxGui::GLGuiSlider(); 484 lightPosY->setRange(- 600, 600);499 lightPosY->setRange(-4000, 4000); 485 500 lightPosY->setStep(15); 486 501 lightPosY->setValue(this->lightPos.y); … … 489 504 490 505 OrxGui::GLGuiSlider* lightPosZ = new OrxGui::GLGuiSlider(); 491 lightPosZ->setRange(- 600, 600);506 lightPosZ->setRange(-4000, 4000); 492 507 lightPosZ->setStep(15); 493 508 lightPosZ->setValue(this->lightPos.z); … … 504 519 505 520 OrxGui::GLGuiSlider* waterHeight = new OrxGui::GLGuiSlider(); 506 waterHeight->setRange( -500, 500);521 waterHeight->setRange(100, 370); 507 522 waterHeight->setValue(this->waterHeight); 508 waterHeight->setStep( 10);523 waterHeight->setStep(4); 509 524 waterHeight->connect(SIGNAL(waterHeight, valueChanged), this, SLOT(MappedWater, setWaterHeight)); 510 525 waterHeightBox->pack(waterHeight); … … 547 562 glDisable(GL_BLEND); 548 563 564 // TODO change texture coords, so water doesnt look distorted when xWidth != zWidth 549 565 glBegin(GL_QUADS); 550 566 // The back left vertice for the water -
trunk/src/world_entities/environments/model_entity.cc
r7193 r9235 32 32 { 33 33 this->setClassID(CL_MODEL_ENTITY, "ModelEntity"); 34 this->toList(OM_ENVIRON _NOTICK);34 this->toList(OM_ENVIRON); 35 35 36 36 this->speed = NULL; … … 71 71 void ModelEntity::setMomentum (float angle, float x, float y, float z) 72 72 { 73 Vector v(x,y,z); 74 v.debug(); 75 v.normalize(); 76 v.debug(); 77 73 78 if (this->momentum == NULL) 74 79 this->momentum = new Quaternion; 75 *this->momentum = Quaternion(angle, Vector(x, y, z)); 80 *this->momentum = Quaternion(angle, v); 81 82 this->momentum->debug(); 76 83 } 77 84 … … 82 89 83 90 if (this->momentum != NULL) 84 this->shiftDir(*this->momentum * dt); 91 { 92 this->shiftDir((*this->momentum * dt ).getNormalized()); 93 //this->getAbsDir().debug(); 94 } 85 95 } -
trunk/src/world_entities/npcs/generic_npc.cc
r9110 r9235 82 82 { 83 83 this->setClassID(CL_GENERIC_NPC, "GenericNPC"); 84 84 85 this->toList(OM_GROUP_00); 85 86 … … 206 207 /** 207 208 * each animation has to be initialized here 209 */ 210 /** 211 * 208 212 */ 209 213 void GenericNPC::initNPC() … … 578 582 579 583 580 void GenericNPC::destroy( )584 void GenericNPC::destroy(WorldEntity* killer) 581 585 { 582 586 int randi = (int)(5.0f * (float)rand()/(float)RAND_MAX); -
trunk/src/world_entities/npcs/generic_npc.h
r9061 r9235 77 77 78 78 79 v oid destroy();79 virtual void destroy(WorldEntity* killer); 80 80 81 81 private: -
trunk/src/world_entities/npcs/ground_turret.cc
r8777 r9235 176 176 } 177 177 178 void GroundTurret::destroy( )178 void GroundTurret::destroy(WorldEntity* killer) 179 179 { 180 180 this->setAbsDirSoft(Quaternion(-90, Vector(0,0,1)), 90); -
trunk/src/world_entities/npcs/ground_turret.h
r7954 r9235 25 25 virtual void leftWorld (); 26 26 27 virtual void destroy( );27 virtual void destroy(WorldEntity* killer); 28 28 29 29 virtual void draw() const; -
trunk/src/world_entities/npcs/npc.cc
r9003 r9235 19 19 20 20 #include "npc.h" 21 22 23 using namespace std;24 21 25 22 … … 51 48 void NPC::loadParams(const TiXmlElement* root) 52 49 { 53 if(root != NULL)54 50 WorldEntity::loadParams(root); 55 51 } -
trunk/src/world_entities/npcs/npc_test.cc
r8724 r9235 23 23 #include "shader.h" 24 24 #include "state.h" 25 #include "stdlibincl.h"26 25 #include "debug.h" 27 26 27 #include "loading/factory.h" 28 #include "loading/load_param.h" 28 29 29 using namespace std; 30 #include "effects/explosion.h" 31 32 CREATE_FACTORY(NPC2, CL_NPC_TEST2); 30 33 31 34 32 NPC2::NPC2( )35 NPC2::NPC2(const TiXmlElement* root) 33 36 : NPC(NULL) 34 37 { … … 36 39 37 40 if ((float)rand()/RAND_MAX > .5f) 38 this->loadModel("models/ships/bolido.obj", 3);41 this->loadModel("models/ships/bolido.obj", 6); 39 42 else 40 this->loadModel("models/ships/gobblin.obj", 3); 43 this->loadModel("models/ships/gobblin.obj", 6); 44 45 46 41 47 42 48 this->shader = NULL; … … 44 50 this->shader = Shader::getShader("shaders/toon.vert", "shaders/toon.frag"); 45 51 46 this-> obj = gluNewQuadric();52 this->randomRotAxis = VECTOR_RAND(1); 47 53 48 this->randomRotAxis = VECTOR_RAND(1); 54 if (root != NULL) 55 this->loadParams(root); 49 56 } 50 57 … … 54 61 if (this->shader) 55 62 Shader::unload(this->shader); 56 gluDeleteQuadric(this->obj); 63 } 64 65 66 void NPC2::loadParams(const TiXmlElement* root) 67 { 68 NPC::loadParams(root); 69 70 } 71 72 73 void NPC2::destroy(WorldEntity* killer) 74 { 75 Explosion::explode(this, Vector(10,10,10)); 76 this->toList(OM_DEAD); 77 57 78 } 58 79 … … 67 88 void NPC2::draw() const 68 89 { 69 //glMatrixMode(GL_MODELVIEW);70 //glPushMatrix();71 //float matrix[4][4];72 // 73 ///* translate */74 //glTranslatef (this->getAbsCoor ().x,75 //this->getAbsCoor ().y,76 //this->getAbsCoor ().z);77 ///* rotate */78 //this->getAbsDir ().matrix (matrix);79 //glMultMatrixf((float*)matrix);80 // 90 glMatrixMode(GL_MODELVIEW); 91 glPushMatrix(); 92 float matrix[4][4]; 93 94 /* translate */ 95 glTranslatef (this->getAbsCoor ().x, 96 this->getAbsCoor ().y, 97 this->getAbsCoor ().z); 98 /* rotate */ 99 this->getAbsDir ().matrix (matrix); 100 glMultMatrixf((float*)matrix); 101 81 102 // if (this->shader != NULL && this->shader != Shader::getActiveShader()) 82 103 // shader->activateShader(); 83 // gluSphere(this->obj, 3, 10, 10); 104 105 this->getModel()->draw(); 84 106 // shader->deactivateShader(); 85 // 86 // 87 / / /* if (this->model)88 //this->model->draw();*/89 //glPopMatrix();107 108 109 /* if (this->model) 110 this->model->draw();*/ 111 glPopMatrix(); 90 112 } 91 113 … … 97 119 //if (directin.len() < 100) 98 120 // this->shiftCoor(direction *dt * 5 * exp(-direction.len() / 30.0)); 99 this->shiftDir(Quaternion(dt, this->randomRotAxis));121 // this->shiftDir(Quaternion(dt, this->randomRotAxis)); 100 122 101 123 } -
trunk/src/world_entities/npcs/npc_test.h
r6981 r9235 11 11 12 12 public: 13 NPC2 ( );13 NPC2 (const TiXmlElement* root); 14 14 virtual ~NPC2 (); 15 15 16 virtual void loadParams(const TiXmlElement* root); 16 17 17 18 void addAI(AI* ai); 19 20 virtual void destroy(WorldEntity* killer); 18 21 19 22 virtual void tick(float dt); … … 23 26 Vector randomRotAxis; 24 27 Shader* shader; 25 GLUquadricObj* obj;26 27 28 }; 28 29 -
trunk/src/world_entities/npcs/npc_test1.cc
r8724 r9235 24 24 #include "power_ups/turret_power_up.h" 25 25 #include "power_ups/laser_power_up.h" 26 27 using namespace std;28 26 29 27 -
trunk/src/world_entities/playable.cc
r9110 r9235 67 67 this->bDead = false; 68 68 69 //subscribe to collision reaction70 this->subscribeReaction(CREngine::CR_PHYSICS_GROUND_WALK, CL_BSP_ENTITY);71 69 72 70 registerVar( new SynchronizeableInt( &score, &score, "score" ) ); … … 393 391 PRINTF(0)("Playable respawn\n"); 394 392 // only if this is the spaceship of the player 395 if( this == State::getPlayer()->getPlayable())393 if( State::getGameRules() && State::getPlayer() && this == State::getPlayer()->getPlayable()) 396 394 State::getGameRules()->onPlayerSpawn(); 397 395 … … 403 401 404 402 405 void Playable::destroy() 406 { 407 Explosion::explode(dynamic_cast<PNode*>(this), Vector(1.0f, 1.0f, 1.0f)); 408 409 403 void Playable::destroy(WorldEntity* killer) 404 { 410 405 if( !this->bDead) 411 406 { … … 416 411 if( this == State::getPlayer()->getPlayable()) 417 412 State::getGameRules()->onPlayerDeath(); 418 419 // this->toList(OM_GROUP_05);420 //HACK: moves the entity to an unknown place far far away: in the future, GameRules will look for that421 this->setAbsCoor(-2000.0, -2000.0, -2000.0);422 423 //explosion hack424 425 413 } 426 414 this->bDead = true; 415 416 if( State::getGameRules() != NULL) 417 State::getGameRules()->registerKill(Kill(killer, this)); 427 418 } 428 419 } -
trunk/src/world_entities/playable.h
r9061 r9235 80 80 81 81 // WorldEntity Extensions 82 virtual void destroy( );82 virtual void destroy(WorldEntity* killer); 83 83 virtual void respawn(); 84 84 virtual void collidesWith(WorldEntity* entity, const Vector& location); … … 90 90 static const std::string& playmodeToString(Playable::Playmode playmode); 91 91 static const std::string playmodeNames[]; 92 93 inline bool beFire(){ return this->bFire; } 94 inline void fire(bool bF){ this->bFire = bF;} 92 95 93 96 protected: -
trunk/src/world_entities/projectiles/guided_missile.cc
r8362 r9235 35 35 this->setClassID(CL_GUIDED_MISSILE, "GuidedMissile"); 36 36 37 this->loadModel("models/projectiles/orx-rocket.obj", .3);37 this->loadModel("models/projectiles/orx-rocket.obj", 2.0); 38 38 this->loadExplosionSound("sound/explosions/explosion_4.wav"); 39 39 … … 88 88 GuidedMissile::trailParticles->setLifeSpan(1.0, .3); 89 89 GuidedMissile::trailParticles->setRadius(0.0, .5); 90 GuidedMissile::trailParticles->setRadius(0.2, 2.0);91 GuidedMissile::trailParticles->setRadius(.5, .8);92 GuidedMissile::trailParticles->setRadius(1.0, .8);90 GuidedMissile::trailParticles->setRadius(0.2, 4.0); 91 GuidedMissile::trailParticles->setRadius(.5, 1.5); 92 GuidedMissile::trailParticles->setRadius(1.0, 1.5); 93 93 GuidedMissile::trailParticles->setColor(0.0, 1,0,0,.7); 94 94 GuidedMissile::trailParticles->setColor(0.2, .8,.8,0,.5); … … 135 135 { 136 136 if (this->hitEntity != entity) 137 this->destroy( );137 this->destroy( entity ); 138 138 this->hitEntity = entity; 139 139 } … … 180 180 * the function gets called, when the projectile is destroyed 181 181 */ 182 void GuidedMissile::destroy () 183 { 184 Projectile::destroy(); 182 void GuidedMissile::destroy (WorldEntity* killer) 183 { 184 185 printf("THIS SHOULD WORLk\n"); 186 187 Projectile::destroy( killer ); 185 188 PRINTF(5)("DESTROY GuidedMissile\n"); 186 189 this->lifeCycle = .95; //!< @todo calculate this usefully. -
trunk/src/world_entities/projectiles/guided_missile.h
r6622 r9235 26 26 virtual void collidesWith(WorldEntity* entity, const Vector& location); 27 27 28 virtual void destroy ( );28 virtual void destroy (WorldEntity* killer); 29 29 30 30 virtual void tick (float time); -
trunk/src/world_entities/projectiles/hyperblast.cc
r8362 r9235 126 126 * the function gets called, when the projectile is destroyed 127 127 */ 128 void Hyperblast::destroy ( )128 void Hyperblast::destroy (WorldEntity* killer) 129 129 { 130 Projectile::destroy( );130 Projectile::destroy( killer ); 131 131 132 132 PRINTF(5)("DESTROY Hyperblast\n"); -
trunk/src/world_entities/projectiles/hyperblast.h
r6821 r9235 27 27 virtual void collidesWith(WorldEntity* entity, const Vector& location); 28 28 29 virtual void destroy ( );29 virtual void destroy (WorldEntity* killer); 30 30 31 31 virtual void tick (float time); -
trunk/src/world_entities/projectiles/laser.cc
r9061 r9235 42 42 43 43 this->setMinEnergy(10); 44 this->setHealthMax( 10);44 this->setHealthMax(0); 45 45 this->lifeSpan = 5.0; 46 46 … … 88 88 } 89 89 90 this->setHealth(10); 90 this->setDamage(0); 91 this->setHealth(0); 91 92 } 92 93 … … 107 108 { 108 109 if (this->hitEntity != entity && entity->isA(CL_NPC)) 109 this->destroy( );110 this->destroy( entity ); 110 111 this->hitEntity = entity; 111 112 } … … 128 129 * the function gets called, when the projectile is destroyed 129 130 */ 130 void Laser::destroy ( )131 void Laser::destroy (WorldEntity* killer) 131 132 { 132 Projectile::destroy( );133 Projectile::destroy( killer ); 133 134 PRINTF(5)("DESTROY Laser\n"); 134 135 this->lifeCycle = .95; //!< @todo calculate this usefully. -
trunk/src/world_entities/projectiles/laser.h
r6622 r9235 27 27 virtual void collidesWith(WorldEntity* entity, const Vector& location); 28 28 29 virtual void destroy ( );29 virtual void destroy (WorldEntity* killer); 30 30 31 31 virtual void tick (float dt); -
trunk/src/world_entities/projectiles/projectile.cc
r8362 r9235 41 41 /* character attributes */ 42 42 this->setHealth(1.0f); 43 this->setDamage(1 00.0f); // default damage of a projectile set to 100.0 damage points43 this->setDamage(1.0f); // default damage of a projectile set to 100.0 damage points 44 44 45 45 this->explosionBuffer = NULL; … … 162 162 163 163 if (this->tickLifeCycle(dt)) 164 this->destroy( );164 this->destroy( NULL ); 165 165 } 166 166 … … 169 169 * the function gets called, when the projectile is destroyed 170 170 */ 171 void Projectile::destroy ( )171 void Projectile::destroy (WorldEntity* killer) 172 172 { 173 173 if (this->explosionBuffer != NULL) -
trunk/src/world_entities/projectiles/projectile.h
r7460 r9235 41 41 virtual void deactivate() = 0; 42 42 43 virtual void destroy ( );43 virtual void destroy (WorldEntity* killer); 44 44 45 45 virtual void tick (float dt); -
trunk/src/world_entities/projectiles/rocket.cc
r8362 r9235 128 128 { 129 129 if (this->hitEntity != entity) 130 this->destroy( );130 this->destroy( entity ); 131 131 this->hitEntity = entity; 132 132 } … … 149 149 * the function gets called, when the projectile is destroyed 150 150 */ 151 void Rocket::destroy ( )151 void Rocket::destroy (WorldEntity* killer) 152 152 { 153 Projectile::destroy( );153 Projectile::destroy( killer ); 154 154 155 155 PRINTF(5)("DESTROY Rocket\n"); -
trunk/src/world_entities/projectiles/rocket.h
r6622 r9235 27 27 virtual void collidesWith(WorldEntity* entity, const Vector& location); 28 28 29 virtual void destroy ( );29 virtual void destroy (WorldEntity* killer); 30 30 31 31 virtual void tick (float time); -
trunk/src/world_entities/projectiles/test_bullet.cc
r8362 r9235 119 119 { 120 120 if (this->hitEntity != entity && entity->isA(CL_NPC)) 121 this->destroy( );121 this->destroy( entity ); 122 122 this->hitEntity = entity; 123 123 } … … 147 147 * the function gets called, when the projectile is destroyed 148 148 */ 149 void TestBullet::destroy ( )149 void TestBullet::destroy (WorldEntity* killer) 150 150 { 151 151 PRINTF(5)("DESTROY TestBullet\n"); -
trunk/src/world_entities/projectiles/test_bullet.h
r6624 r9235 27 27 virtual void collidesWith(WorldEntity* entity, const Vector& location); 28 28 29 virtual void destroy ( );29 virtual void destroy (WorldEntity* killer); 30 30 31 31 virtual void tick (float time); -
trunk/src/world_entities/script_trigger.cc
r9110 r9235 29 29 ->addMethod("getAbsCoorZ", ExecutorLua0ret<PNode, float>(&PNode::getAbsCoorZ)) 30 30 //Properties 31 ->addMethod("setName", ExecutorLua1<BaseObject, const std::string&>(&BaseObject::setName)) 31 32 ->addMethod("setTarget", ExecutorLua1<ScriptTrigger, const std::string&>(&ScriptTrigger::setTarget)) 32 33 ->addMethod("setTriggerParent", ExecutorLua1<ScriptTrigger, const std::string&>(&ScriptTrigger::setTriggerParent)) … … 51 52 this->toList(OM_COMMON); 52 53 54 radius = 10; 53 55 returnCount = 1; 54 56 scriptFinished = false; … … 71 73 72 74 } 75 73 76 } 74 77 … … 215 218 void ScriptTrigger::setScript(const std::string& file) 216 219 { 217 218 220 ScriptManager* scriptManager = State::getScriptManager(); 219 221 if (scriptManager != NULL) -
trunk/src/world_entities/skydome.cc
r9006 r9235 1 1 /* 2 2 orxonox - the future of 3D-vertical-scrollers 3 3 4 4 Copyright (C) 2006 orx 5 5 6 6 This program is free software; you can redistribute it and/or modify 7 7 it under the terms of the GNU General Public License as published by 8 8 the Free Software Foundation; either version 2, or (at your option) 9 9 any later version. 10 10 11 11 ### File Specific: 12 12 main-programmer: hdavid, amaechler … … 47 47 this->toList(OM_BACKGROUND); 48 48 this->toReflectionList(); 49 49 this->indices = NULL; 50 this->vertices = NULL; 51 this->planeVertices = NULL; 52 this->shader = NULL; 50 53 activateDome = false; 51 54 … … 91 94 if(!activateDome) 92 95 return; 93 96 94 97 glPushAttrib(GL_ENABLE_BIT); 95 98 96 99 glDisable(GL_LIGHTING); 97 100 glDisable(GL_BLEND); 101 glDisable(GL_FOG); 98 102 99 103 glEnable(GL_TEXTURE_3D); … … 105 109 glTranslatef(0.0f,pRadius,0.0f); 106 110 107 108 111 glBegin(GL_TRIANGLES); 109 110 112 for (int i=0; i < numIndices; i++) 111 113 { … … 115 117 glVertex3f(planeVertices[indices[i]].x, planeVertices[indices[i]].y, planeVertices[indices[i]].z); 116 118 } 117 118 119 glEnd(); 119 120 121 WorldEntity::draw(); 122 120 123 glPopMatrix(); 121 124 … … 128 131 void Skydome::generateSkyPlane(int divisions, float planetRadius, float atmosphereRadius, float hTile, float vTile) 129 132 { 130 PRINTF(0)("Generating a sky plane ");133 PRINTF(0)("Generating a sky plane\n"); 131 134 132 135 // Make sure our vertex array is clear -
trunk/src/world_entities/space_ships/cruizer.cc
r9061 r9235 78 78 dynamic_cast<Element2D*>(this->getWeaponManager().getFixedTarget())->setVisibility( false); 79 79 80 this->loadModel("models/ships/human_cruizer.obj", 0.05);80 // this->loadModel("models/ships/human_cruizer.obj", 0.05); 81 81 82 82 } -
trunk/src/world_entities/space_ships/helicopter.cc
r8783 r9235 43 43 ->addMethod("getAbsCoorY", ExecutorLua0ret<PNode, float>(&PNode::getAbsCoorY)) 44 44 ->addMethod("getAbsCoorZ", ExecutorLua0ret<PNode, float>(&PNode::getAbsCoorZ)) 45 45 46 46 ); 47 47 … … 124 124 void Helicopter::init() 125 125 { 126 this->chopperBuffer = NULL; 127 126 128 this->setClassID(CL_HELICOPTER, "Helicopter"); 127 128 129 PRINTF(4)("HELICOPTER INIT\n"); 129 130 -
trunk/src/world_entities/space_ships/helicopter.h
r8783 r9235 39 39 40 40 virtual void process(const Event &event); 41 41 42 42 virtual void moveUp(bool move){bAscend = move;}; 43 43 virtual void moveDown(bool move){bDescend = move;}; … … 78 78 float airViscosity; 79 79 80 OrxSound::SoundSource soundSource;81 OrxSound::SoundBuffer* chopperBuffer;80 OrxSound::SoundSource soundSource; 81 OrxSound::SoundBuffer* chopperBuffer; 82 82 83 83 }; -
trunk/src/world_entities/space_ships/hover.cc
r8719 r9235 25 25 26 26 #include "util/loading/factory.h" 27 //#include "util/loading/resource_manager.h" 28 27 29 #include "key_mapper.h" 28 30 #include "state.h" … … 34 36 CREATE_FACTORY(Hover, CL_HOVER); 35 37 38 #include "script_class.h" 39 CREATE_SCRIPTABLE_CLASS(Hover, CL_HOVER, 40 addMethod("hasPlayer", ExecutorLua0ret<Playable,bool>(&Playable::hasPlayer)) 41 //Coordinates 42 ->addMethod("setAbsCoor", ExecutorLua3<PNode,float,float,float>(&PNode::setAbsCoor)) 43 ->addMethod("getAbsCoorX", ExecutorLua0ret<PNode, float>(&PNode::getAbsCoorX)) 44 ->addMethod("getAbsCoorY", ExecutorLua0ret<PNode, float>(&PNode::getAbsCoorY)) 45 ->addMethod("getAbsCoorZ", ExecutorLua0ret<PNode, float>(&PNode::getAbsCoorZ)) 46 ); 47 36 48 /** 37 49 * destructs the hover, deletes alocated memory … … 40 52 { 41 53 this->setPlayer(NULL); 54 55 //if (this->hoverBuffer != NULL) 56 // ResourceManager::getInstance()->unload(this->hoverBuffer); 42 57 } 43 58 … … 58 73 59 74 this->loadParams(doc.RootElement()); 75 76 //load sound 77 //if (this->hoverBuffer != NULL) 78 // ResourceManager::getInstance()->unload(this->hoverBuffer); 79 //this->hoverBuffer = (OrxSound::SoundBuffer*)ResourceManager::getInstance()->load("sound/engine/hover.wav", WAV); 80 60 81 } 61 82 … … 97 118 void Hover::init() 98 119 { 120 121 //this->hitEntity = NULL; 122 //this->hoverBuffer = NULL; 123 99 124 // this->setRelDir(Quaternion(M_PI, Vector(1,0,0))); 100 125 this->setClassID(CL_HOVER, "Hover"); … … 112 137 this->cameraLook = 0.0f; 113 138 this->rotation = 0.0f; 114 this->acceleration = 25.0f;139 this->acceleration = 15.0f; 115 140 this->airFriction = 3.0f; 116 141 … … 206 231 State::getCameraNode()->setRelCoorSoft(-10, 0,0); 207 232 State::getCameraTargetNode()->setParentSoft(&this->cameraNode); 233 234 //this->soundSource.play(this->hoverBuffer, 0.3f, true); 235 208 236 } 209 237 -
trunk/src/world_entities/space_ships/hover.h
r7346 r9235 7 7 #ifndef _HOVER_H 8 8 #define _HOVER_H 9 10 //#include "sound_buffer.h" 11 //#include "sound_source.h" 9 12 10 13 #include "playable.h" … … 68 71 float airViscosity; 69 72 70 WorldEntity* hitEntity; 73 WorldEntity* hitEntity; 74 75 //OrxSound::SoundSource soundSource; 76 //OrxSound::SoundBuffer* hoverBuffer; 71 77 }; 72 78 -
trunk/src/world_entities/space_ships/space_ship.cc
r9110 r9235 58 58 CREATE_SCRIPTABLE_CLASS(SpaceShip, CL_SPACE_SHIP, 59 59 addMethod("hasPlayer", ExecutorLua0ret<Playable,bool>(&Playable::hasPlayer)) 60 ->addMethod("fire", ExecutorLua1<Playable, bool>(&Playable::fire)) 61 ->addMethod("loadModel", ExecutorLua2<WorldEntity,const std::string& ,float>(&WorldEntity::loadModel2)) 62 ->addMethod("setName", ExecutorLua1<BaseObject,const std::string&>(&BaseObject::setName)) 63 ->addMethod("hide", ExecutorLua0<WorldEntity>(&WorldEntity::hide)) 64 ->addMethod("unhide", ExecutorLua0<WorldEntity>(&WorldEntity::unhide)) 60 65 //Coordinates 61 66 ->addMethod("setAbsCoor", ExecutorLua3<PNode,float,float,float>(&PNode::setAbsCoor)) … … 352 357 // return; 353 358 354 // spaceship controlled movement 359 // spaceship controlled movement fire(bool bF){ this->bFire = bF;} 355 360 //if (this->getOwner() == this->getHostID()) 356 361 this->calculateVelocity(time); … … 404 409 Vector accel(0.0, 0.0, 0.0); 405 410 /* 406 Vector rot(0.0, 0.0, 0.0); // wird ben ötigt für Helicopter411 Vector rot(0.0, 0.0, 0.0); // wird ben�igt fr Helicopter 407 412 */ 408 413 //float rotVal = 0.0; … … 513 518 } 514 519 515 void SpaceShip::destroy( )520 void SpaceShip::destroy( WorldEntity* killer ) 516 521 { 517 522 PRINTF(0)("spaceship destroy\n"); -
trunk/src/world_entities/space_ships/space_ship.h
r9008 r9235 37 37 virtual void leftWorld(); 38 38 39 virtual void destroy( );39 virtual void destroy(WorldEntity* killer); 40 40 virtual void respawn(); 41 41 -
trunk/src/world_entities/space_ships/spacecraft_2d.cc
r9110 r9235 35 35 #include "debug.h" 36 36 37 #include "script_class.h" 38 39 37 40 CREATE_FACTORY(Spacecraft2D, CL_SPACECRAFT_2D); 38 41 39 /** 40 * destructs the spacecraft_2d, deletes alocated memory 41 */ 42 Spacecraft2D::~Spacecraft2D () 43 { 44 this->setPlayer(NULL); 45 delete this->toTravelHeight; 46 } 42 43 CREATE_SCRIPTABLE_CLASS(Spacecraft2D, CL_SPACECRAFT_2D, 44 addMethod("hasPlayer", ExecutorLua0ret<Playable,bool>(&Playable::hasPlayer)) 45 //Coordinates 46 ->addMethod("setAbsCoor", ExecutorLua3<PNode,float,float,float>(&PNode::setAbsCoor)) 47 ->addMethod("getAbsCoorX", ExecutorLua0ret<PNode, float>(&PNode::getAbsCoorX)) 48 ->addMethod("getAbsCoorY", ExecutorLua0ret<PNode, float>(&PNode::getAbsCoorY)) 49 ->addMethod("getAbsCoorZ", ExecutorLua0ret<PNode, float>(&PNode::getAbsCoorZ)) 50 ->addMethod("setAirFriction", ExecutorLua1<Spacecraft2D, float>(&Spacecraft2D::setAirFriction)) 51 ); 52 47 53 48 54 /** … … 76 82 this->loadParams(root); 77 83 84 85 78 86 //weapons: 79 Weapon* wpRight = new TestGun(0); 80 wpRight->setName("testGun Right"); 81 Weapon* wpLeft = new TestGun(1); 82 wpLeft->setName("testGun Left"); 83 //Weapon* cannon = dynamic_cast<Weapon*>(Factory::fabricate(CL_HYPERBLASTER)); 87 Weapon* wpRight = dynamic_cast<Weapon*>(Factory::fabricate(CL_LASER_CANNON)); 88 wpRight->setName("Cannon_Right"); 89 Weapon* wpLeft = dynamic_cast<Weapon*>(Factory::fabricate(CL_LASER_CANNON)); 90 wpLeft->setName("Cannon_Left"); 91 92 Weapon* turretLeft = dynamic_cast<Weapon*>(Factory::fabricate(CL_BOOMERANG_GUN)); 93 wpRight->setName("Turret_Left"); 94 Weapon* turretRight = dynamic_cast<Weapon*>(Factory::fabricate(CL_BOOMERANG_GUN)); 95 wpLeft->setName("Turret_Right"); 84 96 85 97 // cannon->setName("BFG"); … … 87 99 this->addWeapon(wpLeft, 1, 0); 88 100 this->addWeapon(wpRight,1 ,1); 101 this->addWeapon(turretLeft, 1, 2); 102 this->addWeapon(turretRight, 1, 3); 103 89 104 //this->addWeapon(cannon, 0, 2); 90 105 91 106 this->getWeaponManager().changeWeaponConfig(1); 92 107 dynamic_cast<Element2D*>(this->getWeaponManager().getFixedTarget())->setVisibility( false); 108 } 109 110 111 /** 112 * @brief destructs the spacecraft_2d, deletes alocated memory 113 */ 114 Spacecraft2D::~Spacecraft2D () 115 { 116 this->setPlayer(NULL); 117 delete this->toTravelHeight; 93 118 } 94 119 … … 109 134 this->cameraLook = 0.0f; 110 135 this->rotation = 0.0f; 111 this->acceleration = 10.0f; 112 this->airFriction = 2.0f; 113 114 115 this->setHealthMax(100); 116 this->setHealth(100); 136 this->acceleration = 20.0f; 137 this->airFriction = 0.0f; 138 139 140 this->setHealthMax(1000); 141 this->setHealth(1000); 142 this->setDamage(100.0f); 143 117 144 118 145 … … 122 149 this->travelNode = new PNode(); 123 150 151 this->loadModel("models/ships/mantawing.obj", 5.0f); 124 152 125 153 // camera - issue … … 166 194 this->getWeaponManager().setSlotCount(5); 167 195 168 this->getWeaponManager().setSlotPosition(0, Vector( -0.28, 1.186, -2.750));196 this->getWeaponManager().setSlotPosition(0, Vector(1.843, -0.335, 2.029) * 5.0); 169 197 this->getWeaponManager().setSlotCapability(0, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL); 170 198 171 this->getWeaponManager().setSlotPosition(1, Vector( -0.28, 1.186, 2.750));199 this->getWeaponManager().setSlotPosition(1, Vector(1.843, -0.335, -2.029) * 5.0); 172 200 this->getWeaponManager().setSlotCapability(1, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL); 173 201 174 this->getWeaponManager().setSlotPosition(2, Vector(-1.63, .809, -.003));175 this->getWeaponManager().setSlotCapability(2, WTYPE_HEAVY);176 177 202 /// TODO: THESE ARE TOO MUCH 178 this->getWeaponManager().setSlotPosition( 3, Vector(-1.63, .678, -.652));179 this->getWeaponManager().setSlotDirection( 3, Quaternion(-24/180 * M_PI, Vector(1,0,0)));180 181 this->getWeaponManager().setSlotPosition( 4, Vector(-1.63, .678, .652));182 this->getWeaponManager().setSlotDirection( 4, Quaternion(24/180 * M_PI, Vector(1,0,0)));203 this->getWeaponManager().setSlotPosition(2, Vector(-0.351, -.238, 1.406) * 5.0); 204 this->getWeaponManager().setSlotDirection(2, Quaternion(-1.7, Vector(0,1,0))); 205 206 this->getWeaponManager().setSlotPosition(3, Vector(-0.351, -.238, -1.406) * 5.0); 207 this->getWeaponManager().setSlotDirection(3, Quaternion(1.7, Vector(0,1,0))); 183 208 184 209 this->cameraNode.setRelCoor(1,5,0); … … 193 218 registerVar( new SynchronizeableFloat( &cameraLook, &cameraLook, "cameraLook", PERMISSION_OWNER ) ); 194 219 registerVar( new SynchronizeableFloat( &rotation, &rotation, "rotation", PERMISSION_OWNER ) ); 220 221 222 195 223 } 196 224 … … 285 313 286 314 State::getCameraNode()->setParentSoft(this->travelNode); 287 State::getCameraNode()->setRelCoorSoft(-3, 50,0);315 State::getCameraNode()->setRelCoorSoft(-3, 100,0); 288 316 State::getCameraTargetNode()->setParentSoft(this->travelNode); 289 State::getCameraTargetNode()->setRelCoorSoft( 0,0,0);317 State::getCameraTargetNode()->setRelCoorSoft(5,0,1); 290 318 291 319 … … 406 434 if (this->toTravelHeight != NULL) 407 435 { 408 this->travelNode->shiftCoor(Vector(0, (*toTravelHeight - this->travelNode->getAbsCoor().y) * dt , 0));436 this->travelNode->shiftCoor(Vector(0, (*toTravelHeight - this->travelNode->getAbsCoor().y) * dt * 10.0, 0)); 409 437 if (fabsf(this->travelNode->getAbsCoor().y - *this->toTravelHeight) < .1) 410 438 { … … 416 444 417 445 accel.y = 0.0; 446 418 447 Vector accelerationDir = this->getAbsDir().apply(accel * this->acceleration); 419 448 accelerationDir.y = 0.0; … … 424 453 425 454 this->velocity += (accelerationDir - damping)* dt; 455 456 if (this->getRelCoor().z > this->travelDistance.y && velocity.z > 0.0) 457 this->velocity.z = 0.0f; 458 if (this->getRelCoor().z < -this->travelDistance.y && velocity.z < 0.0) 459 this->velocity.z = 0.0f; 460 461 if (this->getRelCoor().x > this->travelDistance.x && velocity.x > 0.0) 462 this->velocity.x = 0.0f; 463 if (this->getRelCoor().x < -this->travelDistance.x && velocity.x < 0.0) 464 this->velocity.x = 0.0f; 465 466 426 467 this->shiftCoor (this->velocity * dt); 427 this->setRelDirSoft(Quaternion(0, Vector(0,0,0)), 1.0f); 468 if (accel.z == 0) 469 this->setRelDirSoft(Quaternion(0, Vector(0,0,0)), 5.0f); 470 else 471 this->setRelDirSoft(Quaternion(this->velocity.z * .004, Vector(1,0,0)), 4.5f); 428 472 } 429 473 break; … … 475 519 else if (cameraLook < -M_PI_4) 476 520 cameraLook = -M_PI_4; 477 //this->cameraNode.setRelDirSoft(this->direction,10);478 521 } 479 522 } -
trunk/src/world_entities/space_ships/spacecraft_2d.h
r9110 r9235 27 27 void setTravelDistance(const Vector2D& distance); 28 28 void setTravelDistance(float x, float y); 29 30 void setAirFriction(float friction) { this->airFriction = friction; }; 29 31 30 32 -
trunk/src/world_entities/spawning_point.cc
r9008 r9235 57 57 58 58 MessageManager::getInstance()->registerMessageHandler( MSGID_RESPAWN, respawnMessageHandler, NULL ); 59 60 this->setSynchronized( true ); 59 61 } 60 62 … … 102 104 void SpawningPoint::spawn(Playable* entity) 103 105 { 106 const std::list<BaseObject*> * list = ClassList::getList( CL_PLAYABLE ); 107 108 bool found = false; 109 110 if ( !list ) 111 return; 112 113 for ( std::list<BaseObject*>::const_iterator it = list->begin(); it != list->end(); it++ ) 114 { 115 if ( *it == entity ) 116 { 117 found = true; 118 break; 119 } 120 } 121 122 if ( !found ) 123 return; 124 104 125 PRINTF(0)("Spawningpoint spawns Entity (%s)\n", entity->getClassName()); 105 126 … … 137 158 this->spawn(it->entity); 138 159 139 if ( SharedNetworkData::getInstance()->isGameServer() ) 160 const std::list<BaseObject*> * list = ClassList::getList( CL_PLAYABLE ); 161 162 bool found = false; 163 164 if ( !list ) 165 return; 166 167 for ( std::list<BaseObject*>::const_iterator it2 = list->begin(); it2 != list->end(); it2++ ) 168 { 169 if ( *it2 == it->entity ) 170 { 171 found = true; 172 break; 173 } 174 } 175 176 if ( found && SharedNetworkData::getInstance()->isGameServer() ) 140 177 this->sendRespawnMessage( it->entity->getUniqueID() ); 141 178 … … 194 231 assert( Converter::byteArrayToInt( data+INTSIZE, &uniqueId ) == INTSIZE ); 195 232 233 PRINTF(0)("SPAWNMESSAGE %d\n", uniqueId); 234 196 235 SpawningPoint * sp = NULL; 197 236 Playable * playable = NULL; … … 203 242 for ( std::list<BaseObject*>::const_iterator it = list->begin(); it != list->end(); it++ ) 204 243 { 205 if ( dynamic_cast<SpawningPoint*>(*it)->getUniqueID() == uniqueId ) 244 PRINTF(0)("%d:%d\n", dynamic_cast<SpawningPoint*>(*it)->getUniqueID(), spUniqueId); 245 if ( dynamic_cast<SpawningPoint*>(*it)->getUniqueID() == spUniqueId ) 206 246 { 207 247 sp = dynamic_cast<SpawningPoint*>(*it); … … 213 253 if ( !sp ) 214 254 { 215 PRINTF( 2)("could not find spawning point\n");255 PRINTF(0)("could not find spawning point\n"); 216 256 return false; 217 257 } … … 233 273 if ( !playable ) 234 274 { 235 PRINTF( 2)("could not find playable\n");275 PRINTF(0)("could not find playable\n"); 236 276 return false; 237 277 } -
trunk/src/world_entities/test_entity.cc
r9003 r9235 116 116 if( this->lastCollided != entity) 117 117 { 118 this->destroy( );118 this->destroy( entity ); 119 119 this->lastCollided = entity; 120 120 … … 126 126 127 127 128 void TestEntity::destroy( )128 void TestEntity::destroy(WorldEntity* killer) 129 129 { 130 130 if( this->bDeath) -
trunk/src/world_entities/test_entity.h
r8778 r9235 25 25 void setAnim(int animationIndex, int animPlaybackMode); 26 26 27 virtual void destroy( );27 virtual void destroy(WorldEntity* killer); 28 28 29 29 virtual void tick (float time); -
trunk/src/world_entities/weapons/fps_sniper_rifle.cc
r9003 r9235 33 33 #include "fps_sniper_rifle.h" 34 34 35 36 #include "effects/explosion.h" 35 37 36 38 using namespace std; … … 145 147 return; 146 148 147 pj->setParent(PNode::getNullParent());149 // Explosion::explode(this, Vector(0.1,0.1,0.1)); 148 150 149 pj->setVelocity(this->getAbsDir().apply(Vector(1,0,0))*250 + VECTOR_RAND(5)); 151 pj->setParent(this); 152 pj->setParentMode(PNODE_ROTATE_AND_MOVE); 150 153 151 pj->setAbsCoor(this->getEmissionPoint()); 154 pj->setVelocity(this->getAbsDir().apply(Vector(1,0,0))*550 + VECTOR_RAND(5) ); 155 156 pj->setAbsCoor(this->getEmissionPoint() + this->getAbsDirX() * 25.0f); 152 157 pj->setAbsDir(this->getAbsDir()); 153 158 pj->activate(); -
trunk/src/world_entities/world_entity.cc
r9110 r9235 85 85 86 86 this->toList(OM_NULL); 87 87 88 88 registerVar( new SynchronizeableString( &this->md2TextureFileName, &this->md2TextureFileName, "md2TextureFileName" ) ); 89 89 modelFileName_handle = registerVarId( new SynchronizeableString( &modelFileName, &modelFileName, "modelFileName" ) ); 90 90 scaling_handle = registerVarId( new SynchronizeableFloat( &scaling, &scaling, "scaling" ) ); 91 91 list_handle = registerVarId( new SynchronizeableInt( (int*)&objectListNumber, &list_write, "list" ) ); 92 92 93 93 health_handle = registerVarId( new SynchronizeableFloat( &this->health, &this->health_write, "health" ) ); 94 94 healthMax_handle = registerVarId( new SynchronizeableFloat( &this->healthMax, &this->healthMax_write, "maxHealth" ) ); … … 209 209 this->buildObbTree(obbTreeDepth); 210 210 } 211 else /*if(fileName.find(".md3") != std::string::npos)*/211 else if(fileName.find(".md3") != std::string::npos) 212 212 { 213 213 PRINTF(4)("fetching MD3 file: %s\n", fileName.c_str()); … … 414 414 bool WorldEntity::registerCollision(WorldEntity* entityA, WorldEntity* entityB, BoundingVolume* bvA, BoundingVolume* bvB) 415 415 { 416 PRINTF(5)("registering collision of type: %s vs %s\n", entityA->getClassName(), entityB->getClassName()); 416 417 // is there any handler listening? 417 418 if( !this->bReactive) … … 571 572 */ 572 573 void WorldEntity::reset() 573 {} 574 { 575 this->setHealth( this->getHealthMax() ); 576 } 574 577 575 578 /** … … 742 745 this->decreaseHealth(damage); 743 746 744 PRINTF( 0)("Hit me: %s now only %f/%f health\n", this->getClassName(), this->getHealth(), this->getHealthMax());747 PRINTF(5)("Hit me: %s now only %f/%f health\n", this->getClassName(), this->getHealth(), this->getHealthMax()); 745 748 746 749 if( this->getHealth() > 0) … … 750 753 else 751 754 { 752 this->destroy(); 753 754 if( State::getGameRules() != NULL) 755 State::getGameRules()->registerKill(Kill(killer, this)); 755 this->destroy( killer ); 756 756 } 757 757 } … … 761 761 * destoys the world entity 762 762 */ 763 void WorldEntity::destroy( )763 void WorldEntity::destroy(WorldEntity* killer) 764 764 { 765 765 this->toList(OM_DEAD); … … 841 841 this->toList( (OM_LIST)list_write ); 842 842 } 843 843 844 844 if ( std::find( id.begin(), id.end(), health_handle ) != id.end() ) 845 845 { 846 846 this->setHealth( health_write ); 847 847 } 848 848 849 849 if ( std::find( id.begin(), id.end(), healthMax_handle ) != id.end() ) 850 850 { -
trunk/src/world_entities/world_entity.h
r9110 r9235 47 47 48 48 void loadModel(const std::string& fileName, float scaling = 1.0f, unsigned int modelNumber = 0, unsigned int obbTreeDepth = 4); 49 void loadModel2(const std::string& fileN, float scal = 1.0f){this->loadModel(fileN,scal,0,4);} 49 50 void setModel(Model* model, unsigned int modelNumber = 0); 50 51 Model* getModel(unsigned int modelNumber = 0) const { return (this->models.size() > modelNumber)? this->models[modelNumber] : NULL; }; … … 74 75 /** @returns a reference to the obb tree of this worldentity */ 75 76 inline BVTree* getOBBTree() const { return this->obbTree; }; 77 inline void setOBBTree(OBBTree* tree) { /*if( this->obbTree != NULL) delete this->obbTree;*/ this->obbTree = (BVTree*)tree; } 76 78 void drawBVTree(int depth, int drawMode) const; 77 inline AABB* getModelAABB() { return (this->aabbNode)?this->aabbNode->getAABB():NULL;}79 inline AABB* getModelAABB() const { return (this->aabbNode)?this->aabbNode->getAABB():NULL;} 78 80 79 81 /* --- Collision Reaction Block --- */ … … 101 103 virtual void hit(float damage, WorldEntity* killer); 102 104 103 virtual void destroy( );105 virtual void destroy( WorldEntity* killer ); 104 106 105 107 … … 198 200 int list_write; //!< entity's list 199 201 int list_handle; //!< handle for list changes 200 202 201 203 float health_write; 202 204 int health_handle; 203 205 204 206 float healthMax_write; 205 207 int healthMax_handle;
Note: See TracChangeset
for help on using the changeset viewer.