• Visit Rebornbuddy
  • Walter, Joe, anyone Help! Trying to understand Framelocking

    Discussion in 'Community Developer Forum' started by alltrueist, May 15, 2014.

    1. alltrueist

      alltrueist Active Member

      Joined:
      Dec 10, 2012
      Messages:
      1,424
      Likes Received:
      16
      Trophy Points:
      38
      ***DISCLAIMER: I have no coding knowledge at all. Everything I've done with PureSWTOR has either been copy/pasting shit from Pure, or using Ama's framework. I lack any ability to figure this problem out myself, so I need a smart person to just show me once and I can copy that over to everything else***

      Hey all,
      I think I'm the last person working on Pure, which is probably not a good sign for the routine :D

      Anyway, I've been getting sick of the way the bot will frequently skip higher-priority actions and get "stuck" repeat-casting a lower-priority spell. The best examples I can think of for this behavior are with Vigilance Guardians or Balance Shadows (although it happens with almost every class): the Guardian will keep casting Slash even though Master Strike/Plasma Brand/Overhead Slash/Blade Storm are off cooldown; the Shadow will keep casting Double Strike even after the DoTs have dropped off (he's supposed to re-cast DoTs with < 3 seconds left). There's nothing I can do code-wise to fix this issue, as I've tried to lock out Slash or Double Strike when the DoTs aren't up, but this just causes massive issues when the DoTs miss-- and the bot even ignores this req sometimes!

      So I've been looking into Framelocking. I know Walter has mentioned this several times, which is why it came to mind. On several occasions, Walter has mentioned that Ama basically ported the Pure code from Honorbuddy, so I looked at PureRotation in depth, but couldn't find much about Framelocking. All I found was this bit of code from the RotationBehaviors file:
      Code:
      #region Nested type: LockSelector
      
              /// <summary>
              /// This behavior wraps the child behaviors in a 'FrameLock' which can provide a big performance improvement
              /// if the child behaviors makes multiple api calls that internally run off a frame in WoW in one CC pulse.
              /// </summary>
              private class LockSelector : PrioritySelector
              {
                  public LockSelector(params Composite[] children)
                      : base(children)
                  {
                  }
      
                  public override RunStatus Tick(object context)
                  {
                      using (StyxWoW.Memory.AcquireFrame())
                      {
                          return base.Tick(context);
                      }
                  }
              }
      
              #endregion Nested type: LockSelector
      I ported that code into PureSWTOR, and it hasn't caused any crashes or problems:

      Code:
      private class LockSelector : PrioritySelector
              {
                  public LockSelector(params Composite[] children)
                      : base(children)
                  {
                  }
      
                  public override RunStatus Tick(object context)
                  {
                      using (BuddyTor.Memory.AcquireFrame())
                      {
                          return base.Tick(context);
                      }
                  }
              }
      But it also hasn't fixed anything. I tried putting this code into the RotationBase file AND into the individual Class file (Shadow Balance for testing purposes). In both cases the rotation ran fine, but I noticed not changes.

      If I understand it correctly, Framelocking should cause the bot to freeze the game's frames as it completes each pass through the routine. This should potentially stop the issues I outlined above, as the bot can't get "stuck" because it only moves on after the ability has been cast.

      What I need help with is understanding how the code I've found interacts with actual Framelocking. I imagine there's some element I'm missing. Google searches have been useless, and I've investigated TreeSharp, but only found something like
      Code:
      using (new FrameLock(true))
      but I don't know how or where to utilize that, and I didn't see that function used at all in PureRotation.

      So, does anyone know how we might Framelock PureSWTOR? I'd love for this routine to be as great as it can be, but I simply lack the coding knowledge necessary. I appreciate any and all help, but I find singular examples best as I can then learn through seeing/doing. As I said earlier, my knowledge of coding isn't strong enough to get into an abstract discussion :(

      Thanks for all you do to keep this bot running.
       
    2. w118cmh

      w118cmh New Member

      Joined:
      Feb 10, 2010
      Messages:
      50
      Likes Received:
      3
      Trophy Points:
      0
      Hey man,

      Are you saying you just added the code into one of the class files, or have you actually replaced the PrioritySelectors in the Routine with the new LockSelector?
       
    3. w118cmh

      w118cmh New Member

      Joined:
      Feb 10, 2010
      Messages:
      50
      Likes Received:
      3
      Trophy Points:
      0
    4. alltrueist

      alltrueist Active Member

      Joined:
      Dec 10, 2012
      Messages:
      1,424
      Likes Received:
      16
      Trophy Points:
      38
      That's just it: when I was diving around in PureRotation, I couldn't figure out where they were using the Lockselectors. So for now, I just have that snipped of code in the BaseRotation file.

      It's so frustrating, because I know I need to use the LockSelector, but I have no idea how. What I'm hoping is that someone can either post some code or point me to some code so I can see how it's done. After that, I think I can replicate it. I hate knowing that I don't know something, but not knowing how to figure it out (if that makes sense).
       
    5. alltrueist

      alltrueist Active Member

      Joined:
      Dec 10, 2012
      Messages:
      1,424
      Likes Received:
      16
      Trophy Points:
      38
      Reading that makes it seem like all I would need to do would be to wrap my PrioritySelector in the using (new FrameLock()) code. That can't be right, that would be way too easy (which means someone would have done it before me). So what else needs to happen besides the base code I have and wrapping in FrameLock() code?
       
    6. w118cmh

      w118cmh New Member

      Joined:
      Feb 10, 2010
      Messages:
      50
      Likes Received:
      3
      Trophy Points:
      0
      Take a look at this:

      http://www.thebuddyforum.com/honorbuddy-forum/botbases/45436-botbase-raidbot-30fps-cc-execution.html

      It's an old BotBase Apoc did for HonorBuddy, that really is what you're looking for.

      If I'm looking at this correctly, just replace the PrioritySelector with the new LockSelector class where the PVERotation (or whatever it's called. Sorry, at work) composite is created. In Pure, that should force all of the logic (healing, Combat, ranged, whatever) to be executed within the same frame.

      You can just try it in the specs you specified to see if it makes a difference.
       
    7. alltrueist

      alltrueist Active Member

      Joined:
      Dec 10, 2012
      Messages:
      1,424
      Likes Received:
      16
      Trophy Points:
      38
      Thanks man. I replaced the PrioritySelectors (all of them) with LockSelectors in the individual class routine (Balance Shadows are my test subject, for the DoTs that keep dropping). I'm going to run some tests this afternoon and see if that fixed it. If not, I may still go ahead and framelock the class routines just for fun.
       
    8. alltrueist

      alltrueist Active Member

      Joined:
      Dec 10, 2012
      Messages:
      1,424
      Likes Received:
      16
      Trophy Points:
      38
      UPDATE:

      Good news: the framelocking worked! Immediately, I gained 400 dps on my Vigilance Guardian (he was doing ~1650dps before framelocking, now he does ~2000+ in crappy 156 gear), and he no longer "sticks" on certain abilities. The Priority Selector functions beautifully, and he always hits the right moves in the right order. This is a huge improvement.

      Bad news: Framelocking did not fix either the Shadow/Balance DoT issues or the Healing Targeting issues. I took my Scoundrel to Oricon, and ran into that pack near the entrance with the 2 golds (Crazed Jedi and Crazed Sith). He was healing great, but then he got stuck healing himself, and kept spamming Slow-release Medpac on himself as Bowdar slowly died. Obviously, the bot knows it needs to heal Bowdar, and it's trying, but for some reason it's not changing targets. We will need to investigate what the heck is causing this, because it invalidates Pure for healing classes until fixed (at least in groups).

      The DoT thing I think I can work around by making a new Decorator just for DoTs and putting it above the DPS section of the rotation. Then, I'll put a req in the DPS section that the target has DoTs on it, and that should be good enough. I'd still love to figure out why the DoT stuff isn't working, but I suspect it has to do with the way Ama had to write the code to work around Same-Name debuffs (this is a huge problem in SWTOR because unlike WoW we can't get SpellIDs).

      If anyone has any idea for how to work with targeting, I'd love to hear them. Thanks to w118cmh for your help so far!
       
    9. walter

      walter Active Member

      Joined:
      Jun 25, 2012
      Messages:
      1,112
      Likes Received:
      10
      Trophy Points:
      38

      I have been gone on work trip for last few weeks and did not see this post FYI.

      Big issue with debuff names is how the are classified in pure but that can be fixed with love. Also some SWTOR patches changed a lot of how the combat works and I think buddywing will need a little update to reflect some of those changes.

      Great work on framelocking but are you running into issues with bot working for long periods of time? Was an issue joe had and myself had at times. Big thing framelocking does is smooths out combat. Did this on honorbot routine I did years back. Just swtor spaghetti coding you will see the issues that will come up over time.

      Wingit and other routines had the same issue.

      Framelocking does stop lots of object error and get.health bug (from stealth) at times doesn't come up as much. Only fix I ever found that worked was having a reset in routine just in case.


      TreeSharp is great stuff if people would read how it works! :D!
       
      Last edited: May 26, 2014
    10. alltrueist

      alltrueist Active Member

      Joined:
      Dec 10, 2012
      Messages:
      1,424
      Likes Received:
      16
      Trophy Points:
      38
      I've noticed that on slower computers (I had my laptop for a bit while my main PC was in the shop) Framelocking doesn't play nice with AFK routines. I tried not Framelocking the out-of-combat stuff, and saw an improvement, but I haven't run it long enough to know if that solved the problem or not.

      Do you have an idea for how to fix the debuff issues? Obviously the problem stems back to over a year ago when we were trying to figure out how to handle same-name debuffs. Unlike WoW, we don't have spell IDs to work with, so when two different abilities put a DoT on the target with the same name (Burning (Physical), or Crushed (Physical), for examples) there's no way to work around that. The Spell.DoT function that Ama wrote was a kludge fix, so if you get any good ideas for how we could handle same-name debuffs, I'm all ears.

      In the other post you said that Ama's BotLoader does the job well, and you're totally right on that. I think the larger issue is the way BW handles companions, because that's the only place we're seeing problems anymore. We may just have to cut our losses, because the fixes we're trying to implement aren't working so far, and the bot functions fine in a full party healing other players (with BotLoader).
       

    Share This Page