- Timestamp:
- Nov 27, 2015, 6:49:54 PM (9 years ago)
- Location:
- code/branches/fabienHS15
- Files:
-
- 36 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/fabienHS15/data/levels/includes/weaponSettingsAssff.oxi
r10814 r10878 45 45 </weaponpacks> 46 46 <munition> 47 <LaserMunition initialmagazines=8 maxmagazines=8 munitionpermagazine=10 replenishamount= 1 replenishinterval=0.5/>47 <LaserMunition initialmagazines=8 maxmagazines=8 munitionpermagazine=10 replenishamount=2 replenishinterval=7.5/> 48 48 <LightningMunition initialmagazines=4 maxmagazines=4 munitionpermagazine=8 /> 49 49 <RocketMunition initialmagazines=5 maxmagazines=5 munitionpermagazine=1 /> -
code/branches/fabienHS15/data/levels/includes/weaponSettingsAssff2.oxi
r10814 r10878 43 43 </weaponpacks> 44 44 <munition> 45 <LaserMunition initialmagazines=8 maxmagazines=8 munitionpermagazine=10 replenishamount=1 replenishinterval= 0.5/>45 <LaserMunition initialmagazines=8 maxmagazines=8 munitionpermagazine=10 replenishamount=1 replenishinterval=7.5/> 46 46 <LightningMunition initialmagazines=4 maxmagazines=4 munitionpermagazine=8 /> 47 47 <RocketMunition initialmagazines=5 maxmagazines=5 munitionpermagazine=1 /> -
code/branches/fabienHS15/data/levels/includes/weaponSettingsCollateral.oxi
r10814 r10878 47 47 </weaponpacks> 48 48 <munition> 49 <LaserMunition initialmagazines=8 maxmagazines=8 munitionpermagazine=10 replenishamount=1 replenishinterval= 0.5/>49 <LaserMunition initialmagazines=8 maxmagazines=8 munitionpermagazine=10 replenishamount=1 replenishinterval=7.5/> 50 50 <LightningMunition initialmagazines=4 maxmagazines=4 munitionpermagazine=8 /> 51 51 <RocketMunition initialmagazines=5 maxmagazines=5 munitionpermagazine=1 /> -
code/branches/fabienHS15/data/levels/includes/weaponSettingsEscort.oxi
r10791 r10878 27 27 </weaponpacks> 28 28 <munition> 29 <LaserMunition initialmagazines=8 maxmagazines=8 munitionpermagazine=10 replenishamount=1 replenishinterval= 0.5/>29 <LaserMunition initialmagazines=8 maxmagazines=8 munitionpermagazine=10 replenishamount=1 replenishinterval=7.5/> 30 30 </munition> -
code/branches/fabienHS15/data/levels/includes/weaponSettingsFPS.oxi
r10791 r10878 51 51 </weaponpacks> 52 52 <munition> 53 <LaserMunition initialmagazines=8 maxmagazines=8 munitionpermagazine=5 replenishamount=1 replenishinterval= 0.5/>53 <LaserMunition initialmagazines=8 maxmagazines=8 munitionpermagazine=5 replenishamount=1 replenishinterval=7.5/> 54 54 <LightningMunition initialmagazines=2 maxmagazines=2 munitionpermagazine=8 /> 55 55 </munition> -
code/branches/fabienHS15/data/levels/includes/weaponSettingsFPS_HS14.oxi
r10791 r10878 51 51 </weaponpacks> 52 52 <munition> 53 <LaserMunition initialmagazines=8 maxmagazines=8 munitionpermagazine=5 replenishamount=1 replenishinterval= 0.5/>53 <LaserMunition initialmagazines=8 maxmagazines=8 munitionpermagazine=5 replenishamount=1 replenishinterval=7.5/> 54 54 <LightningMunition initialmagazines=2 maxmagazines=2 munitionpermagazine=8 /> 55 55 </munition> -
code/branches/fabienHS15/data/levels/includes/weaponSettingsFS15.oxi
r10814 r10878 51 51 </weaponpacks> 52 52 <munition> 53 <LaserMunition initialmagazines=8 maxmagazines=8 munitionpermagazine=10 replenishamount=1 replenishinterval= 0.5/>53 <LaserMunition initialmagazines=8 maxmagazines=8 munitionpermagazine=10 replenishamount=1 replenishinterval=7.5/> 54 54 <LightningMunition initialmagazines=4 maxmagazines=4 munitionpermagazine=8 /> 55 55 <RocketMunition initialmagazines=5 maxmagazines=5 munitionpermagazine=1 /> -
code/branches/fabienHS15/data/levels/includes/weaponSettingsGhost.oxi
r10791 r10878 37 37 </weaponpacks> 38 38 <munition> 39 <LaserMunition initialmagazines=8 maxmagazines=8 munitionpermagazine=10 replenishamount=1 replenishinterval= 0.5/>39 <LaserMunition initialmagazines=8 maxmagazines=8 munitionpermagazine=10 replenishamount=1 replenishinterval=7.5/> 40 40 <LightningMunition initialmagazines=4 maxmagazines=4 munitionpermagazine=8 /> 41 41 <RocketMunition initialmagazines=5 maxmagazines=5 munitionpermagazine=1 /> -
code/branches/fabienHS15/data/levels/includes/weaponSettingsH2.oxi
r10791 r10878 44 44 </weaponpacks> 45 45 <munition> 46 <LaserMunition initialmagazines=10 maxmagazines=10 munitionpermagazine=10 replenishamount=1 replenishinterval= 0.5/>46 <LaserMunition initialmagazines=10 maxmagazines=10 munitionpermagazine=10 replenishamount=1 replenishinterval=7.5/> 47 47 </munition> 48 48 -
code/branches/fabienHS15/data/levels/includes/weaponSettingsHXY.oxi
r10791 r10878 26 26 </weaponpacks> 27 27 <munition> 28 <LaserMunition initialmagazines=10 maxmagazines=10 munitionpermagazine=10 replenishamount=1 replenishinterval= 0.5/>28 <LaserMunition initialmagazines=10 maxmagazines=10 munitionpermagazine=10 replenishamount=1 replenishinterval=7.5/> 29 29 <LightningMunition initialmagazines=4 maxmagazines=4 munitionpermagazine=8 /> 30 30 </munition> -
code/branches/fabienHS15/data/levels/includes/weaponSettingsHeartAttack.oxi
r10814 r10878 42 42 </weaponpacks> 43 43 <munition> 44 <LaserMunition initialmagazines=20 maxmagazines=20 munitionpermagazine=10 replenishamount=1 replenishinterval= 0.25/>44 <LaserMunition initialmagazines=20 maxmagazines=20 munitionpermagazine=10 replenishamount=1 replenishinterval=6.0/> 45 45 <LightningMunition initialmagazines=4 maxmagazines=4 munitionpermagazine=8 /> 46 46 <RocketMunition initialmagazines=8 maxmagazines=8 munitionpermagazine=1 /> -
code/branches/fabienHS15/data/levels/includes/weaponSettingsHeavyCruiser.oxi
r10814 r10878 45 45 </weaponpacks> 46 46 <munition> 47 <LaserMunition initialmagazines=12 maxmagazines=12 munitionpermagazine=10 replenishamount=1 replenishinterval= 0.3/>47 <LaserMunition initialmagazines=12 maxmagazines=12 munitionpermagazine=10 replenishamount=1 replenishinterval=5.0/> 48 48 <LightningMunition initialmagazines=4 maxmagazines=4 munitionpermagazine=8 /> 49 49 <RocketMunition initialmagazines=5 maxmagazines=5 munitionpermagazine=1 /> -
code/branches/fabienHS15/data/levels/includes/weaponSettingsHeavyCruiserBody.oxi
r10814 r10878 47 47 </weaponpacks> 48 48 <munition> 49 <LaserMunition initialmagazines=12 maxmagazines=12 munitionpermagazine=10 replenishamount=1 replenishinterval= 0.3/>49 <LaserMunition initialmagazines=12 maxmagazines=12 munitionpermagazine=10 replenishamount=1 replenishinterval=7.0/> 50 50 <LightningMunition initialmagazines=4 maxmagazines=4 munitionpermagazine=8 /> 51 51 <RocketMunition initialmagazines=5 maxmagazines=5 munitionpermagazine=1 /> -
code/branches/fabienHS15/data/levels/includes/weaponSettingsImmTest.oxi
r10814 r10878 57 57 </weaponpacks> 58 58 <munition> 59 <LaserMunition initialmagazines=12 maxmagazines=12 munitionpermagazine=10 replenishamount=1 replenishinterval= 0.3/>59 <LaserMunition initialmagazines=12 maxmagazines=12 munitionpermagazine=10 replenishamount=1 replenishinterval=7.0/> 60 60 <LightningMunition initialmagazines=4 maxmagazines=4 munitionpermagazine=8 /> 61 61 <RocketMunition initialmagazines=5 maxmagazines=5 munitionpermagazine=1 /> -
code/branches/fabienHS15/data/levels/includes/weaponSettingsPirate.oxi
r10791 r10878 24 24 </weaponpacks> 25 25 <munition> 26 <LaserMunition initialmagazines=12 maxmagazines=12 munitionpermagazine=10 replenishamount=1 replenishinterval= 0.3/>26 <LaserMunition initialmagazines=12 maxmagazines=12 munitionpermagazine=10 replenishamount=1 replenishinterval=7.0/> 27 27 </munition> -
code/branches/fabienHS15/data/levels/includes/weaponSettingsRing.oxi
r10791 r10878 30 30 </weaponpacks> 31 31 <munition> 32 <LaserMunition initialmagazines=12 maxmagazines=12 munitionpermagazine=10 replenishamount=1 replenishinterval= 0.3/>32 <LaserMunition initialmagazines=12 maxmagazines=12 munitionpermagazine=10 replenishamount=1 replenishinterval=7.5/> 33 33 <GravityBombMunition initialmagazines=8 maxmagazines=8 munitionpermagazine=1 /> 34 34 <IceMunition initialmagazines=16 maxmagazines=16 munitionpermagazine=1 /> -
code/branches/fabienHS15/data/levels/includes/weaponSettingsSpacecruiser.oxi
r10814 r10878 89 89 </weaponpacks> 90 90 <munition> 91 <LaserMunition initialmagazines=20 maxmagazines=20 munitionpermagazine=10 replenishamount=1 replenishinterval= 0.2/>91 <LaserMunition initialmagazines=20 maxmagazines=20 munitionpermagazine=10 replenishamount=1 replenishinterval=7.5/> 92 92 <LightningMunition initialmagazines=4 maxmagazines=4 munitionpermagazine=8 /> 93 93 <RocketMunition initialmagazines=5 maxmagazines=5 munitionpermagazine=1 /> -
code/branches/fabienHS15/data/levels/includes/weaponSettingsSwallow.oxi
r10791 r10878 25 25 </weaponpacks> 26 26 <munition> 27 <LaserMunition initialmagazines=20 maxmagazines=20 munitionpermagazine=10 replenishamount=1 replenishinterval= 0.5/>27 <LaserMunition initialmagazines=20 maxmagazines=20 munitionpermagazine=10 replenishamount=1 replenishinterval=7.5/> 28 28 <SplitMunition initialmagazines=4 maxmagazines=4 munitionpermagazine=8 /> 29 29 </munition> -
code/branches/fabienHS15/data/levels/includes/weaponSettingsTransporter.oxi
r10791 r10878 26 26 </weaponpacks> 27 27 <munition> 28 <LaserMunition initialmagazines=20 maxmagazines=20 munitionpermagazine=10 replenishamount=1 replenishinterval= 0.5/>28 <LaserMunition initialmagazines=20 maxmagazines=20 munitionpermagazine=10 replenishamount=1 replenishinterval=7.5/> 29 29 <LightningMunition initialmagazines=4 maxmagazines=4 munitionpermagazine=8 /> 30 30 </munition> -
code/branches/fabienHS15/data/levels/includes/weaponSettingsTurret.oxi
r10791 r10878 22 22 </weaponpacks> 23 23 <munition> 24 <LaserMunition initialmagazines=8 maxmagazines=8 munitionpermagazine=10 replenishamount=1 replenishinterval= 0.5/>24 <LaserMunition initialmagazines=8 maxmagazines=8 munitionpermagazine=10 replenishamount=1 replenishinterval=7.5/> 25 25 </munition> -
code/branches/fabienHS15/data/levels/includes/weaponSettingsTurret1.oxi
r10791 r10878 22 22 </weaponpacks> 23 23 <munition> 24 <LaserMunition initialmagazines=8 maxmagazines=8 munitionpermagazine=10 replenishamount=1 replenishinterval= 0.5/>24 <LaserMunition initialmagazines=8 maxmagazines=8 munitionpermagazine=10 replenishamount=1 replenishinterval=7.5/> 25 25 </munition> -
code/branches/fabienHS15/data/levels/includes/weaponSettingsbigship.oxi
r10814 r10878 48 48 </weaponpacks> 49 49 <munition> 50 <LaserMunition initialmagazines=12 maxmagazines=12 munitionpermagazine=10 replenishamount=1 replenishinterval= 0.4/>50 <LaserMunition initialmagazines=12 maxmagazines=12 munitionpermagazine=10 replenishamount=1 replenishinterval=7.5/> 51 51 <LightningMunition initialmagazines=4 maxmagazines=4 munitionpermagazine=8 /> 52 52 <RocketMunition initialmagazines=5 maxmagazines=5 munitionpermagazine=1 /> -
code/branches/fabienHS15/src/modules/overlays/hud/HUDEnemyShieldBar.cc
r10842 r10878 71 71 target = target->getParent(); 72 72 pawn = orxonox_cast<Pawn*>(target); 73 // Don't show the HealthBar if the pawn is invisible73 // Don't show the EnemyShieldBar if the pawn is invisible 74 74 if (pawn && !pawn->isVisible()) 75 75 pawn = NULL; 76 76 } 77 // Set the pawn as owner of the HealthBar77 // Set the pawn as owner of the EnemyShieldBar 78 78 this->setShieldBarOwner(pawn); 79 79 this->setVisible(pawn != NULL); -
code/branches/fabienHS15/src/modules/overlays/hud/HUDWeaponMode.cc
r10795 r10878 160 160 ReplenishingMunition* replenishingMunition = dynamic_cast<ReplenishingMunition*>(munition); 161 161 162 if (replenishingMunition->canAddM unition(1))162 if (replenishingMunition->canAddMagazines(1)) 163 163 { 164 164 float progress = 1.0f - replenishingMunition->getProgress(); -
code/branches/fabienHS15/src/modules/weapons/munitions/FusionMunition.cc
r10791 r10878 46 46 this->maxMunitionPerMagazine_ = 10; 47 47 this->maxMagazines_ = 10; 48 this-> magazines_ = 10;48 this->unassignedMagazines_ = 10; 49 49 50 50 this->deployment_ = MunitionDeployment::Separate; -
code/branches/fabienHS15/src/modules/weapons/munitions/GravityBombMunition.cc
r10791 r10878 18 18 this->maxMunitionPerMagazine_ = 1; 19 19 this->maxMagazines_ = 30; 20 this-> magazines_ = 15;20 this->unassignedMagazines_ = 15; 21 21 22 22 this->deployment_ = MunitionDeployment::Stack; -
code/branches/fabienHS15/src/modules/weapons/munitions/IceMunition.cc
r10791 r10878 46 46 this->maxMunitionPerMagazine_ = 1; 47 47 this->maxMagazines_ = 50; 48 this-> magazines_ = 25;48 this->unassignedMagazines_ = 25; 49 49 50 50 this->deployment_ = MunitionDeployment::Stack; -
code/branches/fabienHS15/src/modules/weapons/munitions/LaserMunition.cc
r10791 r10878 46 46 this->maxMunitionPerMagazine_ = 20; 47 47 this->maxMagazines_ = 10; 48 this-> magazines_ = 10;48 this->unassignedMagazines_ = 10; 49 49 50 50 this->deployment_ = MunitionDeployment::Separate; … … 53 53 this->bAllowMultiMunitionRemovementUnderflow_ = true; 54 54 55 this->replenishInterval_ = 0.5f;55 this->replenishInterval_ = 7.0f; 56 56 this->replenishAmount_ = 1; 57 57 -
code/branches/fabienHS15/src/modules/weapons/munitions/LightningMunition.cc
r10791 r10878 46 46 this->maxMunitionPerMagazine_ = 20; 47 47 this->maxMagazines_ = 1; 48 this-> magazines_ = 1;48 this->unassignedMagazines_ = 1; 49 49 50 50 this->deployment_ = MunitionDeployment::Share; -
code/branches/fabienHS15/src/modules/weapons/munitions/RocketMunition.cc
r10791 r10878 46 46 this->maxMunitionPerMagazine_ = 1; 47 47 this->maxMagazines_ = 30; 48 this-> magazines_ = 10;48 this->unassignedMagazines_ = 10; 49 49 50 50 this->deployment_ = MunitionDeployment::Stack; -
code/branches/fabienHS15/src/modules/weapons/munitions/SplitMunition.cc
r10791 r10878 46 46 this->maxMunitionPerMagazine_ = 5; 47 47 this->maxMagazines_ = 10; 48 this-> magazines_ = 5;48 this->unassignedMagazines_ = 5; 49 49 50 50 this->deployment_ = MunitionDeployment::Share; -
code/branches/fabienHS15/src/orxonox/controllers/HumanController.cc
r10624 r10878 199 199 @brief 200 200 Starts the boosting mode. 201 Resets the boosting timeout and ells the ControllableEntity to boost (or not boost anymore).201 Resets the boosting timeout and tells the ControllableEntity to boost (or not boost anymore). 202 202 */ 203 203 void HumanController::startBoosting(void) -
code/branches/fabienHS15/src/orxonox/weaponsystem/Munition.cc
r10791 r10878 44 44 this->maxMunitionPerMagazine_ = 10; 45 45 this->maxMagazines_ = 10; 46 this-> magazines_ = 10;46 this->unassignedMagazines_ = 10; 47 47 48 48 this->deployment_ = MunitionDeployment::Stack; … … 57 57 Munition::~Munition() 58 58 { 59 for (std::map<WeaponMode*, Magazine*>::iterator it = this-> currentMagazines_.begin(); it != this->currentMagazines_.end(); ++it)59 for (std::map<WeaponMode*, Magazine*>::iterator it = this->assignedMagazines_.begin(); it != this->assignedMagazines_.end(); ++it) 60 60 delete it->second; 61 61 } … … 79 79 80 80 // Use the map to get the magazine assigned to the given user 81 std::map<WeaponMode*, Magazine*>::const_iterator it = this-> currentMagazines_.find(user);82 if (it != this-> currentMagazines_.end())81 std::map<WeaponMode*, Magazine*>::const_iterator it = this->assignedMagazines_.find(user); 82 if (it != this->assignedMagazines_.end()) 83 83 return it->second; 84 84 } … … 86 86 { 87 87 // We don't use separate magazines for each user, so just take the first magazine 88 if (this-> currentMagazines_.size() > 0)89 return this-> currentMagazines_.begin()->second;88 if (this->assignedMagazines_.size() > 0) 89 return this->assignedMagazines_.begin()->second; 90 90 } 91 91 … … 100 100 if (deployment_ == MunitionDeployment::Stack) 101 101 // With stacked munition every magazine contributes to the total amount 102 return this->maxMunitionPerMagazine_ * this-> magazines_ + magazine->munition_;102 return this->maxMunitionPerMagazine_ * this->unassignedMagazines_ + magazine->munition_; 103 103 else 104 104 // Wihtout stacked munition we just consider the current magazine … … 125 125 Magazine* magazine = this->getMagazine(0); 126 126 if (magazine && magazine->munition_ == this->maxMunitionPerMagazine_) 127 return this-> magazines_ + 1;128 } 129 130 return this-> magazines_;127 return this->unassignedMagazines_ + 1; 128 } 129 130 return this->unassignedMagazines_; 131 131 } 132 132 133 133 void Munition::setNumMagazines(unsigned int numMagazines) 134 134 { 135 this-> magazines_ = numMagazines;135 this->unassignedMagazines_ = numMagazines; 136 136 } 137 137 … … 154 154 if (deployment_ == MunitionDeployment::Stack) 155 155 { 156 munition += this->maxMunitionPerMagazine_ * this-> magazines_;156 munition += this->maxMunitionPerMagazine_ * this->unassignedMagazines_; 157 157 } 158 158 … … 200 200 magazine->munition_ = 0; 201 201 202 if (this->reload( 0))202 if (this->reload(NULL)) 203 203 // Successfully reloaded, continue recursively 204 204 return this->takeMunition(amount, 0); … … 224 224 { 225 225 // As long as we have enough magazines (and don't stack munition) we can reload 226 return (this-> magazines_ > 0 && deployment_ != MunitionDeployment::Stack);226 return (this->unassignedMagazines_ > 0 && deployment_ != MunitionDeployment::Stack); 227 227 } 228 228 … … 252 252 253 253 // Check if we actually can reload 254 if (this-> magazines_ == 0)254 if (this->unassignedMagazines_ == 0) 255 255 return false; 256 256 … … 266 266 267 267 // Remove the current magazine for the given user 268 std::map<WeaponMode*, Magazine*>::iterator it = this-> currentMagazines_.find(user);269 if (it != this-> currentMagazines_.end())268 std::map<WeaponMode*, Magazine*>::iterator it = this->assignedMagazines_.find(user); 269 if (it != this->assignedMagazines_.end()) 270 270 { 271 271 if (it->first == lastFilledWeaponMode_) … … 274 274 } 275 275 delete it->second; 276 this-> currentMagazines_.erase(it);276 this->assignedMagazines_.erase(it); 277 277 } 278 278 279 279 // Load a new magazine 280 this-> currentMagazines_[user] = new Magazine(this, bUseReloadTime);281 this-> magazines_--;280 this->assignedMagazines_[user] = new Magazine(this, bUseReloadTime); 281 this->unassignedMagazines_--; 282 282 283 283 return true; … … 299 299 { 300 300 // Return true if any of the current magazines is not full (loading counts as full although it returns 0 munition) 301 for (std::map<WeaponMode*, Magazine*>::const_iterator it = this-> currentMagazines_.begin(); it != this->currentMagazines_.end(); ++it)301 for (std::map<WeaponMode*, Magazine*>::const_iterator it = this->assignedMagazines_.begin(); it != this->assignedMagazines_.end(); ++it) 302 302 if (it->second->munition_ < this->maxMunitionPerMagazine_ && it->second->bLoaded_) 303 303 return true; … … 325 325 { 326 326 magazine->munition_ -= this->maxMunitionPerMagazine_; 327 this-> magazines_++;327 this->unassignedMagazines_++; 328 328 } 329 329 330 330 // If we reached the limit, reduce both magazines and munition to the maximum 331 if (this-> magazines_ >= this->maxMagazines_)332 { 333 this-> magazines_ = this->maxMagazines_;331 if (this->unassignedMagazines_ >= this->maxMagazines_) 332 { 333 this->unassignedMagazines_ = this->maxMagazines_; 334 334 magazine->munition_ = this->maxMunitionPerMagazine_; 335 335 } … … 349 349 if (lastFilledWeaponMode_ == NULL) 350 350 { 351 it = this-> currentMagazines_.begin();351 it = this->assignedMagazines_.begin(); 352 352 } 353 353 else 354 354 { 355 it = this-> currentMagazines_.find(lastFilledWeaponMode_);355 it = this->assignedMagazines_.find(lastFilledWeaponMode_); 356 356 ++ it; 357 357 } … … 362 362 { 363 363 bool change = false; 364 while (it != this-> currentMagazines_.end())364 while (it != this->assignedMagazines_.end()) 365 365 { 366 366 // Add munition if the magazine isn't full (but only to loaded magazines) … … 383 383 } 384 384 385 it = this-> currentMagazines_.begin();385 it = this->assignedMagazines_.begin(); 386 386 firstLoop = false; 387 387 } … … 400 400 else 401 401 // If we don't stack munition, we're more limited 402 return ((this->currentMagazines_.size() + this->magazines_) < this->maxMagazines_); 403 } 404 405 bool Munition::addMagazines(unsigned int amount) 406 { 402 return ((this->assignedMagazines_.size() + this->unassignedMagazines_) < this->maxMagazines_); 403 } 404 405 unsigned int Munition::addMagazines(unsigned int amount) 406 { 407 unsigned int addedMagazines = 0; 408 407 409 if (!this->canAddMagazines(amount)) 408 return false;410 return 0; 409 411 410 412 // Calculate how many magazines are needed 411 int needed_magazines = this->maxMagazines_ - this-> magazines_ - this->currentMagazines_.size();413 int needed_magazines = this->maxMagazines_ - this->unassignedMagazines_ - this->assignedMagazines_.size(); 412 414 413 415 // If zero or less magazines are needed, we definitively don't need more magazines (unless we stack munition - then a magazine contributes directly to the munition) 414 416 if (needed_magazines <= 0 && deployment_ != MunitionDeployment::Stack) 415 return false;417 return 0; 416 418 417 419 if (amount <= static_cast<unsigned int>(needed_magazines)) 418 420 { 419 421 // We need more magazines than we get, so just add them 420 this->magazines_ += amount; 422 this->unassignedMagazines_ += amount; 423 addedMagazines = amount; 421 424 } 422 425 else 423 426 { 424 427 // We get more magazines than we need, so just add the needed amount 425 this->magazines_ += needed_magazines; 428 this->unassignedMagazines_ += needed_magazines; 429 addedMagazines = needed_magazines; 426 430 if (deployment_ == MunitionDeployment::Stack) 427 431 { … … 433 437 } 434 438 435 return true; 439 // Reload as many empty magazines as possible 440 // Double loop and break is needed because the reload function changes the assigned magazines. This may confuse the iterator. 441 for (unsigned int i = 0; i < addedMagazines; ++i) 442 { 443 for (std::map<WeaponMode*, Magazine*>::iterator it = this->assignedMagazines_.begin(); it != this->assignedMagazines_.end(); ++it) 444 { 445 if (needReload(it->first)) 446 { 447 reload(it->first); 448 break; 449 } 450 } 451 } 452 453 return addedMagazines; 436 454 } 437 455 … … 440 458 if (deployment_ == MunitionDeployment::Stack) 441 459 { 442 if (this-> magazines_ >= amount)460 if (this->unassignedMagazines_ >= amount) 443 461 { 444 462 // We have enough magazines 445 463 return true; 446 464 } 447 else if (this-> magazines_ == amount - 1)465 else if (this->unassignedMagazines_ == amount - 1) 448 466 { 449 467 // We lack one magazine, check if the current magazine is still full, if yes we're fine … … 461 479 { 462 480 // In case we're not stacking munition, just check the number of magazines 463 return (this-> magazines_ >= amount);481 return (this->unassignedMagazines_ >= amount); 464 482 } 465 483 … … 472 490 return false; 473 491 474 if (this-> magazines_ >= amount)492 if (this->unassignedMagazines_ >= amount) 475 493 { 476 494 // We have enough magazines, just remove the amount 477 this-> magazines_ -= amount;495 this->unassignedMagazines_ -= amount; 478 496 } 479 497 else if (deployment_ == MunitionDeployment::Stack) 480 498 { 481 499 // We don't have enough magazines, but we're stacking munition, so additionally remove the bullets from the current magazine 482 this-> magazines_ = 0;500 this->unassignedMagazines_ = 0; 483 501 Magazine* magazine = this->getMagazine(0); 484 502 if (magazine) … … 500 518 501 519 // Remove the current magazine for the given user 502 std::map<WeaponMode*, Magazine*>::iterator it = this-> currentMagazines_.find(user);503 if (it != this-> currentMagazines_.end())520 std::map<WeaponMode*, Magazine*>::iterator it = this->assignedMagazines_.find(user); 521 if (it != this->assignedMagazines_.end()) 504 522 { 505 523 if (it->first == lastFilledWeaponMode_) … … 508 526 } 509 527 delete it->second; 510 this-> currentMagazines_.erase(it);528 this->assignedMagazines_.erase(it); 511 529 return true; 512 530 } -
code/branches/fabienHS15/src/orxonox/weaponsystem/Munition.h
r10794 r10878 97 97 98 98 bool canAddMagazines(unsigned int amount) const; 99 bool addMagazines(unsigned int amount); 99 /** 100 @brief Try to add magazines. 101 @param amount The amount of magazines tried to add. 102 @return The amount of magazines sucessfully added. 103 */ 104 unsigned int addMagazines(unsigned int amount); 100 105 101 106 bool canRemoveMagazines(unsigned int amount) const; … … 107 112 unsigned int maxMunitionPerMagazine_; 108 113 unsigned int maxMagazines_; 109 unsigned int magazines_;110 std::map<WeaponMode*, Magazine*> currentMagazines_; // Maps weapon modes to magazines that are currently used.114 unsigned int unassignedMagazines_; // Number of magazines that are not assigned to a weapon mode. These are alway treated as full. 115 std::map<WeaponMode*, Magazine*> assignedMagazines_; // Maps weapon modes to magazines that are currently used. 111 116 112 117 MunitionDeployment::Value deployment_; // Defines the behaviour how munition and magazines are distributed to the consuming weapon modes. … … 115 120 bool bAllowMultiMunitionRemovementUnderflow_; 116 121 117 float reloadTime_; 122 float reloadTime_; // The time needed to replace a magazine by a new one. 118 123 WeaponMode* lastFilledWeaponMode_; // Pointer to the weapon mode that got the last munition during the last call of addMunition. 119 124 -
code/branches/fabienHS15/src/orxonox/weaponsystem/ReplenishingMunition.cc
r10791 r10878 76 76 void ReplenishingMunition::replenish() 77 77 { 78 if (this->canAddM unition(this->replenishAmount_))78 if (this->canAddMagazines(this->replenishAmount_)) 79 79 { 80 80 // Make a temporary copy of bAllowMunitionRefilling_, because this might be disallowed in every … … 84 84 85 85 // Replenish munition 86 this->addM unition(this->replenishAmount_);86 this->addMagazines(this->replenishAmount_); 87 87 88 88 // Write back the temporary value -
code/branches/fabienHS15/src/orxonox/weaponsystem/ReplenishingMunition.h
r10791 r10878 64 64 protected: 65 65 float replenishInterval_; //!< The interval in which the munition is replenished. 66 unsigned int replenishAmount_; //!< The amount by which it is replenished.66 unsigned int replenishAmount_; //!< The amount of magazines by which it is replenished. 67 67 68 68 private: 69 void replenish(); 69 void replenish(); //!< Every call of this function replenishes the munition. This function is called by the timer. 70 70 void initializeTimer(); 71 71
Note: See TracChangeset
for help on using the changeset viewer.