• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.
  • Vote for the theme of Hive's HD Modeling Contest #7! Click here to vote! - Please only vote if you plan on participating❗️

Sorting MUI quests

Status
Not open for further replies.
Level 2
Joined
Feb 24, 2020
Messages
11
Hi everyone.

So I have been making MUI quests using the simple methods which are used in The_big_S's guide in combination with a UI created via the Reforged UI creator. In total a player can have 14 quests. I want to somehow bind each quest to a button in the UI. This is because I want to remove the correct quest from each players quest log whenever they finish a quest, or when they chose to abandon a quest. I then want to be able to fill in that empty gap, or move all quest below up once so there is no gap. I have tried making it work with Hashtables but I am having a hard time figuring that out correctly.

I am able to make it so that the correct text is shown for each button, I have done this is in a stupid temp way by just saving the amount of quests the player has and then binding the last button to the last quest. This is done in a pretty stupid way but I couldn't think of another way of doing it MUI. I have no clue how to add GUI triggers to threads correctly, so I've added a print.


Skärmklipp.PNG



JASS:
function Trig_QuestPlace_Actions takes nothing returns nothing



        if (udg_QuestAmount[GetConvertedPlayerId(GetTriggerPlayer())] == 1) then
            call BlzFrameSetText(QuestbuttonT[00],Thisquesttitle)
        call BlzFrameSetVisible(QuestbuttonT[00],true)
            set Quest1Title[R2I(QuestAdd)] = Thisquesttitle
            set Quest1String[R2I(QuestAdd)] = Thisquesttext
       

        elseif (udg_QuestAmount[GetConvertedPlayerId(GetTriggerPlayer())] == 2) then
            call BlzFrameSetText(QuestbuttonT[01],Thisquesttitle)
        call BlzFrameSetVisible(QuestbuttonT[01],true)
            set Quest2Title[R2I(QuestAdd)] = Thisquesttitle
            set Quest2String[R2I(QuestAdd)] = Thisquesttext
       

        elseif (udg_QuestAmount[R2I(QuestAdd)] == 3) then
            call BlzFrameSetText(QuestbuttonT[02],Thisquesttitle)
        call BlzFrameSetVisible(QuestbuttonT[02],true)
            set Quest3Title[R2I(QuestAdd)] = Thisquesttitle
            set Quest3String[R2I(QuestAdd)] = Thisquesttext
       

        elseif (udg_QuestAmount[R2I(QuestAdd)] == 4) then
            call BlzFrameSetText(QuestbuttonT[03],Thisquesttitle)
        call BlzFrameSetVisible(QuestbuttonT[03],true)
            set Quest4Title[R2I(QuestAdd)] = Thisquesttitle
            set Quest4String[R2I(QuestAdd)] = Thisquesttext
       

        elseif (udg_QuestAmount[R2I(QuestAdd)] == 5) then
            call BlzFrameSetText(QuestbuttonT[04],Thisquesttitle)
        call BlzFrameSetVisible(QuestbuttonT[04],true)
            set Quest5Title[R2I(QuestAdd)] = Thisquesttitle
            set Quest5String[R2I(QuestAdd)] = Thisquesttext
       

        elseif (udg_QuestAmount[R2I(QuestAdd)] == 6) then
            call BlzFrameSetText(QuestbuttonT[05],Thisquesttitle)
        call BlzFrameSetVisible(QuestbuttonT[05],true)
            set Quest6Title[R2I(QuestAdd)] = Thisquesttitle
            set Quest6String[R2I(QuestAdd)] = Thisquesttext
       

        elseif (udg_QuestAmount[R2I(QuestAdd)] == 7) then
            call BlzFrameSetText(QuestbuttonT[06],Thisquesttitle)
        call BlzFrameSetVisible(QuestbuttonT[06],true)
            set Quest7Title[R2I(QuestAdd)] = Thisquesttitle
            set Quest7String[R2I(QuestAdd)] = Thisquesttext
       

        elseif (udg_QuestAmount[R2I(QuestAdd)] == 8) then
            call BlzFrameSetText(QuestbuttonT[07],Thisquesttitle)
        call BlzFrameSetVisible(QuestbuttonT[07],true)
            set Quest8Title[R2I(QuestAdd)] = Thisquesttitle
            set Quest8String[R2I(QuestAdd)] = Thisquesttext
       

        elseif (udg_QuestAmount[R2I(QuestAdd)] == 9) then
            call BlzFrameSetText(QuestbuttonT[8],Thisquesttitle)
        call BlzFrameSetVisible(QuestbuttonT[8],true)
            set Quest9Title[R2I(QuestAdd)] = Thisquesttitle
            set Quest9String[R2I(QuestAdd)] = Thisquesttext
       

        elseif (udg_QuestAmount[R2I(QuestAdd)] == 10) then
            call BlzFrameSetText(QuestbuttonT[9],Thisquesttitle)
        call BlzFrameSetVisible(QuestbuttonT[9],true)
            set Quest10Title[R2I(QuestAdd)] = Thisquesttitle
            set Quest10String[R2I(QuestAdd)] = Thisquesttext
       

        elseif (udg_QuestAmount[R2I(QuestAdd)] == 11) then
            call BlzFrameSetText(QuestbuttonT[10],Thisquesttitle)
        call BlzFrameSetVisible(QuestbuttonT[10],true)
            set Quest11Title[R2I(QuestAdd)] = Thisquesttitle
            set Quest11String[R2I(QuestAdd)] = Thisquesttext
       

        elseif (udg_QuestAmount[R2I(QuestAdd)] == 12) then
            call BlzFrameSetText(QuestbuttonT[11],Thisquesttitle)
        call BlzFrameSetVisible(QuestbuttonT[11],true)
            set Quest12Title[R2I(QuestAdd)] = Thisquesttitle
            set Quest12String[R2I(QuestAdd)] = Thisquesttext
       

        elseif (udg_QuestAmount[R2I(QuestAdd)] == 13) then
            call BlzFrameSetText(QuestbuttonT[12],Thisquesttitle)
        call BlzFrameSetVisible(QuestbuttonT[12],true)
            set Quest13Title[R2I(QuestAdd)] = Thisquesttitle
            set Quest13String[R2I(QuestAdd)] = Thisquesttext
       

        elseif (udg_QuestAmount[R2I(QuestAdd)] == 14) then
            call BlzFrameSetText(QuestbuttonT[13],Thisquesttitle)
        call BlzFrameSetVisible(QuestbuttonT[13],true)
            set Quest14Title[R2I(QuestAdd)] = Thisquesttitle
            set Quest14String[R2I(QuestAdd)] = Thisquesttext
       

        elseif (udg_QuestAmount[R2I(QuestAdd)] == 15) then
            call BlzFrameSetText(QuestbuttonT[14],Thisquesttitle)
        call BlzFrameSetVisible(QuestbuttonT[14],true)
            set Quest15Title[R2I(QuestAdd)] = Thisquesttitle
            set Quest15String[R2I(QuestAdd)] = Thisquesttext
       
         endif
