[Orxonox-commit 6246] r10903 - in code/branches/campaignHS15: data/levels src/orxonox/controllers src/orxonox/worldentities/pawns

gania at orxonox.net gania at orxonox.net
Mon Nov 30 17:39:43 CET 2015


Author: gania
Date: 2015-11-30 17:39:43 +0100 (Mon, 30 Nov 2015)
New Revision: 10903

Modified:
   code/branches/campaignHS15/data/levels/AITest.oxw
   code/branches/campaignHS15/src/orxonox/controllers/ActionpointController.cc
   code/branches/campaignHS15/src/orxonox/controllers/FightingController.cc
   code/branches/campaignHS15/src/orxonox/worldentities/pawns/Pawn.h
Log:
AI attacks targets that are close

Modified: code/branches/campaignHS15/data/levels/AITest.oxw
===================================================================
--- code/branches/campaignHS15/data/levels/AITest.oxw	2015-11-30 16:37:42 UTC (rev 10902)
+++ code/branches/campaignHS15/data/levels/AITest.oxw	2015-11-30 16:39:43 UTC (rev 10903)
@@ -157,7 +157,7 @@
 <!-- HERE STARTS DEMO FOR FIGHTING -->
     
 
-    <SpaceShip position="-4000, 1500, -1000" lookat="0,0,0" team=0 name="ss2">
+    <SpaceShip position="-4000, 1500, -1000" lookat="0,0,0" team=0 name="d1sd1">
       <templates>
         <Template link=spaceshipassff />
       </templates>
@@ -167,7 +167,7 @@
         </DivisionController>
       </controller>
     </SpaceShip>
-    <SpaceShip position="-4000, 1900, -1000" lookat="0,0,0" team=0>
+    <SpaceShip position="-4000, 1900, -1000" lookat="0,0,0" team=0 name="d1ss1">
       <templates>
         <Template link=spaceshipassff />
       </templates>
@@ -176,7 +176,7 @@
         </SectionController>
       </controller>
     </SpaceShip>
-    <SpaceShip position="-4000, 2100, -1000" lookat="0,0,0" team=0>
+    <SpaceShip position="-4000, 2100, -1000" lookat="0,0,0" team=0 name="d1sw1">
       <templates>
         <Template link=spaceshipassff />
       </templates>
@@ -185,7 +185,7 @@
         </WingmanController>
       </controller>
     </SpaceShip>
-    <SpaceShip position="-4000, 2400, -1000" lookat="0,0,0" team=0>
+    <SpaceShip position="-4000, 2400, -1000" lookat="0,0,0" team=0 name="d1sw2">
       <templates>
         <Template link=spaceshipassff />
       </templates>
@@ -194,38 +194,18 @@
         </WingmanController>
       </controller>
     </SpaceShip>
-    <SpaceShip position="-4000, 1500, -3000" lookat="0,0,0" team=0>
-      <templates>
-        <Template link=spaceshipassff />
-      </templates>
-      <controller>
-        <DivisionController team=0 formationMode="WALL">
 
-        </DivisionController>
-      </controller>
-    </SpaceShip>
-    <SpaceShip position="-4000, 1900, -3000" lookat="0,0,0" team=0>
+    <SpaceShip position="2000, -1500, 1000" lookat="0,0,0" team=1  name="d2sd1">
       <templates>
         <Template link=spaceshipassff />
       </templates>
       <controller>
-        <SectionController team=0>
-        </SectionController>
-      </controller>
-    </SpaceShip>
-
-
-    <SpaceShip position="2000, -1500, 1000" lookat="0,0,0" team=1 >
-      <templates>
-        <Template link=spaceshipassff />
-      </templates>
-      <controller>
         <DivisionController team=1 formationMode="WALL">
 
         </DivisionController>
       </controller>
     </SpaceShip>
-    <SpaceShip position="2000, -1900, 1000" lookat="0,0,0" team=1>
+    <SpaceShip position="2000, -1900, 1000" lookat="0,0,0" team=1 name="d2ss1">
       <templates>
         <Template link=spaceshipassff />
       </templates>
@@ -234,7 +214,7 @@
         </SectionController>
       </controller>
     </SpaceShip>
