summaryrefslogtreecommitdiff
path: root/src/being.cpp
diff options
context:
space:
mode:
authorBjørn Lindeijer <bjorn@lindeijer.nl>2006-12-11 15:47:35 +0000
committerBjørn Lindeijer <bjorn@lindeijer.nl>2006-12-11 15:47:35 +0000
commit8da32105732949b4b0273c718d118bcfae70a1c9 (patch)
tree0a354974d48268cfaafcdb1e06b498fa26a59c1e /src/being.cpp
parentf9ce4e302cb3ed203d89a7a18e10b7ad4f11519c (diff)
downloadmana-8da32105732949b4b0273c718d118bcfae70a1c9.tar.gz
mana-8da32105732949b4b0273c718d118bcfae70a1c9.tar.bz2
mana-8da32105732949b4b0273c718d118bcfae70a1c9.tar.xz
mana-8da32105732949b4b0273c718d118bcfae70a1c9.zip
Merged 0.0 changes from revision 2825 to 2898 to trunk.
Diffstat (limited to 'src/being.cpp')
-rw-r--r--src/being.cpp87
1 files changed, 40 insertions, 47 deletions
diff --git a/src/being.cpp b/src/being.cpp
index 50a2dc35..9cd0af0d 100644
--- a/src/being.cpp
+++ b/src/being.cpp
@@ -49,7 +49,7 @@ PATH_NODE::PATH_NODE(Uint16 iX, Uint16 iY):
Being::Being(Uint16 id, Uint16 job, Map *map):
mJob(job),
- mX(0), mY(0), mDirection(DOWN),
+ mX(0), mY(0),
mAction(STAND),
mWalkTime(0),
mEmotion(0), mEmotionTime(0),
@@ -60,12 +60,15 @@ Being::Being(Uint16 id, Uint16 job, Map *map):
mWeapon(0),
mWalkSpeed(150),
mSpeedModifier(1024),
+ mDirection(DOWN),
mMap(NULL),
mHairStyle(0), mHairColor(0),
mSpeechTime(0),
mDamageTime(0),
mShowSpeech(false), mShowDamage(false),
- mSprites(VECTOREND_SPRITE, NULL)
+ mPx(0), mPy(0),
+ mSprites(VECTOREND_SPRITE, NULL),
+ mEquipmentSpriteIDs(VECTOREND_SPRITE, 0)
{
setMap(map);
}
@@ -110,9 +113,7 @@ void Being::adjustCourse(Uint16 srcX, Uint16 srcY, Uint16 dstX, Uint16 dstY)
p1 = mMap->findPath(srcX / 32, srcY / 32, dstX / 32, dstY / 32);
if (p1.empty())
{
- // No path? Better teleport.
- mX = dstX;
- mY = dstY;
+ // No path, but don't teleport since it could be user input.
setPath(p1);
return;
}
@@ -189,9 +190,8 @@ void Being::adjustCourse(Uint16 srcX, Uint16 srcY, Uint16 dstX, Uint16 dstY)
if (bestRating < 0)
{
- // Unable to reach the path? Better teleport.
- mX = srcX;
- mY = srcY;
+ // Unable to reach the path? Still, don't teleport since it could be
+ // user input instead of server command.
setPath(p1);
delete[] p1_dist;
return;
@@ -263,8 +263,9 @@ Being::setHairStyle(Uint16 style)
}
void
-Being::setVisibleEquipment(Uint8 slot, Uint8 id)
+Being::setVisibleEquipment(Uint8 slot, int id)
{
+ mEquipmentSpriteIDs[slot] = id;
}
void
@@ -304,7 +305,7 @@ Being::setMap(Map *map)
void
Being::setAction(Uint8 action)
{
- SpriteAction currentAction = ACTION_STAND;
+ SpriteAction currentAction = ACTION_INVALID;
switch (action)
{
case WALK:
@@ -314,37 +315,21 @@ Being::setAction(Uint8 action)
currentAction = ACTION_SIT;
break;
case ATTACK:
- if (getType() == MONSTER)
+ switch (getWeapon())
{
- currentAction = ACTION_DEAD;
+ case 3:
+ currentAction = ACTION_ATTACK;
+ break;
+ case 2:
+ currentAction = ACTION_ATTACK_BOW;
+ break;
+ case 1:
+ currentAction = ACTION_ATTACK_STAB;
+ break;
+ case 0:
+ currentAction = ACTION_ATTACK;
+ break;
}
- else {
- switch (getWeapon())
- {
- case 3:
- currentAction = ACTION_ATTACK;
- break;
- case 2:
- currentAction = ACTION_ATTACK_BOW;
- break;
- case 1:
- currentAction = ACTION_ATTACK_STAB;
- break;
- case 0:
- currentAction = ACTION_ATTACK;
- break;
- }
- for (int i = 0; i < VECTOREND_SPRITE; i++)
- {
- if (mSprites[i])
- {
- mSprites[i]->reset();
- }
- }
- };
- break;
- case MONSTER_ATTACK:
- currentAction = ACTION_ATTACK;
for (int i = 0; i < VECTOREND_SPRITE; i++)
{
if (mSprites[i])
@@ -353,25 +338,33 @@ Being::setAction(Uint8 action)
}
}
break;
+ case HURT:
+ //currentAction = ACTION_HURT; // Buggy: makes the player stop
+ // attacking and unable to attack
+ // again until he moves
+ break;
case DEAD:
currentAction = ACTION_DEAD;
break;
- default:
+ case STAND:
currentAction = ACTION_STAND;
break;
}
- for (int i = 0; i < VECTOREND_SPRITE; i++)
+ if (currentAction != ACTION_INVALID)
{
- if (mSprites[i])
+ for (int i = 0; i < VECTOREND_SPRITE; i++)
{
- mSprites[i]->play(currentAction);
+ if (mSprites[i])
+ {
+ mSprites[i]->play(currentAction);
+ }
}
+ mAction = action;
}
-
- mAction = action;
}
+
void
Being::setDirection(Uint8 direction)
{
@@ -487,7 +480,7 @@ Being::logic()
}
void
-Being::draw(Graphics *graphics, int offsetX, int offsetY)
+Being::draw(Graphics *graphics, int offsetX, int offsetY) const
{
int px = mPx + offsetX;
int py = mPy + offsetY;
@@ -528,7 +521,7 @@ Being::drawSpeech(Graphics *graphics, Sint32 offsetX, Sint32 offsetY)
}
// Draw damage above this being
- if (mShowDamage)
+ if (mShowDamage && get_elapsed_time(mDamageTime) > 250)
{
// Selecting the right color
if (mDamage == "miss")