set QuestAdd = 0
endfunction

//===========================================================================
function InitTrig_QuestPlace takes nothing returns nothing
    set gg_trg_QuestPlace = CreateTrigger(  )
    call TriggerRegisterVariableEvent( gg_trg_QuestPlace, "QuestAdd", NOT_EQUAL, 0 )
    call TriggerAddAction( gg_trg_QuestPlace, function Trig_QuestPlace_Actions )
endfunction

I also tried doing it like this
  • Events
  • Map initialization
  • Conditions
  • Actions
    • Hashtable - create a hashtable
    • set Variable QuestHash = (last created hashtable)
  • Events
  • Unit - A unit comes withing 256.00 of Verna Furlbrow <gen>
  • Conditions
  • Actions
    • For each (Integer A) from 1 to 14,do (Actions)
      • Loop - Actions
        • Custom script: set udg_CurrQuest= LoadInteger(udg_QuestHash,GetConvertedPlayerId(GetOwningPlayer(GetTriggerUnit())),GetForLoopIndexA())
        • if (All conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • CurrQuest Equal to 0
          • Then - Actions
            • Custom script: call SaveInteger(udg_CastHash, GetConvertedPlayerId(GetOwningPlayer(GetTriggerUnit())),GetForLoopIndexA(), 100)
But that did not work either. When I loaded the data I always got 0, which is the Initial value of udg_CurrQuest.

I hope I've been clear enough. If not feel free to ask for more information.

Thank you in advance.
 
Last edited:

Uncle

Warcraft Moderator
Level 71
Joined
Aug 10, 2018
Messages
7,588
So what you're really looking for is MPI, not MUI. Each Player has their own Quest Log, not each Unit.

That aside, I'm assuming that the Reforged UI creator doesn't take MPI into consideration and simply creates frames that will be shared by everyone as this is the default behavior of a frame. There are 2 solutions to handling frames for multiple players:
1) Players share the same frames and you take advantage of GetLocalPlayer() in order to modify frames for specific players.
2) You create individual frames for each player and use GetLocalPlayer() to hide them from others so that each player can only see their own specific set of frames.

