[Orxonox-commit 6548] r11189 - in code/branches/sagerjFS16: data/levels data/levels/includes data/levels/templates data/overlays src/modules/overlays/hud src/modules/weapons/weaponmodes src/orxonox/weaponsystem

sagerj at orxonox.net sagerj at orxonox.net
Thu May 19 17:04:41 CEST 2016


Author: sagerj
Date: 2016-05-19 17:04:41 +0200 (Thu, 19 May 2016)
New Revision: 11189

Added:
   code/branches/sagerjFS16/data/levels/includes/weaponSettingsEscortDischarger.oxi
   code/branches/sagerjFS16/data/levels/templates/spaceshipEscortDischarger.oxt
Modified:
   code/branches/sagerjFS16/data/levels/emptyLevel.oxw
   code/branches/sagerjFS16/data/levels/includes/weaponSettingsEscort.oxi
   code/branches/sagerjFS16/data/overlays/HUDTemplates3.oxo
   code/branches/sagerjFS16/src/modules/overlays/hud/HUDChargeBar.cc
   code/branches/sagerjFS16/src/modules/overlays/hud/HUDChargeBar.h
   code/branches/sagerjFS16/src/modules/weapons/weaponmodes/Discharger.cc
   code/branches/sagerjFS16/src/modules/weapons/weaponmodes/Discharger.h
   code/branches/sagerjFS16/src/orxonox/weaponsystem/WeaponMode.cc
   code/branches/sagerjFS16/src/orxonox/weaponsystem/WeaponMode.h
Log:
done/fixed everything, weaponmode/discharger fully commented only hudchargebar left

Modified: code/branches/sagerjFS16/data/levels/emptyLevel.oxw
===================================================================
--- code/branches/sagerjFS16/data/levels/emptyLevel.oxw	2016-05-19 11:34:34 UTC (rev 11188)
+++ code/branches/sagerjFS16/data/levels/emptyLevel.oxw	2016-05-19 15:04:41 UTC (rev 11189)
@@ -12,7 +12,7 @@
 ?>
 
 <?lua
-  include("templates/spaceshipEscort.oxt")
+  include("templates/spaceshipEscortDischarger.oxt")
 ?>
 
 <Level>
@@ -27,7 +27,7 @@
   >
 
     <Light type=directional position="0,0,0" direction="0.253, 0.593, -0.765" diffuse="1.0, 0.9, 0.9, 1.0" specular="1.0, 0.9, 0.9, 1.0"/>
-    <SpawnPoint team=0 position="-200,0,0" lookat="0,0,0" spawnclass=SpaceShip pawndesign=spaceshipescort />
+    <SpawnPoint team=0 position="-200,0,0" lookat="0,0,0" spawnclass=SpaceShip pawndesign=spaceshipescortdischarger />
     
   </Scene>
 </Level>

Modified: code/branches/sagerjFS16/data/levels/includes/weaponSettingsEscort.oxi
===================================================================
--- code/branches/sagerjFS16/data/levels/includes/weaponSettingsEscort.oxi	2016-05-19 11:34:34 UTC (rev 11188)
+++ code/branches/sagerjFS16/data/levels/includes/weaponSettingsEscort.oxi	2016-05-19 15:04:41 UTC (rev 11189)
@@ -23,7 +23,7 @@
             mode=0
             munitionpershot=1
             delay=0
-            damage=0.5
+            damage=0.8
             material="Flares/point_lensflare"
             muzzleoffset=" 1.6, 1.3, -2.0"
             projectileMesh="LaserBeam2.mesh"

Added: code/branches/sagerjFS16/data/levels/includes/weaponSettingsEscortDischarger.oxi
===================================================================
--- code/branches/sagerjFS16/data/levels/includes/weaponSettingsEscortDischarger.oxi	                        (rev 0)
+++ code/branches/sagerjFS16/data/levels/includes/weaponSettingsEscortDischarger.oxi	2016-05-19 15:04:41 UTC (rev 11189)
@@ -0,0 +1,50 @@
+    <weaponslots>
+      <WeaponSlot position="-9.2,2,-13" />
+      <WeaponSlot position=" 9.2,2,-13" />
+    </weaponslots>
+    <weaponsets>
+      <WeaponSet firemode=0 />
+      <WeaponSet firemode=1 />
+    </weaponsets>
+    <weaponpacks>
+      <WeaponPack>
+        <links>
+          <DefaultWeaponmodeLink firemode=0 weaponmode=0 />
+          <DefaultWeaponmodeLink firemode=1 weaponmode=1 />
+        </links>
+        <Weapon>
+          <Discharger
+            mode=0
+            munitionpershot=1
+            delay=0
+            damage=0.8
+            material="Flares/point_lensflare"
+            projectileMesh="LaserBeam2.mesh"
+          />
+        </Weapon>
+        <Weapon>
+          <Discharger
+            mode=0
+            munitionpershot=1
+            delay=0
+            damage=0.8
+            material="Flares/point_lensflare"
+            projectileMesh="LaserBeam2.mesh"
+          />
+        </Weapon>
+      </WeaponPack>
+      <WeaponPack>
+        <links>
+          <DefaultWeaponmodeLink firemode=1 weaponmode=0 />
+        </links>
+      </WeaponPack>
+    </weaponpacks>
+    <munition>
+      <LaserMunition
+        initialmagazines=2
+        maxmagazines=4
+        munitionpermagazine=5
+        replenishamount=2
+        replenishinterval=30
+      />
+    </munition>

