Index: game/modules/tome/dialogs/UseTalents.lua =================================================================== --- game/modules/tome/dialogs/UseTalents.lua (revision 2987) +++ game/modules/tome/dialogs/UseTalents.lua (working copy) @@ -134,6 +134,7 @@ local list = { {name="Unbind", what="unbind"}, {name="Bind to left mouse click (on a target)", what="left"}, + {name="Bind to middle mouse click (on a target)", what="middle"}, } for i = 1, 36 do list[#list+1] = {name="Hotkey "..i, what=i} end Dialog:listPopup("Bind talent: "..item.name, "How do you want to bind this talent?", list, 400, 500, function(b) @@ -144,11 +145,15 @@ end self.actor.hotkey[b.what] = {"talent", item.talent} self:simplePopup("Hotkey "..b.what.." assigned", self.actor:getTalentFromId(item.talent).name:capitalize().." assigned to hotkey "..b.what) + elseif b.what == "middle" then + self.actor.auto_shoot_midclick_talent = item.talent + self:simplePopup("Middle mouse click assigned", self.actor:getTalentFromId(item.talent).name:capitalize().." assigned to middle mouse click on an hostile target.") elseif b.what == "left" then self.actor.auto_shoot_talent = item.talent self:simplePopup("Left mouse click assigned", self.actor:getTalentFromId(item.talent).name:capitalize().." assigned to left mouse click on an hostile target.") elseif b.what == "unbind" then if self.actor.auto_shoot_talent == item.talent then self.actor.auto_shoot_talent = nil end + if self.actor.auto_shoot_midclick_talent == item.talent then self.actor.auto_shoot_midclick_talent = nil end for i = 1, 36 do if self.actor.hotkey[i] and self.actor.hotkey[i][1] == "talent" and self.actor.hotkey[i][2] == item.talent then self.actor.hotkey[i] = nil end end Index: game/modules/tome/class/Game.lua =================================================================== --- game/modules/tome/class/Game.lua (revision 2987) +++ game/modules/tome/class/Game.lua (working copy) @@ -1139,6 +1139,9 @@ -- Default left button action if button == "left" and not xrel and not yrel and event == "button" and self.zone and not self.zone.wilderness then if self:mouseLeftClick(mx, my) then return end end + -- Default middle button action + if button == "middle" and not xrel and not yrel and event == "button" and self.zone and not self.zone.wilderness then if self:mouseMiddleClick(mx, my) then return end end + -- Handle the mouse movement/scrolling self.player:mouseHandleDefault(self.key, self.key == self.normal_key, button, mx, my, xrel, yrel, event) end) @@ -1207,6 +1210,24 @@ end end +--- Middle mouse click on the map +function _M:mouseMiddleClick(mx, my) + local tmx, tmy = self.level.map:getMouseTile(mx, my) + local p = self.player + local a = game.level.map(tmx, tmy, Map.ACTOR) + if not a then return end + if not p.auto_shoot_midclick_talent then return end + local t = p:getTalentFromId(p.auto_shoot_midclick_talent) + if not t then return end + + local target_dist = math.floor(core.fov.distance(p.x, p.y, a.x, a.y)) + + if p:enoughEnergy() and p:reactionToward(a) < 0 and not p:isTalentCoolingDown(t) and p:preUseTalent(t, true, true) and target_dist <= p:getTalentRange(t) and p:canProject({type="hit"}, a.x, a.y) then + p:useTalent(t.id, nil, nil, nil, a) + return true + end +end + --- Right mouse click on the map function _M:mouseRightClick(mx, my) local tmx, tmy = self.level.map:getMouseTile(mx, my)