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.

File:
1 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        }
Note: See TracChangeset for help on using the changeset viewer.