Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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


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

making weapons loadable

File:
1 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
Note: See TracChangeset for help on using the changeset viewer.