Changeset 6671 in orxonox.OLD for trunk/src/world_entities/weapons/weapon.cc
- Timestamp:
- Jan 24, 2006, 2:52:25 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/world_entities/weapons/weapon.cc
r6512 r6671 95 95 this->maxCharge = 1.0; //< The maximum charge is also one unit. 96 96 97 this->energyLoaded = .0; //< How much energy is loaded in the Gun. (Weapons must be charged befor usage) 98 this->energyLoadedMax = 5.0; //< Each Weapon has a Maximum energy that can be charged onto it 99 this->energy = .0; //< The secondary Buffer (before we have to reload) 97 this->energy = 10; //< The secondary Buffer (before we have to reload) 100 98 this->energyMax = 10.0; //< How much energy can be carried 101 99 this->capability = WTYPE_ALL; //< The Weapon has all capabilities @see W_Capability. 102 100 103 101 this->energyWidget = NULL; 104 this->energyLoadedWidget = NULL;105 102 } 106 103 … … 288 285 } 289 286 290 291 GLGuiWidget* Weapon::getLoadedEnergyWidget()292 {293 if (this->energyLoadedWidget == NULL)294 {295 this->energyLoadedWidget = new GLGuiBar;296 //this->energyLoadedWidget->setParent2D(this->bar);297 this->energyLoadedWidget->setRelCoor2D(20,0);298 this->energyLoadedWidget->setSize2D(10,50);299 this->energyLoadedWidget->setMaximum(this->getLoadedEnergyMax());300 }301 return this->energyLoadedWidget;302 }303 304 287 void Weapon::updateWidgets() 305 288 { … … 308 291 this->energyWidget->setMaximum(this->energyMax); 309 292 this->energyWidget->setValue(this->energy); 310 }311 if (this->energyLoadedWidget != NULL)312 {313 this->energyLoadedWidget->setMaximum(this->energyLoadedMax);314 this->energyLoadedWidget->setValue(this->energyLoaded);315 293 } 316 294 } … … 392 370 switch (action) 393 371 { 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 372 case WA_SHOOT: 373 return this->fireW(); 374 break; 375 case WA_CHARGE: 376 return this->chargeW(); 377 break; 378 case WA_RELOAD: 379 return this->reloadW(); 380 break; 381 case WA_DEACTIVATE: 382 return this->deactivateW(); 383 break; 384 case WA_ACTIVATE: 385 return this->activateW(); 386 break; 409 387 } 410 388 } … … 454 432 bool Weapon::chargeW() 455 433 { 456 if ( this->currentState != WS_INACTIVE && this->energy Loaded>= this->minCharge)434 if ( this->currentState != WS_INACTIVE && this->energy >= this->minCharge) 457 435 { 458 436 // playing Sound … … 478 456 { 479 457 //if (likely(this->currentState != WS_INACTIVE)) 480 if (this->minCharge <= this->energy Loaded)458 if (this->minCharge <= this->energy) 481 459 { 482 460 // playing Sound … … 485 463 this->updateWidgets(); 486 464 // fire 487 this->energy Loaded-= this->minCharge;465 this->energy -= this->minCharge; 488 466 this->fire(); 489 467 // setting up for the next state … … 504 482 { 505 483 PRINTF(4)("Reloading Weapon %s\n", this->getName()); 506 if (unlikely(this->energy + this->energyLoaded < this->minCharge)) 484 if (this->ammoContainer.get() != NULL && 485 unlikely(this->energy + this->ammoContainer->getStoredEnergy() < this->minCharge)) 507 486 { 508 487 this->requestAction(WA_DEACTIVATE); … … 511 490 } 512 491 513 float chargeSize = this->energyLoadedMax - this->energyLoaded; //!< The energy to be charged514 492 515 493 if (this->soundBuffers[WA_RELOAD] != NULL) 516 494 this->soundSource->play(this->soundBuffers[WA_RELOAD]); 517 495 518 if (chargeSize > this->energy) 519 { 520 this->energyLoaded += this->energy; 521 this->energy = 0.0; 522 PRINT(5)("Energy depleted\n"); 523 } 524 else 525 { 526 PRINTF(5)("Loaded %f energy into the Guns Buffer\n", chargeSize); 527 this->energyLoaded += chargeSize; 528 this->energy -= chargeSize; 529 } 530 496 if (this->ammoContainer.get() != NULL) 497 this->ammoContainer->fillWeapon(this); 498 else 499 { 500 this->energy = this->energyMax; 501 } 531 502 this->updateWidgets(); 532 503 this->reload(); … … 614 585 { 615 586 PRINT(0)("Weapon-Debug %s, state: %s (duration: %fs), nextAction: %s\n", this->getName(), Weapon::stateToChar(this->currentState), this->stateDuration, Weapon::actionToChar(requestedAction)); 616 PRINT(0)("Energy: max: %f; current: %f; loadedMax: %f; loadedCurrent: %f;chargeMin: %f, chargeMax %f\n",617 this->energyMax, this->energy, this-> energyLoadedMax, this->energyLoaded, this->minCharge, this->maxCharge);587 PRINT(0)("Energy: max: %f; current: %f; chargeMin: %f, chargeMax %f\n", 588 this->energyMax, this->energy, this->minCharge, this->maxCharge); 618 589 619 590 … … 660 631 switch (action) 661 632 { 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 633 case WA_SHOOT: 634 return "shoot"; 635 break; 636 case WA_CHARGE: 637 return "charge"; 638 break; 639 case WA_RELOAD: 640 return "reload"; 641 break; 642 case WA_ACTIVATE: 643 return "activate"; 644 break; 645 case WA_DEACTIVATE: 646 return "deactivate"; 647 break; 648 case WA_SPECIAL1: 649 return "special1"; 650 break; 651 default: 652 return "none"; 653 break; 683 654 } 684 655 } … … 723 694 switch (state) 724 695 { 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 } 750 } 696 case WS_SHOOTING: 697 return "shooting"; 698 break; 699 case WS_CHARGING: 700 return "charging"; 701 break; 702 case WS_RELOADING: 703 return "reloading"; 704 break; 705 case WS_ACTIVATING: 706 return "activating"; 707 break; 708 case WS_DEACTIVATING: 709 return "deactivating"; 710 break; 711 case WS_IDLE: 712 return "idle"; 713 break; 714 case WS_INACTIVE: 715 return "inactive"; 716 break; 717 default: 718 return "none"; 719 break; 720 } 721 }
Note: See TracChangeset
for help on using the changeset viewer.