Larian Banner: Baldur's Gate Patch 9
Previous Thread
Next Thread
Print Thread
#770590 21/04/21 01:33 PM
Joined: Apr 2021
W
stranger
OP Offline
stranger
W
Joined: Apr 2021
Hello modding community!
I'm completely new to DoS2 modding and modding in general. I've been attempting to find an answer to a very specific question, hope you can help me.

Goal: I want to create custom tags/subtitles for specific characters (think "The Source King" for Braccus Rex) and have this displayed in the UI when hovering over that character.
Attempted method: I tried to think of how it had been done in Origins and could only come up with the "Trader" tags, visible after an NPC's level: "Level 20, Trader". However, I can't seem to find where the ", Trader" section is set.

Is there a way of creating custom tags similar to the TRADER tag, or is there a better solution of adding subtitles to NPCs?

Last edited by Wacktorious; 21/04/21 01:33 PM.
Joined: Apr 2021
W
stranger
OP Offline
stranger
W
Joined: Apr 2021
After receiving help from the modding community on Discord and mining through some code I was able to generate the results I was looking for!

On Discord follow the conversation between myself and Focus:
https://discord.com/channels/98922182746329088/358337334619406336/835902122398187542
https://discord.com/channels/98922182746329088/358337334619406336/837370150322831395
https://discord.com/channels/98922182746329088/358337334619406336/838080357240406026

The code that yielded the result was the following.

NOTE:
This feature is part of the Norbyte's Script Extender v55 which is currently in development. If you don't have the Script Extender install it first by following this guide.
In the code below I explain how to get the development version 55.


Code
-- Only possible on the client side of lua
local TextSetOnObjects = {}
local TagDescriptions = {
    ['Some tag1'] = "Some description 1",
    ['Some tag2'] = "Some description 2",
}

local function SetCustomTagDescription(ui, method, name, description, param3)
    if name ~= "" and description ~= "" and Ext.GetPickingState().HoverCharacter then
        local pickingState = Ext.GetPickingState()
        local object = Ext.GetCharacter(pickingState.HoverCharacter) or Ext.GetItem(pickingState.HoverCharacter)
        
        if object and not TextSetOnObjects[pickingState.HoverCharacter] then
            for i, tag in ipairs(object:GetTags()) do
                if TagDescriptions[tag] then
                    description = description..", "..tag
                end
            end
            TextSetOnObjects[pickingState.HoverCharacter] = true
            ui:Invoke("setText", name, description, param3)
            TextSetOnObjects[pickingState.HoverCharacter] = nil
        end
    end
end

---This feature is part of extender version 55; current version is 54.
---It currently works with the development version of the extender. Add the file DefEd\bin\OsiUpdateChannel.txt and fill it with the word "Devel", then change the if statement below to 54 and restart the Engine and DOS2:DE clients.
if Ext.Version() >= 55 then
    Ext.RegisterUITypeInvokeListener(42, "setText", SetCustomTagDescription, "After")
end


Link Copied to Clipboard
Powered by UBB.threads™ PHP Forum Software 7.7.5