From e975b11e1885457295a51778d8337b097549228d Mon Sep 17 00:00:00 2001 From: David Athay Date: Tue, 19 May 2009 15:58:58 +0100 Subject: Fixed targeting and warn on attack-range not being found in itemdb. Tried to make the client continue attacking (it does not need to send attack packets, but just continue playing attack animation and sounds). Now logs a warning when a weapon is found without an attack-range (I keep finding weapons with an attack-range of 0 which makes it hard to target monsters). --- src/gui/viewport.cpp | 12 ++---------- src/localplayer.cpp | 14 +++++--------- src/net/tmwserv/protocol.h | 6 ++++-- src/resources/itemdb.cpp | 4 ++++ 4 files changed, 15 insertions(+), 21 deletions(-) (limited to 'src') diff --git a/src/gui/viewport.cpp b/src/gui/viewport.cpp index cbde95c4..787723c0 100644 --- a/src/gui/viewport.cpp +++ b/src/gui/viewport.cpp @@ -357,20 +357,12 @@ void Viewport::mousePressed(gcn::MouseEvent &event) if (player_node->withinAttackRange(being) || keyboard.isKeyActive(keyboard.KEY_ATTACK)) { - player_node->setGotoTarget(being); - player_node->attack(being, !keyboard.isKeyActive(keyboard.KEY_TARGET)); - } else { -#ifdef TMWSERV_SUPPORT - player_node->setDestination(event.getX() + (int) mPixelViewX, - event.getY() + (int) mPixelViewY); -#else - player_node->setDestination(tilex, tiley); -#endif + player_node->setGotoTarget(being); } break; default: @@ -399,9 +391,9 @@ void Viewport::mousePressed(gcn::MouseEvent &event) event.getY() + (int) mPixelViewY); } #else - player_node->stopAttack(); player_node->setDestination(tilex, tiley); #endif + player_node->stopAttack(); mPlayerFollowMouse = true; } } diff --git a/src/localplayer.cpp b/src/localplayer.cpp index b9f4b850..31b963ab 100644 --- a/src/localplayer.cpp +++ b/src/localplayer.cpp @@ -209,18 +209,14 @@ void LocalPlayer::logic() // Find whether target is in range const int rangeX = abs(mTarget->getPosition().x - getPosition().x); const int rangeY = abs(mTarget->getPosition().y - getPosition().y); - const int attackRange = getAttackRange(); - const int inRange = rangeX > attackRange || rangeY > attackRange - ? 1 : 0; #else // Find whether target is in range const int rangeX = abs(mTarget->mX - mX); const int rangeY = abs(mTarget->mY - mY); +#endif const int attackRange = getAttackRange(); const int inRange = rangeX > attackRange || rangeY > attackRange ? 1 : 0; -#endif - mTarget->setTargetAnimation( mTargetCursor[inRange][mTarget->getTargetCursorSize()]); @@ -290,9 +286,7 @@ void LocalPlayer::nextStep() if (mGoingToTarget && mTarget && withinAttackRange(mTarget)) { mAction = Being::STAND; -#ifdef EATHENA_SUPPORT attack(mTarget, true); -#endif mGoingToTarget = false; mPath.clear(); return; @@ -703,11 +697,11 @@ void LocalPlayer::attack(Being *target, bool keep) #else int dist_x = target->mX - mX; int dist_y = target->mY - mY; -#endif // Must be standing to attack if (mAction != STAND) return; +#endif if (abs(dist_y) >= abs(dist_x)) { @@ -744,10 +738,12 @@ void LocalPlayer::attack(Being *target, bool keep) sound.playSfx("sfx/fist-swish.ogg"); } +#ifdef EATHENA_SUPPORT Net::getPlayerHandler()->attack(target->getId()); if (!keep) stopAttack(); +#endif } void LocalPlayer::stopAttack() @@ -872,7 +868,7 @@ int LocalPlayer::getAttackRange() const ItemInfo info = weapon->getInfo(); return info.getAttackRange(); } - return 32; // unarmed range + return 48; // unarmed range #else return mAttackRange; #endif diff --git a/src/net/tmwserv/protocol.h b/src/net/tmwserv/protocol.h index 0f2a1b0d..6124263a 100644 --- a/src/net/tmwserv/protocol.h +++ b/src/net/tmwserv/protocol.h @@ -162,9 +162,11 @@ enum { CPMSG_GUILD_QUIT_RESPONSE = 0x0361, // B error PCMSG_GUILD_PROMOTE_MEMBER = 0x0365, // W guild, S name, B rights CPMSG_GUILD_PROMOTE_MEMBER_RESPONSE = 0x0366, // B error + PCMSG_GUILD_KICK_MEMBER = 0x0370, // W guild, S name + CPMSG_GUILD_KICK_MEMBER_RESPONSE = 0x0371, // B error - CPMSG_GUILD_INVITED = 0x0370, // S char name, S guild name, W id - CPMSG_GUILD_REJOIN = 0x0371, // S name, W guild, W rights, W channel, S announce + CPMSG_GUILD_INVITED = 0x0388, // S char name, S guild name, W id + CPMSG_GUILD_REJOIN = 0x0389, // S name, W guild, W rights, W channel, S announce // Party PCMSG_PARTY_INVITE = 0x03A0, // S name diff --git a/src/resources/itemdb.cpp b/src/resources/itemdb.cpp index 99907ca7..fa31c556 100644 --- a/src/resources/itemdb.cpp +++ b/src/resources/itemdb.cpp @@ -210,6 +210,10 @@ void ItemDB::load() } } + if (weaponType > 0) + if (attackRange == 0) + logger->log("ItemDB: Missing attack range from weapon %i!", id); + #define CHECK_PARAM(param, error_value) \ if (param == error_value) \ logger->log("ItemDB: Missing " #param " attribute for item %i!",id) -- cgit v1.2.3-70-g09d2