Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 10067 for code/branches


Ignore:
Timestamp:
May 21, 2014, 10:38:09 PM (11 years ago)
Author:
noep
Message:

Added explosions. (Because who doesn't love explosions.) Added printing health-status of shipparts to chat. Removed more debug-output.

Location:
code/branches/modularships
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • code/branches/modularships/data/levels/templates/HeavyCruiser.oxt

    r10058 r10067  
    5050   
    5151    <parts>
    52         <ShipPart name="frontL" initialhealth="10" damageabsorption="0.5">
     52        <ShipPart name="frontL" initialhealth="10" maxhealth="10" damageabsorption="0.5" explosionposition="-76,30,-330">
    5353            <destructionevents>
    5454                <PartDestructionEvent targetType="ship" targetParam="shieldhealth" operation="*" value="0.5"/>
    5555            </destructionevents>
    5656        </ShipPart>
    57         <ShipPart name="frontR" initialhealth="10" damageabsorption="0.5">
     57        <ShipPart name="frontR" initialhealth="10" maxhealth="10" damageabsorption="0.5" explosionposition="76,30,-330">
    5858            <destructionevents>
    5959                <PartDestructionEvent targetType="ship" targetParam="shieldhealth" operation="*" value="0.5"/>
    6060            </destructionevents>
    6161        </ShipPart>
    62         <ShipPart name="partL" initialhealth="10" damageabsorption="0.5">
     62        <ShipPart name="partL" initialhealth="10" maxhealth="10" damageabsorption="0.5" explosionposition="-100,33,-200">
    6363            <destructionevents>
    6464                <PartDestructionEvent targetType="ship" targetParam="boostpowerrate" operation="-" value="0.5" message="One of your ship's generators was destroyed!"/>
    65                 <PartDestructionEvent targetType="engine" targetName="bodyengine" targetParam="speedfront" operation="-" value="50"/>
    66                 <PartDestructionEvent targetType="engine" targetName="bodyengine" targetParam="accelerationfront" operation="-" value="3"/>
    67                 <PartDestructionEvent targetType="engine" targetName="bodyengine" targetParam="boostfactor" operation="set" value="1"/>
    68             </destructionevents>
    69         </ShipPart>
    70         <ShipPart name="partR" initialhealth="10" damageabsorption="0.5">
     65                <PartDestructionEvent targetType="engine" targetName="bodyengine" targetParam="speedfront" operation="-" value="50"/>
     66                <PartDestructionEvent targetType="engine" targetName="bodyengine" targetParam="accelerationfront" operation="-" value="3"/>
     67                <PartDestructionEvent targetType="engine" targetName="bodyengine" targetParam="boostfactor" operation="set" value="1"/>
     68            </destructionevents>
     69        </ShipPart>
     70        <ShipPart name="partR" initialhealth="10" maxhealth="10" damageabsorption="0.5" explosionposition="100,33,-200">
    7171            <destructionevents>
    7272                <PartDestructionEvent targetType="ship" targetParam="boostpowerrate" operation="-" value="0.5" message="One of your ship's generators was destroyed!"/>
    73                 <PartDestructionEvent targetType="engine" targetName="bodyengine" targetParam="speedfront" operation="-" value="50"/>
    74                 <PartDestructionEvent targetType="engine" targetName="bodyengine" targetParam="accelerationfront" operation="-" value="3"/>
    75                 <PartDestructionEvent targetType="engine" targetName="bodyengine" targetParam="boostfactor" operation="set" value="1"/>
    76             </destructionevents>
    77         </ShipPart>
    78         <ShipPart name="sidearmL" initialhealth="20" damageabsorption="0.2">
     73                <PartDestructionEvent targetType="engine" targetName="bodyengine" targetParam="speedfront" operation="-" value="50"/>
     74                <PartDestructionEvent targetType="engine" targetName="bodyengine" targetParam="accelerationfront" operation="-" value="3"/>
     75                <PartDestructionEvent targetType="engine" targetName="bodyengine" targetParam="boostfactor" operation="set" value="1"/>
     76            </destructionevents>
     77        </ShipPart>
     78        <ShipPart name="sidearmL" initialhealth="20" maxhealth="20" damageabsorption="0.2" explosionposition="-140,30,100">
    7979            <destructionevents>
    8080                <PartDestructionEvent targetType="engine" targetName="sidearmLengine" operation="destroy" message="The left auxiliary engine was destroyed!"/>
    81                 <PartDestructionEvent targetType="part" targetName="sidearmLfront" operation="destroy"/>
    82                 <PartDestructionEvent targetType="ship" targetParam="rotationthrust" operation="-" value="0.04" />
    83             </destructionevents>
    84         </ShipPart>
    85         <ShipPart name="sidearmLfront" initialhealth="10" damageabsorption="0.5">
     81                <PartDestructionEvent targetType="part" targetName="sidearmLfront" operation="destroy"/>
     82                <PartDestructionEvent targetType="ship" targetParam="rotationthrust" operation="-" value="0.04" />
     83            </destructionevents>
     84        </ShipPart>
     85        <ShipPart name="sidearmLfront" initialhealth="10" maxhealth="10" damageabsorption="0.5" explosionposition="-140,20,-50">
    8686            <destructionevents>
    8787                <PartDestructionEvent targetType="engine" targetName="sidearmLengine" targetParam="boostfactor" operation="set" value="1" message="The left auxiliary engine lost it's booster!"/>
    8888            </destructionevents>
    89         </ShipPart>
    90         <ShipPart name="sidearmR" initialhealth="20" damageabsorption="0.2">
     89        </ShipPart>
     90        <ShipPart name="sidearmR" initialhealth="20" maxhealth="20" damageabsorption="0.2" explosionposition="140,30,100">
    9191            <destructionevents>
    9292                <PartDestructionEvent targetType="engine" targetName="sidearmRengine" operation="destroy" message="The right auxiliary engine was destroyed!"/>
    93                 <PartDestructionEvent targetType="part" targetName="sidearmRfront" operation="destroy"/>
    94                 <PartDestructionEvent targetType="ship" targetParam="rotationthrust" operation="-" value="0.04" />           
    95             </destructionevents>
    96         </ShipPart>
    97         <ShipPart name="sidearmRfront" initialhealth="10" damageabsorption="0.5">
     93                <PartDestructionEvent targetType="part" targetName="sidearmRfront" operation="destroy"/>
     94                <PartDestructionEvent targetType="ship" targetParam="rotationthrust" operation="-" value="0.04" />           
     95            </destructionevents>
     96        </ShipPart>
     97        <ShipPart name="sidearmRfront" initialhealth="10" maxhealth="10" damageabsorption="0.5" explosionposition="140,20,-50">
    9898            <destructionevents>
    9999                <PartDestructionEvent targetType="engine" targetName="sidearmRengine" targetParam="boostfactor" operation="set" value="1" message="The right auxiliary engine lost it's booster!"/>
    100100            </destructionevents>
    101         </ShipPart>
     101        </ShipPart>
    102102    </parts>
    103103   
  • code/branches/modularships/src/orxonox/items/ShipPart.cc

    r10058 r10067  
    4141#include "worldentities/StaticEntity.h"
    4242#include "items/PartDestructionEvent.h"
     43#include "worldentities/BigExplosion.h"
     44#include "chat/ChatManager.h"
    4345
    4446
     
    7072        XMLPortParam(ShipPart, "damageabsorption", setDamageAbsorption, getDamageAbsorption, xmlelement, mode).defaultValues(0.5);
    7173
     74        XMLPortParamTemplate(ShipPart, "explosionposition", setExplosionPosition, getExplosionPosition, xmlelement, mode, Vector3);
     75
    7276        XMLPortObject(ShipPart, PartDestructionEvent, "destructionevents", addDestructionEvent, getDestructionEvent, xmlelement, mode);
    73 
    74         /*
    75         XMLPortParam(ShipPart, "shieldhealth", setShieldHealth, getShieldHealth, xmlelement, mode).defaultValues(0);
    76         XMLPortParam(ShipPart, "initialshieldhealth", setInitialShieldHealth, getInitialShieldHealth, xmlelement, mode).defaultValues(0);
    77         XMLPortParam(ShipPart, "maxshieldhealth", setMaxShieldHealth, getMaxShieldHealth, xmlelement, mode).defaultValues(100);
    78         XMLPortParam(ShipPart, "shieldabsorption", setShieldAbsorption, getShieldAbsorption, xmlelement, mode).defaultValues(0);
    79 
    80         XMLPortParam(ShipPart, "sShipPartparticlesource", setSShipPartParticleSource, getSShipPartParticleSource, xmlelement, mode);
    81         XMLPortParam(ShipPart, "sShipPartparticleduration", setSShipPartParticleDuration, getSShipPartParticleDuration, xmlelement, mode).defaultValues(3.0f);
    82         XMLPortParam(ShipPart, "explosionchunks", setExplosionChunks, getExplosionChunks, xmlelement, mode).defaultValues(7);
    83 
    84         XMLPortParam(ShipPart, "reloadrate", setReloadRate, getReloadRate, xmlelement, mode).defaultValues(0);
    85         XMLPortParam(ShipPart, "reloadwaittime", setReloadWaitTime, getReloadWaitTime, xmlelement, mode).defaultValues(1.0f);
    86 
    87         XMLPortParam(ShipPart, "explosionSound",  setExplosionSound,  getExplosionSound,  xmlelement, mode);
    88 
    89         XMLPortParam ( RadarViewable, "radarname", setRadarName, getRadarName, xmlelement, mode );
    90         */
    9177    }
    9278
     
    10288            return;
    10389
     90        this->explode();
    10491        this->setAlive(false);
    10592
     
    115102        // Remove this ShipPart from the parent.
    116103        this->parent_->removeShipPart(this);
    117         orxout() << this->getName() << " has died." << endl;
     104    }
     105
     106    void ShipPart::explode()
     107    {
     108        BigExplosion* chunk = new BigExplosion(this->getContext());
     109        chunk->setPosition(this->parent_->getPosition() + this->parent_->getOrientation() * (this->explosionPosition_));
     110        //chunk->setPosition(this->parent_->getPosition() + this->parent_->getOrientation() * Vector3(this->entityList_[0]->getLocalInertia()));
     111        chunk->setVelocity(this->parent_->getVelocity());
     112
     113        // this->explosionSound_->setPosition(this->parent_->getPosition());
     114        // this->explosionSound_->play();
    118115    }
    119116
     
    160157    }
    161158
    162     void ShipPart::printEntities()
    163     {
    164         orxout() << "ShipPart " << this->getName() << " has the following entities assigned:" << endl;
    165         for(unsigned int j = 0; j < this->entityList_.size(); j++)
    166         {
    167             orxout() << "  " << this->entityList_[j]->getName() << endl;
    168         }
    169     }
    170 
    171159    /**
    172160    @brief
     
    221209    void ShipPart::handleHit(float damage, float healthdamage, float shielddamage, Pawn* originator)
    222210    {
    223         orxout() << "ShipPart " <<this->getName() << " is handling a hit!" << endl;
    224 
    225211        if (parent_->getGametype() && parent_->getGametype()->allowPawnDamage(parent_, originator))
    226212        {
     
    247233        if (this->health_ < 0)
    248234            this->death();
    249         orxout() << "Health of ShipPart " << this->getName() << " is " << this->getHealth() << endl;
     235
     236        // (Ugly) Chatoutput of health, until a GUI for modularspaceships-shipparts is implemented.
     237        if (this->health_ < 0.2 * this->maxHealth_)
     238        {
     239            ChatManager::message("ShipPart " + this->getName() + " remaining health is 20%!");
     240            return;
     241        }
     242        if (this->health_ < 0.4 * this->maxHealth_)
     243        {
     244            ChatManager::message("ShipPart " + this->getName() + " remaining health is 40%!");
     245            return;
     246        }
     247        if (this->health_ < 0.6 * this->maxHealth_)
     248        {
     249            ChatManager::message("ShipPart " + this->getName() + " remaining health is 60%!");
     250            return;
     251        }
     252        if (this->health_ < 0.8 * this->maxHealth_)
     253        {
     254            ChatManager::message("ShipPart " + this->getName() + " remaining health is 80%!");
     255            return;
     256        }
    250257    }
    251258
  • code/branches/modularships/src/orxonox/items/ShipPart.h

    r10058 r10067  
    5252
    5353            virtual void death();
     54            virtual void explode();
    5455
    5556            //virtual void attachTo(Pawn* newParent);
     
    6263            void addDestructionEvent(PartDestructionEvent* event);
    6364            PartDestructionEvent* getDestructionEvent(unsigned int index);
    64 
    65             void printEntities(); // FIXME: (noep) remove debug
    6665
    6766            virtual void setDamageAbsorption(float value);
     
    101100                { return this->initialHealth_; }
    102101
     102            inline void setExplosionPosition(Vector3 pos)
     103                { this->explosionPosition_ = pos; }
     104            inline Vector3 getExplosionPosition()
     105                { return this->explosionPosition_; }
     106
    103107
    104108            // FIXME: (noep) Why doesn't this work? Works fine in Engine.h
     
    121125            bool eventExecution_;
    122126
     127            Vector3 explosionPosition_;
     128
    123129
    124130    }; // tolua_export
  • code/branches/modularships/src/orxonox/worldentities/pawns/ModularSpaceShip.cc

    r10058 r10067  
    108108                    // An entry in the partMap_ is created, assigning the part to the entity.
    109109                    this->addPartEntityAssignment((StaticEntity*)(this->getAttachedObject(i)), this->partList_[j]);
    110                     orxout() << "A matching part-entity-pair with name " << this->partList_[j]->getName() << " was found!" << endl;
    111                     this->partList_[j]->printEntities(); // FIXME: (noep) remove debug
    112110                }
    113111            }
    114112        }
    115 
    116         orxout() << "List of all assignments:" << endl;
    117         for (std::map<StaticEntity*, ShipPart*>::const_iterator it = this->partMap_.begin(); it != this->partMap_.end(); ++it)
    118                 {
    119                     orxout() << "Entity: " << it->first << "   Part: " << it->second << endl;
    120                 }
    121113    }
    122114
     
    147139
    148140        this->partMap_[entity] = part;
    149 
    150         orxout() << "New entity-part assignment created!" << endl;
    151141    }
    152142
Note: See TracChangeset for help on using the changeset viewer.