summaryrefslogtreecommitdiff
path: root/src/monster.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/monster.cpp')
-rw-r--r--src/monster.cpp47
1 files changed, 34 insertions, 13 deletions
diff --git a/src/monster.cpp b/src/monster.cpp
index f71457df..eaea6225 100644
--- a/src/monster.cpp
+++ b/src/monster.cpp
@@ -1,9 +1,8 @@
/*
- * Aethyra
+ * The Mana World
* Copyright (C) 2004 The Mana World Development Team
*
- * This file is part of Aethyra based on original code
- * from The Mana World.
+ * This file is part of The Mana World.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -40,7 +39,7 @@ Monster::Monster(int 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;
@@ -82,11 +81,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)
{
@@ -96,13 +96,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;
@@ -118,11 +119,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)
@@ -163,6 +164,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, AttackType type)
{
Being::handleAttack(victim, damage, type);
@@ -172,6 +189,8 @@ void Monster::handleAttack(Being *victim, int damage, AttackType type)
MONSTER_EVENT_HIT : MONSTER_EVENT_MISS));
}
+#endif
+
void Monster::takeDamage(Being *attacker, int amount, AttackType type)
{
if (amount > 0) sound.playSfx(getInfo().getSound(MONSTER_EVENT_HURT));
@@ -185,15 +204,17 @@ 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)
+void Monster::setShowName(bool show)
{
- if (mText)
- {
- delete mText;
- }
+ delete mText;
+
if (show)
{
mText = new Text(getInfo().getName(), mPx + NAME_X_OFFSET,