Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 17, 2008, 2:10:11 AM (16 years ago)
Author:
landauf
Message:

merged weapon2 branch to presentation

Location:
code/branches/presentation
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • code/branches/presentation

  • code/branches/presentation/src/orxonox/objects/controllers/AIController.cc

    r2485 r2493  
    5757        float random;
    5858        float maxrand = 100.0f / ACTION_INTERVAL;
    59 /*
     59
    6060        // search enemy
    6161        random = rnd(maxrand);
     
    7272        if (random < 10 && (this->target_))
    7373            this->searchNewTarget();
    74 */
     74
    7575        // fly somewhere
    7676        random = rnd(maxrand);
     
    8787        if (random < 30 && (this->bHasTargetPosition_ && !this->target_))
    8888            this->searchRandomTargetPosition();
    89 /*
     89
    9090        // shoot
    9191        random = rnd(maxrand);
     
    9797        if (random < 25 && (this->bShooting_))
    9898            this->bShooting_ = false;
    99 */
    10099    }
    101100
     
    112111
    113112        if (this->getControllableEntity() && this->bShooting_ && this->isCloseAtTarget(500) && this->isLookingAtTarget(Ogre::Math::PI / 20.0))
    114             this->getControllableEntity()->fire();
     113            this->getControllableEntity()->fire(WeaponMode::fire);
    115114
    116115        SUPER(AIController, tick, dt);
  • code/branches/presentation/src/orxonox/objects/controllers/ArtificialController.cc

    r2485 r2493  
    5656
    5757        Vector2 coord = get2DViewdirection(this->getControllableEntity()->getPosition(), this->getControllableEntity()->getOrientation() * WorldEntity::FRONT, this->getControllableEntity()->getOrientation() * WorldEntity::UP, this->targetPosition_);
     58        float distance = (this->targetPosition_ - this->getControllableEntity()->getPosition()).length();
    5859
    59         float distance = (this->targetPosition_ - this->getControllableEntity()->getPosition()).length();
    60         if (this->target_ || distance > 50)
     60        if (this->target_ || distance > 10)
    6161        {
    6262            // Multiply with 0.8 to make them a bit slower
    63             this->getControllableEntity()->rotateYaw(0.8 * sgn(coord.x) * coord.x*coord.x);
     63            this->getControllableEntity()->rotateYaw(-0.8 * sgn(coord.x) * coord.x*coord.x);
    6464            this->getControllableEntity()->rotatePitch(0.8 * sgn(coord.y) * coord.y*coord.y);
    6565        }
    6666
    67         if (this->target_ && distance < 1000 && this->getControllableEntity()->getVelocity().squaredLength() > this->target_->getVelocity().squaredLength())
     67        if (this->target_ && distance < 200 && this->getControllableEntity()->getVelocity().squaredLength() > this->target_->getVelocity().squaredLength())
    6868            this->getControllableEntity()->moveFrontBack(-0.5); // They don't brake with full power to give the player a chance
    6969        else
     
    7373    void ArtificialController::searchRandomTargetPosition()
    7474    {
    75         this->targetPosition_ = Vector3(rnd(-5000,5000), rnd(-5000,5000), rnd(-5000,5000));
     75        this->targetPosition_ = Vector3(rnd(-2000,2000), rnd(-2000,2000), rnd(-2000,2000));
    7676        this->bHasTargetPosition_ = true;
    7777    }
     
    8888        {
    8989//            if (it->getTeamNr() != this->getTeamNr())
     90            if ((ControllableEntity*)(*it) != this->getControllableEntity())
    9091            {
    9192                float speed = this->getControllableEntity()->getVelocity().length();
     
    113114            return;
    114115
    115         static const float hardcoded_projectile_speed = 500;
     116        static const float hardcoded_projectile_speed = 1250;
    116117
    117         this->targetPosition_ = getPredictedPosition(this->getControllableEntity()->getPosition(), hardcoded_projectile_speed, this->target_->getPosition(), this->target_->getOrientation() * this->target_->getVelocity());
     118        this->targetPosition_ = getPredictedPosition(this->getControllableEntity()->getPosition(), hardcoded_projectile_speed, this->target_->getPosition(), this->target_->getVelocity());
    118119        this->bHasTargetPosition_ = (this->targetPosition_ != Vector3::ZERO);
    119120    }
     
    138139    }
    139140
    140     void ArtificialController::shipDied(Pawn* ship)
     141    void ArtificialController::destroyedPawn(Pawn* ship)
    141142    {
    142143        if (ship == this->target_)
  • code/branches/presentation/src/orxonox/objects/controllers/ArtificialController.h

    r2485 r2493  
    3333
    3434#include "Controller.h"
     35#include "objects/worldentities/pawns/Pawn.h"
    3536#include "util/Math.h"
    3637
    3738namespace orxonox
    3839{
    39     class _OrxonoxExport ArtificialController : public Controller
     40    class _OrxonoxExport ArtificialController : public Controller, public PawnListener
    4041    {
    4142        public:
     
    4344            virtual ~ArtificialController();
    4445
    45             void shipDied(Pawn* ship);
     46            virtual void destroyedPawn(Pawn* pawn);
    4647
    4748        protected:
  • code/branches/presentation/src/orxonox/objects/controllers/HumanController.cc

    r2485 r2493  
    110110    {
    111111        if (HumanController::localController_s && HumanController::localController_s->controllableEntity_)
    112             HumanController::localController_s->controllableEntity_->fire();
     112            HumanController::localController_s->controllableEntity_->fire(WeaponMode::fire);
    113113    }
    114114
     
    116116    {
    117117        if (HumanController::localController_s && HumanController::localController_s->controllableEntity_)
    118             HumanController::localController_s->controllableEntity_->altFire();
     118            HumanController::localController_s->controllableEntity_->fire(WeaponMode::altFire);
    119119    }
    120120
Note: See TracChangeset for help on using the changeset viewer.