Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 10861


Ignore:
Timestamp:
Nov 25, 2015, 8:46:09 PM (8 years ago)
Author:
gania
Message:

finished everything, demos are commented out in AITest.oxw

Location:
code/branches/campaignHS15
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • code/branches/campaignHS15/data/levels/AITest.oxw

    r10859 r10861  
    6060<!-- HERE ENDS DEMO FOR THE "WAYPOINTS" -->
    6161
    62 <!-- HERE STARTS DEMO FOR THE ACTIONPOINTS -->
     62<!-- HERE STARTS DEMO FOR THE ACTIONPOINTS.
     63P.S. Never set protectMe in the first actionpoint: if human didn't spawn, that actionpoint will be skipped -->
    6364       
    6465    <Model mesh="cube.mesh" scale=8 position="0,0,0" />
     
    7172        <DivisionController team=0 formationMode="finger4">
    7273          <actionpoints>
    73             <Actionpoint position="0,0,0" action="FLY" />
     74            <Actionpoint position="0,0,0" action="FLY" /> 
    7475            <Actionpoint position="-1000,750,-500" action="ATTACK" attack="ss3" />
    75             <Actionpoint position="-1000,750,-500" action="PROTECt" protect="fuck" />
    76           </actionpoints>
     76            <Actionpoint position="-1000,750,-500" action="PROTECt" protectMe=true />
     77            <Actionpoint position="-1000,750,-500" action="PROTECt" protect="fuck" />
     78            <Actionpoint position="-1000,750,-500" action="FIGHTALL" />
     79           </actionpoints>
    7780        </DivisionController>
    7881      </controller>
     
    120123      </templates>
    121124    </SpaceShip>
     125 
    122126   
    123127<!-- HERE ENDS DEMO FOR THE ACTIONPOINTS -->
  • code/branches/campaignHS15/src/orxonox/controllers/CommonController.cc

    r10859 r10861  
    7474        this->parsedActionpoints_.clear();
    7575        RegisterObject( CommonController );
    76 
     76        this->bTakenOver_ = false;
    7777    }
    7878    CommonController::~CommonController()
    7979    {
     80        parsedActionpoints_.clear();
     81        actionpoints_.clear();
    8082    }
    8183    void CommonController::tick(float dt)
     
    9799            std::reverse(parsedActionpoints_.begin(), parsedActionpoints_.end());
    98100            std::reverse(actionpoints_.begin(), actionpoints_.end());
     101            if (this->parsedActionpoints_.empty())
     102            {
     103                this->action_ = Action::FIGHTALL;
     104            }
    99105        }
    100106        if (this->bFirstTick_)
     
    822828                    {
    823829                        std::string protectName = this->loopActionpoints_.back().name;
    824 
    825                         for (ObjectList<Pawn>::iterator itP = ObjectList<Pawn>::begin(); itP; ++itP)
    826                         {
    827                             if (CommonController::getName(*itP) == protectName)
     830                        if (protectName == "reservedKeyword:human")
     831                        {
     832                            for (ObjectList<Pawn>::iterator itP = ObjectList<Pawn>::begin(); itP; ++itP)
    828833                            {
    829                                 this->setProtect (static_cast<ControllableEntity*>(*itP));
     834                                if (orxonox_cast<ControllableEntity*>(*itP) && ((*itP)->getController()) && orxonox_cast <NewHumanController*> ((*itP)->getController()))
     835                                {
     836                                    this->setProtect (static_cast<ControllableEntity*>(*itP));
     837                                }
    830838                            }
     839                        }
     840                        else
     841                        {
     842                            for (ObjectList<Pawn>::iterator itP = ObjectList<Pawn>::begin(); itP; ++itP)
     843                            {
     844                                if (CommonController::getName(*itP) == protectName)
     845                                {
     846                                    this->setProtect (static_cast<ControllableEntity*>(*itP));
     847                                }
     848                            }                           
    831849                        }
    832850                        if (!this->getProtect())
     
    915933                    case Action::PROTECT:
    916934                    {
     935                       
    917936                        std::string protectName = this->parsedActionpoints_.back().name;
    918 
    919                         for (ObjectList<Pawn>::iterator itP = ObjectList<Pawn>::begin(); itP; ++itP)
    920                         {
    921                             if (CommonController::getName(*itP) == protectName)
     937                        if (protectName == "reservedKeyword:human")
     938                        {
     939                            for (ObjectList<Pawn>::iterator itP = ObjectList<Pawn>::begin(); itP; ++itP)
    922940                            {
    923                                 this->setProtect (static_cast<ControllableEntity*>(*itP));
     941                                if (orxonox_cast<ControllableEntity*>(*itP) && ((*itP)->getController()) && orxonox_cast <NewHumanController*> ((*itP)->getController()))
     942                                {
     943                                    this->setProtect (static_cast<ControllableEntity*>(*itP));
     944                                }
    924945                            }
     946                        }
     947                        else
     948                        {
     949                            for (ObjectList<Pawn>::iterator itP = ObjectList<Pawn>::begin(); itP; ++itP)
     950                            {
     951                                if (CommonController::getName(*itP) == protectName)
     952                                {
     953                                    this->setProtect (static_cast<ControllableEntity*>(*itP));
     954                                }
     955                            }                           
    925956                        }
    926957                        if (!this->getProtect())
     
    10281059        if (!this || !this->getControllableEntity())
    10291060            return;
    1030         orxout (internal_error) << "Size of actions is " << this->parsedActionpoints_.size() << endl;
     1061        // orxout (internal_error) << "Size of actions is " << this->parsedActionpoints_.size() << endl;
    10311062        this->startAttackingEnemiesThatAreClose();
    10321063        //No action -> pop one from stack
    1033         if (this->action_ == Action::NONE)
    1034         {
     1064        if (this->action_ == Action::NONE || this->bTakenOver_)
     1065        {
     1066            if (this->parsedActionpoints_.empty() && this->loopActionpoints_.empty())
     1067            {
     1068                Point p = { Action::FIGHTALL, "", Vector3::ZERO, false };
     1069                this->parsedActionpoints_.push_back (p);
     1070            }
    10351071            this->executeActionpoint();
     1072            this->bTakenOver_ = false;
    10361073        }
    10371074        //Action fightall -> fight till nobody alive
     
    11341171      this->parsedActionpoints_ = vector;
    11351172      this->loopActionpoints_ = loop;
    1136       this->bLoop_ = b;
    1137       this->setAction (Action::NONE);
    1138       // this->setTarget(0);
    1139       // this->setTargetPosition (this->getControllableEntity()->getWorldPosition());
    1140       orxout(internal_error) << "Top action is " << this->parsedActionpoints_.back().action << endl;
     1173      this->bLoop_ = this->bLoop_;
     1174      this->bTakenOver_ = true;
     1175      // orxout(internal_error) << "Top action is " << this->parsedActionpoints_.back().action << endl;
    11411176    }
    11421177    void CommonController::boostControl()
  • code/branches/campaignHS15/src/orxonox/controllers/CommonController.h

    r10859 r10861  
    229229                bool bInLoop_;
    230230                bool bLoop_;   
    231                 bool bEndLoop_;               
     231                bool bEndLoop_; 
     232                bool bTakenOver_;             
    232233            //----[/"Private" variables]----   
    233234           
  • code/branches/campaignHS15/src/orxonox/controllers/DivisionController.cc

    r10859 r10861  
    8383    {   
    8484        if (!this->isActive())
    85             return;
     85            return;   
    8686        SUPER(DivisionController, tick, dt);
    8787    }
     
    9090        if (!this || !this->getControllableEntity())
    9191            return;
     92       
    9293        CommonController::action();
     94        if (!this || !this->getControllableEntity())
     95            return;
     96        if (!(this->parsedActionpoints_.empty() && this->loopActionpoints_.empty()))
     97        {
     98            if (this->myFollower_)
     99            {
     100                this->myFollower_->takeActionpoints(this->parsedActionpoints_, this->loopActionpoints_, this->bLoop_);
     101            }
     102            else if (this->myWingman_)
     103            {
     104                this->myWingman_->takeActionpoints(this->parsedActionpoints_, this->loopActionpoints_, this->bLoop_);
     105            }   
     106        }
    93107       
    94108    }
  • code/branches/campaignHS15/src/orxonox/controllers/SectionController.cc

    r10859 r10861  
    9898        if (!myDivisionLeader_)
    9999        {
     100           
    100101            CommonController::action();
     102            if (!this || !this->getControllableEntity())
     103                return;
     104            if (!(this->parsedActionpoints_.empty() && this->loopActionpoints_.empty()))
     105            {
     106                if (this->myWingman_)
     107                {
     108                    this->myWingman_->takeActionpoints(this->parsedActionpoints_, this->loopActionpoints_, this->bLoop_);
     109                }   
     110            }
    101111        }
    102112        else if (myDivisionLeader_)
Note: See TracChangeset for help on using the changeset viewer.