• Visit Rebornbuddy
  • On Death ?

    Discussion in 'Community Developer Forum' started by Thecamel, Nov 10, 2014.

    1. Thecamel

      Thecamel Community Developer

      Joined:
      Aug 8, 2012
      Messages:
      2,036
      Likes Received:
      46
      Trophy Points:
      48
      Hi Devs,

      id like to modify the following plugin,

      Code:
      using ff14bot;
      using ff14bot.Helpers;
      using ff14bot.Interfaces;
      using ff14bot.Managers;
      using System;
      using System.Collections.Generic;
      using System.Linq;
      using System.Threading;
      
      
      // The majority of this code was originally from Wheredidigo's FateHunter. I just modified
      // it and changed it a bit so that it only had one zone per level range and moved you there when you
      // met the appropriate level range.
      
      namespace FateAutoLeveler
      {
          class FateAutoLeveler : IBotPlugin
          {
              #region Necessary Stuff
      
              public string Author { get { return "Zamphire"; } }
              public Version Version { get { return new Version(1, 0); } }
              public string Name { get { return "FateAutoLeveler"; } }
              public string Description { get { return "Brings you to the correct zone according to your level."; } }
              public bool WantButton { get { return false; } }
              public string ButtonText { get { return "FateAutoLeveler"; } }
              public void OnButtonPress() { throw new NotImplementedException(); }
              public bool Equals(IBotPlugin other) { throw new NotImplementedException(); }
      
              #endregion
      
              #region Variables
              public static Dictionary<string, uint> _availableLocations = new Dictionary<string, uint>();
              Random _random = new Random(int.Parse(Guid.NewGuid().ToString().Substring(0, 8), System.Globalization.NumberStyles.HexNumber));
      
              private int _currentLevel;
              public int CurrentLevel
              {
                  get
                  {
                      if (_currentLevel == 0)
                      {
                          _currentLevel = (int)Core.Player.ClassLevel;
                      }
                      return _currentLevel;
                  }
              }
      
              #endregion
      
              #region On Methods
      
              public void OnPulse()
              {
                  if (BotManager.Current.Name == "Fate Bot")
                  {
                      if (_currentLevel == 0)
                      {
                          ChangeZone();
                      }
                      if (CurrentLevel < Core.Player.ClassLevel)
                      {
                          _currentLevel = Core.Player.ClassLevel;
                          ChangeZone();
                      }
                  }
              }
              public void OnInitialize()
              {
                  foreach (var location in WorldManager.AvailableLocations)
                  {
                      _availableLocations.Add(location.Name, location.AetheryteId);
                  }
              }
              public void OnShutdown() { }
              public void OnEnabled() { }
              public void OnDisabled() { }
      
              #endregion
      
              #region Helper Methods
      
              private void ChangeZone()
              {
                  var _nextLocation = NextLocation();
      
                  if (_nextLocation == 0)
                  {
                      Logging.Write("[FateAutoLeveler] No Valid Locations to Teleport to.");
                      return;
                  }
                  if (WorldManager.ZoneId == _nextLocation)
                  { return; }
      
                  TreeRoot.Stop();
      
                  if (Core.Player.IsMounted)
                  {
                      Actionmanager.Dismount();
                      Thread.Sleep(5000);
                  }
                  Logging.Write("Moving to " + _availableLocations.FirstOrDefault(x => x.Value == _nextLocation).Key);
                  WorldManager.TeleportById(_nextLocation);
                  Thread.Sleep(15000);
                  TreeRoot.Start();
              }
      
              private uint NextLocation()
              {
                  var currentLevel = (int)Core.Player.ClassLevel;
      
                  if (currentLevel >= 1 && currentLevel < 15)
                  {
                      return GetZone1Thru15();
                  }
                  else if (currentLevel >= 15 && currentLevel < 20)
                  {
                      return GetZone15Thru20();
                  }
                  else if (currentLevel >= 20 && currentLevel < 25)
                  {
                      return GetZone20Thru25();
                  }
                  else if (currentLevel >= 25 && currentLevel < 30)
                  {
                      return GetZone25Thru30();
                  }
                  else if (currentLevel >= 30 && currentLevel < 35)
                  {
                      return GetZone30Thru35();
                  }
                  else if (currentLevel >= 35 && currentLevel < 40)
                  {
                      return GetZone35Thru40();
                  }
                  else if (currentLevel >= 40 && currentLevel < 50)
                  {
                      return GetZone40Thru50();
                  }
                  else
                  { return 0; }
              }
      
              #region Get Zone By Level
              private uint GetZone1Thru15()
              {
                  var zoneList = new List<uint>();
                  //Middle La Noscea - Summerford Farms
                  if (_availableLocations.ContainsKey("summerford farms"))
                  {
                      zoneList.Add(_availableLocations["summerford farms"]);
                  }
                  if (zoneList.Count <= 0)
                  {
                      return 0;
                  }
      
                  return zoneList[_random.Next(0, zoneList.Count)];
      
              }
              private uint GetZone15Thru20()
              {
                  var zoneList = new List<uint>();
      
                  //Western La Noscea - Aleport
                  if (_availableLocations.ContainsKey("aleport"))
                  {
                      zoneList.Add(_availableLocations["aleport"]);
                  }
                  if (zoneList.Count <= 0)
                  {
                      return 0;
                  }
      
                  return zoneList[_random.Next(0, zoneList.Count)];
              }
              private uint GetZone20Thru25()
              {
                  var zoneList = new List<uint>();
                  //Eastern Thanalan - Camp Drybone
                  if (_availableLocations.ContainsKey("camp drybone"))
                  {
                      zoneList.Add(_availableLocations["camp drybone"]);
                  }
                  if (zoneList.Count <= 0)
                  {
                      return 0;
                  }
      
                  return zoneList[_random.Next(0, zoneList.Count)];
              }
              private uint GetZone25Thru30()
              {
                  var zoneList = new List<uint>();
      
                  //South Shroud - Quarrymill
                  if (_availableLocations.ContainsKey("quarrymill"))
                  {
                      zoneList.Add(_availableLocations["quarrymill"]);
                  }
                  if (zoneList.Count <= 0)
                  {
                      return 0;
                  }
      
                  return zoneList[_random.Next(0, zoneList.Count)];
              }
              private uint GetZone30Thru35()
              {
                  var zoneList = new List<uint>();
      
                  //Eastern La Noscea - Costa del Sol
                  if (_availableLocations.ContainsKey("costa del sol"))
                  {
                      zoneList.Add(_availableLocations["costa del sol"]);
                  }
                  if (zoneList.Count <= 0)
                  {
                      return 0;
                  }
      
                  return zoneList[_random.Next(0, zoneList.Count)];
              }
              private uint GetZone35Thru40()
              {
                  var zoneList = new List<uint>();
      
                  //Upper La Noscea - Camp Bronze Lake
                  if (_availableLocations.ContainsKey("camp bronze lake"))
                  {
                      zoneList.Add(_availableLocations["camp bronze lake"]);
                  }
      
                  if (zoneList.Count <= 0)
                  {
                      return 0;
                  }
      
                  return zoneList[_random.Next(0, zoneList.Count)];
              }
              private uint GetZone40Thru50()
              {
                  var zoneList = new List<uint>();
      
                  //Coerthas Central Highlands - Camp Dragonhead
                  if (_availableLocations.ContainsKey("camp dragonhead"))
                  {
                      zoneList.Add(_availableLocations["camp dragonhead"]);
                  }
                  if (zoneList.Count <= 0)
                  {
                      return 0;
                  }
      
                  return zoneList[_random.Next(0, zoneList.Count)];
              }
              #endregion
      
              #endregion
          }
      }

      To perform the same checks it dose on the start of the bot ( Check level and zone) when the bot dies and is released ?

      Thanks in advanced.
       
    2. kagamihiiragi17

      kagamihiiragi17 Community Developer

      Joined:
      Jun 24, 2014
      Messages:
      873
      Likes Received:
      25
      Trophy Points:
      0
      Then please post in the plugin's topic. That would be a job for the plugin author.
       
    3. Thecamel

      Thecamel Community Developer

      Joined:
      Aug 8, 2012
      Messages:
      2,036
      Likes Received:
      46
      Trophy Points:
      48
      Well, he's Not the author, He just updated a dead project, and he's Indicated he doesn't know how too...

      Pretty simple request...

      Either
      A- Its a simple piece of code I ad..
      B- Not possible at this time-due to the orderbot botbase.
      C- Its Possible but not a simple piece of code, Needs to rewritten.

      I'm fine with all 3 of those answers.


      FYI- This is the community development section ? - this is community development and this plugin is no longer a single author plugin..

      No need to be running around trying to be a forum cop... We all appreciate your efforts with this bot, and my bot wouldn't be where it is today with out your profiles and plugins, Im sure you started somewhere, perhaps there would be more community developers if newbies(noobies) where not approached like this, ?
       
      Last edited: Nov 10, 2014
    4. kagamihiiragi17

      kagamihiiragi17 Community Developer

      Joined:
      Jun 24, 2014
      Messages:
      873
      Likes Received:
      25
      Trophy Points:
      0
      I don't know why you respond so negatively whenever someone doesn't answer exactly the way you want them to, but it's really quite irritating.

      That aside, just put a Decorator in that checks whether the player's current zone is the zone you want to be grinding, and if not, then teleport to it.
       
    5. kaihaider

      kaihaider Community Developer

      Joined:
      May 18, 2010
      Messages:
      1,325
      Likes Received:
      5
      Trophy Points:
      38
      I think she just wanted to avoid people posting edit requests in this section every time they want something customized.

      You should have stated that you're working with the dev because he can't figure it out :p
      Or that you want to know how to do it for your own project.
       

    Share This Page