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: Simple Sound module tibia 13 Qt #1098

Closed
wants to merge 4 commits into from

Conversation

kokekanon
Copy link
Collaborator

@kokekanon kokekanon commented Feb 11, 2025

The content of this PR is not intended to be merged. I don't use sounds, I don't use Tibia 13, and I don't know how the g_sound works. I just wanted to learn about the JSON from protobuf #1074

The sounds sent by the server work perfectly, but ambient or UI sounds don't work because I think it would be necessary to use onAddThing and onPositionChange to determine if the player is with in X sqm of the item emitting the sound.

For UI sounds:
I believe onTalk should be used

connect(rootWidget or UIWidget, { 
    onClick = onClick (if UIbutton), 
})

I don't know how to do it in an optimized way.
also
Since the server doesn't send that information, it's necessary to dive into the 16k-line JSON to find the sounds. 💀

"functional"

without client_options filters:

  • Movements (ex: equip armor in inventory)
  • Spells (ex : exevo gran mas tera)
  • Actions (ex: open door)

test in 13.40 (opentibiabr/canary#1017)

ENABLE sound of the video

image

2025-02-10.20-27-04.mp4

how does it work?

image

flowchart TD
    A@{ label: "fa:fa-magic Player casts the spell 'exevo gran mas tera'" } --> B@{ label: "fa:fa-server Server sends the packet 'parseMagicEffectt' with :<br>- source, <br>- sound ID,<br>- position" }
    B --> C@{ label: "fa:fa-list 'Source' identifies: <br>0=global, <br>1=own, <br>2=others, <br>3=creature" }
    C --> D{"fa:fa-cogs Is it active(volume or checkbox) in game_options?"}
    D -- False --> E["fa:fa-ban Not executed"]
    D -- True --> F@{ label: "fa:fa-search Searches for SoundId in 'numericSoundEffect' from the protobuf" }
    F --> G@{ label: "fa:fa-filter Identifies 'numericSoundType' (attack, healing, or support)" }
    G --> H{"fa:fa-check Is the checkbox enabled?"}
    H -- False --> I["fa:fa-ban Not executed"]
    H -- True --> J@{ label: "fa:fa-database Searches for 'SimpleSoundEffect.SoundId' in the 'sound' array from the protobuf" }
    J --> K["fa:fa-file-audio get the .ogg file"]

    A@{ shape: rounded}
    B@{ shape: rounded}
    C@{ shape: rounded}
    F@{ shape: rect}
    G@{ shape: rect}
    J@{ shape: rect}
    style F fill:#AA00FF,stroke:#AA00FF,color:#FFFFFF
    style G fill:#FF9800,stroke:#FF9800,color:#FFFFFF
    style J fill:#2962FF,stroke:#2962FF,color:#FFFFFF
    style K fill:#4CAF50,stroke:#4CAF50,color:#FFFFFF



Loading

UI

image

image

image

callback

1) soundMain

g_lua.callGlobalField("g_sounds", "soundMain", soundSource, SoundID, pos);

Activates or deactivates this

disconnect or connect(g_sounds, {
            soundMain = soundMain,
            soundSecondary = soundSecondary
        })

2) soundMain and 3) enableSound

info of ProtocolGame::parseMagicEffect(const InputMessagePtr& msg)

g_lua.callGlobalField("g_sounds", "soundMain", soundSource, SoundID, pos);
g_lua.callGlobalField("g_sounds", "enableSound", enable); 

soundSource = Type of "numericSoundType"(protobuf)
SoundID = ID of "numericSoundEffect" (protobuf)
pos = position of effect

Example : Server send 2045
soundSource = 0 (used for filter in client_options)
SoundID =2045
pos = 100,100,7

New functions

 g_lua.bindSingletonFunction("g_sounds", "getSoundEffectType", &SoundManager::getSoundEffectType, &g_sounds);

image

 g_lua.bindSingletonFunction("g_sounds", "getRandomSoundIds", &SoundManager::getRandomSoundIds, &g_sounds);

image

devMode

modules.game_sound.toggleDebugMode()

Yellow: soundMain 
============================
=== Debug Sound Playback ===
============================
Missile created from
================================================================================
Positions
Position Sonido    x= 32367    y= 32209    z= 7
Posicion del player    x= 32368    y= 32209    z= 7
distanceCalculate    1
gainCalculate    0.875
================================================================================
Info del sonido
g_sounds.soundIds(soundID) 1056
g_sounds.getSoundEffectType(soundID)    1
channelId    3
============================


Red: soundSecondary 
============================
=== Debug Sound Playback ===
============================
Missile created from
================================================================================
Positions
Position Sonido    x= 32368    y= 32210    z= 7
Posicion del player    x= 32368    y= 32209    z= 7
distanceCalculate    1
gainCalculate    0.875
================================================================================
Info del sonido
g_sounds.soundIds(soundID)  2677
g_sounds.getSoundEffectType(soundID)    4
channelId    12
============================

@kokekanon kokekanon closed this Feb 11, 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.

1 participant