Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 10627


Ignore:
Timestamp:
Oct 6, 2015, 9:37:11 PM (9 years ago)
Author:
fvultier
Message:

Minor improvements. Use of the Munition class.

Location:
code/branches/towerdefenseFabien
Files:
4 added
7 edited

Legend:

Unmodified
Added
Removed
  • code/branches/towerdefenseFabien/data/levels/towerDefense.oxw

    r10606 r10627  
    143143        </links>
    144144        <Weapon>
    145           <SplitGun mode=0 munitionpershot=0 damage=9.3 muzzleoffset=" 1.6, 1.3, -2.0" splittime=0.2 numberofsplits=2 numberofchilds=5 spread=0.1 />
     145          <SplitGun mode=0 munitionpershot=0 damage=9.3 muzzleoffset=" 1.6, 1.3, -2.0" splittime=0.2 numberofsplits=2 numberofchilds=5 spread=0.1 damagereduction=3.0 />
    146146        </Weapon>
    147147      </WeaponPack>
  • code/branches/towerdefenseFabien/src/modules/weapons/munitions/CMakeLists.txt

    r7846 r10627  
    44  FusionMunition.cc
    55  RocketMunition.cc
     6  SplitMunition.cc
     7  IceMunition.cc
    68)
  • code/branches/towerdefenseFabien/src/modules/weapons/projectiles/SplitGunProjectile.cc

    r10606 r10627  
    4949        this->numberOfSplits_ = 0;
    5050        this->numberOfChilds_ = 0;
    51         this->splitTime_ = 1.0;     
    52         this->spread_ = 0.2;
     51        this->splitTime_ = 1.0f;
     52        this->spread_ = 0.2f;
     53        this->damageReduction_ = 1.0f;
    5354    }
    5455
     
    9697    void SplitGunProjectile::setSpread(float spread)
    9798    {
    98         spread_ = spread;
     99        this->spread_ = spread;
     100    }
     101
     102    /**
     103    @brief
     104        This is the setter function for the damageReduction_ variable. The value of the variable is bounded between 0 and 1.
     105    */
     106    void SplitGunProjectile::setDamageReduction(float damageReduction)
     107    {
     108        this->damageReduction_ = (damageReduction >= 0.0f ? damageReduction : 1.0f);
    99109    }
    100110
     
    109119            -- numberOfSplits_;
    110120
    111             // Reduce damage of this projectile by the number of childs plus one. This way the total amount of possible damage contained in the original projectile and its childs is unchanged after s aplit.
    112             this->setDamage(this->getDamage()/(numberOfChilds_+1));
     121            // Reduce damage of this projectile
     122            this->setDamage(this->getDamage() * this->damageReduction_ / (this->numberOfChilds_+1));
    113123
    114124            // Calculate a normalized vector (velocityOffset) that is perpendicluar to the velocity of this projectile. Since there are infinitly many perpendicular vectors a random one is chosen.
     
    138148                projectile->setSplitTime(this->splitTime_);
    139149                projectile->setSpread(this->spread_);
     150                projectile->setDamageReduction(this->damageReduction_);
    140151
    141152                projectile->setShooter(this->getShooter());
  • code/branches/towerdefenseFabien/src/modules/weapons/projectiles/SplitGunProjectile.h

    r10606 r10627  
    6161            virtual void setSplitTime(float splitTime);
    6262            virtual void setSpread(float spread);
     63            virtual void setDamageReduction(float damageReduction);
    6364
    6465        private:           
     
    6768            float splitTime_;
    6869            float spread_;
     70            float damageReduction_; //The damage of a child projectile is reduced by this factor
    6971            Timer splitTimer_;
    7072
  • code/branches/towerdefenseFabien/src/modules/weapons/weaponmodes/IceGun.cc

    r10608 r10627  
    5454        this->reloadTime_ = 1.0f;
    5555        this->damage_ = 0.0f;
    56         this->speed_ = 750.0f;
     56        this->speed_ = 1200.0f;
    5757
    5858        this->setFreezeTime(3.0);
  • code/branches/towerdefenseFabien/src/modules/weapons/weaponmodes/SplitGun.cc

    r10606 r10627  
    5656        this->numberOfSplits_ = 2;
    5757        this->numberOfChilds_ = 3;
    58         this->splitTime_ = 0.3;
    59         this->spread_ = 0.1;
     58        this->splitTime_ = 0.3f;
     59        this->spread_ = 0.1f;
     60        this->damageReduction_ = 1.0f;
    6061
    61         this->setMunitionName("LaserMunition");
     62        this->setMunitionName("SplitMunition");
    6263        this->setDefaultSound("sounds/Weapon_LightningGun.ogg");
    6364    }
     
    7980        XMLPortParam(SplitGun, "splittime", setSplitTime, getSplitTime, xmlelement, mode);
    8081        XMLPortParam(SplitGun, "spread", setSpread, getSpread, xmlelement, mode);
     82        XMLPortParam(SplitGun, "damagereduction", setDamageReduction, getDamageReduction, xmlelement, mode);
    8183    }
    8284
     
    9597        projectile->setVelocity(this->getMuzzleDirection() * this->speed_);
    9698
    97         // Pass important information to the projectile: Number of splits, Number of childs, split time, spread
     99        // Pass important information to the projectile: Number of splits, Number of childs, split time, spread and the damage reduction
    98100        projectile->setNumberOfSplits(getNumberOfSplits());
    99101        projectile->setNumberOfChilds(getNumberOfChilds());
    100102        projectile->setSplitTime(getSplitTime());
    101103        projectile->setSpread(getSpread());
     104        projectile->setDamageReduction(getDamageReduction());
    102105
    103106        projectile->setShooter(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn());
  • code/branches/towerdefenseFabien/src/modules/weapons/weaponmodes/SplitGun.h

    r10606 r10627  
    7373            inline float getSpread() const
    7474                { return this->spread_; }
     75            inline void setDamageReduction(float damageReduction)
     76                { this->damageReduction_ = (damageReduction >= 0.0f ? damageReduction : 1.0f); }
     77            inline float getDamageReduction() const
     78                { return this->damageReduction_; }
    7579
    7680       private:
     
    8084            float splitTime_; //The time between creation of the projectile and the split of the projectile
    8185            float spread_; //Low spread means that the child projectiles are concentrated in a small area
     86            float damageReduction_; //The damage of a child projectile is reduced by this factor
    8287    };
    8388}
Note: See TracChangeset for help on using the changeset viewer.