Skip to content

feature: boosted creature / reading staticdata from assets / bestiary races rework#1064

Merged
mehah merged 28 commits intoopentibiabr:mainfrom
Zbizu:staticdata-rework
Jan 23, 2025
Merged

feature: boosted creature / reading staticdata from assets / bestiary races rework#1064
mehah merged 28 commits intoopentibiabr:mainfrom
Zbizu:staticdata-rework

Conversation

@Zbizu
Copy link
Copy Markdown
Contributor

@Zbizu Zbizu commented Jan 22, 2025

Description

This PR is quite big, but it would be rather difficult to split these three as they are very closely related to each other.
The original intention was to display boosted creature, but this ended up being a tip of an iceberg - staticdata was not read from the client at all, once I got it working, I found out that data behind boosted creature does not flow properly. Once I fixed that, I found out that the outfits cannot display because the assets don't preload. So in short: a lot of refactoring was involved in order to get a small thing to work.

Summary of changes

  • client is now able to read staticdata (currently it only reads monsters and bosses, but it's easy to add things such as achievements)
  • similarly, reading a soundbank should be way easier to implement now
  • fixed scrollbar for "hints" panel (huge thanks to Fifth for help)
  • if service and server are configured in init.lua, the client can now fetch boosted creature/boss the same way QT client does
  • unique server mode only: in order to display outfits on login screen, the assets are now preloaded
  • fixed an issue with wrong characterlist in unique server mode + web login scenario
  • RACES and boss equivalent were removed from utils.lua, Cyclopedia outfits are now loaded from staticdata
  • corrected the packet for requesting bestiary category
  • corrected a few typos in function names and strings

Removed monster/boss list from cyclopedia utils.lua
This is a breaking change so I wrote a tool that allows converting staticdata between dat and json:
https://github.com/Zbizu/staticdata-json
There are two branches - master repacks staticdata and branch sound repacks soundbanks

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested

I was testing the code while working on it.
There is some issue with outfits scaling, the one you may know from character list.
Boosted creatures display properly.
Charms assign properly.
Bosses display properly.
Bestiary entries display properly.
Bestiary search bar doesn't seem to do anything. This is due to the fact that the implementation was already incorrect prior to this PR.

Test Configuration:

  • Server Version: custom (tfs-based)
  • Client: 13.20
  • Operating System: Windows

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I checked the PR checks reports
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works

@Zbizu Zbizu changed the title feature: boosted creature / reading staticdata from assets / monster bank rework feature: boosted creature / reading staticdata from assets / bestiary races rework Jan 22, 2025
@Zbizu Zbizu requested a review from luanluciano93 January 22, 2025 14:54
@Zbizu
Copy link
Copy Markdown
Contributor Author

Zbizu commented Jan 22, 2025

changes in fa93c8d:

  • addressed some sonar-reported issues
  • addressed @dudantas' review
  • added compatibility for 'raceid' field which was used before bosstiary was introduced
  • added missing 'meta' fields
  • reduced code duplication

@Zbizu
Copy link
Copy Markdown
Contributor Author

Zbizu commented Jan 23, 2025

I don't understand why CI has a problem with it
I opened the project as a folder and tried exact same build and it works normally in Windows 10
obraz

could anyone try with Windows 11?

@Zbizu Zbizu force-pushed the staticdata-rework branch 2 times, most recently from 046f0a4 to e7f699d Compare January 23, 2025 12:29
@kokekanon
Copy link
Copy Markdown
Contributor

kokekanon commented Jan 23, 2025

I don't understand why CI has a problem with it I opened the project as a folder and tried exact same build and it works normally in Windows 10 ![obraz](https://private-user-images.githubusercontent.com/5205079/405973840-5b5644c8-201e-4bfa-
could anyone try with Windows 11?

>------ Build All started: Project: otclient, Configuration: windows-release-windows-release ------
  [1/31] Running cpp protocol buffer compiler on D:/github/otclient.readme/src/protobuf/staticdata.proto
  [2/31] Running cpp protocol buffer compiler on D:/github/otclient.readme/src/protobuf/sounds.proto
  [3/31] Running cpp protocol buffer compiler on D:/github/otclient.readme/src/protobuf/appearances.proto
  [4/31] Building RC object src\CMakeFiles\otclient.dir\__\cmake\icon\otcicon.rc.res
  [5/31] Building CXX object src\CMakeFiles\otclient.dir\cmake_pch.cxx.obj
  [6/31] Building CXX object src\protobuf\CMakeFiles\protobuf.dir\staticdata.pb.cc.obj
  [7/31] Building CXX object src\protobuf\CMakeFiles\protobuf.dir\sounds.pb.cc.obj
  [8/31] Building CXX object src\protobuf\CMakeFiles\protobuf.dir\appearances.pb.cc.obj
  [9/31] Linking CXX static library src\protobuf\protobuf.lib
  [10/31] Building CXX object src\CMakeFiles\otclient.dir\Unity\unity_20_cxx.cxx.obj
  [11/31] Building CXX object src\CMakeFiles\otclient.dir\Unity\unity_4_cxx.cxx.obj
  [12/31] Building CXX object src\CMakeFiles\otclient.dir\Unity\unity_15_cxx.cxx.obj
  [13/31] Building CXX object src\CMakeFiles\otclient.dir\Unity\unity_14_cxx.cxx.obj
  [14/31] Building CXX object src\CMakeFiles\otclient.dir\Unity\unity_17_cxx.cxx.obj
  [15/31] Building CXX object src\CMakeFiles\otclient.dir\Unity\unity_18_cxx.cxx.obj
  [16/31] Building CXX object src\CMakeFiles\otclient.dir\Unity\unity_19_cxx.cxx.obj
  [17/31] Building CXX object src\CMakeFiles\otclient.dir\Unity\unity_5_cxx.cxx.obj
  [18/31] Building CXX object src\CMakeFiles\otclient.dir\Unity\unity_16_cxx.cxx.obj
  [19/31] Building CXX object src\CMakeFiles\otclient.dir\Unity\unity_13_cxx.cxx.obj
  [20/31] Building CXX object src\CMakeFiles\otclient.dir\Unity\unity_0_cxx.cxx.obj
  [21/31] Building CXX object src\CMakeFiles\otclient.dir\Unity\unity_12_cxx.cxx.obj
  [22/31] Building CXX object src\CMakeFiles\otclient.dir\Unity\unity_7_cxx.cxx.obj
  [23/31] Building CXX object src\CMakeFiles\otclient.dir\Unity\unity_9_cxx.cxx.obj
  [24/31] Building CXX object src\CMakeFiles\otclient.dir\Unity\unity_6_cxx.cxx.obj
  [25/31] Building CXX object src\CMakeFiles\otclient.dir\Unity\unity_11_cxx.cxx.obj
  [26/31] Building CXX object src\CMakeFiles\otclient.dir\Unity\unity_10_cxx.cxx.obj
  [27/31] Building CXX object src\CMakeFiles\otclient.dir\Unity\unity_1_cxx.cxx.obj
  [28/31] Building CXX object src\CMakeFiles\otclient.dir\Unity\unity_3_cxx.cxx.obj
  [29/31] Building CXX object src\CMakeFiles\otclient.dir\Unity\unity_2_cxx.cxx.obj
  [30/31] Building CXX object src\CMakeFiles\otclient.dir\Unity\unity_8_cxx.cxx.obj
  [31/31] Linking CXX executable D:\github\otclient.readme\otclient.exe
  
Build All succeeded.

cmake -
image

Edition : Windows 11 Pro
Version : 23H2
Os Build 22631.4751
Installed on 28/‎04/‎2024

@sonarqubecloud
Copy link
Copy Markdown

@Zbizu
Copy link
Copy Markdown
Contributor Author

Zbizu commented Jan 23, 2025

@dudantas @luanluciano93 @mehah build issue fixed

Copy link
Copy Markdown
Contributor

@kokekanon kokekanon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

test:
work boosted creature, and cyclopedia in 13.40

@mehah
Copy link
Copy Markdown
Collaborator

mehah commented Jan 23, 2025

can i merge then? :)

