Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 8757 for code/branches


Ignore:
Timestamp:
Jul 13, 2011, 9:42:03 PM (13 years ago)
Author:
jo
Message:

ai && weapons. Trying to identify each weapon installed on a spaceship.

Location:
code/branches/ai2
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • code/branches/ai2/data/levels/includes/weaponSettingsSwallow.oxi

    r7679 r8757  
    1414        </links>
    1515        <Weapon>
    16           <HsW01 mode=0 munitionpershot=0 delay=0 material="Flares/point_lensflare" />
    17           <HsW01 mode=0 munitionpershot=0 delay=0.125 material="Flares/point_lensflare" muzzleoffset=" 0.5,0.6,1.7" />
    18           <LightningGun mode=1 muzzleoffset="0,0,0" />
     16          <HsW01 mode=0 munitionpershot=0 delay=0 damage=3.14159 material="Flares/point_lensflare" />
     17          <HsW01 mode=0 munitionpershot=0 delay=0.125 damage=3.14159 material="Flares/point_lensflare" muzzleoffset=" 0.5,0.6,1.7" />
     18
     19          <LightningGun mode=1 muzzleoffset="0,0,0" damage=3.14159 shielddamage=20/>
    1920        </Weapon>
    2021        <Weapon>
    21           <HsW01 mode=0 munitionpershot=0 delay=0  material="Flares/point_lensflare" />
    22           <HsW01 mode=0 munitionpershot=0 delay=0.125 material="Flares/point_lensflare" muzzleoffset="-0.5,0.6,1.7" />
    23           <LightningGun mode=1 muzzleoffset="0,0,0" />
     22          <HsW01 mode=0 munitionpershot=0 delay=0  damage=3.14159 material="Flares/point_lensflare" />
     23          <HsW01 mode=0 munitionpershot=0 delay=0.125 damage=3.14159 material="Flares/point_lensflare" muzzleoffset="-0.5,0.6,1.7" />
     24          <LightningGun mode=1 muzzleoffset="0,0,0" damage=3.14159 shielddamage=20/>
    2425        </Weapon>
    2526      </WeaponPack>
  • code/branches/ai2/src/modules/weapons/weaponmodes/EnergyDrink.cc

    r8706 r8757  
    5757        this->delayTimer_.setTimer(1.0f, false, createExecutor(createFunctor(&EnergyDrink::shot, this)));
    5858        this->delayTimer_.stopTimer();
     59        this->setName("ENERGY_DRINK");
    5960    }
    6061
  • code/branches/ai2/src/modules/weapons/weaponmodes/FusionFire.cc

    r8706 r8757  
    5252
    5353        this->setMunitionName("FusionMunition");
     54        this->setName("FUSION_FIRE");
    5455    }
    5556
  • code/branches/ai2/src/modules/weapons/weaponmodes/HsW01.cc

    r8706 r8757  
    6060
    6161        this->setDefaultSound("sounds/Weapon_HsW01.ogg");
     62        this->setName("HSW01");
    6263    }
    6364
  • code/branches/ai2/src/modules/weapons/weaponmodes/LaserFire.cc

    r8706 r8757  
    4949
    5050        this->setMunitionName("LaserMunition");
     51        this->setName("LASER_FIRE");
    5152    }
    5253
  • code/branches/ai2/src/modules/weapons/weaponmodes/LightningGun.cc

    r8706 r8757  
    5050        this->setMunitionName("LaserMunition");
    5151        this->setDefaultSound("sounds/Weapon_LightningGun.ogg");
     52        this->setName("LIGHTNING_GUN");
    5253    }
    5354
  • code/branches/ai2/src/modules/weapons/weaponmodes/RocketFire.cc

    r8706 r8757  
    5252
    5353        this->setMunitionName("RocketMunition");
     54        this->setName("RocketFire");
    5455        // The firing sound of the Rocket is played in Rocket.cc (because of OpenAl sound positioning)
    5556    }
  • code/branches/ai2/src/modules/weapons/weaponmodes/SimpleRocketFire.cc

    r8706 r8757  
    5555        this->setMunitionName("RocketMunition");
    5656        this->setDefaultSoundWithVolume("sounds/Rocket_launch.ogg",0.4f);
     57        this->setName("SimpleRocketFire");
    5758        // The firing sound of the Rocket is played in Rocket.cc (because of OpenAl sound positioning)
    5859    }
  • code/branches/ai2/src/orxonox/controllers/ArtificialController.cc

    r8736 r8757  
    3333
    3434#include "util/Math.h"
     35#include "util/Convert.h"
    3536#include "core/CoreIncludes.h"
    3637#include "core/XMLPort.h"
     
    10471048            float random = rnd(1);//
    10481049            if (this->isCloseAtTarget(130) && weapons[1] )
    1049             {//LENSFLARE: short range weapon     
     1050            {//LENSFLARE: short range weapon
    10501051                this->getControllableEntity()->fire(1); //ai uses lens flare if they're close enough to the target
    10511052            }
     
    10801081            if(pawn)
    10811082            {
     1083                this->analyseWeapons(pawn);
    10821084                for(unsigned int i=0; i < WeaponSystem::MAX_WEAPON_MODES; i++)
    10831085                {
    1084                     const std::string wpn = getWeaponname(i, pawn); COUT(0)<<wpn<< std::endl;//Temporary debug info.
     1086                    //const std::string wpn = getWeaponname(i, 0, pawn); COUT(0)<<wpn<< std::endl;//Temporary debug info.
    10851087                    /*if(wpn=="") //future, more generic implementation; until now, only LaserMunition works. Is this a bug??
    10861088                        weapons[i]=false;
     
    11101112    }
    11111113
    1112     const std::string& ArtificialController::getWeaponname(int i, Pawn* pawn)
     1114    const std::string ArtificialController::getWeaponname(int i, int u, Pawn* pawn)//Search through all wPacks,
    11131115    {//is there a way to minimize this long if-return structure, without triggering nullpointer exceptions?
    1114         if(!pawn) return "";
    1115         WeaponPack* wPack = pawn->getWeaponPack(i);
    1116         if(!wPack) return "";
     1116        if(!pawn) return "a";
     1117        WeaponPack* wPack = pawn->getWeaponPack(u);
     1118        if(!wPack) return "b";
    11171119        Weapon* wpn = wPack->getWeapon(i);
    1118         if(!wpn) return "";
    1119         WeaponMode* wMode = wpn->getWeaponmode(i);
    1120         if(!wMode) return "";
    1121         return wMode->getMunitionName();
     1120        if(!wpn && u<10 && i>0)
     1121        {
     1122            return this->getWeaponname(i, u+1, pawn);
     1123        }
     1124        else if(!wpn)
     1125            return "c";
     1126        //return wpn->getName();
     1127        WeaponMode* wMode = wpn->getWeaponmode(0);
     1128        if(!wMode) return "d";
     1129        return wMode->getMunitionName();//getName();
    11221130    }//pawn->getWeaponpack(i)->getWeapon(i)->getWeaponmode(i)->getMunitionName()
    1123 
    1124    
     1131    /**
     1132        @brief Display how a spaceship is equiped with weapons. TODO: why are only 3 out of 8 weapons displayed??
     1133    */
     1134    void ArtificialController::analyseWeapons(Pawn* pawn)
     1135    {
     1136        int max=10, i=0, j=0, k=0;
     1137        if(!pawn) {COUT(0)<<"NO PAWN"<<std::endl; return;}
     1138        while(i<max)
     1139        {
     1140            WeaponPack* wPack = pawn->getWeaponPack(i); //WeaponSet* wSet = pawn->getWeaponSet(i);
     1141            i++;
     1142            if(wPack==NULL) continue;
     1143            while(j<max)
     1144            {
     1145                Weapon* wpn = wPack->getWeapon(j);
     1146                j++;
     1147                if(wpn==NULL) continue;
     1148                while(k<max)
     1149                {
     1150                    WeaponMode* wMode = wpn->getWeaponmode(k);
     1151                    k++;
     1152                    if(wMode==NULL) continue;
     1153                    COUT(0)<<wMode->getName()<<": weaponpack "+multi_cast<std::string>(i-1)<<", weapon "<<multi_cast<std::string>(j-1)<<", weaponmode "<<multi_cast<std::string>(k-1)<<std::endl;
     1154                }
     1155            }
     1156        }
     1157    }
     1158
     1159
    11251160    void ArtificialController::setBotLevel(float level)
    11261161    {
    11271162        if (level < 0.0f)
    1128             this->botlevel_ = 0.0f; 
     1163            this->botlevel_ = 0.0f;
    11291164        else if (level > 1.0f)
    11301165            this->botlevel_ = 1.0f;
     
    11321167            this->botlevel_ = level;
    11331168    }
    1134    
     1169
    11351170    void ArtificialController::setAllBotLevel(float level)
    11361171    {
     
    11431178        this->mode_ = DEFAULT; //Vector-implementation: mode_.pop_back();
    11441179    }
    1145    
     1180
    11461181    void ArtificialController::boostControl()
    11471182    {
  • code/branches/ai2/src/orxonox/controllers/ArtificialController.h

    r8741 r8757  
    8080
    8181            virtual void doFire();
    82             void setBotLevel(float level=1.0f);
    83             inline float getBotLevel() const
     82            void setBotLevel(float level=1.0f);
     83            inline float getBotLevel() const
    8484                { return this->botlevel_; }
    8585            static void setAllBotLevel(float level);
     
    157157            enum Mode {DEFAULT, ROCKET, DEFENCE, MOVING};//TODO; implement DEFENCE, MOVING modes
    158158            Mode mode_; //TODO: replace single value with stack-like implementation: std::vector<Mode> mode_;
    159             void setPreviousMode(); 
     159            void setPreviousMode();
    160160            void setupWeapons(); //<! Defines which weapons are available for a bot. Is recalled whenever a bot was killed.
    161             const std::string& getWeaponname(int i, Pawn* pawn); //<! Function that links a weapon's firemode to its name.
     161            const std::string getWeaponname(int i, int u, Pawn* pawn); //<! Function that links a weapon's firemode to its name.
     162            void analyseWeapons(Pawn* pawn);
    162163            bool bSetupWorked; //<! If false, setupWeapons() is called.
    163164    };
Note: See TracChangeset for help on using the changeset viewer.