Beispiel #1
0
 public override void Run()
 {
     WoWScript.ExecuteNoResults("Dismount()");
     Gatherer.HarvestTarget.Interact();
     Engine.DelayNextPulse(Globals.SleepTime); // Let's give ourself about 1,5 seconds to harvest this node
     Globals.Harvests++;
 }
Beispiel #2
0
        private void EquipItem(WoWItem item, EquipSlot slot)
        {
            int bi, bs;

            item.GetSlotIndexes(out bi, out bs);
            WoWScript.ExecuteNoResults(string.Format("ClearCursor(); PickupContainerItem({0}, {1}); EquipCursorItem({2})", bi, bs, (int)slot));
        }
Beispiel #3
0
 public void Learn(int count = 1)
 {
     for (int i = 0; i < count; i++)
     {
         WoWScript.ExecuteNoResults("LearnTalent(" + Tab + ", " + Index + ")");
     }
 }
Beispiel #4
0
        public bool CanCast(WoWUnit target = null, bool checkrange = false)
        {
            WoWLocalPlayer Me = Manager.LocalPlayer;

            if (!IsReady)
            {
                return(false);
            }
            if (Me.IsCasting)
            {
                return(false);
            }
            if (IsUsing)
            {
                return(false);
            }
            var r = WoWScript.Execute("IsUsableSpell(select(1, GetSpellInfo(" + this.Id + ")))");

            if (r.Count <= 0 || !r[0].Equals("1"))
            {
                return(false);
            }
            if (checkrange && target != null)
            {
                if (IsMeleeRange && !Me.IsWithinMeleeRangeOf(target))
                {
                    return(false);
                }
                else if (IsRanged && (target.Distance < MinRange || target.Distance > MaxRange))
                {
                    return(false);
                }
            }
            return(true);
        }
Beispiel #5
0
        private int DanceCommand(string cmd, string args)
        {
            Manager.Console.Write("Let's dance!", WoWConsoleColor.Highlight);
            WoWScript.ExecuteNoResults("DoEmote(\"dance\")");

            return(1);
        }
Beispiel #6
0
        private Dictionary <string, int> GetMounts()
        {
            var mountDictionary = new Dictionary <string, int>();
            var mountCount      = 0;
            var NumCompanions   = WoWScript.Execute("GetNumCompanions(\"mount\")");

            if (NumCompanions != null && NumCompanions.Count > 0)
            {
                mountCount = int.Parse(NumCompanions[0]);
            }

            if (mountCount > 0)
            {
                for (int i = 0; i < mountCount; i++)
                {
                    var mountInfo = WoWScript.Execute("GetCompanionInfo(\"mount\", " + i + ")");
                    if (mountInfo != null && mountInfo.Count > 0)
                    {
                        var mountFlags = int.Parse(mountInfo[5]);
                        if ((mountFlags & 0x02) != 0) // It's a flying mount
                        {
                            mountDictionary.Add(mountInfo[1], i);
                        }
                    }
                }
            }
            return(mountDictionary);
        }
Beispiel #7
0
        public override void Run()
        {
            CurrentLootable = Lootables.FirstOrDefault() ?? WoWUnit.Invalid;

            if (CurrentLootable != null && CurrentLootable.IsValid)
            {
                if (CurrentLootable.Distance > 4f)
                {
                    if (!Moving || !Manager.LocalPlayer.IsClickMoving)
                    {
                        Moving = true;
                        _parent.Print("Moving to loot {0}", CurrentLootable.Name);
                        Mover.MoveTo(CurrentLootable.Location);
                    }
                    _parent.FSM.DelayNextPulse(500);
                }
                else
                {
                    Moving = false;
                    CurrentLootable.Interact();
                    if (Manager.LocalPlayer.IsLooting)
                    {
                        WoWScript.ExecuteNoResults(
                            "local res = GetCVar(\"AutoLootDefault\") if res == \"0\" then for i = GetNumLootItems(), 1, -1 do LootSlot(i) end end CloseLoot()");
                    }
                    _parent.FSM.DelayNextPulse(2000);
                }
            }
        }
