Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Sep 16, 2006, 3:34:04 PM (18 years ago)
Author:
bensch
Message:

orxonox/new_class_id: does not run anymore with scripts, but i think, it is on track

lua_State is now handled over the Global Executor

File:
1 edited

Legend:

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

    r9716 r9746  
    3939CREATE_SCRIPTABLE_CLASS(GenericNPC, GenericNPC::classID(),
    4040                        // Move
    41                         addMethod("walkTo", ExecutorLua3<GenericNPC,float,float,float>(&GenericNPC::walkTo))
    42                         ->addMethod("runTo", ExecutorLua3<GenericNPC,float,float,float>(&GenericNPC::runTo))
    43                         ->addMethod("turnTo", ExecutorLua1<GenericNPC,float>(&GenericNPC::turnTo))
    44                         ->addMethod("finalGoalReached", ExecutorLua0ret<GenericNPC,bool>(&GenericNPC::finalGoalReached))
    45                         ->addMethod("stop", ExecutorLua0<GenericNPC>(&GenericNPC::stop))
    46                         ->addMethod("resume", ExecutorLua0<GenericNPC>(&GenericNPC::resume))
    47                         ->addMethod("playAnimation", ExecutorLua2<GenericNPC,int,int>(&GenericNPC::playAnimation))
     41                        addMethod("walkTo", Executor3<GenericNPC, lua_State*,float,float,float>(&GenericNPC::walkTo))
     42                        ->addMethod("runTo", Executor3<GenericNPC, lua_State*,float,float,float>(&GenericNPC::runTo))
     43                        ->addMethod("turnTo", Executor1<GenericNPC, lua_State*,float>(&GenericNPC::turnTo))
     44                        ->addMethod("finalGoalReached", Executor0ret<GenericNPC, lua_State*,bool>(&GenericNPC::finalGoalReached))
     45                        ->addMethod("stop", Executor0<GenericNPC, lua_State*>(&GenericNPC::stop))
     46                        ->addMethod("resume", Executor0<GenericNPC, lua_State*>(&GenericNPC::resume))
     47                        ->addMethod("playAnimation", Executor2<GenericNPC, lua_State*,int,int>(&GenericNPC::playAnimation))
    4848                        // Display
    49                         ->addMethod("hide", ExecutorLua0<WorldEntity>(&WorldEntity::hide))
    50                         ->addMethod("unhide", ExecutorLua0<WorldEntity>(&WorldEntity::unhide))
     49                        ->addMethod("hide", Executor0<WorldEntity, lua_State*>(&WorldEntity::hide))
     50                        ->addMethod("unhide", Executor0<WorldEntity, lua_State*>(&WorldEntity::unhide))
    5151                        // Coordinates
    52                         ->addMethod("getAbsCoorX", ExecutorLua0ret<PNode, float>(&PNode::getAbsCoorX))
    53                         ->addMethod("getAbsCoorY", ExecutorLua0ret<PNode, float>(&PNode::getAbsCoorY))
    54                         ->addMethod("getAbsCoorZ", ExecutorLua0ret<PNode, float>(&PNode::getAbsCoorZ))
    55                         ->addMethod("setAbsCoor", ExecutorLua3<PNode,float,float,float>(&PNode::setAbsCoor))
    56                         ->addMethod("setAbsDir", ExecutorLua4<PNode,float,float,float,float>(&PNode::setAbsDir))
     52                        ->addMethod("getAbsCoorX", Executor0ret<PNode, lua_State*, float>(&PNode::getAbsCoorX))
     53                        ->addMethod("getAbsCoorY", Executor0ret<PNode, lua_State*, float>(&PNode::getAbsCoorY))
     54                        ->addMethod("getAbsCoorZ", Executor0ret<PNode, lua_State*, float>(&PNode::getAbsCoorZ))
     55                        ->addMethod("setAbsCoor", Executor3<PNode, lua_State*,float,float,float>(&PNode::setAbsCoor))
     56                        ->addMethod("setAbsDir", Executor4<PNode, lua_State*,float,float,float,float>(&PNode::setAbsDir))
    5757                       );
    5858
     
    234234        this->setAnimationSpeed(0.5f);
    235235      }
    236         break;
     236      break;
    237237      case Run:
    238238      {
     
    247247        this->setAnimationSpeed(1.0f);
    248248      }
    249         break;
     249      break;
    250250      case Crouch:
    251251      {
     
    260260        this->setAnimationSpeed(1.0f);
    261261      }
    262         break;
     262      break;
    263263      case LookAt:
    264         if( this->getAnimation() != STAND)
    265           this->setAnimation(STAND, MD2_ANIM_LOOP);
    266         break;
     264      if( this->getAnimation() != STAND)
     265        this->setAnimation(STAND, MD2_ANIM_LOOP);
     266      break;
    267267      case Shoot:
    268         if( this->getAnimation() != STAND)
    269           this->setAnimation(STAND, MD2_ANIM_LOOP);
    270         break;
     268      if( this->getAnimation() != STAND)
     269        this->setAnimation(STAND, MD2_ANIM_LOOP);
     270      break;
    271271
    272272      default:
    273         if( this->getAnimation() != STAND)
    274           this->setAnimation(STAND, MD2_ANIM_LOOP);
    275         break;
     273      if( this->getAnimation() != STAND)
     274        this->setAnimation(STAND, MD2_ANIM_LOOP);
     275      break;
    276276
    277277    }
     
    307307        this->setAnimationSpeed(0.5f);
    308308      }
    309         break;
     309      break;
    310310      case Run:
    311311      {
     
    320320        this->setAnimationSpeed(1.0f);
    321321      }
    322         break;
     322      break;
    323323      case Crouch:
    324324      {
     
    333333        this->setAnimationSpeed(1.0f);
    334334      }
    335         break;
     335      break;
    336336      case LookAt:
    337337      {
     
    339339          this->setAnimation(STAND, MD2_ANIM_LOOP);
    340340      }
    341         break;
     341      break;
    342342      case Shoot:
    343         if( this->getAnimation() != STAND)
     343      if( this->getAnimation() != STAND)
    344344        this->setAnimation(STAND, MD2_ANIM_LOOP);
    345         break;
     345      break;
    346346
    347347      default:
    348         if( this->getAnimation() != STAND)
     348      if( this->getAnimation() != STAND)
    349349        this->setAnimation(STAND, MD2_ANIM_LOOP);
    350         break;
     350      break;
    351351
    352352    }
     
    510510    {
    511511      case Walk:
     512      {
     513        Vector dest = currentAnimation.v - this->getAbsCoor();
     514        dest.y = 0.0f;
     515        if (dest.len() < .5)
    512516        {
    513           Vector dest = currentAnimation.v - this->getAbsCoor();
    514           dest.y = 0.0f;
    515           if (dest.len() < .5)
    516           {
    517             this->nextStep();
    518           }
    519           else
    520           {
    521             Vector move = dest.getNormalized() * currentAnimation.speed * dt;
    522             this->shiftCoor(move);
    523           }
     517          this->nextStep();
    524518        }
    525         break;
     519        else
     520        {
     521          Vector move = dest.getNormalized() * currentAnimation.speed * dt;
     522          this->shiftCoor(move);
     523        }
     524      }
     525      break;
    526526
    527527      case Run:
     
    552552
    553553      case TurnTo:
    554         //Quaternion direction = this->
    555         break;
     554      //Quaternion direction = this->
     555      break;
    556556
    557557      case LookAt:
    558         break;
     558      break;
    559559
    560560      case Shoot:
    561         break;
     561      break;
    562562
    563563      default:
    564         break;
     564      break;
    565565
    566566    }
     
    572572    this->fallVelocity += 300.0f * dt;
    573573    //velocity -= Vector(0.0, 1.0, 0.0) * this->fallVelocity;
    574    // PRINTF(0)("%s is not on ground\n", this->getName());
     574    // PRINTF(0)("%s is not on ground\n", this->getName());
    575575    this->shiftCoor(Vector(0, -this->fallVelocity * dt,0));
    576576
Note: See TracChangeset for help on using the changeset viewer.