Skip to content

Commit 3576cc6

Browse files
authored
fix: combat control (#1094)
1 parent 617d256 commit 3576cc6

File tree

3 files changed

+36
-3
lines changed

3 files changed

+36
-3
lines changed

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<h1><img src="https://github.com/mehah/otclient/blob/main/data/images/clienticon.png?raw=true" width="32" alt="logo"/> OTClient - Redemption</h1>
22

3-
[![Discord Shield](https://discordapp.com/api/guilds/888062548082061433/widget.png?style=shield)](https://discord.gg/HZN8yJJSyC)
3+
[![Discord Shield](https://discordapp.com/api/guilds/888062548082061433/widget.png?style=shield)](https://discord.gg/tUjTBZzMCy)
44
[![Build - Ubuntu](https://github.com/mehah/otclient/actions/workflows/build-ubuntu.yml/badge.svg)](https://github.com/mehah/otclient/actions/workflows/build-ubuntu.yml)
55
[![Build - Windows](https://github.com/mehah/otclient/actions/workflows/build-windows.yml/badge.svg)](https://github.com/mehah/otclient/actions/workflows/build-windows.yml)
66
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
@@ -517,7 +517,7 @@ xhost -
517517

518518
## <a name="need-help?">🩺 Need help?</a>
519519

520-
Try to ask questions in [discord](https://discord.gg/HZN8yJJSyC)
520+
Try to ask questions in [discord](https://discord.gg/tUjTBZzMCy)
521521

522522
## <a name="bugs">📑 Bugs?</a>
523523

modules/game_inventory/inventory.lua

+33
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,21 @@ function inventoryController:onInit()
278278
end
279279

280280
function inventoryController:onGameStart()
281+
local player = g_game.getLocalPlayer()
282+
if player then
283+
local char = g_game.getCharacterName()
284+
local lastCombatControls = g_settings.getNode('LastCombatControls')
285+
if not table.empty(lastCombatControls) then
286+
if lastCombatControls[char] then
287+
g_game.setFightMode(lastCombatControls[char].fightMode)
288+
g_game.setChaseMode(lastCombatControls[char].chaseMode)
289+
g_game.setSafeFight(lastCombatControls[char].safeFight)
290+
if lastCombatControls[char].pvpMode then
291+
g_game.setPVPMode(lastCombatControls[char].pvpMode)
292+
end
293+
end
294+
end
295+
end
281296
inventoryController:registerEvents(LocalPlayer, {
282297
onInventoryChange = inventoryEvent,
283298
onSoulChange = onSoulChange,
@@ -324,6 +339,24 @@ end
324339

325340
function inventoryController:onGameEnd()
326341
stopEvent()
342+
343+
local lastCombatControls = g_settings.getNode('LastCombatControls')
344+
if not lastCombatControls then
345+
lastCombatControls = {}
346+
end
347+
local player = g_game.getLocalPlayer()
348+
if player then
349+
local char = g_game.getCharacterName()
350+
lastCombatControls[char] = {
351+
fightMode = g_game.getFightMode(),
352+
chaseMode = g_game.getChaseMode(),
353+
safeFight = g_game.isSafeFight()
354+
}
355+
if g_game.getFeature(GamePVPMode) then
356+
lastCombatControls[char].pvpMode = g_game.getPVPMode()
357+
end
358+
g_settings.setNode('LastCombatControls', lastCombatControls)
359+
end
327360
end
328361

329362
function onSetSafeFight(self, checked)

tools/api/status.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@
8181
$response = array(
8282
"playersonline" => "$playersOnline",
8383
"discord_online" => $online_discord,
84-
"discord_link" => "https://discord.gg/HZN8yJJSyC",
84+
"discord_link" => "https://discord.gg/tUjTBZzMCy",
8585
"youtube_link" => "https://www.youtube.com/watch?v=6_2zizoJKxQ",
8686
"gamingyoutubestreams" => "0",
8787
"gamingyoutubeviewer" => "0",

0 commit comments

Comments
 (0)