Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 16, 2011, 8:36:41 PM (12 years ago)
Author:
jo
Message:

Merged Formation branch. There are still some bugs (just have a look at the tutorial level)

Location:
code/branches/presentation2011
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/branches/presentation2011

  • code/branches/presentation2011/src/orxonox/controllers/ArtificialController.h

    r8980 r8992  
    3131
    3232#include "OrxonoxPrereqs.h"
    33 
    34 #include <map>
    35 
    36 #include "util/Math.h"
    37 #include "Controller.h"
    38 #include "controllers/NewHumanController.h"
    39 #include "weaponsystem/WeaponSystem.h"
     33#include "controllers/FormationController.h"
    4034
    4135namespace orxonox
    4236{
    43     class _OrxonoxExport ArtificialController : public Controller
     37    class _OrxonoxExport ArtificialController : public FormationController
    4438    {
    4539        public:
     
    4741            virtual ~ArtificialController();
    4842
    49             virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
    50 
    5143            void abandonTarget(Pawn* target);
    5244
    53             inline void setTeam(int team) //TODO: write through to controllable entity.
    54                 { this->team_ = team; }
    55             inline int getTeam() const
    56                 { return this->team_; }
    57 
    58             inline void setFormationFlight(bool formation)
    59                 { this->formationFlight_ = formation; }
    60             inline bool getFormationFlight() const
    61                 { return this->formationFlight_; }
    62 
    63             inline void setFormationSize(int size)
    64                 { this->maxFormationSize_ = size; }
    65             inline int getFormationSize() const
    66                 { return this->maxFormationSize_; }
    67 
    68             inline void setPassive(bool passive)
    69                 { this->passive_ = passive; }
    70             inline bool getPassive() const
    71                 { return this->passive_; }
    72 
    7345            virtual void changedControllableEntity();
    74 
    75             static void formationflight(const bool form);
    76             static void masteraction(const int action);
    77             static void followme();
    78             static void passivebehaviour(const bool passive);
    79             static void formationsize(const int size);
    80 
     46//************************************************************************* NEW
    8147            virtual void doFire();
    8248            void setBotLevel(float level=1.0f);
     
    9561            void manageWaypoints();
    9662
     63           
     64
    9765        protected:
    98 
    99             int team_;
    100             bool formationFlight_;
    101             bool passive_;
    102             unsigned int maxFormationSize_;
    103             int freedomCount_;
    104             enum State {SLAVE, MASTER, FREE};
    105             State state_;
    106             std::vector<ArtificialController*> slaves_;
    107             ArtificialController *myMaster_;
    108             enum SpecificMasterAction {NONE, HOLD, SPIN, TURN180, FOLLOW};
    109             SpecificMasterAction specificMasterAction_;
    110             int specificMasterActionHoldCount_;
    111             float speedCounter_; //for speed adjustment when following
    112 
    113             void moveToPosition(const Vector3& target);
    114             void moveToTargetPosition();
    115             void absoluteMoveToPosition(const Vector3& target);
    116 
    117             virtual void positionReached() {}
    118 
    119             void removeFromFormation();
    120             void unregisterSlave();
    121             void searchNewMaster();
    122             void commandSlaves();
    123             void setNewMasterWithinFormation();
    124 
    125             void freeSlaves();
    126             void forceFreeSlaves();
    127             void loseMasterState();
    128             void forceFreedom();
    129             bool forcedFree();
    130 
    131             void specificMasterActionHold();
    132             void turn180Init();
    133             void turn180();
    134             void spinInit();
    135             void spin();
    136             void followInit(Pawn* pawn, const bool always = false, const int secondsToFollow = 100);
    137             void followRandomHumanInit();
    138             void follow();
    139             void followForSlaves(const Vector3& target);
    140 
    141             void setTargetPosition(const Vector3& target);
    142             void searchRandomTargetPosition();
    143 
    144             void setTarget(Pawn* target);
    145             void searchNewTarget();
    146             void forgetTarget();
     66           
    14767            void aimAtTarget();
    14868
    14969            bool isCloseAtTarget(float distance) const;
    15070            bool isLookingAtTarget(float angle) const;
    151 
    152             void targetDied();
    153 
    154             static bool sameTeam(ControllableEntity* entity1, ControllableEntity* entity2, Gametype* gametype); // hack
    155             void boostControl(); //<! Sets and resets the boost parameter of the spaceship. Bots alternate between boosting and saving boost.
    156 
    157             bool bHasTargetPosition_;
    158             Vector3 targetPosition_;
    159             WeakPtr<Pawn> target_;
    160             bool bShooting_;
    161 
     71//************************************************************************* NEW
    16272            float botlevel_; //<! Makes the level of a bot configurable.
    16373            enum Mode {DEFAULT, ROCKET, DEFENCE, MOVING};//TODO; implement DEFENCE, MOVING modes
     
    16575            void setPreviousMode();
    16676
     77
    16778            //WEAPONSYSTEM DATA
    168             std::map<std::string, int> weaponModes_; //<! Links each "weapon" to it's weaponmode- managed by setupWeapons()
     79            std::map<std::string, int> weaponModes_; //<! Links each "weapon" to it's weaponmode - managed by setupWeapons()
    16980            //std::vector<int> projectiles_; //<! Displays amount of projectiles of each weapon. - managed by setupWeapons()
    17081            float timeout_; //<! Timeout for rocket usage. (If a rocket misses, a bot should stop using it.)
     
    17384            int getFiremode(std::string name);
    17485
     86
    17587            //WAYPOINT DATA
    17688            std::vector<WeakPtr<WorldEntity> > waypoints_;
     
    17890            float squaredaccuracy_;
    17991            WorldEntity* defaultWaypoint_;
     92
     93            void boostControl(); //<! Sets and resets the boost parameter of the spaceship. Bots alternate between boosting and saving boost.
     94
     95        private:
    18096    };
    18197}
Note: See TracChangeset for help on using the changeset viewer.