Added: code/branches/sagerjFS16/data/levels/templates/spaceshipEscortDischarger.oxt
===================================================================
--- code/branches/sagerjFS16/data/levels/templates/spaceshipEscortDischarger.oxt	                        (rev 0)
+++ code/branches/sagerjFS16/data/levels/templates/spaceshipEscortDischarger.oxt	2016-05-19 15:04:41 UTC (rev 11189)
@@ -0,0 +1,127 @@
+<Template name=spaceshipescortdischarger>
+  <SpaceShip
+   hudtemplate            = spaceshiphud
+   camerapositiontemplate = spaceshipescortcameras
+   spawnparticlesource    = "Orxonox/fairytwirl"
+   spawnparticleduration  = 3
+   explosionchunks        = 10
+
+   health            = 80
+   maxhealth         = 200
+   initialhealth     = 80
+
+   shieldhealth        = 35
+   initialshieldhealth = 35
+   maxshieldhealth     = 60
+   shieldabsorption    = 0.9
+   shieldrechargerate  = 1
+   shieldrechargewaittime = 1
+
+   primaryThrust     = 150
+   auxilaryThrust    = 30
+   rotationThrust    = 50
+
+   lift = 1;
+   stallSpeed = 220;
+
+   boostPower            = 20
+   boostPowerRate        = 1
+   boostRate             = 5
+   boostCooldownDuration = 10
+
+   shakeFrequency = 15
+   shakeAmplitude = 6
+
+   collisionType     = "dynamic"
+   mass              = 80
+   linearDamping     = 0.7
+   angularDamping    = 0.9999999
+  >
+    <engines>
+      <MultiStateEngine position=" 7.6, 0, 6" template=spaceshipescortengine />
+      <MultiStateEngine position="-7.6, 0, 0" template=spaceshipescortengine />
+    </engines>
+    <attached>
+      <Model position="0,0,0" yaw=90 pitch=0 roll=0 scale=4 mesh="escortShip.mesh" />
+      <Model position="0,0,0" yaw=180 pitch=90 roll=0 scale=4 mesh="escortWeapon.mesh" />
+<!--Model mesh="cube.mesh" mass=10 position="0,0,3" scale3D="10,4,8" />
+<Model mesh="cube.mesh" mass=10 position="12.6,-2,3" scale3D="2.8,2.8,11" />
+<Model mesh="cube.mesh" mass=10 position="-12.6,-2,3" scale3D="2.8,2.8,11" />
+<Model mesh="cube.mesh" mass=10 position="0,0,-12" scale3D="4,4,7" /-->
+    </attached>
+    <collisionShapes>
+      <BoxCollisionShape position="0    ,0 ,  3" halfExtents="10,   4,8" />
+      <BoxCollisionShape position="12.6 ,-2,  3" halfExtents="2.8,2.8,11"/>
+      <BoxCollisionShape position="-12.6,-2,  3" halfExtents="2.8,2.8,11"/>
+      <BoxCollisionShape position="0,     0,-12" halfExtents="4  , 4 ,7" />
+    </collisionShapes>
+    <explosion>
+      <ExplosionPart minspeed=0 maxspeed=0 effect1="orxonox/explosion_flash2" effect2="orxonox/explosion_flame2" />
+      <ExplosionPart minspeed=0 maxspeed=0 effect1="orxonox/explosion_shockwave2" effect2="orxonox/explosion_sparks2" />
+      <ExplosionPart minspeed=0 maxspeed=0 effect1="orxonox/explosion_streak2" effect2="orxonox/explosion_afterglow" />
+
+      <ExplosionPart mesh="explosionparts/escort_part_1.mesh" effect1="Orxonox/fire4" effect2="Orxonox/smoke6" />
+      <ExplosionPart mesh="explosionparts/escort_part_2.mesh" effect1="Orxonox/fire4" effect2="Orxonox/smoke6" />
+      <ExplosionPart mesh="explosionparts/escort_part_3.mesh" effect1="Orxonox/fire4" effect2="Orxonox/smoke6" />
+      <ExplosionPart mesh="explosionparts/escort_part_4.mesh" effect1="Orxonox/fire4" effect2="Orxonox/smoke6" />
+      <ExplosionPart mesh="explosionparts/escort_part_5.mesh" effect1="Orxonox/fire4" effect2="Orxonox/smoke6" />
+      <ExplosionPart mesh="explosionparts/escort_part_6.mesh" effect1="Orxonox/fire4" effect2="Orxonox/smoke6" />
+    </explosion>
+<?lua
+  include("../includes/weaponSettingsEscortDischarger.oxi")
+?>
+  </SpaceShip>
+</Template>
+
+<Template name=spaceshipescortcameras defaults=0>
+  <SpaceShip>
+    <camerapositions>
+      <CameraPosition position="0,15, 60" drag=true mouselook=true />
+      <CameraPosition position="0,20, 90" drag=true mouselook=true />
+      <CameraPosition position="0,30,120" drag=true mouselook=true />
+    </camerapositions>
+  </SpaceShip>
+</Template>
+
+<Template name=spaceshipescortengine baseclass=MultiStateEngine>
+  <MultiStateEngine
+   boostfactor    = 2.2
+
+   speedfront     = 200
+   speedback      =  70
+   speedleftright =  70
+   speedupdown    =  70
+
+   defEngineSndNormal = "sounds/Engine_low.ogg"
+   defEngineSndBoost = "sounds/Engine_high.ogg"
+
+   accelerationfront     = 700
+   accelerationbrake     = 700
+   accelerationback      =  125
+   accelerationleftright =  125
+   accelerationupdown    =  125
+  >
+    <EffectContainer condition="idle">
+      <WorldSound mainstate="activity" source="sounds/Engine_idle.ogg" looping=1 active=false/>
+       />
+      <Backlight mainstate=activity active=false scale=0.33 name=bltest position=" 12, -2, 14" colour="0.2, 0.5, 0.65, 1.0" width=150 length=15 lifetime=2 elements=1 trailmaterial="Trail/backlighttrail" turnontime=2 turnofftime=1 material="Flares/ThrusterFlare1" />
+      <Backlight mainstate=activity active=false scale=0.33 name=bltest position="-12, -2, 14" colour="0.2, 0.5, 0.65, 1.0" width=15 length=15 lifetime=2 elements=1 trailmaterial="Trail/backlighttrail" turnontime=2 turnofftime=1 material="Flares/ThrusterFlare1" />
+    </EffectContainer>
+    <EffectContainer condition="not idle">
+      <FadingBillboard mainstate=activity active=false scale=0.09 position="12, -2, 13" colour="0.2, 1.0, 0.65, 1.0" material="Examples/Flare" turnontime=0.5 turnofftime=0.5 />
+      <FadingBillboard mainstate=activity active=false scale=0.09 position="-12, -2, 13" colour="0.2, 1.0, 0.65, 1.0" material="Examples/Flare" turnontime=0.5 turnofftime=0.5 />
+    </EffectContainer>
+    <EffectContainer condition="normal or brake">
+
+    </EffectContainer>
+    <EffectContainer condition="normal or boost">
+      <Backlight mainstate=activity active=false scale=0.33 name=bltest position=" 12, -2, 14" colour="0.2, 1.0, 0.65, 1.0" width=5 length=1500 lifetime=2 elements=1 trailmaterial="Trail/backlighttrail" turnontime=1 turnofftime=1 material="Flares/ThrusterFlare1" />
+      <Backlight mainstate=activity active=false scale=0.33 name=bltest position="-12, -2, 14" colour="0.2, 1.0, 0.65, 1.0" width=15 length=1500 lifetime=2 elements=1 trailmaterial="Trail/backlighttrail" turnontime=1 turnofftime=1 material="Flares/ThrusterFlare1" />
+    </EffectContainer>
+    <EffectContainer condition="boost">
+      <Backlight mainstate=activity active=false scale=0.33 name=bltest position=" 12, 0, 10" colour="0.6, 0.8, 0.75, 0.7" width=25 length=1000 lifetime=1 elements=30 trailmaterial="Trail/backlighttrail" turnontime=1 turnofftime=1 material="Examples/Flare" />
+      <Backlight mainstate=activity active=false scale=0.33 name=bltest position="-12, 0, 10" colour="0.6, 0.8, 0.75, 0.7" width=25 length=1000 lifetime=1 elements=30 trailmaterial="Trail/backlighttrail" turnontime=1 turnofftime=1 material="Examples/Flare" />
+    </EffectContainer>
+
+  </MultiStateEngine>
+</Template>