Either way, you'll need to use GetLocalPlayer() at some point. I use the 2nd method as it removes the need for GetLocalPlayer() outside of adjusting visibility, but I also use Lua which makes all of this much much easier.

Anyway, here's some example functions that may help you out with your current setup or at least point you in the right direction:
vJASS:
// call this in order to get the [index] of an open quest button
// it will return -1 if all 14 quest buttons are closed
function GetOpenQuestButton takes nothing returns integer
    local integer i = 0
    loop
        if (BlzFrameGetText(QuestbuttonT[i]) == "") then
            return i
        endif
        set i = i + 1
        exitwhen i == 14
    endloop
    return -1
endfunction

// call this after removing a quest to sort the order of quests
function SortQuests takes nothing returns nothing
    local integer i = 0
    loop
        if (BlzFrameGetText(QuestbuttonT[i]) == "") then
            loop
                if (i < 14) then
                    call BlzFrameSetText(QuestbuttonT[i], BlzFrameGetText(QuestbuttonT[i+1]))
                else
                    call BlzFrameSetText(QuestbuttonT[i], "")
                    return
                endif
                set i = i + 1
            endloop
        endif
        set i = i + 1
    endloop
endfunction

// call this and provide a quest name (title) in the parameters
// it will return true if the player has the quest or false if they do not
function HasQuest takes string questName returns boolean
    local integer i = 0
    loop
        if (BlzFrameGetText(QuestbuttonT[i]) == questName) then
            return true
        endif
        set i = i + 1
        exitwhen i == 14
    endloop
    return false
endfunction
I take advantage of the BlzFrameGetText() function which gets us the text of a frame. This can tell us whether or not a button is being used, since buttons that have quests will have text and ones that don't will have empty strings. I use this information in order to find open (unused) quest buttons, full quest logs, and to sort the quest log so that there aren't any gaps.

You can probably use BlzFrameGetText() to manage most of what you need, just remember to set unused button's text to "" for these functions to work properly.

Here's some examples of using them in GUI:
  • Custom script: set udg_Integer = GetOpenQuestButton()
  • Custom script: set udg_Boolean = HasQuest("Poor Old Blanchy")
  • Custom script: call SortQuests()
Keep in mind this is not MPI friendly until you introduce GetLocalPlayer() into the mix. Also, BlzFrameGetText() may desync if used with GetLocalPlayer(), I've never tested it. If I have time in the future and you're still struggling I can try to throw together an actual working quest system for you.
 
Last edited:
Level 2
Joined
Feb 24, 2020
Messages
11
Hi @Uncle

Thanks for the help. As I only had 14 quests I ended up swaping BlzFrameGetText with a string array for playernumber x 15 + i instead. This means that there should be no desyncs.

Thank you for helping me solve this.
 
Status
Not open for further replies.
Top