Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 10263 in orxonox.OLD


Ignore:
Timestamp:
Jan 17, 2007, 4:27:43 PM (17 years ago)
Author:
patrick
Message:

ai is now handeled in npc, weapon manager added

Location:
branches/ai/src/world_entities/npcs
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/ai/src/world_entities/npcs/npc.cc

    r9869 r10263  
    1818
    1919
     20#include "movement_module.h"
     21#include "ai_module.h"
     22#include "ai_team.h"
     23#include "ai_swarm.h"
     24#include "ai_engine.h"
     25
     26#include "loading/load_param.h"
     27
     28
    2029#include "npc.h"
    2130
     
    2332
    2433NPC::NPC(const TiXmlElement* root)
     34  : weaponMan(this)
    2535{
    2636  this->registerObject(this, NPC::_objectList);
     
    2838  this->toList(OM_GROUP_00);
    2939
     40  std::cout << "Team Number: " << teamNumber << "\n";
     41  std::cout << "Swarm Number:" << swarmNumber << "\n";
     42  //aiModule=new MovementModule(this);
     43  //AIEngine::getInstance()->addAI(teamNumber,swarmNumber,aiModule);
     44  AIEngine::getInstance()->addAI(teamNumber,swarmNumber,(WorldEntity*)this);
     45
     46  this->bFire = false;
     47
    3048}
    3149
    3250
    33 NPC::~NPC () {}
    34 
    35 
    36 
    37 /**
    38  * adds an AI to this NPC
    39  */
    40 void NPC::addAI(AI* ai)
    41 {}
     51NPC::~NPC ()
     52{
     53  AIEngine::getInstance()->removeAI(teamNumber,swarmNumber,(WorldEntity*)this);
     54}
    4255
    4356
     
    5063{
    5164   WorldEntity::loadParams(root);
     65
     66  LoadParam(root, "team", this, NPC, setTeamNumber)
     67  .describe("this sets the team number")
     68  .defaultValues(0);
     69
     70  LoadParam(root, "swarm", this, NPC, setSwarmNumber)
     71  .describe("this sets the swarm number")
     72  .defaultValues(0);
    5273}
    5374
     75
     76void NPC::tick(float dt)
     77{
     78  this->weaponMan.tick(dt);
     79  if (this->bFire)
     80    weaponMan.fire();
     81}
  • branches/ai/src/world_entities/npcs/npc.h

    r10138 r10263  
    44
    55#include "world_entity.h"
     6#include "ai_module.h"
     7#include "world_entities/weapons/weapon_manager.h"
    68
    79class AI;
    810
    9 class NPC : public WorldEntity {
     11class NPC : public WorldEntity
     12{
    1013  ObjectListDeclaration(NPC);
    11  public:
    12    NPC (const TiXmlElement* root);
     14
     15public:
     16  NPC(const TiXmlElement* root = NULL);
    1317  virtual ~NPC ();
    1418
    1519  virtual void loadParams(const TiXmlElement* root = NULL);
    1620
    17   void addAI(AI* ai);
     21  virtual void tick(float dt);
     22  inline int getTeam()  { return teamNumber; }
     23
     24
     25private:
     26  inline void setTeamNumber(int number) { teamNumber=number; }
     27  inline void setSwarmNumber(int number) { swarmNumber=number; }
    1828
    1929
    2030 private:
    2131
     32  int                   teamNumber;   //!< number of the team
     33  int                   swarmNumber;  //!< number of the swarm
     34  int                   difficulty;   //!< difficulty
     35
     36  WeaponManager         weaponMan;    //!< weapon manager
     37  bool                  bFire;        //!< fire
     38
     39  AIModule*             aiModule;
    2240};
    2341
  • branches/ai/src/world_entities/npcs/npc_test.cc

    r10226 r10263  
    3232
    3333#include "class_id_DEPRECATED.h"
    34 #include "movement_module.h"
    35 #include "ai_module.h"
    36 #include "ai_team.h"
    37 #include "ai_swarm.h"
    38 #include "ai_engine.h"
     34
    3935
    4036ObjectListDefinitionID(NPC2, CL_NPC_TEST2);
     
    4238
    4339
    44 NPC2::NPC2(const TiXmlElement* root) : NPC(NULL)
     40NPC2::NPC2(const TiXmlElement* root)
    4541{
    46         this->registerObject(this, NPC2::_objectList);
     42  this->registerObject(this, NPC2::_objectList);
    4743
    48         if (root != NULL)
    49                 this->loadParams(root);
     44  if (root != NULL)
     45    this->loadParams(root);
    5046
    51         std::cout << "Team Number: " << teamNumber << "\n";
    52         std::cout << "Swarm Number:" << swarmNumber << "\n";
    53         //aiModule=new MovementModule(this);
    54         //AIEngine::getInstance()->addAI(teamNumber,swarmNumber,aiModule);
    55         AIEngine::getInstance()->addAI(teamNumber,swarmNumber,(WorldEntity*)this);
     47
     48  // create the weapons and their manager
     49
    5650}
    5751
    5852NPC2::~NPC2()
    5953{
    60         AIEngine::getInstance()->removeAI(teamNumber,swarmNumber,(WorldEntity*)this);
    6154}
    6255
     
    6558  NPC::loadParams(root);
    6659
    67   LoadParam(root, "team", this, NPC2, setTeamNumber)
    68                 .describe("this sets the team number")
    69                 .defaultValues(0);
    70 
    71   LoadParam(root, "swarm", this, NPC2, setSwarmNumber)
    72                 .describe("this sets the swarm number")
    73                 .defaultValues(0);
    7460}
    7561
     
    7864void NPC2::tick(float dt)
    7965{
    80         // animating the md2 model
    81         if( likely(this->getModel(0) != NULL) && this->getModel(0)->isA(MD2Model::staticClassID()))
    82                 ((MD2Model*)this->getModel(0))->tick(dt);
     66
     67
     68
     69
     70  // animating the md2 model
     71  if( likely(this->getModel(0) != NULL) && this->getModel(0)->isA(MD2Model::staticClassID()))
     72    ((MD2Model*)this->getModel(0))->tick(dt);
    8373}
    8474
  • branches/ai/src/world_entities/npcs/npc_test.h

    r10138 r10263  
    44
    55#include "npc.h"
    6 #include "ai_module.h"
     6
     7
    78
    89class AI;
     
    1011class AIModule;
    1112
    12 class NPC2 : public NPC {
    13         ObjectListDeclaration(NPC2);
     13class NPC2 : public NPC
     14{
     15  ObjectListDeclaration(NPC2);
    1416
    15         public:
    16                 NPC2 (const TiXmlElement* root);
    17                 virtual ~NPC2 ();
    18                 virtual void loadParams(const TiXmlElement* root);
    19                 virtual void tick(float dt);
    20                 inline int getTeam(){return teamNumber;}
     17public:
     18  NPC2 (const TiXmlElement* root);
     19  virtual ~NPC2 ();
     20  virtual void loadParams(const TiXmlElement* root);
     21  virtual void tick(float dt);
    2122
    2223
    23         private:
    24                 inline void setTeamNumber(int number){teamNumber=number;}
    25                 inline void setSwarmNumber(int number){swarmNumber=number;}
    2624
    27                 int teamNumber;
    28                 int swarmNumber;
    29                 int difficulty;
    3025
    31                 AIModule* aiModule;
     26private:
     27
    3228};
    3329
Note: See TracChangeset for help on using the changeset viewer.