• Visit Rebornbuddy
  • Visit Panda Profiles
  • Visit LLamamMagic
  • help setting fate poi

    Discussion in 'Community Developer Forum' started by kaihaider, Nov 19, 2014.

    1. kaihaider

      kaihaider Community Developer

      Joined:
      May 18, 2010
      Messages:
      1,325
      Likes Received:
      5
      Trophy Points:
      38
      Code:
                  
      if (BotManager.Current.Name == "Fate Bot" && (Poi.Current.Unit as BattleCharacter) != null && Poi.Current.Type == PoiType.Kill
                       && ((Poi.Current.Unit as BattleCharacter).FateId == 0 || Poi.Current.Unit.IsFateGone)
                      && !FateManager.WithinFate && AttemptPoiChange < DateTime.UtcNow.TimeOfDay)
      {
           Logging.Write(Colors.SkyBlue, "[Patrol] Searching for Fate");
           AttemptPoiChange = DateTime.UtcNow.TimeOfDay + TimeSpan.FromSeconds(5);
           var activeFates = FateManager.ActiveFates.Where(fate => fate.IsValid 
                && (FatebotSettings.Instance.MonsterSlayingEnabled && fate.Icon == FateIconType.Battle
                  || FatebotSettings.Instance.EscortEnabled && (fate.Icon == FateIconType.ProtectNPC || fate.Icon == FateIconType.ProtectNPC2)
                  || FatebotSettings.Instance.BossEnabled && fate.Icon == FateIconType.Boss && FatebotSettings.Instance.BossPercentRequired < fate.Progress)
                && FatebotSettings.Instance.MinLevel <= fate.Level && fate.Level <= (Core.Me.ClassLevel +FatebotSettings.Instance.MaxLevel)).OrderBy(fate => Core.Me.Distance(fate.Location)) .Take(8).ToArray();
          if (activeFates.Any())
          {
             var navReq = activeFates.Select(r => new CanFullyNavigateTarget { Id = r.Id, Position = r.Location });
             var resultsArray = Navigator.NavigationProvider.CanFullyNavigateTo(navReq);
             if (resultsArray != null)
             {
                 var result = resultsArray.FirstOrDefault(r => r.CanNavigate == 1);
                  Poi.Current = new Poi(activeFates.FirstOrDefault(z => result != null && z.Id == result.Id), PoiType.Fate);
                  Logging.Write(Colors.SkyBlue, "[Patrol] Attempting to Set Fate");
                  AttemptPoiChange = DateTime.UtcNow.TimeOfDay + TimeSpan.FromSeconds(15);
             }
          }
      }
      typically it will attempt to set poi when a fate appears, fatebot will clear poi saying it's not valid then fatebot will set the new fate as poi

      Please tell me what I'm doing wrong :S

      btw, I also sometimes get memory read errors from the .FateId
       

      Attached Files:

      Last edited: Nov 19, 2014
    2. mastahg

      mastahg Administrator Staff Member

      Joined:
      Feb 27, 2011
      Messages:
      5,343
      Likes Received:
      383
      Trophy Points:
      83
      For the memory errors, your checking paramters on an object that might be invalid, so after making sure the object is null you need to make sure !obj.IsInvalid.

      As for the poi stuff, its getting cleared due to internal code not currently exposed in the current version. Fatebot assumes a variable will be updated with the currentfate and since its not it clears the poi. Ill change this for next version.
       
    3. kaihaider

      kaihaider Community Developer

      Joined:
      May 18, 2010
      Messages:
      1,325
      Likes Received:
      5
      Trophy Points:
      38
      awesomeness on both counts, thanks ^_^
       

    Share This Page