Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Mar 26, 2009, 2:56:39 PM (16 years ago)
Author:
polakma
Message:

added unlimited munition, reverted shared munition and fixed some bugs

Location:
code/branches/weaponsystem/src/orxonox/objects/weaponSystem
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • code/branches/weaponsystem/src/orxonox/objects/weaponSystem/Weapon.cc

    r2804 r2852  
    6868        XMLPortParam(Weapon, "bulletLoadingTime", setBulletLoadingTime, getBulletLoadingTime, xmlelement, mode);
    6969        XMLPortParam(Weapon, "magazineLoadingTime", setMagazineLoadingTime, getMagazineLoadingTime, xmlelement, mode);
    70         XMLPortParam(Weapon, "bSharedMunition", setSharedMunition, getSharedMunition, xmlelement, mode);
    7170        XMLPortParam(Weapon, "bullets", setBulletAmount, getBulletAmount, xmlelement, mode);
    7271        XMLPortParam(Weapon, "magazines", setMagazineAmount, getMagazineAmount, xmlelement, mode);
     
    8887    void Weapon::fire()
    8988    {
    90 COUT(0) << "Weapon::fire" << std::endl;
    9189        if ( this->bulletReadyToShoot_ && this->magazineReadyToShoot_ && !this->bReloading_)
    9290        {
    93 COUT(0) << "Weapon::fire 2" << std::endl;
    9491            this->bulletReadyToShoot_ = false;
    9592            if ( this->unlimitedMunition_== true )
    9693            {
    97 COUT(0) << "Weapon::fire 3" << std::endl;
    9894                //shoot
    9995                this->reloadBullet();
     
    10298            else
    10399            {
    104 COUT(0) << "Weapon::fire 4" << std::endl;
    105100                if ( this->munition_->bullets() > 0)
    106101                {
    107 COUT(0) << "Weapon::fire 5" << std::endl;
    108                     //shoot
     102                    //shoot and reload
    109103                    this->takeBullets();
    110104                    this->reloadBullet();
     
    114108                else if ( this->munition_->magazines() > 0 && this->munition_->bullets() == 0 )
    115109                {
    116 COUT(0) << "Weapon::fire 6" << std::endl;
     110                    //reload magazine
    117111                    this->takeMagazines();
    118112                    this->reloadMagazine();
     
    126120        else
    127121        {
    128 COUT(0) << "Weapon::fire not reloaded" << std::endl;
    129122            //weapon not reloaded
    130123        }
     
    132125    }
    133126
    134     /*
    135     * weapon reloading
    136     */
     127
     128    //weapon reloading
    137129    void Weapon::bulletTimer(float bulletLoadingTime)
    138130    {
     
    156148        this->bReloading_ = false;
    157149        this->munition_->fillBullets();
    158         this->magazineReadyToShoot_ = true;
    159         this->bulletReadyToShoot_ = true;
    160     }
     150    }
     151
    161152
    162153
     
    164155    {
    165156        /*  if munition type already exists attach it, else create a new one of this type and attach it to the weapon and to the WeaponSystem
    166         *   if the weapon shares one munitionType put it into sharedMunitionSet else to munitionSet
    167157        */
    168158        if (this->parentWeaponSystem_)
    169159        {
    170             if (this->bSharedMunition_ == false)
    171             {
     160            //getMunitionType returns 0 if there is no such munitionType
     161            Munition* munition = this->parentWeaponSystem_->getMunitionType(munitionName);
     162            if ( munition )
     163            {
     164                this->munition_ = munition;
     165                this->setMunition();
     166            }
     167            else
     168            {
     169                //create new munition with identifier because there is no such munitionType
    172170                this->munitionIdentifier_ = ClassByString(munitionName);
    173171                this->munition_ = this->munitionIdentifier_.fabricate(this);
    174172                this->parentWeaponSystem_->setNewMunition(munitionName, this->munition_);
    175             }
    176             else
    177             {
    178                 //getMunitionType returns 0 if there is no such munitionType
    179                 Munition* munition = this->parentWeaponSystem_->getMunitionType(munitionName);
    180                 if ( munition )
    181                     this->munition_ = munition;
    182                 else
    183                 {
    184                     //create new munition with identifier because there is no such munitionType
    185                     this->munitionIdentifier_ = ClassByString(munitionName);
    186                     this->munition_ = this->munitionIdentifier_.fabricate(this);
    187                     this->parentWeaponSystem_->setNewSharedMunition(munitionName, this->munition_);
    188                 }
    189             }
    190             this->setMunition();
     173                this->setMunition();
     174            }
    191175        }
    192176    }
     
    208192
    209193
    210      /*get and set functions
    211      *
    212      */
     194    //get and set functions for XMLPort
    213195    void Weapon::setMunitionType(std::string munitionType)
    214196    {   this->munitionType_ = munitionType; }
     
    229211    {   return this->magazineLoadingTime_;  }
    230212
    231     void Weapon::setSharedMunition(bool bSharedMunition)
    232     {   this->bSharedMunition_ = bSharedMunition; }
    233 
    234     const bool Weapon::getSharedMunition()
    235     {   return this->bSharedMunition_;  }
    236 
    237213    void Weapon::setBulletAmount(unsigned int amount)
    238214    {   this->bulletAmount_ = amount; }
     
    245221
    246222    const unsigned int Weapon::getMagazineAmount()
    247     {   return this->magazineAmount_;  }
     223    {   return this->magazineAmount_;   }
    248224
    249225    void Weapon::setUnlimitedMunition(bool unlimitedMunition)
  • code/branches/weaponsystem/src/orxonox/objects/weaponSystem/Weapon.h

    r2804 r2852  
    6969            virtual void setMagazineLoadingTime(float loadingTime);
    7070            virtual const float getMagazineLoadingTime();
    71             virtual void setSharedMunition(bool bSharedMunition);
    72             virtual const bool getSharedMunition();
    7371            virtual void setBulletAmount(unsigned int amount);
    7472            virtual const unsigned int getBulletAmount();
     
    106104            bool bulletReadyToShoot_;
    107105            bool magazineReadyToShoot_;
    108             bool bSharedMunition_;
    109106            bool unlimitedMunition_;
    110107            float bulletLoadingTime_;
  • code/branches/weaponsystem/src/orxonox/objects/weaponSystem/WeaponSystem.cc

    r2804 r2852  
    8282    }
    8383
    84     void WeaponSystem::setNewSharedMunition(std::string munitionType, Munition * munitionToAdd)
    85     {
    86         this->munitionSharedSet_[munitionType] = munitionToAdd;
    87     }
    8884
    8985    //returns the Pointer to the munitionType, if this munitionType doesn't exist returns 0, see Weapon::attachNeededMunition
    9086    Munition * WeaponSystem::getMunitionType(std::string munitionType)
    9187    {
    92         std::map<std::string, Munition *>::const_iterator it = this->munitionSharedSet_.find(munitionType);
    93         if (it != this->munitionSharedSet_.end())
     88        std::map<std::string, Munition *>::const_iterator it = this->munitionSet_.find(munitionType);
     89        if (it != this->munitionSet_.end())
    9490            return it->second;
    9591        else
    9692            return 0;
    9793    }
    98 
    99 
    100 
    10194
    10295
  • code/branches/weaponsystem/src/orxonox/objects/weaponSystem/WeaponSystem.h

    r2804 r2852  
    7373            std::vector<WeaponSlot *> weaponSlots_;
    7474            std::vector<WeaponPack *> weaponPacks_;
    75             std::map<std::string, Munition *> munitionSharedSet_;
    7675            std::map<std::string, Munition *> munitionSet_;
    7776            Pawn *parentPawn_;
  • code/branches/weaponsystem/src/orxonox/objects/weaponSystem/munitions/CMakeLists.txt

    r2710 r2852  
    11ADD_SOURCE_FILES(ORXONOX_SRC_FILES
    22  LaserGunMunition.cc
     3  FusionMunition.cc
    34)
  • code/branches/weaponsystem/src/orxonox/objects/weaponSystem/munitions/LaserGunMunition.cc

    r2662 r2852  
    4343        RegisterObject(LaserGunMunition);
    4444
     45        //default if not defined in XML
    4546        this->maxBullets_ = 40;
    4647        this->maxMagazines_ = 100;
Note: See TracChangeset for help on using the changeset viewer.