@mehah mehah merged commit 2a1b946 into opentibiabr:main Jan 23, 2025
@Zbizu Zbizu deleted the staticdata-rework branch January 23, 2025 21:31

-- check if race id is present in the staticdata
if raceData.raceId == 0 then
local msg = string.format("[%s] Creature with race id %s was not found.", fileName, data.creatureraceid)
Copy link
Copy Markdown
Contributor

@lucasoares lucasoares Jan 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you tested when the raceis not found? This will throw an error since data is not defined. @Zbizu

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it returns an empty struct

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it returns an empty struct

For me it was throwing an error saying data is nil...

haha

@lucasoares
Copy link
Copy Markdown
Contributor

lucasoares commented Jan 27, 2025

Have you tested on a 860 server? The bestiary and cyclopedia doesn't exists, but most of servers have the concept of boosted monsters.. I'm unable to make the creature appear in the bottommenu:

WARNING: [@/client_bottommenu/bottommenu.lua] Creature with race id 35 was not found.

Apparently m_monsterRaces is empty on protocol 860 @Zbizu

I made it work for simple creatures (with specific look type) by setting outfit with {type: looktype} if the race is not found.

@Zbizu
Copy link
Copy Markdown
Contributor Author

Zbizu commented Jan 27, 2025

@lucasoares
you need catalog-content.json pointing to staticdata, and a staticdata file of course
you may also need an extra line in things loader for that
would you like to open a pr once you get it working?