Modified: code/branches/sagerjFS16/data/overlays/HUDTemplates3.oxo
===================================================================
--- code/branches/sagerjFS16/data/overlays/HUDTemplates3.oxo	2016-05-19 11:34:34 UTC (rev 11188)
+++ code/branches/sagerjFS16/data/overlays/HUDTemplates3.oxo	2016-05-19 15:04:41 UTC (rev 11189)
@@ -191,7 +191,7 @@
      position      = "0.0 , 0.5 "
      pickpoint     = "0, 1"
      correctaspect = true
-     iconmaterial  = "Orxonox/BarIconSpeed"
+     iconmaterial  = "Orxonox/BarIconCharge"
     >
       <BarColour position = 0.0 colour = "0.7,0.5,0.2" />
       <BarColour position = 0.5 colour = "0.2,0.7,0.2" />

Modified: code/branches/sagerjFS16/src/modules/overlays/hud/HUDChargeBar.cc
===================================================================
--- code/branches/sagerjFS16/src/modules/overlays/hud/HUDChargeBar.cc	2016-05-19 11:34:34 UTC (rev 11188)
+++ code/branches/sagerjFS16/src/modules/overlays/hud/HUDChargeBar.cc	2016-05-19 15:04:41 UTC (rev 11189)
@@ -30,7 +30,6 @@
 
 #include "util/Convert.h"
 #include "core/CoreIncludes.h"