Beispiel #8
0
        public override void Run()
        {
            CurrentLootable = Lootables.FirstOrDefault() ?? WoWUnit.Invalid;

            if (CurrentLootable != null && CurrentLootable.IsValid)
            {
                if (CurrentLootable.Distance > 4f)
                {
                    if (Mover.Status != MovementStatus.Moving || Mover.Destination != CurrentLootable.Location)
                    {
                        _parent.Print("Moving to loot {0}", CurrentLootable.Name);
                        if (!Mover.PathTo(CurrentLootable.Location))
                        {
                            _parent.Blacklisted.Add(CurrentLootable.Guid);
                        }
                    }
                    _parent.FSM.DelayNextPulse(500);
                }
                else
                {
                    CurrentLootable.Interact();
                    if (Manager.LocalPlayer.IsLooting)
                    {
                        WoWScript.ExecuteNoResults(
                            "local res = GetCVar(\"AutoLootDefault\") if res == \"0\" then for i = GetNumLootItems(), 1, -1 do LootSlot(i) end end CloseLoot()");
                    }
                    _parent.FSM.DelayNextPulse(2000);
                }
            }
        }
Beispiel #9
0
 public override void OnStart()
 {
     WoWScript.ExecuteNoResults("SetWhoToUI(1)");
     Events.Register("WHO_LIST_UPDATE", HandleEvent);
     TotalSearches      = 0;
     CurrentLevelSearch = 1;
     CurrentState       = GRState.Search;
 }
Beispiel #10
0
 public void BuyAllAvailable()
 {
     WoWScript.ExecuteNoResults("SetTrainerServiceTypeFilter(\"available\", 1)");
     foreach (TrainerService s in Services.Where(x => x.Available))
     {
         s.Buy();
     }
 }
Beispiel #11
0
 public void SelectGameAccount(string account)
 {
     WoWScript.ExecuteNoResults(
         string.Format(
             "for i = 0, GetNumGameAccounts(), 1 do local name = GetGameAccountInfo(i) " +
             "if (name == '{0}') then SetGameAccount(i) end end",
             account));
 }
Beispiel #12
0
 public void Buy(int quantity)
 {
     while (quantity > 0)
     {
         int amount = (quantity > MaxStack ? MaxStack : quantity);
         WoWScript.ExecuteNoResults("BuyMerchantItem(" + Index + ", " + amount + ")");
         quantity -= amount;
     }
 }
Beispiel #13
0
 public void SelectCharacter(string character)
 {
     if (CharSelectVisible)
     {
         WoWScript.ExecuteNoResults(
             string.Format(
                 "for i=0,GetNumCharacters(),1 do local name = GetCharacterInfo(i)" +
                 "if (name ~= nil and name == '{0}') then CharacterSelect_SelectCharacter(i) end end",
                 character));
     }
 }
Beispiel #14
0
 public void SetFilter(bool available = true, bool?unavailable = false, bool?used = false)
 {
     WoWScript.ExecuteNoResults(string.Format("SetTrainerServiceTypeFilter(\"available\", {0})", available ? 1 : 0));
     if (unavailable.HasValue)
     {
         WoWScript.ExecuteNoResults(string.Format("SetTrainerServiceTypeFilter(\"unavailable\", {0})", unavailable.Value ? 1 : 0));
     }
     if (used.HasValue)
     {
         WoWScript.ExecuteNoResults(string.Format("SetTrainerServiceTypeFilter(\"used\", {0})", used.Value ? 1 : 0));
     }
 }
Beispiel #15
0
        public WoWCompanion(string type, int index)
        {
            List <string> ret = WoWScript.Execute("GetCompanionInfo(\"" + type + "\", " + index + ")");

            Type  = type;
            Index = index;

            CreatureId = int.Parse(ret[0]);
            Name       = ret[1];
            SpellId    = int.Parse(ret[2]);
            Active     = !(ret[4] == "false" || ret[4] == "0" || ret[4] == "nil");
        }
        public override void OnStart()
        {
            if (!Manager.ObjectManager.IsInGame)
            {
                return;
            }

            WoWScript.ExecuteNoResults("SetWhoToUI(1)");
            Manager.Events.Register("WHO_LIST_UPDATE", HandleEvent);
            TotalSearches      = 0;
            CurrentLevelSearch = 1;
            CurrentState       = GRState.Search;
        }
