diff options
author | Andrei Karas <akaras@inbox.ru> | 2011-10-10 01:36:09 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2011-10-10 01:36:09 +0300 |
commit | 994ce665a9a32899a0f7efadf1253faa9a3cdbed (patch) | |
tree | b46d2bbf36d85143c95f35c987817ca3f1d25fab | |
parent | 2d449d99cc4b42faf246bd24a87ec76da1363e41 (diff) | |
download | plus-994ce665a9a32899a0f7efadf1253faa9a3cdbed.tar.gz plus-994ce665a9a32899a0f7efadf1253faa9a3cdbed.tar.bz2 plus-994ce665a9a32899a0f7efadf1253faa9a3cdbed.tar.xz plus-994ce665a9a32899a0f7efadf1253faa9a3cdbed.zip |
Add support for reading monsters attack range.
Tmw server not supported.
-rw-r--r-- | src/being.cpp | 7 | ||||
-rw-r--r-- | src/being.h | 13 | ||||
-rw-r--r-- | src/localplayer.h | 5 | ||||
-rw-r--r-- | src/net/ea/beinghandler.cpp | 34 |
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, |