Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 6601 for code/branches


Ignore:
Timestamp:
Mar 22, 2010, 5:33:42 PM (15 years ago)
Author:
solex
Message:

ArtificialController: sameTeam hacking

Location:
code/branches/ai/src/orxonox/controllers
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • code/branches/ai/src/orxonox/controllers/ArtificialController.cc

    r6502 r6601  
    3030
    3131#include "core/CoreIncludes.h"
     32#include "core/XMLPort.h"
    3233#include "worldentities/ControllableEntity.h"
    3334#include "worldentities/pawns/Pawn.h"
     
    4344
    4445        this->target_ = 0;
     46        this->team_ = 0;//new
     47        this->isMaster_ = false;//new
    4548        this->bShooting_ = false;
    4649        this->bHasTargetPosition_ = false;
     
    5255    ArtificialController::~ArtificialController()
    5356    {
     57    }
     58
     59    void ArtificialController::XMLPort(Element& xmlelement, XMLPort::Mode mode)
     60    {
     61        SUPER(ArtificialController, XMLPort, xmlelement, mode);
     62
     63        XMLPortParam(ArtificialController, "team", setTeam, getTeam, xmlelement, mode).defaultValues(0);
    5464    }
    5565
     
    188198        int team2 = -1;
    189199
    190         if (entity1->getXMLController())
    191         {
    192             WaypointPatrolController* wpc = orxonox_cast<WaypointPatrolController*>(entity1->getXMLController());
    193             if (wpc)
    194                 team1 = wpc->getTeam();
    195         }
    196         if (entity2->getXMLController())
    197         {
    198             WaypointPatrolController* wpc = orxonox_cast<WaypointPatrolController*>(entity2->getXMLController());
    199             if (wpc)
    200                 team2 = wpc->getTeam();
     200        Controller* controller = 0;
     201        if (entity1->getController())
     202            controller = entity1->getController();
     203        else
     204            controller = entity1->getXMLController();
     205        if (controller)
     206        {
     207            ArtificialController* ac = orxonox_cast<ArtificialController*>(controller);
     208            if (ac)
     209                team1 = ac->getTeam();
     210        }
     211
     212        if (entity1->getController())
     213            controller = entity1->getController();
     214        else
     215            controller = entity1->getXMLController();
     216        if (controller)
     217        {
     218            ArtificialController* ac = orxonox_cast<ArtificialController*>(controller);
     219            if (ac)
     220                team2 = ac->getTeam();
    201221        }
    202222
  • code/branches/ai/src/orxonox/controllers/ArtificialController.h

    r6417 r6601  
    4343            virtual ~ArtificialController();
    4444
     45            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);//new
     46
    4547            void abandonTarget(Pawn* target);
     48
     49            inline void setTeam(int team)//new
     50                { this->team_ = team; }
     51            inline int getTeam() const
     52                { return this->team_; }
     53
    4654
    4755        protected:
     
    6977            bool bShooting_;
    7078
     79            bool isMaster_;//new
     80            int team_;//new
     81
    7182        private:
    7283    };
  • code/branches/ai/src/orxonox/controllers/WaypointPatrolController.cc

    r6502 r6601  
    4242        RegisterObject(WaypointPatrolController);
    4343
    44         this->team_ = 0;
     44        //this->team_ = 0;
    4545        this->alertnessradius_ = 500;
    4646
     
    5353
    5454        XMLPortParam(WaypointPatrolController, "alertnessradius", setAlertnessRadius, getAlertnessRadius, xmlelement, mode).defaultValues(500.0f);
    55         XMLPortParam(WaypointPatrolController, "team", setTeam, getTeam, xmlelement, mode).defaultValues(0);
     55//        XMLPortParam(WaypointPatrolController, "team", setTeam, getTeam, xmlelement, mode).defaultValues(0);
    5656    }
    5757
  • code/branches/ai/src/orxonox/controllers/WaypointPatrolController.h

    r5929 r6601  
    4646            virtual void tick(float dt);
    4747
    48             inline void setTeam(int team)
     48           /* inline void setTeam(int team)
    4949                { this->team_ = team; }
    5050            inline int getTeam() const
    51                 { return this->team_; }
     51                { return this->team_; } */
    5252
    5353            inline void setAlertnessRadius(float radius)
     
    5959            void searchEnemy();
    6060
    61             int team_;
     61            //int team_;
    6262            float alertnessradius_;
    6363            Timer patrolTimer_;
Note: See TracChangeset for help on using the changeset viewer.