summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/being.cpp7
-rw-r--r--src/being.h13
-rw-r--r--src/localplayer.h5
-rw-r--r--src/net/ea/beinghandler.cpp34
4 files changed, 44 insertions, 15 deletions
diff --git a/src/being.cpp b/src/being.cpp
index 84528622d..5eac242fd 100644
--- a/src/being.cpp
+++ b/src/being.cpp
@@ -229,6 +229,7 @@ Being::Being(int id, Type type, Uint16 subtype, Map *map):
mGender(GENDER_UNSPECIFIED),
mParty(0),
mIsGM(false),
+ mAttackRange(1),
mType(type),
mX(0), mY(0),
mDamageTaken(0),
@@ -1994,7 +1995,11 @@ bool Being::drawSpriteAt(Graphics *graphics, int x, int y) const
if (mHighlightMonsterAttackRange && mType == ActorSprite::MONSTER
&& isAlive())
{
- const int attackRange = 32;
+ int attackRange;
+ if (mAttackRange)
+ attackRange = 32 * mAttackRange;
+ else
+ attackRange = 32;
graphics->setColor(userPalette->getColorWithAlpha(
UserPalette::MONSTER_ATTACK_RANGE));
diff --git a/src/being.h b/src/being.h
index 90bfcfb54..9b38e1479 100644
--- a/src/being.h
+++ b/src/being.h
@@ -755,6 +755,18 @@ class Being : public ActorSprite, public ConfigListener
bool isShopEnabled()
{ return mShop; }
+ /**
+ * Sets the attack range.
+ */
+ void setAttackRange(int range)
+ { mAttackRange = range; }
+
+ void attack(Being *target = NULL, bool keep = false,
+ bool dontChangeEquipment = false);
+
+ void attack2(Being *target = NULL, bool keep = false,
+ bool dontChangeEquipment = false);
+
protected:
/**
* Sets the new path for this being.
@@ -823,6 +835,7 @@ class Being : public ActorSprite, public ConfigListener
Party *mParty;
bool mIsGM;
+ int mAttackRange;
private:
diff --git a/src/localplayer.h b/src/localplayer.h
index 447306994..30acb3cda 100644
--- a/src/localplayer.h
+++ b/src/localplayer.h
@@ -130,11 +130,6 @@ class LocalPlayer : public Being, public ActorSpriteListener,
void actorSpriteDestroyed(const ActorSprite &actorSprite);
/**
- * Sets the attack range.
- */
- void setAttackRange(int range) { mAttackRange = range; }
-
- /**
* Gets the attack range.
*/
int getAttackRange();
diff --git a/src/net/ea/beinghandler.cpp b/src/net/ea/beinghandler.cpp
index 2ac1f87c5..8fca76353 100644
--- a/src/net/ea/beinghandler.cpp
+++ b/src/net/ea/beinghandler.cpp
@@ -209,14 +209,22 @@ void BeingHandler::processBeingVisibleOrMove(Net::MessageIn &msg, bool visible)
if (dstBeing->getType() == ActorSprite::MONSTER)
{
- int hp = msg.readInt32();
- int maxHP = msg.readInt32();
- if (hp && maxHP)
+ if (serverVersion > 0)
{
- int oldHP = dstBeing->getHP();
- if (!oldHP || oldHP > hp)
- dstBeing->setHP(hp);
- dstBeing->setMaxHP(maxHP);
+ int hp = msg.readInt32();
+ int maxHP = msg.readInt32();
+ if (hp && maxHP)
+ {
+ int oldHP = dstBeing->getHP();
+ if (!oldHP || oldHP > hp)
+ dstBeing->setHP(hp);
+ dstBeing->setMaxHP(maxHP);
+ }
+ }
+ else
+ {
+ msg.readInt32();
+ msg.readInt32();
}
gloves = 0;
}
@@ -236,14 +244,22 @@ void BeingHandler::processBeingVisibleOrMove(Net::MessageIn &msg, bool visible)
msg.readInt16(); // manner
dstBeing->setStatusEffectBlock(32, msg.readInt16()); // opt3
- msg.readInt8(); // karma
+ if (serverVersion > 0 && dstBeing->getType() == ActorSprite::MONSTER)
+ {
+ int attackRange = msg.readInt8(); // karma
+ dstBeing->setAttackRange(attackRange);
+ }
+ else
+ {
+ msg.readInt8(); // karma
+ }
gender = msg.readInt8();
// reserving bits for future usage
- gender &= 1;
if (dstBeing->getType() == ActorSprite::PLAYER)
{
+ gender &= 1;
dstBeing->setGender((gender == 0) ? GENDER_FEMALE : GENDER_MALE);
// Set these after the gender, as the sprites may be gender-specific
setSprite(dstBeing, EA_SPRITE_HAIR, hairStyle * -1,