Changeset 3583 in orxonox.OLD for orxonox/trunk/src/world_entities
- Timestamp:
- Mar 16, 2005, 11:08:33 PM (20 years ago)
- Location:
- orxonox/trunk/src/world_entities
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/trunk/src/world_entities/character_attributes.cc
r3582 r3583 49 49 */ 50 50 void CharacterAttributes::setHealth(int health) 51 {} 51 { 52 this->health = health; 53 } 52 54 53 55 /** 54 56 \brief adds health to the charater 55 57 \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 57 59 */ 58 60 int 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 } 60 71 61 72 /** … … 65 76 */ 66 77 bool 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 } 68 87 69 88 /** … … 72 91 */ 73 92 int CharacterAttributes::getHealth() 74 {} 93 { 94 return this->health; 95 } 75 96 76 97 … … 82 103 */ 83 104 void CharacterAttributes::setHealthMax(int healthMax) 84 {} 105 { 106 this->healthMax = healthMax; 107 } 85 108 86 109 /** … … 89 112 */ 90 113 int CharacterAttributes::getHealthMax() 91 {} 114 { 115 return this->healthMax; 116 } 92 117 93 118 … … 98 123 */ 99 124 void CharacterAttributes::setShieldStrength(int shieldStrength) 100 {} 125 { 126 this->shieldStrength = shieldStrength; 127 } 101 128 102 129 /** 103 130 \brief adds shield strength 104 131 \param strength 132 133 there is currently no limit to shieldstrength 105 134 */ 106 135 void CharacterAttributes::addShieldStrength(int shiledStrength) 107 {} 136 { 137 this->shieldStrength += shieldStrength; 138 } 108 139 109 140 /** 110 141 \brief substracts shield strength 111 142 \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 113 144 */ 114 145 int 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 } 116 155 117 156 /** … … 120 159 */ 121 160 int CharacterAttributes::getShieldStrength() 122 {} 161 { 162 return this->shieldStrength; 163 } 123 164 124 165 … … 127 168 \brief sets the amount of base damage dealt to all aircrafts 128 169 \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) 129 174 */ 130 175 void CharacterAttributes::setDamageToAirCraft(int damage) 131 {} 176 { 177 this->damageToAirCraft = damage; 178 } 132 179 133 180 /** 134 181 \brief gets the amount of base damage 135 182 \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) 136 187 */ 137 188 int CharacterAttributes::getDamageToAirCraft() 138 {} 189 { 190 return this->damageToAirCraft; 191 } 139 192 140 193 … … 142 195 \brief sets the amount of base damage dealt to all groundcrafts 143 196 \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) 144 201 */ 145 202 void CharacterAttributes::setDamageToGroundCraft(int damage) 146 {} 203 { 204 this->damageToGroundCraft = damage; 205 } 147 206 148 207 /** 149 208 \briefgets the amount of base damage 150 209 \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) 151 214 */ 152 215 int CharacterAttributes::getDamageToGroundCraft() 153 {} 216 { 217 return this->damageToGroundCraft; 218 } 154 219 155 220 … … 161 226 */ 162 227 void CharacterAttributes::setDamageLaserModifier(float modifier) 163 {} 228 { 229 this->damageLaserModifier = modifier; 230 } 164 231 165 232 /** … … 170 237 */ 171 238 float CharacterAttributes::getDamageLaserModifier() 172 {} 239 { 240 return this->damageLaserModifier; 241 } 173 242 174 243 … … 180 249 */ 181 250 void CharacterAttributes::setDamagePlasmaModifier(float modifier) 182 {} 251 { 252 this->damagePlasmaModifier = modifier; 253 } 183 254 184 255 /** … … 189 260 */ 190 261 float CharacterAttributes::getDamagePlasmaModifier() 191 {} 262 { 263 return this->damagePlasmaModifier; 264 } 192 265 193 266 … … 199 272 */ 200 273 void CharacterAttributes::setDamageExplosiveModifier(float modifier) 201 {} 274 { 275 this->damageExplosiveModifier = modifier; 276 } 202 277 203 278 /** … … 208 283 */ 209 284 float CharacterAttributes::getDamageExplosiveModifier() 210 {} 285 { 286 return this->damageExplosiveModifier; 287 } 211 288 212 289 … … 217 294 */ 218 295 void CharacterAttributes::setEnergy(int energy) 219 {} 296 { 297 this->energy = energy; 298 } 220 299 221 300 /** … … 225 304 */ 226 305 int 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 } 228 316 229 317 /** … … 233 321 */ 234 322 bool 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 } 236 332 237 333 /** … … 240 336 */ 241 337 int CharacterAttributes::getEnergy() 242 {} 338 { 339 return this->energy; 340 } 243 341 244 342 … … 247 345 \param amount of energy 248 346 */ 249 void setEnergyConsumption(int energy) 250 {} 347 void CharacterAttributes::setEnergyConsumption(int energy) 348 { 349 this->energyConsumption = energy; 350 } 251 351 252 352 /** … … 254 354 \returns amount of energy 255 355 */ 256 int getEnergyConsumption() 257 {} 356 int CharacterAttributes::getEnergyConsumption() 357 { 358 return this->energyConsumption; 359 } 258 360 259 361 … … 262 364 \param amount of energy 263 365 */ 264 void setEnergyMax(int energy) 265 {} 366 void CharacterAttributes::setEnergyMax(int energy) 367 { 368 this->energyMax = energy; 369 } 266 370 267 371 /** … … 269 373 \returns amount of energy 270 374 */ 271 int getEnergyMax() 272 {} 375 int CharacterAttributes::getEnergyMax() 376 { 377 return this->energyMax; 378 } -
orxonox/trunk/src/world_entities/character_attributes.h
r3582 r3583 70 70 /* healt */ 71 71 int health; //<! the healt of a projectile 72 int he lathMax; //<! the max healt of a projectile, =0 if no limit72 int healthMax; //<! the max healt of a projectile, =0 if no limit 73 73 74 74 /* armor/ shields */ … … 81 81 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 82 82 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 damageExplosiveModif er; //<! [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 damage83 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 84 84 85 85 /* energy */ -
orxonox/trunk/src/world_entities/player.cc
r3578 r3583 20 20 //#include "collision.h" 21 21 #include "objModel.h" 22 #include "list.h" 23 #include "weapon.h" 22 24 23 25 using namespace std; … … 30 32 { 31 33 this->model = new OBJModel("../data/models/reaplow.obj"); 34 this->weapons = new tList<Weapon>(); 32 35 } 33 36 … … 37 40 Player::~Player () 38 41 { 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 */ 56 void 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 */ 66 void Player::removeWeapon(Weapon* weapon) 67 { 68 this->weapons->remove(weapon); 69 } 70 41 71 42 72 /** -
orxonox/trunk/src/world_entities/player.h
r3578 r3583 9 9 #include "world_entity.h" 10 10 11 template<class T> class tList; 11 12 class OBJModel; 13 class Weapon; 12 14 13 15 //! Basic controllable WorldEntity … … 19 21 Player(bool isFree = false); 20 22 virtual ~Player(); 23 24 void addWeapon(Weapon* weapon); 25 void removeWeapon(Weapon* weapon); 21 26 22 27 virtual void postSpawn(); 23 virtual void tick(float time);28 virtual void leftWorld(); 24 29 virtual void hit(WorldEntity* weapon, Vector* loc); 25 30 virtual void collide(WorldEntity* other, Uint32 ownhitflags, Uint32 otherhitflags); 31 32 virtual void tick(float time); 33 virtual void draw(); 34 26 35 virtual void command(Command* cmd); 27 28 virtual void draw();29 // virtual void getLookat(Location* locbuf);30 31 virtual void leftWorld();32 36 33 37 private: … … 40 44 bool bFire; //!< fire button pressed. 41 45 46 tList<Weapon>* weapons;//!< a list of weapon 47 42 48 Vector velocity; //!< the velocity of the player. 43 49 float travelSpeed; //!< the current speed of the player (to make soft movement) -
orxonox/trunk/src/world_entities/projectile.h
r3578 r3583 25 25 26 26 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 31 29 }; 32 30 -
orxonox/trunk/src/world_entities/weapon.cc
r3579 r3583 33 33 */ 34 34 Weapon::Weapon () : WorldEntity() 35 { 36 this->model = new OBJModel(""); 37 } 35 {} 38 36 39 37 … … 55 53 */ 56 54 void Weapon::enable() 57 {} 55 { 56 this->enabled = true; 57 } 58 58 59 59 … … 66 66 */ 67 67 void Weapon::disable() 68 {} 68 { 69 this->enabled = false; 70 } 69 71 70 72 … … 78 80 */ 79 81 bool Weapon::isEnabled() 80 {} 82 { 83 return this->enabled; 84 } 81 85 82 86 … … 133 137 {} 134 138 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 */ 146 void 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 */ 156 float 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 */ 166 bool Weapon::hasWeaponIdleTimeElapsed(void) 171 167 {} 172 168 … … 211 207 212 208 /** 209 \brief is called, when there is no fire button pressed 210 */ 211 void Weapon::weaponIdle() 212 {} 213 214 215 /** 213 216 \brief this will draw the weapon 214 217 */ 215 218 void 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 28 28 class Projectile; 29 29 30 typedef enum { 31 SHOOT, 32 EMPTY, 33 RELOAD, 34 SPECIAL1, 35 SPECIAL2, 36 SPECIAL3 37 } weaponSoundType; 38 39 30 40 class Weapon : public WorldEntity 31 41 { … … 36 46 virtual ~Weapon (); 37 47 38 void enable( );39 void disable( );40 bool isEnabled( );48 void enable(void); 49 void disable(void); 50 bool isEnabled(void); 41 51 42 52 void setProjectile(Projectile* projectile); 43 Projectile* getProjectile( );53 Projectile* getProjectile(void); 44 54 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); 48 58 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); 53 62 54 virtual void fire( );63 virtual void fire(void); 55 64 virtual void hit (WorldEntity* weapon, Vector* loc); 56 virtual void destroy ();65 virtual void destroy(void); 57 66 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); 60 70 61 71 62 72 private: 63 73 bool enabled; 64 float firingRate;65 74 float localTime; 66 75 float slowDownFactor; 67 int energyConsumption;68 int energyLimit;69 76 Projectile* projectile; 77 //WeaponSound sound; 70 78 71 79 }; -
orxonox/trunk/src/world_entities/world_entity.cc
r3578 r3583 52 52 53 53 /** 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 56 58 */ 57 /*PN 58 Location* WorldEntity::getLocation () 59 { 60 return &loc; 61 } 62 */ 59 void WorldEntity::setCharacterAttributes(CharacterAttributes* charAttr) 60 {} 61 63 62 64 63 /** 65 \brief get the Placement of the WorldEntity66 \return a pointer to placement64 \brief gets the Character attributes of this worldentity 65 \returns character attributes 67 66 */ 68 /*PN 69 Placement* WorldEntity::getPlacement () 70 { 71 return &place; 72 } 73 */ 67 CharacterAttributes* WorldEntity::getCharacterAttributes() 68 {} 69 70 74 71 /** 75 72 \brief query whether the WorldEntity in question is free … … 95 92 } 96 93 */ 97 98 /**99 \brief this method is called every frame100 \param time: the time in seconds that has passed since the last tick101 102 Handle all stuff that should update with time inside this method (movement, animation, etc.)103 */104 void WorldEntity::tick(float time)105 {106 }107 94 108 95 … … 132 119 133 120 /** 134 \brief the entity is drawn onto the screen with this function135 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 /**142 121 \brief this function is called, when two entities collide 143 122 \param other: the world entity with whom it collides … … 149 128 void WorldEntity::collide(WorldEntity* other, Uint32 ownhitflags, Uint32 otherhitflags) {} 150 129 130 151 131 /** 152 132 \brief this function is called, when the ship is hit by a waepon … … 157 137 */ 158 138 void WorldEntity::hit(WorldEntity* weapon, Vector* loc) {} 159 160 139 161 140 … … 170 149 } 171 150 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 */ 158 void 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 */ 169 void 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 */ 179 void WorldEntity::draw() 180 {} 181 182 172 183 /** 173 184 \brief this handles incoming command messages … … 180 191 { 181 192 } 182 183 /**184 \brief this is called by the local Camera to determine the point it should look at on the WorldEntity185 \param locbuf: a pointer to the buffer to fill with a location to look at186 187 You may put any Location you want into locbuf, the Camera will determine via the corresponding Track how188 to look at the location you return with this.189 */190 /*PN191 void WorldEntity::getLookat (Location* locbuf)192 {193 }194 */195 196 /**197 \brief this method is called by the world if the WorldEntity leaves valid gamespace198 199 For free entities this means it left the Track boundaries. With bound entities it means its Location adresses a200 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 12 12 13 13 //class CollisionCluster; 14 class CharacterAttributes; 15 14 16 15 17 //! Basic class from which all interactive stuff in the world is derived from … … 23 25 24 26 25 OBJModel* model; //!< The model that should be loaded for this entity. 27 26 28 27 29 //void setCollision (CollisionCluster* newhull); 28 30 29 bool isFree ();30 31 31 //void addAbility(Ability* ability); 32 32 //void removeAbility(Ability* ability); 33 33 void setDrawable (bool bDraw); 34 bool isFree (); 35 void setCharacterAttributes(CharacterAttributes* charAttr); 36 CharacterAttributes* getCharacterAttributes(); 37 34 38 virtual void postSpawn (); 35 virtual void tick (float time); 39 virtual void leftWorld (); 40 36 41 virtual void hit (WorldEntity* weapon, Vector* loc); 37 42 virtual void collide (WorldEntity* other, Uint32 ownhitflags, Uint32 otherhitflags); … … 40 45 void processDraw (); 41 46 virtual void draw (); 42 v oid setDrawable (bool bDraw);47 virtual void tick (float time); 43 48 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 45 52 46 53 private: … … 49 56 bool bDraw; //!< If it should be visible. 50 57 58 59 51 60 //CollisionCluster* collisioncluster; //!< The collision-Cluster of this entity. 52 61 };
Note: See TracChangeset
for help on using the changeset viewer.