Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 12, 2006, 10:43:36 PM (18 years ago)
Author:
tfahrni
Message:
 
File:
1 edited

Legend:

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

    r10041 r10045  
    3737
    3838
    39 NPC2::NPC2(const TiXmlElement* root)
    40   : NPC(NULL)
     39NPC2::NPC2(const TiXmlElement* root) : NPC(NULL)
    4140{
    4241  this->registerObject(this, NPC2::_objectList);
    4342
     43  if (root != NULL)this->loadParams(root);
    4444
    45   if (root != NULL)this->loadParams(root);
    46  
    4745  addToTeam(0);
    4846}
     
    5654{
    5755  NPC::loadParams(root);
    58 
    5956}
    60 
    61 
    6257
    6358
     
    6560void NPC2::tick(float dt)
    6661{
    67        
    68        
    69   // animating the md2 model (uninteressant)
     62  // animating the md2 model
    7063  if( likely(this->getModel(0) != NULL))
    7164    ((MD2Model*)this->getModel(0))->tick(dt);
    72 
    73         return;
    74         //this things will now be managed by the AI modules..../////
    75 
    76   PRINTF(0)("====================\n");
    77   PRINTF(0)("NPC2::tick(%f)\n", dt);
    78 
    79   // information gathering
    80 
    81   Vector absPosition = this->getAbsCoor();
    82 
    83   PRINTF(0)(" npc abs coor: %f, %f, %f\n", absPosition.x, absPosition.y, absPosition.z);
    84 
    85   Player* pl = State::getPlayer();
    86   Vector playerAbsPos = pl->getPlayable()->getAbsCoor();
    87 
    88   PRINTF(0)(" player abs coor: %f, %f, %f\n", playerAbsPos.x, playerAbsPos.y, playerAbsPos.z);
    89 
    90 
    91   // intelligent reaction
    92 
    93   Vector distanceVector = playerAbsPos - absPosition;
    94   distanceVector.normalize();
    95 
    96   float speed = 10.0f;
    97 
    98   this->shiftCoor( distanceVector * speed * dt);
    99 
    100 
    101 
    10265}
    10366
Note: See TracChangeset for help on using the changeset viewer.