Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Apr 23, 2015, 4:19:02 PM (9 years ago)
Author:
meggiman
Message:

Implemented all necessary classes. No the weapon works without bugs.

Location:
code/branches/weaponFS15/src/modules/weapons
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • code/branches/weaponFS15/src/modules/weapons/projectiles/GravityBomb.cc

    r10369 r10391  
    1919                        RegisterObject(GravityBomb);
    2020
    21                         this->setMass(15.0);
     21                        this->setMass(10.0);
     22                        this->isDetonated_ = false;
    2223                        if (GameMode::isMaster())
    2324                        {
    2425                                //Define CollisionType of the bomb
    25                                 this->velocityAtLastTick_= 1000;
     26                                this->timeToLife_= 5;
    2627                                this->setCollisionResponse(false);
    27                                 this->setCollisionType(WorldEntity::Kinematic);
     28                                this->setCollisionType(WorldEntity::Dynamic);
    2829                                this->enableCollisionCallback();
    2930
     
    4647        void GravityBomb::tick(float dt)
    4748        {
    48                         velocityAtLastTick_=getVelocity().length();
    4949                        SUPER(GravityBomb,tick,dt);
    50                         if(velocityAtLastTick_ < this->getVelocity().length())
     50                        timeToLife_ -= dt;
     51                        if(timeToLife_ < 0)
    5152                        {
    5253                                orxout(debug_output) << "bomb has stoped moving" <<endl;
    5354                                setVelocity(Vector3::ZERO);
    5455                                setAcceleration(Vector3::ZERO);
    55                                 velocityAtLastTick_=0;
    5656                                detonate();
    57                                 orxout(debug_output) << "denoting" <<endl;
    5857                        }
    5958                        else
    6059                        {
    61                                 velocityAtLastTick_=getVelocity().length();
    62                                 orxout(debug_output)<< velocityAtLastTick_ <<endl;
    63                                 orxout(debug_output) << "acceleration" << getAcceleration().length() <<endl;
     60                                orxout(debug_output)<< "Time to live:" << timeToLife_ <<endl;
    6461                                destroyCheck();
    6562                        }
     63                        if(isDetonated_) detonate();
    6664        }
    6765
    6866        bool GravityBomb::collidesAgainst(WorldEntity* otherObject, const btCollisionShape* cs, btManifoldPoint& contactPoint)
    6967        {
    70                 orxout(debug_output) << "collides" << endl;
    71                 processCollision(otherObject, contactPoint,cs);
    72                 //detonate();
    73                 return true;
     68                if(otherObject != getShooter())
     69                {
     70                        orxout(debug_output) << "collides" << endl;
     71                        processCollision(otherObject, contactPoint,cs);
     72                        isDetonated_ = true;
     73                        return true;
     74                }
     75                else{
     76                        orxout(debug_output) << "collided with shooter. Has no effect..." << endl;
     77                        return false;
     78                }
    7479        }
    7580
     
    7782        {
    7883                GravityBombField* field = new GravityBombField(this->getContext());
    79                 orxout(debug_output) << "denoting" <<endl;
     84                field->setPosition(getPosition());
     85                orxout(debug_output) << "detonating. Creating GravityBombField." <<endl;
     86                orxout(debug_output) << "Field is at Position: " << getPosition() << endl;
    8087                this->destroy();
    8188        }
  • code/branches/weaponFS15/src/modules/weapons/projectiles/GravityBomb.h

    r10369 r10391  
    6464                        virtual bool collidesAgainst(WorldEntity* otherObject, const btCollisionShape* cs, btManifoldPoint& contactPoint);
    6565                        void detonate();
    66 
    6766                private:
    68 
    69                 float velocityAtLastTick_; //Used to check wether the Object is already accelarating in the oposite direction to detect the time to detonate it.
     67                bool isDetonated_; //Used to check whether the Bomb has to be destroyed during next tick.
     68                float timeToLife_; //Time the bomb flies before it explodes.
    7069
    7170        };
  • code/branches/weaponFS15/src/modules/weapons/projectiles/GravityBombField.cc

    r10369 r10391  
    77
    88#include "GravityBombField.h"
     9#include "graphics/Model.h"
    910
    1011namespace orxonox{
    1112        RegisterClass(GravityBombField);
    1213
    13         const float GravityBombField::FORCE_FIELD_LIFETIME = 5;
    14         const float GravityBombField::FORCE_SPHERE_START_RADIUS = 100;
    15         const float GravityBombField::FORCE_SPHERE_START_STRENGTH = -1000;
     14        const float GravityBombField::FORCE_FIELD_LIFETIME = 100;
     15        const float GravityBombField::FORCE_SPHERE_START_RADIUS = 500;
     16        const float GravityBombField::FORCE_SPHERE_START_STRENGTH = -500;
    1617
    1718        GravityBombField::GravityBombField(Context* context) : ForceField(context)
     
    2223                setDiameter(FORCE_SPHERE_START_RADIUS);
    2324                setMode(modeInvertedSphere_s);
     25                setCollisionResponse(false);
     26
     27                //Attach Demo Model for debuging.
     28                        Model* model = new Model(this->getContext());
     29                        model->setMeshSource("rocket.mesh"); //Demo Model from SimpleRocket
     30                        model->scale(0.7f);
     31                        this->attach(model);
    2432        }
    2533
     
    3240                if(lifetime_ < 0)
    3341                {
     42                        orxout(debug_output) << "Timeout. Destroying field." << endl;
    3443                        this->destroy();
    3544                }
  • code/branches/weaponFS15/src/modules/weapons/projectiles/LightningGunProjectile.cc

    r9667 r10391  
    4747
    4848        this->textureIndex_ = 1;
     49        this->setMass(2);
     50        this->setCollisionType(Dynamic);
    4951        this->maxTextureIndex_ = 8;
    5052        this->textureTimer_.setTimer(0.01f, true, createExecutor(createFunctor(&LightningGunProjectile::changeTexture, this)));
  • code/branches/weaponFS15/src/modules/weapons/weaponmodes/GravityBombFire.cc

    r10369 r10391  
    2626                this->bParallelReload_ = false;
    2727                this->damage_ = 0.0f;
    28                 this->speed_ = 200.0f;
    29                 this->slowDownRate_ = -10.0f;
     28                this->speed_ = 100.0f;
    3029
    3130                this->setMunitionName("GravityBombMunition");
     
    4140        bomb->setOrientation(this->getMuzzleOrientation());
    4241        bomb->setPosition(this->getMuzzlePosition());
    43         bomb->setVelocity(this->getMuzzleDirection() * this->speed_);
    44         bomb->setAcceleration(this->getMuzzleDirection()* this->slowDownRate_);
     42        bomb->setVelocity(this->getMuzzleDirection() * (this->speed_+this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn()->getVelocity().length()));
    4543
    4644        bomb->setShooter(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn());
  • code/branches/weaponFS15/src/modules/weapons/weaponmodes/GravityBombFire.h

    r10369 r10391  
    5858        private:
    5959            float speed_; //!< The initial speed of the bomb when it is launched.
    60             float slowDownRate_;
    6160    };
    6261}
Note: See TracChangeset for help on using the changeset viewer.