Changeset 9235 in orxonox.OLD for trunk/src/world_entities/creatures
- Timestamp:
- Jul 5, 2006, 4:39:02 PM (18 years ago)
- Location:
- trunk/src/world_entities/creatures
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
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
Note: See TracChangeset
for help on using the changeset viewer.