Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 21, 2014, 10:38:09 PM (10 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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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
Note: See TracChangeset for help on using the changeset viewer.