Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 9656 in orxonox.OLD for trunk/src/world_entities


Ignore:
Timestamp:
Aug 4, 2006, 11:01:28 PM (18 years ago)
Author:
bensch
Message:

orxonox/trunk: merged the proxy bache back with no conflicts

Location:
trunk/src/world_entities
Files:
32 edited
2 copied

Legend:

Unmodified
Added
Removed
  • trunk/src/world_entities/WorldEntities.am

    r9235 r9656  
    55                world_entities/npcs/ground_turret.cc \
    66                world_entities/npcs/space_turret.cc \
     7                world_entities/npcs/network_turret.cc \
    78                world_entities/npcs/generic_npc.cc \
    89                world_entities/npcs/door.cc \
     
    7980                npcs/ground_turret.h \
    8081                npcs/space_turret.h \
     82                npcs/network_turret.h \
    8183                npcs/door.cc \
    8284                npcs/repair_station.h \
  • trunk/src/world_entities/bsp_entity.cc

    r9406 r9656  
    5454  this->bspManager = NULL;
    5555
    56   this->name_handle = registerVarId( new SynchronizeableString( &this->name, &this->name_write, "name" ) );
     56  this->name_handle = registerVarId( new SynchronizeableString( &this->name, &this->name_write, "name", PERMISSION_MASTER_SERVER ) );
    5757
    5858  this->setSynchronized( true );
  • trunk/src/world_entities/environments/model_entity.cc

    r9406 r9656  
    3636  this->speed = NULL;
    3737  this->momentum = NULL;
     38
     39  this->setSynchronized(true);
    3840
    3941  if (root != NULL)
  • trunk/src/world_entities/environments/water.cc

    r9406 r9656  
    5959  // To test the Wave equation
    6060  //this->wave(5.0,4.0, 1, 10);
    61  
    62   height_handle = registerVarId( new SynchronizeableFloat( &height, &height, "height" ) );
    63   resX_handle = registerVarId( new SynchronizeableUInt( &resX, &resX, "resX" ) );
    64   resY_handle = registerVarId( new SynchronizeableUInt( &resY, &resY, "resY" ) );
    65   sizeX_handle = registerVarId( new SynchronizeableFloat( &sizeX, &sizeX, "sizeX" ) );
    66   sizeY_handle = registerVarId( new SynchronizeableFloat( &sizeY, &sizeY, "sizeY" ) );
     61
     62  height_handle = registerVarId( new SynchronizeableFloat( &height, &height, "height", PERMISSION_MASTER_SERVER ) );
     63  resX_handle = registerVarId( new SynchronizeableUInt( &resX, &resX, "resX", PERMISSION_MASTER_SERVER ) );
     64  resY_handle = registerVarId( new SynchronizeableUInt( &resY, &resY, "resY", PERMISSION_MASTER_SERVER ) );
     65  sizeX_handle = registerVarId( new SynchronizeableFloat( &sizeX, &sizeX, "sizeX", PERMISSION_MASTER_SERVER ) );
     66  sizeY_handle = registerVarId( new SynchronizeableFloat( &sizeY, &sizeY, "sizeY", PERMISSION_MASTER_SERVER ) );
    6767}
    6868
     
    313313    this->rebuildGrid();
    314314  }
    315  
     315
    316316  WorldEntity::varChangeHandler( id );
    317317}
  • trunk/src/world_entities/npcs/ground_turret.cc

    r9406 r9656  
    3939 */
    4040GroundTurret::GroundTurret(const TiXmlElement* root)
    41   : NPC(root)
     41    : NPC(root)
    4242{
    4343  this->init();
     
    5252GroundTurret::~GroundTurret ()
    5353{
    54 
    5554}
    5655
     
    8079
    8180/**
    82  * loads a GroundTurret from a XML-element
     81 * @brief loads a GroundTurret from a XML-element
    8382 * @param root the XML-element to load from
    8483 * @todo make the class Loadable
     
    8887  // all the clases this Entity is directly derived from must be called in this way, to load all settings.
    8988  NPC::loadParams(root);
    90 
    9189
    9290  /**
     
    126124void GroundTurret::tick(float dt)
    127125{
    128   if(this->getHealth() > 0.0f && State::getPlayer() &&
    129      State::getPlayer()->getPlayable() &&
    130      State::getPlayer()->getPlayable()->distance(this) < 120) // HACK
     126  if(this->getHealth() > 0.0f
     127    ) // HACK <--- YOU ARE THE MOTHERFUCKER
    131128  {
    132   if (likely(this->left != NULL))
    133   {
    134 //    this->left->tickW(dt);
    135     this->left->requestAction(WA_SHOOT);
    136   }
    137   if (likely(this->right != NULL))
    138   {
    139 //    this->right->tickW(dt);
    140     this->right->requestAction(WA_SHOOT);
    141   }
     129    if (likely(this->left != NULL))
     130    {
     131      //    this->left->tickW(dt);
     132      this->left->requestAction(WA_SHOOT);
     133    }
     134    if (likely(this->right != NULL))
     135    {
     136      //    this->right->tickW(dt);
     137      this->right->requestAction(WA_SHOOT);
     138    }
    142139  }
    143140}
     
    164161void GroundTurret::postSpawn ()
    165162{
    166 
    167163}
    168164
     
    173169void GroundTurret::leftWorld ()
    174170{
    175 
    176171}
    177172
  • trunk/src/world_entities/npcs/ground_turret.h

    r9235 r9656  
    1515{
    1616
    17  public:
     17public:
    1818  GroundTurret(const TiXmlElement* root = NULL);
    1919  virtual ~GroundTurret();
    2020
    21   void init();
    2221  virtual void loadParams(const TiXmlElement* root);
    2322
     
    3029  virtual void tick(float time);
    3130
    32  private:
    33    PNode  weaponHolder[2];
    34    Weapon *left, *right;
     31private:
     32  void init();
     33
     34
     35private:
     36  PNode  weaponHolder[2];
     37  Weapon *left, *right;
    3538};
    3639
  • trunk/src/world_entities/npcs/space_turret.cc

    r9235 r9656  
    7474  this->weaponHolder[0].setParent(this);
    7575  this->weaponHolder[1].setParent(this);
     76
     77  this->wLeftHandle = registerVarId( new SynchronizeableString( &this->wLeft, &this->wLeft, "weapon-left", PERMISSION_MASTER_SERVER ) );
     78  this->wRightHandle = registerVarId( new SynchronizeableString( &this->wRight, &this->wRight, "weapon-right", PERMISSION_MASTER_SERVER ) );
     79
    7680}
    7781
     
    98102  if (this->left)
    99103  {
     104    this->wLeft = element->Value();
     105
    100106    this->left->setParent(this);
    101107    this->left->toList(this->getOMListNumber());
     
    110116  if (this->right)
    111117  {
     118    this->wRight = element->Value();
     119
    112120    this->right->setParent(this);
    113121    this->right->toList(this->getOMListNumber());
     
    117125  }
    118126}
     127
     128
     129/**
     130 * sets the left weapon called from net sync
     131 * @param wLeft the left weapon string
     132 */
     133void SpaceTurret::setWeaponLeft(const std::string& wLeft)
     134{
     135
     136}
     137
     138/**
     139 * sets the left weapon called from net sync
     140 * @param wRught the right weapon string
     141 */
     142void SpaceTurret::setWeaponRight(const std::string& wRight)
     143{}
    119144
    120145/**
     
    198223
    199224}
     225
     226
     227
     228/**
     229 * handler for changes on registred vars
     230 * @param id id's which changed
     231 */
     232void SpaceTurret::varChangeHandler( std::list< int > & id )
     233{
     234  if ( std::find( id.begin(), id.end(), this->wLeftHandle ) != id.end())
     235  {
     236    this->setWeaponLeft(this->wLeft);
     237  }
     238
     239  if ( std::find( id.begin(), id.end(), this->wRightHandle ) != id.end() )
     240  {
     241    this->setWeaponRight(this->wRight);
     242  }
     243
     244
     245  WorldEntity::varChangeHandler( id );
     246}
     247
  • trunk/src/world_entities/npcs/space_turret.h

    r9235 r9656  
    88
    99#include "npcs/npc.h"
     10
     11#include <string>
     12#include <list>
     13
    1014
    1115class Weapon;
     
    2024
    2125  virtual void loadParams(const TiXmlElement* root);
     26  virtual void varChangeHandler( std::list< int > & id );
     27
     28
     29  void setWeaponLeft(const std::string& wLeft);
     30  void setWeaponRight(const std::string& wRight);
    2231
    2332  virtual void postSpawn ();
     
    3645  PNode  weaponHolder[2];
    3746  Weapon *left, *right;
     47
     48  std::string wLeft;
     49  std::string wRight;
     50  int wLeftHandle;
     51  int wRightHandle;
    3852};
    3953
  • trunk/src/world_entities/playable.cc

    r9406 r9656  
    6868
    6969
    70   registerVar( new SynchronizeableInt( &score, &score, "score" ) );
     70  this->teamChangeHandler = registerVarId( new SynchronizeableInt( &this->teamId, &this->teamId, "team-id", PERMISSION_MASTER_SERVER ) );
     71
     72  registerVar( new SynchronizeableInt( &score, &score, "score", PERMISSION_MASTER_SERVER ) );
    7173  registerVar( new SynchronizeableBool( &bFire, &bFire, "bFire", PERMISSION_OWNER));
    7274}
     
    139141bool Playable::addWeapon(Weapon* weapon, int configID, int slotID)
    140142{
     143  weapon->setOwner(this->getOwner());
     144
     145
    141146  if(this->weaponMan.addWeapon(weapon, configID, slotID))
    142147  {
     
    272277  return false;
    273278}
     279
     280
     281/**
     282 * @brief sets the TeamID and all the properties needed to be visible on the Playable
     283 * @param teamID: the new TeamID of the Entity
     284 */
     285void Playable::setTeam(int teamID)
     286{
     287  /// Derive this function to make it look different with differen groups.
     288  PRINTF(4)("No special team specific function implemented for %s::%s in Team %d\n", this->getClassCName(), this->getCName(), teamID);
     289}
     290
    274291
    275292/**
     
    512529  "FirstPerson"
    513530};
     531
     532
     533/**
     534 * handler for changes on registred vars
     535 * @param id id's which changed
     536 */
     537void Playable::varChangeHandler( std::list< int > & id )
     538{
     539  if ( std::find( id.begin(), id.end(), this->teamChangeHandler) != id.end() )
     540  {
     541    this->setTeam(this->teamId);
     542  }
     543
     544  WorldEntity::varChangeHandler(id);
     545}
  • trunk/src/world_entities/playable.h

    r9406 r9656  
    1111#include "event.h"
    1212#include <vector>
     13#include <list>
    1314
    1415#include "world_entities/weapons/weapon_manager.h"
     
    4344
    4445  virtual void loadParams(const TiXmlElement* root);
     46  void varChangeHandler( std::list< int > & id );
    4547
    4648  // Weapon and Pickups
     
    6264  inline const std::vector<int>& getEventList() { return this->events; };
    6365
     66
    6467  // Camera and Playmode
    6568  void attachCamera();
     
    7275  void setPlayDirection(float angle, float dirX, float dirY, float dirZ, float speed = 0.0f);
    7376
     77  // Networking interface
    7478  inline void setScore( int score ) { this->score = score; }
    7579  inline int  getScore() { return this->score; }
     80  inline void setTeamId( int teamId) { this->teamId = teamId;}
     81  inline int getTeamId() const { return this->teamId; }
     82  virtual void setTeam(int teamID);
     83
    7684
    7785  void setEnterRadius(float radius) { this->enterRadius = radius; };
     
    8593  virtual void tick(float dt);
    8694
     95
     96  inline bool beFire() const { return this->bFire; }
     97  inline void fire(bool bF) { this->bFire = bF;}
     98
    8799  // Transformations:
    88100  static Playable::Playmode stringToPlaymode(const std::string& playmode);
    89101  static const std::string& playmodeToString(Playable::Playmode playmode);
    90102  static const std::string playmodeNames[];
    91 
    92   inline bool beFire(){ return this->bFire; }
    93   inline void fire(bool bF){ this->bFire = bF;}
    94103
    95104protected:
     
    117126
    118127  int                   score;              //!< players score
     128  int                   teamChangeHandler;  //!< handler id for team changes network sync
     129  int                   teamId;             //!< id of the current team
    119130
    120131  bool                  bDead;
     
    124135  float                 enterRadius;        //!< How far one can be away from the Playable to enter it.
    125136
    126   WorldEntity* collider;
     137  WorldEntity*          collider;
    127138};
    128139
  • trunk/src/world_entities/power_ups/param_power_up.cc

    r9406 r9656  
    4343  if( root != NULL)
    4444    this->loadParams(root);
    45  
    46   registerVar( new SynchronizeableInt( (int*)&type, (int*)&type, "type" ) );
    47   registerVar( new SynchronizeableFloat( &value, &value, "value" ) );
    48   registerVar( new SynchronizeableFloat( &max_value, &max_value, "max_value" ) );
    49   registerVar( new SynchronizeableFloat( &min_value, &min_value, "min_value" ) );
     45
     46  registerVar( new SynchronizeableInt( (int*)&type, (int*)&type, "type", PERMISSION_MASTER_SERVER ) );
     47  registerVar( new SynchronizeableFloat( &value, &value, "value", PERMISSION_MASTER_SERVER ) );
     48  registerVar( new SynchronizeableFloat( &max_value, &max_value, "max_value", PERMISSION_MASTER_SERVER ) );
     49  registerVar( new SynchronizeableFloat( &min_value, &min_value, "min_value", PERMISSION_MASTER_SERVER ) );
    5050}
    5151
  • trunk/src/world_entities/projectiles/guided_missile.h

    r9235 r9656  
    1313class ParticleEmitter;
    1414class FastFactory;
    15 class Aim;
    1615
    1716class GuidedMissile : public Projectile
  • trunk/src/world_entities/projectiles/laser.cc

    r9406 r9656  
    8888  }
    8989
    90   this->setDamage(0);
     90  this->setDamage(20);
    9191  this->setHealth(0);
    9292}
  • trunk/src/world_entities/projectiles/projectile.cc

    r9406 r9656  
    4545  this->explosionBuffer = NULL;
    4646  this->engineBuffer = NULL;
     47
     48  //this->addNodeFlags(PNODE_PROHIBIT_DELETE_WITH_PARENT);
    4749}
    4850
  • trunk/src/world_entities/script_trigger.cc

    r9406 r9656  
    4949 */
    5050ScriptTrigger::ScriptTrigger(const TiXmlElement* root)
    51 { PRINT(1)("testerror\n");
     51{
    5252  this->setClassID(CL_SCRIPT_TRIGGER, "ScriptTrigger");
    5353  this->toList(OM_COMMON);
  • trunk/src/world_entities/skybox.cc

    r9406 r9656  
    9696{
    9797  this->rebuild();
    98  
    99   textureName_handle = registerVarId( new SynchronizeableString( &textureName, &textureName, "textureName") );
    100   size_handle = registerVarId( new SynchronizeableFloat( &size, &size, "size" ) );
     98
     99  textureName_handle = registerVarId( new SynchronizeableString( &textureName, &textureName, "textureName", PERMISSION_MASTER_SERVER) );
     100  size_handle = registerVarId( new SynchronizeableFloat( &size, &size, "size", PERMISSION_MASTER_SERVER ) );
    101101}
    102102
     
    297297{
    298298  bool somethinChanged = false;
    299  
     299
    300300  if ( std::find( id.begin(), id.end(), textureName_handle ) != id.end() )
    301301  {
     
    303303    setTexture( textureName );
    304304  }
    305  
     305
    306306  if ( std::find( id.begin(), id.end(), size_handle ) != id.end() )
    307307  {
    308308    somethinChanged = true;
    309309  }
    310  
     310
    311311  rebuild();
    312  
     312
    313313  WorldEntity::varChangeHandler( id );
    314314}
  • trunk/src/world_entities/space_ships/hover.cc

    r9235 r9656  
    330330  this->shiftCoor (this->velocity * dt);
    331331
    332     // limit the maximum rotation speed.
     332  // limit the maximum rotation speed.
    333333  if (this->rotation != 0.0f)
    334334  {
  • trunk/src/world_entities/space_ships/space_ship.cc

    r9494 r9656  
    234234  this->burstSystem->setColor(1.0, .8,.8,.8,.0);
    235235
    236   registerVar( new SynchronizeableVector( &velocity, &velocity, "velocity" ) );
     236  registerVar( new SynchronizeableVector( &velocity, &velocity, "velocity", PERMISSION_MASTER_SERVER ) );
    237237  registerVar( new SynchronizeableQuaternion( &mouseDir, &mouseDir, "mousedir", PERMISSION_OWNER ) );
    238238
  • trunk/src/world_entities/space_ships/turbine_hover.cc

    r9494 r9656  
    9191
    9292  this->loadModel("models/ships/hoverglider_mainbody.obj");
     93
    9394}
    9495
     
    222223  registerVar( new SynchronizeableFloat( &cameraLook, &cameraLook, "cameraLook", PERMISSION_OWNER ) );
    223224  registerVar( new SynchronizeableFloat( &rotation, &rotation, "rotation", PERMISSION_OWNER ) );
     225
     226  if( State::isOnline())
     227    toList( OM_PLAYERS );
    224228}
    225229
     
    231235{
    232236  Playable::loadParams(root);
     237}
     238
     239
     240void TurbineHover::setBoostColor(const Color& color)
     241{
     242  this->burstSystem->setColor(0.0, color);
     243  this->burstSystem->setColor(0.2, color * 0.6);
     244  this->burstSystem->setColor(0.5, color * .3 + Color(0.5, 0.5, 0.8, 0.3));
     245  this->burstSystem->setColor(1.0, 0.8, 0.8, 0.8, 0.0);
     246
     247  printf(":::::::::::::::::::::::\n");
     248  this->burstSystem->debug();
    233249}
    234250
     
    256272
    257273}
     274
     275void TurbineHover::setTeam(int teamID)
     276{
     277  printf("::::::::::::::::: TEAM ::: %d\n", teamID);
     278  if (teamID == 0)
     279  {
     280    this->setBoostColor(Color::blue);
     281  }
     282  else if (teamID == 1)
     283  {
     284    this->setBoostColor(Color::red);
     285  }
     286
     287  ///HACK this is very much hard coded.set the owner of the weapons
     288  this->getWeaponManager().getWeapon(0)->setOwner(this->getOwner());
     289  this->getWeaponManager().getWeapon(1)->setOwner(this->getOwner());
     290
     291  //choose collision list
     292  if( State::isOnline())
     293  {
     294    if( teamID == 0)
     295      toList( OM_GROUP_00 );
     296    else if(teamID == 1)
     297      toList( OM_GROUP_01);
     298  }
     299
     300
     301  // set the local team id, very important
     302  this->setTeamId(teamID);
     303}
     304
    258305
    259306
     
    527574  }
    528575}
     576
     577
     578/**
     579 *  respawning function called by the GameRules
     580 */
     581void TurbineHover::respawn( )
     582{
     583
     584  Playable::respawn();
     585}
  • trunk/src/world_entities/space_ships/turbine_hover.h

    r8490 r9656  
    99
    1010#include "playable.h"
     11
     12#include "color.h"
    1113
    1214// Forward Declaration
     
    2123    virtual ~TurbineHover();
    2224
     25    void setBoostColor(const Color& color);
     26
    2327    virtual void loadParams(const TiXmlElement* root);
    2428    virtual void setPlayDirection(const Quaternion& rot, float speed = 0.0f);
     
    2630    virtual void leave();
    2731
     32    virtual void setTeam(int teamID);
     33
    2834    virtual void postSpawn();
    2935    virtual void leftWorld();
     36    virtual void respawn();
    3037
    3138    virtual void collidesWith(WorldEntity* entity, const Vector& location);
  • trunk/src/world_entities/spawning_point.cc

    r9494 r9656  
    207207void SpawningPoint::sendRespawnMessage( int uniqueId )
    208208{
    209 #warning this byte array is not being deleted according to valginrd
    210   byte * buf = new byte[2*INTSIZE];
     209  byte buf[2*INTSIZE];
    211210
    212211  assert( Converter::intToByteArray( this->getUniqueID(), buf, INTSIZE ) == INTSIZE );
    213212  assert( Converter::intToByteArray( uniqueId, buf + INTSIZE, INTSIZE ) == INTSIZE );
    214213
    215   MessageManager::getInstance()->sendMessage( MSGID_RESPAWN, buf, 2*INTSIZE, RT_ALL_BUT_ME, 0, MP_HIGHBANDWIDTH );
    216 }
    217 
    218 bool SpawningPoint::respawnMessageHandler( MessageId messageId, byte * data, int dataLength, void * someData, int userId )
     214  MessageManager::getInstance()->sendMessage( MSGID_RESPAWN, buf, 2*INTSIZE, RT_ALL_BUT_ME, NET_UNASSIGNED, MP_HIGHBANDWIDTH );
     215}
     216
     217/**
     218 * message handler for respawn message
     219 */
     220bool SpawningPoint::respawnMessageHandler( MessageType messageType, byte * data, int dataLength, void * someData, int senderId, int destinationId  )
    219221{
    220222  if ( SharedNetworkData::getInstance()->isMasterServer() /*|| SharedNetworkData::getInstance()->isProxyServerActive()*/)
  • trunk/src/world_entities/spawning_point.h

    r9494 r9656  
    7070
    7171    void sendRespawnMessage( int uniqueId );
    72     static bool respawnMessageHandler( MessageId messageId, byte * data, int dataLength, void * someData, int userId );
     72    static bool respawnMessageHandler( MessageType messageType, byte * data, int dataLength, void * someData, int senderId, int destinationId );
    7373
    7474
  • trunk/src/world_entities/weapons/aim.cc

    r9406 r9656  
    5050Aim::~Aim ()
    5151{
    52   if (this->material)
    53     delete this->material;
    54 
    5552/*  if (this->text != NULL)
    5653    delete this->text;*/
     
    7067
    7168  this->setBindNode(this);
    72   this->material = new Material;
    7369  this->source = NULL;
    7470
    75   this->range = 10000;
     71  this->range = 1000;
    7672  this->angle = M_PI_4;
    77   this->group = OM_GROUP_01;
     73  this->targetGroup = OM_GROUP_01;
    7874  this->anim = new tAnimation<Aim>(this, &Aim::setSize);
    7975  this->anim->setInfinity(ANIM_INF_CONSTANT);
     
    10399  LoadParam(root, "rotation-speed", this, Aim, setRotationSpeed)
    104100      .describe("the Speed with which the Aim should rotate");
     101
     102  LoadParam(root, "target-group", this, Aim, setTargetGroupS);
    105103}
    106104
     
    108106{
    109107  ObjectManager::EntityList::iterator entity;
    110 
    111   for (entity = State::getObjectManager()->getObjectList(group).begin();
    112        entity != State::getObjectManager()->getObjectList(group).end();
     108  //printf("%d\n", this->targetGroup);
     109  for (entity = State::getObjectManager()->getObjectList(this->targetGroup).begin();
     110       entity != State::getObjectManager()->getObjectList(this->targetGroup).end();
    113111       entity ++)
    114112  {
    115113    diffVec = ( (*entity)->getAbsCoor() - this->source->getAbsCoor() );
    116114
    117     if ( diffVec.len() < range &&  acos( (this->source->getAbsDirX()).dot(diffVec)/(diffVec.len() * (this->source->getAbsDirX()).len() ) )  < angle)
     115    if ( diffVec.len() < range )//&&  acos( (this->source->getAbsDirX()).dot(diffVec)/(diffVec.len() * (this->source->getAbsDirX()).len() ) )  < angle)
    118116    {
    119117      //if (this->getParent() != (*entity))
    120118      {
     119        printf("found target::: %d %s::%s\n", (*entity)->getOMListNumber(), (*entity)->getClassCName(), (*entity)->getCName());
    121120        this->anim->replay();
    122121        this->setParentSoft(*entity, 5);
     
    128127   //if no target found:
    129128   this->setParent(PNode::getNullParent());
    130 
    131 
    132 
    133 }
    134 
     129}
     130
     131void Aim::setTargetGroupS(const std::string& groupName)
     132{
     133  OM_LIST id = ObjectManager::StringToOMList(groupName);
     134  if (id != OM_NULL)
     135    this->setTargetGroup(id);
     136  else
     137    PRINTF(2)("List %s not found for targetting\n", groupName.c_str());
     138}
    135139
    136140/**
     
    149153void Aim::setTexture(const std::string& textureFile)
    150154{
    151   this->material->setDiffuseMap(textureFile);
     155  this->material.setDiffuseMap(textureFile);
    152156}
    153157
     
    170174//only look for target if the aim hasn`t locked a target yet or if the actual target is out of range
    171175   if(this->getParent() == PNode::getNullParent() ||
    172       diffVec.len() > range ||
    173      ( acos( (this->source->getAbsDirX()).dot(diffVec)/(diffVec.len() * (this->source->getAbsDirX()).len() ) ) > angle))
     176      diffVec.len() > range )// ||
     177     //( acos( (this->source->getAbsDirX()).dot(diffVec)/(diffVec.len() * (this->source->getAbsDirX()).len() ) ) > angle))
    174178    {
    175179     this->setParentSoft(PNode::getNullParent(),5);
     
    213217
    214218  glRotatef(this->getAbsDir2D(), 0,0,1);
    215   this->material->select();
     219  this->material.select();
    216220  glBegin(GL_TRIANGLE_STRIP);
    217221  glTexCoord2f(0, 0);
  • trunk/src/world_entities/weapons/aim.h

    r7221 r9656  
    1111#include "object_manager.h"
    1212
     13#include "material.h"
     14
    1315// FORWARD DECLARATION
    1416class Model;
    1517class Text;
    16 class Material;
    1718class TiXmlElement;
    1819template<class T> class tAnimation;
     
    2526 * Also the Aim is a Element2D, as it draws a cross onto the Target.
    2627 */
    27 class Aim : public PNode, public Element2D {
     28class Aim : public PNode, public Element2D
     29{
    2830
    29  public:
     31public:
    3032  Aim(PNode* source, const TiXmlElement* root = NULL);
    3133  virtual ~Aim();
    3234
    33   void init();
    3435  virtual void loadParams(const TiXmlElement* root);
    3536
     
    3738
    3839  inline void selectTarget(PNode* target) { this->setParent(target); };
    39   inline PNode* getTarget(PNode* target) { return this->getParent(); };
     40  inline PNode* getTarget(PNode* target) const { return this->getParent(); };
    4041
    4142  void searchTarget();
    4243
    43   void setRange(float range){this->range = range;};
    44   void setAngle(float angle){this->angle = angle;};
    45   void setGroup(OM_LIST group){this->group = group;};
     44  void setRange(float range) {this->range = range;};
     45  void setAngle(float angle) {this->angle = angle;};
     46  void setTargetGroup(OM_LIST group) { this->targetGroup = group; };
     47  void setTargetGroupS(const std::string& grounName);
    4648
    4749  void setSize(float size);
     
    5355  virtual void draw() const;
    5456
    55  private:
    56    Material*        material;             //!< a material for the Aim.
    57    float            rotationSpeed;        //!< Speed of the Rotation.
    58    tAnimation<Aim>* anim;
     57private:
     58  void init();
    5959
    60    float            range;                //!<
    61    float            angle;                //!<
    62    Vector           diffVec;
    63    OM_LIST          group;
    6460
    65    PNode*           source;               //!< Where this Shot has come from.
     61private:
     62  Material         material;             //!< a material for the Aim.
     63  float            rotationSpeed;        //!< Speed of the Rotation.
     64  tAnimation<Aim>* anim;
    6665
    67    Text*            text;                 //!< A Text to display onto this Node. (distance to Target)
     66  float            range;                //!<
     67  float            angle;                //!<
     68  Vector           diffVec;
     69  OM_LIST          targetGroup;
     70
     71  PNode*           source;               //!< Where this Shot has come from.
     72
     73  //   Text             text;                 //!< A Text to display onto this Node. (distance to Target)
    6874};
    6975
  • trunk/src/world_entities/weapons/aiming_turret.cc

    r9406 r9656  
    3838*/
    3939AimingTurret::AimingTurret ()
    40   : Weapon()
     40    : Weapon(), target(this)
    4141{
    4242  this->init();
     
    4646
    4747AimingTurret::AimingTurret(const TiXmlElement* root)
     48    : target(this)
    4849{
    4950  this->init();
     
    5859{
    5960  // model will be deleted from WorldEntity-destructor
    60 //  delete this->target;
     61  //  delete this->target;
    6162}
    6263
     
    9192  //this->getProjectileFactory()->prepare(100);
    9293
    93   this->target = new Aim(this);
    94   this->target->setVisibility(false);
    95   this->target->setRange(400);
    96   this->target->setAngle(M_PI_2);
     94  this->target.addNodeFlags(PNODE_PROHIBIT_DELETE_WITH_PARENT | PNODE_PROHIBIT_CHILD_DELETE);
     95  this->target.setVisibility(false);
     96  this->target.setRange(400);
     97  this->target.setAngle(M_PI_2);
    9798
    9899  this->setActionSound(WA_SHOOT, "sound/explosions/explosion_3.wav");
     
    110111void AimingTurret::activate()
    111112{
    112   this->target->setVisibility(true);
     113  this->target.setVisibility(true);
    113114}
    114115
    115116void AimingTurret::deactivate()
    116117{
    117   this->target->setVisibility(false);
     118  this->target.setVisibility(false);
    118119}
    119120
     
    123124    return;
    124125  Quaternion quat;
    125   Vector direction = this->target->getAbsCoor() - this->getAbsCoor();
     126  Vector direction = this->target.getAbsCoor() - this->getAbsCoor();
    126127
    127128  direction.normalize();
    128129
    129130  if (likely (this->getParent() != NULL))
    130     quat = Quaternion(direction, this->getParent()->getAbsDir().apply(Vector(0,1,0))) * Quaternion ( -M_PI_2, Vector(0,1,0)) ;
     131    //quat = Quaternion(direction, this->getParent()->getAbsDirY()) * Quaternion ( -M_PI_2, Vector(0,1,0)) ;
     132    quat = Quaternion ( M_PI_2, this->getParent()->getAbsDirY()) * Quaternion::lookAt(this->getAbsCoor(), this->target.getAbsCoor(), this->getParent()->getAbsDirY());
    131133  else
    132     quat = Quaternion(direction, Vector(0,1,0)) * Quaternion ( -M_PI_2, Vector(0,1,0)) ;
     134    //quat = Quaternion(direction, Vector(0,1,0)) * Quaternion ( -M_PI_2, Vector(0,1,0)) ;
     135    quat = Quaternion ( M_PI_2, Vector(0,1,0)) * Quaternion::lookAt(this->getAbsCoor(), this->target.getAbsCoor(), Vector(0,1,0));
    133136
    134137  this->setAbsDirSoft(quat, 5);
    135138
    136   this->target->tick(dt);
     139  this->target.tick(dt);
    137140}
    138141
     
    143146    return;
    144147
    145   pj->setVelocity(/*this->getVelocity()+*/(this->getAbsDir().apply(Vector(1,0,0))*250.0 + VECTOR_RAND(13)
    146             /*target->getAbsCoor() - this->getAbsCoor()*/)*.5);//this->getVelocity());
     148  pj->setVelocity(/*this->getVelocity()+*/(this->getAbsDirX()*250.0 + VECTOR_RAND(4)
     149                                          /*target.getAbsCoor() - this->getAbsCoor()*/)*.5);//this->getVelocity());
    147150
    148151  pj->setParent(PNode::getNullParent());
  • trunk/src/world_entities/weapons/aiming_turret.h

    r8777 r9656  
    88
    99#include "weapon.h"
    10 
     10#include "aim.h"
    1111/* FORWARD DECLARATION */
    12 class Aim;
    1312
    1413class AimingTurret : public Weapon
    15   {
    16   public:
    17     AimingTurret ();
    18     AimingTurret(const TiXmlElement* root);
    19     virtual ~AimingTurret ();
     14{
     15public:
     16  AimingTurret ();
     17  AimingTurret(const TiXmlElement* root);
     18  virtual ~AimingTurret ();
    2019
    21     void init();
    22     virtual void loadParams(const TiXmlElement* root);
     20  virtual void loadParams(const TiXmlElement* root);
    2321
    24     virtual void activate();
    25     virtual void deactivate();
     22  void setTargetGroup(OM_LIST targetGroup) { this->target.setTargetGroup(targetGroup); };
    2623
    27     virtual void tick(float dt);
    28     virtual void fire();
     24  virtual void activate();
     25  virtual void deactivate();
     26
     27  virtual void tick(float dt);
     28  virtual void fire();
    2929
    3030
    31     virtual void draw() const;
     31  virtual void draw() const;
    3232
    33   private:
    34     Aim*          target;
    35   };
     33private:
     34  void init();
     35
     36private:
     37  Aim           target;
     38};
    3639
    3740#endif /* _AIMING_TURRET_H */
  • trunk/src/world_entities/weapons/laser_cannon.cc

    r9235 r9656  
    121121    return;
    122122
     123  // make this to let the onKill(...) fuction get the stuff
     124  pj->setOwner(this->getOwner());
     125
    123126  pj->setParent(PNode::getNullParent());
    124127
  • trunk/src/world_entities/weapons/targeting_turret.cc

    r9406 r9656  
    1717#include "targeting_turret.h"
    1818
    19 #include "weapon_manager.h"
    20 #include "aim.h"
    21 #include "world_entities/projectiles/projectile.h"
     19#include "projectiles/projectile.h"
    2220
    2321#include "model.h"
     
    2523#include "animation3d.h"
    2624
     25#include "util/loading/load_param.h"
    2726#include "util/loading/factory.h"
    2827
     
    3029
    3130
    32 
    33 
    34 /**
    35  *  standard constructor
    36 
    37    creates a new weapon
    38 */
    39 TargetingTurret::TargetingTurret ()
    40   : Weapon()
    41 {
    42   this->init();
    43 
    44 }
    45 
    46 
    4731TargetingTurret::TargetingTurret(const TiXmlElement* root)
     32  : target(this)
    4833{
    4934  this->init();
     
    9176  //this->getProjectileFactory()->prepare(100);
    9277
    93   this->target = new Aim(this);
    94   this->target->setVisibility(false);
    95   this->target->setRange(1000);
    96   this->target->setAngle(M_PI_4);
    97   this->lockedTarget = this->target;
     78  this->target.setVisibility(false);
     79  this->target.addNodeFlags(PNODE_PROHIBIT_DELETE_WITH_PARENT | PNODE_PROHIBIT_CHILD_DELETE);
     80  this->target.setRange(1000);
     81  this->target.setAngle(M_PI_4);
     82  this->lockedTarget = &this->target;
    9883
    9984  this->lockedTime = 0;
     
    11297  Weapon::loadParams(root);
    11398
     99  LoadParam(root, "target-group", &target, Aim, setTargetGroupS);
     100
    114101}
    115102
     
    122109void TargetingTurret::deactivate()
    123110{
    124   this->target->setVisibility(false);
     111  this->target.setVisibility(false);
    125112}
    126113
     
    130117    return;
    131118
     119  this->target.tick(dt);
     120
    132121  if( lockedTime >= neededLockTime )
    133122   {
    134     lockedTarget = this->target->getParent();
     123    lockedTarget = this->target.getParent();
    135124    lockedTime = 0;
    136125   }
    137126
    138   this->target->tick(dt);
    139127
    140   if(this->target->getParent() == PNode::getNullParent())
     128  if(this->target.getParent() == PNode::getNullParent())
    141129   lockedTime = 0;
    142130  else
     
    159147  pj->setAbsDir(this->getAbsDir());
    160148  pj->activate();
    161 
    162149}
    163150
  • trunk/src/world_entities/weapons/targeting_turret.h

    r8777 r9656  
    88
    99#include "weapon.h"
    10 
    11 /* FORWARD DECLARATION */
    12 class Aim;
     10#include "aim.h"
    1311
    1412class TargetingTurret : public Weapon
    15   {
    16   public:
    17     TargetingTurret ();
    18     TargetingTurret(const TiXmlElement* root);
    19     virtual ~TargetingTurret ();
     13{
     14public:
     15  TargetingTurret(const TiXmlElement* root = NULL);
     16  virtual ~TargetingTurret ();
    2017
    21     void init();
    22     virtual void loadParams(const TiXmlElement* root);
     18  virtual void loadParams(const TiXmlElement* root);
    2319
    24     virtual void activate();
    25     virtual void deactivate();
     20  virtual void activate();
     21  virtual void deactivate();
    2622
    27     virtual void tick(float dt);
    28     virtual void fire();
     23  virtual void tick(float dt);
     24  virtual void fire();
    2925
    30     virtual void draw() const;
     26  virtual void draw() const;
    3127
    32   private:
    33     Aim*           target;
    34     PNode*         lockedTarget;
    35     float          lockedTime;
    36     float          neededLockTime;
    37   };
     28  void setTargetGroup(OM_LIST targetGroup) { this->target.setTargetGroup(targetGroup); };
     29  const PNode* getLockedTarget() const { return lockedTarget; };
     30
     31private:
     32  void init();
     33
     34private:
     35  Aim            target;
     36  PNode*         lockedTarget;
     37  float          lockedTime;
     38  float          neededLockTime;
     39};
    3840
    3941#endif /* _TARGETING_TURRET_H */
  • trunk/src/world_entities/weapons/test_gun.cc

    r9002 r9656  
    177177  if (pj == NULL)
    178178    return;
     179
     180  // set the owner
     181  pj->setOwner(this->getOwner());
    179182
    180183  pj->setParent(PNode::getNullParent());
  • trunk/src/world_entities/world_entity.cc

    r9494 r9656  
    2828#include "util/loading/resource_manager.h"
    2929#include "util/loading/load_param.h"
    30 #include "vector.h"
    3130#include "obb_tree.h"
    3231
     
    8685  this->toList(OM_NULL);
    8786
    88   registerVar( new SynchronizeableString( &this->md2TextureFileName, &this->md2TextureFileName, "md2TextureFileName" ) );
    89   modelFileName_handle = registerVarId( new SynchronizeableString( &modelFileName, &modelFileName, "modelFileName" ) );
    90   scaling_handle = registerVarId( new SynchronizeableFloat( &scaling, &scaling, "scaling" ) );
    91   list_handle = registerVarId( new SynchronizeableInt( (int*)&objectListNumber, &list_write, "list" ) );
    92 
    93   health_handle = registerVarId( new SynchronizeableFloat( &this->health, &this->health_write, "health" ) );
    94   healthMax_handle = registerVarId( new SynchronizeableFloat( &this->healthMax, &this->healthMax_write, "maxHealth" ) );
     87  registerVar( new SynchronizeableString( &this->md2TextureFileName, &this->md2TextureFileName, "md2TextureFileName", PERMISSION_MASTER_SERVER ) );
     88  modelFileName_handle = registerVarId( new SynchronizeableString( &modelFileName, &modelFileName, "modelFileName", PERMISSION_MASTER_SERVER ) );
     89  scaling_handle = registerVarId( new SynchronizeableFloat( &scaling, &scaling, "scaling", PERMISSION_MASTER_SERVER ) );
     90  list_handle = registerVarId( new SynchronizeableInt( (int*)&objectListNumber, &list_write, "list", PERMISSION_MASTER_SERVER ) );
     91
     92  health_handle = registerVarId( new SynchronizeableFloat( &this->health, &this->health_write, "health", PERMISSION_MASTER_SERVER ) );
     93  healthMax_handle = registerVarId( new SynchronizeableFloat( &this->healthMax, &this->healthMax_write, "maxHealth", PERMISSION_MASTER_SERVER ) );
    9594}
    9695
     
    141140  .describe("The Health the WorldEntity has at this moment")
    142141  .defaultValues(1.0f);
     142
     143  LoadParam(root, "list", this, WorldEntity, toListS);
    143144}
    144145
     
    478479}
    479480
     481void WorldEntity::toListS(const std::string& listName)
     482{
     483  OM_LIST id = ObjectManager::StringToOMList(listName);
     484  if (id != OM_NULL)
     485    this->toList(id);
     486  else
     487    PRINTF(2)("List %s not found\n", listName.c_str());
     488}
     489
     490
    480491void WorldEntity::toReflectionList()
    481492{
     
    822833  PRINT(0)("WorldEntity %s::%s  (DEBUG)\n", this->getClassCName(), this->getCName());
    823834  this->debugNode();
    824   PRINT(0)("List: %s ; ModelCount %d - ", ObjectManager::OMListToString(this->objectListNumber) , this->models.size());
     835  PRINT(0)("List: %s ; ModelCount %d - ", ObjectManager::OMListToString(this->objectListNumber).c_str(), this->models.size());
    825836  for (unsigned int i = 0; i < this->models.size(); i++)
    826837  {
  • trunk/src/world_entities/world_entity.h

    r9298 r9656  
    115115  /* --- Object Manager Block --- */
    116116  void toList(OM_LIST list);
     117  void toListS(const std::string& listName);
    117118
    118119  void toReflectionList();
Note: See TracChangeset for help on using the changeset viewer.