-    <SpaceShip position="2000, -2100, 1000" lookat="0,0,0" team=1>
+    <SpaceShip position="2000, -2100, 1000" lookat="0,0,0" team=1 name="d2sw1">
       <templates>
         <Template link=spaceshipassff />
       </templates>
@@ -243,7 +223,7 @@
         </WingmanController>
       </controller>
     </SpaceShip>
-    <SpaceShip position="2000, -2400, 1000" lookat="0,0,0" team=1>
+    <SpaceShip position="2000, -2400, 1000" lookat="0,0,0" team=1 name="d2sw2">
       <templates>
         <Template link=spaceshipassff />
       </templates>

Modified: code/branches/campaignHS15/src/orxonox/controllers/ActionpointController.cc
===================================================================
--- code/branches/campaignHS15/src/orxonox/controllers/ActionpointController.cc	2015-11-30 16:37:42 UTC (rev 10902)
+++ code/branches/campaignHS15/src/orxonox/controllers/ActionpointController.cc	2015-11-30 16:39:43 UTC (rev 10903)
@@ -118,6 +118,7 @@
             return;
         if (!this->getControllableEntity() || !orxonox_cast<Pawn*> (this->getControllableEntity()))
             return;
+            this->startAttackingEnemiesThatAreClose();
 
         this->deltaHp = orxonox_cast<Pawn*> (this->getControllableEntity())->getHealth() - this->previousHp;
         this->previousHp = orxonox_cast<Pawn*> (this->getControllableEntity())->getHealth();
@@ -131,7 +132,6 @@
             //     orxout(internal_error) << "found health" << endl;
             //     this->parsedActionpoints_.push_back(point);
             // }
