Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 10838


Ignore:
Timestamp:
Nov 23, 2015, 3:50:59 PM (8 years ago)
Author:
gania
Message:

Gani changed something

Location:
code/branches/campaignHS15
Files:
9 edited

Legend:

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

    r10834 r10838  
    3232
    3333    <Light type=directional position="0,0,0" direction="0.253, 0.593, -0.765" diffuse="1.0, 0.9, 0.9, 1.0" specular="1.0, 0.9, 0.9, 1.0"/>
    34     <SpawnPoint team=0 position="-1000,-1000,-1000" lookat="1,1,-1" spawnclass=SpaceShip pawndesign=spaceshipassff />
    35     >
     34    <TeamSpawnPoint team=1 position="-1000,-1000,-1000" lookat="1,1,-1" spawnclass=SpaceShip pawndesign=spaceshipassff />
     35   
    3636<!--
    3737    <?lua
     
    5252 
    5353   
    54     <SpaceShip position="4000, 1500, -1000" lookat="0,0,0">
     54    <SpaceShip position="4000, 1500, -1000" lookat="0,0,0" team=0>
    5555      <templates>
    5656        <Template link=spaceshipassff />
    5757      </templates>
    5858      <controller>
    59         <DivisionController team=1 formationMode="wall" action="FIGHT">
     59        <DivisionController formationMode="wall" action="PROTECT" protect="FUCK" team=0>
    6060        </DivisionController>
    6161      </controller>
    6262    </SpaceShip>
    63     <SpaceShip position="4000 ,1500, -1600 " lookat="0,0,0">
     63    <SpaceShip position="4000 ,1500, -1600 " lookat="0,0,0" team=0>
    6464      <templates>
    6565        <Template link=spaceshipassff />
    6666      </templates>
    6767      <controller>
    68         <WingmanController team=1>
     68        <WingmanController >
    6969        </WingmanController>
    7070      </controller>
    7171    </SpaceShip>
    72     <SpaceShip position="4000, 1500, -2200" lookat="0,0,0">
     72    <SpaceShip position="4000, 1500, -2200" lookat="0,0,0" team=0>
    7373      <templates>
    7474        <Template link=spaceshipassff />
    7575      </templates>
    7676      <controller>
    77         <WingmanController team=1>
     77        <WingmanController >
    7878        </WingmanController>
    7979      </controller>
    8080    </SpaceShip>
    81     <SpaceShip position="4000, 1500, -2800 " lookat="0,0,0">
     81    <SpaceShip position="4000, 1500, -2800 " lookat="0,0,0" team=0>
    8282      <templates>
    8383        <Template link=spaceshipassff />
    8484      </templates>
    8585      <controller>
    86         <SectionController team=1>
     86        <SectionController >
     87        </SectionController>
     88      </controller>
     89    </SpaceShip>
     90    <SpaceShip position="-4000, 1500, -2800 " lookat="0,0,0" team=0 name="FUCK">
     91      <templates>
     92        <Template link=spaceshipassff />
     93      </templates>
     94      <controller>
     95        <SectionController>
    8796        </SectionController>
    8897      </controller>
    8998    </SpaceShip>
    9099   
    91     <SpaceShip position="-4000, 1500, -5000" lookat="0,0,0">
     100    <!-- <SpaceShip position="-4000, 1500, -5000" lookat="0,0,0">
    92101      <templates>
    93102        <Template link=spaceshipassff />
     
    124133        </SectionController>
    125134      </controller>
    126     </SpaceShip>
     135    </SpaceShip> -->
    127136
    128137   
  • code/branches/campaignHS15/src/orxonox/controllers/CommonController.cc

    r10834 r10838  
    3838
    3939#include "Scene.h"
    40 #include <OgreRay.h>
    41 #include <OgreSceneQuery.h>
    42 #include <OgreCamera.h>
    43 #include <OgreSceneManager.h>
     40
     41#include "worldentities/pawns/TeamBaseMatchBase.h"
     42#include "gametypes/TeamDeathmatch.h"
     43#include "gametypes/Dynamicmatch.h"
     44#include "gametypes/Mission.h"
     45#include "gametypes/Gametype.h"
     46#include "controllers/WaypointPatrolController.h"
     47#include "controllers/NewHumanController.h"
     48#include "controllers/DroneController.h"
     49
     50
    4451namespace orxonox
    4552{
     
    5158    CommonController::CommonController( Context* context ): Controller( context )
    5259    {
    53 
    54        
    5560        this->action_ = Action::FLY;
    5661        this->stopLookingAtTarget();
     
    7075        XMLPortParam( CommonController, "formationMode", setFormationModeXML, getFormationModeXML,  xmlelement, mode );
    7176        XMLPortParam( CommonController, "action", setActionXML, getActionXML,  xmlelement, mode );
    72 
     77        XMLPortParam ( CommonController, "protect", setProtectXML, getProtectXML,  xmlelement, mode );
     78        //XMLPortParam ( CommonController, "enemy", setEnemyXML, getEnemyXML,  xmlelement, mode );
     79    }
     80    void CommonController::setProtectXML( std::string val )
     81    {
     82        for (ObjectList<Pawn>::iterator itP = ObjectList<Pawn>::begin(); itP; ++itP)
     83        {
     84            if ((*itP)->getName() == val)
     85            {
     86                this->setProtect (static_cast<ControllableEntity*>(*itP));
     87            }
     88        }
     89    }
     90    std::string CommonController::getProtectXML ()
     91    {
     92        if (!this->getProtect())
     93            return "noProtectWasSet";
     94        return this->getProtect()->getName();
     95    }
     96
     97    void CommonController::setProtect (ControllableEntity* protect)
     98    {
     99        this->protect_ = protect;
     100    }
     101    ControllableEntity* CommonController::getProtect ()
     102    {
     103        return this->protect_;
    73104    }
    74105    void CommonController::setActionXML( std::string val)
     
    205236        Pawn* closestTarget = 0;
    206237        float minDistance =  std::numeric_limits<float>::infinity();
    207        
     238        Gametype* gt = this->getGametype();
    208239        for (ObjectList<Pawn>::iterator itP = ObjectList<Pawn>::begin(); itP; ++itP)
    209240        {
    210             if ( CommonController::sameTeam (this->getControllableEntity(), static_cast<ControllableEntity*>(*itP)) )
     241            if ( CommonController::sameTeam (this->getControllableEntity(), static_cast<ControllableEntity*>(*itP), gt) )
    211242                continue;
    212243
     
    669700        return ( entity1->getPosition() - entity2->getPosition() ).length();
    670701    }
    671     bool CommonController::sameTeam (ControllableEntity* entity1, ControllableEntity* entity2)
    672     {
    673         if (!entity1 || !entity2)
     702    bool CommonController::sameTeam (ControllableEntity* entity1, ControllableEntity* entity2, Gametype* gametype)
     703    {
     704        /*if (!entity1 || !entity2)
    674705            return false;
    675         return entity1->getTeam() == entity2->getTeam();
     706        return entity1->getTeam() == entity2->getTeam();*/
     707        if (entity1 == entity2)
     708            return true;
     709
     710        int team1 = entity1->getTeam();
     711        int team2 = entity2->getTeam();
     712
     713        Controller* controller = 0;
     714        if (entity1->getController())
     715            controller = entity1->getController();
     716        else
     717            controller = entity1->getXMLController();
     718        if (controller)
     719        {
     720            CommonController* ac = orxonox_cast<CommonController*>(controller);
     721            if (ac)
     722                team1 = ac->getTeam();
     723        }
     724
     725        if (entity2->getController())
     726            controller = entity2->getController();
     727        else
     728            controller = entity2->getXMLController();
     729        if (controller)
     730        {
     731            CommonController* ac = orxonox_cast<CommonController*>(controller);
     732            if (ac)
     733                team2 = ac->getTeam();
     734        }
     735
     736        TeamGametype* tdm = orxonox_cast<TeamGametype*>(gametype);
     737        if (tdm)
     738        {
     739            if (entity1->getPlayer())
     740                team1 = tdm->getTeam(entity1->getPlayer());
     741
     742            if (entity2->getPlayer())
     743                team2 = tdm->getTeam(entity2->getPlayer());
     744        }
     745
     746        TeamBaseMatchBase* base = 0;
     747        base = orxonox_cast<TeamBaseMatchBase*>(entity1);
     748        if (base)
     749        {
     750            switch (base->getState())
     751            {
     752                case BaseState::ControlTeam1:
     753                    team1 = 0;
     754                    break;
     755                case BaseState::ControlTeam2:
     756                    team1 = 1;
     757                    break;
     758                case BaseState::Uncontrolled:
     759                default:
     760                    team1 = -1;
     761            }
     762        }
     763        base = orxonox_cast<TeamBaseMatchBase*>(entity2);
     764        if (base)
     765        {
     766            switch (base->getState())
     767            {
     768                case BaseState::ControlTeam1:
     769                    team2 = 0;
     770                    break;
     771                case BaseState::ControlTeam2:
     772                    team2 = 1;
     773                    break;
     774                case BaseState::Uncontrolled:
     775                default:
     776                    team2 = -1;
     777            }
     778        }
     779
     780        DroneController* droneController = 0;
     781        droneController = orxonox_cast<DroneController*>(entity1->getController());
     782        if (droneController && static_cast<ControllableEntity*>(droneController->getOwner()) == entity2)
     783            return true;
     784        droneController = orxonox_cast<DroneController*>(entity2->getController());
     785        if (droneController && static_cast<ControllableEntity*>(droneController->getOwner()) == entity1)
     786            return true;
     787        DroneController* droneController1 = orxonox_cast<DroneController*>(entity1->getController());
     788        DroneController* droneController2 = orxonox_cast<DroneController*>(entity2->getController());
     789        if (droneController1 && droneController2 && droneController1->getOwner() == droneController2->getOwner())
     790            return true;
     791
     792        Dynamicmatch* dynamic = orxonox_cast<Dynamicmatch*>(gametype);
     793        if (dynamic)
     794        {
     795            if (dynamic->notEnoughPigs||dynamic->notEnoughKillers||dynamic->notEnoughChasers) {return false;}
     796
     797            if (entity1->getPlayer())
     798                team1 = dynamic->getParty(entity1->getPlayer());
     799
     800            if (entity2->getPlayer())
     801                team2 = dynamic->getParty(entity2->getPlayer());
     802
     803            if (team1 ==-1 ||team2 ==-1 ) {return false;}
     804            else if (team1 == dynamic->chaser && team2 != dynamic->chaser) {return false;}
     805            else if (team1 == dynamic->piggy && team2 == dynamic->chaser) {return false;}
     806            else if (team1 == dynamic->killer && team2 == dynamic->chaser) {return false;}
     807            else return true;
     808        }
     809
     810        return (team1 == team2 && team1 != -1);
    676811    }
    677812    void CommonController::doFire()
  • code/branches/campaignHS15/src/orxonox/controllers/CommonController.h

    r10834 r10838  
    103103                        { return this->rank_; }
    104104                //----[/Rank data]----
     105                //----[Protect data]----
     106                    void setProtectXML( std::string val );
     107                    std::string getProtectXML ();
     108                    void setProtect (ControllableEntity* protect);
     109                    ControllableEntity* getProtect ();
     110                //----[/Protect data]----
    105111            //----[/XML data]----
    106112
     
    124130                float randomInRange(float a, float b);
    125131                static float distance(ControllableEntity* entity1, ControllableEntity* entity2);
    126                 static bool sameTeam (ControllableEntity* entity1, ControllableEntity* entity2);
     132                static bool sameTeam (ControllableEntity* entity1, ControllableEntity* entity2, Gametype* gt);
    127133                static bool isLooking( ControllableEntity* entityThatLooks, ControllableEntity* entityBeingLookedAt, float angle ) ;
    128134
     
    168174                bool bHasTargetOrientation_;
    169175                Quaternion targetOrientation_;
    170                 // Vector3 destination_;
    171                 // bool bHasDestination;
     176               
     177                Vector3 destination_;
     178                bool bHasDestination;
    172179            //----[/where-to-fly information]----
    173            
     180            //----[protect information]----
     181                WeakPtr<ControllableEntity> protect_;
     182            //----[/protect information]----
    174183            //----[who-to-kill information]----
    175184                WeakPtr<ControllableEntity> target_;
    176                 //WeakPtr<ControllableEntity> objectiveTarget_;
     185                WeakPtr<ControllableEntity> enemy_;
    177186
    178187                bool bHasPositionOfTarget_;
  • code/branches/campaignHS15/src/orxonox/controllers/DivisionController.cc

    r10834 r10838  
    133133        else if (this->action_ == Action::PROTECT)
    134134        {
    135 
     135            if (this->getProtect())
     136            {
     137                orxout(internal_error) << "PROTECT FOUND" << endl;
     138            }
    136139        }
    137140
  • code/branches/campaignHS15/src/orxonox/controllers/SectionController.cc

    r10834 r10838  
    168168                    //----new target should be close to division's target----
    169169                    Vector3 divisionTargetPosition = this->myDivisionLeader_->getTarget()->getWorldPosition();
    170                    
     170                    Gametype* gt = this->getGametype();
    171171                    for (ObjectList<Pawn>::iterator itP = ObjectList<Pawn>::begin(); itP; ++itP)
    172172                    {
    173173                        //----is enemy?----
    174                         if ( CommonController::sameTeam (this->getControllableEntity(), static_cast<ControllableEntity*>(*itP)) )
     174                        if ( CommonController::sameTeam (this->getControllableEntity(), static_cast<ControllableEntity*>(*itP), gt) )
    175175                            continue;           
    176176                        //----in range?----
  • code/branches/campaignHS15/src/orxonox/controllers/WingmanController.cc

    r10834 r10838  
    135135        CommonController* closestLeader = 0;
    136136        float minDistance =  std::numeric_limits<float>::infinity();
    137 
     137        Gametype* gt = this->getGametype();
    138138        for (ObjectList<CommonController>::iterator it = ObjectList<CommonController>::begin(); it; ++it)
    139139        {
     
    145145           
    146146            //----same team?----
    147             if ( !CommonController::sameTeam (this->getControllableEntity(), (it)->getControllableEntity()) )
     147            if ( !CommonController::sameTeam (this->getControllableEntity(), (it)->getControllableEntity(), gt) )
    148148                continue;
    149149           
  • code/branches/campaignHS15/src/orxonox/worldentities/SpawnPoint.h

    r9667 r10838  
    5555                { return this->template_; }
    5656
    57             Pawn* spawn();
     57            virtual Pawn* spawn();
    5858            void spawn(ControllableEntity* entity);
    5959
  • code/branches/campaignHS15/src/orxonox/worldentities/TeamSpawnPoint.cc

    r9667 r10838  
    4949        XMLPortParam(TeamSpawnPoint, "team", setTeamNumber, getTeamNumber, xmlelement, mode).defaultValues(0);
    5050    }
     51    Pawn* TeamSpawnPoint::spawn()
     52    {
     53        Pawn* entity = SpawnPoint::spawn();
     54        static_cast<ControllableEntity*>(entity)->setTeam (this->teamNumber_);
     55        return entity;
     56    }
    5157}
  • code/branches/campaignHS15/src/orxonox/worldentities/TeamSpawnPoint.h

    r9667 r10838  
    4949            unsigned int getTeamNumber() const
    5050                { return this->teamNumber_; }
     51            virtual Pawn* spawn();
    5152
    5253        private:
    53             unsigned int teamNumber_;
     54            int teamNumber_;
    5455    };
    5556}
Note: See TracChangeset for help on using the changeset viewer.