-#include "core/XMLPort.h"
 #include "worldentities/pawns/Pawn.h"
 #include "overlays/OverlayGroup.h"
 
@@ -44,78 +43,44 @@
         RegisterObject(HUDChargeBar);
 
         this->owner_ = nullptr;
-        this->bUseBarColour_ = false;
-        this->textOffset_ = Vector2(0.0f, 0.0f);
-        this->textScale_ = 1.0f;
-        this->correspondingMode_ = nullptr;
-
-        this->setIconPosition(Vector2(0.05f,0.5f));
-        this->setIconDimensions(Vector2(0.1f,0.5f));
-
-        this->textoverlay_ = new OverlayText(this->getContext());
-
-        assert(this->textoverlay_.get());
-
-        this->textoverlay_->setCaption("");
-        this->textoverlay_->setAspectCorrection(false);
-
-        positionText();
+        this->correspondingMode_ = nullptr;             // usually no chargeable weapon equipped
     }
 
-    HUDChargeBar::~HUDChargeBar()
-    {
-        if (this->isInitialized())
-        {
-            this->textoverlay_->destroy();
-            this->textoverlay_ = nullptr;
-        }
-    }
+    HUDChargeBar::~HUDChargeBar() { }
 
-    void HUDChargeBar::XMLPort(Element& xmlelement, XMLPort::Mode mode)
-    {
-        SUPER(HUDChargeBar, XMLPort, xmlelement, mode);
-
-        XMLPortParam(HUDChargeBar, "showtext",          setTextVisible,          getTextVisible,          xmlelement, mode).defaultValues(true);
-        XMLPortParam(HUDChargeBar, "textfont",          setTextFont,             getTextFont,             xmlelement, mode).defaultValues("Monofur");
-        XMLPortParam(HUDChargeBar, "textusebarcolour",  setTextUseBarColour,     getTextUseBarColour,     xmlelement, mode).defaultValues(false);
-        XMLPortParam(HUDChargeBar, "textcolour",        setTextColour,           getTextColour,           xmlelement, mode).defaultValues(ColourValue(1.0, 1.0, 1.0, 1.0));
-        XMLPortParam(HUDChargeBar, "textalign",         setTextAlignmentString,  getTextAlignmentString,  xmlelement, mode).defaultValues("left");
-        XMLPortParam(HUDChargeBar, "textoffset",        setTextOffset,           getTextOffset,           xmlelement, mode).defaultValues(Vector2::ZERO);
-        XMLPortParam(HUDChargeBar, "textscale",         setTextScale,            getTextScale,            xmlelement, mode).defaultValues(1.0f);
-        XMLPortParam(HUDChargeBar, "textpickpoint",     setTextPickPoint,        getTextPickPoint,        xmlelement, mode).defaultValues(Vector2::ZERO);
-        XMLPortParam(HUDChargeBar, "textrotation",      setTextRotation,         getTextRotation,         xmlelement, mode).defaultValues(0.0f);
-        XMLPortParam(HUDChargeBar, "textspacewidth",    setTextSpaceWidth,       getTextSpaceWidth,       xmlelement, mode).defaultValues(true);
-    }
-
     void HUDChargeBar::tick(float dt)
     {
         SUPER(HUDChargeBar, tick, dt);
 
         if (this->owner_)
         {
-            if(correspondingMode_ != nullptr){
-                this->setValue( correspondingMode_->getCharges() * 1.0f / correspondingMode_->getMaxCharges() );
-                this->textoverlay_->setCaption(multi_cast<std::string>(static_cast<int>(this->owner_->getHealth())));
+            if(correspondingMode_ != nullptr)                                                                       // if there is a chargeable weapon equipped we want to show the charged amount with a HUDBar
+            {
+                this->setValue( correspondingMode_->getCharges() * 1.0f / correspondingMode_->getMaxCharges() );    // The Value of the HUDBar is the ratio of current Charges and the maximum Charges possible
+                
+                if(this->correspondingMode_->getCharges() > 0)                                                      // The HUDBar should only be visible when we are charging up
+                    this->setVisible(true);
+                }
+                else
+                {
+                    this->setVisible(false);
+                }
             }
-
-            
         }
         else
         {
             this->setValue(0);
-            this->textoverlay_->setCaption("0");
         }
 
-        if (this->bUseBarColour_)
-            this->textoverlay_->setColour(this->getCurrentBarColour());
-
-
     }
 
     void HUDChargeBar::changedOwner()
     {
         SUPER(HUDChargeBar, changedOwner);
 
+        this->setVisible(false);
+        this->correspondingMode_ = nullptr;
+
         this->owner_ = orxonox_cast<Pawn*>(this->getOwner());
         if(this->owner_ == nullptr){
             return;
@@ -140,57 +105,4 @@
             }
         }
     }
