2012-01-03 21:41:00 +01:00
|
|
|
|
2012-01-13 01:31:39 +01:00
|
|
|
function Thing:isInsideContainer()
|
2012-01-30 01:00:12 +01:00
|
|
|
local pos = self:getPosition()
|
2012-01-13 01:31:39 +01:00
|
|
|
return (pos and pos.x == 65535 and pos.y >= 64)
|
|
|
|
end
|
|
|
|
|
|
|
|
function Thing:getContainerId()
|
2012-01-30 01:00:12 +01:00
|
|
|
local pos = self:getPosition()
|
2012-01-13 01:31:39 +01:00
|
|
|
if not pos then return 0 end
|
|
|
|
return pos.y - 64
|
|
|
|
end
|
|
|
|
|
2012-01-03 21:41:00 +01:00
|
|
|
-- public functions
|
2012-02-08 22:23:15 +01:00
|
|
|
function g_game.processMouseAction(menuPosition, mouseButton, autoWalk, lookThing, useThing, creatureThing, multiUseThing)
|
2012-01-09 21:54:37 +01:00
|
|
|
local keyboardModifiers = g_window.getKeyboardModifiers()
|
2012-01-12 02:21:59 +01:00
|
|
|
|
2012-01-24 19:39:16 +01:00
|
|
|
if autoWalk and keyboardModifiers == KeyboardNoModifier and mouseButton == MouseLeftButton then
|
2012-01-09 21:54:37 +01:00
|
|
|
-- todo auto walk
|
|
|
|
return true
|
|
|
|
end
|
2012-01-12 02:21:59 +01:00
|
|
|
|
2012-01-09 21:54:37 +01:00
|
|
|
if not Options.classicControl then
|
2012-01-24 19:39:16 +01:00
|
|
|
if keyboardModifiers == KeyboardNoModifier and mouseButton == MouseRightButton then
|
2012-02-08 22:23:15 +01:00
|
|
|
g_game.createThingMenu(menuPosition, lookThing, useThing, creatureThing)
|
2012-01-09 21:54:37 +01:00
|
|
|
return true
|
|
|
|
elseif lookThing and keyboardModifiers == KeyboardShiftModifier and (mouseButton == MouseLeftButton or mouseButton == MouseRightButton) then
|
2012-02-08 22:23:15 +01:00
|
|
|
g_game.look(lookThing)
|
2012-01-09 21:54:37 +01:00
|
|
|
return true
|
|
|
|
elseif useThing and keyboardModifiers == KeyboardCtrlModifier and (mouseButton == MouseLeftButton or mouseButton == MouseRightButton) then
|
|
|
|
if useThing:isContainer() then
|
2012-01-13 01:31:39 +01:00
|
|
|
if useThing:isInsideContainer() then
|
2012-02-08 22:23:15 +01:00
|
|
|
g_game.open(useThing, useThing:getContainerId())
|
2012-01-24 19:39:16 +01:00
|
|
|
return true
|
2012-01-13 01:31:39 +01:00
|
|
|
else
|
2012-02-08 22:23:15 +01:00
|
|
|
g_game.open(useThing, Containers.getFreeContainerId())
|
2012-01-24 19:39:16 +01:00
|
|
|
return true
|
2012-01-13 01:31:39 +01:00
|
|
|
end
|
2012-01-09 21:54:37 +01:00
|
|
|
elseif useThing:isMultiUse() then
|
2012-02-08 22:23:15 +01:00
|
|
|
g_game.startUseWith(useThing)
|
2012-01-24 19:39:16 +01:00
|
|
|
return true
|
2012-01-09 21:54:37 +01:00
|
|
|
else
|
2012-02-08 22:23:15 +01:00
|
|
|
g_game.use(useThing)
|
2012-01-24 19:39:16 +01:00
|
|
|
return true
|
2012-01-09 21:54:37 +01:00
|
|
|
end
|
|
|
|
return true
|
|
|
|
elseif creatureThing and keyboardModifiers == KeyboardAltModifier and (mouseButton == MouseLeftButton or mouseButton == MouseRightButton) then
|
2012-02-08 22:23:15 +01:00
|
|
|
g_game.attack(creatureThing)
|
2012-01-09 21:54:37 +01:00
|
|
|
return true
|
|
|
|
end
|
|
|
|
else
|
2012-01-24 19:39:16 +01:00
|
|
|
if multiUseThing and keyboardModifiers == KeyboardNoModifier and mouseButton == MouseRightButton then
|
2012-01-09 21:54:37 +01:00
|
|
|
if multiUseThing:asCreature() then
|
2012-02-08 22:23:15 +01:00
|
|
|
g_game.attack(multiUseThing:asCreature())
|
2012-01-24 19:39:16 +01:00
|
|
|
return true
|
2012-01-09 21:54:37 +01:00
|
|
|
elseif multiUseThing:isContainer() then
|
2012-01-13 01:31:39 +01:00
|
|
|
if multiUseThing:isInsideContainer() then
|
2012-02-08 22:23:15 +01:00
|
|
|
g_game.open(multiUseThing, multiUseThing:getContainerId())
|
2012-01-24 19:39:16 +01:00
|
|
|
return true
|
2012-01-13 01:31:39 +01:00
|
|
|
else
|
2012-02-08 22:23:15 +01:00
|
|
|
g_game.open(multiUseThing, Containers.getFreeContainerId())
|
2012-01-24 19:39:16 +01:00
|
|
|
return true
|
2012-01-13 01:31:39 +01:00
|
|
|
end
|
2012-01-09 21:54:37 +01:00
|
|
|
elseif multiUseThing:isMultiUse() then
|
2012-02-08 22:23:15 +01:00
|
|
|
g_game.startUseWith(multiUseThing)
|
2012-01-24 19:39:16 +01:00
|
|
|
return true
|
2012-01-09 21:54:37 +01:00
|
|
|
else
|
2012-02-08 22:23:15 +01:00
|
|
|
g_game.use(multiUseThing)
|
2012-01-09 21:54:37 +01:00
|
|
|
end
|
|
|
|
return true
|
|
|
|
elseif lookThing and keyboardModifiers == KeyboardShiftModifier and (mouseButton == MouseLeftButton or mouseButton == MouseRightButton) then
|
2012-02-08 22:23:15 +01:00
|
|
|
g_game.look(lookThing)
|
2012-01-09 21:54:37 +01:00
|
|
|
return true
|
|
|
|
elseif useThing and keyboardModifiers == KeyboardCtrlModifier and (mouseButton == MouseLeftButton or mouseButton == MouseRightButton) then
|
2012-02-08 22:23:15 +01:00
|
|
|
g_game.createThingMenu(menuPosition, lookThing, useThing, creatureThing)
|
2012-01-09 21:54:37 +01:00
|
|
|
return true
|
|
|
|
elseif creatureThing and keyboardModifiers == KeyboardAltModifier and (mouseButton == MouseLeftButton or mouseButton == MouseRightButton) then
|
2012-02-08 22:23:15 +01:00
|
|
|
g_game.attack(creatureThing)
|
2012-01-09 21:54:37 +01:00
|
|
|
return true
|
|
|
|
end
|
|
|
|
end
|
2012-01-12 02:21:59 +01:00
|
|
|
|
2012-01-09 21:54:37 +01:00
|
|
|
return false
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2012-02-08 22:23:15 +01:00
|
|
|
function g_game.createThingMenu(menuPosition, lookThing, useThing, creatureThing)
|
2012-01-03 21:41:00 +01:00
|
|
|
local menu = createWidget('PopupMenu')
|
2012-01-12 02:21:59 +01:00
|
|
|
|
2012-01-04 14:02:35 +01:00
|
|
|
if lookThing then
|
2012-02-08 22:23:15 +01:00
|
|
|
menu:addOption('Look', function() g_game.look(lookThing) end)
|
2012-01-04 14:02:35 +01:00
|
|
|
end
|
2012-01-03 21:41:00 +01:00
|
|
|
|
2012-01-04 14:02:35 +01:00
|
|
|
if useThing then
|
|
|
|
if useThing:isContainer() then
|
2012-01-13 01:31:39 +01:00
|
|
|
if useThing:isInsideContainer() then
|
2012-02-08 22:23:15 +01:00
|
|
|
menu:addOption('Open', function() g_game.open(useThing, useThing:getContainerId()) end)
|
|
|
|
menu:addOption('Open in new window', function() g_game.open(useThing, Containers.getFreeContainerId()) end)
|
2012-01-13 01:31:39 +01:00
|
|
|
else
|
2012-02-08 22:23:15 +01:00
|
|
|
menu:addOption('Open', function() g_game.open(useThing, Containers.getFreeContainerId()) end)
|
2012-01-13 01:31:39 +01:00
|
|
|
end
|
2012-01-03 23:27:31 +01:00
|
|
|
else
|
2012-01-04 14:02:35 +01:00
|
|
|
if useThing:isMultiUse() then
|
2012-02-08 22:23:15 +01:00
|
|
|
menu:addOption('Use with ...', function() g_game.startUseWith(useThing) end)
|
2012-01-03 23:27:31 +01:00
|
|
|
else
|
2012-02-08 22:23:15 +01:00
|
|
|
menu:addOption('Use', function() g_game.use(useThing) end)
|
2012-01-03 23:27:31 +01:00
|
|
|
end
|
|
|
|
end
|
2012-01-12 02:21:59 +01:00
|
|
|
|
2012-01-04 14:02:35 +01:00
|
|
|
if useThing:isRotateable() then
|
2012-02-08 22:23:15 +01:00
|
|
|
menu:addOption('Rotate', function() g_game.rotate(useThing) end)
|
2012-01-03 23:27:31 +01:00
|
|
|
end
|
2012-01-12 02:21:59 +01:00
|
|
|
|
2012-01-09 01:43:36 +01:00
|
|
|
end
|
2012-01-12 02:21:59 +01:00
|
|
|
|
2012-01-09 01:43:36 +01:00
|
|
|
if lookThing and not lookThing:asCreature() and not lookThing:isNotMoveable() and lookThing:isPickupable() then
|
|
|
|
menu:addSeparator()
|
|
|
|
menu:addOption('Trade with ...', function() print('trade with') end)
|
2012-01-04 14:02:35 +01:00
|
|
|
end
|
2012-01-12 02:21:59 +01:00
|
|
|
|
2012-01-09 01:43:36 +01:00
|
|
|
-- check for move up
|
2012-01-12 02:21:59 +01:00
|
|
|
|
2012-01-04 14:02:35 +01:00
|
|
|
if creatureThing then
|
2012-01-03 23:27:31 +01:00
|
|
|
menu:addSeparator()
|
2012-01-12 02:21:59 +01:00
|
|
|
|
2012-01-04 14:02:35 +01:00
|
|
|
if creatureThing:asLocalPlayer() then
|
2012-02-08 22:23:15 +01:00
|
|
|
menu:addOption('Set Outfit', function() g_game.requestOutfit() end)
|
2012-01-12 02:21:59 +01:00
|
|
|
|
2012-01-11 00:38:32 +01:00
|
|
|
if creatureThing:asPlayer():isPartyMember() --[[and not fighting]] then
|
|
|
|
if creatureThing:asPlayer():isPartyLeader() then
|
|
|
|
if creatureThing:asPlayer():isPartySharedExperienceActive() then
|
2012-02-08 22:23:15 +01:00
|
|
|
menu:addOption('Disable Shared Experience', function() g_game.partyShareExperience(false) end)
|
2012-01-11 00:38:32 +01:00
|
|
|
else
|
2012-02-08 22:23:15 +01:00
|
|
|
menu:addOption('Enable Shared Experience', function() g_game.partyShareExperience(true) end)
|
2012-01-11 00:38:32 +01:00
|
|
|
end
|
|
|
|
end
|
2012-02-08 22:23:15 +01:00
|
|
|
menu:addOption('Leave Party', function() g_game.partyLeave() end)
|
2012-01-11 00:38:32 +01:00
|
|
|
end
|
2012-01-12 02:21:59 +01:00
|
|
|
|
2012-01-03 23:27:31 +01:00
|
|
|
else
|
2012-02-08 22:23:15 +01:00
|
|
|
local localPlayer = g_game.getLocalPlayer()
|
2012-01-07 23:24:29 +01:00
|
|
|
if localPlayer then
|
2012-02-08 22:23:15 +01:00
|
|
|
if g_game.getAttackingCreature() ~= creatureThing then
|
|
|
|
menu:addOption('Attack', function() g_game.attack(creatureThing) end)
|
2012-01-07 23:24:29 +01:00
|
|
|
else
|
2012-02-08 22:23:15 +01:00
|
|
|
menu:addOption('Stop Attack', function() g_game.cancelAttack() end)
|
2012-01-07 23:24:29 +01:00
|
|
|
end
|
2012-01-12 02:21:59 +01:00
|
|
|
|
2012-02-08 22:23:15 +01:00
|
|
|
if g_game.getFollowingCreature() ~= creatureThing then
|
|
|
|
menu:addOption('Follow', function() g_game.follow(creatureThing) end)
|
2012-01-07 23:24:29 +01:00
|
|
|
else
|
2012-02-08 22:23:15 +01:00
|
|
|
menu:addOption('Stop Follow', function() g_game.cancelFollow() end)
|
2012-01-07 23:24:29 +01:00
|
|
|
end
|
2012-01-12 02:21:59 +01:00
|
|
|
|
2012-01-11 00:38:32 +01:00
|
|
|
if creatureThing:asPlayer() then
|
|
|
|
menu:addSeparator()
|
|
|
|
menu:addOption('Message to ' .. creatureThing:getName(), function() print('message') end)
|
2012-02-08 22:23:15 +01:00
|
|
|
menu:addOption('Add to VIP list', function() g_game.addVip(creatureThing:getName()) end)
|
2012-01-11 00:38:32 +01:00
|
|
|
menu:addOption('Ignore ' .. creatureThing:getName(), function() print('ignore') end)
|
2012-01-12 02:21:59 +01:00
|
|
|
|
2012-01-11 00:38:32 +01:00
|
|
|
local localPlayerShield = localPlayer:asCreature():getShield()
|
|
|
|
local creatureShield = creatureThing:getShield()
|
2012-01-12 02:21:59 +01:00
|
|
|
|
2012-01-11 00:38:32 +01:00
|
|
|
if localPlayerShield == ShieldNone or localPlayerShield == ShieldWhiteBlue then
|
|
|
|
if creatureShield == ShieldWhiteYellow then
|
2012-02-08 22:23:15 +01:00
|
|
|
menu:addOption('Join ' .. creatureThing:getName() .. '\'s Party', function() g_game.partyJoin(creatureThing:getId()) end)
|
2012-01-11 00:38:32 +01:00
|
|
|
else
|
2012-02-08 22:23:15 +01:00
|
|
|
menu:addOption('Invite to Party', function() g_game.partyInvite(creatureThing:getId()) end)
|
2012-01-11 00:38:32 +01:00
|
|
|
end
|
|
|
|
elseif localPlayerShield == ShieldWhiteYellow then
|
|
|
|
if creatureShield == ShieldWhiteBlue then
|
2012-02-08 22:23:15 +01:00
|
|
|
menu:addOption('Revoke ' .. creatureThing:getName() .. '\'s Invitation', function() g_game.partyRevokeInvitation(creatureThing:getId()) end)
|
2012-01-11 00:38:32 +01:00
|
|
|
end
|
|
|
|
elseif localPlayerShield == ShieldYellow or localPlayerShield == ShieldYellowSharedExp or localPlayerShield == ShieldYellowNoSharedExpBlink or localPlayerShield == ShieldYellowNoSharedExp then
|
|
|
|
if creatureShield == ShieldWhiteBlue then
|
2012-02-08 22:23:15 +01:00
|
|
|
menu:addOption('Revoke ' .. creatureThing:getName() .. '\'s Invitation', function() g_game.partyRevokeInvitation(creatureThing:getId()) end)
|
2012-01-11 00:38:32 +01:00
|
|
|
elseif creatureShield == ShieldBlue or creatureShield == ShieldBlueSharedExp or creatureShield == ShieldBlueNoSharedExpBlink or creatureShield == ShieldBlueNoSharedExp then
|
2012-02-08 22:23:15 +01:00
|
|
|
menu:addOption('Pass Leadership to ' .. creatureThing:getName(), function() g_game.partyPassLeadership(creatureThing:getId()) end)
|
2012-01-11 00:38:32 +01:00
|
|
|
else
|
2012-02-08 22:23:15 +01:00
|
|
|
menu:addOption('Invite to Party', function() g_game.partyInvite(creatureThing:getId()) end)
|
2012-01-11 00:38:32 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2012-01-05 15:24:38 +01:00
|
|
|
end
|
2012-01-03 23:27:31 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
menu:addSeparator()
|
2012-01-05 13:48:10 +01:00
|
|
|
menu:addOption('Copy Name', function() g_window.setClipboardText(creatureThing:getName()) end)
|
2012-01-12 02:21:59 +01:00
|
|
|
|
2012-01-03 21:41:00 +01:00
|
|
|
end
|
2012-01-12 02:21:59 +01:00
|
|
|
|
2012-01-03 21:41:00 +01:00
|
|
|
menu:display(menuPosition)
|
|
|
|
end
|
2012-01-13 01:31:39 +01:00
|
|
|
|