[Orxonox-commit 5404] r10067 - in code/branches/modularships: data/levels/templates src/orxonox/items src/orxonox/worldentities/pawns

noep at orxonox.net noep at orxonox.net
Wed May 21 22:38:09 CEST 2014


Author: noep
Date: 2014-05-21 22:38:09 +0200 (Wed, 21 May 2014)
New Revision: 10067

Modified:
   code/branches/modularships/data/levels/templates/HeavyCruiser.oxt
   code/branches/modularships/src/orxonox/items/ShipPart.cc
   code/branches/modularships/src/orxonox/items/ShipPart.h
   code/branches/modularships/src/orxonox/worldentities/pawns/ModularSpaceShip.cc
Log:
Added explosions. (Because who doesn't love explosions.) Added printing health-status of shipparts to chat. Removed more debug-output.

Modified: code/branches/modularships/data/levels/templates/HeavyCruiser.oxt
===================================================================
--- code/branches/modularships/data/levels/templates/HeavyCruiser.oxt	2014-05-21 13:28:28 UTC (rev 10066)
+++ code/branches/modularships/data/levels/templates/HeavyCruiser.oxt	2014-05-21 20:38:09 UTC (rev 10067)
@@ -49,56 +49,56 @@
     </engines>
     
     <parts>
-        <ShipPart name="frontL" initialhealth="10" damageabsorption="0.5">
+        <ShipPart name="frontL" initialhealth="10" maxhealth="10" damageabsorption="0.5" explosionposition="-76,30,-330">
             <destructionevents>
                 <PartDestructionEvent targetType="ship" targetParam="shieldhealth" operation="*" value="0.5"/>
             </destructionevents>
         </ShipPart>
-        <ShipPart name="frontR" initialhealth="10" damageabsorption="0.5">
+        <ShipPart name="frontR" initialhealth="10" maxhealth="10" damageabsorption="0.5" explosionposition="76,30,-330">
             <destructionevents>
                 <PartDestructionEvent targetType="ship" targetParam="shieldhealth" operation="*" value="0.5"/>
             </destructionevents>
         </ShipPart>
-        <ShipPart name="partL" initialhealth="10" damageabsorption="0.5">
+        <ShipPart name="partL" initialhealth="10" maxhealth="10" damageabsorption="0.5" explosionposition="-100,33,-200">
             <destructionevents>
                 <PartDestructionEvent targetType="ship" targetParam="boostpowerrate" operation="-" value="0.5" message="One of your ship's generators was destroyed!"/>
-		<PartDestructionEvent targetType="engine" targetName="bodyengine" targetParam="speedfront" operation="-" value="50"/>
-            	<PartDestructionEvent targetType="engine" targetName="bodyengine" targetParam="accelerationfront" operation="-" value="3"/>
-		<PartDestructionEvent targetType="engine" targetName="bodyengine" targetParam="boostfactor" operation="set" value="1"/>
-	    </destructionevents>
+                <PartDestructionEvent targetType="engine" targetName="bodyengine" targetParam="speedfront" operation="-" value="50"/>
+                <PartDestructionEvent targetType="engine" targetName="bodyengine" targetParam="accelerationfront" operation="-" value="3"/>
+                <PartDestructionEvent targetType="engine" targetName="bodyengine" targetParam="boostfactor" operation="set" value="1"/>
+            </destructionevents>
         </ShipPart>
-        <ShipPart name="partR" initialhealth="10" damageabsorption="0.5">
+        <ShipPart name="partR" initialhealth="10" maxhealth="10" damageabsorption="0.5" explosionposition="100,33,-200">
             <destructionevents>
                 <PartDestructionEvent targetType="ship" targetParam="boostpowerrate" operation="-" value="0.5" message="One of your ship's generators was destroyed!"/>
-		<PartDestructionEvent targetType="engine" targetName="bodyengine" targetParam="speedfront" operation="-" value="50"/>
-            	<PartDestructionEvent targetType="engine" targetName="bodyengine" targetParam="accelerationfront" operation="-" value="3"/>
-		<PartDestructionEvent targetType="engine" targetName="bodyengine" targetParam="boostfactor" operation="set" value="1"/>
+                <PartDestructionEvent targetType="engine" targetName="bodyengine" targetParam="speedfront" operation="-" value="50"/>
+                <PartDestructionEvent targetType="engine" targetName="bodyengine" targetParam="accelerationfront" operation="-" value="3"/>
+                <PartDestructionEvent targetType="engine" targetName="bodyengine" targetParam="boostfactor" operation="set" value="1"/>
             </destructionevents>
         </ShipPart>
-        <ShipPart name="sidearmL" initialhealth="20" damageabsorption="0.2">
+        <ShipPart name="sidearmL" initialhealth="20" maxhealth="20" damageabsorption="0.2" explosionposition="-140,30,100">
             <destructionevents>
                 <PartDestructionEvent targetType="engine" targetName="sidearmLengine" operation="destroy" message="The left auxiliary engine was destroyed!"/>
-		<PartDestructionEvent targetType="part" targetName="sidearmLfront" operation="destroy"/>
-		<PartDestructionEvent targetType="ship" targetParam="rotationthrust" operation="-" value="0.04" />
+                <PartDestructionEvent targetType="part" targetName="sidearmLfront" operation="destroy"/>
+                <PartDestructionEvent targetType="ship" targetParam="rotationthrust" operation="-" value="0.04" />
             </destructionevents>
         </ShipPart>
-        <ShipPart name="sidearmLfront" initialhealth="10" damageabsorption="0.5">
+        <ShipPart name="sidearmLfront" initialhealth="10" maxhealth="10" damageabsorption="0.5" explosionposition="-140,20,-50">
             <destructionevents>
                 <PartDestructionEvent targetType="engine" targetName="sidearmLengine" targetParam="boostfactor" operation="set" value="1" message="The left auxiliary engine lost it's booster!"/>
             </destructionevents>
-	</ShipPart>
-        <ShipPart name="sidearmR" initialhealth="20" damageabsorption="0.2">
+        </ShipPart>
+        <ShipPart name="sidearmR" initialhealth="20" maxhealth="20" damageabsorption="0.2" explosionposition="140,30,100">
             <destructionevents>
                 <PartDestructionEvent targetType="engine" targetName="sidearmRengine" operation="destroy" message="The right auxiliary engine was destroyed!"/>
-		<PartDestructionEvent targetType="part" targetName="sidearmRfront" operation="destroy"/> 
-		<PartDestructionEvent targetType="ship" targetParam="rotationthrust" operation="-" value="0.04" />           
-	    </destructionevents>
-	</ShipPart>
-        <ShipPart name="sidearmRfront" initialhealth="10" damageabsorption="0.5">
+                <PartDestructionEvent targetType="part" targetName="sidearmRfront" operation="destroy"/> 
+                <PartDestructionEvent targetType="ship" targetParam="rotationthrust" operation="-" value="0.04" />           
+            </destructionevents>
+        </ShipPart>
+        <ShipPart name="sidearmRfront" initialhealth="10" maxhealth="10" damageabsorption="0.5" explosionposition="140,20,-50">
             <destructionevents>
                 <PartDestructionEvent targetType="engine" targetName="sidearmRengine" targetParam="boostfactor" operation="set" value="1" message="The right auxiliary engine lost it's booster!"/>
             </destructionevents>
-	</ShipPart>
+        </ShipPart>
     </parts>
     
     <attached>

Modified: code/branches/modularships/src/orxonox/items/ShipPart.cc
===================================================================
--- code/branches/modularships/src/orxonox/items/ShipPart.cc	2014-05-21 13:28:28 UTC (rev 10066)
+++ code/branches/modularships/src/orxonox/items/ShipPart.cc	2014-05-21 20:38:09 UTC (rev 10067)
@@ -40,6 +40,8 @@
 #include "gametypes/Gametype.h"
 #include "worldentities/StaticEntity.h"
 #include "items/PartDestructionEvent.h"
+#include "worldentities/BigExplosion.h"
+#include "chat/ChatManager.h"
 
 
 namespace orxonox
@@ -69,25 +71,9 @@
 
         XMLPortParam(ShipPart, "damageabsorption", setDamageAbsorption, getDamageAbsorption, xmlelement, mode).defaultValues(0.5);
 
+        XMLPortParamTemplate(ShipPart, "explosionposition", setExplosionPosition, getExplosionPosition, xmlelement, mode, Vector3);
+
         XMLPortObject(ShipPart, PartDestructionEvent, "destructionevents", addDestructionEvent, getDestructionEvent, xmlelement, mode);
-
-        /*
-        XMLPortParam(ShipPart, "shieldhealth", setShieldHealth, getShieldHealth, xmlelement, mode).defaultValues(0);
-        XMLPortParam(ShipPart, "initialshieldhealth", setInitialShieldHealth, getInitialShieldHealth, xmlelement, mode).defaultValues(0);
-        XMLPortParam(ShipPart, "maxshieldhealth", setMaxShieldHealth, getMaxShieldHealth, xmlelement, mode).defaultValues(100);
-        XMLPortParam(ShipPart, "shieldabsorption", setShieldAbsorption, getShieldAbsorption, xmlelement, mode).defaultValues(0);
-
-        XMLPortParam(ShipPart, "sShipPartparticlesource", setSShipPartParticleSource, getSShipPartParticleSource, xmlelement, mode);
-        XMLPortParam(ShipPart, "sShipPartparticleduration", setSShipPartParticleDuration, getSShipPartParticleDuration, xmlelement, mode).defaultValues(3.0f);
-        XMLPortParam(ShipPart, "explosionchunks", setExplosionChunks, getExplosionChunks, xmlelement, mode).defaultValues(7);
-
-        XMLPortParam(ShipPart, "reloadrate", setReloadRate, getReloadRate, xmlelement, mode).defaultValues(0);
-        XMLPortParam(ShipPart, "reloadwaittime", setReloadWaitTime, getReloadWaitTime, xmlelement, mode).defaultValues(1.0f);
-
-        XMLPortParam(ShipPart, "explosionSound",  setExplosionSound,  getExplosionSound,  xmlelement, mode);
-
-        XMLPortParam ( RadarViewable, "radarname", setRadarName, getRadarName, xmlelement, mode );
-        */
     }
 
     /**
@@ -101,6 +87,7 @@
         if (!(this->isAlive()))
             return;
 
+        this->explode();
         this->setAlive(false);
 
         if(eventExecution_)
@@ -114,9 +101,19 @@
 
         // Remove this ShipPart from the parent.
         this->parent_->removeShipPart(this);
-        orxout() << this->getName() << " has died." << endl;
     }
 
+    void ShipPart::explode()
+    {
+        BigExplosion* chunk = new BigExplosion(this->getContext());
+        chunk->setPosition(this->parent_->getPosition() + this->parent_->getOrientation() * (this->explosionPosition_));
+        //chunk->setPosition(this->parent_->getPosition() + this->parent_->getOrientation() * Vector3(this->entityList_[0]->getLocalInertia()));
+        chunk->setVelocity(this->parent_->getVelocity());
+
+        // this->explosionSound_->setPosition(this->parent_->getPosition());
+        // this->explosionSound_->play();
+    }
+
     /**
     @brief
         Add a StaticEntity to the ShipPart.
@@ -159,15 +156,6 @@
         return false;
     }
 
-    void ShipPart::printEntities()
-    {
-        orxout() << "ShipPart " << this->getName() << " has the following entities assigned:" << endl;
-        for(unsigned int j = 0; j < this->entityList_.size(); j++)
-        {
-            orxout() << "  " << this->entityList_[j]->getName() << endl;
-        }
-    }
-
     /**
     @brief
         Add a PartDestructionEvent to the ShipPart.
@@ -220,8 +208,6 @@
     */
     void ShipPart::handleHit(float damage, float healthdamage, float shielddamage, Pawn* originator)
     {
-        orxout() << "ShipPart " <<this->getName() << " is handling a hit!" << endl;
-
         if (parent_->getGametype() && parent_->getGametype()->allowPawnDamage(parent_, originator))
         {
             if (shielddamage >= parent_->getShieldHealth())
@@ -246,7 +232,28 @@
         }
         if (this->health_ < 0)
             this->death();
-        orxout() << "Health of ShipPart " << this->getName() << " is " << this->getHealth() << endl;
+
+        // (Ugly) Chatoutput of health, until a GUI for modularspaceships-shipparts is implemented.
+        if (this->health_ < 0.2 * this->maxHealth_)
+        {
+            ChatManager::message("ShipPart " + this->getName() + " remaining health is 20%!");
+            return;
+        }
+        if (this->health_ < 0.4 * this->maxHealth_)
+        {
+            ChatManager::message("ShipPart " + this->getName() + " remaining health is 40%!");
+            return;
+        }
+        if (this->health_ < 0.6 * this->maxHealth_)
+        {
+            ChatManager::message("ShipPart " + this->getName() + " remaining health is 60%!");
+            return;
+        }
+        if (this->health_ < 0.8 * this->maxHealth_)
+        {
+            ChatManager::message("ShipPart " + this->getName() + " remaining health is 80%!");
+            return;
+        }
     }
 
 

