Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 10883


Ignore:
Timestamp:
Nov 28, 2015, 11:46:05 AM (8 years ago)
Author:
gania
Message:

ships spread before fight

Location:
code/branches/campaignHS15
Files:
7 edited

Legend:

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

    r10882 r10883  
    3535   
    3636<!-- HERE STARTS DEMO FOR THE "WAYPOINTS" -->
    37      
     37      <!--
    3838    <Model mesh="cube.mesh" scale=8 position="  0,2000,-600" />
    3939    <Model mesh="cube.mesh" scale=8 position="  0,2000,-800" />
     
    5757      </controller>
    5858    </SpaceShip>
    59    
     59    -->
    6060<!-- HERE ENDS DEMO FOR THE "WAYPOINTS" -->
    6161
     
    128128<!-- HERE STARTS DEMO FOR FIGHTING -->
    129129    <!--
    130     <SpaceShip position="-2000, 1500, -1000" lookat="0,0,0" team=0 name="ss2">
     130    <SpaceShip position="-4000, 1500, -1000" lookat="0,0,0" team=0 name="ss2">
    131131      <templates>
    132132        <Template link=spaceshipassff />
     
    140140      </controller>
    141141    </SpaceShip>
    142     <SpaceShip position="-2000, 1900, -1000" lookat="0,0,0" team=0>
     142    <SpaceShip position="-4000, 1900, -1000" lookat="0,0,0" team=0>
    143143      <templates>
    144144        <Template link=spaceshipassff />
     
    149149      </controller>
    150150    </SpaceShip>
    151     <SpaceShip position="-2000, 2100, -1000" lookat="0,0,0" team=0>
    152       <templates>
    153         <Template link=spaceshipassff />
    154       </templates>
    155       <controller>
    156         <WingmanController team=0>
    157         </WingmanController>
    158       </controller>
    159     </SpaceShip>
    160     <SpaceShip position="-2000, 2400, -1000" lookat="0,0,0" team=0>
     151    <SpaceShip position="-4000, 2100, -1000" lookat="0,0,0" team=0>
     152      <templates>
     153        <Template link=spaceshipassff />
     154      </templates>
     155      <controller>
     156        <WingmanController team=0>
     157        </WingmanController>
     158      </controller>
     159    </SpaceShip>
     160    <SpaceShip position="-4000, 2400, -1000" lookat="0,0,0" team=0>
    161161      <templates>
    162162        <Template link=spaceshipassff />
     
    210210<!-- HERE ENDS DEMO FOR FIGHTING -->
    211211<!-- HERE STARTS DEMO FOR FORMATIONS -->
    212     <!--
     212   
    213213    <Model mesh="cube.mesh" scale=8 position="   0,2000,    0" />
    214214    <Model mesh="cube.mesh" scale=8 position="   0,2000,-2000" />
     
    259259      </controller>
    260260    </SpaceShip>
    261     -->
     261   
    262262<!-- HERE ENDS DEMO FOR FORMATIONS -->
    263263    <!--
  • code/branches/campaignHS15/src/orxonox/controllers/ActionpointController.cc

    r10882 r10883  
    4141    ActionpointController::ActionpointController(Context* context) : FightingController(context)
    4242    {
     43        this->actionCounter_ = 0;
    4344        this->bInLoop_ = false;
    4445        this->bLoop_ = false;
     
    419420            return;
    420421        // orxout (internal_error) << "Size of actions is " << this->parsedActionpoints_.size() << endl;
    421         if (this->actionCounter_ % 5 == 0)
     422        if (this->actionCounter_ % 2 == 0)
    422423            this->startAttackingEnemiesThatAreClose();
    423424        //No action -> pop one from stack
  • code/branches/campaignHS15/src/orxonox/controllers/DivisionController.cc

    r10882 r10883  
    3939    {
    4040        RegisterObject(DivisionController);
    41         this->actionCounter_ = 0;
    4241        this->setFormationMode(FormationMode::DIAMOND);
    4342        this->target_ = 0;
  • code/branches/campaignHS15/src/orxonox/controllers/FightingController.cc

    r10880 r10883  
    3838    FightingController::FightingController( Context* context ): FlyingController( context )
    3939    {
    40         this->attackRange_ = 2500;
     40        this->attackRange_ = 2000;
    4141        this->stopLookingAtTarget();
    4242
     
    129129       
    130130        //too far? well, come closer then
    131         if ( diffLength > this->attackRange_ )
    132         {
     131        if (diffLength > this->attackRange_)
     132        {
     133            this->spread_ = 300;
     134            this->formationMode_ = FormationMode::WALL;
     135            this->bKeepFormation_ = true;
     136           
    133137            this->setTargetPosition( this->positionOfTarget_ );
    134138        }
     
    136140        else if ( diffLength < 500 )
    137141        {   
     142            this->bKeepFormation_ = false;
     143
    138144            //at this point, just look and shoot
    139145            if ( diffLength < 250 )
     
    150156        else if ( !bTargetIsLookingAtThis )
    151157        {
     158            this->bKeepFormation_ = false;
    152159            this->setTargetPosition( this->positionOfTarget_ );
    153160        }
     
    155162        else
    156163        {   
     164            this->bKeepFormation_ = false;
    157165            if (maneuverCounter_ == 0)
    158166            {
  • code/branches/campaignHS15/src/orxonox/controllers/FightingController.h

    r10877 r10883  
    4949            ControllableEntity* getTarget()
    5050                { return this->target_; }
     51            bool bKeepFormation_;
    5152           
    5253        protected:
  • code/branches/campaignHS15/src/orxonox/controllers/SectionController.cc

    r10881 r10883  
    124124        else if (myDivisionLeader_)
    125125        {
    126             switch (myDivisionLeader_->getAction())
    127             {
    128                 case Action::FIGHT:
    129                 {
    130                     if (!this->hasTarget())
    131                     {
    132                         this->chooseTarget();
    133                     }
    134                     break;
    135                 }
    136                 case Action::FIGHTALL:
    137                 {
    138                     if (!this->hasTarget())
    139                     {
    140                         this->chooseTarget();
    141                     }
    142                     break;
    143                 }
    144                 case Action::ATTACK:
    145                 {
    146                     if (!this->hasTarget())
    147                     {
    148                         this->chooseTarget();
    149                     }
    150                     break;
    151                 }
    152                 default:
    153                 {
    154                     //formation flight is executed in tick
    155                     ControllableEntity* myEntity = this->getControllableEntity();
    156             Vector3 myPosition = myEntity->getWorldPosition();
    157             if (!this->myDivisionLeader_)
    158             {
    159                 return;
    160             }
    161             ControllableEntity* leaderEntity = this->myDivisionLeader_->getControllableEntity();
    162             Quaternion orient = leaderEntity->getWorldOrientation();
    163             Vector3 leaderPosition = leaderEntity->getWorldPosition();
    164 
    165             Vector3 targetRelativePosition = getFormationPosition();
    166             if (!this->myDivisionLeader_)
    167             {
    168                 return;
    169             }
    170             Vector3 targetAbsolutePosition =
    171                 (leaderPosition + (orient*WorldEntity::FRONT) * (leaderEntity->getVelocity().length()/5)
    172                  + (orient* (targetRelativePosition)));
    173             //let ship finish rotating. also don't call copyOrientation to often as it is a slow function.
    174             if (this->actionCounter_ % 9 == 0 && !this->bHasTargetOrientation_)
    175                 this->setAction (Action::FLY, targetAbsolutePosition, orient);
     126            if (this->myDivisionLeader_->bKeepFormation_ || !(this->myDivisionLeader_->getAction() == Action::FIGHT
     127                || this->myDivisionLeader_->getAction() == Action::FIGHTALL
     128                || this->myDivisionLeader_->getAction() == Action::ATTACK))
     129            {
     130                ControllableEntity* myEntity = this->getControllableEntity();
     131                Vector3 myPosition = myEntity->getWorldPosition();
     132                if (!this->myDivisionLeader_)
     133                {
     134                    return;
     135                }
     136                ControllableEntity* leaderEntity = this->myDivisionLeader_->getControllableEntity();
     137                Quaternion orient = leaderEntity->getWorldOrientation();
     138                Vector3 leaderPosition = leaderEntity->getWorldPosition();
     139
     140                Vector3 targetRelativePosition = getFormationPosition();
     141                if (!this->myDivisionLeader_)
     142                {
     143                    return;
     144                }
     145                Vector3 targetAbsolutePosition =
     146                    (leaderPosition + (orient*WorldEntity::FRONT) * (leaderEntity->getVelocity().length()/5)
     147                     + (orient* (targetRelativePosition)));
     148                //let ship finish rotating. also don't call copyOrientation to often as it is a slow function.
     149                if (this->actionCounter_ % 9 == 0 && !this->bHasTargetOrientation_)
     150                    this->setAction (Action::FLY, targetAbsolutePosition, orient);
     151                else
     152                    this->setAction (Action::FLY, targetAbsolutePosition);
     153
     154                if ((targetAbsolutePosition - myPosition).length() > this->tolerance_ * 1.5f)
     155                {
     156                    this->boostControl();
     157                }
     158                else
     159                {
     160                   this->getControllableEntity()->boost(false);
     161                }
     162            }
    176163            else
    177                 this->setAction (Action::FLY, targetAbsolutePosition);
    178 
    179             if ((targetAbsolutePosition - myPosition).length() > this->tolerance_ * 1.5f)
    180             {
    181                 this->boostControl();
    182             }
    183             else
    184             {
    185                this->getControllableEntity()->boost(false);
    186             }
    187                 }
    188             }
    189             if (this->hasTarget())
    190             {
    191                 //----choose where to go----
    192                 this->maneuver();
    193                 //----fire if you can----
    194                 this->bShooting_ = this->canFire();               
    195             }
     164            {
     165                switch (myDivisionLeader_->getAction())
     166                {
     167                    case Action::FIGHT:
     168                    {
     169                        if (!this->hasTarget())
     170                        {
     171                            this->chooseTarget();
     172                        }
     173                        break;
     174                    }
     175                    case Action::FIGHTALL:
     176                    {
     177                        if (!this->hasTarget())
     178                        {
     179                            this->chooseTarget();
     180                        }
     181                        break;
     182                    }
     183                    case Action::ATTACK:
     184                    {
     185                        if (!this->hasTarget())
     186                        {
     187                            this->chooseTarget();
     188                        }
     189                        break;
     190                    }
     191                    default:
     192                    {
     193                        //formation flight is executed in tick
     194                    }
     195                }
     196                if (this->hasTarget())
     197                {
     198                    //----choose where to go----
     199                    this->maneuver();
     200                    //----fire if you can----
     201                    this->bShooting_ = this->canFire();               
     202                }
     203            }
     204           
     205           
    196206        }
    197207        this->actionCounter_ += this->actionCounter_ < 100000 ? 1 : -this->actionCounter_ ;
     
    263273    {
    264274        this->setFormationMode( this->myDivisionLeader_->getFormationMode() );
     275        this->spread_ = this->myDivisionLeader_->getSpread();
    265276        Vector3* targetRelativePosition;
    266277        switch (this->formationMode_){
  • code/branches/campaignHS15/src/orxonox/controllers/WingmanController.cc

    r10881 r10883  
    105105        else if (this->myLeader_)
    106106        {
    107             switch (this->myLeader_->getAction())
    108             {
    109                 case Action::FIGHT:
    110                 {
    111                     if (!this->hasTarget())
    112                     {
    113                         this->setTarget(this->myLeader_->getTarget());
    114                     }
    115                     break;
    116                 }
    117                 case Action::FIGHTALL:
    118                 {
    119                     if (!this->hasTarget())
    120                     {
    121                         this->setTarget(this->myLeader_->getTarget());
    122                     }
    123                     break;
    124                 }
    125                 case Action::ATTACK:
    126                 {
    127                     if (!this->hasTarget())
    128                     {
    129                         this->setTarget(this->myLeader_->getTarget());
    130                     }
    131                     break;
    132                 }
    133                 default:
    134                 {
     107            if (this->myLeader_->bKeepFormation_ || !(this->myLeader_->getAction() == Action::FIGHT || this->myLeader_->getAction() == Action::FIGHTALL
     108                || this->myLeader_->getAction() == Action::ATTACK))
     109            {
     110                ControllableEntity* myEntity = this->getControllableEntity();
     111                Vector3 myPosition = myEntity->getWorldPosition();
     112                if (!this->myLeader_)
     113                {
     114                    return;
     115                }
     116                ControllableEntity* leaderEntity = this->myLeader_->getControllableEntity();
     117                Quaternion orient = leaderEntity->getWorldOrientation();
     118                Vector3 leaderPosition = leaderEntity->getWorldPosition();
     119                Vector3 targetRelativePosition = getFormationPosition();
     120                if (!this->myLeader_)
     121                {
     122                    return;
     123                }
     124                Vector3 targetAbsolutePosition =
     125                    (leaderPosition + (orient*WorldEntity::FRONT) * (leaderEntity->getVelocity().length()/5)
     126                     + (orient* (targetRelativePosition)));
     127                //let ship finish rotating. also don't call copyOrientation to often as it is a slow function.
     128                if (this->actionCounter_ % 9 == 0 && !this->bHasTargetOrientation_)
     129                    this->setAction (Action::FLY, targetAbsolutePosition, orient);
     130                else
     131                    this->setAction (Action::FLY, targetAbsolutePosition);
     132                if ((targetAbsolutePosition - myPosition).length() > this->tolerance_ * 1.5f)
     133                {
     134                    this->boostControl();
     135                }
     136                else
     137                {
     138                   this->getControllableEntity()->boost(false);
     139                }
     140            }
     141            else
     142            {
     143                switch (this->myLeader_->getAction())
     144                {
     145                    case Action::FIGHT:
     146                    {
     147                        if (!this->hasTarget())
     148                        {
     149                            this->setTarget(this->myLeader_->getTarget());
     150                        }
     151                        break;
     152                    }
     153                    case Action::FIGHTALL:
     154                    {
     155                        if (!this->hasTarget())
     156                        {
     157                            this->setTarget(this->myLeader_->getTarget());
     158                        }
     159                        break;
     160                    }
     161                    case Action::ATTACK:
     162                    {
     163                        if (!this->hasTarget())
     164                        {
     165                            this->setTarget(this->myLeader_->getTarget());
     166                        }
     167                        break;
     168                    }
     169                    default:
     170                    {
    135171                   
    136             ControllableEntity* myEntity = this->getControllableEntity();
    137             Vector3 myPosition = myEntity->getWorldPosition();
    138             if (!this->myLeader_)
    139             {
    140                 return;
    141             }
    142             ControllableEntity* leaderEntity = this->myLeader_->getControllableEntity();
    143             Quaternion orient = leaderEntity->getWorldOrientation();
    144             Vector3 leaderPosition = leaderEntity->getWorldPosition();
    145             Vector3 targetRelativePosition = getFormationPosition();
    146             if (!this->myLeader_)
    147             {
    148                 return;
    149             }
    150             Vector3 targetAbsolutePosition =
    151                 (leaderPosition + (orient*WorldEntity::FRONT) * (leaderEntity->getVelocity().length()/5)
    152                  + (orient* (targetRelativePosition)));
    153             //let ship finish rotating. also don't call copyOrientation to often as it is a slow function.
    154             if (this->actionCounter_ % 9 == 0 && !this->bHasTargetOrientation_)
    155                 this->setAction (Action::FLY, targetAbsolutePosition, orient);
    156             else
    157                 this->setAction (Action::FLY, targetAbsolutePosition);
    158             if ((targetAbsolutePosition - myPosition).length() > this->tolerance_ * 1.5f)
    159             {
    160                 this->boostControl();
    161             }
    162             else
    163             {
    164                this->getControllableEntity()->boost(false);
    165             }
    166                 }
    167             }
    168             if (this->hasTarget())
    169             {
    170                 //----choose where to go----
    171                 this->maneuver();
    172                 //----fire if you can----
    173                 this->bShooting_ = this->canFire();               
    174             }
     172                    }
     173                }
     174                if (this->hasTarget())
     175                {
     176                    //----choose where to go----
     177                    this->maneuver();
     178                    //----fire if you can----
     179                    this->bShooting_ = this->canFire();               
     180                }
     181            }
     182           
     183           
    175184        }
    176185        this->actionCounter_ += this->actionCounter_ < 100000 ? 1 : -this->actionCounter_ ;
     
    182191        this->setFormationMode( this->myLeader_->getFormationMode() );
    183192        Vector3* targetRelativePosition;
    184 
     193        this->spread_ = this->myLeader_->getSpread();
    185194        if (this->myLeader_->getIdentifier()->getName() == "DivisionController")
    186195        {
Note: See TracChangeset for help on using the changeset viewer.