Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 2494


Ignore:
Timestamp:
Dec 17, 2008, 3:20:25 AM (15 years ago)
Author:
landauf
Message:

shooting, hitting and killing works

Location:
code/branches/presentation/src/orxonox/objects
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • code/branches/presentation/src/orxonox/objects/gametypes/Gametype.cc

    r2492 r2494  
    169169    void Gametype::pawnKilled(Pawn* victim, Pawn* killer)
    170170    {
     171        if (victim && victim->getPlayer())
     172        {
     173            std::string message;
     174            if (killer)
     175            {
     176                if (killer->getPlayer())
     177                    message = victim->getPlayer()->getName() + " was killed by " + killer->getPlayer()->getName();
     178                else
     179                    message = victim->getPlayer()->getName() + " was killed";
     180            }
     181            else
     182                message = victim->getPlayer()->getName() + " died";
     183
     184            COUT(0) << message << std::endl;
     185            Host::Broadcast(message);
     186        }
     187
    171188        if (victim && victim->getPlayer())
    172189        {
  • code/branches/presentation/src/orxonox/objects/weaponSystem/projectiles/Projectile.cc

    r2493 r2494  
    4040#include "objects/worldentities/Model.h"
    4141#include "objects/worldentities/ParticleSpawner.h"
     42#include "objects/worldentities/pawns/Pawn.h"
     43#include "objects/collisionshapes/SphereCollisionShape.h"
    4244#include "core/Core.h"
    4345
     
    4951
    5052        this->setConfigValues();
    51         this->explosionTemplateName_ = "Orxonox/explosion3";
    52         this->smokeTemplateName_ = "Orxonox/smoke4";
    53 
    54         //this->setStatic(false);
    55 //        this->translate(Vector3(55, 0, 0), Ogre::Node::TS_LOCAL);
     53        this->bDestroy_ = false;
     54        this->owner_ = 0;
    5655
    5756        // Get notification about collisions
    5857        this->enableCollisionCallback();
    5958
    60         /*
    61         if (this->owner_)
    62         {
    63             this->setOrientation(this->owner_->getOrientation());
    64             this->setPosition(this->owner_->getPosition());
    65             this->setVelocity(this->owner_->getInitialDir() * this->speed_);
    66         }
    67         */
     59        this->setCollisionType(Kinematic);
     60
     61        SphereCollisionShape* shape = new SphereCollisionShape(this);
     62        shape->setRadius(10);
     63        this->attachCollisionShape(shape);
    6864
    6965        if(!Core::isClient()) //only if not on client
     
    8884        if (!this->isActive())
    8985            return;
    90 /*
    91         float radius;
    92         for (ObjectList<Model>::iterator it = ObjectList<Model>::begin(); it; ++it)
    93         {
    94 //            if ((*it) != this->owner_)
    95             {
    96                 radius = it->getScale3D().x * 3.0;
    9786
    98                 if (this->getPosition().squaredDistance(it->getPosition()) <= (radius*radius))
    99                 {
    100                     // hit
    101                     ParticleSpawner* explosion = new ParticleSpawner(this);
    102                     explosion->setSource(this->explosionTemplateName_);
    103                     explosion->setLOD(LODParticle::low);
    104                     explosion->configure(2.0);
    105                     explosion->setPosition(this->getPosition());
    106                     explosion->create();
    107                     ParticleSpawner* smoke = new ParticleSpawner(this);
    108                     smoke->setSource(this->smokeTemplateName_);
    109                     smoke->setLOD(LODParticle::normal);
    110                     smoke->configure(2.0, 0.0);
    111                     smoke->setPosition(this->getPosition());
    112 //                    smoke->getParticleInterface()->setSpeedFactor(3.0);
    113                     smoke->create();
    114                     delete this;
    115                     return;
    116                 }
    117             }
    118         }
    119 */
     87        if (this->bDestroy_)
     88            delete this;
    12089    }
    12190
     
    12493        delete this;
    12594    }
     95
     96    bool Projectile::collidesAgainst(WorldEntity* otherObject, btManifoldPoint& contactPoint)
     97    {
     98        if (!this->bDestroy_)
     99        {
     100            this->bDestroy_ = true;
     101            Pawn* victim = dynamic_cast<Pawn*>(otherObject);
     102            if (victim)
     103                victim->damage(this->damage_, this->owner_);
     104
     105
     106            if (this->owner_)
     107            {
     108                {
     109                    ParticleSpawner* effect = new ParticleSpawner(this->owner_->getCreator());
     110                    effect->setPosition(this->getPosition());
     111                    effect->setOrientation(this->getOrientation());
     112                    effect->setDestroyAfterLife(true);
     113                    effect->setSource("Orxonox/explosion3");
     114                    effect->setLifetime(2.0f);
     115                }
     116                {
     117                    ParticleSpawner* effect = new ParticleSpawner(this->owner_->getCreator());
     118                    effect->setPosition(this->getPosition());
     119                    effect->setOrientation(this->getOrientation());
     120                    effect->setDestroyAfterLife(true);
     121                    effect->setSource("Orxonox/smoke4");
     122                    effect->setLifetime(3.0f);
     123                }
     124            }
     125        }
     126        return false;
     127    }
    126128}
  • code/branches/presentation/src/orxonox/objects/weaponSystem/projectiles/Projectile.h

    r2493 r2494  
    4040    {
    4141        public:
     42            Projectile(BaseObject* creator);
    4243            virtual ~Projectile();
     44
    4345            void setConfigValues();
    4446            void destroyObject();
     47
    4548            virtual void tick(float dt);
     49            virtual bool collidesAgainst(WorldEntity* otherObject, btManifoldPoint& contactPoint);
    4650
    47         protected:
    48             Projectile(BaseObject* creator);
     51            inline void setOwner(Pawn* owner)
     52                { this->owner_ = owner; }
     53            inline Pawn* getOwner() const
     54                { return this->owner_; }
    4955
    5056        private:
    51             std::string explosionTemplateName_;
    52             std::string smokeTemplateName_;
    53         protected:
    54             float speed_;
    55         private:
     57            Pawn* owner_;
    5658            float lifetime_;
    5759            float damage_;
     60            bool bDestroy_;
    5861            Timer<Projectile> destroyTimer_;
    5962    };
  • code/branches/presentation/src/orxonox/objects/weaponSystem/weapons/Fusion.cc

    r2493 r2494  
    7373        projectile->setPosition(this->getWorldPosition());
    7474        projectile->setVelocity(this->getWorldOrientation() * WorldEntity::FRONT * this->speed_);
     75        projectile->setOwner(this->getParentWeaponSystem()->getParentPawn());
    7576    }
    7677}
  • code/branches/presentation/src/orxonox/objects/weaponSystem/weapons/LaserGun.cc

    r2493 r2494  
    7373        projectile->setPosition(this->getWorldPosition());
    7474        projectile->setVelocity(this->getWorldOrientation() * WorldEntity::FRONT * this->speed_);
     75        projectile->setOwner(this->getParentWeaponSystem()->getParentPawn());
    7576    }
    7677}
  • code/branches/presentation/src/orxonox/objects/worldentities/WorldEntity.cc

    r2485 r2494  
    498498    void WorldEntity::setScale3D(const Vector3& scale)
    499499    {
     500/*
    500501        if (this->hasPhysics() && scale != Vector3::UNIT_SCALE)
    501502        {
     
    503504            return;
    504505        }
    505 
     506*/
    506507        this->node_->setScale(scale);
    507508
Note: See TracChangeset for help on using the changeset viewer.