diff options
author | Yohann Ferreira <yohann_dot_ferreira_at_orange_dot_efer> | 2011-06-24 01:49:58 +0200 |
---|---|---|
committer | Yohann Ferreira <yohann_dot_ferreira_at_orange_dot_efer> | 2011-06-24 01:49:58 +0200 |
commit | b4589749217c550db0849b439b6687ff4f5822d7 (patch) | |
tree | 7e23d1b1e3397cf3bdc8f45c3fa2aab244fb003b /src/game-server/character.cpp | |
parent | bb7033e0247ab1d3a526a5d68f9c482f6ff01ba7 (diff) | |
download | manaserv-b4589749217c550db0849b439b6687ff4f5822d7.tar.gz manaserv-b4589749217c550db0849b439b6687ff4f5822d7.tar.bz2 manaserv-b4589749217c550db0849b439b6687ff4f5822d7.tar.xz manaserv-b4589749217c550db0849b439b6687ff4f5822d7.zip |
Fixed autoattacks basic handling.
The server is now using the autoattacks system to perform damage
based on the attack's timer.
I also added a default bare knuckle attack when the character
is unequipped.
As a result, maggots can be killed again with bare hands now.
Known issues left:
This isn't tested against equipment changes for now, and the client
isn't in sync with the attacks speed.
Reviewed-by: Crush.
Diffstat (limited to 'src/game-server/character.cpp')
-rw-r--r-- | src/game-server/character.cpp | 46 |
1 files changed, 34 insertions, 12 deletions
diff --git a/src/game-server/character.cpp b/src/game-server/character.cpp index 46f9eade..bbe26bd6 100644 --- a/src/game-server/character.cpp +++ b/src/game-server/character.cpp @@ -143,25 +143,47 @@ void Character::update() void Character::perform() { - if (mAction != ATTACK || mTarget == NULL) return; + // Ticks attacks even when not attacking to permit cooldowns and warmups. + std::list<AutoAttack> attacksReady; + mAutoAttacks.tick(&attacksReady); - // wait before next attack - // Note: The auto-attack system will handle the delay between two attacks. - // TODO: Remove this condition when it's done. - if (mMoveTime > WORLD_TICK_MS) + if (mAction != ATTACK || mTarget == NULL) { - mMoveTime -= WORLD_TICK_MS; + mAutoAttacks.stop(); return; } - std::list<AutoAttack> attacks; - mAutoAttacks.tick(&attacks); - if (attacks.empty()) - return; // TODO: Install default attack? + // Deal with the ATTACK action. + + // Install default bare knuckle attack if no attacks were added from config. + // TODO: Get this from configuration. + if (!mAutoAttacks.getAutoAttacksNumber()) + { + int damageBase = getModifiedAttribute(ATTR_STR); + int damageDelta = damageBase / 2; + Damage knuckleDamage(damageBase, damageDelta, 2, ELEMENT_NEUTRAL, + DAMAGE_PHYSICAL, + (getSize() < DEFAULT_TILE_LENGTH) ? + DEFAULT_TILE_LENGTH : getSize()); + + AutoAttack knuckleAttack(knuckleDamage, 7, 3); + mAutoAttacks.add(knuckleAttack); + } + + if (attacksReady.empty()) + { + if (!mAutoAttacks.areActive()) + mAutoAttacks.start(); + } else - for (std::list<AutoAttack>::iterator it = attacks.begin(); - it != attacks.end(); ++it) + { + // Performs all ready attacks. + for (std::list<AutoAttack>::iterator it = attacksReady.begin(); + it != attacksReady.end(); ++it) + { performAttack(mTarget, it->getDamage()); + } + } } void Character::died() |