errorMessage = errorMessage ..
tr('Unable to load spr file, please place a valid spr in \'%s.spr\'', sprPath)
errorList[#errorList + 1] = tr('Unable to load spr file, please place a valid spr in \'%s.spr\'', sprPath)
end
Copy link
Copy Markdown
Contributor Author

@Zbizu Zbizu Jan 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there it needs g_things.loadStaticData for things that use spr/dat

you can customize your staticdata with the tool I provided: https://github.com/Zbizu/staticdata-json

@lucasoares
Copy link
Copy Markdown
Contributor

lucasoares commented Jan 28, 2025

@lucasoares you need catalog-content.json pointing to staticdata, and a staticdata file of course you may also need an extra line in things loader for that would you like to open a pr once you get it working?

Don't think this all is necessary. At least not for the creature boost feature to work. For me it's working now.

I made my status API to return all necessary outfit data:

"creatureraceid" => [
                    "type" => $boostedCreature["looktype"],
                    "feet" => $boostedCreature["lookfeet"],
                    "legs" => $boostedCreature["looklegs"],
                    "hand" => $boostedCreature["lookhead"],
                    "body" => $boostedCreature["lookbody"],
                    "addons" => $boostedCreature["lookaddons"]
                ],

And made the client compatible with a table response:

local function applyToBoostedSlot(data, outfitWidget, imageWidget, fileName)
    -- check if raceId was provided in the JSON response
    if not data then
        return
    end

    local outfit = nil
    if type(data) ~= "table" then
        -- fetch race data
        local raceData = g_things.getRaceData(data)

        -- check if race id is present in the staticdata
        if raceData.raceId == 0 then
            local msg = string.format("[%s] Creature with race id %s was not found.", fileName, data)
            g_logger.warning(msg)

            outfit = {
                type = data,
            }
        else
            outfit = raceData.outfit
        end
    else
        outfit = data
    end

    -- apply to selected widget
    outfitWidget:setOutfit(outfit)
    outfitWidget:getCreature():setStaticWalking(1000)
    outfitWidget:setVisible(true)
    imageWidget:setVisible(false)
end

I'm accepting when the race is not found, using the raceid (data) as a looktype (this will work only with looktype-specific creatures, not human outfit, for example) to also have a little more compatibility.

vllsystems pushed a commit to vllsystems/otclient that referenced this pull request Feb 20, 2025
vllsystems pushed a commit to vllsystems/otclient that referenced this pull request Mar 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants