Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 9, 2015, 2:45:58 PM (8 years ago)
Author:
maxima
Message:

Merged presentation and fabiens branch. Had to modify hoverHUD and invaderHUD, because the text of the healthbar wasn't correctly displayed and the weapon settings of the hovership.

Location:
code/branches/presentationHS15
Files:
2 deleted
67 edited
22 copied

Legend:

Unmodified
Added
Removed
  • code/branches/presentationHS15

  • code/branches/presentationHS15/src/modules/overlays/CMakeLists.txt

    r7163 r10961  
    1616  LINK_LIBRARIES
    1717    orxonox
     18    weapons
    1819  SOURCE_FILES ${OVERLAYS_SRC_FILES}
    1920)
  • code/branches/presentationHS15/src/modules/overlays/OverlaysPrereqs.h

    r9939 r10961  
    9090    class HUDRadar;
    9191    class HUDSpeedBar;
     92    class HUDShieldBar;
    9293    class HUDBoostBar;
     94    class HUDRocketFuelBar;
     95    class HUDEnemyHealthBar;
     96    class HUDEnemyShieldBar;
     97    class HUDWeaponSystem;
     98    class HUDWeapon;
     99    class HUDWeaponMode;
    93100    class HUDTimer;
    94101    class HUDAimAssistant;
  • code/branches/presentationHS15/src/modules/overlays/hud/CMakeLists.txt

    r9939 r10961  
    55  HUDSpeedBar.cc
    66  HUDBoostBar.cc
     7  HUDShieldBar.cc
    78  HUDHealthBar.cc
     9  HUDRocketFuelBar.cc
    810  HUDTimer.cc
    911  HUDEnemyHealthBar.cc
     12  HUDEnemyShieldBar.cc
     13  HUDWeaponMode.cc
     14  HUDWeapon.cc
     15  HUDWeaponSystem.cc
    1016  ChatOverlay.cc
    1117  AnnounceMessage.cc
  • code/branches/presentationHS15/src/modules/overlays/hud/HUDBar.cc

    r9667 r10961  
    4747    RegisterClass(BarColour);
    4848
    49     BarColour::BarColour(Context* context)
    50         : BaseObject(context)
     49    BarColour::BarColour(Context* context) : BaseObject(context)
    5150    {
    5251        RegisterObject(BarColour);
    53 
     52       
    5453        this->setColour(ColourValue(1.0, 1.0, 1.0, 1.0));
    5554        this->setPosition(0.0);
     
    6968    RegisterClass(HUDBar);
    7069
    71     HUDBar::HUDBar(Context* context)
    72         : OrxonoxOverlay(context), right2Left_(false), autoColour_(false)
     70    HUDBar::HUDBar(Context* context) : OrxonoxOverlay(context), right2Left_(false), autoColour_(false)
    7371    {
    7472        RegisterObject(HUDBar);
     
    8886        this->bar_->setMaterialName(materialname);
    8987
     88        this->bar_->setPosition(0.0f,0.0f);
     89        this->bar_->setDimensions(1.0f,1.0f);
     90
     91        this->bUseIcon_ = false;
    9092        this->value_ = 1.0f;  // initialize with 1.0f to trigger a change when calling setValue(0.0f) on the line below
    9193        this->setAutoColour(true);
     
    9597
    9698        this->background_->addChild(bar_);
     99
     100        this->icon_ = static_cast<Ogre::PanelOverlayElement* >(Ogre::OverlayManager::getSingleton().createOverlayElement("Panel", "HUDBar_icon_" + getUniqueNumberString()));
     101        this->icon_->setPosition(0.06f,0.0f);
     102        this->icon_->setDimensions(0.1f,1.0f);
     103        this->background_->addChild(this->icon_);
    97104    }
    98105
     
    115122        XMLPortParam(HUDBar, "autocolour",   setAutoColour,  getAutoColour,  xmlelement, mode);
    116123        XMLPortParam(HUDBar, "bartexture",   setBarTexture,  getBarTexture, xmlelement, mode);
     124        XMLPortParam(HUDBar, "iconmaterial", setIconMaterial, getIconMaterial, xmlelement, mode);
    117125        XMLPortObject(HUDBar, BarColour, "", addColour, getColour, xmlelement, mode);
    118126    }
     
    161169        }
    162170
     171        float height = this->bar_->getHeight();
     172        float top = this->bar_->getTop();
     173
    163174        // set value
    164175        if (this->right2Left_)
    165176        {
    166177            // backward case
    167             this->bar_->setPosition(0.06f + 0.88f * (1 - this->value_), 0.0f);
    168             this->bar_->setDimensions(0.88f * this->value_, 1.0f);
     178            if (this->bUseIcon_)
     179            {
     180                this->bar_->setPosition(0.16f + 0.78f * (1 - this->value_), top);
     181                this->bar_->setDimensions(0.78f * this->value_, height);
     182            }
     183            else
     184            {
     185                this->bar_->setPosition(0.06f + 0.88f * (1 - this->value_), top);
     186                this->bar_->setDimensions(0.88f * this->value_, height);
     187            }
    169188        }
    170189        else
    171190        {
    172191            // default case
    173             this->bar_->setPosition(0.06f, 0.0f);
    174             this->bar_->setDimensions(0.88f * this->value_, 1.0f);
    175         }
     192            if (this->bUseIcon_)
     193            {
     194                this->bar_->setPosition(0.16f, top);
     195                this->bar_->setDimensions(0.78f * this->value_, height);
     196            }
     197            else
     198            {
     199                this->bar_->setPosition(0.06f, top);
     200                this->bar_->setDimensions(0.88f * this->value_, height);
     201            }
     202        }
     203
    176204        if (this->value_ != 0)
    177205            this->bar_->setTiling(this->value_, 1.0);
     
    208236        return this->textureUnitState_->getTextureName();
    209237    }
     238
     239    void HUDBar::setIconMaterial(const std::string& iconMaterial)
     240    {
     241        this->bUseIcon_ = true;
     242        this->icon_->setMaterialName(iconMaterial);
     243        valueChanged();
     244    }
     245
     246    const std::string& HUDBar::getIconMaterial() const
     247    {
     248        return this->icon_->getMaterialName();
     249    }
    210250}
  • code/branches/presentationHS15/src/modules/overlays/hud/HUDBar.h

    r9667 r10961  
    3737#include <map>
    3838#include <vector>
     39#include <OgrePanelOverlayElement.h>
    3940
    4041#include "util/Math.h"
     
    5152        virtual ~BarColour() { }
    5253
    53         virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
     54        virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);     
    5455
    5556        void setColour(const ColourValue& colour) { this->colour_ = colour; }
     
    115116        const std::string& getBarTexture() const;
    116117
     118        void setIconMaterial(const std::string& iconMaterial);
     119        const std::string& getIconMaterial() const;
     120
    117121        inline const ColourValue& getCurrentBarColour() const
    118122            { return this->currentColour_; }
    119123
     124        inline void setIconPosition(Vector2 position)
     125            { this->icon_->setPosition(position.x, position.y); }
     126        inline void setIconDimensions(Vector2 dimensions)
     127            { this->icon_->setDimensions(dimensions.x, dimensions.y); }
     128
    120129    protected:
    121130        virtual void valueChanged();
    122 
    123131    private:
    124132        void addColour(BarColour* colour);
     
    129137        float value_;                       //!< progress of bar
    130138        ColourValue currentColour_;
     139        bool bUseIcon_;
    131140
    132141        Ogre::PanelOverlayElement* bar_;
    133142        Ogre::TextureUnitState* textureUnitState_;
     143        Ogre::PanelOverlayElement* icon_;
    134144        std::map<float, ColourValue> colours_;
    135145        std::vector<BarColour*> barColours_;
  • code/branches/presentationHS15/src/modules/overlays/hud/HUDBoostBar.cc

    r9667 r10961  
    5959            if (this->owner_->isBoostCoolingDown())
    6060            {
    61                 this->setBackgroundColour(ColourValue(0.7f, 0.2f, 0.2f));
     61                //this->setBackgroundColour(ColourValue(0.7f, 0.2f, 0.2f));
    6262                if (this->flashDt_ <= 0.0f)
    6363                {
     
    7272                this->flashDt_ = 0.0f;
    7373                this->show();
    74                 this->setBackgroundColour(ColourValue(0.2f, 0.7f, 0.2f));
     74                //this->setBackgroundColour(ColourValue(0.2f, 0.7f, 0.2f));
    7575            }
    7676
  • code/branches/presentationHS15/src/modules/overlays/hud/HUDHealthBar.cc

    r9667 r10961  
    4545        this->owner_ = 0;
    4646        this->bUseBarColour_ = false;
     47        this->textOffset_ = Vector2(0.0f, 0.0f);
     48        this->textScale_ = 1.0f;
     49
     50        this->setIconPosition(Vector2(0.05f,0.5f));
     51        this->setIconDimensions(Vector2(0.1f,0.5f));
    4752
    4853        this->textoverlay_ = new OverlayText(this->getContext());
     
    5156
    5257        this->textoverlay_->setCaption("");
     58        this->textoverlay_->setAspectCorrection(false);
     59
     60        positionText();
    5361    }
    5462
     
    5866        {
    5967            this->textoverlay_->destroy();
    60             this->textoverlay_ = 0;
     68            this->textoverlay_ = NULL;
    6169        }
    6270    }
     
    7078        XMLPortParam(HUDHealthBar, "textusebarcolour",  setTextUseBarColour,     getTextUseBarColour,     xmlelement, mode).defaultValues(false);
    7179        XMLPortParam(HUDHealthBar, "textcolour",        setTextColour,           getTextColour,           xmlelement, mode).defaultValues(ColourValue(1.0, 1.0, 1.0, 1.0));
    72         XMLPortParam(HUDHealthBar, "textsize",          setTextSize,             getTextSize,             xmlelement, mode).defaultValues(1.0f);
    7380        XMLPortParam(HUDHealthBar, "textalign",         setTextAlignmentString,  getTextAlignmentString,  xmlelement, mode).defaultValues("left");
    7481        XMLPortParam(HUDHealthBar, "textoffset",        setTextOffset,           getTextOffset,           xmlelement, mode).defaultValues(Vector2::ZERO);
     82        XMLPortParam(HUDHealthBar, "textscale",         setTextScale,            getTextScale,            xmlelement, mode).defaultValues(1.0f);
    7583        XMLPortParam(HUDHealthBar, "textpickpoint",     setTextPickPoint,        getTextPickPoint,        xmlelement, mode).defaultValues(Vector2::ZERO);
    7684        XMLPortParam(HUDHealthBar, "textrotation",      setTextRotation,         getTextRotation,         xmlelement, mode).defaultValues(0.0f);
    77         XMLPortParam(HUDHealthBar, "textcorrectaspect", setTextAspectCorrection, getTextAspectCorrection, xmlelement, mode).defaultValues(true);
    7885        XMLPortParam(HUDHealthBar, "textspacewidth",    setTextSpaceWidth,       getTextSpaceWidth,       xmlelement, mode).defaultValues(true);
    7986    }
     
    139146            this->textoverlay_->setColour(this->textColour_);
    140147    }
     148
     149    void HUDHealthBar::positionText()
     150    {
     151        this->textoverlay_->setPosition(this->getPosition() + this->textOffset_*this->getActualSize());
     152        this->textoverlay_->setTextSize(this->getActualSize().y*this->textScale_);
     153    }
     154
     155    void HUDHealthBar::positionChanged()
     156    {
     157        HUDBar::positionChanged();
     158        positionText();
     159    }
     160
     161    void HUDHealthBar::sizeChanged()
     162    {
     163        HUDBar::sizeChanged();
     164        positionText();
     165    }   
    141166}
  • code/branches/presentationHS15/src/modules/overlays/hud/HUDHealthBar.h

    r10624 r10961  
    7575                { return this->textoverlay_->getAlignmentString(); }
    7676
    77             inline void setTextSize(float size)
    78                 { this->textoverlay_->setTextSize(size); }
    79             inline float getTextSize() const
    80                 { return this->textoverlay_->getTextSize(); }
    81 
    8277            inline void setTextVisible(bool bVisible)
    8378                { this->textoverlay_->setVisible(bVisible); }
    8479            inline bool getTextVisible() const
    8580                { return this->textoverlay_->isVisible(); }
     81
     82            inline void setTextScale(float scale)
     83                { this->textScale_ = scale;
     84                  positionText();
     85                }
     86            inline float getTextScale() const
     87                { return this->textScale_; }
    8688
    8789            inline void setTextPickPoint(const Vector2& pickpoint)
     
    9193
    9294            inline void setTextOffset(const Vector2& position)
    93                 { this->textoverlay_->setPosition(this->getPosition() + (position - this->getPickPoint()) * this->getSize()); }
     95                { this->textOffset_ = position;
     96                  this->positionText();
     97                }
    9498            inline Vector2 getTextOffset() const
    95                 { return (this->textoverlay_->getPosition() - this->getPosition()) / this->getSize() + this->getPickPoint(); }
    96 
    97             inline void setTextAspectCorrection(bool correct)
    98                 { this->textoverlay_->setAspectCorrection(correct); }
    99             inline bool getTextAspectCorrection() const
    100                 { return this->textoverlay_->getAspectCorrection(); }
     99                { return this->textOffset_; }
    101100
    102101            inline void setTextRotation(const Degree& angle)
     
    112111            inline void setHealthBarOwner(Pawn* owner)
    113112                { this->owner_ = owner; }
    114 
     113        protected:
     114            virtual void positionChanged();
     115            virtual void sizeChanged();
    115116        private:
     117            virtual void positionText();
    116118            WeakPtr<Pawn> owner_;
    117119            StrongPtr<OverlayText> textoverlay_;
    118120            bool bUseBarColour_;
    119121            ColourValue textColour_;
     122            Vector2 textOffset_;
     123            float textScale_;
    120124    };
    121125}
  • code/branches/presentationHS15/src/modules/pickup/PickupPrereqs.h

    r9348 r10961  
    8585    class ShrinkPickup;
    8686    class DamageBoostPickup;
     87    class MunitionPickup;
     88    class MunitionContainer;
    8789}
    8890
  • code/branches/presentationHS15/src/modules/pickup/PickupRepresentation.cc

    r9667 r10961  
    187187        Billboard* icon = new Billboard(spawner->getContext());
    188188        icon->setColour(ColourValue(0.89f, 0.79f, 0.08f));
    189         icon->setMaterial("asterisk");
     189        icon->setMaterial("Unknown");
    190190        icon->setScale(0.5);
    191191        sphere->attach(icon);
  • code/branches/presentationHS15/src/modules/pickup/items/CMakeLists.txt

    r9348 r10961  
    88  ShrinkPickup.cc
    99  DamageBoostPickup.cc
     10  BoostPickup.cc
     11  MunitionPickup.cc
     12  MunitionContainer.cc
    1013)
  • code/branches/presentationHS15/src/modules/pickup/items/DronePickup.h

    r9667 r10961  
    4343#include "tools/interfaces/Tickable.h"
    4444
    45 namespace orxonox {
     45namespace orxonox
     46{
    4647
    4748    /**
     
    8081            std::string droneTemplate_; //!< The name of the template, based upon which the Drone is created.
    8182            Pawn* carrierToPawnHelper(void); //!< Helper to transform the PickupCarrier to a Pawn, and throw an error message if the conversion fails.
    82 
    83 
    84 
    8583    };
    8684}
  • code/branches/presentationHS15/src/modules/towerdefense/TowerDefenseTower.cc

    r10727 r10961  
    6161        {
    6262            upgrade++;
    63             float reloadrate = getReloadRate();
    64             float reloadwaittime = getReloadWaitTime();
    6563            this->setDamageMultiplier((upgrade+1)*2.0f);
    6664            //this->setRotationThrust(2*this->getRotationThrust());
    67             reloadrate = 0.5f*reloadrate;
    68             reloadwaittime = 0.5f*reloadwaittime;
    69             setReloadRate(reloadrate);
    70             setReloadWaitTime(reloadwaittime);
    7165            //this->addTemplate("towerturret1");
    7266        }
  • code/branches/presentationHS15/src/modules/weapons/WeaponsPrereqs.h

    r10622 r10961  
    6969{
    7070    class MuzzleFlash;
     71    class IceGunFreezer;
     72    class RocketController;
    7173
    7274    // munitions
    7375    class FusionMunition;
    7476    class LaserMunition;
    75     class ReplenishingMunition;
    7677    class RocketMunition;
    7778    class GravityBombMuntion;
     79    class IceMunition;
     80    class LightningMunition;
     81    class SplitMunition;
    7882
    7983    // projectiles
     
    8185    class LightningGunProjectile;
    8286    class ParticleProjectile;
     87    class IceProjectile;
     88    class SplitProjectile;
    8389    class Projectile;
     90    class BasicProjectile;
    8491    class Rocket;
    8592    class RocketOld;
     
    9198    class FusionFire;
    9299    class HsW01;
     100    class IceGun;
     101    class SplitGun;
    93102    class LaserFire;
    94103    class LightningGun;
  • code/branches/presentationHS15/src/modules/weapons/munitions/CMakeLists.txt

    r10629 r10961  
    11ADD_SOURCE_FILES(WEAPONS_SRC_FILES
    2   ReplenishingMunition.cc
    32  LaserMunition.cc
     3  LightningMunition.cc
    44  FusionMunition.cc
    55  RocketMunition.cc
  • code/branches/presentationHS15/src/modules/weapons/munitions/FusionMunition.cc

    r9667 r10961  
    2828
    2929/**
    30     @file FusionMunition.h
     30    @file FusionMunition.cc
    3131    @brief Implementation of the FusionMunition class.
    3232*/
     
    3434#include "FusionMunition.h"
    3535#include "core/CoreIncludes.h"
     36#include "core/XMLPort.h"
    3637
    3738namespace orxonox
     
    4546        this->maxMunitionPerMagazine_ = 10;
    4647        this->maxMagazines_ = 10;
    47         this->magazines_ = 10;
     48        this->unassignedMagazines_ = 10;
    4849
    49         this->bUseSeparateMagazines_ = true;
    50         this->bStackMunition_ = false;
     50        this->deployment_ = MunitionDeployment::Separate;
     51
    5152        this->reloadTime_ = 1.0f;
    5253
    5354        this->bAllowMunitionRefilling_ = true;
    5455        this->bAllowMultiMunitionRemovementUnderflow_ = true;
     56
     57        this->reloadTime_ = 0.5f;
     58    }
     59
     60    void FusionMunition::XMLPort(Element& xmlelement, XMLPort::Mode mode)
     61    {
     62        SUPER(FusionMunition, XMLPort, xmlelement, mode);
    5563    }
    5664}
  • code/branches/presentationHS15/src/modules/weapons/munitions/FusionMunition.h

    r9667 r10961  
    5353            FusionMunition(Context* context);
    5454            virtual ~FusionMunition() {}
     55            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
    5556    };
    5657}
  • code/branches/presentationHS15/src/modules/weapons/munitions/GravityBombMunition.cc

    r10622 r10961  
    77#include "GravityBombMunition.h"
    88#include "core/CoreIncludes.h"
     9#include "core/XMLPort.h"
    910
    1011namespace orxonox
     
    1718        this->maxMunitionPerMagazine_ = 1;
    1819        this->maxMagazines_ = 30;
    19         this->magazines_ = 15;
     20        this->unassignedMagazines_ = 15;
    2021
    21         this->bUseSeparateMagazines_ = false;
    22         this->bStackMunition_ = true;
     22        this->deployment_ = MunitionDeployment::Stack;
    2323
    2424        this->bAllowMunitionRefilling_ = true;
    2525        this->bAllowMultiMunitionRemovementUnderflow_ = false;
     26
     27        this->reloadTime_ = 0.0f;
    2628    }
    2729
     30    void GravityBombMunition::XMLPort(Element& xmlelement, XMLPort::Mode mode)
     31    {
     32        SUPER(GravityBombMunition, XMLPort, xmlelement, mode);
     33    }
    2834}
    2935
  • code/branches/presentationHS15/src/modules/weapons/munitions/GravityBombMunition.h

    r10622 r10961  
    2828            GravityBombMunition(Context* context);
    2929            virtual ~GravityBombMunition() {}
     30            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
    3031    };
    3132
  • code/branches/presentationHS15/src/modules/weapons/munitions/IceMunition.cc

    r10629 r10961  
    2828
    2929/**
    30     @file IceMunition.h
     30    @file IceMunition.cc
    3131    @brief Implementation of the IceMunition class.
    3232*/
     
    3434#include "IceMunition.h"
    3535#include "core/CoreIncludes.h"
     36#include "core/XMLPort.h"
    3637
    3738namespace orxonox
     
    4546        this->maxMunitionPerMagazine_ = 1;
    4647        this->maxMagazines_ = 50;
    47         this->magazines_ = 25;
     48        this->unassignedMagazines_ = 25;
    4849
    49         this->bUseSeparateMagazines_ = false;
    50         this->bStackMunition_ = true;
     50        this->deployment_ = MunitionDeployment::Stack;
    5151
    52         this->bAllowMunitionRefilling_ = false;
     52        this->bAllowMunitionRefilling_ = true;
    5353        this->bAllowMultiMunitionRemovementUnderflow_ = false;
     54
     55        this->reloadTime_ = 0.5f;
     56    }
     57
     58    void IceMunition::XMLPort(Element& xmlelement, XMLPort::Mode mode)
     59    {
     60        SUPER(IceMunition, XMLPort, xmlelement, mode);
    5461    }
    5562}
  • code/branches/presentationHS15/src/modules/weapons/munitions/IceMunition.h

    r10629 r10961  
    5353            IceMunition(Context* context);
    5454            virtual ~IceMunition() {}
     55            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
    5556    };
    5657}
  • code/branches/presentationHS15/src/modules/weapons/munitions/LaserMunition.cc

    r9667 r10961  
    2828
    2929/**
    30     @file LaserMunition.h
     30    @file LaserMunition.cc
    3131    @brief Implementation of the LaserMunition class.
    3232*/
     
    3434#include "LaserMunition.h"
    3535#include "core/CoreIncludes.h"
     36#include "core/XMLPort.h"
    3637
    3738namespace orxonox
     
    4445
    4546        this->maxMunitionPerMagazine_ = 20;
    46         this->maxMagazines_ = 1;
    47         this->magazines_ = 1;
     47        this->maxMagazines_ = 10;
     48        this->unassignedMagazines_ = 10;
    4849
    49         this->bUseSeparateMagazines_ = false;
    50         this->bStackMunition_ = true;
     50        this->deployment_ = MunitionDeployment::Separate;
    5151
    5252        this->bAllowMunitionRefilling_ = true;
    5353        this->bAllowMultiMunitionRemovementUnderflow_ = true;
    5454
    55         this->replenishInterval_ = 0.5f;
    56         this->replenishMunitionAmount_ = 1;
     55        this->replenishInterval_ = 7.0f;
     56        this->replenishAmount_ = 1;
     57
     58        this->reloadTime_ = 0.5f;
     59    }
     60
     61    void LaserMunition::XMLPort(Element& xmlelement, XMLPort::Mode mode)
     62    {
     63        SUPER(LaserMunition, XMLPort, xmlelement, mode);
    5764    }
    5865}
  • code/branches/presentationHS15/src/modules/weapons/munitions/LaserMunition.h

    r9667 r10961  
    3636
    3737#include "weapons/WeaponsPrereqs.h"
    38 #include "ReplenishingMunition.h"
     38#include "weaponsystem/ReplenishingMunition.h"
    3939
    4040namespace orxonox
     
    5353            LaserMunition(Context* context);
    5454            virtual ~LaserMunition() {}
     55            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
    5556    };
    5657}
  • code/branches/presentationHS15/src/modules/weapons/munitions/RocketMunition.cc

    r9667 r10961  
    2828
    2929/**
    30     @file RocketMunition.h
     30    @file RocketMunition.cc
    3131    @brief Implementation of the RocketMunition class.
    3232*/
     
    3434#include "RocketMunition.h"
    3535#include "core/CoreIncludes.h"
     36#include "core/XMLPort.h"
    3637
    3738namespace orxonox
     
    4546        this->maxMunitionPerMagazine_ = 1;
    4647        this->maxMagazines_ = 30;
    47         this->magazines_ = 10;
     48        this->unassignedMagazines_ = 10;
    4849
    49         this->bUseSeparateMagazines_ = false;
    50         this->bStackMunition_ = true;
     50        this->deployment_ = MunitionDeployment::Stack;
    5151
    52         this->bAllowMunitionRefilling_ = false;
     52        this->bAllowMunitionRefilling_ = true;
    5353        this->bAllowMultiMunitionRemovementUnderflow_ = false;
     54
     55        this->reloadTime_ = 0.5f;
     56    }
     57
     58    void RocketMunition::XMLPort(Element& xmlelement, XMLPort::Mode mode)
     59    {
     60        SUPER(RocketMunition, XMLPort, xmlelement, mode);
    5461    }
    5562}
  • code/branches/presentationHS15/src/modules/weapons/munitions/RocketMunition.h

    r9667 r10961  
    5353            RocketMunition(Context* context);
    5454            virtual ~RocketMunition() {}
     55            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
    5556    };
    5657}
  • code/branches/presentationHS15/src/modules/weapons/munitions/SplitMunition.cc

    r10629 r10961  
    2828
    2929/**
    30     @file SplitMunition.h
     30    @file SplitMunition.cc
    3131    @brief Implementation of the SplitMunition class.
    3232*/
     
    3434#include "SplitMunition.h"
    3535#include "core/CoreIncludes.h"
     36#include "core/XMLPort.h"
    3637
    3738namespace orxonox
     
    4344        RegisterObject(SplitMunition);
    4445
    45         this->maxMunitionPerMagazine_ = 1;
    46         this->maxMagazines_ = 100;
    47         this->magazines_ = 25;
     46        this->maxMunitionPerMagazine_ = 5;
     47        this->maxMagazines_ = 10;
     48        this->unassignedMagazines_ = 5;
    4849
    49         this->bUseSeparateMagazines_ = false;
    50         this->bStackMunition_ = true;
     50        this->deployment_ = MunitionDeployment::Share;
    5151
    5252        this->bAllowMunitionRefilling_ = true;
    5353        this->bAllowMultiMunitionRemovementUnderflow_ = false;
     54
     55        this->reloadTime_ = 0.5f;
     56    }
     57
     58    void SplitMunition::XMLPort(Element& xmlelement, XMLPort::Mode mode)
     59    {
     60        SUPER(SplitMunition, XMLPort, xmlelement, mode);
    5461    }
    5562}
  • code/branches/presentationHS15/src/modules/weapons/munitions/SplitMunition.h

    r10629 r10961  
    5353            SplitMunition(Context* context);
    5454            virtual ~SplitMunition() {}
     55            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
    5556    };
    5657}
  • code/branches/presentationHS15/src/modules/weapons/projectiles/BasicProjectile.cc

    r10293 r10961  
    6868    @brief
    6969        The function called when a projectile hits another thing.
    70         Calls the hit-function, starts the reload countdown, displays visual hit effects defined in Pawn.
     70        Calls the hit-function, starts the shield recharge countdown, displays visual hit effects defined in Pawn.
    7171        Needs to be called in the collidesAgainst() function by every Class directly inheriting from BasicProjectile.
    7272    @param otherObject
     
    9797            {
    9898                victim->hit(this->getShooter(), contactPoint, cs, this->getDamage(), this->getHealthDamage(), this->getShieldDamage());
    99                 victim->startReloadCountdown();
     99                victim->startShieldRechargeCountdown();
    100100            }
    101101
  • code/branches/presentationHS15/src/modules/weapons/projectiles/GravityBombField.cc

    r10622 r10961  
    164164        if (lifetime_ <= -4)
    165165        {
    166             orxout(debug_output) << "Timeout. Destroying field." << endl;
    167166            this->destroy();
    168167        }
  • code/branches/presentationHS15/src/modules/weapons/projectiles/Rocket.cc

    r10622 r10961  
    6666
    6767        this->localAngularVelocity_ = 0;
    68         this->lifetime_ = 100.0f;
     68        this->lifetime_ = 20.0f;
    6969
    7070        if (GameMode::isMaster())
     
    7676            Model* model = new Model(this->getContext());
    7777            model->setMeshSource("rocket.mesh");
    78             model->scale(0.7f);
     78            model->scale(1.0f);
    7979            this->attach(model);
    8080
     
    100100            this->attachCollisionShape(collisionShape);
    101101
    102             this->destroyTimer_.setTimer(this->lifetime_, false, createExecutor(createFunctor(&BasicProjectile::destroyObject, this)));
    103 
    104102            // Add sound
    105103            this->defSndWpnEngine_ = new WorldSound(this->getContext());
     
    114112            this->defSndWpnLaunch_->setVolume(1.0f);
    115113            this->attach(defSndWpnLaunch_);
     114
     115            this->setHudTemplate("rockethud");
    116116        }
    117117        else
     
    320320    }
    321321
     322    float Rocket::getFuel() const
     323    {
     324        return this->destroyTimer_.getRemainingTime();
     325    }
     326
     327    void Rocket::setMaxFuel(float fuel)
     328    {
     329        this->lifetime_ = fuel;
     330        this->destroyTimer_.setTimer(this->lifetime_, false, createExecutor(createFunctor(&BasicProjectile::destroyObject, this)));
     331    }
    322332}
  • code/branches/presentationHS15/src/modules/weapons/projectiles/Rocket.h

    r10216 r10961  
    118118            virtual void fired(unsigned int firemode);
    119119
     120            /**
     121            @brief Set the maximum lifetime of the rocket.
     122            */
     123            virtual void setMaxFuel(float fuel);
     124            /**
     125            @brief Get the maximum lifetime of the rocket.
     126            */
     127            inline float getMaxFuel() const
     128                { return lifetime_; }
     129            virtual float getFuel() const;
     130
    120131        private:
    121132            Vector3 localAngularVelocity_; //!< Variable to temporarily store accumulated steering command input.
  • code/branches/presentationHS15/src/modules/weapons/projectiles/SimpleRocket.cc

    r10299 r10961  
    7676            Model* model = new Model(this->getContext());
    7777            model->setMeshSource("rocket.mesh");
    78             model->scale(0.7f);
     78            model->scale(1.0f);
    7979            this->attach(model);
    8080
  • code/branches/presentationHS15/src/modules/weapons/weaponmodes/EnergyDrink.cc

    r10622 r10961  
    6363        this->delayTimer_.setTimer(1.0f, false, createExecutor(createFunctor(&EnergyDrink::shot, this)));
    6464        this->delayTimer_.stopTimer();
     65
     66        hudImageString_ = "Orxonox/WSHUD_WM_EnergyDrink";
    6567    }
    6668
  • code/branches/presentationHS15/src/modules/weapons/weaponmodes/FusionFire.cc

    r10622 r10961  
    5858
    5959        this->setMunitionName("FusionMunition");
     60
     61        hudImageString_ = "Orxonox/WSHUD_WM_FusionFire";
    6062    }
    6163
  • code/branches/presentationHS15/src/modules/weapons/weaponmodes/GravityBombFire.cc

    r10622 r10961  
    3131        this->setMunitionName("GravityBombMunition");
    3232        this->setDefaultSoundWithVolume("sounds/Rocket_launch.ogg",0.8);    ///< sets sound of the bomb as it is fired.
     33
     34        hudImageString_ = "Orxonox/WSHUD_WM_GravityBombFire";
    3335    }
    3436
  • code/branches/presentationHS15/src/modules/weapons/weaponmodes/HsW01.cc

    r10296 r10961  
    6969
    7070        this->setDefaultSound(this->sound_);
     71
     72        hudImageString_ = "Orxonox/WSHUD_WM_HsW01";
    7173    }
    7274
  • code/branches/presentationHS15/src/modules/weapons/weaponmodes/IceGun.cc

    r10629 r10961  
    5959        this->setFreezeFactor(0.5);
    6060
    61         this->setMunitionName("LaserMunition");
     61        this->setMunitionName("IceMunition");
    6262        this->setDefaultSound("sounds/Weapon_LightningGun.ogg");
     63
     64        hudImageString_ = "Orxonox/WSHUD_WM_IceGun";
    6365    }
    6466
  • code/branches/presentationHS15/src/modules/weapons/weaponmodes/LaserFire.cc

    r10622 r10961  
    5656
    5757        this->setMunitionName("LaserMunition");
     58
     59        hudImageString_ = "Orxonox/WSHUD_WM_LaserFire";
    5860    }
    5961
  • code/branches/presentationHS15/src/modules/weapons/weaponmodes/LightningGun.cc

    r10296 r10961  
    5454        this->speed_ = 750.0f;
    5555
    56         this->setMunitionName("LaserMunition");
     56        this->setMunitionName("LightningMunition");
    5757        this->setDefaultSound("sounds/Weapon_LightningGun.ogg");
     58
     59        hudImageString_ = "Orxonox/WSHUD_WM_LightningGun";
    5860    }
    5961
  • code/branches/presentationHS15/src/modules/weapons/weaponmodes/RocketFire.cc

    r10296 r10961  
    4141#include "weaponsystem/WeaponSystem.h"
    4242#include "worldentities/pawns/Pawn.h"
    43 
     43#include "core/XMLPort.h"
    4444#include "weapons/projectiles/Rocket.h"
    4545
     
    5656        this->damage_ = 0.0f;
    5757        this->speed_ = 500.0f;
     58        this->fuel_ = 10.0f;
    5859
    5960        this->setMunitionName("RocketMunition");
    6061        // The firing sound of the Rocket is played in Rocket.cc (because of OpenAl sound positioning)
     62
     63        hudImageString_ = "Orxonox/WSHUD_WM_RocketFire";
    6164    }
    6265
    6366    RocketFire::~RocketFire()
    6467    {
     68    }
     69
     70    /**
     71    @brief
     72        XMLPort for the RocketFire. You can define the maximum lifetime of the rockets
     73    */
     74    void RocketFire::XMLPort(Element& xmlelement, XMLPort::Mode mode)
     75    {
     76        SUPER(RocketFire, XMLPort, xmlelement, mode);
     77
     78        XMLPortParam(RocketFire, "fuel", setFuel, getFuel, xmlelement, mode);
    6579    }
    6680
     
    7791        rocket->setPosition(this->getMuzzlePosition());
    7892        rocket->setVelocity(this->getMuzzleDirection() * this->speed_);
    79         rocket->scale(2);
     93        rocket->scale(1.0f);
    8094
    8195        rocket->setShooter(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn());
     
    8397        rocket->setShieldDamage(this->getShieldDamage());
    8498        rocket->setHealthDamage(this->getHealthDamage());
     99        rocket->setMaxFuel(this->fuel_);
    85100    }
    86101}
  • code/branches/presentationHS15/src/modules/weapons/weaponmodes/RocketFire.h

    r9667 r10961  
    5454            virtual ~RocketFire();
    5555
     56            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
     57
    5658            virtual void fire();
     59            inline void setFuel(float fuel)
     60                { this->fuel_ = fuel; }
     61            inline float getFuel() const
     62                { return this->fuel_; }
    5763
    5864        private:
    5965            float speed_; //!< The speed of the Rocket.
     66            float fuel_; //!< The maximum lifetime of the rocket
    6067    };
    6168}
  • code/branches/presentationHS15/src/modules/weapons/weaponmodes/RocketFireOld.cc

    r10622 r10961  
    5959        this->setMunitionName("RocketMunition");
    6060        // The firing sound of the Rocket is played in Rocket.cc (because of OpenAl sound positioning)
     61
     62        hudImageString_ = "Orxonox/WSHUD_WM_SimpleRocketFire";
    6163    }
    6264
  • code/branches/presentationHS15/src/modules/weapons/weaponmodes/SimpleRocketFire.cc

    r9667 r10961  
    6464        this->setDefaultSoundWithVolume("sounds/Rocket_launch.ogg",0.4f);
    6565        // The firing sound of the Rocket is played in Rocket.cc (because of OpenAl sound positioning)
     66
     67        hudImageString_ = "Orxonox/WSHUD_WM_SimpleRocketFire";
    6668    }
    6769
     
    8385        rocket->setVelocity(this->getMuzzleDirection()*this->speed_);
    8486        rocket->setShooter(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn());
     87        rocket->scale(1.0f);
    8588
    8689        rocket->setDamage(this->damage_);
     
    8992
    9093        WorldEntity* pawn = static_cast<ControllableEntity*>(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn())->getTarget();
    91         if (pawn) controller->setTarget(pawn);
     94        if (pawn)
     95            controller->setTarget(pawn);
    9296    }
    9397}
  • code/branches/presentationHS15/src/modules/weapons/weaponmodes/SplitGun.cc

    r10629 r10961  
    3535
    3636#include "core/CoreIncludes.h"
    37 #include "core/XMLPort.h"   
     37#include "core/XMLPort.h"
    3838#include "weaponsystem/Weapon.h"
    3939#include "weaponsystem/WeaponPack.h"
     
    6262        this->setMunitionName("SplitMunition");
    6363        this->setDefaultSound("sounds/Weapon_LightningGun.ogg");
     64
     65        hudImageString_ = "Orxonox/WSHUD_WM_SplitGun";
    6466    }
    6567
  • code/branches/presentationHS15/src/orxonox/OrxonoxPrereqs.h

    r10624 r10961  
    167167    class DefaultWeaponmodeLink;
    168168    class Munition;
     169    class ReplenishingMunition;
    169170    class Weapon;
    170171    class WeaponMode;
  • code/branches/presentationHS15/src/orxonox/controllers/HumanController.cc

    r10624 r10961  
    199199    @brief
    200200        Starts the boosting mode.
    201         Resets the boosting timeout and ells the ControllableEntity to boost (or not boost anymore).
     201        Resets the boosting timeout and tells the ControllableEntity to boost (or not boost anymore).
    202202    */
    203203    void HumanController::startBoosting(void)
  • code/branches/presentationHS15/src/orxonox/infos/PlayerInfo.cc

    r10624 r10961  
    202202
    203203        this->changedControllableEntity();
     204
     205         // HACK-ish
     206        if(this->isHumanPlayer())
     207            entity->createHud();
    204208    }
    205209
     
    252256        if( !entity || this->previousControllableEntity_.size() == 0 )
    253257            return;
     258
     259        entity->destroyHud(); // HACK-ish
    254260
    255261        this->controllableEntity_->setController(0);
  • code/branches/presentationHS15/src/orxonox/overlays/OrxonoxOverlay.cc

    r10624 r10961  
    450450        tempTx->setColourOperationEx(Ogre::LBX_MODULATE, Ogre::LBS_MANUAL, Ogre::LBS_CURRENT, colour);
    451451    }
     452
     453    void OrxonoxOverlay::setZOrder(unsigned short order)
     454    {
     455        if (this->overlay_)
     456        {
     457            this->overlay_->setZOrder(order);
     458        }
     459    }
    452460}
  • code/branches/presentationHS15/src/orxonox/overlays/OrxonoxOverlay.h

    r9667 r10961  
    6565          only for displaying a picture).
    6666        - Reacts to changes of the window aspect
    67         - Last but not least: On demand you can tell the overlay to automatically resale to correct for
     67        - Last but not least: On demand you can tell the overlay to automatically rescale to correct for
    6868          aspect distortion. E.g. if you play 1024x768 you wouldn't want a round object to be oval.
    6969          Remark: This can (due to the Ogre::Overlay transformation order) only work for angle that are
     
    186186        virtual void changedOverlayGroup()
    187187            { this->changedVisibility(); }
     188        virtual void setZOrder(unsigned short order);
    188189
    189190    protected:
  • code/branches/presentationHS15/src/orxonox/weaponsystem/CMakeLists.txt

    r5781 r10961  
    11ADD_SOURCE_FILES(ORXONOX_SRC_FILES
    22  Munition.cc
     3  ReplenishingMunition.cc
    34  Weapon.cc
    45  WeaponMode.cc
  • code/branches/presentationHS15/src/orxonox/weaponsystem/Munition.cc

    r9667 r10961  
    2424 *      Fabian 'x3n' Landau
    2525 *   Co-authors:
    26  *      ...
     26 *      Fabien Vultier
    2727 *
    2828 */
     
    3232#include "core/CoreIncludes.h"
    3333#include "core/command/Executor.h"
     34#include "core/XMLPort.h"
    3435
    3536namespace orxonox
     
    4344        this->maxMunitionPerMagazine_ = 10;
    4445        this->maxMagazines_ = 10;
    45         this->magazines_ = 10;
    46 
    47         this->bUseSeparateMagazines_ = false;
    48         this->bStackMunition_ = true;
     46        this->unassignedMagazines_ = 10;
     47
     48        this->deployment_ = MunitionDeployment::Stack;
    4949        this->bAllowMunitionRefilling_ = true;
    5050        this->bAllowMultiMunitionRemovementUnderflow_ = true;
    5151
    52         this->reloadTime_ = 0;
     52        this->reloadTime_ = 0.5f;
     53
     54        this->lastFilledWeaponMode_ = NULL;
    5355    }
    5456
    5557    Munition::~Munition()
    5658    {
    57         for (std::map<WeaponMode*, Magazine*>::iterator it = this->currentMagazines_.begin(); it != this->currentMagazines_.end(); ++it)
     59        for (std::map<WeaponMode*, Magazine*>::iterator it = this->assignedMagazines_.begin(); it != this->assignedMagazines_.end(); ++it)
    5860            delete it->second;
    5961    }
    6062
     63    void Munition::XMLPort(Element& xmlelement, XMLPort::Mode mode)
     64    {
     65        SUPER(Munition, XMLPort, xmlelement, mode);
     66
     67        XMLPortParam(Munition, "initialmagazines", setNumMagazines, getNumMagazines, xmlelement, mode);
     68        XMLPortParam(Munition, "maxmagazines", setMaxMagazines, getMaxMagazines, xmlelement, mode);
     69        XMLPortParam(Munition, "munitionpermagazine", setMaxMunitionPerMagazine, getMaxMunitionPerMagazine, xmlelement, mode);
     70    }
     71
    6172    Munition::Magazine* Munition::getMagazine(WeaponMode* user) const
    6273    {
    63         if (this->bUseSeparateMagazines_)
     74        if (deployment_ == MunitionDeployment::Separate)
    6475        {
    6576            // For separated magazines we definitively need a given user
     
    6879
    6980            // Use the map to get the magazine assigned to the given user
    70             std::map<WeaponMode*, Magazine*>::const_iterator it = this->currentMagazines_.find(user);
    71             if (it != this->currentMagazines_.end())
     81            std::map<WeaponMode*, Magazine*>::const_iterator it = this->assignedMagazines_.find(user);
     82            if (it != this->assignedMagazines_.end())
    7283                return it->second;
    7384        }
     
    7586        {
    7687            // We don't use separate magazines for each user, so just take the first magazine
    77             if (this->currentMagazines_.size() > 0)
    78                 return this->currentMagazines_.begin()->second;
     88            if (this->assignedMagazines_.size() > 0)
     89                return this->assignedMagazines_.begin()->second;
    7990        }
    8091
     
    8798        if (magazine)
    8899        {
    89             if (this->bStackMunition_)
     100            if (deployment_ == MunitionDeployment::Stack)
    90101                // With stacked munition every magazine contributes to the total amount
    91                 return this->maxMunitionPerMagazine_ * this->magazines_ + magazine->munition_;
     102                return this->maxMunitionPerMagazine_ * this->unassignedMagazines_ + magazine->munition_;
    92103            else
    93104                // Wihtout stacked munition we just consider the current magazine
     
    109120    unsigned int Munition::getNumMagazines() const
    110121    {
    111         if (this->bStackMunition_)
     122        if (deployment_ == MunitionDeployment::Stack)
    112123        {
    113124            // If we stack munition and the current magazine is still full, it counts too
    114125            Magazine* magazine = this->getMagazine(0);
    115126            if (magazine && magazine->munition_ == this->maxMunitionPerMagazine_)
    116                 return this->magazines_ + 1;
    117         }
    118 
    119         return this->magazines_;
     127                return this->unassignedMagazines_ + 1;
     128        }
     129
     130        return this->unassignedMagazines_;
     131    }
     132
     133    void Munition::setNumMagazines(unsigned int numMagazines)
     134    {
     135        this->unassignedMagazines_ = numMagazines;
    120136    }
    121137
    122138    unsigned int Munition::getMaxMunition() const
    123139    {
    124         if (this->bStackMunition_)
     140        if (deployment_ == MunitionDeployment::Stack)
    125141            return this->maxMunitionPerMagazine_ * this->maxMagazines_;
    126142        else
     
    135151            unsigned int munition = magazine->munition_;
    136152
    137             // If we stack munition, we con't care about the current magazine - we just need enough munition in total
    138             if (this->bStackMunition_)
    139                 munition += this->maxMunitionPerMagazine_ * this->magazines_;
     153            // If we stack munition, we don't care about the current magazine - we just need enough munition in total
     154            if (deployment_ == MunitionDeployment::Stack)
     155            {
     156                munition += this->maxMunitionPerMagazine_ * this->unassignedMagazines_;
     157            }
    140158
    141159            if (munition == 0)
     160            {
    142161                // Absolutely no munition - no chance to take munition
    143162                return false;
     163            }
    144164            else if (this->bAllowMultiMunitionRemovementUnderflow_)
     165            {
    145166                // We're not empty AND we allow underflow, so this will always work
    146167                return true;
     168            }
    147169            else
     170            {
    148171                // We don't allow underflow, so we have to check the amount
    149172                return (munition >= amount);
     173            }
     174
    150175        }
    151176        return false;
     
    169194            {
    170195                // Not enough munition
    171                 if (this->bStackMunition_)
     196                if (deployment_ == MunitionDeployment::Stack)
    172197                {
    173198                    // We stack munition, so just take what we can and then load the next magazine
     
    175200                    magazine->munition_ = 0;
    176201
    177                     if (this->reload(0))
     202                    if (this->reload(NULL))
    178203                        // Successfully reloaded, continue recursively
    179204                        return this->takeMunition(amount, 0);
     
    199224    {
    200225        // As long as we have enough magazines (and don't stack munition) we can reload
    201         return (this->magazines_ > 0 && !this->bStackMunition_);
     226        return (this->unassignedMagazines_ > 0 && deployment_ != MunitionDeployment::Stack);
    202227    }
    203228
     
    207232        if (magazine)
    208233        {
    209             if (this->bStackMunition_)
     234            if (deployment_ == MunitionDeployment::Stack)
    210235                // With stacked munition, we never have to reload
    211236                return false;
     
    227252
    228253        // Check if we actually can reload
    229         if (this->magazines_ == 0)
     254        if (this->unassignedMagazines_ == 0)
    230255            return false;
    231256
    232257        // If we use separate magazines for each user, we definitively need a user given
    233         if (this->bUseSeparateMagazines_ && !user)
     258        if (deployment_ == MunitionDeployment::Separate && !user)
    234259            return false;
    235260
    236261        // If we don't use separate magazines, set user to 0
    237         if (!this->bUseSeparateMagazines_)
    238             user = 0;
     262        if (deployment_ != MunitionDeployment::Separate)
     263        {
     264            user = NULL;
     265        }
    239266
    240267        // Remove the current magazine for the given user
    241         std::map<WeaponMode*, Magazine*>::iterator it = this->currentMagazines_.find(user);
    242         if (it != this->currentMagazines_.end())
    243         {
     268        std::map<WeaponMode*, Magazine*>::iterator it = this->assignedMagazines_.find(user);
     269        if (it != this->assignedMagazines_.end())
     270        {
     271            if (it->first == lastFilledWeaponMode_)
     272            {
     273                lastFilledWeaponMode_ = NULL;
     274            }           
    244275            delete it->second;
    245             this->currentMagazines_.erase(it);
     276            this->assignedMagazines_.erase(it);
    246277        }
    247278
    248279        // Load a new magazine
    249         this->currentMagazines_[user] = new Magazine(this, bUseReloadTime);
    250         this->magazines_--;
     280        this->assignedMagazines_[user] = new Magazine(this, bUseReloadTime);
     281        this->unassignedMagazines_--;
    251282
    252283        return true;
     
    260291            return false;
    261292
    262         if (this->bStackMunition_)
     293        if (deployment_ == MunitionDeployment::Stack)
    263294        {
    264295            // If we stack munition, we can always add munition until we reach the limit
     
    268299        {
    269300            // Return true if any of the current magazines is not full (loading counts as full although it returns 0 munition)
    270             for (std::map<WeaponMode*, Magazine*>::const_iterator it = this->currentMagazines_.begin(); it != this->currentMagazines_.end(); ++it)
     301            for (std::map<WeaponMode*, Magazine*>::const_iterator it = this->assignedMagazines_.begin(); it != this->assignedMagazines_.end(); ++it)
    271302                if (it->second->munition_ < this->maxMunitionPerMagazine_ && it->second->bLoaded_)
    272303                    return true;
     
    281312            return false;
    282313
    283         if (this->bStackMunition_)
     314        if (deployment_ == MunitionDeployment::Stack)
    284315        {
    285316            // Stacking munition means, if a magazine gets full, the munition adds to a new magazine
    286             Magazine* magazine = this->getMagazine(0);
     317            Magazine* magazine = this->getMagazine(NULL);
    287318            if (magazine)
    288319            {
     
    294325                {
    295326                    magazine->munition_ -= this->maxMunitionPerMagazine_;
    296                     this->magazines_++;
     327                    this->unassignedMagazines_++;
    297328                }
    298329
    299                 // If we reached the limit, reduze both magazines and munition to the maximum
    300                 if (this->magazines_ >= this->maxMagazines_)
    301                 {
    302                     this->magazines_ = this->maxMagazines_ - 1;
     330                // If we reached the limit, reduce both magazines and munition to the maximum
     331                if (this->unassignedMagazines_ >= this->maxMagazines_)
     332                {
     333                    this->unassignedMagazines_ = this->maxMagazines_;
    303334                    magazine->munition_ = this->maxMunitionPerMagazine_;
    304335                }
     
    312343        else
    313344        {
     345            std::map<WeaponMode*, Magazine*>::iterator it;
     346
     347            // If the pointer to the weapon mode whose magazine got munition added to is NULL, then set the iterator to the beginning of the map
     348            // Otherwise set it to the next weapon mode
     349            if (lastFilledWeaponMode_ == NULL)
     350            {
     351                it = this->assignedMagazines_.begin();
     352            }
     353            else
     354            {
     355                it = this->assignedMagazines_.find(lastFilledWeaponMode_);
     356                ++ it;
     357            }
     358
    314359            // Share the munition equally to the current magazines
     360            bool firstLoop = true;
    315361            while (amount > 0)
    316362            {
    317363                bool change = false;
    318                 for (std::map<WeaponMode*, Magazine*>::iterator it = this->currentMagazines_.begin(); it != this->currentMagazines_.end(); ++it)
     364                while (it != this->assignedMagazines_.end())
    319365                {
    320366                    // Add munition if the magazine isn't full (but only to loaded magazines)
     
    323369                        it->second->munition_++;
    324370                        amount--;
     371                        lastFilledWeaponMode_ = it->first;
    325372                        change = true;
    326373                    }
     374
     375                    ++it;
    327376                }
    328377
    329378                // If there was no change in a loop, all magazines are full (or locked due to loading)
    330                 if (!change)
     379                // Because the first loop does not start at the beginning of the map we have to treat is separately
     380                if (!change && !firstLoop)
     381                {
    331382                    break;
     383                }                   
     384
     385                it = this->assignedMagazines_.begin();
     386                firstLoop = false;
    332387            }
    333388
     
    340395        // TODO: 'amount' is not used
    341396
    342         if (this->bStackMunition_)
     397        if (deployment_ == MunitionDeployment::Stack)
    343398            // If we stack munition, we can always add new magazines because they contribute directly to the munition
    344399            return (this->getNumMunition(0) < this->getMaxMunition());
    345400        else
    346401            // If we don't stack munition, we're more limited
    347             return ((this->currentMagazines_.size() + this->magazines_) < this->maxMagazines_);
    348     }
    349 
    350     bool Munition::addMagazines(unsigned int amount)
    351     {
     402            return ((this->assignedMagazines_.size() + this->unassignedMagazines_) < this->maxMagazines_);
     403    }
     404
     405    unsigned int Munition::addMagazines(unsigned int amount)
     406    {
     407        unsigned int addedMagazines = 0;
     408
    352409        if (!this->canAddMagazines(amount))
    353             return false;
     410            return 0;
    354411
    355412        // Calculate how many magazines are needed
    356         int needed_magazines = this->maxMagazines_ - this->magazines_ - this->currentMagazines_.size();
     413        int needed_magazines = this->maxMagazines_ - this->unassignedMagazines_ - this->assignedMagazines_.size();
    357414
    358415        // If zero or less magazines are needed, we definitively don't need more magazines (unless we stack munition - then a magazine contributes directly to the munition)
    359         if (needed_magazines <= 0 && !this->bStackMunition_)
    360             return false;
     416        if (needed_magazines <= 0 && deployment_ != MunitionDeployment::Stack)
     417            return 0;
    361418
    362419        if (amount <= static_cast<unsigned int>(needed_magazines))
    363420        {
    364421            // We need more magazines than we get, so just add them
    365             this->magazines_ += amount;
     422            this->unassignedMagazines_ += amount;
     423            addedMagazines = amount;
    366424        }
    367425        else
    368426        {
    369427            // We get more magazines than we need, so just add the needed amount
    370             this->magazines_ += needed_magazines;
    371             if (this->bStackMunition_)
     428            this->unassignedMagazines_ += needed_magazines;
     429            addedMagazines = needed_magazines;
     430            if (deployment_ == MunitionDeployment::Stack)
    372431            {
    373432                // We stack munition, so the additional amount contributes directly to the munition of the current magazine
     
    378437        }
    379438
    380         return true;
     439        // Reload as many empty magazines as possible
     440        // Double loop and break is needed because the reload function changes the assigned magazines. This may confuse the iterator.
     441        for (unsigned int i = 0; i < addedMagazines; ++i)
     442        {
     443            for (std::map<WeaponMode*, Magazine*>::iterator it = this->assignedMagazines_.begin(); it != this->assignedMagazines_.end(); ++it)
     444            {
     445                if (needReload(it->first))
     446                {
     447                    reload(it->first);
     448                    break;
     449                }
     450            }
     451        }
     452
     453        return addedMagazines;
    381454    }
    382455
    383456    bool Munition::canRemoveMagazines(unsigned int amount) const
    384457    {
    385         if (this->bStackMunition_)
    386         {
    387             if (this->magazines_ >= amount)
     458        if (deployment_ == MunitionDeployment::Stack)
     459        {
     460            if (this->unassignedMagazines_ >= amount)
    388461            {
    389462                // We have enough magazines
    390463                return true;
    391464            }
    392             else if (this->magazines_ == amount - 1)
     465            else if (this->unassignedMagazines_ == amount - 1)
    393466            {
    394467                // We lack one magazine, check if the current magazine is still full, if yes we're fine
     
    406479        {
    407480            // In case we're not stacking munition, just check the number of magazines
    408             return (this->magazines_ >= amount);
     481            return (this->unassignedMagazines_ >= amount);
    409482        }
    410483
     
    417490            return false;
    418491
    419         if (this->magazines_ >= amount)
     492        if (this->unassignedMagazines_ >= amount)
    420493        {
    421494            // We have enough magazines, just remove the amount
    422             this->magazines_ -= amount;
    423         }
    424         else if (this->bStackMunition_)
     495            this->unassignedMagazines_ -= amount;
     496        }
     497        else if (deployment_ == MunitionDeployment::Stack)
    425498        {
    426499            // We don't have enough magazines, but we're stacking munition, so additionally remove the bullets from the current magazine
    427             this->magazines_ = 0;
     500            this->unassignedMagazines_ = 0;
    428501            Magazine* magazine = this->getMagazine(0);
    429502            if (magazine)
     
    437510    {
    438511        // If we use separate magazines, we need a user
    439         if (this->bUseSeparateMagazines_ && !user)
     512        if (deployment_ == MunitionDeployment::Separate && !user)
    440513            return false;
    441514
    442515        // If we don't use separate magazines, set user to 0
    443         if (!this->bUseSeparateMagazines_)
    444             user = 0;
     516        if (deployment_ != MunitionDeployment::Separate)
     517            user = NULL;
    445518
    446519        // Remove the current magazine for the given user
    447         std::map<WeaponMode*, Magazine*>::iterator it = this->currentMagazines_.find(user);
    448         if (it != this->currentMagazines_.end())
    449         {
     520        std::map<WeaponMode*, Magazine*>::iterator it = this->assignedMagazines_.find(user);
     521        if (it != this->assignedMagazines_.end())
     522        {
     523            if (it->first == lastFilledWeaponMode_)
     524            {
     525                lastFilledWeaponMode_ = NULL;
     526            }
    450527            delete it->second;
    451             this->currentMagazines_.erase(it);
     528            this->assignedMagazines_.erase(it);           
    452529            return true;
    453530        }
     
    465542        this->bLoaded_ = false;
    466543
    467         if (bUseReloadTime && munition->reloadTime_ > 0 && !munition->bStackMunition_)
     544        if (bUseReloadTime && munition->reloadTime_ > 0 && !munition->deployment_ == MunitionDeployment::Stack)
    468545        {
    469546            const ExecutorPtr& executor = createExecutor(createFunctor(&Magazine::loaded, this));
  • code/branches/presentationHS15/src/orxonox/weaponsystem/Munition.h

    r9667 r10961  
    2424 *      Fabian 'x3n' Landau
    2525 *   Co-authors:
    26  *      ...
     26 *      Fabien Vultier
    2727 *
    2828 */
     
    3939namespace orxonox
    4040{
     41    namespace MunitionDeployment
     42    {
     43        enum Value
     44        {
     45            Separate, // Every comsuming weapon mode has its own magazine. It is possible that one weapon mode is out of ammo while another still has some.
     46            Share, // All comsuming weapon modes take their munition from the same magazine. If this magazine is empty a new one is loaded.
     47            Stack // There is only one magazine where all the munition is stored. Use this deployment mode for heavy weapons loke rockets, bombs, ...
     48        };
     49    }
     50
    4151    class _OrxonoxExport Munition : public BaseObject
    42     {
     52    {       
    4353        struct Magazine
    4454        {
     
    5969            virtual ~Munition();
    6070
     71            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
     72
    6173            unsigned int getNumMunition(WeaponMode* user) const;
    6274            unsigned int getNumMunitionInCurrentMagazine(WeaponMode* user) const;
     
    6880            inline unsigned int getMaxMunitionPerMagazine() const
    6981                { return this->maxMunitionPerMagazine_; }
     82            inline MunitionDeployment::Value getMunitionDeployment() const
     83                { return deployment_; }
     84
    7085
    7186            bool canTakeMunition(unsigned int amount, WeaponMode* user) const;
     
    8297
    8398            bool canAddMagazines(unsigned int amount) const;
    84             bool addMagazines(unsigned int amount);
     99            /**
     100            @brief Try to add magazines.
     101            @param amount The amount of magazines tried to add.
     102            @return The amount of magazines sucessfully added.
     103            */
     104            unsigned int addMagazines(unsigned int amount);
    85105
    86106            bool canRemoveMagazines(unsigned int amount) const;
     
    92112            unsigned int maxMunitionPerMagazine_;
    93113            unsigned int maxMagazines_;
    94             unsigned int magazines_;
    95             std::map<WeaponMode*, Magazine*> currentMagazines_;
     114            unsigned int unassignedMagazines_; // Number of magazines that are not assigned to a weapon mode. These are alway treated as full.
     115            std::map<WeaponMode*, Magazine*> assignedMagazines_; // Maps weapon modes to magazines that are currently used.
    96116
    97             bool bUseSeparateMagazines_;
    98             bool bStackMunition_;
     117            MunitionDeployment::Value deployment_; // Defines the behaviour how munition and magazines are distributed to the consuming weapon modes.
     118
    99119            bool bAllowMunitionRefilling_;
    100120            bool bAllowMultiMunitionRemovementUnderflow_;
    101121
    102             float reloadTime_;
     122            float reloadTime_; // The time needed to replace a magazine by a new one.
     123            WeaponMode* lastFilledWeaponMode_; // Pointer to the weapon mode that got the last munition during the last call of addMunition.
    103124
    104125        private:
    105126            Magazine* getMagazine(WeaponMode* user) const;
     127            inline void setMaxMagazines(unsigned int maxMagazines)
     128                { this->maxMagazines_ = maxMagazines; }
     129            inline void setMaxMunitionPerMagazine(unsigned int maxMunitionPerMagazine)
     130                { this->maxMunitionPerMagazine_ = maxMunitionPerMagazine; }
     131            void setNumMagazines(unsigned int numMagazines);
    106132    };
    107133}
  • code/branches/presentationHS15/src/orxonox/weaponsystem/Weapon.cc

    r10650 r10961  
    134134    }
    135135
     136    /**
     137    @brief
     138        Reload all @ref orxonox::WeaponMode weapon modes of this weapon.
     139    */
    136140    void Weapon::reload()
    137141    {
     
    151155            it->second->setWeapon(this);
    152156    }
     157
     158    void Weapon::updateMunition()
     159    {
     160        for (std::multimap<unsigned int, WeaponMode*>::iterator it = this->weaponmodes_.begin(); it != this->weaponmodes_.end(); ++it)
     161            it->second->updateMunition();
     162    }
    153163}
  • code/branches/presentationHS15/src/orxonox/weaponsystem/Weapon.h

    r10650 r10961  
    5757            void addWeaponmode(WeaponMode* weaponmode);
    5858            WeaponMode* getWeaponmode(unsigned int index) const;
     59            inline std::multimap<unsigned int, WeaponMode*>* getAllWeaponmodes()
     60                { return &weaponmodes_; }
     61            inline int getNumWeaponModes() const
     62                { return weaponmodes_.size(); }
    5963
    6064            /**
     
    7579            inline WeaponSlot * getWeaponSlot() const
    7680                { return this->weaponSlot_; }
     81            void updateMunition();
    7782
    7883        private:
  • code/branches/presentationHS15/src/orxonox/weaponsystem/WeaponMode.cc

    r10650 r10961  
    7575        this->muzzleOrientation_ = Quaternion::IDENTITY;
    7676
     77        hudImageString_ = "WSHUD_WM_Unknown";
     78
    7779        if( GameMode::isMaster() )
    7880        {
     
    125127            this->bSoundAttached_ = true;
    126128        }
    127 
     129       
     130        // Fireing is only possible if this weapon mode is not reloading and there is enough munition
    128131        if (!this->bReloading_ && this->munition_ && this->munition_->takeMunition(this->munitionPerShot_, this))
    129132        {
     
    134137                if (this->munition_->reload(this))
    135138                {
     139                    // If true, the weapon reloads in parallel to the magazine reloading
    136140                    if (this->bParallelReload_)
     141                    {
     142                        // The time needed to reload is the maximum of the reload time of the weapon mode and the magazine.
    137143                        tempReloadtime = std::max(this->reloadTime_, this->munition_->getReloadTime());
     144                    }                       
    138145                    else
     146                    {
     147                        // The time needed to reload is the sum of the reload time of the weapon mode and the magazine.
    139148                        tempReloadtime = this->reloadTime_ + this->munition_->getReloadTime();
     149                    }                       
    140150                }
    141151            }
    142152
     153            // Mark this weapon mode as reloading and start the reload timer
    143154            this->bReloading_ = true;
    144155            this->reloadTimer_.setInterval(tempReloadtime);
     
    232243        }
    233244        else
    234             this->munition_ = 0;
     245        {
     246            this->munition_ = NULL;
     247        }
    235248    }
    236249
     
    283296    }
    284297
    285     void WeaponMode::setDefaultSoundWithVolume(const std::string& soundPath, const float soundVolume){
    286         if (this->defSndWpnFire_) {
     298    void WeaponMode::setDefaultSoundWithVolume(const std::string& soundPath, const float soundVolume)
     299    {
     300        if (this->defSndWpnFire_)
     301        {
    287302            this->defSndWpnFire_->setSource(soundPath);
    288303            this->defSndWpnFire_->setVolume(soundVolume);
  • code/branches/presentationHS15/src/orxonox/weaponsystem/WeaponMode.h

    r10650 r10961  
    3838#include "core/class/SubclassIdentifier.h"
    3939#include "tools/Timer.h"
     40#include "Munition.h"
    4041
    4142namespace orxonox
     
    104105            inline bool getParallelReload() const
    105106                { return this->bParallelReload_; }
     107            inline bool getReloading() const
     108                { return this->bReloading_; }
    106109
    107110
     
    147150            Vector3 getTarget();
    148151
     152            inline const std::string& getHUDImageString() const
     153                { return this->hudImageString_; }           
     154
     155            void updateMunition();
    149156        protected:
    150157            virtual void fire() = 0;
     
    155162
    156163            float reloadTime_;
    157             bool bAutoReload_;
    158             bool bParallelReload_;
     164            bool bAutoReload_; // If true, the weapon reloads the magazine automatically.
     165            bool bParallelReload_; // If true, the weapon reloads in parallel to the magazine reloading.
    159166
    160167            float damage_;
     
    163170            Vector3 muzzleOffset_;
    164171
    165         private:
    166             void updateMunition();
     172            std::string hudImageString_;
     173
     174        private:           
    167175            void reloaded();
    168176
     
    175183
    176184            Timer reloadTimer_;
    177             bool bReloading_;
     185            bool bReloading_; // If true, this weapon mode is marked as reloading.
    178186
    179187            Vector3 muzzlePosition_;
     
    181189
    182190            WorldSound* defSndWpnFire_;
    183             bool        bSoundAttached_;
     191            bool bSoundAttached_;
    184192    };
    185193}
  • code/branches/presentationHS15/src/orxonox/weaponsystem/WeaponPack.cc

    r10650 r10961  
    124124    }
    125125
     126    std::vector<Weapon*>* WeaponPack::getAllWeapons()
     127    {
     128        return &weapons_;       
     129    }   
     130
    126131    void WeaponPack::addDefaultWeaponmodeLink(DefaultWeaponmodeLink* link)
    127132    {
     
    156161            (*it)->setWeaponPack(this);
    157162    }
     163
     164    void WeaponPack::updateMunition()
     165    {
     166        for (std::vector<Weapon *>::const_iterator it = this->weapons_.begin(); it != this->weapons_.end(); ++it)
     167            (*it)->updateMunition();
     168    }
    158169}
  • code/branches/presentationHS15/src/orxonox/weaponsystem/WeaponPack.h

    r9667 r10961  
    5252            void removeWeapon(Weapon * weapon);
    5353            Weapon * getWeapon(unsigned int index) const;
     54            std::vector<Weapon*>* getAllWeapons();
    5455
    5556            inline size_t getNumWeapons() const
     
    6566            inline WeaponSystem * getWeaponSystem() const
    6667                { return this->weaponSystem_; }
     68            void updateMunition();
    6769
    6870        private:
  • code/branches/presentationHS15/src/orxonox/weaponsystem/WeaponSystem.cc

    r10650 r10961  
    240240    }
    241241
     242    std::vector<WeaponPack *> * WeaponSystem::getAllWeaponPacks()
     243    {
     244        return &weaponPacks_;
     245    }   
     246
    242247    bool WeaponSystem::swapWeaponSlots(WeaponSlot * wSlot1, WeaponSlot * wSlot2)
    243248    {
     
    310315            return it->second;
    311316        }
    312         else if (identifier->getIdentifier()->isA(Class(Munition)))
    313         {
    314             Munition* munition = identifier->fabricate(this->getContext());
    315             this->munitions_[identifier->getIdentifier()] = munition;
    316             return munition;
    317         }
    318317        else
    319318        {
    320             return 0;
     319            return NULL;
     320        }
     321    }
     322
     323    void WeaponSystem::addMunition(Munition* munition)
     324    {
     325        if (munition == NULL)
     326        {
     327            return;
     328        }
     329
     330        SubclassIdentifier<Munition> identifier = munition->getIdentifier();
     331
     332        if (identifier)
     333        {
     334            this->munitions_[identifier] = munition;
     335            updateMunition();
     336        }
     337        else
     338        {
     339            orxout(internal_warning) << "Adding munition failed. identifier == NULL " << endl;
     340        }
     341    }
     342
     343    void WeaponSystem::updateMunition()
     344    {
     345        for (std::vector<WeaponPack*>::iterator it = this->weaponPacks_.begin(); it != this->weaponPacks_.end(); ++it)
     346        {
     347            (*it)->updateMunition();
    321348        }
    322349    }
  • code/branches/presentationHS15/src/orxonox/weaponsystem/WeaponSystem.h

    r10650 r10961  
    6767            void removeWeaponPack(WeaponPack * wPack);
    6868            WeaponPack * getWeaponPack(unsigned int index) const;
     69            std::vector<WeaponPack *> * getAllWeaponPacks();
    6970
    7071            // configure slots and firemodes
     
    7677
    7778            Munition * getMunition(SubclassIdentifier<Munition> * identifier);
     79            void addMunition(Munition* munition);
    7880
    7981            inline void setPawn(Pawn * pawn)
     
    9597
    9698        private:
     99            void updateMunition();
     100           
    97101            std::map<unsigned int, WeaponSet *> weaponSets_;
    98102            std::vector<WeaponSlot *> weaponSlots_;
  • code/branches/presentationHS15/src/orxonox/worldentities/MobileEntity.h

    r10437 r10961  
    4747        linear velocity. Then the linear velocity is multiplied by the time since the last call of tick and then added to the position. The same happens with
    4848        the angular acceleration and velocity. With this procedure MobileEntities can change their position and orientation with time.
     49
     50        A MobileEntity can only have the collisition type WorldEntity::None, WorldEntity::Dynamic or WorldEntity::Kinematic. The collsion type WorldEntity::Static is illegal.
    4951    */
    5052
  • code/branches/presentationHS15/src/orxonox/worldentities/StaticEntity.h

    r10437 r10961  
    4444        it is called StaticEntity. It will keep the same position (always with respect to its parent) forever unless you call the
    4545        function @see setPosition to changee it.
     46
     47        A StaticEntity can only have the collisition type WorldEntity::None or WorldEntity::Static. The collsion types WorldEntity::Dynamic and WorldEntity::Kinematic are illegal.
    4648    */
    4749
  • code/branches/presentationHS15/src/orxonox/worldentities/pawns/Pawn.cc

    r10650 r10961  
    4646#include "weaponsystem/WeaponPack.h"
    4747#include "weaponsystem/WeaponSet.h"
     48#include "weaponsystem/Munition.h"
    4849#include "sound/WorldSound.h"
    4950
     
    6162
    6263        this->bAlive_ = true;
    63         this->bReload_ = false;
    6464
    6565        this->health_ = 0;
     
    7171        this->maxShieldHealth_ = 100; //otherwise shield might increase to float_max
    7272        this->shieldAbsorption_ = 0.5;
    73 
    74         this->reloadRate_ = 0;
    75         this->reloadWaitTime_ = 1.0f;
    76         this->reloadWaitCountdown_ = 0;
     73        this->shieldRechargeRate_ = 0;
     74        this->shieldRechargeWaitTime_ = 1.0f;
     75        this->shieldRechargeWaitCountdown_ = 0;
    7776
    7877        this->lastHitOriginator_ = 0;
     
    141140        XMLPortObject(Pawn, WeaponSlot, "weaponslots", addWeaponSlot, getWeaponSlot, xmlelement, mode);
    142141        XMLPortObject(Pawn, WeaponSet, "weaponsets", addWeaponSet, getWeaponSet, xmlelement, mode);
    143         XMLPortObject(Pawn, WeaponPack, "weapons", addWeaponPackXML, getWeaponPack, xmlelement, mode);
    144 
    145         XMLPortParam(Pawn, "reloadrate", setReloadRate, getReloadRate, xmlelement, mode).defaultValues(0);
    146         XMLPortParam(Pawn, "reloadwaittime", setReloadWaitTime, getReloadWaitTime, xmlelement, mode).defaultValues(1.0f);
     142        XMLPortObject(Pawn, WeaponPack, "weaponpacks", addWeaponPackXML, getWeaponPack, xmlelement, mode);
     143        XMLPortObject(Pawn, Munition, "munition", addMunitionXML, getMunitionXML, xmlelement, mode);
     144
     145        XMLPortParam(Pawn, "shieldrechargerate", setShieldRechargeRate, getShieldRechargeRate, xmlelement, mode).defaultValues(0);
     146        XMLPortParam(Pawn, "shieldrechargewaittime", setShieldRechargeWaitTime, getShieldRechargeWaitTime, xmlelement, mode).defaultValues(1.0f);
    147147
    148148        XMLPortParam(Pawn, "explosionSound",  setExplosionSound,  getExplosionSound,  xmlelement, mode);
     
    153153    void Pawn::registerVariables()
    154154    {
    155         registerVariable(this->bAlive_,           VariableDirection::ToClient);
    156         registerVariable(this->health_,           VariableDirection::ToClient);
    157         registerVariable(this->maxHealth_,        VariableDirection::ToClient);
    158         registerVariable(this->shieldHealth_,     VariableDirection::ToClient);
    159         registerVariable(this->maxShieldHealth_,  VariableDirection::ToClient);
    160         registerVariable(this->shieldAbsorption_, VariableDirection::ToClient);
    161         registerVariable(this->bReload_,          VariableDirection::ToServer);
    162         registerVariable(this->aimPosition_,      VariableDirection::ToServer);  // For the moment this variable gets only transfered to the server
     155        registerVariable(this->bAlive_,            VariableDirection::ToClient);
     156        registerVariable(this->health_,            VariableDirection::ToClient);
     157        registerVariable(this->maxHealth_,         VariableDirection::ToClient);
     158        registerVariable(this->shieldHealth_,      VariableDirection::ToClient);
     159        registerVariable(this->maxShieldHealth_,   VariableDirection::ToClient);
     160        registerVariable(this->shieldAbsorption_,  VariableDirection::ToClient);
     161        registerVariable(this->aimPosition_,       VariableDirection::ToServer);  // For the moment this variable gets only transfered to the server
    163162    }
    164163
     
    167166        SUPER(Pawn, tick, dt);
    168167
    169         this->bReload_ = false;
    170 
     168        // Recharge the shield
    171169        // TODO: use the existing timer functions instead
    172         if(this->reloadWaitCountdown_ > 0)
    173         {
    174             this->decreaseReloadCountdownTime(dt);
    175         }
    176         else
    177         {
    178             this->addShieldHealth(this->getReloadRate() * dt);
    179             this->resetReloadCountdown();
     170        if(this->shieldRechargeWaitCountdown_ > 0)
     171        {
     172            this->decreaseShieldRechargeCountdownTime(dt);
     173        }
     174        else
     175        {
     176            this->addShieldHealth(this->getShieldRechargeRate() * dt);
     177            this->resetShieldRechargeCountdown();
    180178        }
    181179
     
    229227    }
    230228
    231     void Pawn::setReloadRate(float reloadrate)
    232     {
    233         this->reloadRate_ = reloadrate;
    234     }
    235 
    236     void Pawn::setReloadWaitTime(float reloadwaittime)
    237     {
    238         this->reloadWaitTime_ = reloadwaittime;
    239     }
    240 
    241     void Pawn::decreaseReloadCountdownTime(float dt)
    242     {
    243         this->reloadWaitCountdown_ -= dt;
     229    void Pawn::setShieldRechargeRate(float shieldRechargeRate)
     230    {
     231        this->shieldRechargeRate_ = shieldRechargeRate;
     232    }
     233
     234    void Pawn::setShieldRechargeWaitTime(float shieldRechargeWaitTime)
     235    {
     236        this->shieldRechargeWaitTime_ = shieldRechargeWaitTime;
     237    }
     238
     239    void Pawn::decreaseShieldRechargeCountdownTime(float dt)
     240    {
     241        this->shieldRechargeWaitCountdown_ -= dt;
    244242    }
    245243
     
    252250        if (this->getGametype() && this->getGametype()->allowPawnDamage(this, originator))
    253251        {
     252            // Health-damage cannot be absorbed by shields.
     253            // Shield-damage only reduces shield health.
     254            // Normal damage can be (partially) absorbed by shields.
     255
    254256            if (shielddamage >= this->getShieldHealth())
    255257            {
     
    480482    }
    481483
    482     void Pawn::reload()
    483     {
    484         this->bReload_ = true;
    485     }
    486 
    487484    void Pawn::postSpawn()
    488485    {
     
    554551    }
    555552
     553    std::vector<WeaponPack *> * Pawn::getAllWeaponPacks()
     554    {
     555        if (this->weaponSystem_)
     556            return this->weaponSystem_->getAllWeaponPacks();
     557        else
     558            return 0;       
     559    }
     560
     561    void Pawn::addMunitionXML(Munition* munition)
     562    {
     563        if (this->weaponSystem_ && munition)
     564        {
     565            this->weaponSystem_->addMunition(munition);
     566        }
     567    }
     568
     569    Munition* Pawn::getMunitionXML() const
     570    {
     571        return NULL;
     572    }
     573
     574    Munition* Pawn::getMunition(SubclassIdentifier<Munition> * identifier)
     575    {
     576        if (weaponSystem_)
     577        {
     578            return weaponSystem_->getMunition(identifier);
     579        }
     580
     581        return NULL;
     582    }
     583
    556584    //Tell the Map (RadarViewable), if this is a playership
    557585    void Pawn::startLocalHumanControl()
    558586    {
    559 //        SUPER(ControllableEntity, changedPlayer());
     587//        SUPER(ControllableEntity, startLocalHumanControl());
    560588        ControllableEntity::startLocalHumanControl();
    561589        this->isHumanShip_ = true;
  • code/branches/presentationHS15/src/orxonox/worldentities/pawns/Pawn.h

    r10437 r10961  
    4242    /**
    4343    @brief
    44         Everything in Orxonoy that has a health attribute is a Pawn. After a Pawn is spawned its health is set to
     44        Everything in Orxonox that has a health attribute is a Pawn. After a Pawn is spawned its health is set to
    4545        its initial health. In every call of the Pawns tick function the game checks whether the pawns health is at
    4646        or below zero. If it is, the pawn gets killed.
    4747
    48         Pawns can carry pickups and fire weapons. The can also have shields.
     48        Pawns can carry pickups and fire weapons. They can also have shields.
    4949
    5050        Notice that every Pawn is a ControllableEntity.
     
    116116                { return this->shieldAbsorption_; }
    117117
    118             // TODO: Rename to shieldRechargeRate
    119             virtual void setReloadRate(float reloadrate);
    120             inline float getReloadRate() const
    121                 { return this->reloadRate_; }
    122 
    123             virtual void setReloadWaitTime(float reloadwaittime);
    124             inline float getReloadWaitTime() const
    125                 { return this->reloadWaitTime_; }
    126 
    127             inline void resetReloadCountdown()
    128                 { this->reloadWaitCountdown_ = 0; }
    129 
    130             inline void startReloadCountdown()
    131                 { this->reloadWaitCountdown_ = this->getReloadWaitTime(); } // TODO: Implement in Projectile.cc
    132 
    133             virtual void decreaseReloadCountdownTime(float dt);
     118            virtual void setShieldRechargeRate(float shieldRechargeRate);
     119            inline float getShieldRechargeRate() const
     120                { return this->shieldRechargeRate_; }
     121
     122            virtual void setShieldRechargeWaitTime(float shieldRechargeWaitTime);
     123            inline float getShieldRechargeWaitTime() const
     124                { return this->shieldRechargeWaitTime_; }
     125
     126            inline void resetShieldRechargeCountdown()
     127                { this->shieldRechargeWaitCountdown_ = 0; }
     128
     129            inline void startShieldRechargeCountdown()
     130                { this->shieldRechargeWaitCountdown_ = this->getShieldRechargeWaitTime(); } // TODO: Implement in Projectile.cc
     131
     132            virtual void decreaseShieldRechargeCountdownTime(float dt);
    134133
    135134            inline ControllableEntity* getLastHitOriginator() const
    136135                { return this->lastHitOriginator_; }
    137136
    138             //virtual void hit(Pawn* originator, const Vector3& force, float damage);
    139             //virtual void hit(Pawn* originator, btManifoldPoint& contactpoint, float damage);
    140137            virtual void hit(Pawn* originator, const Vector3& force, const btCollisionShape* cs, float damage, float healthdamage = 0.0f, float shielddamage = 0.0f);
    141138            virtual void hit(Pawn* originator, btManifoldPoint& contactpoint, const btCollisionShape* cs, float damage, float healthdamage = 0.0f, float shielddamage = 0.0f);
     
    144141
    145142            virtual void fired(unsigned int firemode);
    146             virtual void reload();
    147143            virtual void postSpawn();
    148144
     
    154150            void addWeaponPackXML(WeaponPack * wPack);
    155151            WeaponPack * getWeaponPack(unsigned int index) const;
     152            std::vector<WeaponPack *> * getAllWeaponPacks();
     153
     154            void addMunitionXML(Munition* munition);
     155            Munition* getMunitionXML() const;
     156           
     157            Munition* getMunition(SubclassIdentifier<Munition> * identifier);
    156158
    157159            virtual void addedWeaponPack(WeaponPack* wPack) {}
     
    207209            virtual void spawneffect();
    208210
    209             //virtual void damage(float damage, Pawn* originator = 0);
    210211            virtual void damage(float damage, float healthdamage = 0.0f, float shielddamage = 0.0f, Pawn* originator = NULL, const btCollisionShape* cs = NULL);
    211212
     
    226227            float initialShieldHealth_;
    227228            float shieldAbsorption_; ///< Has to be between 0 and 1
    228             float reloadRate_;
    229             float reloadWaitTime_;
    230             float reloadWaitCountdown_;
     229            float shieldRechargeRate_;
     230            float shieldRechargeWaitTime_;
     231            float shieldRechargeWaitCountdown_;
    231232
    232233            float damageMultiplier_; ///< Used by the Damage Boost Pickup.
     
    235236
    236237            WeaponSystem* weaponSystem_;
    237             bool bReload_;
    238238
    239239            std::string spawnparticlesource_;
  • code/branches/presentationHS15/src/orxonox/worldentities/pawns/SpaceShip.cc

    r10216 r10961  
    297297        }
    298298    }
     299
     300    void SpaceShip::gainBoostPower(float gainedBoostPower)
     301    {
     302        this->boostPower_ += gainedBoostPower;
     303       
     304        if (this->boostPower_ > this->initialBoostPower_)
     305        {
     306            this->boostPower_ = this->initialBoostPower_;
     307        }
     308
     309        // If the booster is in cooldown mode and we gained boost power, the abort the cooldown.
     310        if (this->isBoostCoolingDown() && this->boostPower_ > 0.0f)
     311        {
     312            timer_.stopTimer();
     313            this->boostCooledDown();
     314        }
     315    }
     316
    299317    /**
    300318    @brief
  • code/branches/presentationHS15/src/orxonox/worldentities/pawns/SpaceShip.h

    r10437 r10961  
    5353        - The <b>boost</b>, there are quite some parameters pertaining to boosting. The boost is a special move of the SpaceShip, where, for a limited amount of time, it can fly considerably faster than usual. The <b>boostPower</b> is the amount of power available for boosting. The <b>boostPowerRate</b> is the rate at which the boost power is replenished. The <b>boostRate</b> is the rate at which boosting uses power. And the <b>boostCooldownDuration</b> is the time the SpaceShip cannot boost, once all the boost power has been used up. Naturally all of these parameters must be non-negative.
    5454        - The <b>boost shaking</b>, when the SpaceShip boosts, the camera shakes to create a more immersive effect. Two parameters can be used to adjust the effect. The <b>shakeFrequency</b> is the frequency with which the camera shakes. And the <b>shakeAmplitude</b> is the amount with which the camera shakes. Again these parameters must bee non-negative.
    55         - The <b>lift</b> creates a more natural flight feeling through the addition of a lift force. There are again tow parameters that can be specified. The <b>lift</b> which is the lift force that is applied. And the <b>stallSpeed</b> which is the forward speed after which no more lift is generated.
     55        - The <b>lift</b> creates a more natural flight feeling through the addition of a lift force. There are again two parameters that can be specified. The <b>lift</b> which is the lift force that is applied. And the <b>stallSpeed</b> which is the forward speed after which no more lift is generated.
     56
     57        A spaceship always needs to have the collision type "dynamic". Other collision types are illegal.
    5658
    5759        As mentioned @ref orxonox::Engine Engines can be mounted on the SpaceShip. Here is a (primitive) example of a SpaceShip defined in XML:
     
    250252            inline float getShakeAmplitude() const
    251253                { return this->shakeAmplitude_; }
     254            /**
     255            @brief Add boost power. Is non-negative.
     256            @return Returns the current boost power.
     257            */
     258            void gainBoostPower(float gainedBoostPower);
    252259
    253260        protected:
     
    262269            bool bBoostCooldown_;         //!< Whether the SpaceShip is currently in boost cooldown, during which boosting is impossible.
    263270            float initialBoostPower_;     //!< The initial (and maximal) boost power.
    264             float boostPower_;            //!< The current boost power.
     271            float boostPower_;            //!< The current boost power. If the boost power is reduced to zero the boost cooldown will start.
    265272            float boostPowerRate_;        //!< The rate at which the boost power is recharged.
    266273            float boostRate_;             //!< The rate at which boost power is used up.
     
    289296            std::vector<Engine*> engineList_; //!< The list of all Engines mounted on this SpaceShip.
    290297
    291             Timer timer_;                          //!< Timer for the cooldown duration.
     298            Timer timer_;                          //!< Timer for the cooldown of the boost.
    292299            float shakeDt_;                        //!< Temporary variable for the shaking of the camera.
    293300            Vector3 cameraOriginalPosition_;       //!< The original position of the camera before shaking it.
Note: See TracChangeset for help on using the changeset viewer.