Improvement / Fix hotkeys
- Hotkeys now check items in inventory - Fixed USEONETARGET hotkey bug
This commit is contained in:
parent
5843b78e87
commit
e6977b1b43
|
@ -376,7 +376,7 @@ function doKeyCombo(keyCombo)
|
||||||
end
|
end
|
||||||
elseif hotKey.useType == HOTKEY_MANAGER_USE then
|
elseif hotKey.useType == HOTKEY_MANAGER_USE then
|
||||||
if g_game.getProtocolVersion() < 780 then
|
if g_game.getProtocolVersion() < 780 then
|
||||||
local item = g_game.findItemInContainers(hotKey.itemId, -1)
|
local item = g_game.findPlayerItem(hotKey.itemId, -1)
|
||||||
if item then
|
if item then
|
||||||
g_game.use(item)
|
g_game.use(item)
|
||||||
end
|
end
|
||||||
|
@ -385,7 +385,7 @@ function doKeyCombo(keyCombo)
|
||||||
end
|
end
|
||||||
elseif hotKey.useType == HOTKEY_MANAGER_USEONSELF then
|
elseif hotKey.useType == HOTKEY_MANAGER_USEONSELF then
|
||||||
if g_game.getProtocolVersion() < 780 then
|
if g_game.getProtocolVersion() < 780 then
|
||||||
local item = g_game.findItemInContainers(hotKey.itemId, -1)
|
local item = g_game.findPlayerItem(hotKey.itemId, -1)
|
||||||
if item then
|
if item then
|
||||||
g_game.useWith(item, g_game.getLocalPlayer())
|
g_game.useWith(item, g_game.getLocalPlayer())
|
||||||
end
|
end
|
||||||
|
@ -395,8 +395,9 @@ function doKeyCombo(keyCombo)
|
||||||
elseif hotKey.useType == HOTKEY_MANAGER_USEONTARGET then
|
elseif hotKey.useType == HOTKEY_MANAGER_USEONTARGET then
|
||||||
local attackingCreature = g_game.getAttackingCreature()
|
local attackingCreature = g_game.getAttackingCreature()
|
||||||
if not attackingCreature then return end
|
if not attackingCreature then return end
|
||||||
|
if not attackingCreature:getTile() then return end
|
||||||
if g_game.getProtocolVersion() < 780 then
|
if g_game.getProtocolVersion() < 780 then
|
||||||
local item = g_game.findItemInContainers(hotKey.itemId, -1)
|
local item = g_game.findPlayerItem(hotKey.itemId, -1)
|
||||||
if item then
|
if item then
|
||||||
g_game.useWith(item, attackingCreature)
|
g_game.useWith(item, attackingCreature)
|
||||||
end
|
end
|
||||||
|
@ -406,7 +407,7 @@ function doKeyCombo(keyCombo)
|
||||||
elseif hotKey.useType == HOTKEY_MANAGER_USEWITH then
|
elseif hotKey.useType == HOTKEY_MANAGER_USEWITH then
|
||||||
local item = Item.create(hotKey.itemId)
|
local item = Item.create(hotKey.itemId)
|
||||||
if g_game.getProtocolVersion() < 780 then
|
if g_game.getProtocolVersion() < 780 then
|
||||||
local tmpItem = g_game.findItemInContainers(hotKey.itemId, -1)
|
local tmpItem = g_game.findPlayerItem(hotKey.itemId, -1)
|
||||||
if not tmpItem then return true end
|
if not tmpItem then return true end
|
||||||
item = tmpItem
|
item = tmpItem
|
||||||
end
|
end
|
||||||
|
|
|
@ -4,6 +4,20 @@ function g_game.getRsa()
|
||||||
return currentRsa
|
return currentRsa
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function g_game.findPlayerItem(itemId, subType)
|
||||||
|
local localPlayer = g_game.getLocalPlayer()
|
||||||
|
if localPlayer then
|
||||||
|
for slot = InventorySlotFirst, InventorySlotLast do
|
||||||
|
local item = localPlayer:getInventoryItem(slot)
|
||||||
|
if item and item:getId() == itemId and (subType == -1 or item:getSubType() == subType) then
|
||||||
|
return item
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return g_game.findItemInContainers(itemId, subType)
|
||||||
|
end
|
||||||
|
|
||||||
function g_game.chooseRsa(host)
|
function g_game.chooseRsa(host)
|
||||||
if currentRsa ~= CIPSOFT_RSA and currentRsa ~= OTSERV_RSA then return end
|
if currentRsa ~= CIPSOFT_RSA and currentRsa ~= OTSERV_RSA then return end
|
||||||
if host:ends('.tibia.com') or host:ends('.cipsoft.com') then
|
if host:ends('.tibia.com') or host:ends('.cipsoft.com') then
|
||||||
|
|
Loading…
Reference in New Issue