diff options
author | Andrei Karas <akaras@inbox.ru> | 2015-09-21 01:44:50 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2015-09-21 01:44:50 +0300 |
commit | 52e799ac652c6edd48d250f814e259af44f92329 (patch) | |
tree | 655a6cc9adc5a1f7179857d9d31c979ed39a1596 /src/gui/windows/skilldialog.cpp | |
parent | c4a9748e841fd8620e7e9d230aad8964f424bb08 (diff) | |
download | manaplus-52e799ac652c6edd48d250f814e259af44f92329.tar.gz manaplus-52e799ac652c6edd48d250f814e259af44f92329.tar.bz2 manaplus-52e799ac652c6edd48d250f814e259af44f92329.tar.xz manaplus-52e799ac652c6edd48d250f814e259af44f92329.zip |
Add option for auto target skill to closest target.
Diffstat (limited to 'src/gui/windows/skilldialog.cpp')
-rw-r--r-- | src/gui/windows/skilldialog.cpp | 27 |
1 files changed, 22 insertions, 5 deletions
diff --git a/src/gui/windows/skilldialog.cpp b/src/gui/windows/skilldialog.cpp index 9c1cbc618..58a9292ae 100644 --- a/src/gui/windows/skilldialog.cpp +++ b/src/gui/windows/skilldialog.cpp @@ -159,7 +159,8 @@ void SkillDialog::action(const ActionEvent &event) if (tab) { const SkillInfo *const info = tab->getSelectedInfo(); - useSkill(info); + useSkill(info, + fromBool(config.getBoolValue("skillAutotarget"), AutoTarget)); } } else if (eventId == "close") @@ -538,7 +539,8 @@ void SkillDialog::widgetResized(const Event &event) mTabs->adjustSize(); } -void SkillDialog::useItem(const int itemId) const +void SkillDialog::useItem(const int itemId, + const AutoTarget autoTarget) const { const std::map<int, SkillInfo*>::const_iterator it = mSkills.find(itemId - SKILL_MIN_ID); @@ -546,7 +548,7 @@ void SkillDialog::useItem(const int itemId) const return; const SkillInfo *const info = (*it).second; - useSkill(info); + useSkill(info, autoTarget); } void SkillDialog::updateTabSelection() @@ -659,9 +661,10 @@ void SkillDialog::playCastingDstEffect(const int id, Being *const being) const paths.getIntValue("skillCastingDstEffectId")); } -void SkillDialog::useSkill(const SkillInfo *const info) +void SkillDialog::useSkill(const SkillInfo *const info, + const AutoTarget autoTarget) { - if (!info) + if (!info || !localPlayer) return; const SkillData *const data = info->data; if (data) @@ -675,6 +678,20 @@ void SkillDialog::useSkill(const SkillInfo *const info) switch (info->type) { case SkillType::Attack: + { + const Being *being = localPlayer->getTarget(); + if (!being && autoTarget == AutoTarget_true) + { + being = localPlayer->setNewTarget(ActorType::Monster, + AllowSort_true); + } + if (being) + { + skillHandler->useBeing(info->id, + info->level, being->getId()); + } + break; + } case SkillType::Support: { const Being *const being = localPlayer->getTarget(); |