Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 10682 for code/branches


Ignore:
Timestamp:
Oct 23, 2015, 2:18:32 PM (9 years ago)
Author:
gania
Message:

Set a layout for WingmanController and LeaderController

Location:
code/branches/AI_HS15/src/orxonox/controllers
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • code/branches/AI_HS15/src/orxonox/controllers/LeaderController.cc

    r10681 r10682  
    5151       
    5252    }
     53    /*
     54    Wingmen and Leaders attack target_, which is a member variable of their classes.
     55    Wingmen's target_ is set to sectionTarget_, which is a member variable of SectionController class, unless
     56    Wingman covers Leader's rear.
     57    Leader's target_ must always equal sectionTarget_.
     58    if section has a target, its Leader shoots at it, but doesn't follow.
     59    Every section is a part of division. Division consisting of one Section is still a division.
     60    Division's leader's target_ must always equal divisionTarget_, which is a member variable of DivisionController.
     61    Division leader ONLY can follow target_ while in formation flight.
     62    If Division doesn't have a target, Division Leader stays in place, unless it has a waypoint.
     63    Division Leader's sectionTarget_ must equal divisionTarget_,
     64    but the other section, that is not a leading section, can attack any target that is near divisonTarget_
    5365
     66    */
    5467    void LeaderController::tick(float dt)
    5568    {
     69        if (!this->isActive())
     70            return;
     71       
     72        //--------------------------Stay in division--------------------------
     73        this->keepDivisionTick();
     74        /*keepDivisionTick(){
     75            if (this->divisionLeader_ && this->divisionLeader_->getControllableEntity() && desiredRelativePosition_){
     76                Vector3 desiredAbsolutePosition = ((this->divisionLeader_->getControllableEntity()->getWorldPosition()) +
     77                    (this->divisionLeader_->getControllableEntity()->getWorldOrientation()* (*desiredRelativePosition_)));
     78                this->moveToPosition (desiredAbsolutePosition);
     79            }
     80        }
     81        */
     82        //If ordered to attack -> follow target and shoot
     83        if (this->bAttackOrder_)
     84        {
    5685
    57      
     86        }
     87        //If ordered to move -> move to a target Point
     88        else if (this->bMoveOrder_)
     89        {
     90
     91        }
     92        else
     93        //No orders -> Don't move, but shoot at whatever is close, unless Boss is shooting at it.
     94        //(Section shoots same target, Boss's section shoots another target)
     95        {
     96
     97        }
     98
     99
    58100        SUPER(LeaderController, tick, dt);
    59101    }
  • code/branches/AI_HS15/src/orxonox/controllers/LeaderController.h

    r10681 r10682  
    4646        protected:
    4747           
    48             virtual void action(); //<! action() is called in regular intervals managing the bot's behaviour ~ setting targets.
    49             //void defaultBehaviour(float maxrand); //<! Helper function for code reusage. Some concrete commands for a bot.
    50 
    51 
    52            
    53                
    5448            enum Mode {KEEPFORMATION, ROCKET, KILLENEMY};
    5549            Mode mode_;
     50
     51            virtual void action(); //<! action() is called in regular intervals managing the bot's behaviour ~ setting targets.
     52            //void defaultBehaviour(float maxrand); //<! Helper function for code reusage. Some concrete commands for a bot.   
     53           
    5654
    5755            //WEAPONSYSTEM DATA
  • code/branches/AI_HS15/src/orxonox/controllers/WingmanController.cc

    r10681 r10682  
    5555    void WingmanController::action()
    5656    {
    57        
     57        //--------------------------Cover Leader's rear--------------------------
     58        //check for enemies in Leader's rear that can attack him and if they are visible, meaning there are no other Leader's between Leader and enemies.
     59        //if there are enemies, set target_ to the nearest one and set bFollowLeader_ to false,
     60        //otherwise set bFollowLeader_ to true and target_ to sectionTarget_
     61        this->coverAllyRear(this->sectionLeader_);
    5862    }
    5963
    6064    void WingmanController::tick(float dt)
    6165    {
     66        if (!this->isActive())
     67            return;
     68        //--------------------------Stay in formation--------------------------
     69        if (bFollowLeader_)
     70        {
     71            this->keepSectionTick();
     72            /*keepSectionTick(){
     73                if (this->sectionLeader_ && this->sectionLeader_->getControllableEntity() && desiredRelativePosition_){
     74                    Vector3 desiredAbsolutePosition = ((this->sectionLeader_->getControllableEntity()->getWorldPosition()) +
     75                        (this->sectionLeader_->getControllableEntity()->getWorldOrientation()* (*desiredRelativePosition_)));
     76                    this->moveToPosition (desiredAbsolutePosition);
     77                }
     78            }
     79            */
     80           
     81            //--------------------------Attack same target as the Leader--------------------------
     82           
     83            if (this->target_)
     84            {
     85                this->aimAtTarget();
     86                this->doFire();
     87            }
     88        }
     89        //--------------------------Protect Leader by killing target_--------------------------
    6290
    63      
     91        else
     92        {
     93            if (this->target_)
     94            {
     95                //--------------------------Don't attack if not visible--------------------------               
     96                if (!this->target_->getRadarVisibility()) /* So AI won't shoot invisible Spaceships */
     97                {
     98                    this->forgetTarget();
     99                    //this->bFollowLeader_ = true;
     100                }
     101                //--------------------------Otherwise destroy it--------------------------
     102                else
     103                {
     104                    this->aimAtTarget();
     105                    this->follow();  //If a bot is shooting a player, it shouldn't let him go away easily.
     106                }
     107                if (this->bHasTargetPosition_)
     108                {
     109                    this->moveToTargetPosition();
     110                }
     111                this->doFire();
     112            }
     113            //--------------------------no target? do nothing until next action() -> either new target appears or bFollowLeader_ set to true--------------------------
     114            else
     115            {
     116
     117            }           
     118
     119        }
    64120        SUPER(WingmanController, tick, dt);
    65121    }
Note: See TracChangeset for help on using the changeset viewer.