Modified: code/branches/modularships/src/orxonox/items/ShipPart.h
===================================================================
--- code/branches/modularships/src/orxonox/items/ShipPart.h	2014-05-21 13:28:28 UTC (rev 10066)
+++ code/branches/modularships/src/orxonox/items/ShipPart.h	2014-05-21 20:38:09 UTC (rev 10067)
@@ -51,6 +51,7 @@
             virtual void handleHit(float damage, float healthdamage, float shielddamage, Pawn* originator);
 
             virtual void death();
+            virtual void explode();
 
             //virtual void attachTo(Pawn* newParent);
             //virtual void detach();
@@ -62,8 +63,6 @@
             void addDestructionEvent(PartDestructionEvent* event);
             PartDestructionEvent* getDestructionEvent(unsigned int index);
 
-            void printEntities(); // FIXME: (noep) remove debug
-
             virtual void setDamageAbsorption(float value);
             inline float getDamageAbsorption()
                 { return this->damageAbsorption_; }
@@ -100,7 +99,12 @@
             inline float getInitialHealth() const
                 { return this->initialHealth_; }
 
+            inline void setExplosionPosition(Vector3 pos)
+                { this->explosionPosition_ = pos; }
+            inline Vector3 getExplosionPosition()
+                { return this->explosionPosition_; }
 
