Code: Select all
local keybindings = {
attack = {
{'y','u'},
{'i','o'},
{'h','j'},
{'k','l'},
},
}
for cind = 1,4 do
local champ = p:getChampion(cind)
if champ:getEnabled() then
for slot = 1,2 do
if champ:isReadyToAttack(slot) then
if context.keyDown(keybindings["attack"][cind][slot]) then
local item = champ:getItem(slot)
if not item then
champ:attack(slot,false)
else
local actionname = item:getPrimaryAction()
local action = nil
if actionname then action = item.go:getComponent(actionname) end
if action then champ:attack(slot,false) end
end
end
end
end
end
end
Obviously this is not yet suitable for actual use - at the very least it needs rebinding and weapon swapping, and could also be a lot more efficient. I'm posting because there are a few issues the community needs to figure out if we're going to put keyboard controls in mods:
- how to handle special attacks. Triggering the secondary action is no problem at all, just use Champion:attack(slot, true) instead of Champion:attack(slot, false) and manually address the energy cost, requirements, etc. The problem is the build-up time; you can certainly require holding down the key to charge the attack, and block other attacks during it, but recreating the visual effect seems difficult.
- how to handle spellcasting - it's easy to draw your own rune panel and have players select runes on that with keys, but I don't think you can do it with the built-in rune panel, *and* I don't know of a way to detect whether the rune panel is open. You could activate an "isCastingSpell" flag every time a rune panel item is used, but I don't know of a way to do that for bare hands, and how would you detect closing the rune panel?
- this is more an unavoidable annoyance than a problem to be solved, but it seems there are a lot of keys that you'd expect to be able to use, but seemingly can't, such as ';'.
Also, additional keyboard controls make it way more obvious how clunky the "input queue" style of party movement is (you can't hold down keys), so be warned. Unfortunately, there's no PartyComponent:move() or PartyComponent:turn() that could be used to fix this.