Beispiel #17
0
        public override void OnStart()
        {
            if (!Manager.ObjectManager.IsInGame)
            {
                return;
            }

            //Print("Facing: {0}", Manager.LocalPlayer.Facing);
            foreach (var p in Manager.ObjectManager.Objects.Where(x => x.IsPlayer).Cast <WoWPlayer>())
            {
                Print("-- {0}", p.Name);
                Print("\tGUID: 0x{0}", p.Guid.ToString("X8"));
                Print("\tPosition: {0}", p.Location);
            }

            //foreach (var obj in Manager.ObjectManager.Objects.Where(x => x.IsUnit).Cast<WoWUnit>())
            //{
            //    if (obj.IsHostile)
            //    {
            //        Print("-- {0}", obj.Name);
            //        Print("\tGUID: 0x{0}", obj.Guid.ToString("0"));
            //        Print("\tPosition: {0}", obj.Location);
            //    }
            //}

            List <WoWUnit> _list = new List <WoWUnit>(GetClosestAttackables());

            if (_list.Count > 0)
            {
                foreach (var obj in _list)
                {
                    Print("-- {0}", obj.Name);
                    Print("\tGUID: 0x{0}", obj.Guid.ToString("0"));
                    Print("\tPosition: {0}", obj.Location);
                    Print("\tDistance: {0}", obj.Distance);
                    Manager.Movement.PathTo(obj.Location);

                    //while (obj.Distance > 5)
                    //    Thread.Sleep(100);

                    Print("\tExecute Facing:");
                    obj.Face();

                    Print("\tExecute Interact:");
                    obj.Interact();

                    Print("\tExecute Attack:");
                    WoWScript.ExecuteNoResults("/startattack");
                }
            }
        }
Beispiel #18
0
 public override void OnTick()
 {
     if (Leader.IsValid)
     {
         if (Helper.InCombat)
         {
             if (FollowingLeader)
             {
                 WoWScript.ExecuteNoResults("MoveForwardStop()");
                 FollowingLeader = false;
             }
             if (Leader.IsCasting && !Manager.LocalPlayer.IsCasting)
             {
                 var id = Leader.CastingId;
                 if (id == 0)
                 {
                     id = Leader.ChanneledCastingId;
                 }
                 var spell = WoWSpell.GetSpell(id);
                 if (spell.IsValid)
                 {
                     var target = Leader.Target;
                     if (target.IsValid)
                     {
                         if (Manager.LocalPlayer.Target != target)
                         {
                             target.Select();
                         }
                         spell.Cast(target as WoWUnit);
                         Print("Casting {0} on {1}", spell.Name, target.Name);
                     }
                     else
                     {
                         spell.Cast(Manager.LocalPlayer);
                         Print("Casting {0} on self", spell.Name);
                     }
                 }
             }
         }
         else
         {
             if (!FollowingLeader)
             {
                 Leader.Select();
                 WoWScript.ExecuteNoResults("FollowUnit(\"target\")");
                 FollowingLeader = true;
             }
         }
     }
 }
Beispiel #19
0
 public override void Run()
 {
     if (_parent.Leader.Distance > 8)
     {
         if (Manager.LocalPlayer.IsClickMoving)
         {
             return;
         }
         Manager.LocalPlayer.ClickToMove(_parent.Leader.Location);
         _parent.FSM.DelayNextPulse(200);
         return;
     }
     _parent.Leader.Select();
     WoWScript.ExecuteNoResults("FollowUnit(\"target\")");
     _parent.FollowingLeader = true;
 }
Beispiel #20
0
        private void btnExecuteLua_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(tbLua.Text))
            {
                return;
            }

            Program.OnFrameOnce += delegate
            {
                Log.WriteLine(tbLua.Text);
                List <string> ret = WoWScript.Execute(tbLua.Text);
                for (int i = 0; i < ret.Count; i++)
                {
                    Log.WriteLine("\t[{0}] = \"{1}\"", i, ret[i]);
                }
            };
        }
