Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Feb 4, 2016, 11:54:04 PM (9 years ago)
Author:
fvultier
Message:

A few modifications in the weapon system: WeaponModes may play a reload sound now. Fireing Sounds of WeaponModes may overlap now. New weapon: FlameGun, a flame thrower for close combat (e.g. for the FPS player)

Location:
code/trunk/src/modules/weapons/projectiles
Files:
2 added
9 edited

Legend:

Unmodified
Added
Removed
  • code/trunk/src/modules/weapons/projectiles/BasicProjectile.cc

    r11099 r11108  
    5454        this->bDestroy_ = false;
    5555
     56        // Default is destroying the projectile after collision
     57        this->destroyAfterCollision_ = true;
     58
    5659        // Default damage must be zero, otherwise it would be above zero if no settings are made in the weaponsettings xml file.
    5760        // same thing for all weaponmodes files
     
    8790                return false;
    8891
    89             this->bDestroy_ = true; // If something is hit, the object is destroyed and can't hit something else.
    90                                     // The projectile is destroyed by its tick()-function (in the following tick).
     92            if (getDestroyAfterCollision())
     93            {
     94                this->bDestroy_ = true; // If something is hit, the object is destroyed and can't hit something else.
     95                                        // The projectile is destroyed by its tick()-function (in the following tick).
     96                                        // TODO: Use destroyLater() for this
     97            }
    9198
    9299            Pawn* victim = orxonox_cast<Pawn*>(otherObject); // If otherObject isn't a Pawn, then victim is nullptr
  • code/trunk/src/modules/weapons/projectiles/BasicProjectile.h

    r11099 r11108  
    119119            bool processCollision(WorldEntity* otherObject, btManifoldPoint& contactPoint, const btCollisionShape* cs);
    120120            void destroyCheck(void);
     121            inline void setDestroyAfterCollision(bool destroyAfterCollision)
     122                { destroyAfterCollision_ = destroyAfterCollision; }
     123            inline bool getDestroyAfterCollision() const
     124                { return destroyAfterCollision_; }
    121125
    122126        private:
     
    130134
    131135            bool bDestroy_; //!< Boolean, to check whether a projectile should be destroyed.
     136            bool destroyAfterCollision_; //!< Boolean, defines whether the projectile gets detroyed after a collision.
    132137    };
    133138}
  • code/trunk/src/modules/weapons/projectiles/CMakeLists.txt

    r11052 r11108  
    77  SplitGunProjectile.cc
    88  IceGunProjectile.cc
     9  FlameGunProjectile.cc
    910  Rocket.cc
    1011  RocketOld.cc
  • code/trunk/src/modules/weapons/projectiles/LightningGunProjectile.cc

    r11071 r11108  
    4747
    4848        this->textureIndex_ = 1;
    49         this->setMass(2);
     49        this->setMass(0.1f);
    5050        this->setCollisionType(CollisionType::Dynamic);
    5151        this->maxTextureIndex_ = 8;
  • code/trunk/src/modules/weapons/projectiles/ParticleProjectile.cc

    r11071 r11108  
    4343    RegisterClass(ParticleProjectile);
    4444
    45     ParticleProjectile::ParticleProjectile(Context* context) : BillboardProjectile(context)
     45    ParticleProjectile::ParticleProjectile(Context* context) : Projectile(context)
    4646    {
    4747        RegisterObject(ParticleProjectile);
    4848
    49         if (GameMode::showsGraphics())
    50         {
    51             // Create the particles.
    52             this->particles_ = new ParticleInterface(this->getScene()->getSceneManager(), "Orxonox/shot3_small", LODParticle::Normal);
    53             this->attachOgreObject(this->particles_->getParticleSystem());
    54             this->particles_->setKeepParticlesInLocalSpace(0);
     49        this->particles_ = nullptr;
    5550
    56             for (unsigned int i = 0; i < this->particles_->getNumEmitters(); ++i)
    57                 this->particles_->getEmitter(i)->setDirection(-WorldEntity::FRONT);
    58         }
    59         else
    60             this->particles_ = nullptr;
     51        //setEffect("Orxonox/sparks2");
    6152    }
    6253
     
    8273            this->particles_->setEnabled(this->isVisible());
    8374    }
     75
     76    void ParticleProjectile::setEffect(const std::string& effect)
     77    {
     78        // If we already have a particle interface, delete it
     79        if (this->particles_)
     80        {
     81            this->detachOgreObject(this->particles_->getParticleSystem());
     82            delete this->particles_;
     83            this->particles_ = nullptr;
     84        }
     85
     86        if (GameMode::showsGraphics())
     87        {
     88            // Create the particles.
     89            this->particles_ = new ParticleInterface(this->getScene()->getSceneManager(), effect, LODParticle::Normal);
     90            this->attachOgreObject(this->particles_->getParticleSystem());
     91            this->particles_->setKeepParticlesInLocalSpace(0);
     92
     93            for (unsigned int i = 0; i < this->particles_->getNumEmitters(); ++i)
     94                this->particles_->getEmitter(i)->setDirection(-WorldEntity::FRONT);
     95        }
     96        else
     97        {
     98            this->particles_ = nullptr;
     99        }
     100    }
    84101}
  • code/trunk/src/modules/weapons/projectiles/ParticleProjectile.h

    r11071 r11108  
    4848    @ingroup WeaponsProjectiles
    4949    */
    50     class _WeaponsExport ParticleProjectile : public BillboardProjectile
     50    class _WeaponsExport ParticleProjectile : public Projectile
    5151    {
    5252        public:
     
    5454            virtual ~ParticleProjectile();
    5555            virtual void changedVisibility() override;
     56            virtual void setEffect(const std::string& effect);
    5657
    5758        private:
  • code/trunk/src/modules/weapons/projectiles/Projectile.cc

    r11071 r11108  
    5454        if (GameMode::isMaster())
    5555        {
    56             this->setMass(1.0f);
     56            this->setMass(0.1f);
    5757            this->enableCollisionCallback();
    5858            this->setCollisionResponse(false);
  • code/trunk/src/modules/weapons/projectiles/SplitGunProjectile.cc

    r11099 r11108  
    5252        this->spread_ = 0.2f;
    5353        this->damageReduction_ = 1.0f;
     54        this->splitSound_ = nullptr;
     55
     56        this->setSplitSound("sounds/Weapon_SplitGun.ogg", 0.8);
     57    }
     58
     59    SplitGunProjectile::~SplitGunProjectile()
     60    {
     61        if (this->isInitialized())
     62        {
     63            if (splitSound_)
     64            {
     65                splitSound_->destroy();
     66            }
     67        }
    5468    }
    5569
     
    158172
    159173            numberOfSplits_ = 0;
     174
     175            if (splitSound_)
     176            {
     177                splitSound_->play();
     178            }
    160179        }
    161180    }
     181
     182    void SplitGunProjectile::setSplitSound(const std::string& soundPath, const float soundVolume)
     183    {
     184        if (!splitSound_)
     185        {
     186            this->splitSound_ = new WorldSound(this->getContext());
     187            this->splitSound_->setLooping(false);
     188            this->attach(splitSound_);
     189        }
     190
     191        this->splitSound_->setSource(soundPath);
     192        this->splitSound_->setVolume(soundVolume);
     193    }
    162194}
  • code/trunk/src/modules/weapons/projectiles/SplitGunProjectile.h

    r11052 r11108  
    2828
    2929/**
    30     @file IceGunProjectile.h
     30    @file SplitGunProjectile.h
    3131    @brief Definition of the SplitGunProjectile class.
    3232*/
     
    4040#include "tools/Timer.h"
    4141#include "BillboardProjectile.h"
     42#include "sound/WorldSound.h"
    4243
    4344namespace orxonox
     
    5556        public:
    5657            SplitGunProjectile(Context* context);
    57             virtual ~SplitGunProjectile() {}
     58            virtual ~SplitGunProjectile();
    5859
    5960            virtual void setNumberOfSplits(int numberOfSplits);
     
    6263            virtual void setSpread(float spread);
    6364            virtual void setDamageReduction(float damageReduction);
     65            virtual void setSplitSound(const std::string& soundPath, const float soundVolume = 1.0);
    6466
    6567        private:           
     
    7072            float damageReduction_; //The damage of a child projectile is reduced by this factor
    7173            Timer splitTimer_;
     74            WorldSound* splitSound_; //Sound played if the projectile splits
    7275
    7376            virtual void split();           
Note: See TracChangeset for help on using the changeset viewer.