Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 6891 for code/branches


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

DroneController modified, sameTeam() mod. hack

Location:
code/branches/ai
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • code/branches/ai/data/levels/pickup.oxw

    r6782 r6891  
    2424
    2525    <Template name=droneTemplate>
    26         <Drone name="meineDrohne" primarythrust="80" auxilarythrust="10" rotationthrust="10" mass= "50" linearDamping = "0.9" angularDamping = "0.7">
     26        <Drone name="meineDrohne" mass= "50" linearDamping = "0.9" angularDamping = "0.7">
    2727        <attached>
    28             <Model scale="10" mesh="drone.mesh"/>
     28            <Model scale="1" mesh="drone.mesh"/>
    2929        </attached>
    3030        <collisionShapes>
    31             <BoxCollisionShape position="0,0,0"      halfExtents="10, 10, 10" />
     31            <BoxCollisionShape position="0,0,0"      halfExtents="1, 1, 1" />
    3232        </collisionShapes>
    3333   
  • code/branches/ai/src/modules/pickup/items/DronePickup.cc

    r6847 r6891  
    134134               
    135135                //Attach to pawn
    136                 Drone* drone = new Drone(this);
     136                Drone* drone = new Drone(pawn->getCreator()); // this is neccessary because the projectiles fired need a valid creator for the particlespawner (when colliding against something)
    137137                drone->addTemplate(this->getDroneTemplate());
    138                 pawn->attach(drone);
     138
    139139                Controller* controller = drone->getController();
    140140                DroneController* droneController = dynamic_cast<DroneController*>(controller);
     
    143143                    droneController->setOwner(pawn);
    144144                }
    145 
     145               
     146                Vector3 spawnPosition = pawn->getWorldPosition() + Vector3(30,0,-30);
     147                drone->setPosition(spawnPosition);
     148               
    146149                //! The pickup has been used up.
    147150                this->setUsed(false);
  • code/branches/ai/src/orxonox/controllers/AIController.cc

    r6888 r6891  
    102102                this->searchRandomTargetPosition();
    103103
    104 
     104/*
    105105            random = rnd(maxrand);
    106106            if (random < 75 && (this->target_ && !this->bShooting_))
     
    110110            random = rnd(maxrand);
    111111            if (random < 25 && (this->bShooting_))
    112                 this->bShooting_ = false;
     112                this->bShooting_ = false; */
    113113
    114114        }
  • code/branches/ai/src/orxonox/controllers/ArtificialController.cc

    r6888 r6891  
    501501        }
    502502
     503        DroneController* droneController = 0;
     504        droneController = orxonox_cast<DroneController*>(entity1->getController());
     505        if (droneController && static_cast<ControllableEntity*>(droneController->getOwner()) == entity2)
     506            return true;
     507        droneController = orxonox_cast<DroneController*>(entity2->getController());
     508        if (droneController && static_cast<ControllableEntity*>(droneController->getOwner()) == entity1)
     509            return true;
     510           
    503511        return (team1 == team2 && team1 != -1);
    504512    }
  • 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}
  • code/branches/ai/src/orxonox/controllers/DroneController.h

    r6847 r6891  
    3333
    3434#include "AIController.h"
     35#include "core/WeakPtr.h"
    3536#include "tools/interfaces/Tickable.h"
    3637
     
    6465        protected:
    6566            virtual void action();
     67            void ownerDied();
    6668
    6769        private:
    6870            Timer actionTimer_;
    69             Pawn* owner_;
     71            WeakPtr<Pawn> owner_;
    7072            Drone* drone_;
    7173    };
Note: See TracChangeset for help on using the changeset viewer.