Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 8965


Ignore:
Timestamp:
Dec 7, 2011, 4:00:37 PM (12 years ago)
Author:
willis
Message:

added some Mode features, fixed a speed issue

Location:
code/branches/formation/src/orxonox/controllers
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • code/branches/formation/src/orxonox/controllers/AIController.cc

    r8953 r8965  
    123123            }
    124124
     125            // next enemy
     126            random = rnd(maxrand);
     127            if (random < 10 && (this->target_))
     128                this->searchNewTarget();
     129
    125130            // shoot
    126131            random = rnd(maxrand);
  • code/branches/formation/src/orxonox/controllers/HumanController.cc

    r8953 r8965  
    174174    {
    175175        if (HumanController::localController_s && HumanController::localController_s->controllableEntity_)
     176        {
    176177            HumanController::localController_s->controllableEntity_->fire(firemode);
     178            //if human fires, set slaves free. See Masterable::forceFreeSlaves()
     179            if (HumanController::localController_s->state_==MASTER && HumanController::localController_s->mode_==NORMAL)
     180            {
     181                HumanController::localController_s->forceFreeSlaves();
     182            }
     183        }
    177184    }
    178185
     
    324331                break;
    325332            }
    326             changedMode();
    327         }
    328     }
    329 
    330     void HumanController::changedMode()
    331     {
    332 
    333     }
    334    
     333        }
     334    }
     335
     336
     337    //used, when slaves are in DEFEND mode.
     338    void HumanController::hit(Pawn* originator, btManifoldPoint& contactpoint, float damage)
     339    {
     340        if (!this->formationFlight_ || this->state_!=MASTER || this->mode_!=DEFEND) return;
     341            this->masterAttacked(originator);
     342    }
     343
    335344    void HumanController::addBots(unsigned int amount)
    336345    {
  • code/branches/formation/src/orxonox/controllers/HumanController.h

    r8953 r8965  
    8888            static void toggleFormationFlight();
    8989            static void FFChangeMode();
    90             static void changedMode();
     90            virtual void hit(Pawn* originator, btManifoldPoint& contactpoint, float damage);
     91
    9192
    9293            static void addBots(unsigned int amount);
  • code/branches/formation/src/orxonox/controllers/Masterable.cc

    r8957 r8965  
    319319                        copyTargetOrientation();
    320320                    }
    321                 if (distance < 40)
    322                 {
    323                     this->getControllableEntity()->moveFrontBack(0.2f*SPEED_MASTER);
     321                if (distance < 100)
     322                {   //linear speed reduction
     323                    this->getControllableEntity()->moveFrontBack(distance/100.0f*0.4f*SPEED_MASTER);
    324324                   
    325325                } else this->getControllableEntity()->moveFrontBack(1.2f*SPEED_MASTER);
     
    451451            this->state_ = MASTER;
    452452            this->myMaster_ = 0;
    453             orxout(debug_output) << "search new master: no master found, but "<<teamSize<<" teammates"<< endl;
    454         } else if (this->state_ != SLAVE)
    455             orxout(debug_output) << "search new master: no master found, no teammates..."<< endl;
     453        }
    456454    }
    457455 /**
     
    620618                 (*it)->myMaster_=this;
    621619            }
     620            this->myMaster_=0;
    622621            this->state_=MASTER;
    623622        }
    624         //debug
     623        /*/debug
    625624        if (this->state_==SLAVE)
    626625           {orxout(debug_output) << this << " is slave "<< endl;}
     
    628627           {orxout(debug_output) << this << " is now a master of "<<this->slaves_.size()<<" slaves."<< endl;}
    629628        if (this->state_==FREE)
    630            {orxout(debug_output) << this << " is free "<< endl;}
    631     }
     629           {orxout(debug_output) << this << " is free "<< endl;}*/
     630    }
     631
     632    void Masterable::masterAttacked(Pawn* originator)
     633    {
     634       orxout(debug_output)<<"slaves, attack!"<<endl;
     635    }     
    632636
    633637
     
    904908    }
    905909
    906 /*
    907     bool Masterable::sameTeam(ControllableEntity* entity1, ControllableEntity* entity2, Gametype* gametype)
    908     {
    909         if (!entity1 || !entity2) return false;
    910         if (entity1 == entity2) return true;
    911 
    912         if (!gametype)
    913             orxout(debug_output) << "gametype NULL"<< endl;
     910  bool Masterable::sameTeam(ControllableEntity* entity1, ControllableEntity* entity2, Gametype* gametype)
     911    {
     912        if (entity1 == entity2)
     913            return true;
    914914
    915915        int team1 = -1;
    916916        int team2 = -1;
    917917
     918        Controller* controller = 0;
     919        if (entity1->getController())
     920            controller = entity1->getController();
     921        else
     922            controller = entity1->getXMLController();
     923        if (controller)
     924        {
     925            Masterable* ac = orxonox_cast<Masterable*>(controller);
     926            if (ac)
     927                team1 = ac->getTeam();
     928        }
     929
     930        if (entity2->getController())
     931            controller = entity2->getController();
     932        else
     933            controller = entity2->getXMLController();
     934        if (controller)
     935        {
     936            Masterable* ac = orxonox_cast<Masterable*>(controller);
     937            if (ac)
     938                team2 = ac->getTeam();
     939        }
     940
    918941        TeamDeathmatch* tdm = orxonox_cast<TeamDeathmatch*>(gametype);
    919942        if (tdm)
     
    924947            if (entity2->getPlayer())
    925948                team2 = tdm->getTeam(entity2->getPlayer());
    926              orxout(debug_output) << "teamdeath okay"<< endl;
    927         }
    928 
    929         if (team1!=-1 && team2!=-1)
    930         {
    931             orxout(debug_output) << "Sameteam: decided in TeamDeathmatch. return "<<(team1 == team2 && team1 != -1)<< endl;
    932             return (team1 == team2 && team1 != -1);
    933         }
    934         team1=team2=-1;
    935         orxout(debug_output) << "Sameteam: not in teamdeathmatch."<< endl;
     949        }
     950
    936951        TeamBaseMatchBase* base = 0;
    937952        base = orxonox_cast<TeamBaseMatchBase*>(entity1);
     
    967982            }
    968983        }
    969 
    970         if (team1!=-1 && team2!=-1)
    971             return (team1 == team2 && team1 != -1);
    972         team1=team2=-1;
    973 
    974984
    975985        DroneController* droneController = 0;
     
    10041014
    10051015        return (team1 == team2 && team1 != -1);
    1006 
    1007     }*/
    1008 
    1009   bool Masterable::sameTeam(ControllableEntity* entity1, ControllableEntity* entity2, Gametype* gametype)
    1010     {
    1011         if (entity1 == entity2)
    1012             return true;
    1013 
    1014         int team1 = -1;
    1015         int team2 = -1;
    1016 
    1017         Controller* controller = 0;
    1018         if (entity1->getController())
    1019             controller = entity1->getController();
    1020         else
    1021             controller = entity1->getXMLController();
    1022         if (controller)
    1023         {
    1024             Masterable* ac = orxonox_cast<Masterable*>(controller);
    1025             if (ac)
    1026                 team1 = ac->getTeam();
    1027         }
    1028 
    1029         if (entity2->getController())
    1030             controller = entity2->getController();
    1031         else
    1032             controller = entity2->getXMLController();
    1033         if (controller)
    1034         {
    1035             Masterable* ac = orxonox_cast<Masterable*>(controller);
    1036             if (ac)
    1037                 team2 = ac->getTeam();
    1038         }
    1039 
    1040         TeamDeathmatch* tdm = orxonox_cast<TeamDeathmatch*>(gametype);
    1041         if (tdm)
    1042         {
    1043             if (entity1->getPlayer())
    1044                 team1 = tdm->getTeam(entity1->getPlayer());
    1045 
    1046             if (entity2->getPlayer())
    1047                 team2 = tdm->getTeam(entity2->getPlayer());
    1048             return (team1 == team2 && team1 != -1); //temp solution
    1049         }
    1050 
    1051         TeamBaseMatchBase* base = 0;
    1052         base = orxonox_cast<TeamBaseMatchBase*>(entity1);
    1053         if (base)
    1054         {
    1055             switch (base->getState())
    1056             {
    1057                 case BaseState::ControlTeam1:
    1058                     team1 = 0;
    1059                     break;
    1060                 case BaseState::ControlTeam2:
    1061                     team1 = 1;
    1062                     break;
    1063                 case BaseState::Uncontrolled:
    1064                 default:
    1065                     team1 = -1;
    1066             }
    1067         }
    1068         base = orxonox_cast<TeamBaseMatchBase*>(entity2);
    1069         if (base)
    1070         {
    1071             switch (base->getState())
    1072             {
    1073                 case BaseState::ControlTeam1:
    1074                     team2 = 0;
    1075                     break;
    1076                 case BaseState::ControlTeam2:
    1077                     team2 = 1;
    1078                     break;
    1079                 case BaseState::Uncontrolled:
    1080                 default:
    1081                     team2 = -1;
    1082             }
    1083         }
    1084 
    1085         DroneController* droneController = 0;
    1086         droneController = orxonox_cast<DroneController*>(entity1->getController());
    1087         if (droneController && static_cast<ControllableEntity*>(droneController->getOwner()) == entity2)
    1088             return true;
    1089         droneController = orxonox_cast<DroneController*>(entity2->getController());
    1090         if (droneController && static_cast<ControllableEntity*>(droneController->getOwner()) == entity1)
    1091             return true;
    1092         DroneController* droneController1 = orxonox_cast<DroneController*>(entity1->getController());
    1093         DroneController* droneController2 = orxonox_cast<DroneController*>(entity2->getController());
    1094         if (droneController1 && droneController2 && droneController1->getOwner() == droneController2->getOwner())
    1095             return true;
    1096 
    1097         Dynamicmatch* dynamic = orxonox_cast<Dynamicmatch*>(gametype);
    1098         if (dynamic)
    1099         {
    1100             if (dynamic->notEnoughPigs||dynamic->notEnoughKillers||dynamic->notEnoughChasers) {return false;}
    1101 
    1102             if (entity1->getPlayer())
    1103                 team1 = dynamic->getParty(entity1->getPlayer());
    1104 
    1105             if (entity2->getPlayer())
    1106                 team2 = dynamic->getParty(entity2->getPlayer());
    1107 
    1108             if (team1 ==-1 ||team2 ==-1 ) {return false;}
    1109             else if (team1 == dynamic->chaser && team2 != dynamic->chaser) {return false;}
    1110             else if (team1 == dynamic->piggy && team2 == dynamic->chaser) {return false;}
    1111             else if (team1 == dynamic->killer && team2 == dynamic->chaser) {return false;}
    1112             else return true;
    1113         }
    1114 
    1115         return (team1 == team2 && team1 != -1);
    11161016    }
    11171017
  • code/branches/formation/src/orxonox/controllers/Masterable.h

    r8957 r8965  
    7878      inline void setTeam(int team)
    7979           { this->team_ = team;
    80              orxout(debug_output) << "Set team to: "<<team<<" in "<<this<< endl;}
     80             orxout(debug_output) << "Set team to: "<<team<<" in "<<this<< endl;} 
    8181      inline int getTeam() const
    8282           { return this->team_; }
     
    134134
    135135      void takeLeadOfFormation();
     136      void masterAttacked(Pawn* originator);     
    136137
    137138      void specificMasterActionHold();
  • code/branches/formation/src/orxonox/controllers/NewHumanController.cc

    r8858 r8965  
    297297    void NewHumanController::hit(Pawn* originator, btManifoldPoint& contactpoint, float damage)
    298298    {
     299        //Used in HumanController for formationFlight
     300        HumanController::hit(originator,contactpoint,damage);
     301       
    299302        if (this->showDamageOverlay_ && !this->controlPaused_ && this->controllableEntity_ && !this->controllableEntity_->isInMouseLook())
    300303        {
Note: See TracChangeset for help on using the changeset viewer.