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); }
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); }
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"); }
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]); } }; }
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]); } }); }
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)"); } } }
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 + ")"); } }
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); }
public Bag(int id) { Id = id; Slots = int.Parse(WoWScript.Execute("GetContainerNumSlots(" + id + ")")[0]); FreeSlots = int.Parse(WoWScript.Execute("GetContainerNumFreeSlots(" + id + ")")[0]); }
public static bool IsDeserter() { return(WoWScript.Execute <bool>("UnitHasLFGDeserter(\"player\")")); }
public static bool HasAcceptedProposal() { return(WoWScript.Execute <int>("GetLFGProposal()", 6) == 1); }
public static bool InDungeon() { return(WoWScript.Execute <string>("IsInInstance()", 1) == "party"); }
private static string GetLFDMode() { var ret = WoWScript.Execute <string>("GetLFGMode()"); return(!string.IsNullOrEmpty(ret) ? ret : "none"); }
public override void OnTick() { switch (CurrentState) { case GRState.Search: Print("Starting a new search for level {0}", CurrentLevelSearch); LastSearch = DateTime.Now; WoWScript.ExecuteNoResults("SendWho(\"" + CurrentLevelSearch + "\")"); TotalSearches++; CurrentState = GRState.Searching; break; case GRState.Searching: var span = DateTime.Now - LastSearch; if (span.TotalSeconds > 5) { Print("Last search didn't give any match after 5 seconds, maybe there are no characters in this level?"); CurrentLevelSearch++; CurrentState = GRState.Search; } break; case GRState.Invite: var searchResult = WoWScript.Execute("GetNumWhoResults()"); var shownResults = int.Parse(searchResult[0]); var totalResults = int.Parse(searchResult[1]); Print("Search returned {0} visible matches out of a total {1}", shownResults, totalResults); for (int i = 1; i <= shownResults; i++) { var searchInfo = WoWScript.Execute("GetWhoInfo(" + i + ")"); var charInfo = new Character() { Name = searchInfo[0], Guild = searchInfo[1], Level = int.Parse(searchInfo[2]), Race = searchInfo[3], Class = searchInfo[4], Zone = searchInfo[5] }; if (string.IsNullOrEmpty(charInfo.Guild) && !InvitedCharacters.ContainsKey(charInfo.Name)) { Print("Inviting {0} (Level {1} {2} {3})", charInfo.Name, charInfo.Level, charInfo.Race, charInfo.Class); WoWScript.ExecuteNoResults("SendChatMessage(\"" + RecruitMessage + "\", \"WHISPER\", nil, \"" + charInfo.Name + "\")"); WoWScript.ExecuteNoResults("GuildInvite(\"" + charInfo.Name + "\")"); InvitedCharacters.Add(charInfo.Name, charInfo); } } CurrentState = GRState.Search; Sleep(5000); break; case GRState.Completed: Print("Stopping after {0} searches and {1} invites", TotalSearches, InvitedCharacters.Count); Stop(); break; } Sleep(500); }
//public bool IsRuneReady(RuneSlot slot) //{ // return _getRuneReday((int)slot) <= 0; //} // TODO: Implement this //public byte GetRuneCount(int index) //{ // //if (index >= 6) // //{ // // throw new IndexOutOfRangeException(StyxResources.This_function_only_takes_vaues_from_0_5); // //} // //Memory arg_23_0 = ObjectManager.Wow; // //uint[] array = new uint[] // //{ // //StyxWoW.Offsets.#Bb(5053) // //}; // //uint num = arg_23_0.ReadRelative<uint>(array); // //result = ((((ulong)num & (ulong)(1L << (index & 31))) != 0uL) ? 1 : 0); //} //public RuneType GetRuneType(int index) //{ // //RuneType result; // //try // //{ // // if (index >= 6) // // { // // throw new IndexOutOfRangeException(StyxResources.This_function_only_takes_vaues_from_0_5); // // } // // Memory arg_27_0 = ObjectManager.Wow; // // uint[] array = new uint[] // // { // // StyxWoW.Offsets.#Bb(5052) + (uint)(4 * index) // // }; // // uint num = arg_27_0.ReadRelative<uint>(array); // // result = (RuneType)num; // //} // //catch (Exception arg_6E_0) // //{ // // uint[] array; // // uint num; // // #3.#1c(arg_6E_0, num, array, this, index); // // throw; // //} // //return result; //} //public byte GetRuneCount(RuneType type) //{ // byte result; // byte b = 0; // for (int i = 0; i < 6; i++) // { // if (GetRuneType(i) == type) // b += GetRuneCount(i); // } //} //public int BloodRunesReady //{ // get // { // int ret = 0; // if (IsRuneReady(RuneSlot.Blood1)) ret++; // if (IsRuneReady(RuneSlot.Blood2)) ret++; // return ret; // } //} //public int FrostRunesReady //{ // get // { // int ret = 0; // if (IsRuneReady(RuneSlot.Frost1)) ret++; // if (IsRuneReady(RuneSlot.Frost2)) ret++; // return ret; // } //} //public int UnholyRunesReady //{ // get // { // int ret = 0; // if (IsRuneReady(RuneSlot.Unholy1)) ret++; // if (IsRuneReady(RuneSlot.Unholy2)) ret++; // return ret; // } //} #endregion #region LUA Helpers public void StartAttack() { WoWScript.Execute("StartAttack()"); }