-
-    void HUDChargeBar::changedOverlayGroup()
-    {
-        SUPER(HUDChargeBar, changedOverlayGroup);
-
-        this->getOverlayGroup()->addElement(this->textoverlay_.get());
-    }
-
-    void HUDChargeBar::changedVisibility()
-    {
-        SUPER(HUDChargeBar, changedVisibility);
-
-        this->textoverlay_->setVisible(this->isVisible());
-    }
-
-    void HUDChargeBar::changedName()
-    {
-        SUPER(HUDChargeBar, changedName);
-
-        this->textoverlay_->setName(this->getName() + "text");
-    }
-
-    void HUDChargeBar::setTextColour(const ColourValue& colour)
-    {
-        this->textColour_ = colour;
-        if (!this->bUseBarColour_)
-            this->textoverlay_->setColour(colour);
-    }
-
-    void HUDChargeBar::setTextUseBarColour(bool bUseBarColour)
-    {
-        this->bUseBarColour_ = bUseBarColour;
-        if (!bUseBarColour)
-            this->textoverlay_->setColour(this->textColour_);
-    }
-
-    void HUDChargeBar::positionText()
-    {
-        this->textoverlay_->setPosition(this->getPosition() + this->textOffset_*this->getActualSize());
-        this->textoverlay_->setTextSize(this->getActualSize().y*this->textScale_);
-    }
-
-    void HUDChargeBar::positionChanged()
-    {
-        HUDBar::positionChanged();
-        positionText();
-    }
-
-    void HUDChargeBar::sizeChanged()
-    {
-        HUDBar::sizeChanged();
-        positionText();
-    }    
 }
\ No newline at end of file

Modified: code/branches/sagerjFS16/src/modules/overlays/hud/HUDChargeBar.h
===================================================================
--- code/branches/sagerjFS16/src/modules/overlays/hud/HUDChargeBar.h	2016-05-19 11:34:34 UTC (rev 11188)
+++ code/branches/sagerjFS16/src/modules/overlays/hud/HUDChargeBar.h	2016-05-19 15:04:41 UTC (rev 11189)
@@ -21,21 +21,21 @@
  *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  *
  *   Author:
- *      Fabian 'x3n' Landau
+ *      Johannes Sager
  *   Co-authors:
  *      ...
  *
  */
 
-#ifndef _HUDHealthBar_H__
-#define _HUDHealthBar_H__
+#ifndef _HUDChargeBar_H__
+#define _HUDChargeBar_H__
 
 #include "overlays/OverlaysPrereqs.h"
