Author Topic: [RESOLVED] Help with creating a 'weave queue' script for FFXIV  (Read 1211 times)

TwilightThrenody

  • Newbie
  • *
  • Posts: 4
[RESOLVED] Help with creating a 'weave queue' script for FFXIV
« on: December 06, 2021, 12:33:19 PM »
Hi! I'm working on an all-in-one group of linked profiles that work for all classes in FFXIV for folks with disabilities (like myself) or those who want to have fun with it, and I'm nearing completion of the first class' code, Sage. I need help with some lines of code that handle 'weave queues', abilities that you can use in between the cooldown of primary ones and would queue up with VoiceAttack.

My current implementation uses 2 declared slots, which are set and executed on specific conditions shown below, but, is there a better way to do this? I'd like it if I could create a system that:
  • Generates the necessary slot variables and assigns them as needed on invocation.
  • Reads and executes the weaves in order of receiving.
  • Checks for double-weave conditions (executes a group of two instead of one between a cooldown).
I thought of using dynamically-generated variables, but I wouldn't even know how to begin with that. Is it possible? Any help would be tremendously appreciated!

EDIT: I figured it out on my own! I will post my solution later today as a reply to this topic for those who run into a similar problem and find this.

Swiftcast, a single weave:
Code: [Select]
Begin Condition : ([isCheckingForWeave] Equals True AND [executingWeave] Equals False)
  # Checks if the first slot is empty and the second one is not queued with itself. #
  Begin Condtion : ([weaveQueueSlot1] Has Not Been Set AND [weaveQueueSlot2] Does Not Equal '{CMD}')
    Set text [weaveQueueSlot1] to '{CMD}'
  # Checks if the first slot is full and not already queued with itself, sending it to the second slot instead. #
  Else if : ([weaveQueueSlot 1] Has Been Set AND [weaveQueueSlot1] Does Not Equal '{CMD}' AND [weaveQueueSlot2] Has Not Been Set)
    Set text [weaveQueueSlot2] to '{CMD}'
  End Condition
Else
  # Activates Swiftcast keybind. #
  Execute command, '.KB Hotbar | Swiftcast' (and wait until it completes)
  # Informs cooldown actions that their cast times should be modified to instant and available for double-weave on next rotation. #
  Set Boolean [swiftcastActive] to True
End Condition

SwiftDream, a double-weave of Swiftcast and Lucid Dreaming:
Code: [Select]
Begin Condition : ([isCheckingForWeave] Equals True AND [executingWeave] Equals False)
  # Checks if both slots are empty
  Begin Condition : ([weaveQueueSlot1] Has Not Been Set AND [weaveQueueSlot2] Has Not Been Set)
    Set text [weaveQueueSlot1] to 'Swiftcast'
    Set text [weaveQueueSlot2] to 'Lucid Dreaming'
  # Checks if the 1st slot is already set and 2nd is open for the second weave.
  Else if : ([weaveQueueSlot1] Equals 'Swiftcast' AND [weaveQueueSlot2] Has Not Been Set)
    Set text [weaveQueueSlot2] to 'Lucid Dreaming'
  End Condition
End Condition

Trigger section of .Function Weave Queue, reset and executed on every manual keypress or looped in vocally-triggered auto-combo:
Code: [Select]
# Informs weaves that it is executing, modifying called weave commands to use keypresses instead of setting queue slots. #
Set Boolean [executingWeave] to True
# Checks if a double-weave can be issued in between a cooldown, otherwise it executes them in sequence of (cooldown) -> (weave1) -> cooldown -> (weave2). #
Begin Condition : ([weaveQueueSlot1] Has Been Set AND [weaveQueueSlot2] Has Been Set AND [~canDoubleWeave] Equals True)
  Execute command, '{TXT:weaveQueueSlot1}' (by name) (and wait until it completes)
  Set text [weaveQueueSlot1] to [Not Set]
  Pause 0,5 seconds
  Execute command, '{TXT:weaveQueueSlot2}' (by name) (and wait until it completes)
  Set text [weaveQueueSlot2] to [Not Set]
Else if Text Compare : [weaveQueueSlot1] Has Been Set
  Execute command, '{TXT:weaveQueueSlot1}' (by name) (and wait until it completes)
  Set text [weaveQueueSlot1] to [Not Set]
