Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 9061 in orxonox.OLD


Ignore:
Timestamp:
Jul 3, 2006, 6:39:10 PM (18 years ago)
Author:
patrick
Message:

merged the single_player branche to trunk

Location:
trunk/src
Files:
21 edited
4 copied

Legend:

Unmodified
Added
Removed
  • trunk/src/defs/class_id.h

    r9006 r9061  
    199199  CL_HOVER                      =    0x0000035e,
    200200  CL_TURBINE_HOVER              =    0x0000035f,
    201   CL_SPECTATOR                  =    0x00000360,
    202   CL_COLLISION_PROBE            =    0x00000361,
    203   CL_FPS_PLAYER                 =    0x00000362,
     201  CL_SPACECRAFT_2D              =    0x00000360,
     202  CL_CRUIZER                    =    0x00000361,
     203  CL_SPECTATOR                  =    0x0000036a,
     204  CL_COLLISION_PROBE            =    0x0000036b,
     205  CL_FPS_PLAYER                 =    0x0000036c,
    204206
    205207  // Powerups
  • trunk/src/lib/collision_reaction/cr_defs.h

    r8894 r9061  
    2929
    3030//!< the collision axis x collision event
    31 #define COLLISION_TYPE_AXIS_X   1
     31#define COLLISION_TYPE_AXIS_X      1
     32#define COLLISION_TZPE_AXIS_X_NEG  2
    3233//!< the collision axis y collision event
    33 #define COLLISION_TYPE_AXIS_Y   2
     34#define COLLISION_TYPE_AXIS_Y      3
     35#define COLLISION_TYPE_AXIS_Y_NEG  4
    3436//!< the collision axis z collision event
    35 #define COLLISION_TYPE_AXIS_Z   4
     37#define COLLISION_TYPE_AXIS_Z      5
     38#define COLLISION_TYPE_AXIS_Z_NEG  6
    3639//!< the collision is a obb collision
    3740#define COLLISION_TYPE_OBB      8
  • trunk/src/lib/collision_reaction/cr_object_damage.cc

    r9027 r9061  
    6464    damage = collision->getEntityB()->getDamage();
    6565    collision->getEntityA()->hit(damage, collision->getEntityB());
     66    PRINTF(4)("Dealing damage - %f damage to %s \n", damage, collision->getEntityA()->getClassName());
    6667  }
    67   PRINTF(4)("Dealing damage - %f damage to %s \n", damage, collision->getEntityA()->getClassName());
    6868
    6969  if( collision->isEntityBCollide()) {
    7070    damage = collision->getEntityA()->getDamage();
    7171    collision->getEntityB()->hit(damage, collision->getEntityA());
     72    PRINTF(4)("Dealing damage - %f damage to %s \n", damage, collision->getEntityB()->getClassName());
    7273  }
    73   PRINTF(4)("Dealing damage - %f damage to %s \n", damage, collision->getEntityB()->getClassName());
    7474
    7575  collision->flushCollisionEvents();
  • trunk/src/lib/collision_reaction/cr_physics_ground_walk.cc

    r9027 r9061  
    9595        // collision in the x-axis
    9696      case COLLISION_TYPE_AXIS_X:
    97         front = collPos.x - box->halfLength[0]; // should be [0]
     97        front = collPos.len() - box->halfLength[0]; // should be [0]
    9898
    9999        // object is beneath the plane (ground)
    100100        if( front <= 0.0f )
    101101        {
    102           Vector backoff = entity->getAbsDirX() * front;
    103 //           entity->shiftCoor(backoff);
    104         }
    105         // object is already in the wall
    106         else if( ce->isInWall())
    107         {
    108 //           entity->setAbsCoor(entity->getLastAbsCoor());
     102          Vector dirX = entity->getAbsDirX(); dirX.y = 0.0f; dirX.normalize();
     103          Vector backoff = dirX * front;
     104         
     105          entity->setAbsCoor(entity->getLastAbsCoor());
     106         // entity->shiftCoor(backoff);
     107        }
     108        // object is already in the wall
     109        else if( ce->isInWall())
     110        {
     111              entity->setAbsCoor(entity->getLastAbsCoor());
     112        }
     113        break;
     114       
     115      case COLLISION_TYPE_AXIS_X_NEG:
     116        front = collPos.len() - box->halfLength[0]; // should be [0]
     117
     118        // object is beneath the plane (ground)
     119        if( front <= 0.0f )
     120        {
     121          Vector dirX = entity->getAbsDirX(); dirX.y = 0.0f; dirX.normalize();
     122          Vector backoff = dirX * front * -1.0f;
     123         
     124          entity->setAbsCoor(entity->getLastAbsCoor());
     125         // entity->shiftCoor(backoff);
     126        }
     127        // object is already in the wall
     128        else if( ce->isInWall())
     129        {
     130          entity->setAbsCoor(entity->getLastAbsCoor());
    109131        }
    110132        break;
     
    112134
    113135        // collision in the y-axis
    114       case COLLISION_TYPE_AXIS_Y:
     136      case COLLISION_TYPE_AXIS_Y_NEG:
    115137        // calulate the height above ground
    116138        height = collPos.y - box->halfLength[1];
     
    118140
    119141        // object is beneath the plane (ground)
    120         if( height <= 0.0f )
    121         {
    122           entity->shiftCoor(Vector(0.0f, -height, 0.0f));
     142        if(height >= 0.0f && height <= 0.0001f) break ;// Do nothing
     143        else if( height < 0.0f )
     144        {
     145          entity->shiftCoor(Vector(0.0f, -height + 0.00001, 0.0f));
    123146          entity->setOnGround(true);
    124147        }
     
    140163      case COLLISION_TYPE_AXIS_Z:
    141164
    142         side = collPos.z - box->halfLength[2]; // should be [2]
     165        side = collPos.len() - box->halfLength[2]; // should be [2]
    143166
    144167        // object is beneath the plane (ground)
    145168        if( side <= 0.0f )
    146169        {
    147           Vector backoff = entity->getAbsDirX() * side;
    148 //           entity->shiftCoor(backoff);
    149         }
    150         // object is already in the wall
    151         else if( ce->isInWall())
    152         {
    153 //           entity->setAbsCoor(entity->getLastAbsCoor());
     170          entity->setAbsCoor(entity->getAbsCoor());
     171          Vector dirZ = entity->getAbsDirZ(); dirZ.y = 0.0f; dirZ.normalize();
     172          Vector backoff = dirZ * side;
     173          entity->shiftCoor(backoff);
     174        }
     175        // object is already in the wall
     176        else if( ce->isInWall())
     177        {
     178          entity->setAbsCoor(entity->getLastAbsCoor());
     179        }
     180        break;
     181       
     182       
     183         // collision in the z-axis
     184      case COLLISION_TYPE_AXIS_Z_NEG:
     185
     186        side = collPos.len()  - box->halfLength[2]; // should be [2]
     187
     188        // object is beneath the plane (ground)
     189        if( side <= 0.0f )
     190        {
     191         
     192          Vector dirZ = entity->getAbsDirZ(); dirZ.y = 0.0f; dirZ.normalize();
     193          Vector backoff = dirZ * side*-1.0f;
     194          entity->shiftCoor(backoff);
     195        }
     196        // object is already in the wall
     197        else if( ce->isInWall())
     198        {
     199          entity->setAbsCoor(entity->getLastAbsCoor());
    154200        }
    155201        break;
  • trunk/src/lib/graphics/importer/bsp_manager.cc

    r9003 r9061  
    972972  Vector position1 = position;
    973973  Vector position2 = position + Vector(0.0,1.0,0.0);
     974  Vector position3 = position;
     975  Vector position4 = position + Vector(0.0,1.0,0.0);
    974976  Vector dest = worldEntity->getAbsCoor() - upDir*40.0f; //
    975977  Vector dest1 = position + forwardDir*4.0f;
    976978  Vector dest2 = position2 + forwardDir*4.0;
     979  Vector dest3 = position + forwardDir*4.0f;
     980  Vector dest4 = position2 + forwardDir*4.0;
    977981  dest = position - Vector(0.0, 40.0,0.0);
    978982  Vector out = dest;
     
    986990
    987991  if( box != NULL) {
    988     position = worldEntity->getAbsCoor() +  box->center + Vector(0.0, 1.0, 0.0) * box->halfLength[1];
    989     dest     = worldEntity->getAbsCoor() +  box->center - Vector(0.0, 1.0, 0.0) * (box->halfLength[1] + BSP_Y_OFFSET);
    990 
    991     position1 = worldEntity->getAbsCoor() +  box->center - worldEntity->getAbsDirX() * (box->halfLength[0]  + BSP_X_OFFSET);
    992     dest1     = worldEntity->getAbsCoor() +  box->center + worldEntity->getAbsDirX() * (box->halfLength[0]  + BSP_X_OFFSET);
    993 
    994     position2 = worldEntity->getAbsCoor() +  box->center - worldEntity->getAbsDirZ() * (box->halfLength[2]  + BSP_Z_OFFSET);
    995     dest2     = worldEntity->getAbsCoor() +  box->center + worldEntity->getAbsDirZ() * (box->halfLength[2]  + BSP_Z_OFFSET);
    996 
     992    position = worldEntity->getAbsCoor() +  box->center; // + Vector(0.0, 1.0, 0.0) * box->halfLength[1] * 1.0f;
     993    dest     = worldEntity->getAbsCoor() +  box->center - Vector(0.0, 1.0, 0.0) * (box->halfLength[1] + BSP_Y_OFFSET) *   100;
     994
     995    Vector dirX =  worldEntity->getAbsDirX(); dirX.y = 0.0f; dirX.normalize();
     996
     997    //position1 = worldEntity->getAbsCoor() +  box->center - dirX * (box->halfLength[0]  + BSP_X_OFFSET);
     998    dest1     = worldEntity->getAbsCoor() +  box->center + dirX * (box->halfLength[0]  + BSP_X_OFFSET);
     999    dest2     = worldEntity->getAbsCoor() -  box->center + dirX * (box->halfLength[0]  + BSP_X_OFFSET);
     1000   
     1001    Vector dirZ =  worldEntity->getAbsDirZ(); dirX.y = 0.0f; dirZ.normalize();
     1002    //position2 = worldEntity->getAbsCoor() +  box->center - dirZ * (box->halfLength[2]  + BSP_Z_OFFSET);
     1003    dest3     = worldEntity->getAbsCoor() +  box->center + dirZ * (box->halfLength[2]  + BSP_Z_OFFSET);
     1004    dest4     = worldEntity->getAbsCoor() -  box->center + dirZ * (box->halfLength[2]  + BSP_Z_OFFSET);
    9971005  } else {
    9981006    // Init positions and destinations to anything useful!
     
    10521060  bool xCollision = false;
    10531061  bool zCollision = false;
     1062  bool xCollisionNeg = false;
     1063  bool zCollisionNeg = false;
     1064 
    10541065
    10551066
     
    11201131  // Return the normal here: Normal's stored in this->collPlane;
    11211132  if( collision) {
    1122     worldEntity->registerCollision(COLLISION_TYPE_AXIS_Y , this->parent, worldEntity, Vector(testPlane->x, testPlane->y, testPlane->z), out, SolidFlag);
     1133    worldEntity->registerCollision(COLLISION_TYPE_AXIS_Y_NEG , this->parent, worldEntity, Vector(testPlane->x, testPlane->y, testPlane->z), out, SolidFlag);
    11231134}
    11241135  if(xCollision) {
    11251136    worldEntity->registerCollision(COLLISION_TYPE_AXIS_X , this->parent, worldEntity, Vector(testPlane->x, testPlane->y, testPlane->z),dest1 , SolidFlag);
    11261137  }
     1138 
    11271139  if(zCollision) {
    11281140    worldEntity->registerCollision(COLLISION_TYPE_AXIS_Z , this->parent, worldEntity, Vector(testPlane->x, testPlane->y, testPlane->z), dest2 , SolidFlag);
  • trunk/src/lib/graphics/importer/bsp_manager.h

    r9003 r9061  
    2828
    2929
    30 #define BSP_X_OFFSET 20.0f
     30#define BSP_X_OFFSET 40.0f
    3131#define BSP_Y_OFFSET 40.0f
    32 #define BSP_Z_OFFSET 20.0f
     32#define BSP_Z_OFFSET 40.0f
    3333
    3434
  • trunk/src/lib/graphics/text_engine/font_data.cc

    r8765 r9061  
    279279    Glyph* tmpGlyph;
    280280
    281     if (tmpGlyph = this->glyphArray[i])
     281    if ((tmpGlyph = this->glyphArray[i]) != NULL)
    282282    {
    283283      if (tmpGlyph->height*this->renderSize > maxLineHeight)
  • trunk/src/lib/script_engine/script.cc

    r9003 r9061  
    2424
    2525#include "class_list.h"
    26 // uncommet this when the std:string and the const bug is fixed
    27 //CREATE_SCRIPTABLE_CLASS(Script, CL_SCRIPT,
    28 //                               addMethod("addObject", ExecutorLua2<Script,std::string,std::string>(&Script::addObject))
    29 //                               ):
     26CREATE_SCRIPTABLE_CLASS(Script, CL_SCRIPT,
     27                    addMethod("addObject", ExecutorLua2<Script,const std::string&, const std::string& >(&Script::addObject))
     28                    ->addMethod("selectFunction", ExecutorLua2ret<Script, bool, const std::string&, int >(&Script::selectFunction))
     29                    ->addMethod("executeFunction", ExecutorLua0ret<Script,bool >(&Script::executeFunction))
     30                     );
    3031
    3132Script::Script(const TiXmlElement* root)
     
    8182   filedest += "scripts/" + filename;
    8283   
     84   this->addThisScript();
     85   this->registerStandartClasses();
     86   
    8387   if(currentFile.length() != 0)
    8488   {
     
    97101     {
    98102      currentFile = filename;
    99       //this->addThisScript();
    100103      return true;
    101104     }
     
    119122 void Script::addObject(const std::string& className, const std::string& objectName)
    120123 {
    121   // printf("Script %p: I am about to add %s of class %s\n",this,objectName.c_str(),className.c_str());
     124   //printf("Script %s: I am about to add %s of class %s\n",this->getName(),objectName.c_str(),className.c_str());
    122125
    123126   BaseObject* scriptClass = ClassList::getObject(className, CL_SCRIPT_CLASS);
     
    163166 }
    164167
    165  bool Script::selectFunction(std::string& functionName, int retCount)
     168 bool Script::selectFunction(const std::string& functionName, int retCount)
    166169 {
    167170   if(returnCount == 0 && currentFunction.length() == 0) //no return values left on the stack and no other function selected
     
    356359   
    357360   //success = this->registerClass(std::string("Vector"));
    358    
     361    success = this->registerClass("ScriptTrigger");
     362
    359363   return success;
    360364 }
  • trunk/src/lib/script_engine/script.h

    r9003 r9061  
    4242    /// EXECUTING
    4343    // first select function
    44     bool selectFunction(std::string& functionName, int retCount);
     44    bool selectFunction(const std::string& functionName, int retCount);
    4545
    4646    // push parameters for luafunction
  • trunk/src/story_entities/game_world.cc

    r9027 r9061  
    309309    //this->update (); /// LESS REDUNDANCY.
    310310//      PNode::getNullParent()->updateNode(this->dtS);
    311 
     311    PNode::getNullParent()->updateNode(this->dtS);
    312312
    313313    /* collision detection */
  • trunk/src/world_entities/WorldEntities.am

    r9003 r9061  
    4444                world_entities/space_ships/hover.cc \
    4545                world_entities/space_ships/turbine_hover.cc \
     46                world_entities/space_ships/spacecraft_2d.cc \
    4647                world_entities/space_ships/collision_probe.cc \
     48                world_entities/space_ships/cruizer.cc \
    4749                world_entities/creatures/md2_creature.cc \
    4850                world_entities/creatures/fps_player.cc \
     
    107109                space_ships/hover.h \
    108110                space_ships/turbine_hover.h \
    109                 space_ships/collision_probe.cc \
     111                space_ships/spacecraft_2d.h \
     112                space_ships/collision_probe.h \
     113                space_ships/cruizer.h \
    110114                creatures/md2_creature.h \
    111115                creatures/fps_player.h \
  • trunk/src/world_entities/npcs/generic_npc.cc

    r9027 r9061  
    4040                        ->addMethod("turnTo", ExecutorLua1<GenericNPC,float>(&GenericNPC::turnTo))
    4141                        ->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))
    4245                        // Display
    4346                        ->addMethod("hide", ExecutorLua0<WorldEntity>(&WorldEntity::hide))
     
    4952                        ->addMethod("setAbsCoor", ExecutorLua3<PNode,float,float,float>(&PNode::setAbsCoor))
    5053                        ->addMethod("setAbsDir", ExecutorLua4<PNode,float,float,float,float>(&PNode::setAbsDir))
    51 
    5254                       );
    5355
     
    8890  time = 30.0f;
    8991
     92  this->behaviourList = new std::list<GenericNPC::Anim>;
     93
    9094  // collision reaction registration
    9195//   this->subscribeReaction(CREngine::CR_PHYSICS_GROUND_WALK, CL_BSP_ENTITY);
     
    170174 * @param filename: name of the file
    171175 */
    172 void GenericNPC::playSound(std::string filename)
     176void GenericNPC::playSound(const std::string& filename)
    173177{}
    174178
     
    179183 */
    180184void GenericNPC::stop()
    181 {}
    182 
    183 
    184 
     185{
     186  this->animationStack.push(this->behaviourList);
     187  this->behaviourList = new std::list<GenericNPC::Anim>;
     188}
     189
     190
     191/**
     192 * continue the generic animation
     193 */
     194void GenericNPC::resume()
     195{
     196  //if()
     197  delete this->behaviourList;
     198  this->behaviourList = this->animationStack.top();
     199  this->animationStack.pop();
     200}
     201
     202
     203/**
     204 * each animation has to be initialized here
     205 */
    185206void GenericNPC::initNPC()
    186207{
    187 
    188   this->unsubscribeReaction();
    189 
    190   if (!this->behaviourList.empty())
    191   {
    192     GenericNPC::Anim currentAnimation = this->behaviourList.front();
    193 
    194     switch(this->behaviourList.front().type)
     208  if (!this->behaviourList->empty())
     209  {
     210    GenericNPC::Anim currentAnimation = this->behaviourList->front();
     211
     212    switch(this->behaviourList->front().type)
    195213    {
    196214      case Walk:
     
    213231
    214232        Vector dir = (currentAnimation.v - this->getAbsCoor()).getNormalized();
     233        dir.y = 0.0f;
     234        dir.getNormalized();
    215235        this->setAbsDir(Quaternion(dir, Vector(0.0, 1.0, 0.0)) * Quaternion(-M_PI_2, Vector(0.0, 1.0, 0.0)));
    216236
     
    224244
    225245        Vector dir = (currentAnimation.v - this->getAbsCoor()).getNormalized();
     246        dir.y = 0.0f;
     247        dir.getNormalized();
    226248        this->setAbsDir(Quaternion(dir, Vector(0.0, 1.0, 0.0)) * Quaternion(-M_PI_2, Vector(0.0, 1.0, 0.0)));
    227249
     
    250272void GenericNPC::nextStep()
    251273{
    252   if (!this->behaviourList.empty())
    253     this->behaviourList.pop_front();
     274  if (!this->behaviourList->empty())
     275    this->behaviourList->pop_front();
    254276  else
    255277    return;
    256278
    257279
    258   if (!this->behaviourList.empty())
    259   {
    260     GenericNPC::Anim currentAnimation = this->behaviourList.front();
     280  if (!this->behaviourList->empty())
     281  {
     282    GenericNPC::Anim currentAnimation = this->behaviourList->front();
    261283
    262284    switch( currentAnimation.type)
     
    266288        if( this->getAnimation() != RUN)
    267289          this->setAnimation(RUN, MD2_ANIM_LOOP);
     290
    268291
    269292        Vector dir = (currentAnimation.v - this->getAbsCoor());
     
    281304
    282305        Vector dir = (currentAnimation.v - this->getAbsCoor()).getNormalized();
     306        dir.y = 0.0f;
     307        dir.getNormalized();
    283308        this->setAbsDirSoft(Quaternion(dir, Vector(0.0, 1.0, 0.0)) * Quaternion(-M_PI_2, Vector(0.0, 1.0, 0.0)), 4.0);
    284309
     
    292317
    293318        Vector dir = (currentAnimation.v - this->getAbsCoor()).getNormalized();
     319        dir.y = 0.0f;
     320        dir.getNormalized();
    294321        this->setAbsDirSoft(Quaternion(dir, Vector(0.0, 1.0, 0.0)) * Quaternion(-M_PI_2, Vector(0.0, 1.0, 0.0)), 4.0);
    295322
     
    332359  anim.speed = 30.0f;
    333360
    334   if( this->behaviourList.empty())
    335   {
    336     this->behaviourList.push_back(anim);
     361  if( this->behaviourList->empty())
     362  {
     363    this->behaviourList->push_back(anim);
    337364    this->initNPC();
    338365  }
    339366  else
    340     this->behaviourList.push_back(anim);
     367    this->behaviourList->push_back(anim);
    341368}
    342369
     
    356383  anim.speed = 60.0f;
    357384
    358   if( this->behaviourList.empty())
    359   {
    360     this->behaviourList.push_back(anim);
     385  if( this->behaviourList->empty())
     386  {
     387    this->behaviourList->push_back(anim);
    361388    this->initNPC();
    362389  }
    363390  else
    364     this->behaviourList.push_back(anim);
     391    this->behaviourList->push_back(anim);
    365392}
    366393
     
    377404  anim.type = Crouch;
    378405
    379   if( this->behaviourList.empty())
    380   {
    381     this->behaviourList.push_back(anim);
     406  if( this->behaviourList->empty())
     407  {
     408    this->behaviourList->push_back(anim);
    382409    this->initNPC();
    383410  }
    384411  else
    385     this->behaviourList.push_back(anim);
     412    this->behaviourList->push_back(anim);
    386413}
    387414void GenericNPC::crouchTo(float x, float y, float z)
     
    398425  anim.type = TurnTo;
    399426
    400   if( this->behaviourList.empty())
    401   {
    402     this->behaviourList.push_back(anim);
     427  if( this->behaviourList->empty())
     428  {
     429    this->behaviourList->push_back(anim);
    403430    this->initNPC();
    404431  }
    405432  else
    406     this->behaviourList.push_back(anim);
     433    this->behaviourList->push_back(anim);
    407434}
    408435
     
    419446  anim.type = LookAt;
    420447
    421   if( this->behaviourList.empty())
    422   {
    423     this->behaviourList.push_back(anim);
     448  if( this->behaviourList->empty())
     449  {
     450    this->behaviourList->push_back(anim);
    424451    this->initNPC();
    425452  }
    426453  else
    427     this->behaviourList.push_back(anim);
     454    this->behaviourList->push_back(anim);
    428455}
    429456
     
    466493
    467494
    468   if (!this->behaviourList.empty())
    469   {
    470     GenericNPC::Anim currentAnimation = this->behaviourList.front();
     495  if (!this->behaviourList->empty())
     496  {
     497    GenericNPC::Anim currentAnimation = this->behaviourList->front();
    471498
    472499    switch( currentAnimation.type)
     
    475502        {
    476503          Vector dest = currentAnimation.v - this->getAbsCoor();
     504          dest.y = 0.0f;
    477505          if (dest.len() < .5)
    478506          {
     
    481509          else
    482510          {
    483             dest.y = 0.0f;
    484             this->shiftCoor(dest.getNormalized() * currentAnimation.speed * dt);
     511            Vector move = dest.getNormalized() * currentAnimation.speed * dt;
     512            this->shiftCoor(move);
    485513          }
    486514        }
     
    528556
    529557  // physical falling of the player
    530 //   if( !this->isOnGround())
    531 //   {
    532 //     this->fallVelocity += 300.0f * dt;
    533 //     velocity -= Vector(0.0, 1.0, 0.0) * this->fallVelocity;
    534 //    // PRINTF(0)("%s is not on ground\n", this->getName());
    535 //     this->shiftCoor(Vector(0, -this->fallVelocity * dt,0));
    536 //   }
    537 //   else
    538 //   {
    539 //     this->fallVelocity = 0.0f;
    540 //   }
    541 
    542 
     558  if( !this->isOnGround())
     559  {
     560    this->fallVelocity += 300.0f * dt;
     561    //velocity -= Vector(0.0, 1.0, 0.0) * this->fallVelocity;
     562   // PRINTF(0)("%s is not on ground\n", this->getName());
     563    this->shiftCoor(Vector(0, -this->fallVelocity * dt,0));
     564
     565  }
     566  else
     567  {
     568    this->fallVelocity = 0.0f;
     569  }
    543570
    544571}
  • trunk/src/world_entities/npcs/generic_npc.h

    r9003 r9061  
    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 */
     
    5255  /* stopping the movement */
    5356  void stop();
     57  void resume();
    5458  void nextStep();
    5559
     
    6872  /* some generic control funtions */
    6973  void playAnimation(int animationIndex, int animPlaybackMode);
    70   void playSound(std::string filename);
    71   void playSound(int i);
     74  void playSound(const std::string& filename);
    7275
    7376  virtual void tick (float time);
     
    123126   float                                   soundVolume;
    124127
    125    std::list<GenericNPC::Anim>             behaviourList;
     128   std::list<GenericNPC::Anim>*            behaviourList;
     129   std::stack<std::list<GenericNPC::Anim>*> animationStack;
    126130   Vector                                  destCoor;
    127131   Quaternion                              destDir;
  • trunk/src/world_entities/playable.cc

    r9008 r9061  
    6363  this->score = 0;
    6464  this->collider = NULL;
     65  this->enterRadius = 10.0f;
    6566
    6667  this->bDead = false;
     
    9495
    9596  LoadParam(root, "abs-dir", this, Playable, setPlayDirection);
     97  LoadParam(root, "enter-radius", this, Playable, setEnterRadius)
     98      .describe("The Distance one can enter the ship from.");
    9699}
    97100
  • trunk/src/world_entities/playable.h

    r8724 r9061  
    5656
    5757  // Player Settup
     58  bool hasPlayer(){return !(this->currentPlayer == NULL);}
    5859  bool setPlayer(Player* player);
    5960  Player* getCurrentPlayer() const { return this->currentPlayer; };
     
    7475  inline int  getScore() { return this->score; }
    7576
     77  void setEnterRadius(float radius) { this->enterRadius = radius; };
     78  /** @returns the EnterRadius (how far away a Player must be to enter this entity) */
     79  inline float getEnterRadius() const { return this->enterRadius; };
    7680
    7781  // WorldEntity Extensions
     
    116120  Playable::Playmode    playmode;           //!< The current playmode.
    117121
     122  float                 enterRadius;        //!< How far one can be away from the Playable to enter it.
     123
    118124  WorldEntity* collider;
    119125};
  • trunk/src/world_entities/player.cc

    r9019 r9061  
    3232Player::Player()
    3333{
    34 //  this->setRelDir(Quaternion(M_PI, Vector(1,0,0)));
     34  //  this->setRelDir(Quaternion(M_PI, Vector(1,0,0)));
    3535  this->setClassID(CL_PLAYER, "Player");
    3636
     
    7474  {
    7575    PRINTF(4)("Enter new Playable\n");
    76       this->playable = playable;
    77       this->_hud.setEnergyWidget(this->playable->getHealthWidget());
    78       this->_hud.setWeaponManager(&this->playable->getWeaponManager());
     76    this->playable = playable;
     77    this->hud.setEnergyWidget(this->playable->getHealthWidget());
     78    this->hud.setWeaponManager(&this->playable->getWeaponManager());
    7979
    80       this->playable->setPlayer(this);
    81       return true;
     80    this->playable->setPlayer(this);
     81    return true;
    8282  }
    8383
     
    8989
    9090bool Player::eject()
    91  {
    92    return this->setPlayable(NULL);
    93  }
     91{
     92  return this->setPlayable(NULL);
     93}
    9494
    9595
     
    9999 }
    100100
    101  void Player::process(const Event &event)
    102  {
    103    if (event.type == KeyMapper::PEV_CHANGE_SHIP && event.bPressed)
    104    {
    105      /// FIXME this should be in the ObjectManager
    106      const std::list<BaseObject*>* objectList = ClassList::getList(CL_PLAYABLE);
    107      if (objectList != NULL)
    108      {
    109        std::list<BaseObject*>::const_iterator node;
    110        for (node = objectList->begin(); node != objectList->end(); node++)
    111          if (this->playable != (*node) && (dynamic_cast<PNode*>(*node)->getAbsCoor() - this->playable->getAbsCoor()).len() < 10.0)
    112        {
    113101
    114          this->setPlayable(dynamic_cast<Playable*>(*node));
     102void Player::enterNewPlayable()
     103{
     104  /// FIXME this should be in the ObjectManager
     105  const std::list<BaseObject*>* objectList = ClassList::getList(CL_PLAYABLE);
     106  if (objectList != NULL)
     107  {
     108    std::list<BaseObject*>::const_iterator node;
     109    for (node = objectList->begin(); node != objectList->end(); node++)
     110      if (this->playable != (*node) &&
     111          (dynamic_cast<PNode*>(*node)->getAbsCoor() - this->playable->getAbsCoor()).len() < (dynamic_cast<Playable*>(*node)->getEnterRadius()))
     112      {
    115113
    116          break;
    117        }
    118      }
    119    }
     114        this->setPlayable(dynamic_cast<Playable*>(*node));
    120115
    121    if (likely(this->playable != NULL))
    122      this->playable->process(event);
    123  }
     116        break;
     117      }
     118  }
     119}
    124120
     121
     122void Player::process(const Event &event)
     123{
     124  if (event.type == KeyMapper::PEV_CHANGE_SHIP && event.bPressed)
     125  {
     126    this->enterNewPlayable();
     127  }
     128
     129  if (likely(this->playable != NULL))
     130    this->playable->process(event);
     131}
     132
  • trunk/src/world_entities/player.h

    r9059 r9061  
    3838
    3939    void              weaponConfigChanged();
     40    void              enterNewPlayable();
    4041
    4142    // eventListener extension.
  • trunk/src/world_entities/projectiles/laser.cc

    r8362 r9061  
    140140void Laser::draw () const
    141141{
    142   glMatrixMode(GL_MODELVIEW);
    143   glPushMatrix();
    144142  glPushAttrib(GL_ENABLE_BIT);
    145143  glDisable(GL_LIGHTING);
     144
     145  WorldEntity::draw();
     146/*  glMatrixMode(GL_MODELVIEW);
     147  glPushMatrix();
    146148
    147149  float matrix[4][4];
     
    151153  glScalef(2.0, 2.0, 2.0);
    152154  this->getModel()->draw();
     155  glPopMatrix();*/
     156
    153157  glPopAttrib();
    154   glPopMatrix();
    155158}
    156159
  • trunk/src/world_entities/script_trigger.cc

    r9006 r9061  
    2323
    2424CREATE_SCRIPTABLE_CLASS(ScriptTrigger, CL_SCRIPT_TRIGGER,
    25                             addMethod("setAbsCoor", ExecutorLua3<PNode,float,float,float>(&PNode::setAbsCoor))
    26                                 ->addMethod("getAbsCoorX", ExecutorLua0ret<PNode, float>(&PNode::getAbsCoorX))
    27                                 ->addMethod("getAbsCoorY", ExecutorLua0ret<PNode, float>(&PNode::getAbsCoorY))
    28                                 ->addMethod("getAbsCoorZ", ExecutorLua0ret<PNode, float>(&PNode::getAbsCoorZ))
    29                        );
     25            // Coordinates
     26             addMethod("setAbsCoor", ExecutorLua3<PNode,float,float,float>(&PNode::setAbsCoor))
     27             ->addMethod("getAbsCoorX", ExecutorLua0ret<PNode, float>(&PNode::getAbsCoorX))
     28             ->addMethod("getAbsCoorY", ExecutorLua0ret<PNode, float>(&PNode::getAbsCoorY))
     29             ->addMethod("getAbsCoorZ", ExecutorLua0ret<PNode, float>(&PNode::getAbsCoorZ))
     30            //Properties
     31             ->addMethod("setTarget", ExecutorLua1<ScriptTrigger, const std::string&>(&ScriptTrigger::setTarget))
     32             ->addMethod("setTriggerParent", ExecutorLua1<ScriptTrigger, const std::string&>(&ScriptTrigger::setTriggerParent))
     33             ->addMethod("setTriggerLasts", ExecutorLua1<ScriptTrigger, bool>(&ScriptTrigger::setTriggerLasts))
     34             ->addMethod("setInvert", ExecutorLua1<ScriptTrigger, bool>(&ScriptTrigger::setInvert))
     35             ->addMethod("setRadius", ExecutorLua1<ScriptTrigger, float>(&ScriptTrigger::setRadius))
     36             ->addMethod("setScript", ExecutorLua1<ScriptTrigger, const std::string&>(&ScriptTrigger::setScript))
     37             ->addMethod("setFunction", ExecutorLua1<ScriptTrigger, const std::string&>(&ScriptTrigger::setFunction))
     38             ->addMethod("setDebugDraw", ExecutorLua1<ScriptTrigger, bool>(&ScriptTrigger::setDebugDraw))
     39             ->addMethod("setAddToScript", ExecutorLua1<ScriptTrigger, bool>(&ScriptTrigger::setAddToScript))
     40             );
    3041
    3142
  • trunk/src/world_entities/space_ships/space_ship.cc

    r9008 r9061  
    5555
    5656CREATE_FACTORY(SpaceShip, CL_SPACE_SHIP);
    57 
     57#include "script_class.h"
     58CREATE_SCRIPTABLE_CLASS(SpaceShip, CL_SPACE_SHIP,
     59                        addMethod("hasPlayer", ExecutorLua0ret<Playable,bool>(&Playable::hasPlayer))
     60                       );
    5861
    5962/**
  • trunk/src/world_entities/world_entity.cc

    r9059 r9061  
    8282
    8383  // registering default reactions:
    84   this->subscribeReaction(CREngine::CR_OBJECT_DAMAGE, CL_WORLD_ENTITY);
     84  this->subscribeReaction(CREngine::CR_OBJECT_DAMAGE, /*CL_WORLD_ENTITY*/ CL_PROJECTILE);
    8585
    8686  this->toList(OM_NULL);
Note: See TracChangeset for help on using the changeset viewer.