Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 10903 for code


Ignore:
Timestamp:
Nov 30, 2015, 5:39:43 PM (9 years ago)
Author:
gania
Message:

AI attacks targets that are close

Location:
code/branches/campaignHS15
Files:
4 edited

Legend:

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

    r10898 r10903  
    158158   
    159159
    160     <SpaceShip position="-4000, 1500, -1000" lookat="0,0,0" team=0 name="ss2">
     160    <SpaceShip position="-4000, 1500, -1000" lookat="0,0,0" team=0 name="d1sd1">
    161161      <templates>
    162162        <Template link=spaceshipassff />
     
    168168      </controller>
    169169    </SpaceShip>
    170     <SpaceShip position="-4000, 1900, -1000" lookat="0,0,0" team=0>
     170    <SpaceShip position="-4000, 1900, -1000" lookat="0,0,0" team=0 name="d1ss1">
    171171      <templates>
    172172        <Template link=spaceshipassff />
     
    177177      </controller>
    178178    </SpaceShip>
    179     <SpaceShip position="-4000, 2100, -1000" lookat="0,0,0" team=0>
    180       <templates>
    181         <Template link=spaceshipassff />
    182       </templates>
    183       <controller>
    184         <WingmanController team=0>
    185         </WingmanController>
    186       </controller>
    187     </SpaceShip>
    188     <SpaceShip position="-4000, 2400, -1000" lookat="0,0,0" team=0>
    189       <templates>
    190         <Template link=spaceshipassff />
    191       </templates>
    192       <controller>
    193         <WingmanController team=0>
    194         </WingmanController>
    195       </controller>
    196     </SpaceShip>
    197     <SpaceShip position="-4000, 1500, -3000" lookat="0,0,0" team=0>
    198       <templates>
    199         <Template link=spaceshipassff />
    200       </templates>
    201       <controller>
    202         <DivisionController team=0 formationMode="WALL">
    203 
    204         </DivisionController>
    205       </controller>
    206     </SpaceShip>
    207     <SpaceShip position="-4000, 1900, -3000" lookat="0,0,0" team=0>
    208       <templates>
    209         <Template link=spaceshipassff />
    210       </templates>
    211       <controller>
    212         <SectionController team=0>
    213         </SectionController>
    214       </controller>
    215     </SpaceShip>
    216 
    217 
    218     <SpaceShip position="2000, -1500, 1000" lookat="0,0,0" team=1 >
     179    <SpaceShip position="-4000, 2100, -1000" lookat="0,0,0" team=0 name="d1sw1">
     180      <templates>
     181        <Template link=spaceshipassff />
     182      </templates>
     183      <controller>
     184        <WingmanController team=0>
     185        </WingmanController>
     186      </controller>
     187    </SpaceShip>
     188    <SpaceShip position="-4000, 2400, -1000" lookat="0,0,0" team=0 name="d1sw2">
     189      <templates>
     190        <Template link=spaceshipassff />
     191      </templates>
     192      <controller>
     193        <WingmanController team=0>
     194        </WingmanController>
     195      </controller>
     196    </SpaceShip>
     197
     198    <SpaceShip position="2000, -1500, 1000" lookat="0,0,0" team=1  name="d2sd1">
    219199      <templates>
    220200        <Template link=spaceshipassff />
     
    226206      </controller>
    227207    </SpaceShip>
    228     <SpaceShip position="2000, -1900, 1000" lookat="0,0,0" team=1>
     208    <SpaceShip position="2000, -1900, 1000" lookat="0,0,0" team=1 name="d2ss1">
    229209      <templates>
    230210        <Template link=spaceshipassff />
     
    235215      </controller>
    236216    </SpaceShip>
    237     <SpaceShip position="2000, -2100, 1000" lookat="0,0,0" team=1>
     217    <SpaceShip position="2000, -2100, 1000" lookat="0,0,0" team=1 name="d2sw1">
    238218      <templates>
    239219        <Template link=spaceshipassff />
     
    244224      </controller>
    245225    </SpaceShip>
    246     <SpaceShip position="2000, -2400, 1000" lookat="0,0,0" team=1>
     226    <SpaceShip position="2000, -2400, 1000" lookat="0,0,0" team=1 name="d2sw2">
    247227      <templates>
    248228        <Template link=spaceshipassff />
  • code/branches/campaignHS15/src/orxonox/controllers/ActionpointController.cc

    r10898 r10903  
    119119        if (!this->getControllableEntity() || !orxonox_cast<Pawn*> (this->getControllableEntity()))
    120120            return;
     121            this->startAttackingEnemiesThatAreClose();
    121122
    122123        this->deltaHp = orxonox_cast<Pawn*> (this->getControllableEntity())->getHealth() - this->previousHp;
     
    132133            //     this->parsedActionpoints_.push_back(point);
    133134            // }
    134             this->startAttackingEnemiesThatAreClose();
    135135
    136136            if (this->parsedActionpoints_.empty() && this->loopActionpoints_.empty())
     
    146146        if (this->action_ == Action::FIGHTALL)
    147147        {
     148
    148149            if (!this->hasTarget())
    149150            {
     
    170171        else if (this->action_ == Action::FIGHT)
    171172        {
    172             if (!this->hasTarget())
     173
     174            if (!this->hasTarget() )
    173175            {
    174176                //----find a target----
     
    210212        else if (this->action_ == Action::FLY)
    211213        {
    212             this->startAttackingEnemiesThatAreClose();           
    213214            if (this->squaredDistanceToTarget() <= this->squaredaccuracy_)
    214215            {
     
    219220        else if (this->action_ == Action::PROTECT)
    220221        {
    221             this->startAttackingEnemiesThatAreClose();           
    222222            if (!this->getProtect())
    223223            {
     
    229229        else if (this->action_ == Action::ATTACK)
    230230        {   
    231             this->startAttackingEnemiesThatAreClose();           
     231
    232232            if (!this->hasTarget())
    233233            {
     
    620620    void ActionpointController::startAttackingEnemiesThatAreClose()
    621621    {
    622         if (this->action_ != Action::FIGHT && this->action_ != Action::FIGHTALL)
     622        //if (this->action_ != Action::FIGHT && this->action_ != Action::FIGHTALL)
    623623        {
    624624            if (!this->target_ || (this->target_ && CommonController::distance (this->getControllableEntity(), this->target_) > this->attackRange_))
     
    636636                    else
    637637                    {
     638                        //orxout (internal_error) << "found new target " << CommonController::getName(newTarget) <<endl;
    638639                        Point p = { Action::FIGHT, CommonController::getName(newTarget), Vector3::ZERO, false };
    639640                        this->parsedActionpoints_.push_back(p);
  • code/branches/campaignHS15/src/orxonox/controllers/FightingController.cc

    r10898 r10903  
    3737#include "weaponsystem/Weapon.h"
    3838#include "weaponsystem/WeaponSlot.h"
    39 #include "weaponsystem/WeaponSlot.h"
     39#include "weaponsystem/WeaponSystem.h"
     40#include "weaponsystem/Munition.h"
     41
    4042namespace orxonox
    4143{
     
    139141        }
    140142        //too close? How do u expect to dodge anything? Just attack!
    141         else if (diffLength < 400)
     143        else if (diffLength < 1000)
    142144        {   
    143145            this->bKeepFormation_ = false;
    144146
    145147            //at this point, just look and shoot
    146             if (diffLength < 200)
     148            if (diffLength < 500)
    147149            {
    148150                this->stopMoving();
     
    151153            else
    152154            {
    153                 this->setTargetPosition(this->positionOfTarget_ - diffUnit * 100.0f);
     155                this->setTargetPosition(this->positionOfTarget_ - diffUnit * 300.0f);
    154156            }
    155157        }
     
    158160        {
    159161            this->bKeepFormation_ = false;
    160             this->setTargetPosition(this->positionOfTarget_ - diffUnit * 100.0f);
     162            this->setTargetPosition(this->positionOfTarget_ - diffUnit * 300.0f);
    161163        }
    162164        //That's unfortunate, he is looking and probably shooting... try to dodge what we can... 
     
    166168            if (maneuverCounter_ == 0)
    167169            {
    168                 this->setTargetPosition(this->positionOfTarget_ - diffUnit * 50.0f);   
     170                this->setTargetPosition(this->positionOfTarget_ - diffUnit * 100.0f);   
    169171                return;
    170172            }
    171             dodge(thisPosition, diffUnit);
     173            if (this->actionCounter_ % 3 == 0)
     174                dodge(thisPosition, diffUnit);
    172175        }
    173176    }
     
    365368                    {
    366369                        std::string wName = wMode->getIdentifier()->getName();
     370                        // SubclassIdentifier<Munition> munition =  ClassByString(wName);
    367371                        if (wName == "RocketFire")
    368372                            this->rocketsLeft_ = 10;
     373                            // this->rocketsLeft_ = orxonox_cast<Pawn*>(this->getControllableEntity())->getWeaponSystem()->getMunition(&munition)->getNumMunitionInCurrentMagazine(wMode);
    369374                        if(this->getFiremode(wName) == -1) //only add a weapon, if it is "new"
    370375                            weaponModes_[wName] = wMode->getMode();
     
    375380            }//pawn->weaponSystem_->getMunition(SubclassIdentifier< Munition > *identifier)->getNumMunition (WeaponMode *user);
    376381        }
     382
     383        //orxout (internal_error) << this->rocketsLeft_ << " rockets left" << endl;
    377384    }
    378385
  • code/branches/campaignHS15/src/orxonox/worldentities/pawns/Pawn.h

    r10437 r10903  
    194194            const std::string& getExplosionSound();
    195195
     196            virtual const WeaponSystem* getWeaponSystem() const
     197                { return this->weaponSystem_; }
     198
    196199        protected:
    197200            virtual void preDestroy();
Note: See TracChangeset for help on using the changeset viewer.