public static string NpcName() { var result = ""; if (Storage.UnitTemplates.IsEmpty()) return String.Empty; if (!Settings.SQLOutputFlag.HasAnyFlagBit(SQLOutput.creature_template)) return string.Empty; const string tableName = "creature_template"; if (SQLConnector.Enabled) { var rowsUpd = new List<QueryBuilder.SQLUpdateRow>(); foreach (var npcName in Storage.UnitTemplates) { var query = string.Format("SELECT name FROM {0}.creature_template WHERE entry={1};", Settings.TDBDatabase, npcName.Key); using (var reader = SQLConnector.ExecuteQuery(query)) { if (reader.HasRows) // possible update { while (reader.Read()) { var row = new QueryBuilder.SQLUpdateRow(); if (!Utilities.EqualValues(reader.GetValue(0), npcName.Value.Item1.Name)) row.AddValue("name", npcName.Value.Item1.Name); if (Utilities.EqualValues(reader.GetValue(0), npcName.Value.Item1.Name) && npcName.Value.Item1.femaleName != null) row.AddValue("femaleName", npcName.Value.Item1.femaleName); row.AddWhere("entry", npcName.Key); row.Table = tableName; if (row.ValueCount != 0) rowsUpd.Add(row); } } } } result += new QueryBuilder.SQLUpdate(rowsUpd).Build(); } return result; }
public static string PointsOfInterest() { if (Storage.GossipPOIs.IsEmpty()) { return(string.Empty); } var result = string.Empty; if (!Storage.GossipSelects.IsEmpty() && Settings.SQLOutputFlag.HasAnyFlagBit(SQLOutput.gossip_menu_option)) { var gossipPOIsTable = new Dictionary <Tuple <uint, uint>, uint>(); foreach (var poi in Storage.GossipPOIs) { foreach (var gossipSelect in Storage.GossipSelects) { var tuple = Tuple.Create(gossipSelect.Key.Item1, gossipSelect.Key.Item2); if (gossipPOIsTable.ContainsKey(tuple)) { continue; } var timeSpan = poi.Value.Item2 - gossipSelect.Value.Item2; if (timeSpan != null && timeSpan.Value.Duration() <= TimeSpan.FromSeconds(1)) { gossipPOIsTable.Add(tuple, poi.Key); } } } var rowsUpd = new List <QueryBuilder.SQLUpdateRow>(); foreach (var u in gossipPOIsTable) { var row = new QueryBuilder.SQLUpdateRow(); row.AddValue("action_poi_id", u.Value); row.AddWhere("menu_id", u.Key.Item1); row.AddWhere("id", u.Key.Item2); row.Table = "gossip_menu_option"; rowsUpd.Add(row); } result += new QueryBuilder.SQLUpdate(rowsUpd).Build(); } if (Settings.SQLOutputFlag.HasAnyFlagBit(SQLOutput.points_of_interest)) { const string tableName = "points_of_interest"; var rowsIns = new List <QueryBuilder.SQLInsertRow>(); uint count = 0; foreach (var poi in Storage.GossipPOIs) { var row = new QueryBuilder.SQLInsertRow(); row.AddValue("entry", "@ID+" + count, noQuotes: true); row.AddValue("x", poi.Value.Item1.XPos); row.AddValue("y", poi.Value.Item1.YPos); row.AddValue("icon", poi.Value.Item1.Icon); row.AddValue("flags", poi.Value.Item1.Flags); row.AddValue("data", poi.Value.Item1.Data); row.AddValue("icon_name", poi.Value.Item1.IconName); rowsIns.Add(row); count++; } result += new QueryBuilder.SQLDelete(Tuple.Create("@ID+0", "@ID+" + (count - 1)), "entry", tableName).Build(); result += new QueryBuilder.SQLInsert(tableName, rowsIns, withDelete: false).Build(); } return(result); }
public static string PointsOfInterest() { if (Storage.GossipPOIs.IsEmpty()) return string.Empty; var result = string.Empty; if (!Storage.GossipSelects.IsEmpty() && Settings.SQLOutputFlag.HasAnyFlagBit(SQLOutput.gossip_menu_option)) { var gossipPOIsTable = new Dictionary<Tuple<uint, uint>, uint>(); foreach (var poi in Storage.GossipPOIs) { foreach (var gossipSelect in Storage.GossipSelects) { var tuple = Tuple.Create(gossipSelect.Key.Item1, gossipSelect.Key.Item2); if (gossipPOIsTable.ContainsKey(tuple)) continue; var timeSpan = poi.Value.Item2 - gossipSelect.Value.Item2; if (timeSpan != null && timeSpan.Value.Duration() <= TimeSpan.FromSeconds(1)) gossipPOIsTable.Add(tuple, poi.Key); } } var rowsUpd = new List<QueryBuilder.SQLUpdateRow>(); foreach (var u in gossipPOIsTable) { var row = new QueryBuilder.SQLUpdateRow(); row.AddValue("action_poi_id", u.Value); row.AddWhere("menu_id", u.Key.Item1); row.AddWhere("id", u.Key.Item2); row.Table = "gossip_menu_option"; rowsUpd.Add(row); } result += new QueryBuilder.SQLUpdate(rowsUpd).Build(); } if (Settings.SQLOutputFlag.HasAnyFlagBit(SQLOutput.points_of_interest)) { const string tableName = "points_of_interest"; var rowsIns = new List<QueryBuilder.SQLInsertRow>(); uint count = 0; foreach (var poi in Storage.GossipPOIs) { var row = new QueryBuilder.SQLInsertRow(); row.AddValue("ID", "@ID+" + count, noQuotes: true); row.AddValue("PositionX", poi.Value.Item1.PositionX); row.AddValue("PositionY", poi.Value.Item1.PositionY); row.AddValue("Icon", poi.Value.Item1.Icon); row.AddValue("Flags", poi.Value.Item1.Flags); row.AddValue("Importance", poi.Value.Item1.Importance); row.AddValue("Name", poi.Value.Item1.Name); rowsIns.Add(row); count++; } result += new QueryBuilder.SQLDelete(Tuple.Create("@ID+0", "@ID+" + (count - 1)), "entry", tableName).Build(); result += new QueryBuilder.SQLInsert(tableName, rowsIns, withDelete: false).Build(); } return result; }
public static string NpcTemplateNonWDB(Dictionary<WowGuid, Unit> units) { /* if (ClientVersion.AddedInVersion(ClientType.WarlordsOfDraenor)) return string.Empty;*/ if (units.Count == 0) return string.Empty; /*if (!Settings.SQLOutputFlag.HasAnyFlagBit(SQLOutput.creature_template)) return string.Empty;*/ var levels = GetLevels(units); var result = string.Empty; const string tableName = "creature_template"; var rowsIns = new List<QueryBuilder.SQLUpdateRow>(); uint count = 0; var templates = new StoreDictionary<uint, UnitTemplateNonWDB>(); foreach (var unit in units) { if (templates.ContainsKey(unit.Key.GetEntry())) continue; var row = new QueryBuilder.SQLUpdateRow(); var npc = unit.Value; var template = new UnitTemplateNonWDB { //GossipMenuId = npc.GossipId, MinLevel = (int) levels[unit.Key.GetEntry()].Item1, MaxLevel = (int) levels[unit.Key.GetEntry()].Item2, Faction = npc.Faction.GetValueOrDefault(35), NpcFlag = (uint) npc.NpcFlags.GetValueOrDefault(NPCFlags.None), SpeedRun = npc.Movement.RunSpeed, SpeedWalk = npc.Movement.WalkSpeed /*BaseAttackTime = npc.MeleeTime.GetValueOrDefault(2000), RangedAttackTime = npc.RangedTime.GetValueOrDefault(2000), UnitClass = (uint) npc.Class.GetValueOrDefault(Class.Warrior), UnitFlag = (uint) npc.UnitFlags.GetValueOrDefault(UnitFlags.None), UnitFlag2 = (uint) npc.UnitFlags2.GetValueOrDefault(UnitFlags2.None), DynamicFlag = (uint) npc.DynamicFlags.GetValueOrDefault(UnitDynamicFlags.None), VehicleId = npc.Movement.VehicleId, HoverHeight = npc.HoverHeight.GetValueOrDefault(1.0f)*/ }; if (template.Faction == 1 || template.Faction == 2 || template.Faction == 3 || template.Faction == 4 || template.Faction == 5 || template.Faction == 6 || template.Faction == 115 || template.Faction == 116 || template.Faction == 1610 || template.Faction == 1629 || template.Faction == 2203 || template.Faction == 2204) // player factions template.Faction = 35; /* template.UnitFlag &= ~(uint)UnitFlags.IsInCombat; template.UnitFlag &= ~(uint)UnitFlags.PetIsAttackingTarget; template.UnitFlag &= ~(uint)UnitFlags.PlayerControlled; template.UnitFlag &= ~(uint)UnitFlags.Silenced; template.UnitFlag &= ~(uint)UnitFlags.PossessedByPlayer; if (!ClientVersion.AddedInVersion(ClientType.WarlordsOfDraenor)) { template.DynamicFlag &= ~(uint)UnitDynamicFlags.Lootable; template.DynamicFlag &= ~(uint)UnitDynamicFlags.Tapped; template.DynamicFlag &= ~(uint)UnitDynamicFlags.TappedByPlayer; template.DynamicFlag &= ~(uint)UnitDynamicFlags.TappedByAllThreatList; } else { template.DynamicFlag &= ~(uint)UnitDynamicFlagsWOD.Lootable; template.DynamicFlag &= ~(uint)UnitDynamicFlagsWOD.Tapped; template.DynamicFlag &= ~(uint)UnitDynamicFlagsWOD.TappedByPlayer; template.DynamicFlag &= ~(uint)UnitDynamicFlagsWOD.TappedByAllThreatList; }*/ // has trainer flag but doesn't have prof nor class trainer flag if ((template.NpcFlag & (uint) NPCFlags.Trainer) != 0 && ((template.NpcFlag & (uint) NPCFlags.ProfessionTrainer) == 0 || (template.NpcFlag & (uint) NPCFlags.ClassTrainer) == 0)) { UnitTemplate unitData; var subname = GetSubName((int)unit.Key.GetEntry(), false); // Fall back if (Storage.UnitTemplates.TryGetValue(unit.Key.GetEntry(), out unitData)) { if (unitData.SubName.Length > 0) template.NpcFlag |= ProcessNpcFlags(unitData.SubName); else // If the SubName doesn't exist or is cached, fall back to DB method template.NpcFlag |= ProcessNpcFlags(subname); } else // In case we have NonWDB data which doesn't have an entry in UnitTemplates template.NpcFlag |= ProcessNpcFlags(subname); } row.AddValue("minlevel", template.MinLevel); row.AddValue("maxlevel", template.MaxLevel); row.AddValue("faction", template.Faction); row.AddValue("npcflag", template.NpcFlag); row.AddValue("speed_walk", template.SpeedWalk); row.AddValue("speed_run", template.SpeedRun); row.AddWhere("entry", unit.Key.GetEntry()); row.Table = tableName; rowsIns.Add(row); count++; templates.Add(unit.Key.GetEntry(), template); } //result += new QueryBuilder.SQLDelete(Tuple.Create("@ID+0", "@ID+" + (count - 1)), "entry", tableName).Build(); result += new QueryBuilder.SQLUpdate(rowsIns).Build(); return result; /*var templatesDb = SQLDatabase.GetDict<uint, UnitTemplateNonWDB>(templates.Keys()); return SQLUtil.CompareDicts(templates, templatesDb, StoreNameType.Unit);*/ }