Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Minor improvements. Use of the Munition class.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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());
Note: See TracChangeset for help on using the changeset viewer.