Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 9042 in orxonox.OLD


Ignore:
Timestamp:
Jul 3, 2006, 3:44:31 PM (18 years ago)
Author:
patrick
Message:

run and crouch also works

Location:
branches/single_player_map/src/world_entities/npcs
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/single_player_map/src/world_entities/npcs/generic_npc.cc

    r9040 r9042  
    8787  time = 30.0f;
    8888
     89  this->behaviourList = new std::list<GenericNPC::Anim>;
     90
    8991  // collision reaction registration
    9092  this->subscribeReaction(CREngine::CR_PHYSICS_GROUND_WALK, CL_BSP_ENTITY);
     
    186188void GenericNPC::initNPC()
    187189{
    188   if (!this->behaviourList.empty())
    189   {
    190     GenericNPC::Anim currentAnimation = this->behaviourList.front();
    191 
    192     switch(this->behaviourList.front().type)
     190  if (!this->behaviourList->empty())
     191  {
     192    GenericNPC::Anim currentAnimation = this->behaviourList->front();
     193
     194    switch(this->behaviourList->front().type)
    193195    {
    194196      case Walk:
     
    211213
    212214        Vector dir = (currentAnimation.v - this->getAbsCoor()).getNormalized();
     215        dir.y = 0.0f;
     216        dir.getNormalized();
    213217        this->setAbsDir(Quaternion(dir, Vector(0.0, 1.0, 0.0)) * Quaternion(-M_PI_2, Vector(0.0, 1.0, 0.0)));
    214218
     
    222226
    223227        Vector dir = (currentAnimation.v - this->getAbsCoor()).getNormalized();
     228        dir.y = 0.0f;
     229        dir.getNormalized();
    224230        this->setAbsDir(Quaternion(dir, Vector(0.0, 1.0, 0.0)) * Quaternion(-M_PI_2, Vector(0.0, 1.0, 0.0)));
    225231
     
    248254void GenericNPC::nextStep()
    249255{
    250   if (!this->behaviourList.empty())
    251     this->behaviourList.pop_front();
     256  if (!this->behaviourList->empty())
     257    this->behaviourList->pop_front();
    252258  else
    253259    return;
    254260
    255261
    256   if (!this->behaviourList.empty())
    257   {
    258     GenericNPC::Anim currentAnimation = this->behaviourList.front();
     262  if (!this->behaviourList->empty())
     263  {
     264    GenericNPC::Anim currentAnimation = this->behaviourList->front();
    259265
    260266    switch( currentAnimation.type)
     
    331337  anim.speed = 30.0f;
    332338
    333   if( this->behaviourList.empty())
    334   {
    335     this->behaviourList.push_back(anim);
     339  if( this->behaviourList->empty())
     340  {
     341    this->behaviourList->push_back(anim);
    336342    this->initNPC();
    337343  }
    338344  else
    339     this->behaviourList.push_back(anim);
     345    this->behaviourList->push_back(anim);
    340346}
    341347
     
    355361  anim.speed = 60.0f;
    356362
    357   if( this->behaviourList.empty())
    358   {
    359     this->behaviourList.push_back(anim);
     363  if( this->behaviourList->empty())
     364  {
     365    this->behaviourList->push_back(anim);
    360366    this->initNPC();
    361367  }
    362368  else
    363     this->behaviourList.push_back(anim);
     369    this->behaviourList->push_back(anim);
    364370}
    365371
     
    376382  anim.type = Crouch;
    377383
    378   if( this->behaviourList.empty())
    379   {
    380     this->behaviourList.push_back(anim);
     384  if( this->behaviourList->empty())
     385  {
     386    this->behaviourList->push_back(anim);
    381387    this->initNPC();
    382388  }
    383389  else
    384     this->behaviourList.push_back(anim);
     390    this->behaviourList->push_back(anim);
    385391}
    386392void GenericNPC::crouchTo(float x, float y, float z)
     
    397403  anim.type = TurnTo;
    398404
    399   if( this->behaviourList.empty())
    400   {
    401     this->behaviourList.push_back(anim);
     405  if( this->behaviourList->empty())
     406  {
     407    this->behaviourList->push_back(anim);
    402408    this->initNPC();
    403409  }
    404410  else
    405     this->behaviourList.push_back(anim);
     411    this->behaviourList->push_back(anim);
    406412}
    407413
     
    418424  anim.type = LookAt;
    419425
    420   if( this->behaviourList.empty())
    421   {
    422     this->behaviourList.push_back(anim);
     426  if( this->behaviourList->empty())
     427  {
     428    this->behaviourList->push_back(anim);
    423429    this->initNPC();
    424430  }
    425431  else
    426     this->behaviourList.push_back(anim);
     432    this->behaviourList->push_back(anim);
    427433}
    428434
     
    465471
    466472
    467   if (!this->behaviourList.empty())
    468   {
    469     GenericNPC::Anim currentAnimation = this->behaviourList.front();
     473  if (!this->behaviourList->empty())
     474  {
     475    GenericNPC::Anim currentAnimation = this->behaviourList->front();
    470476
    471477    switch( currentAnimation.type)
  • branches/single_player_map/src/world_entities/npcs/generic_npc.h

    r9036 r9042  
    1212
    1313#include "sound_source.h"
     14
     15#include <stack>
     16
    1417
    1518namespace OrxSound{ class SoundSource; }
     
    3538
    3639
    37   bool finalGoalReached() { return this->behaviourList.empty(); };
     40  bool finalGoalReached() { return this->behaviourList->empty(); };
    3841
    3942  /* npc controlling functions to be Queued */
     
    122125   float                                   soundVolume;
    123126
    124    std::list<GenericNPC::Anim>             behaviourList;
     127   std::list<GenericNPC::Anim>*            behaviourList;
     128   std::stack<std::list<GenericNPC::Anim>* > animationStack;
    125129   Vector                                  destCoor;
    126130   Quaternion                              destDir;
Note: See TracChangeset for help on using the changeset viewer.