Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Nov 15, 2015, 4:47:35 PM (9 years ago)
Author:
gania
Message:

Finished groundwork: AI fights enemies like I want it to. TODO implement all the functionality of old AI, like Waypoints, XMLPort

File:
1 edited

Legend:

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

    r10803 r10805  
    5151    DivisionController::~DivisionController()
    5252    {
    53      
    5453    }
    5554
     
    7776    void DivisionController::action()
    7877    {
    79         this->maneuver();
    80         this->bShooting_ = this->canFire();
    81        
     78        if (!this->target_)
     79        {
     80            for (ObjectList<Pawn>::iterator itP = ObjectList<Pawn>::begin(); itP; ++itP)
     81            {
     82                if (this->getControllableEntity()->getTeam() == static_cast<ControllableEntity*>(*itP)->getTeam())
     83                    continue;           
     84
     85               
     86                if (static_cast<ControllableEntity*>(*itP) != (this)->getControllableEntity() && !(this)->hasTarget()
     87                    && ((*itP)->getWorldPosition() - (this)->getControllableEntity()->getWorldPosition()).length() < 10000)
     88                {
     89                    (this)->setAction(Action::FIGHT, *itP);
     90                }   
     91            }
     92        }
     93       
     94        if (this->action_ == Action::FIGHT)
     95        {
     96            this->maneuver();
     97            this->bShooting_ = this->canFire();
     98            if (this->target_)
     99            {
     100                if (this->myWingman_)
     101                {
     102                    this->myWingman_->setAction (Action::FIGHT, this->target_);                   
     103                }
     104               
     105                Vector3 diffVector = this->positionOfTarget_ - this->getControllableEntity()->getWorldPosition();         
     106                if (diffVector.length() > 3000)
     107                {
     108                    this->setTargetPositionOfWingman();
     109                    //this->setTargetPositionOfFollower();                   
     110                }   
     111            }
     112        }
     113        else if (this->action_ == Action::FLY)
     114        {
     115            this->setTargetPositionOfWingman();
     116            this->setTargetPositionOfFollower();
     117        }
     118        else if (this->action_ == Action::PROTECT)
     119        {
     120
     121        }
    82122
    83123    }
     
    116156        (this->getControllableEntity()->getWorldOrientation()* (*targetRelativePositionOfWingman)));
    117157       
    118         myWingman_->setTargetOrientation(orient);
    119         myWingman_->setTargetPosition(targetAbsolutePositionOfWingman);
     158        myWingman_->setAction( Action::FLY, targetAbsolutePositionOfWingman, orient);
    120159       
    121160    }
     
    153192        (this->getControllableEntity()->getWorldOrientation()* (*targetRelativePositionOfFollower)));
    154193       
    155         myFollower_->setTargetOrientation(orient);
    156         myFollower_->setTargetPosition(targetAbsolutePositionOfFollower);
    157        
     194        myFollower_->setAction ( Action::FLY, targetAbsolutePositionOfFollower, orient );       
    158195    }
    159196
Note: See TracChangeset for help on using the changeset viewer.