Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: v8 Bot #621

Merged
merged 22 commits into from
Nov 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@

##### Sponsored (Features)
- Shader with Framebuffer | ([@SkullzOTS](https://github.com/SkullzOTS), [@Mryukiimaru](https://github.com/Mryukiimaru), [@JeanTheOne](https://github.com/JeanTheOne), [@KizaruHere](https://github.com/KizaruHere))
- Bot V8 | ([@luanluciano93](https://github.com/luanluciano93), [@SkullzOTS](https://github.com/SkullzOTS), [@kokekanon](https://github.com/kokekanon), [@FranciskoKing](https://github.com/FranciskoKing), [@Kizuno18](https://github.com/Kizuno18))
- Is adapted in 85%
- To enable it, it is necessary to remove/off the BOT_PROTECTION flag.
- [VS Solution](https://github.com/mehah/otclient/blob/68e4e1b94c2041bd235441244156e6477058250c/vc17/settings.props#L9) / [CMAKE](https://github.com/mehah/otclient/blob/68e4e1b94c2041bd235441244156e6477058250c/src/CMakeLists.txt#L13)

##### [OTClient V8](https://github.com/OTCv8) (Features)
- Lighting System
Expand Down
16 changes: 0 additions & 16 deletions cmake/FindZLIB.cmake

This file was deleted.

Binary file added data/images/topbuttons/analyzers.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/images/topbuttons/bot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/images/topbuttons/buttons.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/images/ui/graph_background.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/images/ui/rarity_blue.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/images/ui/rarity_frames.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/images/ui/rarity_gold.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/images/ui/rarity_green.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/images/ui/rarity_purple.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/images/ui/rarity_white.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/sounds/Creature_Detected.ogg
Binary file not shown.
Binary file added data/sounds/Low_Health.ogg
Binary file not shown.
Binary file added data/sounds/Low_Mana.ogg
Binary file not shown.
Binary file added data/sounds/Player_Attack.ogg
Binary file not shown.
Binary file added data/sounds/Player_Detected.ogg
Binary file not shown.
Binary file added data/sounds/Private_Message.ogg
Binary file not shown.
Binary file added data/sounds/alarm.ogg
Binary file not shown.
Binary file added data/sounds/magnum.ogg
Binary file not shown.
60 changes: 60 additions & 0 deletions data/styles/20-smallscrollbar.otui
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
SmallScrollBar < UIScrollBar
orientation: vertical
margin-bottom: 1
step: 20
width: 8
image-source: /images/ui/scrollbar
image-clip: 39 0 13 65
image-border: 1
pixels-scroll: true

UIButton
id: decrementButton
anchors.top: parent.top
anchors.left: parent.left
image-source: /images/ui/scrollbar
image-clip: 0 0 13 13
image-color: #ffffffff
size: 8 8
$hover:
image-clip: 13 0 13 13
$pressed:
image-clip: 26 0 13 13
$disabled:
image-color: #ffffff66

UIButton
id: incrementButton
anchors.bottom: parent.bottom
anchors.right: parent.right
size: 8 8
image-source: /images/ui/scrollbar
image-clip: 0 13 13 13
image-color: #ffffffff
$hover:
image-clip: 13 13 13 13
$pressed:
image-clip: 26 13 13 13
$disabled:
image-color: #ffffff66

UIButton
id: sliderButton
anchors.centerIn: parent
size: 8 11
image-source: /images/ui/scrollbar
image-clip: 0 26 13 13
image-border: 2
image-color: #ffffffff
$hover:
image-clip: 13 26 13 13
$pressed:
image-clip: 26 26 13 13
$disabled:
image-color: #ffffff66

Label
id: valueLabel
anchors.fill: parent
color: white
text-align: center
2 changes: 2 additions & 0 deletions data/styles/40-gamebuttons.otui
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
GameButtonsWindow < MiniWindow
height: 26
5 changes: 5 additions & 0 deletions init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@ local function loadModules()

-- mods 1000-9999
g_modules.autoLoadModules(9999)
g_modules.ensureModuleLoaded('client_mods')

if not g_game.isEnabledBotProtection() then
g_modules.ensureModuleLoaded('game_bot')
end

local script = '/' .. g_app.getCompactName() .. 'rc.lua'

Expand Down
10 changes: 10 additions & 0 deletions mods/client_mods/mods.otmod
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Module
name: client_mods
description: Mod loader
author: OTClient Team
website: https://github.com/mehah/otclient
sandboxed: true
load-later:
- client_profiles
- game_buttons
- game_itemselector
160 changes: 160 additions & 0 deletions mods/client_profiles/profiles.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
local settings = {}
ChangedProfile = false

function init()
connect(g_game, {
onGameStart = online,
onGameEnd = offline
})

end

function terminate()
disconnect(g_game, {
onGameStart = online,
onGameEnd = offline
})
end

-- loads settings on character login
function online()
ChangedProfile = false

-- startup arguments has higher priority than settings
local index = getProfileFromStartupArgument()
if index then
setProfileOption(index)
end

load()

if not index then
setProfileOption(getProfileFromSettings() or 1)
end

-- create main settings dir
if not g_resources.directoryExists("/settings/") then
g_resources.makeDir("/settings/")
end

-- create profiles dirs
for i=1,10 do
local path = "/settings/profile_"..i

if not g_resources.directoryExists(path) then
g_resources.makeDir(path)
end
end
end

function setProfileOption(index)
local currentProfile = g_settings.getNumber('profile')
currentProfile = tostring(currentProfile)
index = tostring(index)

if currentProfile ~= index then
ChangedProfile = true
return modules.client_options.setOption('profile', index)
end

end

-- load profile number from settings
function getProfileFromSettings()
-- settings should save per character, return if not online
if not g_game.isOnline() then return end

local index = g_game.getCharacterName()
local savedData = settings[index]

return savedData
end

-- option to launch client with hardcoded profile
function getProfileFromStartupArgument()
local startupOptions = string.split(g_app.getStartupOptions(), " ")
if #startupOptions < 2 then
return false
end

for index, option in ipairs(startupOptions) do
if option == "--profile" then
local profileIndex = startupOptions[index + 1]
if profileIndex == nil then
return g_logger.info("Startup arguments incomplete: missing profile index.")
end

g_logger.info("Startup options: Forced profile: "..profileIndex)
-- set value in options
return profileIndex
end
end

return false
end

-- returns string path ie. "/settings/1/actionbar.json"
function getSettingsFilePath(fileNameWithFormat)
local currentProfile = g_settings.getNumber('profile')

return "/settings/profile_"..currentProfile.."/"..fileNameWithFormat
end

function offline()
onProfileChange(true)
end

-- profile change callback (called in options), saves settings & reloads given module configs
function onProfileChange(offline)
if not offline then
if not g_game.isOnline() then return end
-- had to apply some delay
scheduleEvent(collectiveReload, 100)
end

local currentProfile = g_settings.getNumber('profile')
local index = g_game.getCharacterName()

if index then
settings[index] = currentProfile
save()
end
end

-- collection of refresh functions from different modules
function collectiveReload()
modules.game_topbar.refresh(true)
modules.game_actionbar.refresh(true)
modules.game_bot.refresh()
end

-- json handlers
function load()
local file = "/settings/profiles.json"
if g_resources.fileExists(file) then
local status, result = pcall(function()
return json.decode(g_resources.readFileContents(file))
end)
if not status then
return onError(
"Error while reading profiles file. To fix this problem you can delete storage.json. Details: " ..
result)
end
settings = result
end
end

function save()
local file = "/settings/profiles.json"
local status, result = pcall(function() return json.encode(settings, 2) end)
if not status then
return onError(
"Error while saving profile settings. Data won't be saved. Details: " ..
result)
end
if result:len() > 100 * 1024 * 1024 then
return onError(
"Something went wrong, file is above 100MB, won't be saved")
end
g_resources.writeFileContents(file, result)
end
11 changes: 11 additions & 0 deletions mods/client_profiles/profiles.otmod
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Module
name: client_profiles
description: Client profiles
author: Vithrax
website: discord_Vithrax#5814
autoload: true
reloadable: false
scripts: [ profiles ]
sandboxed: true
@onLoad: init()
@onUnload: terminate()
Loading
Loading