summaryrefslogtreecommitdiff
path: root/src/monster.cpp
diff options
context:
space:
mode:
authorBjørn Lindeijer <bjorn@lindeijer.nl>2009-03-22 19:45:03 +0100
committerBjørn Lindeijer <bjorn@lindeijer.nl>2009-03-22 19:45:56 +0100
commit0c43d04b438d41c277ae80402d4b4888db1a0b64 (patch)
tree3aaeb75ecd1bcbe85decedab5f1fa426fe0411e3 /src/monster.cpp
parenta7f5eaeb7f643658d356533a608f0f18d85b6d32 (diff)
parent401802c1d7a1b3d659bdc53a45d9a6292fc1121e (diff)
downloadMana-0c43d04b438d41c277ae80402d4b4888db1a0b64.tar.gz
Mana-0c43d04b438d41c277ae80402d4b4888db1a0b64.tar.bz2
Mana-0c43d04b438d41c277ae80402d4b4888db1a0b64.tar.xz
Mana-0c43d04b438d41c277ae80402d4b4888db1a0b64.zip
Merged the tmwserv client with the eAthena client
This merge involved major changes on both sides, and as such took several weeks. Lots of things are expected to be broken now, however, we now have a single code base to improve and extend, which can be compiled to support either eAthena or tmwserv. In the coming months, the plan is to work towards a client that supports both eAthena and tmwserv, without needing to be recompiled. Conflicts: Everywhere!
Diffstat (limited to 'src/monster.cpp')
-rw-r--r--src/monster.cpp34
1 files changed, 29 insertions, 5 deletions
diff --git a/src/monster.cpp b/src/monster.cpp
index 610da492..deabd7a8 100644
--- a/src/monster.cpp
+++ b/src/monster.cpp
@@ -37,7 +37,7 @@ Monster::Monster(Uint32 id, Uint16 job, Map *map):
Being(id, job, map),
mText(0)
{
- const MonsterInfo& info = MonsterDB::get(job - 1002);
+ const MonsterInfo& info = getInfo();
// Setup Monster sprites
int c = BASE_SPRITE;
@@ -79,11 +79,12 @@ Monster::~Monster()
delete mText;
}
+#ifdef EATHENA_SUPPORT
void Monster::logic()
{
if (mAction != STAND)
{
- mFrame = (get_elapsed_time(mWalkTime) * 4) / mWalkSpeed;
+ mFrame = (get_elapsed_time(mWalkTime) * 4) / getWalkSpeed();
if (mFrame >= 4 && mAction != DEAD)
{
@@ -93,13 +94,14 @@ void Monster::logic()
Being::logic();
}
+#endif
Being::Type Monster::getType() const
{
return MONSTER;
}
-void Monster::setAction(Action action)
+void Monster::setAction(Action action, int attackType)
{
SpriteAction currentAction = ACTION_INVALID;
int rotation = 0;
@@ -115,11 +117,11 @@ void Monster::setAction(Action action)
sound.playSfx(getInfo().getSound(MONSTER_EVENT_DIE));
break;
case ATTACK:
- currentAction = ACTION_ATTACK;
+ currentAction = getInfo().getAttackAction(attackType);
mSprites[BASE_SPRITE]->reset();
//attack particle effect
- particleEffect = getInfo().getAttackParticleEffect();
+ particleEffect = getInfo().getAttackParticleEffect(attackType);
if (!particleEffect.empty() && mParticleEffects)
{
switch (mDirection)
@@ -160,6 +162,22 @@ void Monster::setAction(Action action)
}
}
+#ifdef TMWSERV_SUPPORT
+
+void Monster::handleAttack()
+{
+ Being::handleAttack();
+
+ const MonsterInfo &mi = getInfo();
+
+ // TODO: It's not possible to determine hit or miss here, so this stuff
+ // probably needs to be moved somewhere else. We may lose synchronization
+ // between attack animation and the sound, unless we adapt the protocol...
+ sound.playSfx(mi.getSound(MONSTER_EVENT_HIT));
+}
+
+#else
+
void Monster::handleAttack(Being *victim, int damage)
{
Being::handleAttack(victim, damage);
@@ -169,6 +187,8 @@ void Monster::handleAttack(Being *victim, int damage)
MONSTER_EVENT_HIT : MONSTER_EVENT_MISS));
}
+#endif
+
void Monster::takeDamage(int amount)
{
if (amount > 0) sound.playSfx(getInfo().getSound(MONSTER_EVENT_HURT));
@@ -182,7 +202,11 @@ Being::TargetCursorSize Monster::getTargetCursorSize() const
const MonsterInfo &Monster::getInfo() const
{
+#ifdef TMWSERV_SUPPORT
+ return MonsterDB::get(mJob);
+#else
return MonsterDB::get(mJob - 1002);
+#endif
}
void Monster::showName(bool show)