Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 9608 in orxonox.OLD for branches


Ignore:
Timestamp:
Jul 30, 2006, 11:08:47 AM (18 years ago)
Author:
bensch
Message:

orxonox/proxy: added a new Turret for better network synchronisation

Location:
branches/proxy/src
Files:
3 edited
2 copied

Legend:

Unmodified
Added
Removed
  • branches/proxy/src/defs/class_id.h

    r9537 r9608  
    234234  CL_GROUND_TURRET              =    0x000003e5,
    235235  CL_SPACE_TURRET               =    0x000003e6,
    236   CL_GUIDED_MISSILE             =    0x000003e7,
    237   CL_HYPERBLAST                 =    0x000003e8,
    238   CL_BOOMERANG_PROJECTILE       =    0x00000309,
     236  CL_NETWORK_TURRET             =    0x000003e7,
     237  CL_GUIDED_MISSILE             =    0x000003e8,
     238  CL_HYPERBLAST                 =    0x000003e9,
     239  CL_BOOMERANG_PROJECTILE       =    0x0000030a,
    239240
    240241  // NPC's
  • branches/proxy/src/world_entities/WorldEntities.am

    r9235 r9608  
    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 \
  • branches/proxy/src/world_entities/npcs/ground_turret.h

    r9235 r9608  
    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
  • branches/proxy/src/world_entities/npcs/network_turret.cc

    r9606 r9608  
    1414*/
    1515
    16 #include "ground_turret.h"
     16#include "network_turret.h"
    1717#include "model.h"
    1818#include "world_entities/weapons/turret.h"
     
    2929#include "effects/explosion.h"
    3030
    31 CREATE_FACTORY(GroundTurret, CL_GROUND_TURRET);
     31#include "weapons/targeting_turret.h"
     32
     33CREATE_FACTORY(NetworkTurret, CL_NETWORK_TURRET);
    3234
    3335
     
    3537
    3638/**
    37  * constructs and loads a GroundTurret from a XML-element
     39 * constructs and loads a NetworkTurret from a XML-element
    3840 * @param root the XML-element to load from
    3941 */
    40 GroundTurret::GroundTurret(const TiXmlElement* root)
     42NetworkTurret::NetworkTurret(const TiXmlElement* root)
    4143    : NPC(root)
    4244{
     
    5052 * standard deconstructor
    5153 */
    52 GroundTurret::~GroundTurret ()
     54NetworkTurret::~NetworkTurret ()
     55{}
     56
     57
     58/**
     59 * initializes the NetworkTurret
     60 * @todo change this to what you wish
     61 */
     62void NetworkTurret::init()
    5363{
     64  this->setClassID(CL_NETWORK_TURRET, "NetworkTurret");
     65  this->loadModel("models/network_turret_#.obj", 5);
     66  this->weapon = new TargetingTurret();
     67  this->weapon->loadModel("models/guns/turret2.obj", 10);
     68
     69  this->setHealthMax(300);
     70  this->setHealth(300);
     71
     72  this->weaponHolder.addNodeFlags(PNODE_PROHIBIT_DELETE_WITH_PARENT);
     73
     74  this->weaponHolder.setRelCoor(0,25,0);
     75  this->weaponHolder.setParent(this);
    5476}
    5577
    5678
    5779/**
    58  * initializes the GroundTurret
    59  * @todo change this to what you wish
    60  */
    61 void GroundTurret::init()
    62 {
    63   this->setClassID(CL_GROUND_TURRET, "GroundTurret");
    64   this->loadModel("models/ground_turret_#.obj", 5);
    65   this->left = NULL;
    66   this->right = NULL;
    67 
    68   this->setHealthMax(300);
    69   this->setHealth(300);
    70 
    71   this->weaponHolder[0].addNodeFlags(PNODE_PROHIBIT_DELETE_WITH_PARENT);
    72   this->weaponHolder[1].addNodeFlags(PNODE_PROHIBIT_DELETE_WITH_PARENT);
    73 
    74   this->weaponHolder[0].setRelCoor(0,25,0);
    75   this->weaponHolder[0].setParent(this);
    76   this->weaponHolder[1].setParent(this);
    77 }
    78 
    79 
    80 /**
    81  * @brief loads a GroundTurret from a XML-element
     80 * @brief loads a NetworkTurret from a XML-element
    8281 * @param root the XML-element to load from
    8382 * @todo make the class Loadable
    8483 */
    85 void GroundTurret::loadParams(const TiXmlElement* root)
     84void NetworkTurret::loadParams(const TiXmlElement* root)
    8685{
    8786  // all the clases this Entity is directly derived from must be called in this way, to load all settings.
    8887  NPC::loadParams(root);
    89 
    90   /**
    91    * @todo: make the class Loadable
    92    */
    93   const TiXmlElement* element;
    94 
    95   element = root->FirstChildElement("weapon-left");
    96   if (element != NULL) element = element->FirstChildElement();
    97   this->left = dynamic_cast<Weapon*>( Factory::fabricate( element) );
    98   if (this->left)
    99   {
    100     this->left->setParent(this);
    101     this->left->toList(this->getOMListNumber());
    102     this->left->setRelCoor(0,10,-5);
    103     this->left->requestAction( WA_ACTIVATE);
    104     this->left->setParent(&this->weaponHolder[0]);
    105   }
    106 
    107   element = root->FirstChildElement("weapon-right");
    108   if (element != NULL)  if (element != NULL) element = element->FirstChildElement();
    109   this->right = dynamic_cast<Weapon*>( Factory::fabricate( element) );
    110   if (this->right)
    111   {
    112     this->right->setParent(this);
    113     this->right->toList(this->getOMListNumber());
    114     this->right->setRelCoor(0,10,5);
    115     this->left->requestAction( WA_ACTIVATE);
    116     this->right->setParent(&this->weaponHolder[0]);
    117   }
    11888}
    11989
    12090/**
    121  * advances the GroundTurret about time seconds
     91 * advances the NetworkTurret about time seconds
    12292 * @param time the Time to step
    12393 */
    124 void GroundTurret::tick(float dt)
     94void NetworkTurret::tick(float dt)
    12595{
    12696  if(this->getHealth() > 0.0f
    12797    ) // HACK <--- YOU ARE THE MOTHERFUCKER
    12898  {
    129     if (likely(this->left != NULL))
     99    if (likely(this->weapon != NULL))
    130100    {
    131101      //    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);
     102      this->weapon->requestAction(WA_SHOOT);
    138103    }
    139104  }
     
    143108 * draws this worldEntity
    144109 */
    145 void GroundTurret::draw () const
     110void NetworkTurret::draw () const
    146111{
    147112  WorldEntity::draw();
    148113
    149   if (this->left != NULL)
    150     this->left->draw();
    151   if (this->right != NULL)
    152     this->right->draw();
     114  if (this->weapon != NULL)
     115    this->weapon->draw();
    153116}
    154117
     
    159122 *
    160123 */
    161 void GroundTurret::postSpawn ()
    162 {
    163 }
     124void NetworkTurret::postSpawn ()
     125{}
    164126
    165127/**
     
    167129 *
    168130 */
    169 void GroundTurret::leftWorld ()
    170 {
    171 }
     131void NetworkTurret::leftWorld ()
     132{}
    172133
    173 void GroundTurret::destroy(WorldEntity* killer)
     134void NetworkTurret::destroy(WorldEntity* killer)
    174135{
    175136  this->setAbsDirSoft(Quaternion(-90, Vector(0,0,1)), 90);
  • branches/proxy/src/world_entities/npcs/network_turret.h

    r9606 r9608  
    11/*!
    2  * @file ground_turret.h
     2 * @file network_turret.h
    33 * @brief description
    44*/
    55
    6 #ifndef _GROUND_TURRET_H
    7 #define _GROUND_TURRET_H
     6#ifndef _NETWORK_TURRET_H
     7#define _NETWORK_TURRET_H
    88
    99#include "npcs/npc.h"
     
    1212
    1313//! A Class to ...
    14 class GroundTurret : public NPC
     14class NetworkTurret : public NPC
    1515{
    1616
    17  public:
    18   GroundTurret(const TiXmlElement* root = NULL);
    19   virtual ~GroundTurret();
     17public:
     18  NetworkTurret(const TiXmlElement* root = NULL);
     19  virtual ~NetworkTurret();
    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
     34private:
     35  PNode  weaponHolder;
     36  Weapon *weapon;
    3537};
    3638
    37 #endif /* _GROUND_TURRET_H */
     39#endif /* _NETWORK_TURRET_H */
Note: See TracChangeset for help on using the changeset viewer.