Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 3583 in orxonox.OLD


Ignore:
Timestamp:
Mar 16, 2005, 11:08:33 PM (19 years ago)
Author:
patrick
Message:

orxonox/trunk: some changes in the character_attributes, projectile and weapon.

Location:
orxonox/trunk/src/world_entities
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • orxonox/trunk/src/world_entities/character_attributes.cc

    r3582 r3583  
    4949 */
    5050void CharacterAttributes::setHealth(int health)
    51 {}
     51{
     52  this->health = health;
     53}
    5254
    5355/**
    5456   \brief adds health to the charater
    5557   \param health
    56    \returns health that couldnt be added due to healt limit
     58   \returns health that couldnt be added due to healt limit, 0 if everything worked as normal
    5759 */
    5860int CharacterAttributes::addHealth(int health)
    59 {}
     61{
     62  this->health += health;
     63  int rest = this->healthMax - this->health;
     64  if( rest < 0)
     65    {
     66      this->health = this->healthMax;
     67      return 0;
     68    }
     69  return rest;
     70}
    6071
    6172/**
     
    6576 */
    6677bool CharacterAttributes::substractHealth(int health)
    67 {}
     78{
     79  this->health -= health;
     80  if( this->health < 0)
     81    {
     82      this->health = 0;
     83      return false;
     84    }
     85  return true;
     86}
    6887
    6988/**
     
    7291 */
    7392int CharacterAttributes::getHealth()
    74 {}
     93{
     94  return this->health;
     95}
    7596
    7697
     
    82103 */
    83104void CharacterAttributes::setHealthMax(int healthMax)
    84 {}
     105{
     106  this->healthMax = healthMax;
     107}
    85108
    86109/**
     
    89112 */
    90113int CharacterAttributes::getHealthMax()
    91 {}
     114{
     115  return this->healthMax;
     116}
    92117
    93118
     
    98123 */
    99124void CharacterAttributes::setShieldStrength(int shieldStrength)
    100 {}
     125{
     126  this->shieldStrength = shieldStrength;
     127}
    101128
    102129/**
    103130   \brief adds shield strength
    104131   \param strength
     132   
     133   there is currently no limit to shieldstrength
    105134 */
    106135void CharacterAttributes::addShieldStrength(int shiledStrength)
    107 {}
     136{
     137  this->shieldStrength += shieldStrength;
     138}
    108139
    109140/**
    110141   \brief substracts shield strength
    111142   \param strength
    112    \returns amount of shield strength below zero after substraction. Magic: Troumble
     143   \returns amount of shield strength below zero after substraction. Magic: Troumble. if everything works allright, it returns 0
    113144 */
    114145int CharacterAttributes::substractShieldStrength(int shieldStrength)
    115 {}
     146{
     147  int rest = this->shieldStrength -= shieldStrength;
     148  if( rest < 0)
     149    {
     150      this->shieldStrength = 0;
     151      return -rest;
     152    }
     153  return 0;
     154}
    116155
    117156/**
     
    120159 */
    121160int CharacterAttributes::getShieldStrength()
    122 {}
     161{
     162  return this->shieldStrength;
     163}
    123164
    124165
     
    127168   \brief sets the amount of base damage dealt to all aircrafts
    128169   \param damage
     170
     171   There can be a difference between arms that hit a ground/air craft. Eg.
     172   a tank will react differently to explosives than something in the air
     173   (think about physics)
    129174 */
    130175void CharacterAttributes::setDamageToAirCraft(int damage)
    131 {}
     176{
     177  this->damageToAirCraft = damage;
     178}
    132179
    133180/**
    134181   \brief gets the amount of base damage
    135182   \returns base damage to aircrafts
     183
     184   There can be a difference between arms that hit a ground/air craft. Eg.
     185   a tank will react differently to explosives than something in the air
     186   (think about physics)
    136187 */
    137188int CharacterAttributes::getDamageToAirCraft()
    138 {}
     189{
     190  return this->damageToAirCraft;
     191}
    139192
    140193
     
    142195   \brief sets the amount of base damage dealt to all groundcrafts
    143196   \param damage
     197
     198   There can be a difference between arms that hit a ground/air craft. Eg.
     199   a tank will react differently to explosives than something in the air
     200   (think about physics)
    144201 */
    145202void CharacterAttributes::setDamageToGroundCraft(int damage)
    146 {}
     203{
     204  this->damageToGroundCraft = damage;
     205}
    147206
    148207/**
    149208   \briefgets the amount of base damage
    150209   \returns base damage to groundcrafts
     210
     211   There can be a difference between arms that hit a ground/air craft. Eg.
     212   a tank will react differently to explosives than something in the air
     213   (think about physics)
    151214 */
    152215int CharacterAttributes::getDamageToGroundCraft()
    153 {}
     216{
     217  return this->damageToGroundCraft;
     218}
    154219
    155220
     
    161226 */
    162227void CharacterAttributes::setDamageLaserModifier(float modifier)
    163 {}
     228{
     229  this->damageLaserModifier = modifier;
     230}
    164231
    165232/**
     
    170237 */
    171238float CharacterAttributes::getDamageLaserModifier()
    172 {}
     239{
     240  return this->damageLaserModifier;
     241}
    173242
    174243
     
    180249 */
    181250void CharacterAttributes::setDamagePlasmaModifier(float modifier)
    182 {}
     251{
     252  this->damagePlasmaModifier = modifier;
     253}
    183254
    184255/**
     
    189260 */
    190261float CharacterAttributes::getDamagePlasmaModifier()
    191 {}
     262{
     263  return this->damagePlasmaModifier;
     264}
    192265
    193266
     
    199272 */
    200273void CharacterAttributes::setDamageExplosiveModifier(float modifier)
    201 {}
     274{
     275  this->damageExplosiveModifier = modifier;
     276}
    202277
    203278/**
     
    208283 */
    209284float CharacterAttributes::getDamageExplosiveModifier()
    210 {}
     285{
     286  return this->damageExplosiveModifier;
     287}
    211288
    212289
     
    217294 */
    218295void CharacterAttributes::setEnergy(int energy)
    219 {}
     296{
     297  this->energy = energy;
     298}
    220299
    221300/**
     
    225304 */
    226305int CharacterAttributes::addEnergy(int addEnergy)
    227 {}
     306{
     307  this->energy += addEnergy;
     308  int rest = this->energyMax - this->energy;
     309  if(rest < 0)
     310    {
     311      this->energy = 0;
     312      return rest;
     313    }
     314  return 0;
     315}
    228316
    229317/**
     
    233321 */
    234322bool CharacterAttributes::substractEnergy(int subEnergy)
    235 {}
     323{
     324  this->energy -= subEnergy;
     325  if(this->energy < 0)
     326    {
     327      this->energy = 0;
     328      return false;
     329    }
     330  return true;
     331}
    236332
    237333/**
     
    240336 */
    241337int CharacterAttributes::getEnergy()
    242 {}
     338{
     339  return this->energy;
     340}
    243341
    244342
     
    247345   \param amount of energy
    248346*/
    249 void setEnergyConsumption(int energy)
    250 {}
     347void CharacterAttributes::setEnergyConsumption(int energy)
     348{
     349  this->energyConsumption = energy;
     350}
    251351
    252352/**
     
    254354   \returns amount of energy
    255355*/
    256 int getEnergyConsumption()
    257 {}
     356int CharacterAttributes::getEnergyConsumption()
     357{
     358  return this->energyConsumption;
     359}
    258360 
    259361
     
    262364   \param amount of energy
    263365*/
    264 void setEnergyMax(int energy)
    265 {}
     366void CharacterAttributes::setEnergyMax(int energy)
     367{
     368  this->energyMax = energy;
     369}
    266370
    267371/**
     
    269373   \returns amount of energy
    270374*/
    271 int getEnergyMax()
    272 {}
     375int CharacterAttributes::getEnergyMax()
     376{
     377  return this->energyMax;
     378}
  • orxonox/trunk/src/world_entities/character_attributes.h

    r3582 r3583  
    7070  /* healt */
    7171  int health;                        //<! the healt of a projectile
    72   int helathMax;                     //<! the max healt of a projectile, =0 if no limit
     72  int healthMax;                     //<! the max healt of a projectile, =0 if no limit
    7373
    7474  /* armor/ shields */
     
    8181  float damageLaserModifier;         //<! [0..1] the damage from laser is multiplied with this modifier. there can be things in the world, that are immune to certain damage
    8282  float damagePlasmaModifier;        //<! [0..1] the damage from plasma is multiplied with this modifier. there can be things in the world, that are immune to certain damage
    83   float damageExplosiveModifer;      //<! [0..1] the damage from exposives (rockets, tnt,...) is multiplied with this modifier. there can be things in the world, that are immune to certain damage
     83  float damageExplosiveModifier;      //<! [0..1] the damage from exposives (rockets, tnt,...) is multiplied with this modifier. there can be things in the world, that are immune to certain damage
    8484
    8585  /* energy */
  • orxonox/trunk/src/world_entities/player.cc

    r3578 r3583  
    2020//#include "collision.h"
    2121#include "objModel.h"
     22#include "list.h"
     23#include "weapon.h"
    2224
    2325using namespace std;
     
    3032{
    3133  this->model = new OBJModel("../data/models/reaplow.obj");
     34  this->weapons = new tList<Weapon>();
    3235}
    3336
     
    3740Player::~Player ()
    3841{
    39 
    40 }
     42  Weapon* w = this->weapons->enumerate();
     43  while( w != NULL)
     44    {
     45      delete w;
     46      w = this->weapons->nextElement();
     47    }
     48  delete this->weapons;
     49}
     50
     51
     52/**
     53   \brief adds a weapon to the weapon list of player
     54   \param weapon to add
     55*/
     56void Player::addWeapon(Weapon* weapon)
     57{
     58  this->weapons->add(weapon);
     59}
     60
     61
     62/**
     63   \brief removes a weapon from the player
     64   \param weapon to remove
     65*/
     66void Player::removeWeapon(Weapon* weapon)
     67{
     68  this->weapons->remove(weapon);
     69}
     70
    4171
    4272/**
  • orxonox/trunk/src/world_entities/player.h

    r3578 r3583  
    99#include "world_entity.h"
    1010
     11template<class T> class tList;
    1112class OBJModel;
     13class Weapon;
    1214
    1315//! Basic controllable WorldEntity
     
    1921  Player(bool isFree = false);
    2022  virtual ~Player();
     23
     24  void addWeapon(Weapon* weapon);
     25  void removeWeapon(Weapon* weapon);
    2126 
    2227  virtual void postSpawn();
    23   virtual void tick(float time);
     28  virtual void leftWorld();
    2429  virtual void hit(WorldEntity* weapon, Vector* loc);
    2530  virtual void collide(WorldEntity* other, Uint32 ownhitflags, Uint32 otherhitflags);
     31
     32  virtual void tick(float time); 
     33  virtual void draw();
     34
    2635  virtual void command(Command* cmd);
    27  
    28   virtual void draw();
    29   // virtual void getLookat(Location* locbuf);
    30  
    31   virtual void leftWorld();
    3236 
    3337 private:
     
    4044  bool bFire;            //!< fire button pressed.
    4145
     46  tList<Weapon>* weapons;//!< a list of weapon
     47
    4248  Vector velocity;       //!< the velocity of the player.
    4349  float travelSpeed;     //!< the current speed of the player (to make soft movement)
  • orxonox/trunk/src/world_entities/projectile.h

    r3578 r3583  
    2525
    2626 private:
    27   int health;                        //<! the healt of a projectile
    28   int maxHelath;                     //<! the max healt of a projectile
    29   int damageToAirCraft;              //<! damage dealt to a air craft
    30   int damageToGroundCraft;           //<! damage dealt to a ground craft
     27  //physical attriutes like: force, speed, acceleration etc.
     28
    3129};
    3230
  • orxonox/trunk/src/world_entities/weapon.cc

    r3579 r3583  
    3333*/
    3434Weapon::Weapon () : WorldEntity()
    35 {
    36   this->model = new OBJModel("");
    37 }
     35{}
    3836
    3937
     
    5553*/
    5654void Weapon::enable()
    57 {}
     55{
     56  this->enabled = true;
     57}
    5858
    5959
     
    6666*/
    6767void Weapon::disable()
    68 {}
     68{
     69  this->enabled = false;
     70}
    6971
    7072
     
    7880*/
    7981bool Weapon::isEnabled()
    80 {}
     82{
     83  return this->enabled;
     84}
    8185
    8286
     
    133137{}
    134138
    135 
    136 /**
    137    \brief this sets the energy of a weapon
    138    \param amount of energy
    139 
    140    a weapon has a limited amount of energy, this means a limited amount of shoots
    141 */
    142 void Weapon::setWeaponEnergy(int energy)
    143 {}
    144 
    145 /**
    146    \brief adds weapon energy
    147    \param amount of energy
    148    \returns amount of energy, that is over the energy limit
    149 
    150    this can be used for energy-power up for example. There is a limited amount of energy
    151    a weapon can have. so if you want to add more, than it supports, the rest will
    152    be returned from this weapon.
    153 */
    154 int Weapon::addWeaponEnergy(int addEnergy)
    155 {}
    156 
    157 /**
    158    \brief removes weapon energy
    159    \param amount of enery
    160 
    161    this is the case, when ther should be some sort of energy loss in the weapon
    162    system. propably wont be the case but usefull to have
    163 */
    164 void Weapon::substractWeaponEnergy(int subEnergy)
    165 {}
    166 
    167 /**
    168    \brief gets the amount of energy of a weapon (= ammo)
    169 */
    170 int Weapon::getWeaponEnergy()
     139/**
     140   \brief sets a weapon idle time
     141   \param idle time in ms
     142
     143   a weapon idle time is the time spend after a shoot until the weapon can
     144   shoot again
     145*/
     146void Weapon::setWeaponIdleTime(float time)
     147{}
     148
     149/**
     150   \brief gets the weapon idle time
     151   \returns idle time in ms
     152
     153   a weapon idle time is the time spend after a shoot until the weapon can
     154   shoot again
     155*/
     156float Weapon::getWeaponIdleTime(void)
     157{}
     158
     159/**
     160   \brief checks if the idle time is elapsed
     161   \return true if time is elapsed
     162
     163   a weapon idle time is the time spend after a shoot until the weapon can
     164   shoot again
     165*/
     166bool Weapon::hasWeaponIdleTimeElapsed(void)
    171167{}
    172168
     
    211207
    212208/**
     209   \brief is called, when there is no fire button pressed
     210*/
     211void Weapon::weaponIdle()
     212{}
     213
     214
     215/**
    213216   \brief this will draw the weapon
    214217*/
    215218void Weapon::draw ()
    216 {
    217   glMatrixMode(GL_MODELVIEW);
    218   glPushMatrix();
    219 
    220   float matrix[4][4];
    221   glTranslatef (this->getAbsCoor ().x, this->getAbsCoor ().y, this->getAbsCoor ().z);
    222   this->getAbsDir().matrix (matrix);
    223   glMultMatrixf((float*)matrix);
    224   this->model->draw();
    225 
    226   glPopMatrix();
    227 }
    228 
     219{}
     220
  • orxonox/trunk/src/world_entities/weapon.h

    r3580 r3583  
    2828class Projectile;
    2929
     30typedef enum {
     31  SHOOT,
     32  EMPTY,
     33  RELOAD,
     34  SPECIAL1,
     35  SPECIAL2,
     36  SPECIAL3
     37} weaponSoundType;
     38
     39
    3040class Weapon : public WorldEntity
    3141{
     
    3646  virtual ~Weapon ();
    3747 
    38   void enable();
    39   void disable();
    40   bool isEnabled();
     48  void enable(void);
     49  void disable(void);
     50  bool isEnabled(void);
    4151
    4252  void setProjectile(Projectile* projectile);
    43   Projectile* getProjectile();
     53  Projectile* getProjectile(void);
    4454
    45   virtual void activate();
    46   virtual void deactivate();
    47   bool isActive();
     55  virtual void activate(void);
     56  virtual void deactivate(void);
     57  bool isActive(void);
    4858
    49   void setWeaponEnergy(int energy);
    50   int addWeaponEnergy(int addEnergy);
    51   void substractWeaponEnergy(int subEnergy);
    52   int getWeaponEnergy();
     59  virtual void setWeaponIdleTime(float time);
     60  virtual float getWeaponIdleTime(void);
     61  virtual bool hasWeaponIdleTimeElapsed(void);
    5362
    54   virtual void fire();
     63  virtual void fire(void);
    5564  virtual void hit (WorldEntity* weapon, Vector* loc);
    56   virtual void destroy ();
     65  virtual void destroy(void);
    5766 
    58   virtual void tick (float time);
    59   virtual void draw ();
     67  virtual void tick(float time);
     68  virtual void weaponIdle(void);
     69  virtual void draw(void);
    6070
    6171
    6272 private:
    6373  bool enabled;
    64   float firingRate;
    6574  float localTime;
    6675  float slowDownFactor;
    67   int energyConsumption;
    68   int energyLimit;
    6976  Projectile* projectile;
     77  //WeaponSound sound;
    7078
    7179};
  • orxonox/trunk/src/world_entities/world_entity.cc

    r3578 r3583  
    5252
    5353/**
    54    \brief get the Location of the WorldEntity
    55    \return a pointer to location
     54   \brief sets the character attributes of a worldentity
     55   \param character attributes
     56
     57   these attributes don't have to be set, only use them, if you need them
    5658*/
    57 /*PN
    58 Location* WorldEntity::getLocation ()
    59 {
    60   return &loc;
    61 }
    62 */
     59void WorldEntity::setCharacterAttributes(CharacterAttributes* charAttr)
     60{}
     61
    6362
    6463/**
    65    \brief get the Placement of the WorldEntity
    66    \return a pointer to placement
     64   \brief gets the Character attributes of this worldentity
     65   \returns character attributes
    6766*/
    68  /*PN
    69 Placement* WorldEntity::getPlacement ()
    70 {
    71   return &place;
    72 }
    73  */
     67CharacterAttributes* WorldEntity::getCharacterAttributes()
     68{}
     69
     70
    7471/**
    7572   \brief query whether the WorldEntity in question is free
     
    9592}
    9693*/
    97 
    98 /**
    99    \brief this method is called every frame
    100    \param time: the time in seconds that has passed since the last tick
    101    
    102    Handle all stuff that should update with time inside this method (movement, animation, etc.)
    103 */
    104 void WorldEntity::tick(float time)
    105 {
    106 }
    10794
    10895
     
    132119
    133120/**
    134    \brief the entity is drawn onto the screen with this function
    135    
    136    This is a central function of an entity: call it to let the entity painted to the screen. Just override this function with whatever you want to be drawn.
    137 */
    138 void WorldEntity::draw()
    139 {}
    140 
    141 /**
    142121   \brief this function is called, when two entities collide
    143122   \param other: the world entity with whom it collides
     
    149128void WorldEntity::collide(WorldEntity* other, Uint32 ownhitflags, Uint32 otherhitflags) {}
    150129
     130
    151131/**
    152132   \brief this function is called, when the ship is hit by a waepon
     
    157137*/
    158138void WorldEntity::hit(WorldEntity* weapon, Vector* loc) {}
    159 
    160139
    161140
     
    170149}
    171150
     151
     152/**
     153   \brief this method is called by the world if the WorldEntity leaves valid gamespace
     154   
     155   For free entities this means it left the Track boundaries. With bound entities it means its Location adresses a
     156   place that is not in the world anymore. In both cases you might have to take extreme measures (a.k.a. call destroy).
     157*/
     158void WorldEntity::leftWorld ()
     159{
     160}
     161
     162
     163/**
     164   \brief this method is called every frame
     165   \param time: the time in seconds that has passed since the last tick
     166   
     167   Handle all stuff that should update with time inside this method (movement, animation, etc.)
     168*/
     169void WorldEntity::tick(float time)
     170{
     171}
     172
     173
     174/**
     175   \brief the entity is drawn onto the screen with this function
     176   
     177   This is a central function of an entity: call it to let the entity painted to the screen. Just override this function with whatever you want to be drawn.
     178*/
     179void WorldEntity::draw()
     180{}
     181
     182
    172183/**
    173184   \brief this handles incoming command messages
     
    180191{
    181192}
    182 
    183 /**
    184    \brief this is called by the local Camera to determine the point it should look at on the WorldEntity
    185    \param locbuf: a pointer to the buffer to fill with a location to look at
    186        
    187    You may put any Location you want into locbuf, the Camera will determine via the corresponding Track how
    188    to look at the location you return with this.
    189 */
    190 /*PN
    191 void WorldEntity::getLookat (Location* locbuf)
    192 {
    193 }
    194 */
    195 
    196 /**
    197    \brief this method is called by the world if the WorldEntity leaves valid gamespace
    198    
    199    For free entities this means it left the Track boundaries. With bound entities it means its Location adresses a
    200    place that is not in the world anymore. In both cases you might have to take extreme measures (a.k.a. call destroy).
    201 */
    202 void WorldEntity::leftWorld ()
    203 {
    204 }
  • orxonox/trunk/src/world_entities/world_entity.h

    r3578 r3583  
    1212
    1313//class CollisionCluster;
     14class CharacterAttributes;
     15
    1416
    1517//! Basic class from which all interactive stuff in the world is derived from
     
    2325
    2426
    25   OBJModel* model;                  //!< The model that should be loaded for this entity.
     27
    2628 
    2729  //void setCollision (CollisionCluster* newhull);
    2830 
    29   bool isFree ();
    30  
    3131  //void addAbility(Ability* ability);
    3232  //void removeAbility(Ability* ability);
    33  
     33  void setDrawable (bool bDraw); 
     34  bool isFree ();
     35  void setCharacterAttributes(CharacterAttributes* charAttr);
     36  CharacterAttributes* getCharacterAttributes();
     37
    3438  virtual void postSpawn ();
    35   virtual void tick (float time);
     39  virtual void leftWorld ();
     40
    3641  virtual void hit (WorldEntity* weapon, Vector* loc);
    3742  virtual void collide (WorldEntity* other,  Uint32 ownhitflags, Uint32 otherhitflags);
     
    4045  void processDraw ();
    4146  virtual void draw ();
    42   void setDrawable (bool bDraw);
     47  virtual void tick (float time);
    4348 
    44   virtual void leftWorld ();
     49 protected:
     50  OBJModel* model;                  //!< The model that should be loaded for this entity.
     51  CharacterAttributes* charAttr;      //!< the character attributes of a world_entity
    4552 
    4653 private:
     
    4956  bool bDraw;                         //!< If it should be visible.
    5057
     58
     59
    5160  //CollisionCluster* collisioncluster; //!< The collision-Cluster of this entity.
    5261};
Note: See TracChangeset for help on using the changeset viewer.