Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Aug 22, 2011, 3:05:26 PM (13 years ago)
Author:
dafrick
Message:

Cleaning up game immersion. Roughly documenting weapons module.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/trunk/src/modules/weapons/weaponmodes/HsW01.cc

    r8706 r8855  
    2727 */
    2828
     29/**
     30    @file HsW01.h
     31    @brief Implementation of the HsW01 class.
     32*/
     33
    2934#include "HsW01.h"
    3035
     
    3237#include "core/XMLPort.h"
    3338#include "core/command/Executor.h"
     39
    3440#include "graphics/Model.h"
    35 
    36 #include "weapons/projectiles/Projectile.h"
    37 #include "weapons/MuzzleFlash.h"
    3841#include "weaponsystem/Weapon.h"
    3942#include "weaponsystem/WeaponPack.h"
     
    4144#include "worldentities/WorldEntity.h"
    4245#include "worldentities/pawns/Pawn.h"
     46
     47#include "weapons/projectiles/Projectile.h"
     48#include "weapons/MuzzleFlash.h"
    4349
    4450namespace orxonox
     
    5056        RegisterObject(HsW01);
    5157
    52         this->reloadTime_ = 0.25;
    53         this->damage_ = 0; //default 15
    54         this->speed_ = 2500;
    55         this->delay_ = 0;
     58        this->reloadTime_ = 0.25f;
     59        this->damage_ = 0.0f; //default 15
     60        this->speed_ = 2500.0f;
     61        this->delay_ = 0.0f;
    5662        this->setMunitionName("LaserMunition");
    5763
     
    7278        XMLPortParam(HsW01, "delay", setDelay, getDelay, xmlelement, mode);
    7379        XMLPortParam(HsW01, "material", setMaterial, getMaterial, xmlelement, mode);
    74 
    7580    }
    7681
    77     void HsW01::setMaterial(const std::string& material)
     82    /**
     83    @brief
     84        Set the firing delay.
     85    @param delay
     86        The firing delay in seconds.
     87    */
     88    void HsW01::setDelay(float delay)
    7889    {
    79         this->material_ = material;
    80     }
    81 
    82     std::string& HsW01::getMaterial()
    83     {
    84         return this->material_;
    85     }
    86 
    87     void HsW01::setDelay(float d)
    88     {
    89         this->delay_ = d;
     90        this->delay_ = delay;
    9091        this->delayTimer_.setInterval(this->delay_);
    91     }
    92 
    93     float HsW01::getDelay() const
    94     {
    95         return this->delay_;
    9692    }
    9793
     
    10197    }
    10298
    103     void HsW01::muendungsfeuer()
    104     {
    105         MuzzleFlash *muzzleFlash = new MuzzleFlash(this);
    106         this->getWeapon()->attach(muzzleFlash);
    107         muzzleFlash->setPosition(this->getMuzzleOffset());
    108         muzzleFlash->setMaterial(this->material_);
    109     }
    110 
    111     /* Creates the projectile object, sets its properties to the HsW01 properties, calls muendungsfeuer()
    112      */
     99    /**
     100    @brief
     101        Fires the weapon. Creates a projectile and fires it.
     102    */
    113103    void HsW01::shot()
    114104    {
    115105        assert( this->getWeapon() && this->getWeapon()->getWeaponPack() && this->getWeapon()->getWeaponPack()->getWeaponSystem() && this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn() );
     106
     107        // Create the projectile.
    116108        Projectile* projectile = new Projectile(this);
    117109        Model* model = new Model(projectile);
     
    126118        projectile->setVelocity(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn()->getVelocity() + this->getMuzzleDirection() * this->speed_);
    127119
    128         projectile->setOwner(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn());
     120        projectile->setShooter(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn());
    129121        projectile->setDamage(this->getDamage());
    130122        projectile->setShieldDamage(this->getShieldDamage());
    131123        projectile->setHealthDamage(this->getHealthDamage());
    132124
    133         HsW01::muendungsfeuer();
     125        // Display the muzzle flash.
     126        this->HsW01::muzzleflash();
     127    }
     128
     129    /**
     130    @brief
     131        Displays the muzzle flash.
     132    */
     133    void HsW01::muzzleflash()
     134    {
     135        MuzzleFlash *muzzleFlash = new MuzzleFlash(this);
     136        this->getWeapon()->attach(muzzleFlash);
     137        muzzleFlash->setPosition(this->getMuzzleOffset());
     138        muzzleFlash->setMaterial(this->material_);
    134139    }
    135140}
Note: See TracChangeset for help on using the changeset viewer.