public static void LaunchRadar() { int d; var myConn = new MySqlConnection("server=127.0.0.1; user id=tnb; password=tnb006; database=offydump;"); try { myConn.Open(); } catch (Exception e) { Logging.WriteError(e.ToString()); return; } // Various mount repair, portable mailbox, repair robots, Guild Page... var BlackListed = new List <int>(new[] { 77789, 32638, 32639, 32641, 32642, 35642, 191605, 24780, 29561, 49586, 49588, 62822, 211006 }); //Spell WildCharge = new Spell("Wild Charge"); while (true) { /*WoWUnit target = ObjectManager.Target; * if (target.IsValid) * { * Logging.Write("Distance to target (" + target.Name + ") : " + target.GetDistance); * Logging.Write("Target CombatReach : " + target.GetCombatReach); * Logging.Write("Target BoundingRadius : " + target.GetBoundingRadius); * Logging.Write("In Range ? " + CombatClass.InSpellRange(target, WildCharge.MinRangeHostile, WildCharge.MaxRangeHostile)); * }*/ Thread.Sleep(650 * 2); // Every 2 ObjectManager refresh // Prevent corruptions while the game loads after a zone change if (!Usefuls.InGame || Usefuls.IsLoading) { continue; } var npcRadar = new List <Npc>(); List <WoWGameObject> Mailboxes = ObjectManager.GetWoWGameObjectOfType(WoWGameObjectType.Mailbox); List <WoWUnit> Vendors = ObjectManager.GetWoWUnitVendor(); List <WoWUnit> Repairers = ObjectManager.GetWoWUnitRepair(); List <WoWUnit> Inkeepers = ObjectManager.GetWoWUnitInkeeper(); List <WoWUnit> Trainers = ObjectManager.GetWoWUnitTrainer(); List <WoWUnit> FlightMasters = ObjectManager.GetWoWUnitFlightMaster(); List <WoWUnit> Auctioneers = ObjectManager.GetWoWUnitAuctioneer(); List <WoWUnit> SpiritHealers = ObjectManager.GetWoWUnitSpiritHealer(); List <WoWUnit> SpiritGuides = ObjectManager.GetWoWUnitSpiritGuide(); List <WoWUnit> NpcMailboxes = ObjectManager.GetWoWUnitMailbox(); var npcRadarQuesters = new List <Npc>(); List <WoWUnit> NpcQuesters = ObjectManager.GetWoWUnitQuester(); List <WoWGameObject> ObjectQuesters = ObjectManager.GetWoWGameObjectOfType(WoWGameObjectType.Questgiver); List <WoWGameObject> Forges = ObjectManager.GetWoWGameObjectOfType(WoWGameObjectType.SpellFocus); List <WoWGameObject> AllGos = ObjectManager.GetObjectWoWGameObject(); foreach (WoWGameObject go in AllGos) { string query = ""; try { if (go.Entry != 0 && go.Name != "" && go.CreatedBy == 0) { query = "SELECT entry FROM gameobject WHERE entry = " + go.Entry + " AND " + "map = " + Usefuls.RealContinentId + " AND " + "SQRT((x-" + go.Position.X + ")*(x-" + go.Position.X + ") + " + "(y-" + go.Position.Y + ")*(y-" + go.Position.Y + ") + " + "(z-" + go.Position.Z + ")*(z-" + go.Position.Z + ")) < 0.5;"; var cmd = new MySqlCommand(query, myConn); MySqlDataReader result = cmd.ExecuteReader(); if (!result.HasRows && go.GOType != WoWGameObjectType.MoTransport && go.GOType != WoWGameObjectType.Transport) { result.Close(); Quaternion rotations = go.Rotations; Matrix4 matrice = go.WorldMatrix; query = "INSERT INTO gameobject (entry,map,x,y,z,o,r0,r1,r2,r3,m11,m12,m13,m14,m21,m22,m23,m24,m31,m32,m33,m34,m41,m42,m43,m44) VALUES (" + go.Entry + "," + Usefuls.RealContinentId + "," + go.Position.X + "," + go.Position.Y + "," + go.Position.Z + "," + go.Orientation + "," + rotations.X + "," + rotations.Y + "," + rotations.Z + "," + rotations.W + "," + matrice.xx + "," + matrice.xy + "," + matrice.xz + "," + matrice.xw + "," + matrice.yx + "," + matrice.yy + "," + matrice.yz + "," + matrice.yw + "," + matrice.zx + "," + matrice.zy + "," + matrice.zz + "," + matrice.zw + "," + matrice.wx + "," + matrice.wy + "," + matrice.wz + "," + matrice.ww + ");"; cmd = new MySqlCommand(query, myConn); cmd.ExecuteNonQuery(); } else { result.Close(); } //bool newAdded = false; query = "SELECT entry,questitem1 FROM gameobject_template WHERE entry = " + go.Entry + ";"; cmd = new MySqlCommand(query, myConn); result = cmd.ExecuteReader(); if (!result.HasRows) { result.Close(); query = "INSERT IGNORE INTO gameobject_template (entry,type,name,iconname,castbarcaption,model,faction,flags,size"; for (uint i = 0; i < 32; i++) { query += ",data" + i; } query += ",questitem1,questitem2,questitem3,questitem4) VALUES (" + go.Entry + "," + (uint)go.GOType + ",'" + go.Name.Replace("'", "\\'") + "','" + go.IconName.Replace("'", "\\'") + "','" + go.CastBarCaption.Replace("'", "\\'") + "'," + go.DisplayId + "," + go.Faction + "," + (uint)go.GOFlags + "," + go.Size; for (uint i = 0; i < 32; i++) { query += "," + go.Data(i); } query += "," + go.QuestItem1 + "," + go.QuestItem2 + "," + go.QuestItem3 + "," + go.QuestItem4; query += ");"; cmd = new MySqlCommand(query, myConn); cmd.ExecuteNonQuery(); //newAdded = true; } else { result.Read(); int questitem = result.GetInt32(1); result.Close(); if (questitem > 1000000 || questitem < 0) // 1065353216 { query = "UPDATE gameobject_template set size = " + go.Size + ", questitem1 = " + go.QuestItem1 + ", questitem2 = " + go.QuestItem2 + ", questitem3 = " + go.QuestItem3 + ", questitem4 = " + go.QuestItem4 + " WHERE entry =" + go.Entry + ";"; cmd = new MySqlCommand(query, myConn); cmd.ExecuteNonQuery(); } } /*if (!newAdded && go.IconName != "") * { * query = "UPDATE gameobject_template set iconname='" + go.IconName + "' WHERE entry =" + go.Entry + ";"; * cmd = new MySqlCommand(query, myConn); * cmd.ExecuteNonQuery(); * } * if (!newAdded && go.CastBarCaption != "") * { * query = "UPDATE gameobject_template set castbarcaption='" + go.CastBarCaption + "' WHERE entry =" + go.Entry + ";"; * cmd = new MySqlCommand(query, myConn); * cmd.ExecuteNonQuery(); * }*/ } } catch (Exception) { Logging.Write("This query has a problem ? " + query); } } foreach (WoWGameObject o in Mailboxes) { if (o.CreatedBy != 0) { continue; } npcRadar.Add(new Npc { ContinentIdInt = Usefuls.ContinentId, Entry = o.Entry, Faction = UnitRelation.GetObjectRacialFaction(o.Faction), Name = o.Name, Position = o.Position, Type = Npc.NpcType.Mailbox }); } foreach (WoWUnit n in Vendors) { if (BlackListed.Contains(n.Entry) || n.CreatedBy != 0) { continue; } npcRadar.Add(new Npc { ContinentIdInt = Usefuls.ContinentId, Entry = n.Entry, Faction = UnitRelation.GetObjectRacialFaction(n.Faction), Name = n.Name, Position = n.Position, Type = Npc.NpcType.Vendor }); } foreach (WoWUnit n in Repairers) { if (BlackListed.Contains(n.Entry) || n.CreatedBy != 0) { continue; } npcRadar.Add(new Npc { ContinentIdInt = Usefuls.ContinentId, Entry = n.Entry, Faction = UnitRelation.GetObjectRacialFaction(n.Faction), Name = n.Name, Position = n.Position, Type = Npc.NpcType.Repair }); } foreach (WoWUnit n in Inkeepers) { npcRadar.Add(new Npc { ContinentIdInt = Usefuls.ContinentId, Entry = n.Entry, Faction = UnitRelation.GetObjectRacialFaction(n.Faction), Name = n.Name, Position = n.Position, Type = Npc.NpcType.Innkeeper }); } foreach (WoWUnit n in Trainers) { Npc.NpcType newtype; if (n.SubName.Contains("Alchemy") || n.SubName.Contains("alchimistes")) { newtype = Npc.NpcType.AlchemyTrainer; } else if (n.SubName.Contains("Blacksmithing") || n.SubName.Contains("forgerons")) { newtype = Npc.NpcType.BlacksmithingTrainer; } else if (n.SubName.Contains("Enchanting") || n.SubName.Contains("enchanteurs")) { newtype = Npc.NpcType.EnchantingTrainer; } else if (n.SubName.Contains("Engineering") || n.SubName.Contains("ingénieurs")) { newtype = Npc.NpcType.EngineeringTrainer; } else if (n.SubName.Contains("Herbalism") || n.SubName.Contains("herboristes")) { newtype = Npc.NpcType.HerbalismTrainer; } else if (n.SubName.Contains("Inscription") || n.SubName.Contains("calligraphes")) { newtype = Npc.NpcType.InscriptionTrainer; } else if (n.SubName.Contains("Jewelcrafting") || n.SubName.Contains("joailliers")) { newtype = Npc.NpcType.JewelcraftingTrainer; } else if (n.SubName.Contains("Leatherworking") || n.SubName.Contains("travailleurs du cuir")) { newtype = Npc.NpcType.LeatherworkingTrainer; } else if (n.SubName.Contains("Mining") || n.SubName.Contains("mineurs")) { newtype = Npc.NpcType.MiningTrainer; } else if (n.SubName.Contains("Skinning") || n.SubName.Contains("dépeceurs")) { newtype = Npc.NpcType.SkinningTrainer; } else if (n.SubName.Contains("Tailoring") || n.SubName.Contains("tailleurs")) { newtype = Npc.NpcType.TailoringTrainer; } else if (n.SubName.Contains("Archaeology") || n.SubName.Contains("archéologues")) { newtype = Npc.NpcType.ArchaeologyTrainer; } else if (n.SubName.Contains("Cooking") || n.SubName.Contains("cuisiniers")) { newtype = Npc.NpcType.CookingTrainer; } else if (n.SubName.Contains("First Aid") || n.SubName.Contains("secouristes")) { newtype = Npc.NpcType.FirstAidTrainer; } else if (n.SubName.Contains("Fishing") || n.SubName.Contains("pêche")) { newtype = Npc.NpcType.FishingTrainer; } else if (n.SubName.Contains("Riding") || n.SubName.Contains(" de vol") || n.SubName.Contains(" de monte")) { newtype = Npc.NpcType.RidingTrainer; } else { continue; } npcRadar.Add(new Npc { ContinentIdInt = Usefuls.ContinentId, Entry = n.Entry, Faction = UnitRelation.GetObjectRacialFaction(n.Faction), Name = n.Name, Position = n.Position, Type = newtype }); } foreach (WoWUnit n in SpiritHealers) { npcRadar.Add(new Npc { ContinentIdInt = Usefuls.ContinentId, Entry = n.Entry, Faction = UnitRelation.GetObjectRacialFaction(n.Faction), Name = n.Name, Position = n.Position, Type = Npc.NpcType.SpiritHealer }); } foreach (WoWUnit n in SpiritGuides) { npcRadar.Add(new Npc { ContinentIdInt = Usefuls.ContinentId, Entry = n.Entry, Faction = UnitRelation.GetObjectRacialFaction(n.Faction), Name = n.Name, Position = n.Position, Type = Npc.NpcType.SpiritGuide }); } foreach (WoWUnit n in NpcMailboxes) { if (BlackListed.Contains(n.Entry) || n.CreatedBy != 0) { continue; } npcRadar.Add(new Npc { ContinentIdInt = Usefuls.ContinentId, Entry = n.Entry, Faction = UnitRelation.GetObjectRacialFaction(n.Faction), Name = n.Name, Position = n.Position, Type = Npc.NpcType.Mailbox }); } foreach (WoWUnit n in Auctioneers) { npcRadar.Add(new Npc { ContinentIdInt = Usefuls.ContinentId, Entry = n.Entry, Faction = UnitRelation.GetObjectRacialFaction(n.Faction), Name = n.Name, Position = n.Position, Type = Npc.NpcType.Auctioneer }); } foreach (WoWUnit n in NpcQuesters) { if (BlackListed.Contains(n.Entry) || n.CreatedBy != 0) { continue; } npcRadarQuesters.Add(new Npc { ContinentIdInt = Usefuls.ContinentId, Entry = n.Entry, Faction = UnitRelation.GetObjectRacialFaction(n.Faction), Name = n.Name, Position = n.Position, Type = Npc.NpcType.QuestGiver }); } foreach (WoWGameObject o in ObjectQuesters) { if (o.CreatedBy != 0) { continue; } npcRadarQuesters.Add(new Npc { ContinentIdInt = Usefuls.ContinentId, Entry = o.Entry, Faction = UnitRelation.GetObjectRacialFaction(o.Faction), Name = o.Name, Position = o.Position, Type = Npc.NpcType.QuestGiver }); } foreach (WoWGameObject o in Forges) { if (o.CreatedBy != 0) { continue; } Npc.NpcType newtype; switch (o.Data0) { case 3: newtype = Npc.NpcType.SmeltingForge; break; case 1552: newtype = Npc.NpcType.RuneForge; break; default: continue; } npcRadar.Add(new Npc { ContinentIdInt = Usefuls.ContinentId, Entry = o.Entry, Faction = UnitRelation.GetObjectRacialFaction(o.Faction), Name = o.Name, Position = o.Position, Type = newtype }); } d = NpcDB.AddNpcRange(npcRadar, true); if (d > 0) { Logging.Write("Found " + d + " new NPCs/Mailboxes in memory"); } d = AddQuesters(npcRadarQuesters, true); if (d == 1) { Logging.Write("Found " + d + " new Quest Giver in memory"); } else if (d > 1) { Logging.Write("Found " + d + " new Quest Givers in memory"); } } }
// Various mount repair, portable mailbox, repair robots, Guild Page... public static void PulseRadar() { if (!Usefuls.InGame || Usefuls.IsLoading) { return; } var npcRadar = new List <Npc>(); List <WoWGameObject> Mailboxes = ObjectManager.GetWoWGameObjectOfType(WoWGameObjectType.Mailbox); List <WoWUnit> Vendors = ObjectManager.GetWoWUnitVendor(); List <WoWUnit> Repairers = ObjectManager.GetWoWUnitRepair(); List <WoWUnit> NpcMailboxes = ObjectManager.GetWoWUnitMailbox(); var npcRadarQuesters = new List <Npc>(); List <WoWUnit> NpcQuesters = ObjectManager.GetWoWUnitQuester(); List <WoWGameObject> ObjectQuesters = ObjectManager.GetWoWGameObjectOfType(WoWGameObjectType.Questgiver); foreach (WoWGameObject o in Mailboxes) { if (o.CreatedBy != 0) { continue; } npcRadar.Add(new Npc { ContinentIdInt = Usefuls.ContinentId, Entry = o.Entry, Faction = UnitRelation.GetObjectRacialFaction(o.Faction), Name = o.Name, Position = o.Position, Type = Npc.NpcType.Mailbox }); } foreach (WoWUnit n in Vendors) { if (BlackListed.Contains(n.Entry) || n.CreatedBy != 0) { continue; } npcRadar.Add(new Npc { ContinentIdInt = Usefuls.ContinentId, Entry = n.Entry, Faction = UnitRelation.GetObjectRacialFaction(n.Faction), Name = n.Name, Position = n.Position, Type = Npc.NpcType.Vendor }); } foreach (WoWUnit n in Repairers) { if (BlackListed.Contains(n.Entry) || n.CreatedBy != 0) { continue; } npcRadar.Add(new Npc { ContinentIdInt = Usefuls.ContinentId, Entry = n.Entry, Faction = UnitRelation.GetObjectRacialFaction(n.Faction), Name = n.Name, Position = n.Position, Type = Npc.NpcType.Repair }); } foreach (WoWUnit n in NpcMailboxes) { if (BlackListed.Contains(n.Entry) || n.CreatedBy != 0) { continue; } npcRadar.Add(new Npc { ContinentIdInt = Usefuls.ContinentId, Entry = n.Entry, Faction = UnitRelation.GetObjectRacialFaction(n.Faction), Name = n.Name, Position = n.Position, Type = Npc.NpcType.Mailbox }); } foreach (WoWUnit n in NpcQuesters) { if (BlackListed.Contains(n.Entry) || n.CreatedBy != 0) { continue; } npcRadarQuesters.Add(new Npc { ContinentIdInt = Usefuls.ContinentId, Entry = n.Entry, Faction = UnitRelation.GetObjectRacialFaction(n.Faction), Name = n.Name, Position = n.Position, Type = Npc.NpcType.QuestGiver }); } foreach (WoWGameObject o in ObjectQuesters) { if (o.CreatedBy != 0) { continue; } npcRadarQuesters.Add(new Npc { ContinentIdInt = Usefuls.ContinentId, Entry = o.Entry, Faction = UnitRelation.GetObjectRacialFaction(o.Faction), Name = o.Name, Position = o.Position, Type = Npc.NpcType.QuestGiver }); } int d = NpcDB.AddNpcRange(npcRadar, true); if (d == 1) { Logging.Write("Found " + d + " new NPC/Mailbox in memory"); } else if (d > 1) { Logging.Write("Found " + d + " new NPCs/Mailboxes in memory"); } d = AddQuesters(npcRadarQuesters, true); if (d == 1) { Logging.Write("Found " + d + " new Quest Giver in memory"); } else if (d > 1) { Logging.Write("Found " + d + " new Quest Givers in memory"); } }
private void SearchObjectButton_Click(object sender, EventArgs e) { try { SearchObjectButton.Enabled = false; string searchString = ""; if (InputBox(SearchObjectButton.Text, searchInputBox, ref searchString) != DialogResult.OK) { SearchObjectButton.Enabled = true; return; } if (!ObjectManager.Me.IsValid) { SearchObjectButton.Enabled = true; return; } if (string.IsNullOrEmpty(searchString)) { MessageBox.Show(nManager.Translate.Get(nManager.Translate.Id.Name_Empty)); SearchObjectButton.Enabled = true; return; } var npc = new Npc(); List <WoWGameObject> gameObjects = ObjectManager.GetWoWGameObjectByName(searchString); if (gameObjects.Count > 0) { WoWGameObject gameObject = ObjectManager.GetNearestWoWGameObject(gameObjects, true); if (gameObject.IsValid) { npc.Entry = gameObject.Entry; npc.Position = gameObject.Position; npc.Name = gameObject.Name; npc.Faction = UnitRelation.GetObjectRacialFaction(gameObject.Faction); } } if (npc.Entry <= 0) { List <WoWUnit> units = ObjectManager.GetWoWUnitByName(searchString); if (units.Count > 0) { WoWUnit unit = ObjectManager.GetNearestWoWUnit(units, true, true, true); if (unit.IsValid) { npc.Entry = unit.Entry; npc.Position = unit.Position; npc.Name = unit.Name; npc.Faction = UnitRelation.GetObjectRacialFaction(unit.Faction); } } } if (npc.Entry <= 0) { MessageBox.Show(nManager.Translate.Get(nManager.Translate.Id.NPCNotFound)); SearchObjectButton.Enabled = true; return; } npc.ContinentIdInt = Usefuls.ContinentId; npc.Faction = (Npc.FactionType)Enum.Parse(typeof(Npc.FactionType), ObjectManager.Me.PlayerFaction, true); if (Usefuls.IsOutdoors) { npc.Position.Type = "Flying"; } InformationArea.Text = " <Npc>" + Environment.NewLine + " <Entry>" + npc.Entry + "</Entry>" + Environment.NewLine + " <Name>" + npc.Name + "</Name>" + Environment.NewLine + " <Position>" + Environment.NewLine + " <X>" + npc.Position.X + "</X>" + Environment.NewLine + " <Y>" + npc.Position.Y + "</Y>" + Environment.NewLine + " <Z>" + npc.Position.Z + "</Z>" + Environment.NewLine + " <Type>" + npc.Position.Type + "</Type>" + Environment.NewLine + " </Position>" + Environment.NewLine + " <Faction>" + (Npc.FactionType)Enum.Parse(typeof(Npc.FactionType), ObjectManager.Me.PlayerFaction, true) + "</Faction>" + Environment.NewLine + " <Type>None</Type>" + Environment.NewLine + " <ContinentId>" + npc.ContinentId + "</ContinentId>" + Environment.NewLine + " </Npc>"; } catch (Exception ex) { Logging.WriteError("DeveloperToolsMainFrame > SearchObjectButton_Click(object sender, EventArgs e): " + ex); } SearchObjectButton.Enabled = true; }