From 4453242bee835dd20a4aa2aeb65e8822feee9cd1 Mon Sep 17 00:00:00 2001 From: BeniS Date: Sun, 8 Jul 2012 02:09:50 +1200 Subject: [PATCH 1/2] Adjusted chase modes to work correctly, added new option for auto chase override. Fixed NPC speak messages to appear in the correct position. --- .gitignore | 1 + modules/client_options/general.otui | 4 ++++ modules/client_options/options.lua | 9 +++++++-- modules/game_combatcontrols/combatcontrols.lua | 14 ++++++++++++-- modules/game_console/console.lua | 4 +++- src/otclient/core/game.cpp | 11 +++++++---- 6 files changed, 34 insertions(+), 9 deletions(-) diff --git a/.gitignore b/.gitignore index 7faada40..5149639a 100644 --- a/.gitignore +++ b/.gitignore @@ -25,3 +25,4 @@ CMakeLists.txt.user* /modules/myconfig.otml /modules/myotclientrc.lua !.gitignore +otclient.map diff --git a/modules/client_options/general.otui b/modules/client_options/general.otui index f86aa426..1c47eeab 100644 --- a/modules/client_options/general.otui +++ b/modules/client_options/general.otui @@ -3,6 +3,10 @@ Panel id: classicControl !text: tr('Classic control') + OptionCheckBox + id: autoChaseOverride + !text: tr('Allow auto chase override') + OptionCheckBox id: showInfoMessagesInConsole !text: tr('Show info messages in console') diff --git a/modules/client_options/options.lua b/modules/client_options/options.lua index c3bbf526..6f83d475 100644 --- a/modules/client_options/options.lua +++ b/modules/client_options/options.lua @@ -5,6 +5,7 @@ local defaultOptions = { showfps = true, fullscreen = false, classicControl = false, + autoChaseOverride = true, showStatusMessagesInConsole = true, showEventMessagesInConsole = true, showInfoMessagesInConsole = true, @@ -144,7 +145,9 @@ function Options.setOption(key, value) value = 0 end - if graphicsPanel then graphicsPanel:getChildById('backgroundFrameRateLabel'):setText(tr('Game framerate limit: %s', text)) end + if graphicsPanel then + graphicsPanel:getChildById('backgroundFrameRateLabel'):setText(tr('Game framerate limit: %s', text)) + end g_app.setBackgroundPaneMaxFps(value) elseif key == 'foregroundFrameRate' then local text = value @@ -153,7 +156,9 @@ function Options.setOption(key, value) value = 0 end - if graphicsPanel then graphicsPanel:getChildById('foregroundFrameRateLabel'):setText(tr('Interface framerate limit: %s', text)) end + if graphicsPanel then + graphicsPanel:getChildById('foregroundFrameRateLabel'):setText(tr('Interface framerate limit: %s', text)) + end g_app.setForegroundPaneMaxFps(value) elseif key == 'painterEngine' then g_graphics.selectPainterEngine(value) diff --git a/modules/game_combatcontrols/combatcontrols.lua b/modules/game_combatcontrols/combatcontrols.lua index f9ca1ffa..1f2e9f4e 100644 --- a/modules/game_combatcontrols/combatcontrols.lua +++ b/modules/game_combatcontrols/combatcontrols.lua @@ -64,7 +64,8 @@ function CombatControls.init() onGameEnd = CombatControls.offline, onFightModeChange = CombatControls.update, onChaseModeChange = CombatControls.update, - onSafeFightChange = CombatControls.update + onSafeFightChange = CombatControls.update, + onWalk = CombatControls.check }) if g_game.isOnline() then @@ -97,7 +98,8 @@ function CombatControls.terminate() onGameEnd = CombatControls.offline, onFightModeChange = CombatControls.update, onChaseModeChange = CombatControls.update, - onSafeFightChange = CombatControls.update + onSafeFightChange = CombatControls.update, + onWalk = CombatControls.check }) CombatControls = nil @@ -120,6 +122,14 @@ function CombatControls.update() safeFightButton:setChecked(not safeFight) end +function CombatControls.check() + if(Options.getOption('autoChaseOverride')) then + if(g_game.isAttacking() and g_game.getChaseMode() == ChaseOpponent) then + g_game.setChaseMode(DontChase) + end + end +end + function CombatControls.online() combatControlsWindow:setVisible(combatControlsButton:isOn()) CombatControls.update() diff --git a/modules/game_console/console.lua b/modules/game_console/console.lua index 579491cb..bc6e0c86 100644 --- a/modules/game_console/console.lua +++ b/modules/game_console/console.lua @@ -94,7 +94,9 @@ local function onCreatureSpeak(name, level, speaktype, message, channelId, creat if speaktype.private then Console.addPrivateText(composedMessage, speaktype, name, false, name) if Options.getOption('showPrivateMessagesOnScreen') then - TextMessage.displayPrivate(name .. ':\n' .. message) + if(speakType.speakType ~= privateNpcToPlayer) then + TextMessage.displayPrivate(name .. ':\n' .. message) + end end else local channel = tr('Default') diff --git a/src/otclient/core/game.cpp b/src/otclient/core/game.cpp index 5a1c511a..3b4978c0 100644 --- a/src/otclient/core/game.cpp +++ b/src/otclient/core/game.cpp @@ -161,7 +161,9 @@ void Game::processTextMessage(const std::string& type, const std::string& messag void Game::processCreatureSpeak(const std::string& name, int level, Otc::SpeakType type, const std::string& message, int channelId, const Position& creaturePos) { - if(creaturePos.isValid() && (type == Otc::SpeakSay || type == Otc::SpeakWhisper || type == Otc::SpeakYell || type == Otc::SpeakMonsterSay || type == Otc::SpeakMonsterYell)) { + if(creaturePos.isValid() && (type == Otc::SpeakSay || type == Otc::SpeakWhisper || type == Otc::SpeakYell + || type == Otc::SpeakMonsterSay || type == Otc::SpeakMonsterYell || type == Otc::SpeakPrivateNpcToPlayer)) + { StaticTextPtr staticText = StaticTextPtr(new StaticText); staticText->addMessage(name, type, message); g_map.addThing(staticText, creaturePos); @@ -456,6 +458,8 @@ void Game::walk(Otc::Direction direction) m_localPlayer->lockWalk(); forceWalk(direction); + + g_lua.callGlobalField("g_game", "onWalk", direction); } void Game::autoWalk(const std::vector& dirs) @@ -487,6 +491,8 @@ void Game::autoWalk(const std::vector& dirs) nextDirs.erase(nextDirs.begin()); if(nextDirs.size() > 0) m_protocolGame->sendAutoWalk(nextDirs); + + g_lua.callGlobalField("g_game", "onAutoWalk", direction); } void Game::forceWalk(Otc::Direction direction) @@ -494,9 +500,6 @@ void Game::forceWalk(Otc::Direction direction) if(!canPerformGameAction()) return; - // always cancel chasing attacks - setChaseMode(Otc::DontChase); - switch(direction) { case Otc::North: m_protocolGame->sendWalkNorth(); From 69cc53d7f3ae37726021dde2f3976f4cc505ed40 Mon Sep 17 00:00:00 2001 From: BeniS Date: Sun, 8 Jul 2012 02:44:53 +1200 Subject: [PATCH 2/2] Minor fix from last commit. --- modules/client_options/options.lua | 20 ++++++++++---------- modules/game_console/console.lua | 2 +- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/modules/client_options/options.lua b/modules/client_options/options.lua index 6f83d475..ebbd115a 100644 --- a/modules/client_options/options.lua +++ b/modules/client_options/options.lua @@ -150,16 +150,16 @@ function Options.setOption(key, value) end g_app.setBackgroundPaneMaxFps(value) elseif key == 'foregroundFrameRate' then - local text = value - if value <= 0 or value >= 61 then - text = 'max' - value = 0 - end - - if graphicsPanel then - graphicsPanel:getChildById('foregroundFrameRateLabel'):setText(tr('Interface framerate limit: %s', text)) - end - g_app.setForegroundPaneMaxFps(value) + local text = value + if value <= 0 or value >= 61 then + text = 'max' + value = 0 + end + + if graphicsPanel then + graphicsPanel:getChildById('foregroundFrameRateLabel'):setText(tr('Interface framerate limit: %s', text)) + end + g_app.setForegroundPaneMaxFps(value) elseif key == 'painterEngine' then g_graphics.selectPainterEngine(value) end diff --git a/modules/game_console/console.lua b/modules/game_console/console.lua index bc6e0c86..f2cb0785 100644 --- a/modules/game_console/console.lua +++ b/modules/game_console/console.lua @@ -94,7 +94,7 @@ local function onCreatureSpeak(name, level, speaktype, message, channelId, creat if speaktype.private then Console.addPrivateText(composedMessage, speaktype, name, false, name) if Options.getOption('showPrivateMessagesOnScreen') then - if(speakType.speakType ~= privateNpcToPlayer) then + if(speaktype.speakType ~= SpeakPrivateNpcToPlayer) then TextMessage.displayPrivate(name .. ':\n' .. message) end end