diff options
author | Erik Schilling <ablu.erikschilling@googlemail.com> | 2013-02-20 15:34:28 +0100 |
---|---|---|
committer | Erik Schilling <ablu.erikschilling@googlemail.com> | 2013-02-20 15:34:28 +0100 |
commit | c70c6d19c1cabf46b595591802bceab63d371788 (patch) | |
tree | 1c153d2bfe560171bad5889d528dc5cf110e8533 /src/game-server/character.cpp | |
parent | d707495540581f8c1b9ab3d5007c9c4d1ab83b53 (diff) | |
parent | 587b7682e6bf7dd9e616c1d4789a5ed9aa986e6d (diff) | |
download | manaserv-c70c6d19c1cabf46b595591802bceab63d371788.tar.gz manaserv-c70c6d19c1cabf46b595591802bceab63d371788.tar.bz2 manaserv-c70c6d19c1cabf46b595591802bceab63d371788.tar.xz manaserv-c70c6d19c1cabf46b595591802bceab63d371788.zip |
Merge branch 'master' into lpc2012
Conflicts:
gameserver.cbp
src/account-server/accounthandler.cpp
src/game-server/attack.cpp
src/game-server/attack.h
src/game-server/being.cpp
src/game-server/being.h
src/game-server/character.cpp
src/game-server/character.h
src/game-server/inventory.cpp
src/game-server/item.h
src/game-server/monster.cpp
src/game-server/monster.h
Diffstat (limited to 'src/game-server/character.cpp')
-rw-r--r-- | src/game-server/character.cpp | 108 |
1 files changed, 17 insertions, 91 deletions
diff --git a/src/game-server/character.cpp b/src/game-server/character.cpp index 90a261fc..61fb35d1 100644 --- a/src/game-server/character.cpp +++ b/src/game-server/character.cpp @@ -24,7 +24,6 @@ #include "game-server/accountconnection.h" #include "game-server/attributemanager.h" #include "game-server/buysell.h" -#include "game-server/eventlistener.h" #include "game-server/inventory.h" #include "game-server/item.h" #include "game-server/itemmanager.h" @@ -465,98 +464,35 @@ void Character::modifiedAllAttribute() } } -bool Character::recalculateBaseAttribute(unsigned int attr) +void Character::recalculateBaseAttribute(unsigned attr) { - /* - * `attr' may or may not have changed. Recalculate the base value. - */ + // `attr' may or may not have changed. Recalculate the base value. LOG_DEBUG("Received update attribute recalculation request at Character " "for " << attr << "."); if (!mAttributes.count(attr)) - return false; - double newBase = getAttribute(attr); - - /* - * Calculate new base. - */ - switch (attr) - { - case ATTR_ACCURACY: - newBase = getModifiedAttribute(ATTR_DEX); // Provisional - break; - case ATTR_DEFENSE: - newBase = 0.3 * getModifiedAttribute(ATTR_VIT); - break; - case ATTR_DODGE: - newBase = getModifiedAttribute(ATTR_AGI); // Provisional - break; - case ATTR_MAGIC_DODGE: - newBase = 1.0; - // TODO - break; - case ATTR_MAGIC_DEFENSE: - newBase = 0.0; - // TODO - break; - case ATTR_BONUS_ASPD: - newBase = 0.0; - // TODO - break; - case ATTR_STR: - if (mKnuckleAttackInfo) - { - Damage &knuckleDamage = mKnuckleAttackInfo->getDamage(); - knuckleDamage.base = getModifiedAttribute(ATTR_STR); - knuckleDamage.delta = knuckleDamage.base / 2; - } - break; - default: - return Being::recalculateBaseAttribute(attr); - } + return; - if (newBase != getAttribute(attr)) + if (attr == ATTR_STR && mKnuckleAttackInfo) { - setAttribute(attr, newBase); - updateDerivedAttributes(attr); - return true; + // TODO: dehardcode this + Damage &knuckleDamage = mKnuckleAttackInfo->getDamage(); + knuckleDamage.base = getModifiedAttribute(ATTR_STR); + knuckleDamage.delta = knuckleDamage.base / 2; } - LOG_DEBUG("No changes to sync for attribute '" << attr << "'."); - return false; + Being::recalculateBaseAttribute(attr); + } -void Character::updateDerivedAttributes(unsigned int attr) + +void Character::updateDerivedAttributes(unsigned attr) { /* * `attr' has changed, perform updates accordingly. */ flagAttribute(attr); - switch(attr) - { - case ATTR_STR: - recalculateBaseAttribute(ATTR_INV_CAPACITY); - break; - case ATTR_AGI: - recalculateBaseAttribute(ATTR_DODGE); - recalculateBaseAttribute(ATTR_MOVE_SPEED_TPS); - break; - case ATTR_VIT: - recalculateBaseAttribute(ATTR_MAX_HP); - recalculateBaseAttribute(ATTR_HP_REGEN); - recalculateBaseAttribute(ATTR_DEFENSE); - break; - case ATTR_INT: - // TODO - break; - case ATTR_DEX: - recalculateBaseAttribute(ATTR_ACCURACY); - break; - case ATTR_WIL: - // TODO - break; - default: - Being::updateDerivedAttributes(attr); - } + + Being::updateDerivedAttributes(attr); } void Character::flagAttribute(int attr) @@ -776,15 +712,12 @@ void Character::addAttack(AttackInfo *attackInfo) void Character::removeAttack(AttackInfo *attackInfo) { + Being::removeAttack(attackInfo); // Add knuckle attack - if (mAttacks.getNumber() == 1) - { + if (mAttacks.getNumber() == 0) Being::addAttack(mKnuckleAttackInfo); - } - Being::removeAttack(attackInfo); } - void Character::disconnected() { mConnected = false; @@ -795,14 +728,7 @@ void Character::disconnected() else GameState::remove(this); - for (Listeners::iterator i = mListeners.begin(), - i_end = mListeners.end(); i != i_end;) - { - const EventListener &l = **i; - ++i; // In case the listener removes itself from the list on the fly. - if (l.dispatch->disconnected) - l.dispatch->disconnected(&l, this); - } + signal_disconnected.emit(this); } bool Character::takeSpecial(int id) |