-
 #include "util/Math.h"
 #include "tools/interfaces/Tickable.h"
 #include "overlays/OverlayText.h"
 #include "HUDBar.h"
+
 #include "weaponsystem/WeaponSystem.h"
 #include "weaponsystem/WeaponPack.h"
 #include "weaponsystem/WeaponMode.h"
@@ -43,90 +43,27 @@
 
 namespace orxonox
 {
+    /**
+    @brief
+        The HUDChargeBar displays the amount of charges of its owner (a @ref Pawn).
+        The length of the bar is given by the ratio of the current charges and the maximal charges of the @ref Pawn.
+    */
+
     class _OverlaysExport HUDChargeBar : public HUDBar, public Tickable
     {
         public:
             HUDChargeBar(Context* context);
             virtual ~HUDChargeBar();
 
-            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) override;
             virtual void tick(float dt) override;
             virtual void changedOwner() override;
-            virtual void changedOverlayGroup() override;
-            virtual void changedVisibility() override;
-            virtual void changedName() override;
 
-            inline void setTextFont(const std::string& font)
-                { if (!font.empty()) { this->textoverlay_->setFont(font); } }
-            inline const std::string& getTextFont() const
-                { return this->textoverlay_->getFont(); }
-
-            void setTextColour(const ColourValue& colour);
-            inline const ColourValue& getTextColour() const
-                { return this->textoverlay_->getColour(); }
-
-            void setTextUseBarColour(bool bUseBarColour);
-            inline bool getTextUseBarColour() const
-                { return this->bUseBarColour_; }
-
-            inline void setTextAlignment(OverlayText::Alignment alignment)
-                { this->textoverlay_->setAlignment(alignment); }
-            inline OverlayText::Alignment getTextAlignment() const
-                { return this->textoverlay_->getAlignment(); }
-
-            void setTextAlignmentString(const std::string& alignment)
-                { this->textoverlay_->setAlignmentString(alignment); }
-            std::string getTextAlignmentString() const
-                { return this->textoverlay_->getAlignmentString(); }
-
-            inline void setTextVisible(bool bVisible)
-                { this->textoverlay_->setVisible(bVisible); }
-            inline bool getTextVisible() const
-                { return this->textoverlay_->isVisible(); }
-
-            inline void setTextScale(float scale)
-                { this->textScale_ = scale;
-                  positionText();
-                }
-            inline float getTextScale() const
-                { return this->textScale_; }
-
-            inline void setTextPickPoint(const Vector2& pickpoint)
-                { this->textoverlay_->setPickPoint(pickpoint); }
-            inline Vector2 getTextPickPoint() const
-                { return this->textoverlay_->getPickPoint(); }
-
-            inline void setTextOffset(const Vector2& position)
-                { this->textOffset_ = position;
-                  this->positionText();
-                }
-            inline Vector2 getTextOffset() const
-                { return this->textOffset_; }
-
-            inline void setTextRotation(const Degree& angle)
-                { this->textoverlay_->setRotation(angle); }
-            inline const Degree& getTextRotation() const
-                { return this->textoverlay_->getRotation(); }
-
-            inline void setTextSpaceWidth(float width)
-                { this->textoverlay_->setSpaceWidth(width); }
-            inline float getTextSpaceWidth() const
-                { return this->textoverlay_->getSpaceWidth(); }
-
             inline void setHealthBarOwner(Pawn* owner)
                 { this->owner_ = owner; }
-        protected:
-            virtual void positionChanged() override;
-            virtual void sizeChanged() override;
+        
         private:
-            WeaponMode* correspondingMode_;
-            void positionText();
+            WeaponMode* correspondingMode_;         // pointer on the chargeable weaponmode (=nullptr if no chargeable weapons equipped)
             WeakPtr<Pawn> owner_;
-            StrongPtr<OverlayText> textoverlay_;
-            bool bUseBarColour_;
-            ColourValue textColour_;
-            Vector2 textOffset_;
-            float textScale_;
     };
 }
 #endif /* _HUDChargeBar_H__ */

Modified: code/branches/sagerjFS16/src/modules/weapons/weaponmodes/Discharger.cc
===================================================================
--- code/branches/sagerjFS16/src/modules/weapons/weaponmodes/Discharger.cc	2016-05-19 11:34:34 UTC (rev 11188)
+++ code/branches/sagerjFS16/src/modules/weapons/weaponmodes/Discharger.cc	2016-05-19 15:04:41 UTC (rev 11189)
@@ -20,7 +20,7 @@
  *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  *
  *   Author:
- *      God of everything
+ *      Johannes Sager
  *   Co-authors:
  *    
  *
