Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/orxonox/trunk/src/world_entities/character_attributes.cc @ 4396

Last change on this file since 4396 was 4320, checked in by patrick, 20 years ago

orxonox/trunk: now string name of a class works parallel to the int id representation and is only used for documentation purposes

File size: 7.9 KB
Line 
1
2
3/*
4   orxonox - the future of 3D-vertical-scrollers
5
6   Copyright (C) 2004 orx
7
8   This program is free software; you can redistribute it and/or modify
9   it under the terms of the GNU General Public License as published by
10   the Free Software Foundation; either version 2, or (at your option)
11   any later version.
12
13   ### File Specific:
14   main-programmer: Patrick Boenzli
15   co-programmer: ...
16*/
17
18
19#include "character_attributes.h"
20#include "stdincl.h"
21
22using namespace std;
23
24
25/**
26   \brief standard constructor
27   \todo this constructor is not jet implemented - do it
28*/
29CharacterAttributes::CharacterAttributes () 
30{
31   this->setClassID(CL_CHARACTER_ATTRIBUTES, "CharacterAttributes");
32}
33
34
35/**
36   \brief standard deconstructor
37
38*/
39CharacterAttributes::~CharacterAttributes () 
40{
41}
42
43
44/*=====================health=====================*/
45
46/**
47   \brief sets the health of the character
48   \param helath
49 */
50void CharacterAttributes::setHealth(int health)
51{
52  this->health = health;
53}
54
55/**
56   \brief adds health to the charater
57   \param health
58   \returns health that couldnt be added due to healt limit, 0 if everything worked as normal
59 */
60int CharacterAttributes::addHealth(int health)
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}
71
72/**
73   \brief remove health due to damager for example
74   \param amount of health
75   \returns false if health is zero -> dead
76 */
77bool CharacterAttributes::substractHealth(int health)
78{
79  this->health -= health;
80  if( this->health < 0)
81    {
82      this->health = 0;
83      return false;
84    }
85  return true;
86}
87
88/**
89   \brief gets the current amount of health
90   \returns health
91 */
92int CharacterAttributes::getHealth()
93{
94  return this->health;
95}
96
97
98/**
99   \brief sets maximum health
100   \param health
101
102   if healthMax = 0 -> unlimited
103 */
104void CharacterAttributes::setHealthMax(int healthMax)
105{
106  this->healthMax = healthMax;
107}
108
109/**
110   \brief gets health maximium
111   \returns the health maximum
112 */
113int CharacterAttributes::getHealthMax()
114{
115  return this->healthMax;
116}
117
118
119/*======================armor/ shields===================== */
120/**
121   \brief sets the shild strength
122   \param strength
123 */
124void CharacterAttributes::setShieldStrength(int shieldStrength)
125{
126  this->shieldStrength = shieldStrength;
127}
128
129/**
130   \brief adds shield strength
131   \param strength
132   
133   there is currently no limit to shieldstrength
134 */
135void CharacterAttributes::addShieldStrength(int shiledStrength)
136{
137  this->shieldStrength += shieldStrength;
138}
139
140/**
141   \brief substracts shield strength
142   \param strength
143   \returns amount of shield strength below zero after substraction. Magic: Troumble. if everything works allright, it returns 0
144 */
145int CharacterAttributes::substractShieldStrength(int shieldStrength)
146{
147  int rest = this->shieldStrength -= shieldStrength;
148  if( rest < 0)
149    {
150      this->shieldStrength = 0;
151      return -rest;
152    }
153  return 0;
154}
155
156/**
157   \brief gets shield strength
158   \returns the shield strength
159 */
160int CharacterAttributes::getShieldStrength()
161{
162  return this->shieldStrength;
163}
164
165
166/*=====================damage=====================*/
167/**
168   \brief sets the amount of base damage dealt to all aircrafts
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)
174 */
175void CharacterAttributes::setDamageToAirCraft(int damage)
176{
177  this->damageToAirCraft = damage;
178}
179
180/**
181   \brief gets the amount of base damage
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)
187 */
188int CharacterAttributes::getDamageToAirCraft()
189{
190  return this->damageToAirCraft;
191}
192
193
194/**
195   \brief sets the amount of base damage dealt to all groundcrafts
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)
201 */
202void CharacterAttributes::setDamageToGroundCraft(int damage)
203{
204  this->damageToGroundCraft = damage;
205}
206
207/**
208   \briefgets the amount of base damage
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)
214 */
215int CharacterAttributes::getDamageToGroundCraft()
216{
217  return this->damageToGroundCraft;
218}
219
220
221/**
222   \brief sets the damage modifier to the damage that is dealed via laser weapons
223   \param modifier [0..1]
224
225   eg. the damage is calculated after: damage = modifier * damageToGroundCraft
226 */
227void CharacterAttributes::setDamageLaserModifier(float modifier)
228{
229  this->damageLaserModifier = modifier;
230}
231
232/**
233   \brief gets the damage modifier to the damage that is dealed via laser weapons
234   \returns damage modifier
235
236   eg. the damage is calculated after: damage = modifier * damageToGroundCraft
237 */
238float CharacterAttributes::getDamageLaserModifier()
239{
240  return this->damageLaserModifier;
241}
242
243
244/**
245   \brief sets the damage modifier to the damage that is dealed via plasma weapons
246   \param damage modifier
247
248   eg. the damage is calculated after: damage = modifier * damageToGroundCraft
249 */
250void CharacterAttributes::setDamagePlasmaModifier(float modifier)
251{
252  this->damagePlasmaModifier = modifier;
253}
254
255/**
256   \brief gets the damage modifier to the damage that is dealed plasma weapons
257   \returns damage modifier
258
259   eg. the damage is calculated after: damage = modifier * damageToGroundCraft
260 */
261float CharacterAttributes::getDamagePlasmaModifier()
262{
263  return this->damagePlasmaModifier;
264}
265
266
267/**
268   \brief sets the damage modifier to the damage that is dealed via explosives
269   \param damage modifier
270
271   eg. the damage is calculated after: damage = modifier * damageToGroundCraft
272 */
273void CharacterAttributes::setDamageExplosiveModifier(float modifier)
274{
275  this->damageExplosiveModifier = modifier;
276}
277
278/**
279   \brief sets the damage modifier to the damage that is dealed via explosives
280   \returns damage modifier
281
282   eg. the damage is calculated after: damage = modifier * damageToGroundCraft
283 */
284float CharacterAttributes::getDamageExplosiveModifier()
285{
286  return this->damageExplosiveModifier;
287}
288
289
290/*=====================energy=====================*/
291/**
292   \brief sets the amount of energy
293   \param energy
294 */
295void CharacterAttributes::setEnergy(int energy)
296{
297  this->energy = energy;
298}
299
300/**
301   \brief adds energy to the system
302   \param amount of energy
303   \returns amount of energy that is too much due to energy limit
304 */
305int CharacterAttributes::addEnergy(int addEnergy)
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}
316
317/**
318   \brief substracts energy from a system
319   \param amount of energy
320   \returns false if there is no energy anymore
321 */
322bool CharacterAttributes::substractEnergy(int subEnergy)
323{
324  this->energy -= subEnergy;
325  if(this->energy < 0)
326    {
327      this->energy = 0;
328      return false;
329    }
330  return true;
331}
332
333/**
334   \brief gets the amount of energy
335   \returns energy
336 */
337int CharacterAttributes::getEnergy()
338{
339  return this->energy;
340}
341
342
343/**
344   \brief sets the energy consumption
345   \param amount of energy
346*/
347void CharacterAttributes::setEnergyConsumption(int energy)
348{
349  this->energyConsumption = energy;
350}
351
352/**
353   \brief gets the energy consumption
354   \returns amount of energy
355*/
356int CharacterAttributes::getEnergyConsumption()
357{
358  return this->energyConsumption;
359}
360 
361
362/**
363   \brief sets the maximum energy level
364   \param amount of energy
365*/
366void CharacterAttributes::setEnergyMax(int energy)
367{
368  this->energyMax = energy;
369}
370
371/**
372   \brief gets the max energy level
373   \returns amount of energy
374*/
375int CharacterAttributes::getEnergyMax()
376{
377  return this->energyMax;
378}
Note: See TracBrowser for help on using the repository browser.