Jump to content

scsfl

Members
  • Posts

    30
  • Joined

  • Last visited

Posts posted by scsfl

  1. hello community!
    I'm trying to implement following method in druid FC: when condition met bot has to use flying mount, else ground mount.

    There is following logic: I'm subscribing to OnPathFinderFindPath event and checking if I need to use flying path to destination point. If so then I'm setting destination flying and calling LongMove.LongMoveGo(destination).

    private static void checkIfNeedFlyingPath(Vector3 from, Vector3 to, string continentNameMpq, CancelEventArgs cancelable)
    {
    	if (NeedToUseFlyingPath(to))
    	{
    		to.SetFlying();
    		UseFlightForm();		
    		Logging.WriteNavigator($"LongMove to {to}");                
    		LongMove.LongMoveGo(to);                
    		cancelable.Cancel = true;
    	}                
    }

     

    Function that check if I need to fly.

    private static bool NeedToUseFlyingPath(Vector3 dest)
    {
    	RotationLogger.Debug($"Calling NeedToUseFlyingPath({dest})");
    	if (!FlightForm.IsKnown() || Me.IsDead || Me.IsSwimming || Usefuls.ContinentNameMpq == "Azeroth")
    	{
    		RotationLogger.Debug($"NeedToUseFlyingPath() precondition failed!");
    		return false;
    	}
                
    	float dist = Me.Position.DistanceTo(dest);
    	RotationLogger.Debug($"[Movement] Distance to point {dist}");
    
    	if (dist >= FCSettings.CurrentSetting.MinDistanceToFly &&
    		(Logging.Status == "To Town" ||
    		Logging.Status == "Farming" ||
    		Logging.Status == "Looting" ||
    		ToTown.GoToTownInProgress ||
    		dist >= FCSettings.CurrentSetting.DistanceToFly))
    	{                
    		RotationLogger.Debug($"[Movement] Need to use flying path to {dest}");
    		return true;
    	}
      
    	RotationLogger.Debug($"[Movement] Need to use ground path to {dest}");
    	return false;            
    }

     

    The problem that this method is not stable. Sometimes it works fine, sometimes especially after farming state bot literally walks by the ground in flying form, then he might continue flying. I couldn't get where does he get this ground points when there is LongMove between 2 points 🙂

    When I use built-in flying mechanics everything works decent. But I don't know how to implement similar flight mechanics.

  2. On 10/22/2020 at 2:57 AM, Artek said:

    So today during grind player attacked me, bot instead of picking a player, was still attacking and chasing fleeing mob. Is there a way to make wrobot switch attacking player ?

    You have to modify ur fightclass.

    public void Initialize()
    {        
    	FightEvents.OnFightLoop += TargetSwitcher;
    }
    
    public void Dispose()
    {        
    	FightEvents.OnFightLoop -= TargetSwitcher;
    }
    
    private void TargetSwitcher(WoWUnit woWPlayer, System.ComponentModel.CancelEventArgs cancelable)
    {	
        WoWPlayer player = ObjectManager.GetNearestWoWPlayer(ObjectManager.GetObjectWoWPlayer().Where(o => o.IsAttackable).ToList());
        if (player == null || !player.IsValid || !player.IsAlive || player.Faction == ObjectManager.Me.Faction || player.IsFlying || player.IsMyTarget || woWPlayer.Guid == player.Guid)
        	return;
        if (player.InCombatWithMe && ObjectManager.Target.Type != WoWObjectType.Player)
        {
           cancelable.Cancel = true;               
           Fight.StartFight(player.Guid, robotManager.Products.Products.ProductName != "WRotation", false);
        }  
    }

     

  3. Brilliant advice man! I'm very appreciating your help.

    var luaString = @"
    				function OnEvent(self, event)
    					local args = { }
    					eventInfo = {CombatLogGetCurrentEventInfo()}								
    					for key, value in pairs(eventInfo) do
    						table.insert(args, tostring(value))										
    					end
    					_G.args = (table.concat(args, ','))
    				end
    
    				print ('frame works')
    				f = CreateFrame('Frame')
    				f: SetAttribute(name, 'CLEU')
    				f: RegisterEvent('COMBAT_LOG_EVENT_UNFILTERED')
    				f: SetScript('OnEvent', OnEvent)";

    Now I'm able to access _G.args from OnEventsLuaStringWithArgs ?. Thanks ?

  4. Can I ask one more dumb question please.

    Ok I did lua string that initialize lua frame and I'm able to store the payload in table each time event fired.

    luaString = @"
    			local function OnEvent(self, event)
    				local args = { }
    				eventInfo = {CombatLogGetCurrentEventInfo()}								
    				for key, value in pairs(eventInfo) do
    					table.insert(args, tostring(value))							
    				end
    			args = (table.concat(args, ','))
    			print (args) --debug
    			end
    
    			local f = CreateFrame('Frame')
    			f: SetAttribute(name, 'CLEU')
    			f: RegisterEvent('COMBAT_LOG_EVENT_UNFILTERED')
    			f: SetScript('OnEvent', OnEvent)";

    Also I've got a C# function that which takes CLEU args as parameter. Is there way to call this function inside luaString? In other words I need to send args to a function every time event fired.

    The only thing comes in mind is to create chat frame inside lua string, sent CLEU args to this frame and read this frame using EventsLuaWithArgs.OnEventsLuaStringWithArgs. But It looks awful ?

  5. Hi there!

    Does anybody know Is there way to make fight class listen to Lua events? Especially COMBAT_LOG_EVENT_UNFILTERED.

    Yeah I know there is EventsLuaWithArgs.OnEventsLuaStringWithArgs but it pretty often skips COMBAT_LOG_EVENT_UNFILTERED and even when it fires it doesn't return any args cuz I have to use CombatLogGetCurrentEventInfo() function to get a payload.

    How can I subscribe COMBAT_LOG_EVENT_UNFILTERED with args using c#?

    Thank you.

     

  6. This options is not about determinating which rotation spells should be casted or skipped. As Droidz said earlier with that options your next rotation spell tries to launch before it can be used and that is why in some cases this spell could be skipped.

    If you want your rotation to work as you intend I do not recommend to use this option.

  7. Most advanced and fundamental fight class sample I've ever seen. Awesome work.

    The only moment I still didn't get is wanding. Sometimes while wanding the bot is something like can't change rotation step. I mean for example i've got 10 steps in my rotation. Wanding has lowest priority. And if all conditions is fit for wanding he starts shoot. Everything is fine, but if he starts wanding, rotation step is not changing until I manually interrupt hes wanding process by pressing any movement key. Right after that rotation is working again as it should and bot continues rotate steps. Even other rotations spells with "force" enabled doesn't work.

    This problem happens only when bot is wanding. For other spells everything is good.

    My conditions for wanding:

    new RotationStep(new RotationSpell("Shoot"), 10f, (s, t) => MeHaveWand() && !RotationCombatUtil.IsAutoShooting() && !Me.GetMove, RotationCombatUtil.BotTarget),
        private static bool MeHaveWand()
        {
            return ObjectManager.Me.GetEquipedItemBySlot(InventorySlot.INVSLOT_RANGED) != 0 ? true : false;
        }
    		public static bool IsAutoShooting()
    		{
    			return Lua.LuaDoString<bool>("return IsAutoRepeatSpell('Shoot')");
    		}		

    Maybe some problems with spell verification. Wow vanilla.

     

  8. Hi. Try this. Returns a dictionary where key is itemname and value is lowest price.

        private static Dictionary<string, int> GetLowestItemPrice()
        {
            Dictionary<string, int> CheapestItems = new Dictionary<string, int>();        
            List<AuctionHelpers.AuctionItem> ItemsList = new List<AuctionHelpers.AuctionItem>();
            List<string> ItemsToCheck = /*your list of items*/
            int LowestPrice = 0;
    
            if (AuctionHelpers.AuctionHouseIsShown()) 
                foreach (string item in ItemsToCheck)
                {                
                    AuctionHelpers.BrowseNameSetText(item);
                    Thread.Sleep(2000);
                    AuctionHelpers.IsUsableCheckButtonSetChecked(false);
                    if (AuctionHelpers.BrowseSearchButtonIsEnabled())
                    {                
                        AuctionHelpers.BrowseSearchButtonClick();
                        Thread.Sleep(2000);
                        while (AuctionHelpers.BrowseNextPageButtonIsEnabled())
                        {
                            if (AuctionHelpers.GetBrowsePageItems().Any())
                            {
                                ItemsList.AddRange(AuctionHelpers.GetBrowsePageItems());                            
                                AuctionHelpers.BrowseNextPageButtonClick();
                                Thread.Sleep(1000);
                            }
                        }
                        if (AuctionHelpers.GetBrowsePageItems().Any())
                            ItemsList.AddRange(AuctionHelpers.GetBrowsePageItems());
                        ItemsList.RemoveAll(i => (i.Name != item) || (i.BuyoutPricePerUnit == 0));
                        LowestPrice = ItemsList.Min(price => price.BuyoutPricePerUnit);
                        CheapestItems.Add(item, LowestPrice);
                    }                               
                }       
            
            foreach (KeyValuePair<string, int> kvp in CheapestItems)
            {            
                Logging.Write("Itemname = " + kvp.Key + "Itemprice " + kvp.Value);
            }
            AuctionHelpers.CloseAuctionHouse();
            return CheapestItems;
        }

     

  9. Hi there!

    Trying to make own AH product. And there is a question. How do I get list of items currently sailing by me? I've tried

    AuctionHelpers.GetBrowsePageItems()

    But looks like it only works for "Browse" tab of AH. So i cannot get list of elements when I'm on "Auction" tab. Is there built-in function? Or it could be resolved only by lua?

  10. One more question. Is there way to detect stuck nodes? Yeah, I know there is an option in wrobot for this, but I need to do it manually in my plugin. Thanks :)

     

    update: got it. U have to add following condition

    !wManager.wManagerSetting.IsBlackListedAllConditions()
  11. Hello Droidz! Tell me please how can I check is there any gatherable or mineable corpse near me? Tried
     

    ObjectManager.GetWoWUnitLootable().Where(p => p.GetDistance <= 5).ToList()

    but its only works for common loot, not for gather herbs or mine ore from corpse.

    Thanks.

     

  12. Thank you so much! So for felslate it's gonna look something like this:

     float radius = 50;
            foreach (var o in ObjectManager.GetObjectWoWGameObject())
            {
                if (o.IsValid && o.GetDistance < radius && o.CanOpen && o.Name == "Felslate Deposit")
                {
                    // your code here
                }
            }

    Right?

  13. Hi! 2 noob questions from me :)

    1) How can I check is there any lootable node (felslate for example) in specific radius? Center of the circle is a bot.

    2) Can I check a condition when some player put me in target? In other words i need to do some action when i've been selected by another player.

×
×
  • Create New...