Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 10440 in orxonox.OLD for trunk/src/world_entities/npcs


Ignore:
Timestamp:
Jan 28, 2007, 2:09:09 PM (18 years ago)
Author:
patrick
Message:

making weapons loadable

Location:
trunk/src/world_entities/npcs
Files:
2 edited

Legend:

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

    r10439 r10440  
    3434#include "debug.h"
    3535#include "loading/load_param.h"
     36#include "util/loading/load_param_xml.h"
    3637#include "track/track.h"
    3738
     
    5859
    5960  this->toList(OM_GROUP_01);
     61  this->bAIEnabled = false;
    6062
    6163  if( root != NULL)
    62           this->loadParams(root);
    63 
    64   std::cout << "Team Number: " << teamNumber << "\n";
    65   std::cout << "Swarm Number:" << swarmNumber << "\n";
    66 
    67 //add to track
    68   if(this->entityTrack)
    69     this->setParent(this->entityTrack->getTrackNode());
    70   else
    71   AIEngine::getInstance()->addAI(teamNumber,swarmNumber,(WorldEntity*)this,maxSpeed,attackDistance);
     64    this->loadParams(root);
     65
     66  if( this->bAIEnabled)
     67  {
     68    std::cout << "Team Number: " << teamNumber << "\n";
     69    std::cout << "Swarm Number:" << swarmNumber << "\n";
     70
     71    if( this->entityTrack)
     72      this->setParent(this->entityTrack->getTrackNode());
     73    else
     74      AIEngine::getInstance()->addAI(teamNumber,swarmNumber,(WorldEntity*)this,maxSpeed,attackDistance);
     75  }
    7276
    7377  this->bFire = false;
     
    123127
    124128
    125  
     129
    126130
    127131}
     
    144148   WorldEntity::loadParams(root);
    145149
     150  LoadParam(root, "enableAI", this, NPC, enableAI)
     151      .describe("enables the AI algorithms");
     152
    146153  LoadParam(root, "team", this, NPC, setTeamNumber)
    147154  .describe("this sets the team number")
     
    159166  .describe("this sets the NPC distance to target")
    160167  .defaultValues(0);
     168
     169
     170    // Track
     171  LoadParamXML(root, "Weapons", this, NPC, addWeapons)
     172  .describe("creates and adds weapons");
     173}
     174
     175
     176void NPC::addWeapons(const TiXmlElement* root)
     177{
     178  if( root == NULL)
     179    return;
     180
     181  LOAD_PARAM_START_CYCLE(root, element);
     182  {
     183    PRINTF(0)("got weapon: %s\n", element->Value());
     184    BaseObject* obj = Factory::fabricate(element);
     185    if( obj != NULL && obj->isA( Weapon::staticClassID()))
     186    {
     187      PRINTF(0)("created a weapon\n");
     188    }
     189  }
     190  LOAD_PARAM_END_CYCLE(element);
    161191}
    162192
  • trunk/src/world_entities/npcs/npc.h

    r10376 r10440  
    2020
    2121
     22  void addWeapons(const TiXmlElement* root);
    2223  bool addWeapon(Weapon* weapon, int configID = -1, int slotID = -1);
    2324  void removeWeapon(Weapon* weapon);
     
    3132  inline void fire(){ this->bFire=true;}
    3233
    33 
     34  inline void enableAI() { this->bAIEnabled = true; }
    3435
    3536private:
     
    5152
    5253  AIModule*             aiModule;
     54
     55  bool                  bAIEnabled;   //!< true is AI enabled
    5356};
    5457
Note: See TracChangeset for help on using the changeset viewer.