• Visit Rebornbuddy
  • Interact With TradeSkilll Nodes

    Discussion in 'Wildbuddy Developers' started by Angully, Oct 9, 2015.

    1. Angully

      Angully Member

      Joined:
      Sep 19, 2010
      Messages:
      764
      Likes Received:
      1
      Trophy Points:
      18
      1. Is it possible to make the bot interact with tradeskills nodes via profiles or will a plugin be required?
      2. If it is possible via profiles is there any API information about so i can try and work out how to start making some gathering profiles?

      Thanks in Advance
       
    2. Deathdisguise

      Deathdisguise Community Developer

      Joined:
      Mar 7, 2015
      Messages:
      678
      Likes Received:
      6
      Trophy Points:
      0
      1) A specific behavior would probably be preferred to gather from nodes, I can probably include one in QuestHelper as it doesn't seem too complicated, the biggest obstacle is definitely avoidance for primes!
      2) The API framework is exposed if you reference Wildbuddy.exe in any modern C# IDE! (Quick google searches to get you on your way: "Adding reference to Visual Studio project", and "Visual Studio Object Browser")
       
    3. Illindar

      Illindar New Member

      Joined:
      Sep 29, 2015
      Messages:
      15
      Likes Received:
      2
      Trophy Points:
      3
      I can't seem to figure out how to pull back a list of harvestable nodes.

      This will pull back a list of all the objects just fine:

      PHP:
              public void OnButtonClicked(object sender)
              {
                  
               
      Buddy.Common.DefaultDictionary<uintActorobjects GameManager.Actors;
                 foreach (var 
      o in objects.Values) {
                    if (
      o.Distance HarvestShitRadius) { 
                        
      //&& (o.IsScientistScannable || o.IsScientistRawScannable || o.IsScientistActivate)
                         
      Actor me GameManager.LocalPlayer;  
                              
      Log.Warn("Name:" o.Name " Class:" o.Class + " ActorType:" o.ActorType " IsCollect:" o.IsCollect " IsDatacube:" o.IsDatacube " RequiredTradeskill:" o.RequiredTradeskill " RequiredTradeskillTier:" o.RequiredTradeskillTier " Resources:" o.Resources " TargetDisposition:" o.TargetDisposition);
      //                        o.Interact();

                      
      }
                  }
              }

      But when I try and filter on o.ActorType I toss errors. For example by replacing the If criteria above with: if ((o.Distance < HarvestShitRadius) && (o.ActorType = "Harvest")) {

      I know it'll be a basic thing I'm overlooking... Any ideas?
       
    4. Angully

      Angully Member

      Joined:
      Sep 19, 2010
      Messages:
      764
      Likes Received:
      1
      Trophy Points:
      18
      I did it <3 thanks DD
       
    5. Apoc

      Apoc Moderator Staff Member Moderator

      Joined:
      Jan 16, 2010
      Messages:
      2,790
      Likes Received:
      94
      Trophy Points:
      48
      CommonBehaviors.Interact will automatically equip the required harvesting tool to harvest a given node. (Except for herbs, which you need to attack)

      You can check actor.ActorType == ActorType.Harvest to detect when it is a harvest node, then simply call "await CommonBehaviors.EquipHarvestTool(actor)" to equip the correct harvesting tool for the specified actor.

      The implementation of EquipHarvestTool is as follows:

      Code:
      
      		public static async Task<bool> EquipHarvestTool(Actor harvestable)
      		{
      			var harvestType = harvestable.RequiredTradeskill;
      
      
      			// Only these 3 need specific harvesting types.
      			if (harvestType != Tradeskill.Mining && harvestType != Tradeskill.RelicHunter && harvestType != Tradeskill.Survivalist)
      				return true;
      
      
      
      
      			// Check if we already have the required tool equipped.
      			var currentlyEquipped = GameManager.Inventory.Equipped.Items.FirstOrDefault(i => i.EquipSlot == ItemSlot.WeaponTool);
      			if (currentlyEquipped != null && currentlyEquipped.Info.Tradeskill == harvestable.RequiredTradeskill)
      			{
      				// The item is already equipped. TODO: Should we check for upgrades to the harvestable tool?
      				return true;
      			}
      
      
      			// Do we have any tools that can actually be used?
      			var tools = GameManager.Inventory.Bags.Items.Where(i => i.EquipSlot == ItemSlot.WeaponTool && i.Info.Tradeskill == harvestType).ToList();
      			if (tools.Count == 0)
      				return false;
      			// Shortcut the ordering logic if we only have 1.
      			// This may cause issues with trying to equip a higher level tool than we can actually use, but that's on the user.
      			if (tools.Count == 1)
      			{
      				return tools[0].Equip() == GenericError.Ok;
      			}
      
      
      
      
      			// Order by their tradeskill tier requirement (highest first, since we want to use the "best" available tool)
      			tools = tools.OrderByDescending(i => i.Info.GetTradeskillTierRequirement()).ToList();
      
      
      			// Equip the "best" tool we can use for our current tradeskill tier.
      
      
      			// Grab the current tier of the tradeskill. Note: The FirstOrDefault will return an empty structure if we don't have a tradeskill requested.
      			// This means IsActive == false. So USE that. (Also check "Tier" for sanity)
      			var currentTier = GameManager.CurrentTradeskills.FirstOrDefault(ts => ts.Tradeskill == harvestType);
      			if (currentTier.IsActive && currentTier.Tier > 0)
      			{
      				// Check the tools list for the first tool we can actually use (just by it's tier... TODO: check tool level requirement)
      				var bestTool = tools.FirstOrDefault(tool => tool.Info.GetTradeskillTierRequirement() <= currentTier.Tier);
      				return bestTool?.Equip() == GenericError.Ok;
      			}
      			return false;
      		}
       
    6. Illindar

      Illindar New Member

      Joined:
      Sep 29, 2015
      Messages:
      15
      Likes Received:
      2
      Trophy Points:
      3
      Awesome. Thanks Apoc. Didn't have visual studio working right until last night. Really makes the difference when you can use the object browser.
       
    7. Illindar

      Illindar New Member

      Joined:
      Sep 29, 2015
      Messages:
      15
      Likes Received:
      2
      Trophy Points:
      3
      I also forgot: Holy cow, that's a phenomenal sample implementation. You blew me away and made me very sad I can't spend all night again writing code and pretending I don't have to be an adult with responsibilities in the morning.

      I'll share my growing horde of plugins once I can get the bat out and finish beating the remaining bugs out of my tradeskill HarvestShit and sociopath KillShit plugins. Thus far they've made life so much fun doing missions and killing everything that moves.
       

    Share This Page