Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

finished everything, demos are commented out in AITest.oxw

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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()
Note: See TracChangeset for help on using the changeset viewer.