Changes to autowalk position on different floors, move its functions to game interface
This commit is contained in:
parent
2c6b83b476
commit
0b98dca50f
|
@ -304,14 +304,9 @@ function GameInterface.createThingMenu(menuPosition, lookThing, useThing, creatu
|
|||
menu:display(menuPosition)
|
||||
end
|
||||
|
||||
function GameInterface.processMouseAction(menuPosition, mouseButton, autoWalk, lookThing, useThing, creatureThing, multiUseThing)
|
||||
function GameInterface.processMouseAction(menuPosition, mouseButton, autoWalkPos, lookThing, useThing, creatureThing, multiUseThing)
|
||||
local keyboardModifiers = g_keyboard.getModifiers()
|
||||
|
||||
if autoWalk and keyboardModifiers == KeyboardNoModifier and mouseButton == MouseLeftButton then
|
||||
-- todo auto walk
|
||||
return true
|
||||
end
|
||||
|
||||
if not Options.getOption('classicControl') then
|
||||
if keyboardModifiers == KeyboardNoModifier and mouseButton == MouseRightButton then
|
||||
GameInterface.createThingMenu(menuPosition, lookThing, useThing, creatureThing)
|
||||
|
@ -341,7 +336,7 @@ function GameInterface.processMouseAction(menuPosition, mouseButton, autoWalk, l
|
|||
return true
|
||||
end
|
||||
else
|
||||
if multiUseThing and keyboardModifiers == KeyboardNoModifier and mouseButton == MouseRightButton then
|
||||
if multiUseThing and keyboardModifiers == KeyboardNoModifier and mouseButton == MouseRightButton and not g_mouse.isPressed(MouseLeftButton) then
|
||||
if multiUseThing:asCreature() then
|
||||
g_game.attack(multiUseThing:asCreature())
|
||||
return true
|
||||
|
@ -363,6 +358,9 @@ function GameInterface.processMouseAction(menuPosition, mouseButton, autoWalk, l
|
|||
elseif lookThing and keyboardModifiers == KeyboardShiftModifier and (mouseButton == MouseLeftButton or mouseButton == MouseRightButton) then
|
||||
g_game.look(lookThing)
|
||||
return true
|
||||
elseif lookThing and ((g_mouse.isPressed(MouseLeftButton) and mouseButton == MouseRightButton) or (g_mouse.isPressed(MouseRightButton) and mouseButton == MouseLeftButton)) then
|
||||
g_game.look(lookThing)
|
||||
return true
|
||||
elseif useThing and keyboardModifiers == KeyboardCtrlModifier and (mouseButton == MouseLeftButton or mouseButton == MouseRightButton) then
|
||||
GameInterface.createThingMenu(menuPosition, lookThing, useThing, creatureThing)
|
||||
return true
|
||||
|
@ -372,6 +370,16 @@ function GameInterface.processMouseAction(menuPosition, mouseButton, autoWalk, l
|
|||
end
|
||||
end
|
||||
|
||||
if autoWalkPos and keyboardModifiers == KeyboardNoModifier and mouseButton == MouseLeftButton then
|
||||
local dirs = g_map.findPath(g_game.getLocalPlayer():getPosition(), autoWalkPos, 255)
|
||||
if #dirs == 0 then
|
||||
TextMessage.displayStatus(tr('There is no way.'))
|
||||
return true
|
||||
end
|
||||
g_game.autoWalk(dirs)
|
||||
return true
|
||||
end
|
||||
|
||||
return false
|
||||
end
|
||||
|
||||
|
|
|
@ -47,6 +47,10 @@ function UIGameMap:onDrop(widget, mousePos)
|
|||
return true
|
||||
end
|
||||
|
||||
function UIGameMap:onMousePress()
|
||||
self.cancelNextRelease = false
|
||||
end
|
||||
|
||||
function UIGameMap:onMouseRelease(mousePosition, mouseButton)
|
||||
if self.cancelNextRelease then
|
||||
self.cancelNextRelease = false
|
||||
|
@ -56,23 +60,24 @@ function UIGameMap:onMouseRelease(mousePosition, mouseButton)
|
|||
local tile = self:getTile(mousePosition)
|
||||
if tile == nil then return false end
|
||||
|
||||
if Options.getOption('classicControl') and
|
||||
((g_mouse.isPressed(MouseLeftButton) and mouseButton == MouseRightButton) or
|
||||
(g_mouse.isPressed(MouseRightButton) and mouseButton == MouseLeftButton)) then
|
||||
local tile = self:getTile(mousePosition)
|
||||
g_game.look(tile:getTopLookThing())
|
||||
local localPlayerPos = g_game.getLocalPlayer():getPosition()
|
||||
local autoWalkPos = tile:getPosition()
|
||||
if autoWalkPos.z ~= localPlayerPos.z then
|
||||
local dz = autoWalkPos.z - localPlayerPos.z
|
||||
autoWalkPos.x = autoWalkPos.x + dz
|
||||
autoWalkPos.y = autoWalkPos.y + dz
|
||||
autoWalkPos.z = localPlayerPos.z
|
||||
end
|
||||
|
||||
local lookThing = tile:getTopLookThing()
|
||||
local useThing = tile:getTopUseThing()
|
||||
local creatureThing = tile:getTopCreature()
|
||||
local multiUseThing = tile:getTopMultiUseThing()
|
||||
|
||||
local ret = GameInterface.processMouseAction(mousePosition, mouseButton, autoWalkPos, lookThing, useThing, creatureThing, multiUseThing)
|
||||
if ret then
|
||||
self.cancelNextRelease = true
|
||||
return true
|
||||
elseif GameInterface.processMouseAction(mousePosition, mouseButton, nil, tile:getTopLookThing(), tile:getTopUseThing(), tile:getTopCreature(), tile:getTopMultiUseThing()) then
|
||||
return true
|
||||
elseif mouseButton == MouseLeftButton and self:isPressed() then
|
||||
local dirs = g_map.findPath(g_game.getLocalPlayer():getPosition(), tile:getPosition(), 255)
|
||||
if #dirs == 0 then
|
||||
TextMessage.displayStatus(tr('There is no way.'))
|
||||
return true
|
||||
end
|
||||
g_game.autoWalk(dirs)
|
||||
return true
|
||||
end
|
||||
return false
|
||||
|
||||
return ret
|
||||
end
|
||||
|
|
|
@ -256,6 +256,7 @@ void OTClient::registerLuaFunctions()
|
|||
g_lua.bindClassMemberFunction<Thing>("getParentContainer", &Thing::getParentContainer);
|
||||
|
||||
g_lua.registerClass<Creature, Thing>();
|
||||
g_lua.bindClassStaticFunction<Creature>("create", []{ return CreaturePtr(new Creature); });
|
||||
g_lua.bindClassMemberFunction<Creature>("getId", &Creature::getId);
|
||||
g_lua.bindClassMemberFunction<Creature>("getName", &Creature::getName);
|
||||
g_lua.bindClassMemberFunction<Creature>("getHealthPercent", &Creature::getHealthPercent);
|
||||
|
@ -264,6 +265,7 @@ void OTClient::registerLuaFunctions()
|
|||
g_lua.bindClassMemberFunction<Creature>("getEmblem", &Creature::getEmblem);
|
||||
g_lua.bindClassMemberFunction<Creature>("setOutfit", &Creature::setOutfit);
|
||||
g_lua.bindClassMemberFunction<Creature>("getOutfit", &Creature::getOutfit);
|
||||
g_lua.bindClassMemberFunction<Creature>("setDirection", &Creature::setDirection);
|
||||
g_lua.bindClassMemberFunction<Creature>("setSkullTexture", &Creature::setSkullTexture);
|
||||
g_lua.bindClassMemberFunction<Creature>("setShieldTexture", &Creature::setShieldTexture);
|
||||
g_lua.bindClassMemberFunction<Creature>("setEmblemTexture", &Creature::setEmblemTexture);
|
||||
|
|
Loading…
Reference in New Issue