Jump to content

Seminko

Members
  • Posts

    225
  • Joined

  • Last visited

Posts posted by Seminko

  1. I'm trying to find NPCs which are out of range, in other words no longer visible.

    I know that in WotLK addons like NPCScan were able to locate mobs really FAR away, further than visible.

    Is this something that can be done in vanilla?

    I tried code below which works if the NPC is still within the visible range but right when I go step farther so that it disappears the NPC is no longer valid.

    var guard = wManager.Wow.ObjectManager.ObjectManager.GetNearestWoWUnit(wManager.Wow.ObjectManager.ObjectManager.GetWoWUnitByEntry(8147));
    		if (guard.IsValid)
    		{
    			float distance = guard.GetDistance;
    			string myString = distance.ToString(); 
    			MessageBox.Show(myString);
    		}
    		else
    		{
    			MessageBox.Show("Not found");
    		}

    Also found a vanilla API call "TargetByName" which can reach as far as the above code.

    Any ideas if this is a limitation of vanilla or if this can be managed somehow.

    Thanks

  2. I used this. Will test and report back.

    public float Range 
    	{ 
    		get 
    		{
    			if(RangeCheck = true)
    			{
    			  return 29f;
    			}
    			return 5f;
    		} 
    	}
    
    private void RangeManager()
    	{	
    		if (ObjectManager.GetWoWUnitHostile().Count(u => u.Position.DistanceTo(ObjectManager.Target.Position) <= 40  && u.IsAttackable) > 1)
    		{
    			RangeCheck = true;
    		}
    		else
    		{
    			RangeCheck = false;
    		}
    		return;
    	}
    
        public void Start()
        {
            
            Logging.Write("Seminko's Rogue Loaded");
            while (iMageLaunched)
            {
                if (!Products.InPause)
                    {
                        if (!ObjectManager.Me.IsDeadMe)
                        {
    						SprintManager();
    						EquipThrown();
                            if (Fight.InFight && ObjectManager.Me.Target > 0)
                            {
                                RangeManager();
                                GetFightingState();
                            }
                        }
                    }
                Thread.Sleep(10);
            }
            Logging.Write("Seminko's Rogue is now stopped.");
        }

     

  3. Hmmm... Alright, where do you put this, i mean if this is going to be defined right at the start of the class I still don't understand how this gets updated. First thing that comes to mind is a bool. Let say in the fightclass loop I put in bool too check whether the conditions are met or not. If I update your code as below will the range be changed? If so, it's very much counterintuitive for me.

    public float Range 
    { 
    	get 
        {
          	if(bool = 1)
            {
              return 29f;
            }
          	return 5f;
    	} 
    }

     

  4. 4 hours ago, Matenia said:

    If you convert your fightclass to C#, Range() is a getter, so you can set it dynamically.

    I'm a C# noobie so bear with me.

    The default declaration is done within the Main class, like so:

    public float Range { get { return 29f; } }

    When I tried having a void with IF statements and using the above, it wouldn't work. Could you please ellaborate more?

  5. Figured it out. Apparently you can use items to equip them. At least in this case. It's wonky but it works:

    private void EquipThrown()
    	{
    		if (ObjectManager.Me.GetEquipedItemBySlot(wManager.Wow.Enums.InventorySlot.INVSLOT_RANGED) == 0) // if player doesn't have a ranged weapon equipped
    		{
    			if (ItemsManager.HasItemById(3108))
    			{
    				ItemsManager.UseItem(3108);
    			}
    		}
    		return;
    	}

     

  6. Hey,

    I would like to check if Thrown is quiped and if not, equip it.

    I have this but need help with the equip function:

    private void EquipThrown()
    	{
    		if (player.GetEquipedItemBySlot(wManager.Wow.Enums.InventorySlot.INVSLOT_RANGED) = 0)
    		{
    			foreach (WoWItem item in Bag.GetBagItem())
    			{
    				if(item.GetItemInfo.ItemName == "Heavy Throwing Dagger")
    				{
    					EQUIP THE ITEM
    				}
    				if (player.GetEquipedItemBySlot(wManager.Wow.Enums.InventorySlot.INVSLOT_RANGED) != 0)
    				{
    					break;
    				}
    			}
    		}
    		return;
    	}

    Also, is there a way so i can avoid hardcoding the thrown name? Sth like isItemUsable && itemIsRanged

    Thx

  7. Will do.

    Also, still struggling with MultiTargeting... :( I update code i posted above and now it should do one of the following things:

    • If a mob is attacking me, and is not my target, switch to that mob and tell pet to attack it
    • If a mob is attacking me, and is my target, tell pet to attack it
    • If no mob is attacking me, check whether they have Corruption and CoA, if they don't apply it

    However what happens is that the bot switches the targes but doesn't cast anything... It looks like what Matenia said that you cannot tell the bot what target to choose, so it switches targets, seems like it cannot cast the spell and immediatelly switches back. Ideas?

    internal void MultiTargetRotation()
        {
            var unitsAffectingMyCombat = ObjectManager.GetUnitAttackPlayer();
    
            if (unitsAffectingMyCombat.Count <= 0)
                return;
    
            var unitsAttackMe = unitsAffectingMyCombat.Where(u => u != null && u.IsValid && u.IsTargetingMe).ToList();
    
            if (unitsAttackMe.Count >= 1)
            {
                var unitToAttack = unitsAttackMe.FirstOrDefault(u => u != null && u.IsValid && !u.IsMyPetTarget);
                if (unitToAttack != null && unitToAttack.IsValid && unitToAttack.IsAlive)
                {
                    if (!unitToAttack.IsMyTarget)
                        Interact.InteractGameObject(unitToAttack.GetBaseAddress, !ObjectManager.Me.GetMove);
    					Lua.LuaDoString("PetAttack();");
                    if (unitToAttack.IsMyTarget)
                        Lua.LuaDoString("PetAttack();");
                    Logging.Write("PET ATTACKING: " + unitToAttack);
                }
            }
    		else
    		{
    			var unitsAttackPet = unitsAffectingMyCombat.Where(u => u != null && u.IsValid && u.IsTargetingMyPet && (!u.HaveBuff("Corruption") || !u.HaveBuff("Curse of Agony"))).FirstOrDefault();
                if (unitsAttackPet != null && unitsAttackPet.IsValid && unitsAttackPet.IsAlive && !unitsAttackPet.IsMyPetTarget)
                {
                    if (!unitsAttackPet.IsMyTarget)
    				{
    					if (!unitsAttackPet.HaveBuff("Corruption") && Corruption.IsSpellUsable)
    					{
    						Interact.InteractGameObject(unitsAttackPet.GetBaseAddress, !ObjectManager.Me.GetMove);
    						SpellManager.CastSpellByNameLUA("Corruption");
    					}
    					if (!unitsAttackPet.HaveBuff("Curse of Agony") && CurseOfAgony.IsSpellUsable)
    					{
    						Interact.InteractGameObject(unitsAttackPet.GetBaseAddress, !ObjectManager.Me.GetMove);
    						SpellManager.CastSpellByNameLUA("Curse of Agony");
    					}
    				}
                    if (unitsAttackPet.IsMyTarget)
    				{	
    					if (!unitsAttackPet.HaveBuff("Corruption") && Corruption.IsSpellUsable)
    					{
    						SpellManager.CastSpellByNameLUA("Corruption");
    					}
    					if (!unitsAttackPet.HaveBuff("Curse of Agony") && CurseOfAgony.IsSpellUsable)
    					{
    						SpellManager.CastSpellByNameLUA("Curse of Agony");
    					}
                        Lua.LuaDoString("PetAttack();");
    				}
                }
    		}
        }

     

  8. I tried using StopMoveTo before casting my spell but does not have any effect. As I was saying, once the bot is in combat mode and stops to prepare for fight then it creates the HS but otherwise my log shows it tried creating it but didn't stop.

    public bool CreateHealthstone()
            {
                if (ItemsManager.GetItemCountByIdLUA(5512) == 0 && ItemsManager.GetItemCountByIdLUA(19004) == 0 && ItemsManager.GetItemCountByIdLUA(19005) == 0 && !ObjectManager.Me.InCombat)
                {
    				MovementManager.StopMoveTo(false, 500);
    				Logging.WriteDebug("Creating Healthstone");
    				SpellManager.CastSpellByNameLUA("Create Healthstone (Minor)()");
    				Thread.Sleep(Usefuls.Latency + 3500);
    				return false;
                }
                return true;
            }

     

  9. 4 minutes ago, Matenia said:

    This is the function I use to cast spells and make sure my bot stops walking, if required.
    Here, spell.IsKnown() and spell.CanCast() are shorthand functions on my spell class to make sure that the spell is not on cooldown and IsSpellUsable is true.
    AreaSpells is just a list of strings containing spell names like Blizzard, Rain of Fire and other targeting AoE spells.

    Thank you!!!

  10. Still not able to test since the servers are down.

    I still need to figure out the Voidwalker summon / Healthstone creation situation. As I described above:

    1 hour ago, Seminko said:

    Also, since you know your coding, say I would like to summon voidwalker or create healthstone, how do I make the bot stop searching for targets and just stay still until it is summoned? I use IsSpellUsable to check if I have enough mana and if I do, sometimes the bot wants to summon the voidwalker but it's trying to do it while running. It seems once it finds its target it moves to the defined range, stops AND THEN summons the voidwalker.

    I checked the How to create a fight class from Droidz and he has this in his PetManager class:

    public override void Run()
            {
                if (!ObjectManager.Pet.IsValid)
                {
                    _callPet.Launch(true);
                    Thread.Sleep(Usefuls.Latency + 1000);
                }
                if (!ObjectManager.Pet.IsValid || ObjectManager.Pet.IsDead)
                    _revivePet.Launch(true);
     
                _petTimer = new Timer(1000 * 2);
            }

    I see override, does this actually overrieds the default bot behavior?

     

    To be honest I don't know how I would incorporate it into my script. I'm putting together multiple scripts from multiple sources. Here is my potato script and how I handle the combat:

    private void GetFightingState()
            {
    			if ((ObjectManager.Pet.IsValid && !ObjectManager.Pet.IsDead) && ObjectManager.Pet.HealthPercent < 7)
    			{	
    				fightState = fightingStateEnum.LowPetHealth;
    				return;
    			}
    			else if (ObjectManager.Me.HealthPercent < 25 && (_timer == null || _timer.IsReady) && (ItemsManager.GetItemCountByIdLUA(5512) >= 1 || ItemsManager.GetItemCountByIdLUA(19004) >= 1 || ItemsManager.GetItemCountByIdLUA(19005) >= 1))
    			{	
    				fightState = fightingStateEnum.LowPlayerHealth;
    				return;
    			}
    			else if (DrainSoul.IsSpellUsable && ObjectManager.Target.HealthPercent < 35)
    			{
    				fightState = fightingStateEnum.TargetLowHealth;
    				return;
    			}
    			else if (LifeTap.IsSpellUsable && ObjectManager.Me.ManaPercentage < 17 && ObjectManager.Me.HealthPercent >= 25  && !ObjectManager.Target.HaveBuff("Drain Soul"))
    			{
    				fightState = fightingStateEnum.LowPlayerMana;
    				return;
    			}
    			else if (Corruption.IsSpellUsable && !ObjectManager.Target.HaveBuff("Corruption")  && !ObjectManager.Target.HaveBuff("Drain Soul"))
    			{
    				fightState = fightingStateEnum.CorruptionNeed;
    				return;
    			}
    			else if (CurseOfAgony.IsSpellUsable && !ObjectManager.Target.HaveBuff("Curse of Agony") && !ObjectManager.Target.HaveBuff("Drain Soul"))
    			{
    				fightState = fightingStateEnum.CoANeed;
    				return;
    			}
    			else if (Fear.IsSpellUsable && ObjectManager.GetWoWUnitHostile().Count(u => u.GetDistance <= 5 && u.IsAttackable) >= 2  && !ObjectManager.Target.BuffCastedByAll("Fear").Contains(ObjectManager.Me.Guid)  && !ObjectManager.Target.HaveBuff("Drain Soul"))
    			{
    				fightState = fightingStateEnum.TargetClose;
    				return;
    			}
    			else if (ShadowBolt.IsSpellUsable)
    			{	
    				fightState = fightingStateEnum.SpamShadowBolt;
    				return;
    			}
    			else
    			{
    				if (EquippedItems.GetEquippedItem(WoWInventorySlot.Ranged) != null && !Lua.LuaDoString<bool>("return IsAutoRepeatAction(" + (SpellManager.GetSpellSlotId(SpellListManager.SpellIdByName("Shoot")) + 1) + ")") && ObjectManager.Me.ManaPercentage < 17 && ObjectManager.Me.HealthPercent < 25)
    				{
    					if (Shoot.KnownSpell)
    						SpellManager.CastSpellByNameLUA("Shoot");
    					return;
    				}
    			}
            }
    
    public void Start()
        {
            
            Logging.Write("Seminko's Warlock Loaded");
            while (iMageLaunched)
            {
                if (!Products.InPause)
                    {
                        GetFightingState();
                        if (!ObjectManager.Me.IsDeadMe)
                        {
                            GetFightingState();
                            if (!ObjectManager.Me.IsMounted && BuffRotation() == false && !ObjectManager.Me.InCombat)
    						{
                                BuffRotation();
                            }
                            if (Fight.InFight && ObjectManager.Me.Target > 0)
                            {
                                GetFightingState();
                                CombatRotation();
                            }
                        }
                    }
                Thread.Sleep(10);
            }
            Logging.Write("Warlock is now stopped.");
        }
    
    public bool BuffRotation()
        {
    		if (!ObjectManager.Me.InCombat)
    			SummonPet();
    			BuffArmor();
    			TapForManaOoc();
    			ShardManagement();
    			CreateHealthstone();
    
            if (BuffArmor() == true && TapForManaOoc() == true && SummonPet() == true && ShardManagement() == true && CreateHealthstone() == true)
    				return true;
    			else
                    return false;
        }

     

  11. 5 minutes ago, iMod said:
    
    List<WoWUnit> units = new List<WoWUnit>();
    
    // Short version
    IEnumerable<WoWUnit> sortedUnits = units.Where(u => u.Health < 10);
    
    // Long version
    List<WoWUnit> sortedUnits = new List<WoWUnit>();
    foreach(WoWUnit unit in units)
    {
       // Validate
       if(unit.Healt < 10)
       {
          // Add unit
          sortedUnits.Add(unit);
       }
    }

    Hope it explains it a bit. At the end the compiler won't do something else.

     

    Hi iMod, what does it do exactly? It seems it puts all mobs with HP lower than 10 into a list or an array?

  12. Brilliant! I have also found this code:

    internal void MultiTargetRotation()
        {
            var unitsAffectingMyCombat = ObjectManager.GetUnitAttackPlayer();
    
            if (unitsAffectingMyCombat.Count <= 0)
                return;
    
            var unitsAttackMe = unitsAffectingMyCombat.Where(u => u != null && u.IsValid && u.IsTargetingMe).ToList();
    
            if (unitsAttackMe.Count > 1)
            {
                var unitToAttack = unitsAttackMe.FirstOrDefault(u => u != null && u.IsValid && !u.IsMyPetTarget);
                if (unitToAttack != null && unitToAttack.IsValid && unitToAttack.IsAlive)
                {
                    if (!unitToAttack.IsMyTarget)
                        Interact.InteractGameObject(unitToAttack.GetBaseAddress, !ObjectManager.Me.GetMove);
                    if (unitToAttack.IsMyTarget)
                        Lua.LuaDoString("PetAttack();");
                    Logging.Write("PET ATTACKING: " + unitToAttack);
                }
            }
            //IF ALL THE MOBS ARE ATTACKING THE PET FOCUS THE LOWER HP ONE
            else
            {
                var unitsAttackPet = unitsAffectingMyCombat.Where(u => u != null && u.IsValid && u.IsTargetingMyPet).ToList();
                var lowerHpUnit = unitsAttackPet.OrderBy(unit => unit.HealthPercent).FirstOrDefault();
                if (lowerHpUnit != null && lowerHpUnit.IsValid && lowerHpUnit.IsAlive && !lowerHpUnit.IsMyPetTarget)
                {
                    if (!lowerHpUnit.IsMyTarget)
                        Interact.InteractGameObject(lowerHpUnit.GetBaseAddress, !ObjectManager.Me.GetMove);
                    if (lowerHpUnit.IsMyTarget)
                        Lua.LuaDoString("PetAttack();");
                    Logging.Write("PET ATTACKING LOWER HP: " + lowerHpUnit);
                }
            }
        }

     

    Also, since you know your coding, say I would like to summon voidwalker or create healthstone, how do I make the bot stop searching for targets and just stay still until it is summoned? I use IsSpellUsable to check if I have enough mana and if I do, sometimes the bot wants to summon the voidwalker but it's trying to do it while running. It seems once it finds its target it moves to the defined range, stops AND THEN summons the voidwalker.

×
×
  • Create New...