Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 6295


Ignore:
Timestamp:
Dec 9, 2009, 4:54:20 PM (15 years ago)
Author:
wirthmi
Message:

Changed a function call when hit from damage() to hit(). Pass through to controller

Location:
code/branches/presentation2/src
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • code/branches/presentation2/src/modules/weapons/projectiles/Projectile.cc

    r6277 r6295  
    129129            Pawn* victim = orxonox_cast<Pawn*>(otherObject);
    130130            if (victim)
    131                 victim->damage(dmg, this->owner_);
     131                victim->hit(this->owner_, contactPoint, dmg);
    132132        }
    133133        return false;
  • code/branches/presentation2/src/modules/weapons/projectiles/Rocket.cc

    r6285 r6295  
    203203            Pawn* victim = orxonox_cast<Pawn*>(otherObject);
    204204            if (victim)
    205                 victim->damage(dmg, this->owner_);
     205                victim->hit(this->owner_, contactPoint, dmg);
    206206//             this->destroy();
    207207        }
  • code/branches/presentation2/src/orxonox/controllers/Controller.h

    r6195 r6295  
    5050                { return this->player_; }
    5151
     52            virtual inline void hit(Pawn* originator, btManifoldPoint& contactpoint, float damage) {};
     53
    5254            inline ControllableEntity* getControllableEntity() const
    5355                { return this->controllableEntity_; }
  • code/branches/presentation2/src/orxonox/controllers/NewHumanController.cc

    r6289 r6295  
    4444#include "sound/SoundManager.h"
    4545#include "Scene.h"
     46#include "tools/BulletConversions.h"
     47#include "bullet/BulletCollision/NarrowPhaseCollision/btManifoldPoint.h"
    4648
    4749namespace orxonox
     
    246248            HumanController::localController_s->getControllableEntity()->fire(firemode);
    247249
     250    }
     251
     252    void NewHumanController::hit(Pawn* originator, btManifoldPoint& contactpoint, float damage) {
     253        Vector3 posA = multi_cast<Vector3>(contactpoint.getPositionWorldOnA());
     254        //Vector3 posB = multi_cast<Vector3>(contactpoint.getPositionWorldOnB());
     255        //posA and posB are almost identical
     256
     257        Vector3 relativeHit = this->getControllableEntity()->getWorldOrientation() * (posA - this->getControllableEntity()->getPosition());
     258
     259        COUT(0) << relativeHit << endl;
     260        //COUT(0) << "Damage: " << damage << " Point A: " << posA << " Point B: " << posB << endl;
    248261    }
    249262
  • code/branches/presentation2/src/orxonox/controllers/NewHumanController.h

    r6236 r6295  
    5656            virtual void doFire(unsigned int firemode);
    5757
     58            virtual void hit(Pawn* originator, btManifoldPoint& contactpoint, float damage);
     59
    5860            static void unfire();
    5961            virtual void doUnfire();
  • code/branches/presentation2/src/orxonox/worldentities/MovableEntity.cc

    r5929 r6295  
    7979            if (victim)
    8080            {
    81                 victim->damage(this->collisionDamage_ * (victim->getVelocity() - this->getVelocity()).length());
     81                float damage = this->collisionDamage_ * (victim->getVelocity() - this->getVelocity()).length();
     82                victim->hit(0, contactPoint, damage);
    8283            }
    8384        }
  • code/branches/presentation2/src/orxonox/worldentities/pawns/Pawn.cc

    r6112 r6295  
    3838#include "PawnManager.h"
    3939#include "infos/PlayerInfo.h"
     40#include "controllers/Controller.h"
    4041#include "gametypes/Gametype.h"
    4142#include "graphics/ParticleSpawner.h"
     
    176177    }
    177178
     179    void Pawn::hit(Pawn* originator, btManifoldPoint& contactpoint, float damage)
     180    {
     181        if (this->getGametype() && this->getGametype()->allowPawnHit(this, originator))
     182        {
     183            this->damage(damage, originator);
     184
     185            if ( this->getController() )
     186                this->getController()->hit(originator, contactpoint, damage);
     187
     188            // play hit effect
     189        }
     190    }
     191
    178192    void Pawn::kill()
    179193    {
  • code/branches/presentation2/src/orxonox/worldentities/pawns/Pawn.h

    r6111 r6295  
    7575                { return this->lastHitOriginator_; }
    7676
    77             virtual void damage(float damage, Pawn* originator = 0);
    7877            virtual void hit(Pawn* originator, const Vector3& force, float damage);
     78            virtual void hit(Pawn* originator, btManifoldPoint& contactpoint, float damage);
    7979            virtual void kill();
    8080
     
    131131            virtual void spawneffect();
    132132
     133            virtual void damage(float damage, Pawn* originator = 0);
     134
    133135            bool bAlive_;
    134136
Note: See TracChangeset for help on using the changeset viewer.