summaryrefslogtreecommitdiff
path: root/src/localplayer.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2012-05-09 22:59:16 +0300
committerAndrei Karas <akaras@inbox.ru>2012-05-09 22:59:16 +0300
commiteb3cee0bc68ee576ed0eb429d22c6031f27def07 (patch)
tree8172ce45a24497942d489d350cc9cdb1340da97c /src/localplayer.cpp
parentaab80ddc8f56d6a383182ce5c241e9d94ca27bab (diff)
downloadmanaplus-eb3cee0bc68ee576ed0eb429d22c6031f27def07.tar.gz
manaplus-eb3cee0bc68ee576ed0eb429d22c6031f27def07.tar.bz2
manaplus-eb3cee0bc68ee576ed0eb429d22c6031f27def07.tar.xz
manaplus-eb3cee0bc68ee576ed0eb429d22c6031f27def07.zip
Add option to allow automatically attack next target. (disabled by default)
Diffstat (limited to 'src/localplayer.cpp')
-rw-r--r--src/localplayer.cpp16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/localplayer.cpp b/src/localplayer.cpp
index ade74edc1..68a2e295c 100644
--- a/src/localplayer.cpp
+++ b/src/localplayer.cpp
@@ -173,6 +173,7 @@ LocalPlayer::LocalPlayer(int id, int subtype):
mDrawPath = config.getBoolValue("drawPath");
mServerAttack = config.getBoolValue("serverAttack");
mAttackMoving = config.getBoolValue("attackMoving");
+ mAttackNext = config.getBoolValue("attackNext");
mShowJobExp = config.getBoolValue("showJobExp");
mEnableAdvert = config.getBoolValue("enableAdvert");
mTradebot = config.getBoolValue("tradebot");
@@ -194,6 +195,7 @@ LocalPlayer::LocalPlayer(int id, int subtype):
config.addListener("drawPath", this);
config.addListener("serverAttack", this);
config.addListener("attackMoving", this);
+ config.addListener("attackNext", this);
config.addListener("showJobExp", this);
config.addListener("enableAdvert", this);
config.addListener("tradebot", this);
@@ -339,7 +341,7 @@ void LocalPlayer::logic()
if (!mTarget->isAlive() && (!mTargetDeadPlayers
|| mTarget->getType() != Being::PLAYER))
{
- stopAttack();
+ stopAttack(true);
}
if (mKeepAttacking && mTarget)
@@ -995,14 +997,9 @@ void LocalPlayer::setTarget(Being *target)
return;
if (target || mAction == ATTACK)
- {
mTargetTime = tick_time;
- }
else
- {
- mKeepAttacking = false;
mTargetTime = -1;
- }
Being *oldTarget = nullptr;
if (mTarget)
@@ -1389,7 +1386,7 @@ void LocalPlayer::attack(Being *target, bool keep, bool dontChangeEquipment)
stopAttack();
}
-void LocalPlayer::stopAttack()
+void LocalPlayer::stopAttack(bool keepAttack)
{
if (!Client::limitPackets(PACKET_STOPATTACK))
return;
@@ -1398,6 +1395,8 @@ void LocalPlayer::stopAttack()
Net::getPlayerHandler()->stopAttack();
untarget();
+ if (!keepAttack || !mAttackNext)
+ mKeepAttacking = false;
}
void LocalPlayer::untarget()
@@ -1408,7 +1407,6 @@ void LocalPlayer::untarget()
if (mTarget)
setTarget(nullptr);
- mKeepAttacking = false;
mLastTarget = -1;
}
@@ -1648,6 +1646,8 @@ void LocalPlayer::optionChanged(const std::string &value)
mServerAttack = config.getBoolValue("serverAttack");
else if (value == "attackMoving")
mAttackMoving = config.getBoolValue("attackMoving");
+ else if (value == "attackNext")
+ mAttackNext = config.getBoolValue("attackNext");
else if (value == "showJobExp")
mShowJobExp = config.getBoolValue("showJobExp");
else if (value == "enableAdvert")