+
             // FIXME: (noep) Why doesn't this work? Works fine in Engine.h
             //void addToSpaceShip(ModularSpaceShip* ship);
 
@@ -120,7 +124,9 @@
             bool alive_;
             bool eventExecution_;
 
+            Vector3 explosionPosition_;
 
+
     }; // tolua_export
 } // tolua_export
 

Modified: code/branches/modularships/src/orxonox/worldentities/pawns/ModularSpaceShip.cc
===================================================================
--- code/branches/modularships/src/orxonox/worldentities/pawns/ModularSpaceShip.cc	2014-05-21 13:28:28 UTC (rev 10066)
+++ code/branches/modularships/src/orxonox/worldentities/pawns/ModularSpaceShip.cc	2014-05-21 20:38:09 UTC (rev 10067)
@@ -107,17 +107,9 @@
                     this->partList_[j]->addEntity(orxonox_cast<StaticEntity*>(this->getAttachedObject(i)));
                     // An entry in the partMap_ is created, assigning the part to the entity.
                     this->addPartEntityAssignment((StaticEntity*)(this->getAttachedObject(i)), this->partList_[j]);
-                    orxout() << "A matching part-entity-pair with name " << this->partList_[j]->getName() << " was found!" << endl;
-                    this->partList_[j]->printEntities(); // FIXME: (noep) remove debug
                 }
             }
         }
-
-        orxout() << "List of all assignments:" << endl;
-        for (std::map<StaticEntity*, ShipPart*>::const_iterator it = this->partMap_.begin(); it != this->partMap_.end(); ++it)
-                {
-                    orxout() << "Entity: " << it->first << "   Part: " << it->second << endl;
-                }
     }
 
     void ModularSpaceShip::attach(WorldEntity* object)
@@ -146,8 +138,6 @@
                 }
 
         this->partMap_[entity] = part;
-
-        orxout() << "New entity-part assignment created!" << endl;
     }
 
 




More information about the Orxonox-commit mailing list