Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 19, 2016, 5:04:41 PM (8 years ago)
Author:
sagerj
Message:

done/fixed everything, weaponmode/discharger fully commented only hudchargebar left

Location:
code/branches/sagerjFS16/src/orxonox/weaponsystem
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/branches/sagerjFS16/src/orxonox/weaponsystem/WeaponMode.cc

    r11185 r11189  
    2424 *      Fabian 'x3n' Landau
    2525 *   Co-authors:
    26  *      ...
     26 *      Johannes Sager
    2727 *
    2828 */
     
    6363        this->bAutoReload_ = true;
    6464        this->bParallelReload_ = true;
    65         this->chargeable_ = false;
    66         this->charges_ = 0;
    67         this->maxCharges_ = 100;
     65        this->chargeable_ = false;              // most weapons are not chargeable
     66        this->charges_ = 0;                     // always start with no charges
     67        this->maxCharges_ = 100;                // default maximum charges one can have are 100
    6868
    6969        this->reloadTimer_.setTimer(0.0f, false, createExecutor(createFunctor(&WeaponMode::reloaded, this)));
     
    123123    bool WeaponMode::fire(float* reloadTime)
    124124    {
    125         orxout() << "--- " << endl;
    126125        (*reloadTime) = this->reloadTime_;
    127126        // Fireing is only possible if this weapon mode is not reloading and there is enough munition
     
    175174    {
    176175
    177         if( this->chargeable_)
    178         {
    179             if(this->charges_ < this->maxCharges_){
    180                 this->charges_ += 1;
    181             }
     176        if( this->chargeable_)                                                                                                          // chargeable weapons are supposed to charge on push
     177        {
     178            this->munition_ = this->weapon_->getWeaponPack()->getWeaponSystem()->getMunition(&this->munitiontype_);                     // updates the pointer to the munition(which we use in the next step)
     179            if(this->charges_ < this->maxCharges_ && this->bReloading_ == false && this->munition_->canTakeMunition(1, this))           // charges up unless:
     180            {                                                                                                                           // - we are fully charged
     181                this->charges_ += 1;                                                                                                    // - we are reloading
     182            }                                                                                                                           // - we have no munition
    182183            return false;
    183         } else {
     184        }
     185        else                                                                                                                            // normal (not chargeable) weapons are supposed to fire on push
     186        {
    184187            return fire(reloadTime);
    185188        }
    186189    }
    187190
    188     bool WeaponMode::release(float* reloadTime)
    189     {
    190         if( this->chargeable_)
     191    bool WeaponMode::release(float* reloadTime)                 
     192    {
     193        if( this->chargeable_)                                                                                                          // chargeable weapons are supposed to fire on release
    191194        {
    192195            return fire(reloadTime);
    193         }else{
     196        }
     197        else                                                                                                                            // normal (not chargeable) weapons should do nothing on release
     198        {
    194199            return false;
    195200        }
  • code/branches/sagerjFS16/src/orxonox/weaponsystem/WeaponMode.h

    r11185 r11189  
    2424 *      Fabian 'x3n' Landau
    2525 *   Co-authors:
    26  *      ...
     26 *      Johannes Sager
    2727 *
    2828 */
     
    110110
    111111            // Fire
    112             inline unsigned int getMaxCharges()
     112            inline unsigned int getMaxCharges()                 // get the maximum of charges one can have
    113113                { return this->maxCharges_;}
    114             inline unsigned int getCharges()
     114            inline unsigned int getCharges()                    // get the current amount of charges
    115115                { return this->charges_;}
    116             inline bool isChargeable()
     116            inline bool isChargeable()                          // returns if the weaponmode is chargeable
    117117                { return this->chargeable_;}
    118118            inline void setDamage(float damage)
     
    176176            unsigned int initialMagazines_;
    177177            unsigned int munitionPerShot_;
    178             unsigned int charges_;
    179             unsigned int maxCharges_;
     178            unsigned int charges_;                  // current amount of charges only matters for chargeable weapons(chargeable == true)
     179            unsigned int maxCharges_;               // maximum amount of charges (is initialized with 100 in weaponmode.cc) only matters for chargeable weapons(chargeable == true)
    180180
    181181            float reloadTime_;
    182             bool bAutoReload_; // If true, the weapon reloads the magazine automatically.
    183             bool bParallelReload_; // If true, the weapon reloads in parallel to the magazine reloading.
    184             bool chargeable_; // If true, the weapon fires at release instead at push(where he charges up)
     182            bool bAutoReload_;                      // If true, the weapon reloads the magazine automatically.
     183            bool bParallelReload_;                  // If true, the weapon reloads in parallel to the magazine reloading.
     184            bool chargeable_;                       // If true, the weapon charges up on push and fires on release
    185185
    186186            float damage_;
     
    202202
    203203            Timer reloadTimer_;
    204             bool bReloading_; // If true, this weapon mode is marked as reloading.
     204            bool bReloading_;                       // If true, this weapon mode is marked as reloading.
    205205
    206206            Vector3 muzzlePosition_;
    207207            Quaternion muzzleOrientation_;
    208208
    209             std::string fireSoundPath_; // The path of the sound played when fireing
    210             float fireSoundVolume_; // The volume of the sound played when fireing
    211             std::vector<WorldSound*> fireSounds_; // List of sounds used by the weapon mode. Because multiple sounds may overlap, we need mor than one WorldSound instance.
    212             std::string reloadSoundPath_; // The path of the sound played when reloading
    213             float reloadSoundVolume_; // The volume of the sound played when reloading
     209            std::string fireSoundPath_;             // The path of the sound played when fireing
     210            float fireSoundVolume_;                 // The volume of the sound played when fireing
     211            std::vector<WorldSound*> fireSounds_;   // List of sounds used by the weapon mode. Because multiple sounds may overlap, we need mor than one WorldSound instance.
     212            std::string reloadSoundPath_;           // The path of the sound played when reloading
     213            float reloadSoundVolume_;               // The volume of the sound played when reloading
    214214            WorldSound* reloadSound_;
    215215    };
Note: See TracChangeset for help on using the changeset viewer.