Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 12281


Ignore:
Timestamp:
Apr 4, 2019, 4:37:19 PM (6 years ago)
Author:
pomselj
Message:

weapon stuff

Location:
code/branches/OrxoBlox_FS19
Files:
6 added
11 edited

Legend:

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

    r11052 r12281  
    106106        </links>
    107107        <Weapon>         
    108           <LightningGun mode=0 munitionpershot=0 muzzleoffset="0,0,0" damage=2 shielddamage=4 />
     108          <BallGun mode=0 munitionpershot=0 muzzleoffset="0,0,0" damage=200 shielddamage=4 />
    109109        </Weapon>
    110110      </WeaponPack>
    111111    </weaponpacks>
    112112    <munition>
    113       <LightningMunition initialmagazines=1 maxmagazines=1 munitionpermagazine=10/>
    114     </munition>
     113      <BallMunition initialmagazines=1 maxmagazines=1 munitionpermagazine=10/>
     114    </munition>x
    115115    <attached>
    116116      <Backlight position="0,0,0" scale=2.0 colour="0.4, 0.0, 1.0" width=10 length=10 lifetime=0.3 elements=20 trailmaterial="Trail/backlighttrail" material="Examples/Flare" loop=1 />
  • code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/BallGun/BallGun.cc

    r12254 r12281  
    2121 *
    2222 *   Author:
    23  *      Fabien Vultier
     23 *      Hagen Seifert
    2424 *   Co-authors:
    25  *      ...
     25 *      simonmie
    2626 *
    2727 */
    2828
    2929/**
    30     @file IceGun.cc
    31     @brief Implementation of the IceGun class.
     30    @file HsW01.h
     31    @brief Implementation of the HsW01 class.
    3232*/
    3333
     
    3535
    3636#include "core/CoreIncludes.h"
    37 #include "core/XMLPort.h"   
     37#include "core/XMLPort.h"
     38#include "core/command/Executor.h"
     39
     40#include "graphics/Model.h"
    3841#include "weaponsystem/Weapon.h"
    3942#include "weaponsystem/WeaponPack.h"
    4043#include "weaponsystem/WeaponSystem.h"
     44#include "worldentities/WorldEntity.h"
    4145#include "worldentities/pawns/Pawn.h"
    4246
    43 #include "BallProjectile.h"
     47#include "weapons/projectiles/Projectile.h"
     48#include "weapons/MuzzleFlash.h"
    4449
    4550namespace orxonox
     
    5156        RegisterObject(BallGun);
    5257
    53         // Default values
    54         this->reloadTime_ = 1.0f;
    55         this->damage_ = 0.0f;
    56         this->speed_ = 1200.0f;
     58        this->reloadTime_ = 0.25f;
     59        this->damage_ = 0.0f; //default 15
     60        this->speed_ = 750.0f;
     61        this->delay_ = 0.0f;
     62        this->setMunitionName("BallMunition");
     63        this->mesh_ = "laserbeam.mesh";
    5764
    5865
    59         this->setMunitionName("BallMunition");
    60         this->setFireSound("sounds/Weapon_LightningGun.ogg");
    61         this->setReloadSound("sounds/Reload_IceGun.ogg", 0.4);
     66        this->delayTimer_.setTimer(this->delay_, false, createExecutor(createFunctor(&BallGun::shot, this)));
     67        this->delayTimer_.stopTimer();
    6268
    63         hudImageString_ = "Orxonox/WSHUD_WM_IceGun";
     69        this->setFireSound("sounds/Weapon_HsW01.ogg");
     70        this->setReloadSound("sounds/Reload_HsW01.ogg", 0.5);
     71
     72        hudImageString_ = "Orxonox/WSHUD_WM_HsW01";
    6473    }
    6574
     
    6877    }
    6978
     79    void BallGun::XMLPort(Element& xmlelement, XMLPort::Mode mode)
     80    {
     81        SUPER(BallGun, XMLPort, xmlelement, mode);
     82
     83        XMLPortParam(BallGun, "delay", setDelay, getDelay, xmlelement, mode);
     84        XMLPortParam(BallGun, "material", setMaterial, getMaterial, xmlelement, mode);
     85        XMLPortParam(BallGun, "projectileMesh", setMesh, getMesh, xmlelement, mode);
     86        XMLPortParam(BallGun, "sound", setSound, getSound, xmlelement, mode);
     87    }
     88
     89    /**
     90    @brief
     91        Set the firing delay.
     92    @param delay
     93        The firing delay in seconds.
     94    */
     95    void BallGun::setDelay(float delay)
     96    {
     97        orxout() << "delay" << endl;
     98        this->delay_ = delay;
     99        this->delayTimer_.setInterval(this->delay_);
     100    }
     101
     102    void BallGun::fire()
     103    {
     104        orxout() << "fire" << endl;
     105        this->delayTimer_.startTimer();
     106    }
     107
    70108    /**
    71109    @brief
    72110        Fires the weapon. Creates a projectile and fires it.
    73111    */
    74     void BallGun::fire()
     112    void BallGun::shot()
    75113    {
    76         BallProjectile* projectile = new BallProjectile(this->getContext());
     114        assert( this->getWeapon() && this->getWeapon()->getWeaponPack() && this->getWeapon()->getWeaponPack()->getWeaponSystem() && this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn() );
     115        orxout() << "sajkfg" << endl;
     116        // Create the projectile.
     117        Projectile* projectile = new Projectile(this->getContext());
     118        Model* model = new Model(projectile->getContext());
     119        model->setMeshSource(mesh_);
     120        model->setCastShadows(false);
     121        projectile->attach(model);
     122        model->setScale(5);
    77123
    78124        this->computeMuzzleParameters(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn()->getAimPosition());
     
    85131        projectile->setShieldDamage(this->getShieldDamage());
    86132        projectile->setHealthDamage(this->getHealthDamage());
     133
     134        // Display the muzzle flash.
     135        this->BallGun::muzzleflash();
     136    }
     137
     138    /**
     139    @brief
     140        Displays the muzzle flash.
     141    */
     142    void BallGun::muzzleflash()
     143    {
     144        MuzzleFlash *muzzleFlash = new MuzzleFlash(this->getContext());
     145        this->getWeapon()->attach(muzzleFlash);
     146        muzzleFlash->setPosition(this->getMuzzleOffset());
     147        muzzleFlash->setMaterial(this->material_);
    87148    }
    88149}
  • code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/BallGun/BallGun.h

    r12254 r12281  
    2121 *
    2222 *   Author:
    23  *      Fabien Vultier
     23 *      Hagen Seifert
    2424 *   Co-authors:
    2525 *      ...
     
    2828
    2929/**
    30     @file IceGun.h
    31     @brief Definition of the IceGun class.
     30    @file HsW01.h
     31    @brief Definition of the HsW01 class.
    3232*/
    3333
     
    3636
    3737#include "weapons/WeaponsPrereqs.h"
     38
     39#include "tools/Timer.h"
    3840#include "weaponsystem/WeaponMode.h"
    3941
     
    4345    /**
    4446    @brief
    45         A Gun that fires ice arrows that slow down any SpaceShip object that gets hit.
     47        Shoots laser beams.
    4648    @author
    47         Fabien Vultier
     49        Hagen Seifert
    4850    @ingroup WeaponsWeaponModes
    4951    */
     
    5557
    5658            virtual void fire() override;
    57            
    58        private:
    59             float speed_; //The speed of the fired projectile.
     59            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) override;
     60
     61        protected:
     62            /**
     63            @brief Set the mesh.
     64            @param mesh The mesh name.
     65            */
     66            void setMesh(const std::string& mesh)
     67                { this->mesh_ = mesh; }
     68
     69            /**
     70            @brief Get the mesh.
     71            @return Returns the mesh name.
     72            */
     73            const std::string& getMesh() const
     74                { return this->mesh_; }
     75
     76            /**
     77            @brief Set the sound.
     78            @param sound The Sound name.
     79            */
     80            void setSound(const std::string& sound)
     81                { this->sound_ = sound; }
     82
     83            /**
     84            @brief Get the sound.
     85            @return Returns the sound name.
     86            */
     87            const std::string& getSound() const
     88                { return this->sound_; }
     89
     90            /**
     91            @brief Set the material.
     92            @param material The material name.
     93            */
     94            void setMaterial(const std::string& material)
     95                { this->material_ = material; }
     96            /**
     97            @brief Get the material.
     98            @return Returns the material name.
     99            */
     100            const std::string& getMaterial() const
     101                { return this->material_; }
     102
     103            void setDelay(float delay);
     104            /**
     105            @brief Get the firing delay.
     106            @return Returns the firing delay in seconds.
     107            */
     108            float getDelay() const
     109                { return this->delay_; }
     110
     111            virtual void shot();
     112            void muzzleflash();
     113
     114            std::string material_; //!< The material.
     115            std::string mesh_; //!< The mesh.
     116            std::string sound_; //!< The sound.
     117
     118
     119
     120            float speed_; //!< The speed of the fired projectile.
     121            float delay_; //!< The firing delay.
     122            Timer delayTimer_; //!< A timer to delay the firing.
    60123    };
    61124}
    62125
    63 #endif /* _IceGun_H__ */
     126#endif /* _HsW01_H__ */
  • code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/BallGun/BallMunition.cc

    r12254 r12281  
    3939    RegisterClass(BallMunition);
    4040
    41     BallMunition::BallMunition(Context* context) : Munition(context)
     41    BallMunition::BallMunition(Context* context) : ReplenishingMunition(context)
    4242    {
    4343        RegisterObject(BallMunition);
    4444
    45         this->maxMunitionPerMagazine_ = 1;
    46         this->maxMagazines_ = 50;
    47         this->unassignedMagazines_ = 25;
     45        this->maxMunitionPerMagazine_ = 20;
     46        this->maxMagazines_ = 10;
     47        this->unassignedMagazines_ = 10;
    4848
    49         this->deployment_ = MunitionDeployment::Stack;
     49        this->deployment_ = MunitionDeployment::Separate;
    5050
    5151        this->bAllowMunitionRefilling_ = true;
    52         this->bAllowMultiMunitionRemovementUnderflow_ = false;
     52        this->bAllowMultiMunitionRemovementUnderflow_ = true;
    5353
    54         this->reloadTime_ = 0.5f;
     54        this->replenishInterval_ = 7.0f;
     55        this->replenishAmount_ = 1;
     56
     57        this->reloadTime_ = 0.6f;
    5558    }
    5659}
  • code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/BallGun/BallMunition.h

    r12254 r12281  
    3636
    3737#include "weapons/WeaponsPrereqs.h"
    38 #include "weaponsystem/Munition.h"
     38#include "weaponsystem/ReplenishingMunition.h"
    3939
    4040namespace orxonox
     
    4848    @ingroup WeaponsMunitions
    4949    */
    50     class _WeaponsExport BallMunition : public Munition
     50    class _WeaponsExport BallMunition : public ReplenishingMunition
    5151    {
    5252        public:
  • code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/BallGun/BallProjectile.cc

    r12254 r12281  
    3838#include "tools/ParticleInterface.h"
    3939#include "Scene.h"
     40#include "core/command/Executor.h"
     41#include "util/Convert.h"
    4042
    4143namespace orxonox
     
    4345    RegisterClass(BallProjectile);
    4446
    45     BallProjectile::BallProjectile(Context* context) : Projectile(context)
     47    BallProjectile::BallProjectile(Context* context) : BillboardProjectile(context)
    4648    {
    4749        RegisterObject(BallProjectile);
    48 
    49         this->particles_ = nullptr;
     50        orxout() << "It's a bird, it's a plane' it's a BallParticle..." << endl;
     51        this->textureIndex_ = 1;
     52        this->setMass(0.1f);
     53        this->maxTextureIndex_ = 8;
    5054        this->setDestroyAfterCollision(false); //I want the ball to bounce, not to be destroyed
    5155
     
    5357    }
    5458
    55     BallProjectile::~BallProjectile()
     59    void BallProjectile::registerVariables()
    5660    {
    57         if (this->isInitialized() && this->particles_)
    58         {
    59             this->detachOgreObject(this->particles_->getParticleSystem());
    60             delete this->particles_;
    61         }
     61        registerVariable(this->materialBase_);
     62    }
     63
     64    /**
     65    @brief
     66        Set the material.
     67    @param material
     68        The name of the material. Material names with 1 to 8 appended must exist.
     69    */
     70    void BallProjectile::setMaterial(const std::string& material)
     71    {
     72        this->materialBase_ = material;
     73
     74        BillboardProjectile::setMaterial(material + multi_cast<std::string>(this->textureIndex_));
     75    }
     76
     77    /**
     78    @brief
     79        Change the texture.
     80    */
     81    void BallProjectile::changeTexture()
     82    {
     83        this->textureIndex_++;
     84        if (this->textureIndex_ > this->maxTextureIndex_)
     85            this->textureIndex_ = 1;
     86
     87        this->setMaterial(this->materialBase_);
    6288    }
    6389
     
    6894        Vector3 contactPosition = this->getPosition();
    6995
    70         if (positionOtherObject.y < 0) {
    71             this->destroy();
    72         }
    73         else {
     96        //if (positionOtherObject.y < 0) {
     97            //this.destroy()
     98        //}
     99        //else {
     100       
    74101            int distance_X = positionOtherObject.x - contactPosition.x;
     102            int distance_Y = positionOtherObject.y - contactPosition.y;
    75103
    76104            if (distance_X < 0)
    77                 distance_X = -distance_X;
    78 
    79             int distance_Y = positionOtherObject.y - contactPosition.y;   
     105                distance_Y = -distance_Y;
     106   
    80107
    81108            if (distance_Y < 0)
    82                 distance_Y = -distance_Y;
     109                distance_X = -distance_X;
    83110
    84111            if (distance_X < distance_Y)
     
    90117                velocity.y = -velocity.y;
    91118            }
    92         }
     119        //}
    93120    }
    94 
    95121
    96122/**
     
    110136    */
    111137
     138    /*
     139    bool BallProjectile::collidesAgainst(WorldEntity* otherObject, const btCollisionShape* cs, btManifoldPoint& contactPoint)
     140    {
     141        orxout() << "I collided against something" << endl;
     142        return this->processCollision(otherObject, contactPoint, cs);
     143    }
     144    */
     145   
     146    bool BallProjectile::processCollision(WorldEntity* otherObject, btManifoldPoint& contactPoint, const btCollisionShape*)
     147    {
    112148
    113     bool BallProjectile::processCollision(WorldEntity* otherObject, btManifoldPoint& contactPoint, const btCollisionShape* cs)
    114     {
    115         if (GameMode::isMaster())
    116         {
     149        orxout() << "wanna bounce..." << endl;
     150        bool result = BasicProjectile::processCollision(otherObject, contactPoint, cs);
     151        Bounce(otherObject, contactPoint, cs);
     152        orxout() << "BOUNCED!" << endl;
    117153
    118             Pawn* victim = orxonox_cast<Pawn*>(otherObject); // If otherObject isn't a Pawn, then victim is nullptr
    119 
    120             WorldEntity* entity = orxonox_cast<WorldEntity*>(this);
    121             assert(entity); // The projectile must not be a WorldEntity.
    122 
    123             // If visual effects after destruction cause problems, put this block below the effects code block
    124             if (victim)
    125             {
    126                 victim->hit(this->getShooter(), contactPoint, cs, this->getDamage(), this->getHealthDamage(), this->getShieldDamage());
    127                 victim->startShieldRechargeCountdown();
    128             }
    129 
    130             // Visual effects for being hit, depending on whether the shield is hit or not
    131             if (this->getShooter()) // If the owner does not exist (anymore?), no effects are displayed.
    132             {
    133                 // Damping and explosion effect is only played if the victim is no Pawn (see cast above)
    134                 // or if the victim is a Pawn, has no shield left, is still alive and any damage goes to the health
    135                 if (!victim || (victim && !victim->hasShield() && victim->getHealth() > 0.0f && (this->getDamage() > 0.0f || this->getHealthDamage() > 0.0f)))
    136                 {
    137                     {
    138                         ParticleSpawner* effect = new ParticleSpawner(this->getShooter()->getContext());
    139                         effect->setPosition(entity->getPosition());
    140                         effect->setOrientation(entity->getOrientation());
    141                         effect->setDestroyAfterLife(true);
    142                         effect->setSource("Orxonox/explosion3");
    143                         effect->setLifetime(2.0f);
    144                     }
    145                     // Second effect with same condition
    146                     {
    147                         ParticleSpawner* effect = new ParticleSpawner(this->getShooter()->getContext());
    148                         effect->setPosition(entity->getPosition());
    149                         effect->setOrientation(entity->getOrientation());
    150                         effect->setDestroyAfterLife(true);
    151                         effect->setSource("Orxonox/smoke4");
    152                         effect->setLifetime(3.0f);
    153                     }
    154                 }
    155 
    156                 // victim->isAlive() is not false until the next tick, so getHealth() > 0 is used instead
    157                 if (victim && victim->hasShield() && (this->getDamage() > 0.0f || this->getShieldDamage() > 0.0f) && victim->getHealth() > 0.0f)
    158                 {
    159                     ParticleSpawner* effect = new ParticleSpawner(this->getShooter()->getContext());
    160                     effect->setDestroyAfterLife(true);
    161                     effect->setSource("Orxonox/Shield");
    162                     effect->setLifetime(0.5f);
    163                     victim->attach(effect);
    164                 }
    165             }
    166 
    167             Bounce(otherObject, contactPoint, cs);
    168 
    169             return true;
    170         }
    171         return false;
     154        return result;
    172155    }
    173156}
  • code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/BallGun/BallProjectile.h

    r12254 r12281  
    4848    @ingroup WeaponsProjectiles
    4949    */
    50     class _WeaponsExport BallProjectile : public Projectile
     50    class _WeaponsExport BallProjectile : public BillboardProjectile
    5151    {
    5252        public:
    5353            BallProjectile(Context* context);
    54             virtual ~BallProjectile();
    55             virtual void Bounce(WorldEntity* otherObject, btManifoldPoint& contactPoint, const btCollisionShape* cs);
    56             virtual bool processCollision(WorldEntity* otherObject, btManifoldPoint& contactPoint, const btCollisionShape* cs);
     54             void Bounce(WorldEntity* otherObject, btManifoldPoint& contactPoint, const btCollisionShape* cs);
     55             //bool BallProjectile::collidesAgainst(WorldEntity* otherObject, const btCollisionShape* cs, btManifoldPoint& contactPoint);
     56             bool BallProjectile::processCollision(WorldEntity* otherObject, btManifoldPoint& contactPoint, const btCollisionShape*);
     57            virtual void setMaterial(const std::string& material) override;
     58
    5759        private:
    58             ParticleInterface* particles_; //!< The particles.
     60
     61            void registerVariables();
     62            void changeTexture();
     63           
     64            unsigned int textureIndex_; //!< The current index of the texture. (i.e. the index of the currently displayed texture)
     65            unsigned int maxTextureIndex_; //!< The maximal index.
     66            std::string materialBase_; //!< The base name of the material.
    5967    };
    6068}
  • code/branches/OrxoBlox_FS19/src/modules/weapons/munitions/CMakeLists.txt

    r11108 r12281  
    99  SplitMunition.cc
    1010  MineMunition.cc
     11  BallMunition.cc
    1112)
  • code/branches/OrxoBlox_FS19/src/modules/weapons/projectiles/BasicProjectile.h

    r11108 r12281  
    117117
    118118        protected:
    119             bool processCollision(WorldEntity* otherObject, btManifoldPoint& contactPoint, const btCollisionShape* cs);
     119            virtual bool processCollision(WorldEntity* otherObject, btManifoldPoint& contactPoint, const btCollisionShape* cs);
    120120            void destroyCheck(void);
    121121            inline void setDestroyAfterCollision(bool destroyAfterCollision)
  • code/branches/OrxoBlox_FS19/src/modules/weapons/projectiles/CMakeLists.txt

    r12191 r12281  
    1515  MineProjectile.cc
    1616  WagnisProjectile.cc
     17  BallProjectile.cc
    1718)
  • code/branches/OrxoBlox_FS19/src/modules/weapons/weaponmodes/CMakeLists.txt

    r12191 r12281  
    1414  MineGun.cc
    1515  WagnisGun.cc
     16  BallGun.cc
    1617)
Note: See TracChangeset for help on using the changeset viewer.