/* orxonox - the future of 3D-vertical-scrollers Copyright (C) 2004 orx This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. ### File Specific: main-programmer: Patrick Boenzli co-programmer: ... */ #include "character_attributes.h" ObjectListDefinition(CharacterAttributes); /** * standard constructor @todo this constructor is not jet implemented - do it */ CharacterAttributes::CharacterAttributes () { this->registerObject(this, CharacterAttributes::_objectList); } /** * standard deconstructor */ CharacterAttributes::~CharacterAttributes () { } /*=====================health=====================*/ /** * sets the health of the character * @param helath */ void CharacterAttributes::setHealth(int health) { this->health = health; } /** * adds health to the charater * @param health * @returns health that couldnt be added due to healt limit, 0 if everything worked as normal */ int CharacterAttributes::addHealth(int health) { this->health += health; int rest = this->healthMax - this->health; if( rest < 0) { this->health = this->healthMax; return 0; } return rest; } /** * remove health due to damager for example * @param amount of health * @returns false if health is zero -> dead */ bool CharacterAttributes::substractHealth(int health) { this->health -= health; if( this->health < 0) { this->health = 0; return false; } return true; } /** * gets the current amount of health * @returns health */ int CharacterAttributes::getHealth() { return this->health; } /** * sets maximum health * @param health if healthMax = 0 -> unlimited */ void CharacterAttributes::setHealthMax(int healthMax) { this->healthMax = healthMax; } /** * gets health maximium * @returns the health maximum */ int CharacterAttributes::getHealthMax() { return this->healthMax; } /*======================armor/ shields===================== */ /** * sets the shild strength * @param strength */ void CharacterAttributes::setShieldStrength(int shieldStrength) { this->shieldStrength = shieldStrength; } /** * adds shield strength * @param strength there is currently no limit to shieldstrength */ void CharacterAttributes::addShieldStrength(int shiledStrength) { this->shieldStrength += shieldStrength; } /** * substracts shield strength * @param strength * @returns amount of shield strength below zero after substraction. Magic: Troumble. if everything works allright, it returns 0 */ int CharacterAttributes::substractShieldStrength(int shieldStrength) { int rest = this->shieldStrength -= shieldStrength; if( rest < 0) { this->shieldStrength = 0; return -rest; } return 0; } /** * gets shield strength * @returns the shield strength */ int CharacterAttributes::getShieldStrength() { return this->shieldStrength; } /*=====================damage=====================*/ /** * sets the amount of base damage dealt to all aircrafts * @param damage There can be a difference between arms that hit a ground/air craft. Eg. a tank will react differently to explosives than something in the air (think about physics) */ void CharacterAttributes::setDamageToAirCraft(int damage) { this->damageToAirCraft = damage; } /** * gets the amount of base damage * @returns base damage to aircrafts There can be a difference between arms that hit a ground/air craft. Eg. a tank will react differently to explosives than something in the air (think about physics) */ int CharacterAttributes::getDamageToAirCraft() { return this->damageToAirCraft; } /** * sets the amount of base damage dealt to all groundcrafts * @param damage There can be a difference between arms that hit a ground/air craft. Eg. a tank will react differently to explosives than something in the air (think about physics) */ void CharacterAttributes::setDamageToGroundCraft(int damage) { this->damageToGroundCraft = damage; } /** * gets the amount of base damage * @returns base damage to groundcrafts There can be a difference between arms that hit a ground/air craft. Eg. a tank will react differently to explosives than something in the air (think about physics) */ int CharacterAttributes::getDamageToGroundCraft() { return this->damageToGroundCraft; } /** * sets the damage modifier to the damage that is dealed via laser weapons * @param modifier [0..1] eg. the damage is calculated after: damage = modifier * damageToGroundCraft */ void CharacterAttributes::setDamageLaserModifier(float modifier) { this->damageLaserModifier = modifier; } /** * gets the damage modifier to the damage that is dealed via laser weapons * @returns damage modifier eg. the damage is calculated after: damage = modifier * damageToGroundCraft */ float CharacterAttributes::getDamageLaserModifier() { return this->damageLaserModifier; } /** * sets the damage modifier to the damage that is dealed via plasma weapons * @param damage modifier eg. the damage is calculated after: damage = modifier * damageToGroundCraft */ void CharacterAttributes::setDamagePlasmaModifier(float modifier) { this->damagePlasmaModifier = modifier; } /** * gets the damage modifier to the damage that is dealed plasma weapons * @returns damage modifier eg. the damage is calculated after: damage = modifier * damageToGroundCraft */ float CharacterAttributes::getDamagePlasmaModifier() { return this->damagePlasmaModifier; } /** * sets the damage modifier to the damage that is dealed via explosives * @param damage modifier eg. the damage is calculated after: damage = modifier * damageToGroundCraft */ void CharacterAttributes::setDamageExplosiveModifier(float modifier) { this->damageExplosiveModifier = modifier; } /** * sets the damage modifier to the damage that is dealed via explosives * @returns damage modifier eg. the damage is calculated after: damage = modifier * damageToGroundCraft */ float CharacterAttributes::getDamageExplosiveModifier() { return this->damageExplosiveModifier; } /*=====================energy=====================*/ /** * sets the amount of energy * @param energy */ void CharacterAttributes::setEnergy(int energy) { this->energy = energy; } /** * adds energy to the system * @param amount of energy * @returns amount of energy that is too much due to energy limit */ int CharacterAttributes::addEnergy(int addEnergy) { this->energy += addEnergy; int rest = this->energyMax - this->energy; if(rest < 0) { this->energy = 0; return rest; } return 0; } /** * substracts energy from a system * @param amount of energy * @returns false if there is no energy anymore */ bool CharacterAttributes::substractEnergy(int subEnergy) { this->energy -= subEnergy; if(this->energy < 0) { this->energy = 0; return false; } return true; } /** * gets the amount of energy * @returns energy */ int CharacterAttributes::getEnergy() { return this->energy; } /** * sets the energy consumption * @param amount of energy */ void CharacterAttributes::setEnergyConsumption(int energy) { this->energyConsumption = energy; } /** * gets the energy consumption * @returns amount of energy */ int CharacterAttributes::getEnergyConsumption() { return this->energyConsumption; } /** * sets the maximum energy level * @param amount of energy */ void CharacterAttributes::setEnergyMax(int energy) { this->energyMax = energy; } /** * gets the max energy level * @returns amount of energy */ int CharacterAttributes::getEnergyMax() { return this->energyMax; }