Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 9869 in orxonox.OLD for trunk/src/world_entities/npcs/generic_npc.cc


Ignore:
Timestamp:
Oct 3, 2006, 12:19:30 AM (18 years ago)
Author:
bensch
Message:

orxonox/trunk: merged the new_class_id branche back to the trunk.
merged with command:
svn merge https://svn.orxonox.net/orxonox/branches/new_class_id trunk -r9683:HEAD
no conflicts… puh..

File:
1 edited

Legend:

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

    r9235 r9869  
    2727
    2828#include "sound_buffer.h"
    29 
    30 #include "loading/resource_manager.h"
    31 
    32 
    33 CREATE_FACTORY(GenericNPC, CL_GENERIC_NPC);
     29#include "resource_sound_buffer.h"
     30
     31#include "sound/resource_sound_buffer.h"
     32
     33#include "bsp_entity.h"
     34
     35#include "class_id_DEPRECATED.h"
     36ObjectListDefinitionID(GenericNPC, CL_GENERIC_NPC);
     37CREATE_FACTORY(GenericNPC);
    3438
    3539#include "script_class.h"
    36 CREATE_SCRIPTABLE_CLASS(GenericNPC, CL_GENERIC_NPC,
     40CREATE_SCRIPTABLE_CLASS(GenericNPC,
    3741                        // Move
    38                         addMethod("walkTo", ExecutorLua3<GenericNPC,float,float,float>(&GenericNPC::walkTo))
    39                         ->addMethod("runTo", ExecutorLua3<GenericNPC,float,float,float>(&GenericNPC::runTo))
    40                         ->addMethod("turnTo", ExecutorLua1<GenericNPC,float>(&GenericNPC::turnTo))
    41                         ->addMethod("finalGoalReached", ExecutorLua0ret<GenericNPC,bool>(&GenericNPC::finalGoalReached))
    42                         ->addMethod("stop", ExecutorLua0<GenericNPC>(&GenericNPC::stop))
    43                         ->addMethod("resume", ExecutorLua0<GenericNPC>(&GenericNPC::resume))
    44                         ->addMethod("playAnimation", ExecutorLua2<GenericNPC,int,int>(&GenericNPC::playAnimation))
     42                        addMethod("walkTo", Executor3<GenericNPC, lua_State*,float,float,float>(&GenericNPC::walkTo))
     43                        ->addMethod("runTo", Executor3<GenericNPC, lua_State*,float,float,float>(&GenericNPC::runTo))
     44                        ->addMethod("turnTo", Executor1<GenericNPC, lua_State*,float>(&GenericNPC::turnTo))
     45                        ->addMethod("finalGoalReached", Executor0ret<GenericNPC, lua_State*,bool>(&GenericNPC::finalGoalReached))
     46                        ->addMethod("stop", Executor0<GenericNPC, lua_State*>(&GenericNPC::stop))
     47                        ->addMethod("resume", Executor0<GenericNPC, lua_State*>(&GenericNPC::resume))
     48                        ->addMethod("playAnimation", Executor2<GenericNPC, lua_State*,int,int>(&GenericNPC::playAnimation))
    4549                        // Display
    46                         ->addMethod("hide", ExecutorLua0<WorldEntity>(&WorldEntity::hide))
    47                         ->addMethod("unhide", ExecutorLua0<WorldEntity>(&WorldEntity::unhide))
     50                        ->addMethod("hide", Executor0<WorldEntity, lua_State*>(&WorldEntity::hide))
     51                        ->addMethod("unhide", Executor0<WorldEntity, lua_State*>(&WorldEntity::unhide))
    4852                        // Coordinates
    49                         ->addMethod("getAbsCoorX", ExecutorLua0ret<PNode, float>(&PNode::getAbsCoorX))
    50                         ->addMethod("getAbsCoorY", ExecutorLua0ret<PNode, float>(&PNode::getAbsCoorY))
    51                         ->addMethod("getAbsCoorZ", ExecutorLua0ret<PNode, float>(&PNode::getAbsCoorZ))
    52                         ->addMethod("setAbsCoor", ExecutorLua3<PNode,float,float,float>(&PNode::setAbsCoor))
    53                         ->addMethod("setAbsDir", ExecutorLua4<PNode,float,float,float,float>(&PNode::setAbsDir))
     53                        ->addMethod("getAbsCoorX", Executor0ret<PNode, lua_State*, float>(&PNode::getAbsCoorX))
     54                        ->addMethod("getAbsCoorY", Executor0ret<PNode, lua_State*, float>(&PNode::getAbsCoorY))
     55                        ->addMethod("getAbsCoorZ", Executor0ret<PNode, lua_State*, float>(&PNode::getAbsCoorZ))
     56                        ->addMethod("setAbsCoor", Executor3<PNode, lua_State*,float,float,float>(&PNode::setAbsCoor))
     57                        ->addMethod("setAbsDir", Executor4<PNode, lua_State*,float,float,float,float>(&PNode::setAbsDir))
    5458                       );
    5559
     
    8185void GenericNPC::init()
    8286{
    83   this->setClassID(CL_GENERIC_NPC, "GenericNPC");
     87  this->registerObject(this, GenericNPC::_objectList);
    8488
    8589  this->toList(OM_GROUP_00);
    8690
    87   this->soundBuffer = (OrxSound::SoundBuffer*)ResourceManager::getInstance()->load("sound/rain.wav", WAV);
     91  this->soundBuffer = OrxSound::ResourceSoundBuffer("sound/rain.wav");
    8892
    8993  time = 30.0f;
     
    9296
    9397  // collision reaction registration
    94    this->subscribeReaction(CREngine::CR_PHYSICS_GROUND_WALK, CL_BSP_ENTITY);
     98  this->subscribeReaction(CREngine::CR_PHYSICS_GROUND_WALK, BspEntity::staticClassID());
    9599}
    96100
     
    231235        this->setAnimationSpeed(0.5f);
    232236      }
    233         break;
     237      break;
    234238      case Run:
    235239      {
     
    244248        this->setAnimationSpeed(1.0f);
    245249      }
    246         break;
     250      break;
    247251      case Crouch:
    248252      {
     
    257261        this->setAnimationSpeed(1.0f);
    258262      }
    259         break;
     263      break;
    260264      case LookAt:
    261         if( this->getAnimation() != STAND)
    262           this->setAnimation(STAND, MD2_ANIM_LOOP);
    263         break;
     265      if( this->getAnimation() != STAND)
     266        this->setAnimation(STAND, MD2_ANIM_LOOP);
     267      break;
    264268      case Shoot:
    265         if( this->getAnimation() != STAND)
    266           this->setAnimation(STAND, MD2_ANIM_LOOP);
    267         break;
     269      if( this->getAnimation() != STAND)
     270        this->setAnimation(STAND, MD2_ANIM_LOOP);
     271      break;
    268272
    269273      default:
    270         if( this->getAnimation() != STAND)
    271           this->setAnimation(STAND, MD2_ANIM_LOOP);
    272         break;
     274      if( this->getAnimation() != STAND)
     275        this->setAnimation(STAND, MD2_ANIM_LOOP);
     276      break;
    273277
    274278    }
     
    304308        this->setAnimationSpeed(0.5f);
    305309      }
    306         break;
     310      break;
    307311      case Run:
    308312      {
     
    317321        this->setAnimationSpeed(1.0f);
    318322      }
    319         break;
     323      break;
    320324      case Crouch:
    321325      {
     
    330334        this->setAnimationSpeed(1.0f);
    331335      }
    332         break;
     336      break;
    333337      case LookAt:
    334338      {
     
    336340          this->setAnimation(STAND, MD2_ANIM_LOOP);
    337341      }
    338         break;
     342      break;
    339343      case Shoot:
    340         if( this->getAnimation() != STAND)
     344      if( this->getAnimation() != STAND)
    341345        this->setAnimation(STAND, MD2_ANIM_LOOP);
    342         break;
     346      break;
    343347
    344348      default:
    345         if( this->getAnimation() != STAND)
     349      if( this->getAnimation() != STAND)
    346350        this->setAnimation(STAND, MD2_ANIM_LOOP);
    347         break;
     351      break;
    348352
    349353    }
     
    507511    {
    508512      case Walk:
     513      {
     514        Vector dest = currentAnimation.v - this->getAbsCoor();
     515        dest.y = 0.0f;
     516        if (dest.len() < .5)
    509517        {
    510           Vector dest = currentAnimation.v - this->getAbsCoor();
    511           dest.y = 0.0f;
    512           if (dest.len() < .5)
    513           {
    514             this->nextStep();
    515           }
    516           else
    517           {
    518             Vector move = dest.getNormalized() * currentAnimation.speed * dt;
    519             this->shiftCoor(move);
    520           }
     518          this->nextStep();
    521519        }
    522         break;
     520        else
     521        {
     522          Vector move = dest.getNormalized() * currentAnimation.speed * dt;
     523          this->shiftCoor(move);
     524        }
     525      }
     526      break;
    523527
    524528      case Run:
     
    549553
    550554      case TurnTo:
    551         //Quaternion direction = this->
    552         break;
     555      //Quaternion direction = this->
     556      break;
    553557
    554558      case LookAt:
    555         break;
     559      break;
    556560
    557561      case Shoot:
    558         break;
     562      break;
    559563
    560564      default:
    561         break;
     565      break;
    562566
    563567    }
     
    569573    this->fallVelocity += 300.0f * dt;
    570574    //velocity -= Vector(0.0, 1.0, 0.0) * this->fallVelocity;
    571    // PRINTF(0)("%s is not on ground\n", this->getName());
     575    // PRINTF(0)("%s is not on ground\n", this->getName());
    572576    this->shiftCoor(Vector(0, -this->fallVelocity * dt,0));
    573577
Note: See TracChangeset for help on using the changeset viewer.