From 851bee28374c5c60114c9f78299e28eaa14891b3 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Tue, 4 Oct 2011 02:18:31 +0300 Subject: Dont select in archer mode very closer mobs if no other mobs in attack distance. --- src/being.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/being.h') diff --git a/src/being.h b/src/being.h index 2c37ffeb5..90bfcfb54 100644 --- a/src/being.h +++ b/src/being.h @@ -540,7 +540,7 @@ class Being : public ActorSprite, public ConfigListener const Path &getPath() const { return mPath; } - int getDistance() + int getDistance() const { return mDistance; } void setDistance(int n) -- cgit v1.2.3-60-g2f50 From 994ce665a9a32899a0f7efadf1253faa9a3cdbed Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Mon, 10 Oct 2011 01:36:09 +0300 Subject: Add support for reading monsters attack range. Tmw server not supported. --- src/being.cpp | 7 ++++++- src/being.h | 13 +++++++++++++ src/localplayer.h | 5 ----- src/net/ea/beinghandler.cpp | 34 +++++++++++++++++++++++++--------- 4 files changed, 44 insertions(+), 15 deletions(-) (limited to 'src/being.h') 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 @@ -129,11 +129,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. */ 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, -- cgit v1.2.3-60-g2f50