@@ -50,10 +50,10 @@
     {
         RegisterObject(Discharger);
 
-        this->reloadTime_ = 3.14159f;
-        this->damage_ = 0.0f;
-        this->speed_ = 100.0f;
-        this->chargeable_ = true;
+        this->reloadTime_ = 3.14159f;           // how long you cannot charge after fire
+        this->damage_ = 0.0f;                   // if 0.0f then it uses weaponsettings.oxi
+        this->speed_ = 100.0f;                  // base projectile speed
+        this->chargeable_ = true;               // true if weapon chargeable
 
         this->setMunitionName("LaserMunition");
         this->setFireSound("sounds/Weapon_LaserFire.ogg");
@@ -69,12 +69,11 @@
         this->computeMuzzleParameters(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn()->getAimPosition());
         projectile->setOrientation(this->getMuzzleOrientation());
         projectile->setPosition(this->getMuzzlePosition());
-        projectile->setVelocity(this->getMuzzleDirection() * this->speed_ * this->charges_ / 5);
-
+        projectile->setVelocity(this->getMuzzleDirection() * this->speed_ * this->charges_ / 5);// we scale the projectile speed with the current charges / 5
         projectile->setShooter(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn());
         projectile->setDamage(this->getDamage() * this->charges_);
-        projectile->setShieldDamage(this->getShieldDamage() * this->charges_);
-        projectile->setHealthDamage(this->getHealthDamage() * this->charges_);
-        this->charges_ = 0;
+        projectile->setShieldDamage(this->getShieldDamage() * this->charges_);                  // we scale both types of damage with the current charges as
+        projectile->setHealthDamage(this->getHealthDamage() * this->charges_);                  // well since this is the whole purpose of a chareable weapon
+        this->charges_ = 0;                                                                     // firing "consumes" the current charges (reset after fire)
     }
 }
\ No newline at end of file

Modified: code/branches/sagerjFS16/src/modules/weapons/weaponmodes/Discharger.h
===================================================================
--- code/branches/sagerjFS16/src/modules/weapons/weaponmodes/Discharger.h	2016-05-19 11:34:34 UTC (rev 11188)
+++ code/branches/sagerjFS16/src/modules/weapons/weaponmodes/Discharger.h	2016-05-19 15:04:41 UTC (rev 11189)
@@ -20,7 +20,7 @@
  *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  *
  *   Author:
- *       God of everything
+ *       Johannes Sager
  *   Co-authors:
  *      
  *

Modified: code/branches/sagerjFS16/src/orxonox/weaponsystem/WeaponMode.cc
===================================================================
--- code/branches/sagerjFS16/src/orxonox/weaponsystem/WeaponMode.cc	2016-05-19 11:34:34 UTC (rev 11188)
+++ code/branches/sagerjFS16/src/orxonox/weaponsystem/WeaponMode.cc	2016-05-19 15:04:41 UTC (rev 11189)
@@ -23,7 +23,7 @@
  *      Martin Polak
  *      Fabian 'x3n' Landau
  *   Co-authors:
- *      ...
+ *      Johannes Sager
  *
  */
 
@@ -62,9 +62,9 @@
         this->bReloading_ = false;
         this->bAutoReload_ = true;
         this->bParallelReload_ = true;
-        this->chargeable_ = false;
-        this->charges_ = 0;
-        this->maxCharges_ = 100;
+        this->chargeable_ = false;              // most weapons are not chargeable
+        this->charges_ = 0;                     // always start with no charges
+        this->maxCharges_ = 100;                // default maximum charges one can have are 100
 
         this->reloadTimer_.setTimer(0.0f, false, createExecutor(createFunctor(&WeaponMode::reloaded, this)));
         this->reloadTimer_.stopTimer();