-            this->startAttackingEnemiesThatAreClose();
 
             if (this->parsedActionpoints_.empty() && this->loopActionpoints_.empty())
             {
@@ -145,6 +145,7 @@
         //Action fightall -> fight till nobody alive
         if (this->action_ == Action::FIGHTALL)
         {
+
             if (!this->hasTarget())
             {
                 ControllableEntity* newTarget = this->closestTarget();    
@@ -169,7 +170,8 @@
         //Action fight -> fight as long as enemies in range
         else if (this->action_ == Action::FIGHT)
         {
-            if (!this->hasTarget())
+
+            if (!this->hasTarget() )
             {
                 //----find a target----
                 ControllableEntity* newTarget = this->closestTarget();    
@@ -209,7 +211,6 @@
         }
         else if (this->action_ == Action::FLY)
         {
-            this->startAttackingEnemiesThatAreClose();            
             if (this->squaredDistanceToTarget() <= this->squaredaccuracy_)
             {
                 this->nextActionpoint();   
@@ -218,7 +219,6 @@
         }
         else if (this->action_ == Action::PROTECT)
         {
-            this->startAttackingEnemiesThatAreClose();            
             if (!this->getProtect())
             {
                 this->nextActionpoint();
@@ -228,7 +228,7 @@
         }
         else if (this->action_ == Action::ATTACK)
         {   
-            this->startAttackingEnemiesThatAreClose();            
+
             if (!this->hasTarget())
             {
                 this->nextActionpoint();
@@ -619,7 +619,7 @@
     }
     void ActionpointController::startAttackingEnemiesThatAreClose()
     {
-        if (this->action_ != Action::FIGHT && this->action_ != Action::FIGHTALL)
+        //if (this->action_ != Action::FIGHT && this->action_ != Action::FIGHTALL)
         {
             if (!this->target_ || (this->target_ && CommonController::distance (this->getControllableEntity(), this->target_) > this->attackRange_))
             {
@@ -635,6 +635,7 @@
                     }
                     else
                     {
+                        //orxout (internal_error) << "found new target " << CommonController::getName(newTarget) <<endl;
                         Point p = { Action::FIGHT, CommonController::getName(newTarget), Vector3::ZERO, false };
                         this->parsedActionpoints_.push_back(p);
                     }

Modified: code/branches/campaignHS15/src/orxonox/controllers/FightingController.cc
===================================================================
--- code/branches/campaignHS15/src/orxonox/controllers/FightingController.cc	2015-11-30 16:37:42 UTC (rev 10902)
+++ code/branches/campaignHS15/src/orxonox/controllers/FightingController.cc	2015-11-30 16:39:43 UTC (rev 10903)
@@ -36,7 +36,9 @@
 #include "weaponsystem/WeaponPack.h"
 #include "weaponsystem/Weapon.h"
 #include "weaponsystem/WeaponSlot.h"
-#include "weaponsystem/WeaponSlot.h"
+#include "weaponsystem/WeaponSystem.h"
+#include "weaponsystem/Munition.h"
+
 namespace orxonox
 {
 
@@ -138,26 +140,26 @@
             this->setTargetPosition(this->positionOfTarget_ - diffUnit * 100.0f);
         }
         //too close? How do u expect to dodge anything? Just attack!
-        else if (diffLength < 400)
+        else if (diffLength < 1000)
         {   
             this->bKeepFormation_ = false;
 
             //at this point, just look and shoot
-            if (diffLength < 200)
+            if (diffLength < 500)
             {
                 this->stopMoving();
                 this->startLookingAtTarget();
             }
             else
             {
-                this->setTargetPosition(this->positionOfTarget_ - diffUnit * 100.0f);
+                this->setTargetPosition(this->positionOfTarget_ - diffUnit * 300.0f);
             }
         }
         //Good distance? Check if target looks at us. It doesn't? Go hunt!
         else if (!bTargetIsLookingAtThis)
         {
             this->bKeepFormation_ = false;
-            this->setTargetPosition(this->positionOfTarget_ - diffUnit * 100.0f);
+            this->setTargetPosition(this->positionOfTarget_ - diffUnit * 300.0f);
         }
         //That's unfortunate, he is looking and probably shooting... try to dodge what we can...  
         else 
@@ -165,10 +167,11 @@
             this->bKeepFormation_ = false;
             if (maneuverCounter_ == 0)
             {
-                this->setTargetPosition(this->positionOfTarget_ - diffUnit * 50.0f);   
+                this->setTargetPosition(this->positionOfTarget_ - diffUnit * 100.0f);   
                 return;
             }
-            dodge(thisPosition, diffUnit);
+            if (this->actionCounter_ % 3 == 0)
+                dodge(thisPosition, diffUnit);
         }
     }
     void FightingController::dodgeTowards (Vector3& position)
@@ -364,8 +367,10 @@
                     for(int i=0; (wMode = wSlot->getWeapon()->getWeaponmode(i)) ; i++)
                     {
                         std::string wName = wMode->getIdentifier()->getName();
+                        // SubclassIdentifier<Munition> munition =  ClassByString(wName);
                         if (wName == "RocketFire")
                             this->rocketsLeft_ = 10;
+                            // this->rocketsLeft_ = orxonox_cast<Pawn*>(this->getControllableEntity())->getWeaponSystem()->getMunition(&munition)->getNumMunitionInCurrentMagazine(wMode);
                         if(this->getFiremode(wName) == -1) //only add a weapon, if it is "new"
                             weaponModes_[wName] = wMode->getMode();
                     }
@@ -374,6 +379,8 @@
                     this->bSetupWorked = true;
             }//pawn->weaponSystem_->getMunition(SubclassIdentifier< Munition > *identifier)->getNumMunition (WeaponMode *user);
         }
+
+        //orxout (internal_error) << this->rocketsLeft_ << " rockets left" << endl;
     }
 
     int FightingController::getFiremode(std::string name)

Modified: code/branches/campaignHS15/src/orxonox/worldentities/pawns/Pawn.h
===================================================================
--- code/branches/campaignHS15/src/orxonox/worldentities/pawns/Pawn.h	2015-11-30 16:37:42 UTC (rev 10902)
+++ code/branches/campaignHS15/src/orxonox/worldentities/pawns/Pawn.h	2015-11-30 16:39:43 UTC (rev 10903)
@@ -193,6 +193,9 @@
             void setExplosionSound(const std::string& engineSound);
             const std::string& getExplosionSound();
 
+            virtual const WeaponSystem* getWeaponSystem() const
+                { return this->weaponSystem_; }
+
         protected:
             virtual void preDestroy();
 




More information about the Orxonox-commit mailing list