Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 10908


Ignore:
Timestamp:
Nov 30, 2015, 10:55:38 PM (8 years ago)
Author:
fvultier
Message:

Mine damages pawns within range.

Location:
code/branches/particleEffectsHS15
Files:
2 deleted
4 edited

Legend:

Unmodified
Added
Removed
  • code/branches/particleEffectsHS15/data/levels/includes/weaponSettingsEscort.oxi

    r10889 r10908  
    1414        </links>
    1515        <Weapon>
    16           <MineGun mode=0 munitionpershot=0 delay=0.125 damage=9.3 muzzleoffset=" 0.1, 1.4,-3" maxtimeuntilexplosion=5 timeuntilactivation=1.5/>
     16          <MineGun mode=0 munitionpershot=0 delay=0.125 damage=50 shielddamage=15 healthdamage=10 muzzleoffset=" 0.1, 1.4,-3" maxtimeuntilexplosion=25 timeuntilactivation=2.5/>
    1717        </Weapon>
    1818        <Weapon>
    19           <SplitGun mode=0 munitionpershot=0 delay=0.125 damage=9.3 muzzleoffset=" 0.1, 1.4,-3" />
     19          <IceGun mode=0 munitionpershot=0 delay=0.125 damage=9.3 muzzleoffset=" 0.1, 1.4,-3" freezefactor=0.5 freezetime=2.0 />
    2020        </Weapon>
    2121      </WeaponPack>
  • code/branches/particleEffectsHS15/src/modules/weapons/projectiles/MineProjectile.cc

    r10897 r10908  
    2121 *
    2222 *   Author:
     23 *      Jannis Holzer
    2324 *      Fabien Vultier
    2425 *   Co-authors:
     
    3536
    3637#include "core/CoreIncludes.h"
     38#include "graphics/Model.h"
    3739#include "core/command/Executor.h"
     40#include "graphics/ParticleSpawner.h"
     41#include "worldentities/pawns/Pawn.h"
    3842#include "core/EventIncludes.h"
    39 #include "graphics/Model.h"
     43#include "sound/WorldSound.h"
    4044
    4145namespace orxonox
     
    4347    RegisterClass(MineProjectile);
    4448
     49    const float MineProjectile::collisionShapeRadius_ = 15.0f;
     50    const float MineProjectile::damageRadius_ = 200.0f;
     51    const float MineProjectile::triggerRadius_ = 100.0f;
     52
    4553    MineProjectile::MineProjectile(Context* context) : MovableEntity(context), BasicProjectile()
    4654    {
    4755        RegisterObject(MineProjectile);
    4856
    49         this->bActive_ = false;
     57        this->bAllowExplosion_ = false;
    5058        this->maxTimeUntilExplosion_ = 10.0f;
    5159        this->timeUntilActivation_ = 1.0f;
    5260
    53         rings_ = new MovableEntity(this->getContext());
    54         this->attach(rings_);
    55         rings_->setPosition(Vector3(0.0,0.0,0.0));
    56         rings_->setAngularVelocity(Vector3(0.0,5.0,0.0));
    57 
     61        //Create movable entities
     62        rings1_ = new MovableEntity(this->getContext());
     63        this->attach(rings1_);
     64        rings1_->setPosition(Vector3(0.0,0.0,0.0));
     65        rings1_->setAngularVelocity(Vector3(0.0,5.0,0.0));
     66
     67        rings2_ = new MovableEntity(this->getContext());
     68        this->attach(rings2_);
     69        rings2_->setPosition(Vector3(0.0,0.0,0.0));
     70        rings2_->setAngularVelocity(Vector3(0.0,0.0,5.0));
     71
     72        core_ = new MovableEntity(this->getContext());
     73        this->attach(core_);
     74        core_->setPosition(Vector3(0.0,0.0,0.0));
     75        core_->setAngularVelocity(Vector3(2.5,2.5,0.0));
     76
     77        //Create Models
     78        //Core
    5879        modelCore_ = new Model(this->getContext());
    5980        modelCore_->setMeshSource("Mine_Core.mesh");
    6081        modelCore_->setScale(15.0);
    61         this->attach(modelCore_);
     82        core_->attach(modelCore_);
    6283        modelCore_->setPosition(Vector3(0,0,0));
    6384
     85        //Ring 1
    6486        modelRing1_ = new Model(this->getContext());
    6587        modelRing1_->setMeshSource("Mine_Ring.mesh");
    6688        modelRing1_->setScale(15.0);
    67         rings_->attach(modelRing1_);
     89        rings1_->attach(modelRing1_);
    6890        modelRing1_->setPosition(Vector3(0,0,0));
    6991        modelRing1_->yaw(Degree(0));
    70 
     92        //Ring 2
    7193        modelRing2_ = new Model(this->getContext());
    7294        modelRing2_->setMeshSource("Mine_Ring.mesh");
    7395        modelRing2_->setScale(15.0);
    74         rings_->attach(modelRing2_);
     96        rings1_->attach(modelRing2_);
    7597        modelRing2_->setPosition(Vector3(0,0,0));
    7698        modelRing2_->yaw(Degree(180));
     99        //Ring 3
     100        modelRing3_ = new Model(this->getContext());
     101        modelRing3_->setMeshSource("Mine_Ring.mesh");
     102        modelRing3_->setScale(15.0);
     103        rings2_->attach(modelRing3_);
     104        modelRing3_->setPosition(Vector3(0,0,0));
     105        modelRing3_->yaw(Degree(90));
     106        //Ring 4
     107        modelRing4_ = new Model(this->getContext());
     108        modelRing4_->setMeshSource("Mine_Ring.mesh");
     109        modelRing4_->setScale(15.0);
     110        rings2_->attach(modelRing4_);
     111        modelRing4_->setPosition(Vector3(0,0,0));
     112        modelRing4_->yaw(Degree(270));
     113
     114        emitter_ = NULL;
    77115
    78116        if (GameMode::isMaster())
     
    86124            // Create a sphere collision shape and attach it to the projectile.
    87125            collisionShape_ = new SphereCollisionShape(this->getContext());
    88             collisionShape_->setRadius(10.0f);
     126            collisionShape_->setRadius(collisionShapeRadius_);
    89127            this->attachCollisionShape(collisionShape_);
     128            collisionShape_->setPosition(Vector3(0,0,0));
    90129
    91130            // Create a distance trigger and attach it to the projectile.
     
    93132            this->attach(distanceTrigger_);
    94133            distanceTrigger_->setPosition(Vector3(0,0,0));
    95             distanceTrigger_->setDistance(40.0f);
     134            distanceTrigger_->setDistance(triggerRadius_);
    96135            distanceTrigger_->addTarget("Pawn");
    97             distanceTrigger_->setStayActive(true);
     136            distanceTrigger_->setStayActive(false);
    98137
    99138            this->addEventSource(distanceTrigger_, "explode");
     
    105144        if (this->isInitialized())
    106145        {
    107             /*if (modelCore_ != NULL)
     146            modelCore_->destroy();
     147            modelRing1_->destroy();
     148            modelRing2_->destroy();
     149            modelRing3_->destroy();
     150            modelRing4_->destroy();
     151
     152            distanceTrigger_->destroy();
     153
     154            if (emitter_)
    108155            {
    109                 modelCore_->destroy();
    110             }*/
    111             if (distanceTrigger_)
    112                 distanceTrigger_->destroy();
    113         }
    114     }
    115 
     156                emitter_->destroy();
     157            }
     158        }
     159    }
     160
     161    /**
     162    @brief
     163        TODO
     164    */
    116165    void MineProjectile::XMLEventPort(Element& xmlelement, XMLPort::Mode mode)
    117166    {
    118167        SUPER(MineProjectile, XMLEventPort, xmlelement, mode);
    119         XMLPortEventState(MineProjectile, BaseObject, "explode", Explode, xmlelement, mode);
     168        XMLPortEventState(MineProjectile, BaseObject, "explode", explode, xmlelement, mode);
    120169    }
    121170
     
    131180            if (GameMode::isMaster())
    132181            {
    133                 this->explodeTimer_.setTimer(this->maxTimeUntilExplosion_, false, createExecutor(createFunctor(&MineProjectile::Explode, this)));
     182                this->explodeTimer_.setTimer(this->maxTimeUntilExplosion_, false, createExecutor(createFunctor(&MineProjectile::explode, this)));
    134183            }
    135184        }
     
    150199        if (GameMode::isMaster())
    151200        {
    152             this->activationTimer_.setTimer(this->timeUntilActivation_, false, createExecutor(createFunctor(&MineProjectile::Activate, this)));
    153         }
    154     }
    155 
    156     /**
    157     @brief
    158         TODO
    159     */
    160     void MineProjectile::Explode()
    161     {
    162         orxout() << "MineProjectile::Explode" << endl;
    163 
    164         this->destroyLater();
    165 
    166 
    167     }
    168 
    169     /**
    170     @brief
    171         TODO
    172     */
    173     void MineProjectile::Activate()
    174     {
    175         orxout() << "MineProjectile::Activate" << endl;
    176 
    177         bActive_ = true;
     201            this->activationTimer_.setTimer(this->timeUntilActivation_, false, createExecutor(createFunctor(&MineProjectile::allowExplosion, this)));
     202        }
     203    }
     204
     205    /**
     206    @brief
     207        TODO
     208    */
     209    void MineProjectile::explode()
     210    {
     211        if (bAllowExplosion_)
     212        {
     213            if (GameMode::isMaster())
     214            {
     215                // Damage all pawns within the damage radius
     216                for (ObjectList<Pawn>::iterator it = ObjectList<Pawn>::begin(); it != ObjectList<Pawn>::end(); ++it)
     217                {
     218                    Vector3 distanceVector = it->getWorldPosition()-this->getWorldPosition();
     219                    if(distanceVector.length()< damageRadius_)
     220                    {
     221                        it->hit(this->getShooter(), it->getWorldPosition(), NULL, this->getDamage(), this->getHealthDamage(), this->getShieldDamage());
     222                    }
     223                }
     224            }
     225
     226            this->destructionEffect();
     227            this->destroyLater();
     228        }
     229    }
     230
     231    /**
     232    @brief
     233        TODO
     234    */
     235    void MineProjectile::allowExplosion()
     236    {
     237        // Allow explosion
     238        bAllowExplosion_ = true;
     239        // Add particle effect
     240        emitter_ = new ParticleEmitter(this->getContext());
     241        this->attach(emitter_);
     242        emitter_->setOrientation(this->getOrientation());
     243        emitter_->setSource("Orxonox/mineparticle"); 
     244    }
     245
     246    /**
     247    @brief
     248        TODO
     249    */
     250    void MineProjectile::destructionEffect()
     251    {
     252        ParticleSpawner *effect1, *effect2, *effect3;
     253       
     254        effect1 = new ParticleSpawner(this->getContext());
     255        effect2 = new ParticleSpawner(this->getContext());
     256        effect3 = new ParticleSpawner(this->getContext());
     257
     258        effect1->setPosition(this->getPosition());
     259        effect1->setOrientation(this->getOrientation());
     260        effect1->setDestroyAfterLife(true);
     261        effect1->setSource("Orxonox/MineExpl");
     262        effect1->setLifetime(2.5f);
     263
     264        effect2->setPosition(this->getPosition());
     265        effect2->setOrientation(this->getOrientation());
     266        effect2->setDestroyAfterLife(true);
     267        effect2->setSource("Orxonox/MineExpl1");
     268        effect2->setLifetime(2.5f);
     269
     270        effect3->setPosition(this->getPosition());
     271        effect3->setOrientation(this->getOrientation());
     272        effect3->setDestroyAfterLife(true);
     273        effect3->setSource("Orxonox/MineExpl2");
     274        effect3->setLifetime(2.5f);
     275
     276        // Explosion sound effect.
     277        WeakPtr<WorldSound> explosionSound_ = new WorldSound(getContext());
     278        explosionSound_->setSource("sounds/GravityFieldExplosion.ogg");
     279        explosionSound_->setVolume(1.0);
     280        explosionSound_->play();
    178281    }
    179282}
  • code/branches/particleEffectsHS15/src/modules/weapons/projectiles/MineProjectile.h

    r10897 r10908  
    2121 *
    2222 *   Author:
     23 *      Jannis Holzer
    2324 *      Fabien Vultier
    2425 *   Co-authors:
     
    6061            virtual void setMaxTimeUntilExplosion(float maxTimeUntilExplosion);
    6162            virtual void setTimeUntilActivation(float timeUntilActivation);
    62 
     63        protected:
     64            static const float triggerRadius_;
     65            static const float damageRadius_;
     66            static const float collisionShapeRadius_;
    6367        private:
    64             bool bActive_; // The mine can only explode if it is active
     68            bool bAllowExplosion_; // The mine can only explode if it is active
    6569            float maxTimeUntilExplosion_;
    6670            float timeUntilActivation_;
     
    7074            Model* modelRing1_;
    7175            Model* modelRing2_;
    72             MovableEntity* rings_;
     76            Model* modelRing3_;
     77            Model* modelRing4_;
     78            MovableEntity* rings1_;
     79            MovableEntity* rings2_;
     80            MovableEntity* core_;
     81            ParticleEmitter* emitter_;
    7382
    7483            WeakPtr<SphereCollisionShape> collisionShape_; // The collision shape of the projectile.
    7584            WeakPtr<DistanceTrigger> distanceTrigger_;
    7685
    77             virtual void Activate();
    78             virtual void Explode();
     86            virtual void destructionEffect();
     87            virtual void allowExplosion();
     88            virtual void explode();
    7989    };
    8090}
  • code/branches/particleEffectsHS15/src/modules/weapons/weaponmodes/MineGun.h

    r10889 r10908  
    4343    /**
    4444    @brief
    45         A Mine that explodes when a ship is too close
     45        A Weapon that drops mines to space.
    4646    @ingroup WeaponsWeaponModes
    4747    */
Note: See TracChangeset for help on using the changeset viewer.