Player Quest System - WIP

Discussion in 'Player Created Lua Script Repository' started by Tirrag, Sep 25, 2021.

  1. Tirrag

    Tirrag Avatar

    Messages:
    854
    Likes Received:
    1,824
    Trophy Points:
    93
    Location:
    Iowa, USA
    Good day Shroud crowd! I have been working like a man possessed on a new mod and wanted to introduce it to gather feedback as it is being developed. Though completion is still a ways out, I am far enough along that it's going to finish and believe now is a good time to feel out the idea with the community.

    I call this new mod the Player Quest System. My goal is to have a website that allows players to build/edit quests, package them up for distribution, and then distribute them as desired. The core system will read the player built files and load the quest into the PQS.

    Let me talk a little about the design of the system. The current components of a quest are:

    Journal entries - these are the main journal entries documenting the progression through your quest. a journal entry has the journal text and hint text to guide the player on what to do next. journal entries have an optional capability of being a task that can be completed or failed.

    Locations - these are defined scene location coordinates that can be used within the events

    Quest Items - these are virtual items (as in there is nothing that goes in your real inventory) that can be given and removed from players as they progress through your quest

    Quest Variables - these are values you can store associated to the player and can then use them in event criteria and actions.

    Dialogs - PQS has a simple built-in dialog system to use in-addition to or instead of conversationalists. A dialog represents a single panel of conversation and has text slots for player thoughts, player text, and npc text.

    Topics - Each dialog has the option to have multiple topics. The topics control the flow of the conversation and compare to keywords in the SotA dialog system. Topics can be marked as important which will cause their color to be gold. Topics can also be tied to a quest variable so they will only show if the quest variable is 1.

    Events - these are the core of the system. They allow you to control the flow, update quest variables, give/remove quest items, etc. Events are made up of two components: criteria and actions.

    Event Criteria - an event can have any number of criteria that controls if the event is fired when all equate to true. Currently the system has the following criteria implemented with many more planned:
    • quest variable - can check the value of a quest variable with many comparison types
    • scene - check if the player is, is not, entered, or exited the scene
    • location - checks if the player is, is not, entered, or exited a defined location (uses a distance check)
    • journal entry - has, does not have, has viewed, has not viewed, just viewed, has completed, has not completed, just completed, has failed, has not failed, just failed a journal entry
    • pet - is, is not, summoned, dismissed
    • quest item - checks if the player has an item, quantity, item was added, or item was removed
    • NPC - this one I think will be popular. can check for certain text from NPCs including conversationalists... essentially you can have your quest integrated with conversationalists :) options for NPC checking is name (from or to and can dynamically be the player name) and certain text. This criteria also works with the built-in dialog system as all conversation goes through the same process no matter the source.
    • chance - a percentage chance that the criteria will evaluate to true
    • loot - check item and optional quantity gained. this works for loot, harvest, picking up, and fishing.
    • timestamp - allows for an event to fire based on a UTC timestamp value checking against the current timestamp.
    • dialog - allows to check if the user has viewed, has not viewed, or entered a dialog from the built-in dialog system
    • craft - allows to check if the user crafted a specific recipe
    • combat - allows to check for kill or damage. options to check attacker, attacked, skill, damage amount, critical
    Event Actions - an event can have any number of actions that it performs if all of its criteria are met. Currently the system has the following actions implemented with many more planned:
    • add journal entry - controls the flow of the quest by setting a new journal entry
    • set journal entry status - can set to complete or failed
    • set quest variable - allows you to control quest variable values. options for set, increment, and decrement.
    • quest item - allows you to give/remove quest items from the player. options for chance, set, increment, and decrement.
    • console text - output quest text to the lua chat window.
    • start dialog - begin a PQS dialog.
    • timer - allows you to create/start a timer which you can then stop or reset. you can use the amount of ticks the timer has been on for in the quest variable criteria. timer ticks are tracked in a quest variable of the same name as the timer.
    As I mentioned, this is very much still a WIP with no ETA yet. There are a lot more event actions and criteria to be implemented and also the in-game and web interfaces. I am working like crazy on it though with the next items being combat/loot related and am very excited with its progress. At this stage you can already build complete quests if you know the simple file format.

    One question you may have is how can one protect their quest from folks trying to circumvent things... unfortunately you cant. I will do my best to make it at least difficult in the final mod, but there is nothing I can do to completely prevent it. It would be nice if Lua could make calls out to the web to pull data down, though I don't think we will see that any time soon.

    Anyways, I hope this is as exciting to you as it is me. Start dreaming!
     
    Last edited: Oct 23, 2021
  2. Tirrag

    Tirrag Avatar

    Messages:
    854
    Likes Received:
    1,824
    Trophy Points:
    93
    Location:
    Iowa, USA
    Been working the last few days on code refactoring and the window system. Here is a little show of the window system so far.

    https://imgur.com/2jPBq7K

    Going to get some UI completed using this window system and then back to the core system code to implement more features.
     
    Last edited: Oct 11, 2021
    Chris, Time Lord and Violet Ronso like this.
  3. Tristano Sforza

    Tristano Sforza Avatar

    Messages:
    158
    Likes Received:
    330
    Trophy Points:
    18
    Location:
    Mediolanum, Hidden Vale
    This "framework" is undoubtedly inspired by my quest I've made last year. As long as PQS is not ready, everyone can try the quest mechanics playing Sotatales , it's still on ;)

    Tristano
     
  4. Tirrag

    Tirrag Avatar

    Messages:
    854
    Likes Received:
    1,824
    Trophy Points:
    93
    Location:
    Iowa, USA
  5. Tirrag

    Tirrag Avatar

    Messages:
    854
    Likes Received:
    1,824
    Trophy Points:
    93
    Location:
    Iowa, USA
    An update on the progress. Took a break for several days for my 25th wedding anniversary but back in business now :) I have built out more of the windowing system to a point where I can now build the specific screens needed for the PQS. These are still very rudimentary but here is a sample:

    https://imgur.com/2JXG83u

    Shows the access button (which will be movable similar to the buff system), the main menu, the screens I have planned on the menu, and the initial active quests screen. The active quest screen will have more info such as version, author, and progress. It will allow you to cycle through the active quests, you can deactivate the quest, or bring up the journal for the quest.

    The journal will have the details of the quest where you can cycle through the quest entries. Deactivate will disable the quest so it no longer is running (it will still be loaded).

    Still no interface to the scaling yet, but scaling of UI is working as is hiding the UI when F9 is used.
     
    Last edited: Oct 11, 2021
  6. Eveara

    Eveara Avatar

    Messages:
    104
    Likes Received:
    294
    Trophy Points:
    18
    Mission accomplished: I'm dreaming.

    Can't wait to test it out!
     
    Paladin Michael, Time Lord and Tirrag like this.
  7. Tirrag

    Tirrag Avatar

    Messages:
    854
    Likes Received:
    1,824
    Trophy Points:
    93
    Location:
    Iowa, USA
    An update on the last several days of progress. More work was done on the core windowing system and happy to say that for now it is complete. Settings were implemented to allow scaling of the UI and also resetting the UI to default settings. The access button is now movable and soon to have a fancy icon drawn by one of my highly talented and artistic daughters (same one who did my profile image :)). More work was done on the quests window where it can now cycle through the installed quests, disable/enable quests, reset the quest for the player, and open the quest journal. A built-in dialog system has been created that can be used in-addition to or instead of conversationalists. A new event action has been created to start a dialog from an event. A confirmation window has been created to make sure the user wants to do critical things like reset the UI or reset a quest.

    Overall some really great progress. Still to do for the in-game UI are the journal window, the quest items window, and some tweaks to the quest window. Not much left really for the in-game UI. After that I will be working on more event criteria... primarily combat criteria and crafting criteria. I am really hoping that after next weekend I have the SotA side of this wrapped up.

    The time is nearing where I will start planning/implementing the web-based UI. While that is happening I would like one or two savvy and patient volunteers willing to start some Alpha testing. This will involve a lot of working in the quest definition file and not for the feint of heart. If that sounds like you feel free to PM me when I begin the search.
     
    Last edited: Oct 10, 2021
    Paladin Michael, Time Lord and Lained like this.
  8. tervalas

    tervalas Avatar

    Messages:
    50
    Likes Received:
    9
    Trophy Points:
    8
    Can't wait to see how you implement moving the windows. Thought I had it myself but still missing something. I'm sure it has to do with monitoring a value inside an event, but I really only get a little time every couple days to test new things out.
     
    Paladin Michael, Tirrag and Time Lord like this.
  9. Tirrag

    Tirrag Avatar

    Messages:
    854
    Likes Received:
    1,824
    Trophy Points:
    93
    Location:
    Iowa, USA
    greetings! the windows themselves i implemented a container "class" that holds all the controls and it has a moveTo function on it. that function in-turn moves all the internal controls so i just need to move the window and everything else moves.

    here is the basic premise of the move. im sure there are other ways but this is how i have done it. one example is a click and hold mouse button + drag, the other is hold left control click but not hold and keep left control held to move.

    Code:
    local tex = nil
    local client_width = 0
    local client_height = 0
    local test_button1 = nil
    local test_button2 = nil
    function ShroudOnStart()
        ui.onInit(function()
            tex = ui.texture.add(0, 0, "tiny.png")
            test_button1 = ui.guiButton.add(client.screen.width / 2 - 300, client.screen.height / 2 - 150, tex, "Click and hold mouse to move", "", 300, 300)
            test_button1:visible(true)
            test_button1.is_moving = false
            test_button1:onRepeat(function(mouse_x, mouse_y)
                test_button1.is_moving = true
            end)
            ui.onMouseMove(function(button_data, mouse_x, mouse_y)      
                if (test_button1.is_moving) then          
                    if (button_data[1] ~= "held") then
                        test_button1.is_moving = false
                    else
                        test_button1:moveTo(client.mouse.x, client.mouse.y)
                    end
                end
            end)
          
            test_button2 = ui.guiButton.add(client.screen.width / 2, client.screen.height / 2 - 150, tex, "Hold Left CTRL then Click to begin move.\n  Release mouse but hold CTRL while moving.", "", 300, 300)
            test_button2:visible(true)
            test_button2.is_moving = false
            test_button2.moving_timer = ui.timer.add(.0001, false, function()
                if test_button2.is_moving == true and ShroudGetKeyDown("LeftControl") then
                    test_button2:moveTo(client.mouse.x, client.mouse.y)
                else
                    test_button2.is_moving = false
                    ui.timer.pause(test_button2.moving_timer)
                end
            end),
            test_button2:onClick(function(mouse_x, mouse_y)
                if test_button2.is_moving == true then
                    test_button2.is_moving = false
                else
                    if ShroudGetKeyDown("LeftControl") then
                        test_button2.is_moving = true
                        ui.timer.resume(test_button2.moving_timer)
                    end
                end      
            end)
        end)
    end
    function ShroudOnConsoleInput(type, src, msg) end
    function ShroudOnGUI() end
    function ShroudOnUpdate() end
    
     
    Last edited: Oct 10, 2021
    Paladin Michael and Time Lord like this.
  10. Eveara

    Eveara Avatar

    Messages:
    104
    Likes Received:
    294
    Trophy Points:
    18
    *raises her hand*
    (Assuming I can afford the investment, time-wise – and assuming you won't mind the fact that my English can get approximative at times.)
     
    Paladin Michael and Time Lord like this.
  11. tervalas

    tervalas Avatar

    Messages:
    50
    Likes Received:
    9
    Trophy Points:
    8
    Couple things I didn't even think about from that. Thanks!
     
    Paladin Michael and Time Lord like this.
  12. Tirrag

    Tirrag Avatar

    Messages:
    854
    Likes Received:
    1,824
    Trophy Points:
    93
    Location:
    Iowa, USA
    finished up the quests page last night. also implemented a new event criteria related to the built-in dialog system.

    great! hopefully that gives you some forward momentum :) of course there are more ways (the beauty of coding). one easy way that i dont use is a single click to start moving and single click to stop. in the BMS mod, since you can place icons anywhere in the UI it was too easy to accidentally click an icon when playing the game and i would end up with a rogue icon following my mouse during a fight :)

    wish there was a heart emoji in this board! thank you :)
     
    Paladin Michael, Time Lord and Eveara like this.
  13. Tirrag

    Tirrag Avatar

    Messages:
    854
    Likes Received:
    1,824
    Trophy Points:
    93
    Location:
    Iowa, USA
    just a quick update. though i was side-tracked a couple of days checking on the BMS mod and Linux, progress is still moving forward. currently deep into the journal entries interface and inner-workings of journal/tasks. things are going well! it was a fun moment to see the little alert icon overlay pop on when a new journal entry was added :) hoping to have a really fruitful weekend!
     
  14. Tirrag

    Tirrag Avatar

    Messages:
    854
    Likes Received:
    1,824
    Trophy Points:
    93
    Location:
    Iowa, USA
    another quick update. i didnt get the momentum i had hoped over the weekend. my youngest daughters bday festivities overtook most of the weekend in addition to being unable to login to the QA server (where i do development). still, i have some progress to report. the Quest, Journal, and Quest Items screens and functionality are wrapped up. i only have some criteria and actions to go and i can get this alpha stamped. some really exciting stuff :) i did alter a bit the tasks functionality, shortening it to a journal entry can optionally be a task.

    some may wonder why i havent posted screenshots/vids of late (PQS is not vaporware i promise :)). there is currently a bug in QA that causes all the window text to be behind the window background image. essentially it doesnt look good and is very hard to read the text so i dont wish to release anything visual while that is the case. im hoping that it gets resolved soon and once it does i will record the latest updates. maybe @Elgarion can confirm it's on the dev radar since there have been no indications in the bug entry that it is.
     
    Last edited: Oct 18, 2021
    Time Lord and FrostII like this.
  15. Tirrag

    Tirrag Avatar

    Messages:
    854
    Likes Received:
    1,824
    Trophy Points:
    93
    Location:
    Iowa, USA
    i have started writing a document describing the data format that defines a quest. this is what will be needed by the alpha testers in order to test the system. NOTE: it is still a WIP.

    PQS Quest Data File Format

    please keep in mind that the ultimate goal is for the web system to build this file. only due to that part not being created yet will quest builders need to work directly in the quest data file.
     
    Last edited: Oct 18, 2021
  16. Tirrag

    Tirrag Avatar

    Messages:
    854
    Likes Received:
    1,824
    Trophy Points:
    93
    Location:
    Iowa, USA
    The label zindex bug on QA has been resolved (yay!). Over the last few days I have completed the file format document to this point and will be continually updating it as I add more. I have made some structural changes to the code. Also implemented important dialog topics which will make their option a gold color and an option to only show a dialog topic if a quest variable is set to 1. Added timer actions that you can start/stop/reset and use with the event criteria.

    As promised I whipped together a quick gif showing off some of the new things including the dialog system. Going to work on more event actions and criteria this weekend.

    https://imgur.com/VGdyvfg
     
    Last edited: Oct 22, 2021
    Time Lord likes this.
  17. Tirrag

    Tirrag Avatar

    Messages:
    854
    Likes Received:
    1,824
    Trophy Points:
    93
    Location:
    Iowa, USA
    i was able to get more love time on this last night. the only thing remaining before i open this up is combat related event criteria. with nothing major on the docket for me this weekend i should be able to wrap-up the SotA side of this wonderful beast!
     
    Time Lord likes this.
  18. Tirrag

    Tirrag Avatar

    Messages:
    854
    Likes Received:
    1,824
    Trophy Points:
    93
    Location:
    Iowa, USA
    well i struck a little gold in that as i started to look into combat related event criteria i remembered an unfinished mod i built for detailed combat stats. i was able to pull the core functions from that and created a new combat log parsing module i can utilize. puts me way ahead of where i wanted to be on the combat criteria task! thank you to my earlier self for doing the heavy lifting :D
     
    Time Lord and Lained like this.
  19. Tirrag

    Tirrag Avatar

    Messages:
    854
    Likes Received:
    1,824
    Trophy Points:
    93
    Location:
    Iowa, USA
    ok... here we go :) anyone that is interested in trying this out in its alpha state perk up! looking at you @Eveara ;)

    here is the core system:

    https://shroudoftheavatar.tools/player_quest_system_v.6a.zip

    this will need to be decompressed to your Lua folder. if you dont know where that is use /datafolder in chat and you will see the Lua folder in there. once you get it placed correctly you should see player_quest_system.lua and a pqs folder inside of your lua folder.

    be sure your chat tab has Lua enabled. in the chat use /lua reload and you should see informational messages indicating that the system is active. if you dont, we will need to doublecheck everything. if it works, you will also see the PQS button in your lower-right. you can click and a menu should show allowing you to view quests (none there yet), settings, and about.

    once that is all happy, its time to get on with getting the quest files ready. download the quest template:

    https://shroudoftheavatar.tools/player_quest_system_template_v.5a.zip

    again, you will need to decompress to your Lua folder. this time you will see pqs_template.lua and pqs/quests/pqs_template.ini.

    pqs_template.ini is the quest data file. it has TODO messages at the top and in the quest section that will need to be completed and replaced before you do a /lua reload to get the quest loaded.

    if all is good, once you do the /lua reload you should see a message in the chat that your quest has loaded. you should also now see it in the quests window from the PQS menu.

    at this point its really up to you to utilize the tools of the framework to build out the quest using the data definition file above. the framework is designed to be very flexible and it may not be exactly apparent how to accomplish what you want to accomplish. i want this to be a very collaborative process so please, please, please ask any and all questions.
     
    Last edited: Nov 5, 2021
    Time Lord, Anpu and that_shawn_guy like this.
  20. Tirrag

    Tirrag Avatar

    Messages:
    854
    Likes Received:
    1,824
    Trophy Points:
    93
    Location:
    Iowa, USA
    just wanted to tack on that at this point it has pretty much everything i could foresee being needed. obviously there could be more based on tester need. also the icon is not quite done yet.

    im going to start planning how i want the web interface to go and hopefully work closely with testers to fix any issues or implement anything we find missing.
     
    Time Lord likes this.