summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDavid Athay <ko2fan@gmail.com>2009-05-19 12:04:19 +0100
committerDavid Athay <ko2fan@gmail.com>2009-05-19 12:04:19 +0100
commitd75912b44b311a0d6734d558f494f1d2ce1649e2 (patch)
tree021ec1fbc4f3ac358cbfe5aad918ba3f75dad910 /src
parentc3c5ff134ac2e31560b421d125b35a9a73a25e5c (diff)
downloadmanaserv-d75912b44b311a0d6734d558f494f1d2ce1649e2.tar.gz
manaserv-d75912b44b311a0d6734d558f494f1d2ce1649e2.tar.bz2
manaserv-d75912b44b311a0d6734d558f494f1d2ce1649e2.tar.xz
manaserv-d75912b44b311a0d6734d558f494f1d2ce1649e2.zip
Added time between attacks. Added target for monster.
Diffstat (limited to 'src')
-rw-r--r--src/game-server/being.cpp7
-rw-r--r--src/game-server/character.cpp11
-rw-r--r--src/game-server/gamehandler.cpp5
-rw-r--r--src/game-server/monster.cpp3
4 files changed, 15 insertions, 11 deletions
diff --git a/src/game-server/being.cpp b/src/game-server/being.cpp
index b43b789a..069da14b 100644
--- a/src/game-server/being.cpp
+++ b/src/game-server/being.cpp
@@ -224,9 +224,6 @@ int Being::directionToAngle(int direction)
void Being::performAttack(const Damage &damage)
{
- LOG_DEBUG("Direction:"<<getDirection()<<
- " Target:"<<mTarget->getName());
-
if (!mTarget || mTarget == this || mTarget->getAction() == Being::DEAD || !mTarget->canFight())
return;
@@ -234,7 +231,11 @@ void Being::performAttack(const Damage &damage)
getType() == OBJECT_CHARACTER)
return;
+ LOG_DEBUG("Direction: " << getDirection() <<
+ " Target: " << mTarget->getName());
+
mTarget->damage(this, damage);
+ mActionTime += 1000; // set to 10 ticks wait time
}
void Being::setAction(Action action)
diff --git a/src/game-server/character.cpp b/src/game-server/character.cpp
index e17abc2b..7e0dc125 100644
--- a/src/game-server/character.cpp
+++ b/src/game-server/character.cpp
@@ -116,11 +116,14 @@ void Character::update()
void Character::perform()
{
- if (mAction != ATTACK || mActionTime > 0 || mTarget == NULL) return;
+ if (mAction != ATTACK || mTarget == NULL) return;
- mActionTime = 1000;
- mAction = STAND;
- raiseUpdateFlags(UPDATEFLAG_ATTACK);
+ // wait before next attack
+ if (mActionTime > 100)
+ {
+ mActionTime -= 100;
+ return;
+ }
// TODO: Check slot 2 too.
int itemId = mPossessions.equipment[EQUIP_FIGHT1_SLOT];
diff --git a/src/game-server/gamehandler.cpp b/src/game-server/gamehandler.cpp
index 68af5314..12594d26 100644
--- a/src/game-server/gamehandler.cpp
+++ b/src/game-server/gamehandler.cpp
@@ -352,9 +352,10 @@ void GameHandler::processMessage(NetComputer *comp, MessageIn &message)
case PGMSG_ATTACK:
{
- LOG_DEBUG("Character " << computer.character->getPublicID()
- << " attacks");
int id = message.readShort();
+ LOG_DEBUG("Character " << computer.character->getPublicID()
+ << " attacked being " << id);
+
Actor *o = findActorNear(computer.character, id);
if (o && o->getType() != OBJECT_NPC)
{
diff --git a/src/game-server/monster.cpp b/src/game-server/monster.cpp
index eaab71f2..ed7048e2 100644
--- a/src/game-server/monster.cpp
+++ b/src/game-server/monster.cpp
@@ -111,7 +111,6 @@ Monster::~Monster()
void Monster::perform()
{
-
if (mAction == ATTACK && mCurrentAttack)
{
if (mAttackTime == mCurrentAttack->aftDelay)
@@ -208,7 +207,7 @@ void Monster::update()
targetPriority);
if (posPriority > bestTargetPriority)
{
- bestAttackTarget = target;
+ bestAttackTarget = mTarget = target;
bestTargetPriority = posPriority;
bestAttackPosition = attackPosition;
bestAttackDirection = (*j).direction;