Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 10499 in orxonox.OLD for trunk/src/world_entities


Ignore:
Timestamp:
Jan 30, 2007, 11:32:00 AM (18 years ago)
Author:
patrick
Message:

enable ai and weapon stuff

Location:
trunk/src/world_entities
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/world_entities/npcs/npc.cc

    r10498 r10499  
    3737#include "track/track.h"
    3838
     39
     40#include "weapons/test_gun.h"
     41#include "weapons/light_blaster.h"
     42#include "weapons/medium_blaster.h"
     43#include "weapons/heavy_blaster.h"
     44#include "weapons/swarm_launcher.h"
     45#include "weapons/spike_launcher.h"
     46#include "weapons/spike_thrower.h"
     47#include "weapons/acid_launcher.h"
     48#include "weapons/boomerang_gun.h"
     49#include "weapons/turret.h"
     50#include "weapons/cannon.h"
    3951
    4052#include "npc.h"
     
    6375  this->bAIEnabled = false;
    6476
     77
     78
     79   // create the weapons and their manager
     80  Weapon* wpRight1 = new LightBlaster ();
     81  wpRight1->setName( "LightBlaster");
     82  Weapon* wpLeft1 = new LightBlaster ();
     83  wpLeft1->setName( "LightBlaster");
     84
     85  Weapon* wpRight2 = new MediumBlaster ();
     86  wpRight2->setName( "MediumBlaster");
     87  Weapon* wpLeft2 = new MediumBlaster ();
     88  wpLeft2->setName( "MediumBlaster");
     89
     90  Weapon* wpRight3 = new HeavyBlaster (1);
     91  wpRight3->setName( "HeavyBlaster");
     92  Weapon* wpLeft3 = new HeavyBlaster (0);
     93  wpLeft3->setName( "HeavyBlaster");
     94
     95  Weapon* cannon = new SwarmLauncher();
     96  cannon->setName( "SwarmLauncher");
     97
     98  Weapon* spike = new SpikeThrower();
     99  spike->setName( "SpikeThrower" );
     100
     101
     102  Weapon* acid0 = new AcidLauncher();
     103  acid0->setName( "AcidSplasher" );
     104
     105  Weapon* acid1 = new AcidLauncher();
     106  acid1->setName( "AcidSplasher" );
     107
     108
     109  this->weaponMan.addWeapon( wpLeft1, 0, 0);
     110  this->weaponMan.addWeapon( wpRight1, 0, 1);
     111
     112  this->weaponMan.addWeapon( wpLeft2, 1, 2);
     113  this->weaponMan.addWeapon( wpRight2, 1, 3);
     114
     115  this->weaponMan.addWeapon( wpLeft3, 2, 4);
     116  this->weaponMan.addWeapon( wpRight3, 2, 5);
     117/*
     118  this->weaponMan.addWeapon( wpLeft1, 3, 0);
     119  this->weaponMan.addWeapon( wpRight1, 3, 1);
     120
     121  this->weaponMan.addWeapon( wpLeft2, 3, 2);
     122  this->weaponMan.addWeapon( wpRight2, 3, 3);
     123
     124  this->weaponMan.addWeapon( wpLeft3, 3, 4);
     125  this->weaponMan.addWeapon( wpRight3, 3, 5);
     126*/
     127
     128  this->weaponMan.addWeapon( acid0, 3, 0);
     129  this->weaponMan.addWeapon( acid1, 3, 1);
     130
     131
    65132  if( root != NULL)
    66133    this->loadParams(root);
     
    81148  }
    82149
    83     // create the weapons and their manager
    84 
    85 
    86   this->getWeaponManager().changeWeaponConfig(1);
    87 //   Weapon* wpRight = new TestGun(0);
    88 //   wpRight->setName("testGun Right");
    89 //   Weapon* wpLeft = new TestGun(1);
    90 //   wpLeft->setName("testGun Left");
    91 //
    92 //   wpRight->toList( this->getOMListNumber());
    93 //   wpLeft->toList( this->getOMListNumber());
    94 //
    95 //
    96 //   this->addWeapon(wpLeft, 1, 0);
    97 //   this->addWeapon(wpRight,1 ,1);
    98 //
    99 //   wpLeft->increaseEnergy( 100);
    100 //   wpRight->increaseEnergy( 100);
     150
     151
     152
     153//   this->secWeaponMan.addWeapon( acid0, 2, 2);
     154//   this->secWeaponMan.addWeapon( acid1, 2, 3);
     155
     156
     157//   this->weaponMan.changeWeaponConfig(3);
     158
     159//   this->getWeaponManager().changeWeaponConfig(1);
    101160
    102161  this->setHealthMax(100);
    103162  this->setHealth(80);
    104163
    105 //   this->getWeaponManager().setSlotCount(7);
    106 //
    107 //   this->getWeaponManager().setSlotPosition(0, Vector(-2.6, .1, -3.0));
    108 //   this->getWeaponManager().setSlotCapability(0, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL);
    109 //
    110 //   this->getWeaponManager().setSlotPosition(1, Vector(-2.6, .1, 3.0));
    111 //   this->getWeaponManager().setSlotCapability(1, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL);
    112 //
    113 //   this->getWeaponManager().setSlotPosition(2, Vector(-1.5, .5, -.5));
    114 //   this->getWeaponManager().setSlotDirection(2, Quaternion(-M_PI_4*.5, Vector(1,0,0)));
    115 //
    116 //   this->getWeaponManager().setSlotPosition(3, Vector(-1.5, .5, .5));
    117 //   this->getWeaponManager().setSlotDirection(3, Quaternion(M_PI_4*.5, Vector(1,0,0)));
    118 //
    119 //   this->getWeaponManager().setSlotPosition(4, Vector(-1.5, -.5, .5));
    120 //   this->getWeaponManager().setSlotDirection(4, Quaternion(-M_PI_4*.5+M_PI, Vector(1,0,0)));
    121 //
    122 //   this->getWeaponManager().setSlotPosition(5, Vector(-1.5, -.5, -.5));
    123 //   this->getWeaponManager().setSlotDirection(5, Quaternion(+M_PI_4*.5-M_PI, Vector(1,0,0)));
    124 //
    125 //   this->getWeaponManager().setSlotPosition(6, Vector(-1, 0.0, 0));
    126 //   this->getWeaponManager().setSlotCapability(6, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL);
    127 //
    128 //   this->getWeaponManager().getFixedTarget()->setParent(this);
    129 //   this->getWeaponManager().getFixedTarget()->setRelCoor(100000,0,0);
     164  this->getWeaponManager().setSlotCount(7);
     165
     166  this->getWeaponManager().setSlotPosition(0, Vector(-2.6, .1, -3.0));
     167  this->getWeaponManager().setSlotCapability(0, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL);
     168
     169  this->getWeaponManager().setSlotPosition(1, Vector(-2.6, .1, 3.0));
     170  this->getWeaponManager().setSlotCapability(1, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL);
     171
     172  this->getWeaponManager().setSlotPosition(2, Vector(-1.5, .5, -.5));
     173  this->getWeaponManager().setSlotDirection(2, Quaternion(-M_PI_4*.5, Vector(1,0,0)));
     174
     175  this->getWeaponManager().setSlotPosition(3, Vector(-1.5, .5, .5));
     176  this->getWeaponManager().setSlotDirection(3, Quaternion(M_PI_4*.5, Vector(1,0,0)));
     177
     178  this->getWeaponManager().setSlotPosition(4, Vector(-1.5, -.5, .5));
     179  this->getWeaponManager().setSlotDirection(4, Quaternion(-M_PI_4*.5+M_PI, Vector(1,0,0)));
     180
     181  this->getWeaponManager().setSlotPosition(5, Vector(-1.5, -.5, -.5));
     182  this->getWeaponManager().setSlotDirection(5, Quaternion(+M_PI_4*.5-M_PI, Vector(1,0,0)));
     183
     184  this->getWeaponManager().setSlotPosition(6, Vector(-1, 0.0, 0));
     185  this->getWeaponManager().setSlotCapability(6, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL);
     186
     187  this->getWeaponManager().getFixedTarget()->setParent(this);
     188  this->getWeaponManager().getFixedTarget()->setRelCoor(100000,0,0);
    130189
    131190
     
    170229  .defaultValues(0);
    171230
    172   LoadParamXML(root, "Weapons", this, NPC, addWeapons)
    173   .describe("creates and adds weapons");
    174 }
    175 
     231  LoadParam(root, "weapon-config", this, NPC, setWeaponConfig);
     232
     233//   LoadParamXML(root, "Weapons", this, NPC, addWeapons)
     234//   .describe("creates and adds weapons");
     235}
     236
     237
     238void NPC::setWeaponConfig(int i)
     239{
     240  this->weaponMan.changeWeaponConfig(i);
     241}
    176242
    177243void NPC::addWeapons(const TiXmlElement* root)
     
    260326void NPC::tick(float dt)
    261327{
    262         //std::cout << "fire..\n";
    263328  this->weaponMan.tick(dt);
    264329  if (this->bFire)
     330  {
     331    std::cout << "fire..\n";
    265332    weaponMan.fire();
     333  }
    266334  this->bFire = false;
    267335
  • trunk/src/world_entities/npcs/npc.h

    r10447 r10499  
    2626  void previousWeaponConfig();
    2727  inline WeaponManager& getWeaponManager() { return this->weaponMan; };
     28void setWeaponConfig(int i);
    2829
    2930
     
    3334  inline void fire(){ this->bFire=true;}
    3435
    35   inline void enableAI() { this->bAIEnabled = true; }
     36  inline void enableAI(int flag) { this->bAIEnabled = (bool)flag; }
    3637
    3738private:
  • trunk/src/world_entities/weapons/heavy_blaster.cc

    r10472 r10499  
    1212
    1313CREATE_FACTORY(HeavyBlaster);
     14// ObjectListDefinition(HeavyBlaster);
     15
     16
     17
    1418/**
    1519 * Standard constructor
     
    1822 : Weapon()
    1923{
     24//     this->registerObject(this, HeavyBlaster::_objectList);
     25
    2026    this->init(leftRight);
    2127}
     
    2430 : Weapon()
    2531{
     32//     this->registerObject(this, HeavyBlaster::_objectList);
     33
    2634    // TODO add leftRight to params
    2735    this->init(0);
  • trunk/src/world_entities/weapons/heavy_blaster.h

    r10368 r10499  
    1010/**
    1111 *      @author Marc Schaerer <marcscha@ee.ethz.ch>
    12  * 
     12 *
    1313 *  Heavy Blaster class
    1414 */
    1515class HeavyBlaster : public Weapon
    1616{
    17   //ObjectListDeclaration(HeavyBlaster);
     17//   ObjectListDeclaration(HeavyBlaster);
    1818  public:
    1919    HeavyBlaster(int leftRight);
Note: See TracChangeset for help on using the changeset viewer.