• Visit Rebornbuddy
  • CommonTasks.MountUp exiting early

    Discussion in 'Community Developer Forum' started by iyake, Aug 18, 2015.

    1. iyake

      iyake Member

      Joined:
      Oct 19, 2014
      Messages:
      143
      Likes Received:
      5
      Trophy Points:
      18
      CommonTasks.MountUp is exiting early I think.

      I don't really have a way to post a log, but something like

      Code:
      await CommonTasks.MountUp(1);
      
      MovementManager.MoveForwardStart();
      
      will start casting the chocobo mount but also immediately start moving forward and canceling the mount cast.
       
    2. mastahg

      mastahg Administrator Staff Member

      Joined:
      Feb 27, 2011
      Messages:
      5,232
      Likes Received:
      364
      Trophy Points:
      83
      Are you using it within a coroutine properly? It'll behave like that if your not calling it from within an async block.

      Can you post the entire chunk your using?
       
    3. iyake

      iyake Member

      Joined:
      Oct 19, 2014
      Messages:
      143
      Likes Received:
      5
      Trophy Points:
      18
      Compiler wouldn't let you await outside of an async block, but here's the method that I was running into the problem:

      Code:
              public async Task<bool> Fly() {
                  bool moving = false;
      
                  // can't mount continue on tree
                  if (Core.Me.InCombat && !Core.Me.IsMounted) return false;
      
                  await CommonTasks.MountUp(Convert.ToUInt32(MountId));
      
                  MovementManager.SetFacing2D(Location);
      
                  await CommonTasks.TakeOff();
      
                  if (Altitude > float.MinValue) {
                      if (Core.Me.Location.Y > Altitude + 1f) {
                          await CommonTasks.DescendTo(Altitude);
                      } else if (Core.Me.Location.Y < Altitude - 1f) {
                          await CommonTasks.AscendTo(Altitude);
                      }
                  }
      
                  while (Core.Me.Location.Distance2D(Location) > Radius) {
                      if (!moving) {
                          MovementManager.MoveForwardStart();
                          moving = true;
                      }
                      MovementManager.SetFacing2D(Location);
                      await Coroutine.Yield();
                  }
      
                  MovementManager.MoveForwardStop();
      
                  if (LandAfter)
                      await CommonTasks.Land();
      
                  _done = true;
                  return true;
              }
      
      replacing it with a custom mount method:

      Code:
              public static async Task<bool> Mount(int MountId) {
                  if (MountId == 0) return true;
      
                  if (!Core.Player.IsMounted) {
                      Actionmanager.Mount(Convert.ToUInt32(MountId));
                      await Coroutine.Wait(3000, () => Core.Me.IsMounted);
                  }
      
                  return true;
              }
      
      worked
       
    4. mastahg

      mastahg Administrator Staff Member

      Joined:
      Feb 27, 2011
      Messages:
      5,232
      Likes Received:
      364
      Trophy Points:
      83
      Takeoff mounts up for you.
       
    5. mastahg

      mastahg Administrator Staff Member

      Joined:
      Feb 27, 2011
      Messages:
      5,232
      Likes Received:
      364
      Trophy Points:
      83
      Yea you should leave the mounting up logic to take off as it checks to make sure you can fly with the chocobo and if not it dismounts and dismisses the companion if present and gets on the black chocobo. Also, you should be checking the return value of takeoff as you are currently assuming that it always succeeds which is not the case.
       
    6. mastahg

      mastahg Administrator Staff Member

      Joined:
      Feb 27, 2011
      Messages:
      5,232
      Likes Received:
      364
      Trophy Points:
      83
      I was able to replicate the issue. Looks like I inverted an if on accident. Pushing a new build now.
       

    Share This Page