[Orxonox-commit 6023] r10682 - code/branches/AI_HS15/src/orxonox/controllers

gania at orxonox.net gania at orxonox.net
Fri Oct 23 14:18:32 CEST 2015


Author: gania
Date: 2015-10-23 14:18:32 +0200 (Fri, 23 Oct 2015)
New Revision: 10682

Modified:
   code/branches/AI_HS15/src/orxonox/controllers/LeaderController.cc
   code/branches/AI_HS15/src/orxonox/controllers/LeaderController.h
   code/branches/AI_HS15/src/orxonox/controllers/WingmanController.cc
Log:
Set a layout for WingmanController and LeaderController

Modified: code/branches/AI_HS15/src/orxonox/controllers/LeaderController.cc
===================================================================
--- code/branches/AI_HS15/src/orxonox/controllers/LeaderController.cc	2015-10-23 05:44:20 UTC (rev 10681)
+++ code/branches/AI_HS15/src/orxonox/controllers/LeaderController.cc	2015-10-23 12:18:32 UTC (rev 10682)
@@ -50,11 +50,53 @@
     {
         
     }
+    /*
+    Wingmen and Leaders attack target_, which is a member variable of their classes.
+    Wingmen's target_ is set to sectionTarget_, which is a member variable of SectionController class, unless
+    Wingman covers Leader's rear.
+    Leader's target_ must always equal sectionTarget_.
+    if section has a target, its Leader shoots at it, but doesn't follow.
+    Every section is a part of division. Division consisting of one Section is still a division.
+    Division's leader's target_ must always equal divisionTarget_, which is a member variable of DivisionController.
+    Division leader ONLY can follow target_ while in formation flight.
+    If Division doesn't have a target, Division Leader stays in place, unless it has a waypoint.
+    Division Leader's sectionTarget_ must equal divisionTarget_,
+    but the other section, that is not a leading section, can attack any target that is near divisonTarget_
 
+    */
     void LeaderController::tick(float dt)
     {
+        if (!this->isActive())
+            return;
+        
+        //--------------------------Stay in division--------------------------
+        this->keepDivisionTick();
+        /*keepDivisionTick(){
+            if (this->divisionLeader_ && this->divisionLeader_->getControllableEntity() && desiredRelativePosition_){
+                Vector3 desiredAbsolutePosition = ((this->divisionLeader_->getControllableEntity()->getWorldPosition()) + 
+                    (this->divisionLeader_->getControllableEntity()->getWorldOrientation()* (*desiredRelativePosition_)));
+                this->moveToPosition (desiredAbsolutePosition);
+            }
+        }
+        */
+        //If ordered to attack -> follow target and shoot
+        if (this->bAttackOrder_)
+        {
 
-      
+        } 
+        //If ordered to move -> move to a target Point
+        else if (this->bMoveOrder_)
+        {
+
+        } 
+        else
+        //No orders -> Don't move, but shoot at whatever is close, unless Boss is shooting at it. 
+        //(Section shoots same target, Boss's section shoots another target) 
+        {
+
+        }
+
+
         SUPER(LeaderController, tick, dt);
     }
 //**********************************************NEW

Modified: code/branches/AI_HS15/src/orxonox/controllers/LeaderController.h
===================================================================
--- code/branches/AI_HS15/src/orxonox/controllers/LeaderController.h	2015-10-23 05:44:20 UTC (rev 10681)
+++ code/branches/AI_HS15/src/orxonox/controllers/LeaderController.h	2015-10-23 12:18:32 UTC (rev 10682)
@@ -45,15 +45,13 @@
 
         protected:
            
-            virtual void action(); //<! action() is called in regular intervals managing the bot's behaviour ~ setting targets.
-            //void defaultBehaviour(float maxrand); //<! Helper function for code reusage. Some concrete commands for a bot.
-
-
-            
-                
             enum Mode {KEEPFORMATION, ROCKET, KILLENEMY};
             Mode mode_;
 
+            virtual void action(); //<! action() is called in regular intervals managing the bot's behaviour ~ setting targets.
+            //void defaultBehaviour(float maxrand); //<! Helper function for code reusage. Some concrete commands for a bot.    
+            
+
             //WEAPONSYSTEM DATA
             std::map<std::string, int> weaponModes_; //<! Links each "weapon" to it's weaponmode - managed by setupWeapons()
             //std::vector<int> projectiles_; //<! Displays amount of projectiles of each weapon. - managed by setupWeapons()

Modified: code/branches/AI_HS15/src/orxonox/controllers/WingmanController.cc
===================================================================
--- code/branches/AI_HS15/src/orxonox/controllers/WingmanController.cc	2015-10-23 05:44:20 UTC (rev 10681)
+++ code/branches/AI_HS15/src/orxonox/controllers/WingmanController.cc	2015-10-23 12:18:32 UTC (rev 10682)
@@ -54,13 +54,69 @@
     }*/
     void WingmanController::action()
     {
-        
+        //--------------------------Cover Leader's rear--------------------------
+        //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.
+        //if there are enemies, set target_ to the nearest one and set bFollowLeader_ to false, 
+        //otherwise set bFollowLeader_ to true and target_ to sectionTarget_
+        this->coverAllyRear(this->sectionLeader_);
     }
 
     void WingmanController::tick(float dt)
     {
+        if (!this->isActive())
+            return;
+        //--------------------------Stay in formation--------------------------
+        if (bFollowLeader_)
+        {
+            this->keepSectionTick();
+            /*keepSectionTick(){
+                if (this->sectionLeader_ && this->sectionLeader_->getControllableEntity() && desiredRelativePosition_){
+                    Vector3 desiredAbsolutePosition = ((this->sectionLeader_->getControllableEntity()->getWorldPosition()) + 
+                        (this->sectionLeader_->getControllableEntity()->getWorldOrientation()* (*desiredRelativePosition_)));
+                    this->moveToPosition (desiredAbsolutePosition);
+                }
+            }
+            */
+            
+            //--------------------------Attack same target as the Leader--------------------------
+           
+            if (this->target_)
+            {
+                this->aimAtTarget();
+                this->doFire();
+            }
+        }
+        //--------------------------Protect Leader by killing target_--------------------------
 
-      
+        else
+        {
+            if (this->target_)
+            {
+                //--------------------------Don't attack if not visible--------------------------                
+                if (!this->target_->getRadarVisibility()) /* So AI won't shoot invisible Spaceships */
+                {
+                    this->forgetTarget();
+                    //this->bFollowLeader_ = true;
+                }
+                //--------------------------Otherwise destroy it--------------------------
+                else
+                {
+                    this->aimAtTarget();
+                    this->follow();  //If a bot is shooting a player, it shouldn't let him go away easily.
+                }
+                if (this->bHasTargetPosition_)
+                {
+                    this->moveToTargetPosition();
+                }
+                this->doFire();
+            }
+            //--------------------------no target? do nothing until next action() -> either new target appears or bFollowLeader_ set to true--------------------------
+            else
+            {
+
+            }            
+
+        }
         SUPER(WingmanController, tick, dt);
     }
 //**********************************************NEW




More information about the Orxonox-commit mailing list