Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 10, 2010, 4:40:44 PM (14 years ago)
Author:
gasserlu
Message:

DroneController modified, sameTeam() mod. hack

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/ai/src/orxonox/controllers/DroneController.cc

    r6847 r6891  
    5959
    6060        this->actionTimer_.setTimer(ACTION_INTERVAL, true, createExecutor(createFunctor(&DroneController::action, this)));
     61
     62        this->owner_.setCallback(createFunctor(&DroneController::ownerDied, this));
    6163    }
    6264
     
    8385        const Vector3& dronePosition = getDrone()->getWorldPosition();
    8486
    85         const Vector3& locOwnerDir = getDrone()->getOrientation().UnitInverse()*(dronePosition-ownerPosition); //Vector from Drone To Owner out of drones local coordinate system
     87        const Vector3& locOwnerDir = getDrone()->getOrientation().UnitInverse()*(ownerPosition-dronePosition); //Vector from Drone To Owner out of drones local coordinate system
    8688
    8789        int distance = sqrt( (ownerPosition.x-dronePosition.x)*(ownerPosition.x-dronePosition.x)
     
    9092
    9193        if (distance > 500) { //TODO: variable implementation of maxdistance
    92             drone_->moveUpDown(-locOwnerDir.y);
    93             drone_->moveFrontBack(locOwnerDir.z);
    94             drone_->moveRightLeft(-locOwnerDir.x);
     94            drone_->moveUpDown(locOwnerDir.y);
     95            drone_->moveFrontBack(-locOwnerDir.z);
     96            drone_->moveRightLeft(locOwnerDir.x);
    9597        }
    9698
     99
     100        random = rnd(maxrand);
     101        if ( random < 30 && (!this->target_))
     102            this->searchNewTarget();
     103
     104
     105        this->aimAtTarget();
     106        drone_->fire(0);
     107         
     108
     109
     110
     111        //COUT(0) << "Drone: " << dronePosition << endl;
     112        //COUT(0) << "Distance: " << distance << endl;
     113        COUT(0) << "locDrone: " << locOwnerDir << endl;
     114        COUT(0) << "target: " << targetPosition_ << endl;
    97115        COUT(0) << "Owner: " << ownerPosition << endl;
    98         COUT(0) << "Drone: " << dronePosition << endl;
    99         COUT(0) << "Distance: " << distance << endl;
    100         COUT(0) << "locDrone: " << locOwnerDir << endl;
    101 
     116        COUT(0) << "Rand: " << random << endl;
    102117
    103118/*
     
    160175        setTargetPosition(this->getControllableEntity()->getPosition());
    161176
    162 /*      myDrone->setRotationThrust(25);
    163         myDrone->setAuxilaryThrust(30);
    164         myDrone->rotateYaw(10*dt); */
    165177        }
    166178
    167179        SUPER(AIController, tick, dt);
    168180
    169         // you can use the following commands for steering
    170         // - moveFrontBack, moveRightLeft, moveUpDown
    171         // - rotatePitch, rotateYaw, rotateRoll
    172         // - apply the to myDrone (e.g. myDrone->rotateYaw(..) )
     181    }
    173182
     183    void DroneController::ownerDied()
     184    {
     185        if (this->drone_)
     186            this->drone_->destroy();
     187        else
     188            this->destroy();
    174189    }
    175190}
Note: See TracChangeset for help on using the changeset viewer.