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 | |
parent | c4a9748e841fd8620e7e9d230aad8964f424bb08 (diff) | |
download | plus-52e799ac652c6edd48d250f814e259af44f92329.tar.gz plus-52e799ac652c6edd48d250f814e259af44f92329.tar.bz2 plus-52e799ac652c6edd48d250f814e259af44f92329.tar.xz plus-52e799ac652c6edd48d250f814e259af44f92329.zip |
Add option for auto target skill to closest target.
Diffstat (limited to 'src/gui/windows')
-rw-r--r-- | src/gui/windows/skilldialog.cpp | 27 | ||||
-rw-r--r-- | src/gui/windows/skilldialog.h | 7 |
2 files changed, 27 insertions, 7 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(); diff --git a/src/gui/windows/skilldialog.h b/src/gui/windows/skilldialog.h index 29cc69165..8f085ee22 100644 --- a/src/gui/windows/skilldialog.h +++ b/src/gui/windows/skilldialog.h @@ -25,6 +25,7 @@ #include "gui/widgets/window.h" +#include "enums/simpletypes/autotarget.h" #include "enums/simpletypes/modifiable.h" #include "listeners/actionlistener.h" @@ -112,7 +113,8 @@ class SkillDialog final : public Window, void widgetResized(const Event &event) override final; - void useItem(const int itemId) const; + void useItem(const int itemId, + const AutoTarget autoTarget) const; void updateTabSelection(); @@ -132,7 +134,8 @@ class SkillDialog final : public Window, void removeSkill(const int id); - static void useSkill(const SkillInfo *const info); + static void useSkill(const SkillInfo *const info, + const AutoTarget autoTarget); SkillData *getSkillData(const int id) const; |