diff options
author | Philipp Sehmisch <tmw@crushnet.org> | 2007-03-15 23:47:13 +0000 |
---|---|---|
committer | Philipp Sehmisch <tmw@crushnet.org> | 2007-03-15 23:47:13 +0000 |
commit | 7e1011ccea542f4bc972c0a9c03eaca4a718566b (patch) | |
tree | 4ebdde458b132ddb12c737a338e39711eed72534 /src/game-server/being.cpp | |
parent | 16faa1f2ead902fd5f883dab487fc4ef4762c45f (diff) | |
download | manaserv-7e1011ccea542f4bc972c0a9c03eaca4a718566b.tar.gz manaserv-7e1011ccea542f4bc972c0a9c03eaca4a718566b.tar.bz2 manaserv-7e1011ccea542f4bc972c0a9c03eaca4a718566b.tar.xz manaserv-7e1011ccea542f4bc972c0a9c03eaca4a718566b.zip |
Set the default map position of new characters to a value that makes more sense. Implemented new basic attribute system on account server. Removed attribute modifiers, unified basic and derived attributes, storing attributes in a vector, renamed some attribute identifiers, removed identifiers for derived attributes that aren't needed yet.
Diffstat (limited to 'src/game-server/being.cpp')
-rw-r--r-- | src/game-server/being.cpp | 162 |
1 files changed, 40 insertions, 122 deletions
diff --git a/src/game-server/being.cpp b/src/game-server/being.cpp index 8703fc2b..d3c151e7 100644 --- a/src/game-server/being.cpp +++ b/src/game-server/being.cpp @@ -22,6 +22,7 @@ #include "game-server/being.hpp" +#include "defines.h" #include "game-server/collisiondetection.hpp" #include "game-server/mapcomposite.hpp" #include "utils/logger.h" @@ -30,17 +31,7 @@ Being::Being(int type, int id): MovingObject(type, id), mAction(STAND) { - for (int i = 0; i < NB_BASE_ATTRIBUTES; i++) - { - mBaseAttributes[i] = 0; - } - for (int j = 0; j < NB_COMPOUND_ATTRIBUTES; j++) - { - mCompoundAttributes[j] = 0; - } - mBeingModificators.absoluteModificator.resize(NB_COMPOUND_ATTRIBUTES, 0); - mBeingModificators.percentModificators.resize(NB_COMPOUND_ATTRIBUTES); - //TODO: set the base attributes, calculate the compound attributes + mAttributes.resize(NB_ATTRIBUTES_BEING); } Being::~Being() @@ -59,14 +50,14 @@ void Being::damage(Damage damage) switch (damage.type) { case DAMAGETYPE_PHYSICAL: - HPloss -= getCompoundAttribute(ATT_PHYSICAL_DEFENCE) - / damage.penetration; + HPloss -= getAttribute(DERIVED_ATTR_PHYSICAL_DEFENCE) / damage.piercing; + HPloss -= getAttribute(BASE_ATTR_VITALITY); break; case DAMAGETYPE_MAGICAL: - // NIY + HPloss /= getAttribute(BASE_ATTR_WILLPOWER) + 1; break; case DAMAGETYPE_HAZARD: - // NIY + HPloss /= getAttribute(BASE_ATTR_VITALITY) + 1; break; case DAMAGETYPE_OTHER: // nothing to do here @@ -165,127 +156,54 @@ void Being::setAction(Action action) } } -void Being::addAbsoluteStatModifier(int attributeNumber, short value) -{ - mBeingModificators.absoluteModificator.at(attributeNumber) += value; - calculateCompoundAttribute(attributeNumber); -} - -void Being::removeAbsoluteStatModifier(int attributeNumber, short value) -{ - mBeingModificators.absoluteModificator.at(attributeNumber) -= value; - calculateCompoundAttribute(attributeNumber); -} - -void Being::addPercentStatModifier(int attributeNumber, short value) -{ - if (value < -100) - { - LOG_WARN( "Attempt to add a stat modificator for Being"<< - getPublicID()<< - "that would make the stat negative!" - ); - return; - } - - mBeingModificators.percentModificators.at(attributeNumber).push_back(value); - calculateCompoundAttribute(attributeNumber); -} - -void Being::removePercentStatModifier(int attributeNumber, short value) -{ - std::list<short>::iterator - i = mBeingModificators.percentModificators.at(attributeNumber).begin(), - i_end = mBeingModificators.percentModificators.at(attributeNumber).end(); - for (; i != i_end; i++) - { - if ((*i) = value) - { - mBeingModificators.percentModificators.at(attributeNumber).erase(i); - break; - } - } - if (i == i_end) - LOG_WARN("Attempt to remove a stat modificator for Being" << - getPublicID() << - "that hasn't been added before!"); - - calculateCompoundAttribute(attributeNumber); - - return; -} - -void Being::calculateCompoundAttribute(int attributeNumber) +void Being::calculateDerivedAttributes() { - int value; - - if (attributeNumber < NB_BASE_ATTRIBUTES) - value = getBaseAttribute(attributeNumber); - - switch (attributeNumber) + // effective values for basic attributes + for (int i = NB_BASE_ATTRIBUTES; i < NB_EFFECTIVE_ATTRIBUTES; i++) { - case ATT_HP_MAXIMUM: - value = 20 + (20 * getBaseAttribute(ATT_VITALITY)); - break; - case ATT_PHYSICAL_ATTACK_MINIMUM: - value = 10 + getBaseAttribute(ATT_STRENGTH); - break; - case ATT_PHYSICAL_ATTACK_FLUCTUATION: - value = 10; - break; - case ATT_PHYSICAL_DEFENCE: - value = 10 + getBaseAttribute(ATT_STRENGTH); - break; - case ATT_MAGIC: - value = 0; - break; - case ATT_ACCURACY: - value = 50 + getBaseAttribute(ATT_DEXTERITY); - break; - case ATT_SPEED: - value = getBaseAttribute(ATT_AGILITY); - break; + mAttributes.at(i) + = getAttribute(i - NB_BASE_ATTRIBUTES); // TODO: add modifiers } - value += mBeingModificators.absoluteModificator.at(attributeNumber); + // combat-related derived stats + mAttributes.at(DERIVED_ATTR_HP_MAXIMUM) + = getAttribute(ATTR_EFF_VITALITY); // TODO: find a better formula - std::list<short>::iterator i; + mAttributes.at(DERIVED_ATTR_PHYSICAL_ATTACK_MINIMUM) + = getAttribute(ATTR_EFF_STRENGTH); - float multiplier = 1.0f; - - for ( i = mBeingModificators.percentModificators.at(attributeNumber).begin(); - i != mBeingModificators.percentModificators.at(attributeNumber).end(); - i++ - ) - { - multiplier *= (100.0f + (float)(*i)) / 100.0f; - } + mAttributes.at(DERIVED_ATTR_PHYSICAL_ATTACK_FLUCTUATION) + = getAttribute(getWeaponStats().skill); - /* Floating point inaccuracies might result in a negative multiplier. That - * would result in a stat near 2^16. To make sure that this doesn't happen - * we return a value of 0 in that case - */ - mCompoundAttributes[attributeNumber] = - (multiplier < 0.0f) ? 0 : (unsigned short)(value * multiplier); -} - -void Being::recalculateAllCompoundAttributes() -{ - for (int i = 0; i < (NB_COMPOUND_ATTRIBUTES); i++) - { - calculateCompoundAttribute(i); - } + mAttributes.at(DERIVED_ATTR_PHYSICAL_DEFENCE) + = 0 /* + sum of equipment pieces */; } Damage Being::getPhysicalAttackDamage() { Damage damage; + WeaponStats weaponStats = getWeaponStats(); + damage.type = DAMAGETYPE_PHYSICAL; - damage.value = getCompoundAttribute(ATT_PHYSICAL_ATTACK_MINIMUM) - + (rand()%getCompoundAttribute(ATT_PHYSICAL_ATTACK_FLUCTUATION)); - damage.penetration = 1; // TODO: get from equipped weapon - damage.element = ELEMENT_NEUTRAL; // TODO: get from equipped weapon + damage.value = getAttribute(DERIVED_ATTR_PHYSICAL_ATTACK_MINIMUM) + + (rand()%getAttribute(DERIVED_ATTR_PHYSICAL_ATTACK_FLUCTUATION)); + damage.piercing = weaponStats.piercing; + damage.element = weaponStats.element; damage.source = this; return damage; } + +WeaponStats Being::getWeaponStats() +{ + /* this function should never be called. it is just here to pacify the + * compiler. + */ + WeaponStats weaponStats; + + weaponStats.piercing = 1; + weaponStats.element = ELEMENT_NEUTRAL; + weaponStats.skill = 0; + + return weaponStats; +}; |