Beispiel #21
0
        private void btnExecute_Click(object sender, EventArgs e)
        {
            string lua = tbLUA.Text;

            if (string.IsNullOrEmpty(lua))
            {
                return;
            }
            Manager.ExecutionQueue.AddExececution(() =>
            {
                Log.WriteLine(lua);
                List <string> ret = WoWScript.Execute(lua);
                for (int i = 0; i < ret.Count; i++)
                {
                    Log.WriteLine("\t[{0}] = \"{1}\"", i, ret[i]);
                }
            });
        }
Beispiel #22
0
        private void ResetFilter()
        {
            if (!IsOpen)
            {
                return;
            }

            WoWScript.ExecuteNoResults(
                "TradeSkillOnlyShowMakeable(false)" +
                "TradeSkillOnlyShowSkillUps(false)" +
                "SetTradeSkillSubClassFilter(0)" +
                "SetTradeSkillInvSlotFilter(0)" +
                "SetTradeSkillItemNameFilter(\"\")"
                ); // No filters!

            for (int i = 1; i <= WoWScript.Execute <int>("GetNumTradeSkills()"); i++)
            {
                WoWScript.ExecuteNoResults("ExpandTradeSkillSubClass(" + i + ")");
            }
        }
Beispiel #23
0
 public void SelectRealm(string realm)
 {
     if (RealmFrameVisible)
     {
         var curRealm = WoWScript.Execute <string>("GetServerName()");
         if (!string.IsNullOrEmpty(curRealm) && curRealm == realm)
         {
             WoWScript.ExecuteNoResults(
                 string.Format(
                     "for i = 1, select('#', GetRealmCategories()), 1 do local numRealms = GetNumRealms(i)" +
                     "for j = 1, numRealms, 1 do local name, numCharacters = GetRealmInfo(i, j)" +
                     "if (name ~= nil and name == '{0}') RealmList:Hide() ChangeRealm(i,j) end end end",
                     realm));
         }
         else
         {
             WoWScript.ExecuteNoResults("RequestRealmList(1)");
         }
     }
 }
Beispiel #24
0
        private void HandleEvent(string ev, List <string> args)
        {
            switch (ev)
            {
            case "START_LOOT_ROLL":
                EvaluateRollItem(Convert.ToInt32(args.ElementAtOrDefault(0)));
                break;

            case "CONFIRM_DISENCHANT_ROLL":
            case "CONFIRM_LOOT_ROLL":
                WoWScript.ExecuteNoResults("ConfirmLootRoll(" + args.ElementAtOrDefault(0) + "," + args.ElementAtOrDefault(1) + ")");
                break;

            case "LOOT_BIND_CONFIRM":
                WoWScript.ExecuteNoResults("ConfirmLootSlot(" + args.ElementAtOrDefault(0) + ")");
                break;

            case "USE_BIND_CONFIRM":
                WoWScript.ExecuteNoResults("ConfirmBindOnUse()");
                break;

            case "EQUIP_BIND_CONFIRM":
            case "AUTOEQUIP_BIND_CONFIRM":
                WoWScript.ExecuteNoResults("EquipPendingItem(" + args.ElementAtOrDefault(0) + ")");
                break;

            case "ITEM_PUSH":
                // New item in inventory.
                _lastPulse = DateTime.MinValue;
                break;

            case "ACTIVE_TALENT_GROUP_CHANGED":
            case "CHARACTER_POINTS_CHANGED":
            case "PLAYER_ENTERING_WORLD":
                // Update weightsets
                break;
            }
        }
Beispiel #25
0
 public override void Run()
 {
     Mover.StopMoving();
     WoWScript.ExecuteNoResults("RetrieveCorpse()");
 }
Beispiel #26
0
 public void Summon()
 {
     WoWScript.ExecuteNoResults("CallCompanion(\"MOUNT\", " + Index + ")");
 }
Beispiel #27
0
 public static void RepairAll()
 {
     WoWScript.ExecuteNoResults("RepairAllItems()");
 }
Beispiel #28
0
 private void RollItem(int rollId, RollType type)
 {
     WoWScript.ExecuteNoResults("RollOnLoot(" + rollId + "," + (int)type + ")");
 }
