Changeset 6671 in orxonox.OLD for trunk/src/world_entities/weapons
- Timestamp:
- Jan 24, 2006, 2:52:25 PM (19 years ago)
- Location:
- trunk/src/world_entities/weapons
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/world_entities/weapons/aiming_turret.cc
r6637 r6671 86 86 this->setStateDuration(WS_DEACTIVATING, .4); 87 87 88 this->set MaximumEnergy(10000, 50);88 this->setEnergyMax(10000); 89 89 this->increaseEnergy(100000); 90 90 -
trunk/src/world_entities/weapons/ammo_container.h
r6669 r6671 28 28 float decreaseEnergy(float energy); 29 29 30 float getStoredEnergy() const { return this->energy; }; 30 31 float getMaxEnergy() const { return this->maxEnergy; }; 31 32 -
trunk/src/world_entities/weapons/cannon.cc
r6517 r6671 81 81 this->setStateDuration(WS_DEACTIVATING, .4); 82 82 83 this->set MaximumEnergy(100, 20);83 this->setEnergyMax(100); 84 84 this->increaseEnergy(100); 85 85 //this->minCharge = 2; -
trunk/src/world_entities/weapons/targeting_turret.cc
r6637 r6671 80 80 this->setStateDuration(WS_DEACTIVATING, .4); 81 81 82 this->set MaximumEnergy(10000, 50);82 this->setEnergyMax(10000); 83 83 this->increaseEnergy(100000); 84 84 -
trunk/src/world_entities/weapons/test_gun.cc
r6512 r6671 122 122 this->setStateDuration(WS_DEACTIVATING, .4); 123 123 124 this->set MaximumEnergy(1000, 100);124 this->setEnergyMax(1000); 125 125 this->increaseEnergy(1000); 126 126 //this->minCharge = 2; -
trunk/src/world_entities/weapons/turret.cc
r6589 r6671 86 86 this->setStateDuration(WS_DEACTIVATING, .4); 87 87 88 this->set MaximumEnergy(100, 5);88 this->setEnergyMax(100); 89 89 this->increaseEnergy(100); 90 90 //this->minCharge = 2; -
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 } -
trunk/src/world_entities/weapons/weapon.h
r6669 r6671 137 137 inline WeaponState getCurrentState() const { return this->currentState; }; 138 138 139 /** @param energyMax the maximum energy the Weapon can have @param energyLoadedMax the maximum energy in the weapon buffers*/140 inline void set MaximumEnergy(float energyMax, float energyLoadedMax) { this->energyMax = energyMax; this->energyLoadedMax = energyLoadedMax; };141 inline float get LoadedEnergyMax() const { return this->energyLoadedMax; };139 /** @param energyMax the maximum energy the Weapon can have */ 140 inline void setEnergyMax(float energyMax) { this->energyMax = energyMax; }; 141 inline float getEnergy() const { return this->energy; }; 142 142 inline float getEnergyMax() const { return this->energyMax; }; 143 143 inline void setAmmoContainer(const CountPointer<AmmoContainer>& ammoContainer) { this->ammoContainer = ammoContainer;} 144 inline float getEnergy() const { return this->energy; };145 inline float getLoadedEnergy() const { return this->energyLoaded; };146 144 147 145 void setActionSound(WeaponAction action, const char* soundFile); … … 153 151 154 152 GLGuiWidget* getEnergyWidget(); 155 GLGuiWidget* getLoadedEnergyWidget();156 153 157 154 // FLOW … … 201 198 202 199 // it is all about energy 203 float energy; //!< The energy stored in the weapons secondary buffers (reserve)204 float energy Loaded; //!< The energy stored in the weapons primary buffers (fire without reload)200 float energy; //!< The energy stored in the weapons buffers 201 float energyMax; //!< The maximal energy that can be stored in the secondary buffers (reserveMax) 205 202 CountPointer<AmmoContainer> ammoContainer; //!< Pointer to the AmmoContainer this weapon grabs Energy from. 206 float energyMax; //!< The maximal energy that can be stored in the secondary buffers (reserveMax)207 float energyLoadedMax; //!< The maximal energy that can be stored in the primary buffers208 203 //! @todo move this to projectile 209 204 float minCharge; //!< The minimal energy to be loaded onto one projectile if chargeable otherwise the power consumed by one projectile … … 211 206 212 207 GLGuiBar* energyWidget; 213 GLGuiBar* energyLoadedWidget;214 208 215 209 ////////////
Note: See TracChangeset
for help on using the changeset viewer.