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/EnergyDrink.cc

    r8706 r8855  
    2727 */
    2828
     29/**
     30    @file EnergyDrink.h
     31    @brief Implementation of the EnergyDrink class.
     32*/
     33
    2934#include "EnergyDrink.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"
    4043#include "weaponsystem/WeaponSystem.h"
    4144#include "worldentities/pawns/Pawn.h"
     45
     46#include "weapons/projectiles/Projectile.h"
     47#include "weapons/MuzzleFlash.h"
    4248
    4349namespace orxonox
     
    4955        RegisterObject(EnergyDrink);
    5056
    51         this->reloadTime_ = 0.25;
    52         this->damage_ = 0; //default 15
    53         this->speed_ = 2500;
    54         this->delay_ = 0;
     57        this->reloadTime_ = 0.25f;
     58        this->damage_ = 0.0f;
     59        this->speed_ = 2500.0f;
     60        this->delay_ = 0.0f;
    5561        this->setMunitionName("FusionMunition");
    5662
     
    6571        XMLPortParam(EnergyDrink, "delay", setDelay, getDelay, xmlelement, mode);
    6672        XMLPortParam(EnergyDrink, "material", setMaterial, getMaterial, xmlelement, mode);
    67 
    6873    }
    6974
    70     void EnergyDrink::setMaterial(const std::string& material)
     75    /**
     76    @brief
     77        Sets the delay with which is fired.
     78    @param delay
     79        The delay in seconds.
     80    */
     81    void EnergyDrink::setDelay(float delay)
    7182    {
    72         this->material_ = material;
    73     }
    74 
    75     void EnergyDrink::setDelay(float d)
    76     {
    77         this->delay_ = d;
     83        this->delay_ = delay;
    7884        this->delayTimer_.setInterval(this->delay_);
    7985    }
    8086
    81     float EnergyDrink::getDelay() const
    82     {
    83         return this->delay_;
    84     }
    85 
     87    /**
     88    @brief
     89        Fires the weapon.
     90    */
    8691    void EnergyDrink::fire()
    8792    {
     
    8994    }
    9095
    91     void EnergyDrink::muendungsfeuer()
    92     {
    93         MuzzleFlash *muzzleFlash = new MuzzleFlash(this);
    94         this->getWeapon()->attach(muzzleFlash);
    95         muzzleFlash->setPosition(this->getMuzzleOffset());
    96         muzzleFlash->setMaterial(this->material_);
    97     }
    98 
    99     /* Creates the projectile object, sets its properties to the EnergyDrink properties, calls muendungsfeuer()
    100      */
     96    /**
     97    @brief
     98        Executes the shot, be creating the projectile and sending it on its way.
     99    */
    101100    void EnergyDrink::shot()
    102101    {
     102        // Create the projectile
    103103        Projectile* projectile = new Projectile(this);
    104104        Model* model = new Model(projectile);
     
    112112        projectile->setVelocity(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn()->getVelocity() + this->getMuzzleDirection() * this->speed_);
    113113
    114         projectile->setOwner(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn());
     114        projectile->setShooter(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn());
    115115        projectile->setDamage(this->getDamage());
    116116        projectile->setShieldDamage(this->getShieldDamage());
    117117        projectile->setHealthDamage(this->getHealthDamage());
    118118
    119         EnergyDrink::muendungsfeuer();
     119        // Display a muzzle flash.
     120        this->muzzleflash();
     121    }
     122
     123    /**
     124    @brief
     125        Displays a muzzle flash.
     126    */
     127    void EnergyDrink::muzzleflash()
     128    {
     129        MuzzleFlash *muzzleFlash = new MuzzleFlash(this);
     130        this->getWeapon()->attach(muzzleFlash);
     131        muzzleFlash->setPosition(this->getMuzzleOffset());
     132        muzzleFlash->setMaterial(this->material_);
    120133    }
    121134}
Note: See TracChangeset for help on using the changeset viewer.