Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

weapon stuff

File:
1 edited

Legend:

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