private void button4_Click(object sender, EventArgs e) { Pid = Magic.SProcess.GetProcessFromProcessName("WoW"); Player = new GObjectList(Pid); Stream myStream; OpenFileDialog openFileDialog1 = new OpenFileDialog(); openFileDialog1.InitialDirectory = Directory.GetCurrentDirectory() + "\\Waypoints"; openFileDialog1.Filter = "nav files (*.xnav)|*.xnav"; openFileDialog1.FilterIndex = 2; openFileDialog1.RestoreDirectory = false; if (openFileDialog1.ShowDialog() == DialogResult.OK) { if ((myStream = openFileDialog1.OpenFile()) != null) { // Insert code to read the stream here. IFormatter formatter = new BinaryFormatter(); NavWesh = formatter.Deserialize(myStream) as NavMesh; myStream.Close(); } if (!th.IsAlive) { th.Start(); } } }
public static bool EquipNewBag(GItem Item) { BagManager bm = new BagManager(); GContainer bag = (GContainer)GObjectList.FindObject(Item.GUID); if (bag != null) { bm.ClickItem(Item, true); for (int p = 1; p <= 4; p++) { if (Popup.IsVisible(p)) { String text = Popup.GetText(p); PPather.WriteLine("Inventory: Got a popup ('" + text + "')"); if (text.Contains("will bind it to you")) { Popup.ClickButton(p, 1); } else { Popup.ClickButton(p, 2); } } } bm.CloseAllBags(); return(true); } bm.CloseAllBags(); return(false); }
GUnit FindBestTarget() { if (target == null || ppather.IsBlacklisted(target)) UpdateTimer.ForceReady(); else { if (!target.IsValid || target.IsDead) UpdateTimer.ForceReady(); } if (UpdateTimer.IsReady) { GPlayer[] players = GObjectList.GetPlayers(); float[] playerScore = new float[players.Length]; float best_score = 0; GPlayer best_player = null; for (int i = 0; i < players.Length; i++) { GPlayer player = players[i]; if (!player.IsSameFaction || ppather.IsBlacklisted(player) || player == GContext.Main.Me || player.Health < 0.05) { playerScore[i] = -100f; } else { for (int j = 0; j < players.Length; j++) { if (players[j].IsSameFaction && players[j] != GContext.Main.Me && players[j] != player && players[j].Health > 0.05) { double d = players[j].GetDistanceTo(player); if (d < 30) { playerScore[i] += 30f - (float)d; } } } } if (playerScore[i] > best_score) { best_player = player; best_score = playerScore[i]; } } if (best_score > 50) { target = best_player; if (target != null) PPather.WriteLine("follow player " + target.Name + " score " + best_score); } else target = null; UpdateTimer.Reset(); } return target; }
public void changeMain(int i) { if (UserBots.Length > i) { int old = MainCharacter; MainCharacter = i; UserBots[old].Ismain = false; UserBots[MainCharacter].Ismain = true; MainObjectList = UserBots[MainCharacter].Objectlist; BotHelper.Main = MainCharacter; sendconsole("Main Successfully changed !", ConsoleLvl.BotHub); if (switchloc) { RECT rct1 = new RECT(); RECT rct2 = new RECT(); GetWindowRect(UserBots[old].Handle, ref rct1); GetWindowRect(UserBots[MainCharacter].Handle, ref rct2); // sendconsole(rct2.Left.ToString() + " " + rct2.Top.ToString() + " " + rct2.Right.ToString() + " " + rct2.Bottom.ToString(), ConsoleLvl.BotHub); SetWindowPos(UserBots[old].Handle.ToInt32(), 0, rct2.Left, rct2.Top, rct2.Right - rct2.Left, rct2.Bottom - rct2.Top, 0); SetWindowPos(UserBots[MainCharacter].Handle.ToInt32(), 0, rct1.Left, rct1.Top, rct1.Right - rct1.Left, rct1.Bottom - rct1.Top, 0); } SetForegroundWindow(UserBots[MainCharacter].Handle); SetFocus(UserBots[MainCharacter].Handle); UserBots[MainCharacter].ReleaseKeys(); } else { sendconsole("Error , Bot " + i.ToString() + " not existing!", ConsoleLvl.BotHub); } }
public static bool HasBetterBag() { GItem[] Items = GObjectList.GetItems(); foreach (GItem Item in Items) { if (Item.Type.ToString() == "Container" && !IsEquippedBag(Item.GUID)) { GContainer bag = (GContainer)GObjectList.FindObject(Item.GUID); if (bag != null) { long[] AllBags = GPlayerSelf.Me.Bags; foreach (long CurrentBag in AllBags) { GContainer cbag = (GContainer)GObjectList.FindObject(CurrentBag); if (cbag != null) { if (cbag.SlotCount < bag.SlotCount && !cbag.Name.ToString().ToLower().Contains("ammo") && !cbag.Name.ToString().ToLower().Contains("quiver")) { return(true); } } } } } } return(false); }
private GNode FindNode() { GNode[] nodes = GObjectList.GetNodes(); GNode node = null; double bestDistanceToLoc = double.MaxValue; foreach (GNode n in nodes) { if (n.Name == Object) { if (location != null) //this is cause sometimes there are more than 1 object visible, like "Wanted: Poster", if there are more than one, choose the one closest to the location specified. { float distance = location.GetDistanceTo(new Location(n.Location)); if (distance < bestDistanceToLoc) { bestDistanceToLoc = distance; node = n; } } else { node = n; break; } } } return(node); }
/// <summary> /// Retrieves the quantities of all distinct items in all of your bags. /// </summary> /// <param name="useCache">Whether to use cached data, if possible</param> /// <returns> /// A Dictionary with keys corresponding to the names /// of each distinct item in your inventory and values corresponding /// to the number of that item across all of your bags. /// </returns> public static Dictionary <string, int> CreateItemCount(bool useCache) { // only check it every 30 seconds to try to reduce // overhead if (curItemsCache != null && !curItemCacheTimer.IsReady && useCache) { return(curItemsCache); } Dictionary <string, int> items = new Dictionary <string, int>(StringComparer.InvariantCultureIgnoreCase); long[] AllBags = GPlayerSelf.Me.Bags; for (int bagNr = 0; bagNr < 5; bagNr++) { long[] Contents; int SlotCount; if (bagNr == 0) { Contents = GContext.Main.Me.BagContents; SlotCount = GContext.Main.Me.SlotCount; } else { GContainer bag = (GContainer)GObjectList.FindObject(AllBags[bagNr - 1]); if (bag != null) { Contents = bag.BagContents; SlotCount = bag.SlotCount; } else { SlotCount = 0; Contents = null; } } for (int i = 0; i < SlotCount; i++) { if (Contents[i] == 0) { continue; } GItem CurItem = (GItem)GObjectList.FindObject(Contents[i]); if (CurItem != null) { string ItemName = CurItem.Name; int ItemCount = CurItem.StackSize; int OldCount = 0; items.TryGetValue(ItemName, out OldCount); items.Remove(ItemName); items.Add(ItemName, OldCount + ItemCount); } } } curItemCacheTimer.Reset(); curItemsCache = items; return(curItemsCache); }
public GUnit FindNPC() { if (npcUnit == null || !npcUnit.IsValid) { npcUnit = GObjectList.FindUnit(NPC); } return(npcUnit); }
public static void GetEquippedItems() { GItemHelper GIH = new GItemHelper(); if (CharacterSlots == null) { CharacterSlots = GetCharacterSlots(); } CharacterFrame.ShowFrame(); foreach (string slot in CharacterSlots) { string tooltipName = "none"; PPather.Debug("\n\n == SLOT LOOKUP FOR {0} START ==", slot); List <string> tooltip = CharacterFrame.GetTooltip(slot); if (tooltip != null && tooltip.Count > 0) { //foreach (string tip in tooltip) // PPather.WriteLine("Character: Tooltip[{0}]\t=>\t{1}", slot, tip); tooltipName = tooltip[tooltip.Count - 1]; } PPather.Debug("Character: Name for {0} = {1}", slot, tooltipName); if (tooltip == null || IsEmptySlotName(tooltipName)) { AddNullSlot(slot); } else { Item i = ItemManager.get(tooltipName); if (i == null) { AddNullSlot(slot); } else { GItem Item = (GItem)GObjectList.FindObject(GIH.GetEquippedGUID(slot)); if (Item == null) { continue; } EasyItem E = new EasyItem(Item, i, Item.GUID, tooltipName); try { CurrentlyEquipped.Add(slot, E); PPather.WriteLine(LOG_CATEGORY.INFORMATION, "Character: Item [{0}] equipped in '{1}'", tooltipName, slot); PPather.Debug(String.Format("ToolTip[{0}]: {1}", i.Name, CleanToolTip(tooltip))); } catch (ArgumentException) { PPather.Debug("Character: " + tooltipName + " is already added to CurrentlyEquipped (skipping)"); } } } PPather.Debug("\n=== SLOT LOOKUP FOR {0} END ===\n", slot); } CharacterFrame.HideFrame(); }
GUnit FindMobToPull() { // Find stuff to pull GUnit closest = null; // only assist players //GMonster[] monsters = GObjectList.GetMonsters(); GPlayer[] players = GObjectList.GetPlayers(); List <GUnit> units = new List <GUnit>(); //units.AddRange(monsters); units.AddRange(players); float me_z = GContext.Main.Me.Location.Z; foreach (GUnit cur in units) { GUnit unit = cur.Target; if (cur.Reaction != GReaction.Friendly || !cur.IsInCombat || unit == null) { continue; } if (!unit.IsDead && unit.Reaction != GReaction.Friendly && unit.IsInCombat && unit.DistanceToSelf < Distance && !ppather.IsBlacklisted(unit) && !PPather.IsStupidItem(unit)) { Location ml = new Location(unit.Location); float dz = (float)Math.Abs(ml.Z - me_z); if (dz < 30.0f) { if (PPather.world.IsUnderwaterOrInAir(ml)) { PPather.WriteLine(unit.Name + " is underwater or flying"); ppather.Blacklist(unit); } else { if (closest == null || unit.DistanceToSelf < closest.DistanceToSelf) { closest = unit; } } } } } //PPather.WriteLine("Returning unit: " + (closest == null ? "null" : closest.Name)); return(closest); }
/*public BagManager() { * // make sure all bags are closed * * CloseAllBags(); * UpdateItems(); * * // check all contents * }*/ public void UpdateItemsSorted() { //PPather.WriteLine("UpdateItemsSorted()"); int[] count = new int[5] { 0, 0, 0, 0, 0 }; UpdateItems(); for (int i = 0; i < BagItems.Length; i++) { BagItem it = BagItems[i]; //PPather.WriteLine("UpdateItemsSorted: Adding {0} to Bag {1} (count = {2})", it.item.Name, it.bag, count[it.bag] + 1); count[it.bag]++; } int bags = GPlayerSelf.Me.Bags.Length + 1; long[] AllBags = GPlayerSelf.Me.Bags; for (int bagNr = 0; bagNr < 5; bagNr++) { int SlotCount; if (bagNr == 0) { SlotCount = GContext.Main.Me.SlotCount; } else { GContainer bag = (GContainer)GObjectList.FindObject(AllBags[bagNr - 1]); if (bag != null) { SlotCount = bag.SlotCount; } else { SlotCount = 0; } } count[bagNr] = SlotCount; } //PPather.WriteLine("UpdateItemsSorted: Creating new Bag array of size {0}", bags); Bags = new Bag[bags]; for (int i = 0; i < bags; i++) { //PPather.WriteLine("UpdateItemsSorted: Creating new GItem array of size {0} to Bag {1}", count[i], i); GItem[] gits = new GItem[count[i]]; //PPather.WriteLine("UpdateItemsSorted: Adding gits to Bag {0}", i); Bags[i] = new Bag(i, gits); } for (int i = 0; i < BagItems.Length; i++) { BagItem it = BagItems[i]; //PPather.WriteLine("UpdateItemsSorted: Bag[{0}].Add({1}, {2})", it.bag, it.item.Name, it.slot-1); Bags[it.bag].Add(it.item, it.slot - 1); } }
private void InjectToWoW() { ObjectList = new GObjectList(pid.ToInt32()); //Get LocalPlayer localPlayer = ObjectList.LocalPlayer; //Load move move = new GMovement(ObjectList, this); move.sendtext += new StringStatutTransfertEventHandler(SendConsole); Objectlist.sendtext += new StringStatutTransfertEventHandler(SendConsole); }
public void Update() { int dt = -updateTimer.TicksLeft; if (dt >= 1000) { GUnit[] units = GObjectList.GetUnits(); Update(units); } }
private void button3_Click(object sender, EventArgs e) { Pid = Magic.SProcess.GetProcessFromProcessName("WoW"); Player = new GObjectList(Pid); label1.Text = "Zone ID " + Player.LocalPlayer.ZoneID.ToString(); NavWesh = new NavMesh(); if (!th.IsAlive) { th.Start(); } }
private static string G2I(long guid) { GObject[] items = GObjectList.GetItems(); foreach (GObject item in items) { if (item.GUID.Equals(guid)) { return(item.Name); } } return(null); }
public static GItem GetItem(string name) { GItem[] Items = GObjectList.GetItems(); foreach (GItem Item in Items) { if (Item.Name.Equals(name)) { return(Item); } } return(null); }
public static Value MyGear() { Dictionary <String, int> dic = new Dictionary <string, int>(StringComparer.InvariantCultureIgnoreCase); GItem[] items = GObjectList.GetEquippedItems(); foreach (GItem item in items) { dic.Add(item.Name, 1); } return(new Value(dic)); }
private GItem FindItem() { GItem[] items = GObjectList.GetItems(); foreach (GItem i in items) { if (i.Name == Item) { return(i); } } return(null); }
/*public BagManager() { * // make sure all bags are closed * * CloseAllBags(); * UpdateItems(); * * // check all contents * }*/ public void UpdateItems() { List <GItem> ItemList = new List <GItem>(); List <BagItem> BagItemList = new List <BagItem>(); long[] AllBags = GPlayerSelf.Me.Bags; long[] Contents; int SlotCount; for (int bag = 0; bag <= 4; bag++) { SlotCount = 0; if (bag == 0) { Contents = GContext.Main.Me.BagContents; SlotCount = GContext.Main.Me.SlotCount; } else { GContainer container = (GContainer)GObjectList.FindObject(AllBags[bag - 1]); if (container != null) { Contents = container.BagContents; SlotCount = container.SlotCount; } else { Contents = null; } } if (Contents != null) { for (int i = 0; i < Contents.Length; i++) { GItem CurItem = (GItem)GObjectList.FindObject(Contents[i]); if (CurItem != null) { ItemList.Add(CurItem); BagItem bi = new BagItem(bag, SlotCount - i, CurItem); BagItemList.Add(bi); } } } } Items = ItemList.ToArray(); BagItems = BagItemList.ToArray(); }
GNode FindMailbox() { // Find mailbox GNode[] nodes = GObjectList.GetNodes(); foreach (GNode node in nodes) { if (node.IsMailBox) { if (mailbox == null || node.DistanceToSelf < mailbox.DistanceToSelf) { mailbox = node; } } } return(mailbox); }
public static bool EquipBetterBag() { GItem[] Items = GObjectList.GetItems(); foreach (GItem Item in Items) { if (Item.Type.ToString() == "Container" && !IsEquippedBag(Item.GUID)) { GContainer bag = (GContainer)GObjectList.FindObject(Item.GUID); if (bag != null) { long[] AllBags = GPlayerSelf.Me.Bags; for (int i = 0; i < AllBags.Length; i++) { GContainer cbag = (GContainer)GObjectList.FindObject(AllBags[i]); if (cbag != null) { if (cbag.SlotCount < bag.SlotCount && !cbag.Name.ToString().ToLower().Contains("ammo") && !cbag.Name.ToString().ToLower().Contains("quiver")) { GInterfaceObject OldBag = GContext.Main.Interface.GetByName("CharacterBag" + i + "Slot"); BagManager bm = new BagManager(); bm.ClickItem(Item, false); Functions.Click(OldBag, false); for (int p = 1; p <= 4; p++) { if (Popup.IsVisible(p)) { String text = Popup.GetText(p); PPather.WriteLine("Inventory: Got a popup ('" + text + "')"); if (text.Contains("will bind it to you")) { Popup.ClickButton(p, 1); } else { Popup.ClickButton(p, 2); } } } return(true); } } } } } } return(true); }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/json"; GObject obj = new GObject(); obj.Add("name", "任肖").Add("age", "19").Add("desc", "你好爱上飞Y&*^*(67Y*(OIH*^_(*\"\n\tdd3").Add("sex", true).Add("day", DateTime.Now); ; GObjectList list = new GObjectList(); for (int i = 0; i < 10; i++) { GObject obj1 = new GObject(); obj1["name"] = "名字1"; obj1["sex"] = false; obj1["day"] = DateTime.Now; list.Add(obj1); } obj["list"] = list; context.Response.Write(obj.GetJSON()); }
public GPlayer GetClosestPlayer() { GPlayer[] plys = GObjectList.GetPlayers(); GPlayer ClosestPlayer = null; foreach (GPlayer p in plys) { if (p != Me) { if (ClosestPlayer == null || p.GetDistanceTo(Me) < ClosestPlayer.GetDistanceTo(Me)) { ClosestPlayer = p; } } } return(ClosestPlayer); }
GNode FindItemToHarvest() { // Find stuff to loot GNode closest = null; GNode[] nodes = GObjectList.GetNodes(); foreach (GNode node in nodes) { if (ShouldHarvest(node)) { if (closest == null || node.DistanceToSelf < closest.DistanceToSelf) { closest = node; } } } return(closest); }
public override bool WantToDoSomething() { if (GObjectList.GetNearestAttacker(0) != null) { return(false); } GUnit prevMonster = monster; monster = FindMobToLoot(); if (monster != prevMonster) { lootTask = null; walkTask = null; } if (walkTask != null) { // check result of walking if (walkTask.MoveResult != EasyMover.MoveResult.Moving && walkTask.MoveResult != EasyMover.MoveResult.GotThere) { PPather.WriteLine("Can't reach " + monster.Name + ". blacklist. " + walkTask.MoveResult); ppather.Blacklist(monster); return(false); } } // at my pos and at target pos if (monster != null && !ppather.IsItSafeAt(null, monster)) { PPather.WriteLine("It is not safe at: " + monster.Name); DidLoot(monster); // ignore that monster = null; } if (monster != null && !ppather.IsItSafeAt(null, GContext.Main.Me)) { monster = null; } return(monster != null); }
GUnit FindMobToLoot() { // Find stuff to loot GUnit closest = null; GMonster[] monsters = GObjectList.GetMonsters(); foreach (GMonster monster in monsters) { if ((monster.IsLootable || (monster.IsSkinnable && Skin)) && ShouldLoot(monster)) { if (closest == null || monster.DistanceToSelf < closest.DistanceToSelf) { closest = monster; } } } return(closest); }
public static Value MyBagNames() { Dictionary <String, int> dic = new Dictionary <string, int>(StringComparer.InvariantCultureIgnoreCase); long[] AllBags = GPlayerSelf.Me.Bags; for (int bag = 1; bag <= 4; bag++) { GContainer container = (GContainer)GObjectList.FindObject(AllBags[bag - 1]); if (container != null) { string ItemName = container.Name; int OldCount = 0; dic.TryGetValue(ItemName, out OldCount); dic.Remove(ItemName); dic.Add(ItemName, OldCount + 1); } } return(new Value(dic)); }
public static Value MyDurability() { float worst = 1.0f; GItem[] items = GObjectList.GetEquippedItems(); foreach (GItem item in items) { if (item.DurabilityMax > 0) { float dur = (float)item.Durability; if (dur < worst) { worst = dur; } } } return(new Value(worst)); }
public static bool HasFreeBagSlot() { int count = 0; long[] AllBags = GPlayerSelf.Me.Bags; foreach (long CurrentBag in AllBags) { GContainer bag = (GContainer)GObjectList.FindObject(CurrentBag); if (bag != null) { count++; } } if (count == 4) { return(false); } return(true); }
public static bool EquipBetterBag(GItem Item, string BagSlotName) { GContainer bag = (GContainer)GObjectList.FindObject(Item.GUID); if (bag != null) { long[] AllBags = GPlayerSelf.Me.Bags; for (int i = 0; i < AllBags.Length; i++) { GContainer cbag = (GContainer)GObjectList.FindObject(AllBags[i]); if (cbag != null) { GInterfaceObject OldBag = GContext.Main.Interface.GetByName(BagSlotName); BagManager bm = new BagManager(); bm.ClickItem(Item, false); Functions.Click(OldBag, false); for (int p = 1; p <= 4; p++) { if (Popup.IsVisible(p)) { String text = Popup.GetText(p); PPather.WriteLine("Inventory: Got a popup ('" + text + "')"); if (text.Contains("will bind it to you")) { Popup.ClickButton(p, 1); } else { Popup.ClickButton(p, 2); } } } bm.CloseAllBags(); return(true); } } } return(false); }
GUnit FindMobToPull() { // TODO better elite/max level decision, this at least prevents // attacking flight masters int minLevel = nodetask.GetValueOfId("MinLevel").GetIntValue(); int maxLevel = nodetask.GetValueOfId("MaxLevel").GetIntValue(); // TODO add active pvp option // int doPvp = ...; // Find stuff to pull GUnit closest = null; GMonster[] monsters = GObjectList.GetMonsters(); foreach (GMonster monster in monsters) { if (!monster.IsDead && (!monster.IsTagged || monster.IsTargetingMe || monster.IsTargetingMyPet) && !ppather.IsBlacklisted(monster) && !PPather.IsPlayerFaction(monster) && (!monster.IsPlayer /*|| (doPvp && (GPlayer)monster).IsPVP)*/) && !PPather.IsStupidItem(monster)) { double dangerd = (double)DangerDistance + ((monster.IsElite ? 1.25 : 1.0) * (monster.Level - GContext.Main.Me.Level)); if (monster.Reaction == GReaction.Hostile && !monster.IsElite && minLevel <= monster.Level && monster.Level <= maxLevel && monster.DistanceToSelf < dangerd && Math.Abs(monster.Location.Z - GContext.Main.Me.Location.Z) < 15.0) { if (closest == null || monster.DistanceToSelf < closest.DistanceToSelf) { closest = monster; } } } } return(closest); }
/// <summary> /// 用GObjectList构建json对象 /// </summary> /// <param name="list"></param> public JSONObject(GObjectList list) { this.data = list; }