@@ -122,7 +122,6 @@
 
     bool WeaponMode::fire(float* reloadTime)
     {
-        orxout() << "--- " << endl;
         (*reloadTime) = this->reloadTime_;
         // Fireing is only possible if this weapon mode is not reloading and there is enough munition
         if (!this->bReloading_ && this->munition_ && this->munition_->takeMunition(this->munitionPerShot_, this))
@@ -174,23 +173,29 @@
     bool WeaponMode::push(float* reloadTime)
     {
 
-        if( this->chargeable_)
+        if( this->chargeable_)                                                                                                          // chargeable weapons are supposed to charge on push
         {
-            if(this->charges_ < this->maxCharges_){
-                this->charges_ += 1;
-            }
+            this->munition_ = this->weapon_->getWeaponPack()->getWeaponSystem()->getMunition(&this->munitiontype_);                     // updates the pointer to the munition(which we use in the next step)
+            if(this->charges_ < this->maxCharges_ && this->bReloading_ == false && this->munition_->canTakeMunition(1, this))           // charges up unless:
+            {                                                                                                                           // - we are fully charged
+                this->charges_ += 1;                                                                                                    // - we are reloading
+            }                                                                                                                           // - we have no munition
             return false;
-        } else {
+        }
+        else                                                                                                                            // normal (not chargeable) weapons are supposed to fire on push
+        {
             return fire(reloadTime);
         }
     }
 
-    bool WeaponMode::release(float* reloadTime)
+    bool WeaponMode::release(float* reloadTime)                 
     {
-        if( this->chargeable_)
+        if( this->chargeable_)                                                                                                          // chargeable weapons are supposed to fire on release
         { 
             return fire(reloadTime);
-        }else{
+        }
+        else                                                                                                                            // normal (not chargeable) weapons should do nothing on release
+        {
             return false;
         }
     }

Modified: code/branches/sagerjFS16/src/orxonox/weaponsystem/WeaponMode.h
===================================================================
--- code/branches/sagerjFS16/src/orxonox/weaponsystem/WeaponMode.h	2016-05-19 11:34:34 UTC (rev 11188)
+++ code/branches/sagerjFS16/src/orxonox/weaponsystem/WeaponMode.h	2016-05-19 15:04:41 UTC (rev 11189)
@@ -23,7 +23,7 @@
  *      Martin Polak
  *      Fabian 'x3n' Landau
  *   Co-authors:
- *      ...
+ *      Johannes Sager
  *
  */
 
@@ -109,11 +109,11 @@
 
 
             // Fire
-            inline unsigned int getMaxCharges()
+            inline unsigned int getMaxCharges()                 // get the maximum of charges one can have
                 { return this->maxCharges_;}
-            inline unsigned int getCharges()
+            inline unsigned int getCharges()                    // get the current amount of charges
                 { return this->charges_;}
-            inline bool isChargeable()
+            inline bool isChargeable()                          // returns if the weaponmode is chargeable
                 { return this->chargeable_;}
             inline void setDamage(float damage)
                 { this->damage_ = damage;}
@@ -175,13 +175,13 @@
             unsigned int initialMunition_;
             unsigned int initialMagazines_;
             unsigned int munitionPerShot_;
-            unsigned int charges_;
-            unsigned int maxCharges_;
+            unsigned int charges_;                  // current amount of charges only matters for chargeable weapons(chargeable == true)
+            unsigned int maxCharges_;               // maximum amount of charges (is initialized with 100 in weaponmode.cc) only matters for chargeable weapons(chargeable == true)
 
             float reloadTime_;
-            bool bAutoReload_; // If true, the weapon reloads the magazine automatically.
-            bool bParallelReload_; // If true, the weapon reloads in parallel to the magazine reloading.
-            bool chargeable_; // If true, the weapon fires at release instead at push(where he charges up)
+            bool bAutoReload_;                      // If true, the weapon reloads the magazine automatically.
+            bool bParallelReload_;                  // If true, the weapon reloads in parallel to the magazine reloading.
+            bool chargeable_;                       // If true, the weapon charges up on push and fires on release
 
             float damage_;
             float healthdamage_;
@@ -201,16 +201,16 @@
             std::string munitionname_;
 
             Timer reloadTimer_;
-            bool bReloading_; // If true, this weapon mode is marked as reloading.
+            bool bReloading_;                       // If true, this weapon mode is marked as reloading.
 
             Vector3 muzzlePosition_;
             Quaternion muzzleOrientation_;
 
-            std::string fireSoundPath_; // The path of the sound played when fireing
-            float fireSoundVolume_; // The volume of the sound played when fireing
-            std::vector<WorldSound*> fireSounds_; // List of sounds used by the weapon mode. Because multiple sounds may overlap, we need mor than one WorldSound instance.
-            std::string reloadSoundPath_; // The path of the sound played when reloading
-            float reloadSoundVolume_; // The volume of the sound played when reloading
+            std::string fireSoundPath_;             // The path of the sound played when fireing
+            float fireSoundVolume_;                 // The volume of the sound played when fireing
+            std::vector<WorldSound*> fireSounds_;   // List of sounds used by the weapon mode. Because multiple sounds may overlap, we need mor than one WorldSound instance.
+            std::string reloadSoundPath_;           // The path of the sound played when reloading
+            float reloadSoundVolume_;               // The volume of the sound played when reloading
             WorldSound* reloadSound_;
     };
 }




More information about the Orxonox-commit mailing list