Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jun 6, 2008, 5:31:58 PM (16 years ago)
Author:
landauf
Message:

several improvements:

  • AI works properly now - add enemies with 'createEnemy x' where x is the number of enemies to add, default is 1. You can remove AI ships with 'killEnemies'.
  • Added new explosion (with smoke)
  • Added new projectile (with trail)
  • Added new thruster emitter
  • AI ships are destroyable - they start with 100 hp, each hit makes 15 hp damage, this value is configurable in the config-file: [Projectile] damage_
  • Added AI ship spawn and explosion effects
File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/trunk/src/orxonox/objects/Projectile.cc

    r1505 r1552  
    3535#include "core/Executor.h"
    3636#include "core/ConfigValueIncludes.h"
     37#include "particle/ParticleInterface.h"
    3738
    38 #include "SpaceShip.h"
    39 #include "Explosion.h"
     39#include "SpaceShipAI.h"
     40#include "ParticleSpawner.h"
    4041#include "Model.h"
    4142
    4243namespace orxonox
    4344{
    44     CreateFactory(Projectile);
     45    float Projectile::speed_ = 2000;
    4546
    46     float Projectile::speed_ = 0;
    47 
    48     Projectile::Projectile(SpaceShip* owner) :
    49       owner_(owner)
     47    Projectile::Projectile(SpaceShip* owner) : owner_(owner)
    5048    {
    5149        RegisterObject(Projectile);
    5250
    5351        this->setConfigValues();
    54 
    55         this->billboard_.setBillboardSet("Examples/Flare", ColourValue(1.0, 1.0, 0.5), 1);
    56         this->attachObject(this->billboard_.getBillboardSet());
    57         this->scale(0.5);
     52        this->explosionTemplateName_ = "Orxonox/explosion1";
     53        this->smokeTemplateName_ = "Orxonox/smoke3";
    5854
    5955        if (this->owner_)
     
    6359            this->setPosition(this->owner_->getPosition());
    6460            this->translate(Vector3(55, 0, 0), Ogre::Node::TS_LOCAL);
    65             this->setVelocity(Vector3(1, 0, 0) * this->speed_);
     61            this->setVelocity(this->owner_->getInitialDir() * this->speed_);
    6662        }
    6763
    6864        this->destroyTimer_.setTimer(this->lifetime_, false, this, createExecutor(createFunctor(&Projectile::destroyObject)));
    69 //        COUT(3) << this->classID << std::endl;
    7065    }
    7166
     
    7671    void Projectile::setConfigValues()
    7772    {
    78         SetConfigValue(lifetime_, 10.0).description("The time in seconds a projectile stays alive");
     73        SetConfigValue(damage_, 15.0).description("The damage caused by the projectile");
     74        SetConfigValue(lifetime_, 5.0).description("The time in seconds a projectile stays alive");
    7975        SetConfigValue(speed_, 2000.0).description("The speed of a projectile in units per second");
    8076
    81         this->setVelocity(Vector3(1, 0, 0) * this->speed_);
     77        this->setVelocity(this->owner_->getInitialDir() * this->speed_);
    8278    }
    8379
     
    9591                if (this->getPosition().squaredDistance(it->getPosition()) <= (radius*radius))
    9692                {
    97                     Explosion *exp = new Explosion(this);
    98                     exp->create();
     93                    // hit
     94                    if (it->isA(Class(SpaceShipAI)))
     95                        ((SpaceShipAI*)(*it))->damage(this->damage_);
     96                    ParticleSpawner* explosion = new ParticleSpawner(this->explosionTemplateName_, 2.0);
     97                    explosion->setPosition(this->getPosition());
     98                    explosion->create();
     99                    ParticleSpawner* smoke = new ParticleSpawner(this->smokeTemplateName_, 6.0, 0.0);
     100                    smoke->setPosition(this->getPosition());
     101                    smoke->getParticleInterface()->setSpeedFactor(3.0);
     102                    smoke->create();
    99103                    delete this;
    100104                    return;
     
    108112        delete this;
    109113    }
    110 
    111     void Projectile::setColour(const ColourValue& colour)
    112     {
    113         this->billboard_.getBillboardSet()->getBillboard(0)->setColour(colour);
    114     }
    115114}
Note: See TracChangeset for help on using the changeset viewer.