Else if Text Compare : [weaveQueueSlot2] Has Been Set
  Execute command, '{TXT:weaveQueueSlot2}' (by name) (and wait until it completes)
  Set text [weaveQueueSlot2] to [Not Set]
End Condition
# Weaves can now be queued again.
Set Boolean [executingWeave] to False
« Last Edit: December 06, 2021, 04:39:56 PM by Butternubs »

Gary

  • Administrator
  • Hero Member
  • *****
  • Posts: 2827
Re: [RESOLVED] Help with creating a 'weave queue' script for FFXIV
« Reply #1 on: December 06, 2021, 07:56:25 PM »
That's awesome!  Good job there :)

Sorry for the late reply - been fighting to get to a pc all day long o_O

SemlerPDX

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 280
  • Upstanding Lunatic
    • My AVCS Homepage
Re: [RESOLVED] Help with creating a 'weave queue' script for FFXIV
« Reply #2 on: December 06, 2021, 11:57:25 PM »
Well done!!

TwilightThrenody

  • Newbie
  • *
  • Posts: 4
Re: [RESOLVED] Help with creating a 'weave queue' script for FFXIV
« Reply #3 on: December 12, 2021, 12:24:57 PM »
Thank you! Sorry for not posting the solution sooner, had some RSI issues! The solution was I overcomplicated things! VoiceAttack actually has an 'Enqueue Command' feature that is perfect for this type of script. Here's the new code that takes advantage of this:

Swiftcast, a single weave:
Code: [Select]
Play sound, 'internal:Fwip' # Gives audio feedback to user, letting them know it's queued or pressed #
Begin Boolean Compare : [isCheckingForWeave] Equals True # Checks if the commands are looking for weaves, otherwise executes keybind by voice. #
  Enqueue command, '.KB Hotbar | Swiftcast' into [weaveQueue]
Else
  Execute command, '.KB Hotbar | Swiftcast' (and wait until it completes)
End Condition

Keybind code invoked by Swiftcast:
Code: [Select]
Begin Text Compare: [{QUEUEACTIVECMD:weaveQueue}] Equals '{CMD}' # A neat trick to get a command to act differently if it's executing in queue! In this case it informs commands that the next cast is instant. #
  Set Boolean [swiftcastActive] to True
End Condition
Press down Left Shift + = keys
Pause a variable number of seconds [keyPressDelay] # A variable set by user voice, allows them to adjust for their liking. #
Release Left Shift + = keys

SwiftDream, a double-weave of Swiftcast and Lucid Dreaming:
Code: [Select]
Play sound, 'internal:Fwip'
Begin Boolean Compare : [isCheckingForWeave] Equals True
  Enqueue command, '.KB Hotbar | Swiftcast' into [weaveQueue] # It's as simple as adding more things to the queue! #
  Enqueue command, '.KB Hotbar | Lucid Dreaming' into [weaveQueue]
Else
  Execute command, '.KB Hotbar | Swiftcast' (and wait until it completes)
  Pause 0,7 seconds
  Execute command, '.KB Hotbar | Lucid Dreaming' (and wait until it completes)
End Condition

Trigger section of .Function Weave Queue:
Code: [Select]
Set integer [weavesInQueue] value to the converted value of {QUEUECMDCOUNT:weaveQueue}
Begin Integer Compare : [weavesInQueue] Is Greater Than 0 # Executes if there are any weaves queued, otherwise skips. #
  Start queue [weaveQueue] # Starts the queue, executing the first weave in order, and then the next on the next iteration of the loop, and so on. #
  Pause 0,05 seconds
  Pause queue [weaveQueue] # Done to prevent all the weaves executing at once, pausing it ensures it only executes the one it needs. #
  Begin Boolean Compare : [~canDoubleWeave] Equals True # If an ability is used that can double-weave, it executes two in the iteration instead of one, in the order they're received. #
    Pause 0,65 seconds
    Start queue [weaveQueue]
    Pause 0,05 seconds
    Pause queue [weaveQueue]
    Set decimal [~postWeaveCooldown] to [~postWeaveCooldown] minus 0,7
  End Condition
  Set Boolean [~canDoubleWeave] to False
End Condition

As you can see, much simpler! Hope anyone who comes across this finds this useful! ♥