Beispiel #29
0
        private void EvaluateRollItem(int rollId)
        {
            var itemString = WoWScript.Execute <string>("string.match(GetLootRollItemLink(" + rollId + "), 'item[%-?%d:]+')", 0).Trim();

            //Print("{0}: {1}", rollId, itemString);
            if (string.IsNullOrEmpty(itemString))
            {
                RollItem(rollId, RollType.Greed);
                return;
            }

            var splitItemString = itemString.Split(':');
            var itemId          = Convert.ToUInt32(splitItemString.ElementAtOrDefault(1));

            if (itemId == 0)
            {
                RollItem(rollId, RollType.Greed);
                return;
            }
            //Print("{0}: id {1}", rollId, itemId);

            var itemRec       = WoWItem.GetItemRecordFromId(itemId);
            var itemSparseRec = WoWItem.GetItemSparseRecordFromId(itemId);
            var itemName      = itemSparseRec.Name;
            //Print("{0}: {1}", rollId, itemName);
            var itemSuffix = Convert.ToInt32(splitItemString.ElementAtOrDefault(7));

            if (itemSuffix > 0)
            {
                var suffix = Manager.DBC[ClientDB.ItemRandomProperties].GetRow(itemSuffix).GetField <string>(7);
                if (!string.IsNullOrEmpty(suffix))
                {
                    itemName += " " + suffix;
                }
            }

            GameError g_err;
            var       equippable = Manager.LocalPlayer.CanUseItem(WoWItem.GetItemSparseRecordPointerFromId(itemId), out g_err);

            if (!equippable && g_err != GameError.ERR_CANT_EQUIP_LEVEL_I)
            {
                Print("Greeding '{0}' as it's not equippable ({1})", itemSparseRec.Name, g_err);
                RollItem(rollId, RollType.Greed);
                return;
            }

            var itemScore = CalculateItemScore(itemSparseRec, itemRec);
            var goesIn    = WoWItem.GetInventorySlotsByEquipSlot(itemSparseRec.InventoryType);

            foreach (var slot in goesIn)
            {
                var currentItem = Manager.LocalPlayer.GetEquippedItem(slot);
                if (!currentItem.IsValid)
                {
                    if (slot == EquipSlot.OffHand)
                    { // No support for OH rolls yet
                        var mh = Manager.LocalPlayer.GetEquippedItem(EquipSlot.MainHand);
                        if (mh.IsValid && mh.ItemSparseInfo.InventoryType == InventoryType.TwoHandedWeapon)
                        {
                            break;
                        }
                    }

                    Print("Rolling Need for '{0}' (score: {1}) as we have an empty slot", itemSparseRec.Name, itemScore);
                    RollItem(rollId, RollType.Need);
                    return;
                }

                var currScore = CalculateItemScore(currentItem.ItemSparseInfo, currentItem.ItemInfo);

                // If suggested item is 2H and we have MH+OH compare both
                if (itemRec.Class == ItemClass.Weapon)
                {
                    if (itemSparseRec.InventoryType == InventoryType.TwoHandedWeapon &&
                        currentItem.ItemSparseInfo.InventoryType == InventoryType.WeaponMainHand)
                    {
                        var weaponScore = currScore;
                        var offHand     = Manager.LocalPlayer.GetEquippedItem(EquipSlot.OffHand);
                        if (offHand.IsValid)
                        {
                            weaponScore += CalculateItemScore(offHand.ItemSparseInfo, offHand.ItemInfo);
                        }

                        if (itemScore > weaponScore)
                        {
                            Print("Rolling need for 2H '{0}' (score: {1}) because it's better than MH+OH (score: {2})", itemSparseRec.Name, itemScore, weaponScore);
                            RollItem(rollId, RollType.Need);
                            return;
                        }
                    }
                }

                if (itemScore > currScore)
                {
                    Print("Rolling Need for '{0}' (score: {1}) as it's better than '{2}' (score: {3})", itemSparseRec.Name, itemScore, currentItem.Name, currScore);
                    RollItem(rollId, RollType.Need);
                    return;
                }
            }
            Print("Rolling greed for {0}", itemSparseRec.Name);
            RollItem(rollId, RollType.Greed);
        }
Beispiel #30
0
 public static void Hide(string frameName)
 {
     WoWScript.ExecuteNoResults(frameName + ":Hide()");
 }