public void CreateSQLINSERTStatement(uint weenieClassID, IList <WeeniePropertiesCreateList> input, StreamWriter writer) { writer.WriteLine("INSERT INTO `weenie_properties_create_list` (`object_Id`, `destination_Type`, `weenie_Class_Id`, `stack_Size`, `palette`, `shade`, `try_To_Bond`)"); var lineGenerator = new Func <int, string>(i => { string weenieName = null; if (WeenieNames != null) { WeenieNames.TryGetValue(input[i].WeenieClassId, out weenieName); } var label = weenieName + $" ({input[i].WeenieClassId})"; if (input[i].WeenieClassId == 0) { //label = GetValueForTreasureData(weenieClassID, true); label = "nothing"; } return($"{weenieClassID}, {input[i].DestinationType}, {input[i].WeenieClassId.ToString().PadLeft(5)}, {input[i].StackSize.ToString().PadLeft(2)}, {input[i].Palette}, {input[i].Shade:0.######}, {input[i].TryToBond}) /* Create {label ?? "Unknown"} for {Enum.GetName(typeof(DestinationType), input[i].DestinationType)} */"); }); ValuesWriter(input.Count, lineGenerator, writer); }
public void CreateSQLINSERTStatement(IList <TreasureWielded> input, StreamWriter writer) { writer.WriteLine("INSERT INTO `treasure_wielded` (`treasure_Type`, `weenie_Class_Id`, `palette_Id`, `unknown_1`, `shade`, `stack_Size`, `stack_Size_Variance`, `probability`, `unknown_3`, `unknown_4`, `unknown_5`, `set_Start`, `has_Sub_Set`, `continues_Previous_Set`, `unknown_9`, `unknown_10`, `unknown_11`, `unknown_12`)"); var lineGenerator = new Func <int, string>(i => { string weenieLabel = null; if (WeenieNames != null) { WeenieNames.TryGetValue(input[i].WeenieClassId, out weenieLabel); } return ($"{input[i].TreasureType}, " + $"{input[i].WeenieClassId.ToString().PadLeft(5)}, " + $"{input[i].PaletteId.ToString().PadLeft(2)}, " + $"{input[i].Unknown1}, " + $"{input[i].Shade.ToString(CultureInfo.InvariantCulture).PadLeft(4)}, " + $"{input[i].StackSize}, " + $"{input[i].StackSizeVariance}, " + $"{input[i].Probability.ToString(CultureInfo.InvariantCulture).PadLeft(7)}, " + $"{input[i].Unknown3}, " + $"{input[i].Unknown4}, " + $"{input[i].Unknown5}, " + $"{input[i].SetStart.ToString().PadLeft(5)}, " + $"{input[i].HasSubSet.ToString().PadLeft(5)}, " + $"{input[i].ContinuesPreviousSet.ToString().PadLeft(5)}, " + $"{input[i].Unknown9}, " + $"{input[i].Unknown10}, " + $"{input[i].Unknown11}, " + $"{input[i].Unknown12}) /* {weenieLabel} */"); }); ValuesWriter(input.Count, lineGenerator, writer); }
/// <summary> /// Default is formed from: input.RecipeId.ToString("00000") + " " + [SuccessWeenieName or Cook Book Source] /// </summary> public string GetDefaultFileName(Recipe input, IList <CookBook> cookBooks, bool descOnly = false) { string description = null; if (WeenieNames != null) { if (WeenieNames.TryGetValue(input.SuccessWCID, out var weenieName)) { description = weenieName; } } string alternateDescription = null; if (cookBooks != null && cookBooks.Count > 0 && WeenieNames != null) { WeenieNames.TryGetValue(cookBooks[0].SourceWCID, out alternateDescription); for (int i = 1; i < cookBooks.Count; i++) { if (WeenieNames.TryGetValue(cookBooks[i].SourceWCID, out var sourceWeenieName) && sourceWeenieName != alternateDescription) { alternateDescription = null; break; } } } if (string.IsNullOrEmpty(description) && !string.IsNullOrEmpty(alternateDescription)) { description = alternateDescription; } if (description == "Cooking Pot" && !string.IsNullOrEmpty(alternateDescription)) { description = alternateDescription; } if (descOnly) { return(description); } string fileName = input.Id.ToString("00000"); if (!string.IsNullOrEmpty(description)) { fileName += " " + description; } fileName = IllegalInFileName.Replace(fileName, "_"); fileName += ".sql"; return(fileName); }
/// <exception cref="System.Exception">WeenieClassNames must be set, and must have a record for input.ClassId.</exception> public void CreateSQLINSERTStatement(IList <LandblockInstance> input, StreamWriter writer) { var instanceWcids = input.ToDictionary(i => i.Guid, i => i.WeenieClassId); input = input.OrderBy(r => r.Guid).ToList(); foreach (var value in input) { if (value != input[0]) { writer.WriteLine(); } writer.WriteLine("INSERT INTO `landblock_instance` (`guid`, `weenie_Class_Id`, `obj_Cell_Id`, `origin_X`, `origin_Y`, `origin_Z`, `angles_W`, `angles_X`, `angles_Y`, `angles_Z`, `is_Link_Child`, `last_Modified`)"); string label = null; if (WeenieNames != null) { WeenieNames.TryGetValue(value.WeenieClassId, out label); } var output = "VALUES (" + $"0x{value.Guid.ToString("X8")}, " + $"{value.WeenieClassId.ToString().PadLeft(5)}, " + $"0x{value.ObjCellId:X8}, " + $"{TrimNegativeZero(value.OriginX):0.######}, " + $"{TrimNegativeZero(value.OriginY):0.######}, " + $"{TrimNegativeZero(value.OriginZ):0.######}, " + $"{TrimNegativeZero(value.AnglesW):0.######}, " + $"{TrimNegativeZero(value.AnglesX):0.######}, " + $"{TrimNegativeZero(value.AnglesY):0.######}, " + $"{TrimNegativeZero(value.AnglesZ):0.######}, " + $"{value.IsLinkChild.ToString().PadLeft(5)}, " + $"'{value.LastModified:yyyy-MM-dd HH:mm:ss}'" + $"); /* {label} */" + Environment.NewLine + $"/* @teleloc 0x{value.ObjCellId:X8} [{TrimNegativeZero(value.OriginX):F6} {TrimNegativeZero(value.OriginY):F6} {TrimNegativeZero(value.OriginZ):F6}] {TrimNegativeZero(value.AnglesW):F6} {TrimNegativeZero(value.AnglesX):F6} {TrimNegativeZero(value.AnglesY):F6} {TrimNegativeZero(value.AnglesZ):F6} */"; output = FixNullFields(output); writer.WriteLine(output); if (value.LandblockInstanceLink != null && value.LandblockInstanceLink.Count > 0) { writer.WriteLine(); CreateSQLINSERTStatement(value.LandblockInstanceLink.OrderBy(r => r.ChildGuid).ToList(), instanceWcids, writer); } } }
/// <exception cref="System.Exception">WeenieClassNames must be set, and must have a record for input.ClassId.</exception> public void CreateSQLINSERTStatement(IList <LandblockInstance> input, StreamWriter writer) { input = input.OrderBy(r => r.Guid).ToList(); foreach (var value in input) { if (value != input[0]) { writer.WriteLine(); } writer.WriteLine("INSERT INTO `landblock_instance` (`guid`, `weenie_Class_Id`, `obj_Cell_Id`, `origin_X`, `origin_Y`, `origin_Z`, `angles_W`, `angles_X`, `angles_Y`, `angles_Z`, `is_Link_Child`, `last_Modified`)"); string label = null; if (WeenieNames != null) { WeenieNames.TryGetValue(value.WeenieClassId, out label); } var output = "VALUES (" + $"{value.Guid.ToString().PadLeft(10)}, " + $"{value.WeenieClassId.ToString().PadLeft(5)}, " + $"{value.ObjCellId}, " + $"{value.OriginX}, " + $"{value.OriginY}, " + $"{value.OriginZ}, " + $"{value.AnglesW}, " + $"{value.AnglesX}, " + $"{value.AnglesY}, " + $"{value.AnglesZ}, " + $"{value.IsLinkChild.ToString().PadLeft(5)}, " + $"'{value.LastModified.ToString("yyyy-MM-dd HH:mm:ss")}'" + $"); /* {label} */" + Environment.NewLine + $"/* @teleloc 0x{value.ObjCellId.ToString("X8")} [{value.OriginX.ToString("F6")} {value.OriginY.ToString("F6")} {value.OriginZ.ToString("F6")}] {value.AnglesW.ToString("F6")} {value.AnglesX.ToString("F6")} {value.AnglesY.ToString("F6")} {value.AnglesZ.ToString("F6")} */"; output = FixNullFields(output); writer.WriteLine(output); if (value.LandblockInstanceLink != null && value.LandblockInstanceLink.Count > 0) { writer.WriteLine(); CreateSQLINSERTStatement(value.LandblockInstanceLink.OrderBy(r => r.ChildGuid).ToList(), writer); } } }
public void CreateSQLINSERTStatement(uint weenieClassID, IList <WeeniePropertiesGenerator> input, StreamWriter writer) { writer.WriteLine("INSERT INTO `weenie_properties_generator` (`object_Id`, `probability`, `weenie_Class_Id`, " + "`delay`, `init_Create`, `max_Create`, `when_Create`, `where_Create`, `stack_Size`, `palette_Id`, `shade`, " + "`obj_Cell_Id`, `origin_X`, `origin_Y`, `origin_Z`, `angles_W`, `angles_X`, `angles_Y`, `angles_Z`)"); var lineGenerator = new Func <int, string>(i => { string weenieName = null; if (WeenieNames != null) { WeenieNames.TryGetValue(input[i].WeenieClassId, out weenieName); } var label = weenieName + $" ({input[i].WeenieClassId})"; if ((input[i].WhereCreate & (int)RegenLocationType.Treasure) != 0) { label = GetValueForTreasureData(input[i].WeenieClassId, false); } return($"{weenieClassID}, " + $"{input[i].Probability}, " + $"{input[i].WeenieClassId}, " + $"{input[i].Delay}, " + $"{input[i].InitCreate}, " + $"{input[i].MaxCreate}, " + $"{input[i].WhenCreate}, " + $"{input[i].WhereCreate}, " + $"{input[i].StackSize}, " + $"{input[i].PaletteId}, " + $"{input[i].Shade}, " + $"{input[i].ObjCellId}, " + $"{input[i].OriginX}, " + $"{input[i].OriginY}, " + $"{input[i].OriginZ}, " + $"{input[i].AnglesW}, " + $"{input[i].AnglesX}, " + $"{input[i].AnglesY}, " + $"{input[i].AnglesZ})" + $" /* Generate {label} (x{input[i].InitCreate:N0} up to max of {input[i].MaxCreate:N0}) - Regenerate upon {Enum.GetName(typeof(RegenerationType), input[i].WhenCreate)} - Location to (re)Generate: {Enum.GetName(typeof(RegenLocationType), input[i].WhereCreate)} */"); }); ValuesWriter(input.Count, lineGenerator, writer); }
public void CreateSQLINSERTStatement(IList <Encounter> input, StreamWriter writer) { writer.WriteLine("INSERT INTO `encounter` (`landblock`, `weenie_Class_Id`, `cell_X`, `cell_Y`)"); var lineGenerator = new Func <int, string>(i => { string label = null; if (WeenieNames != null) { WeenieNames.TryGetValue(input[i].WeenieClassId, out label); } return($"{input[i].Landblock}, {input[i].WeenieClassId}, {input[i].CellX}, {input[i].CellY}) /* {label} */"); }); ValuesWriter(input.Count, lineGenerator, writer); }
public void CreateSQLINSERTStatement(IList <CookBook> input, StreamWriter writer) { writer.WriteLine("INSERT INTO `cook_book` (`recipe_Id`, `source_W_C_I_D`, `target_W_C_I_D`, `last_Modified`)"); var lineGenerator = new Func <int, string>(i => { string sourceLabel = null; if (WeenieNames != null) { WeenieNames.TryGetValue(input[i].SourceWCID, out sourceLabel); } string targetLabel = null; if (WeenieNames != null) { WeenieNames.TryGetValue(input[i].TargetWCID, out targetLabel); } return($"{input[i].RecipeId}, {input[i].SourceWCID} /* {sourceLabel} */, {input[i].TargetWCID.ToString().PadLeft(5)} /* {targetLabel} */, '{input[i].LastModified:yyyy-MM-dd HH:mm:ss}')"); }); ValuesWriter(input.Count, lineGenerator, writer); }
public void CreateSQLINSERTStatement(Recipe input, StreamWriter writer) { writer.WriteLine("INSERT INTO `recipe` (`id`, `unknown_1`, `skill`, `difficulty`, `salvage_Type`, `success_W_C_I_D`, `success_Amount`, `success_Message`, `fail_W_C_I_D`, `fail_Amount`, `fail_Message`, " + "`success_Destroy_Source_Chance`, `success_Destroy_Source_Amount`, `success_Destroy_Source_Message`, `success_Destroy_Target_Chance`, `success_Destroy_Target_Amount`, `success_Destroy_Target_Message`, " + "`fail_Destroy_Source_Chance`, `fail_Destroy_Source_Amount`, `fail_Destroy_Source_Message`, `fail_Destroy_Target_Chance`, `fail_Destroy_Target_Amount`, `fail_Destroy_Target_Message`, " + "`data_Id`, `last_Modified`)"); string skillLabel = null; if (input.Skill != 0) { skillLabel = Enum.GetName(typeof(Skill), input.Skill); } string successWeenieLabel = null; if (WeenieNames != null) { WeenieNames.TryGetValue(input.SuccessWCID, out successWeenieLabel); } string failWeenieLabel = null; if (WeenieNames != null) { WeenieNames.TryGetValue(input.FailWCID, out failWeenieLabel); } var output = "VALUES (" + $"{input.Id}, " + $"{input.Unknown1}, " + $"{input.Skill} /* {skillLabel} */, " + $"{input.Difficulty}, " + $"{input.SalvageType}, " + $"{input.SuccessWCID} /* {successWeenieLabel} */, " + $"{input.SuccessAmount}, " + $"{GetSQLString(input.SuccessMessage)}, " + $"{input.FailWCID} /* {failWeenieLabel} */, " + $"{input.FailAmount}, " + $"{GetSQLString(input.FailMessage)}, " + $"{input.SuccessDestroySourceChance}, " + $"{input.SuccessDestroySourceAmount}, " + $"{GetSQLString(input.SuccessDestroySourceMessage)}, " + $"{input.SuccessDestroyTargetChance}, " + $"{input.SuccessDestroyTargetAmount}, " + $"{GetSQLString(input.SuccessDestroyTargetMessage)}, " + $"{input.FailDestroySourceChance}, " + $"{input.FailDestroySourceAmount}, " + $"{GetSQLString(input.FailDestroySourceMessage)}, " + $"{input.FailDestroyTargetChance}, " + $"{input.FailDestroyTargetAmount}, " + $"{GetSQLString(input.FailDestroyTargetMessage)}, " + $"{input.DataId}, " + $"'{input.LastModified:yyyy-MM-dd HH:mm:ss}'" + ");"; output = FixNullFields(output); writer.WriteLine(output); if (input.RecipeRequirementsInt != null && input.RecipeRequirementsInt.Count > 0) { writer.WriteLine(); CreateSQLINSERTStatement(input.Id, input.RecipeRequirementsInt.ToList(), writer); } if (input.RecipeRequirementsDID != null && input.RecipeRequirementsDID.Count > 0) { writer.WriteLine(); CreateSQLINSERTStatement(input.Id, input.RecipeRequirementsDID.ToList(), writer); } if (input.RecipeRequirementsIID != null && input.RecipeRequirementsIID.Count > 0) { writer.WriteLine(); CreateSQLINSERTStatement(input.Id, input.RecipeRequirementsIID.ToList(), writer); } if (input.RecipeRequirementsFloat != null && input.RecipeRequirementsFloat.Count > 0) { writer.WriteLine(); CreateSQLINSERTStatement(input.Id, input.RecipeRequirementsFloat.ToList(), writer); } if (input.RecipeRequirementsString != null && input.RecipeRequirementsString.Count > 0) { writer.WriteLine(); CreateSQLINSERTStatement(input.Id, input.RecipeRequirementsString.ToList(), writer); } if (input.RecipeRequirementsBool != null && input.RecipeRequirementsBool.Count > 0) { writer.WriteLine(); CreateSQLINSERTStatement(input.Id, input.RecipeRequirementsBool.ToList(), writer); } if (input.RecipeMod != null && input.RecipeMod.Count > 0) { //writer.WriteLine(); // This is not needed because CreateSQLINSERTStatement will take care of it for us on each Recipe. CreateSQLINSERTStatement(input.Id, input.RecipeMod.ToList(), writer); } }
private void CreateSQLINSERTStatement(IList <LandblockInstanceLink> input, Dictionary <uint, uint> instanceWcids, StreamWriter writer) { writer.WriteLine("INSERT INTO `landblock_instance_link` (`parent_GUID`, `child_GUID`, `last_Modified`)"); var lineGenerator = new Func <int, string>(i => { string label = null; if (WeenieNames != null && instanceWcids.TryGetValue(input[i].ChildGuid, out var wcid) && WeenieNames.TryGetValue(wcid, out var weenieName)) { label = $" /* {weenieName} ({wcid}) */"; } return($"0x{input[i].ParentGuid.ToString("X8")}, 0x{input[i].ChildGuid.ToString("X8")}, '{input[i].LastModified.ToString("yyyy-MM-dd HH:mm:ss")}'){label}"); }); ValuesWriter(input.Count, lineGenerator, writer); }
private void CreateSQLINSERTStatement(IList <WeeniePropertiesEmoteAction> input, StreamWriter writer) { writer.WriteLine("INSERT INTO `weenie_properties_emote_action` (`emote_Id`, `order`, `type`, `delay`, `extent`, `motion`, `message`, `test_String`, `min`, `max`, `min_64`, `max_64`, `min_Dbl`, `max_Dbl`, " + "`stat`, `display`, `amount`, `amount_64`, `hero_X_P_64`, `percent`, `spell_Id`, `wealth_Rating`, `treasure_Class`, `treasure_Type`, `p_Script`, `sound`, `destination_Type`, `weenie_Class_Id`, `stack_Size`, `palette`, `shade`, `try_To_Bond`, " + "`obj_Cell_Id`, `origin_X`, `origin_Y`, `origin_Z`, `angles_W`, `angles_X`, `angles_Y`, `angles_Z`)"); var lineGenerator = new Func <int, string>(i => { string typeLabel = Enum.GetName(typeof(EmoteType), input[i].Type); if (typeLabel != null) { typeLabel = $" /* {typeLabel} */"; } string motionLabel = null; if (input[i].Motion.HasValue) { motionLabel = Enum.GetName(typeof(MotionCommand), input[i].Motion.Value); if (motionLabel != null) { motionLabel = $" /* {motionLabel} */"; } } string spellIdLabel = null; if (SpellNames != null && input[i].SpellId.HasValue) { SpellNames.TryGetValue((uint)input[i].SpellId.Value, out spellIdLabel); if (spellIdLabel != null) { spellIdLabel = $" /* {spellIdLabel} */"; } } string pScriptLabel = null; if (input[i].PScript.HasValue) { pScriptLabel = Enum.GetName(typeof(PlayScript), input[i].PScript.Value); if (pScriptLabel != null) { pScriptLabel = $" /* {pScriptLabel} */"; } } string soundLabel = null; if (input[i].Sound.HasValue) { soundLabel = Enum.GetName(typeof(Sound), input[i].Sound.Value); if (soundLabel != null) { soundLabel = $" /* {soundLabel} */"; } } string weenieClassIdLabel = null; if (input[i].WeenieClassId.HasValue && WeenieNames != null) { WeenieNames.TryGetValue(input[i].WeenieClassId.Value, out weenieClassIdLabel); if (weenieClassIdLabel != null) { weenieClassIdLabel = $" /* {weenieClassIdLabel} */"; } } string destinationTypeLabel = null; if (input[i].DestinationType.HasValue) { destinationTypeLabel = Enum.GetName(typeof(DestinationType), input[i].DestinationType.Value); if (destinationTypeLabel != null) { destinationTypeLabel = $" /* {destinationTypeLabel} */"; } } string telelocLabel = null; if (input[i].ObjCellId.HasValue && input[i].ObjCellId.Value > 0) { telelocLabel = $" /* @teleloc 0x{input[i].ObjCellId.Value:X8} [{TrimNegativeZero(input[i].OriginX.Value):F6} {TrimNegativeZero(input[i].OriginY.Value):F6} {TrimNegativeZero(input[i].OriginZ.Value):F6}] {TrimNegativeZero(input[i].AnglesW.Value):F6} {TrimNegativeZero(input[i].AnglesX.Value):F6} {TrimNegativeZero(input[i].AnglesY.Value):F6} {TrimNegativeZero(input[i].AnglesZ.Value):F6} */"; } string statLabel = null; if (input[i].Stat.HasValue) { switch ((EmoteType)input[i].Type) { case EmoteType.AwardLevelProportionalSkillXP: case EmoteType.AwardSkillPoints: case EmoteType.AwardSkillXP: case EmoteType.InqSkillStat: case EmoteType.InqRawSkillStat: case EmoteType.InqSkillTrained: case EmoteType.InqSkillSpecialized: case EmoteType.UntrainSkill: statLabel = $" /* Skill.{(Skill)input[i].Stat.Value} */"; break; case EmoteType.DecrementIntStat: case EmoteType.IncrementIntStat: case EmoteType.InqIntStat: case EmoteType.SetIntStat: statLabel = $" /* PropertyInt.{(PropertyInt)input[i].Stat.Value} */"; break; case EmoteType.InqAttributeStat: case EmoteType.InqRawAttributeStat: statLabel = $" /* PropertyAttribute.{(PropertyAttribute)input[i].Stat.Value} */"; break; case EmoteType.InqBoolStat: case EmoteType.SetBoolStat: statLabel = $" /* PropertyBool.{(PropertyBool)input[i].Stat.Value} */"; break; case EmoteType.InqFloatStat: case EmoteType.SetFloatStat: statLabel = $" /* PropertyFloat.{(PropertyFloat)input[i].Stat.Value} */"; break; case EmoteType.InqInt64Stat: case EmoteType.SetInt64Stat: statLabel = $" /* PropertyInt64.{(PropertyInt64)input[i].Stat.Value} */"; break; case EmoteType.InqSecondaryAttributeStat: case EmoteType.InqRawSecondaryAttributeStat: statLabel = $" /* PropertyAttribute2nd.{(PropertyAttribute2nd)input[i].Stat.Value} */"; break; case EmoteType.InqStringStat: statLabel = $" /* PropertyString.{(PropertyString)input[i].Stat.Value} */"; break; default: break; } } string amountLabel = null; if (input[i].Amount.HasValue) { switch ((EmoteType)input[i].Type) { case EmoteType.AddCharacterTitle: amountLabel = $" /* {(CharacterTitle)input[i].Amount.Value} */"; break; case EmoteType.AddContract: case EmoteType.RemoveContract: amountLabel = $" /* {(ContractId)input[i].Amount.Value} */"; break; default: break; } } string treasureClassLabel = null; if (input[i].TreasureClass.HasValue) { treasureClassLabel = Enum.GetName(typeof(TreasureClass), input[i].TreasureClass.Value); if (treasureClassLabel != null) { treasureClassLabel = $" /* {treasureClassLabel} */"; } } string treasureTypeLabel = null; if (input[i].TreasureType.HasValue) { treasureTypeLabel = Enum.GetName(typeof(TreasureType), input[i].TreasureType.Value); if (treasureTypeLabel != null) { treasureTypeLabel = $" /* {treasureTypeLabel} */"; } } string paletteLabel = null; if (input[i].Palette.HasValue) { paletteLabel = Enum.GetName(typeof(PaletteTemplate), input[i].Palette.Value); if (paletteLabel != null) { paletteLabel = $" /* {paletteLabel} */"; } } return ("@parent_id, " + $"{input[i].Order.ToString().PadLeft(2)}, " + $"{input[i].Type.ToString().PadLeft(3)}{typeLabel}, " + $"{input[i].Delay:0.######}, " + $"{input[i].Extent:0.######}, " + $"{(input[i].Motion.HasValue ? "0x" : "")}{input[i].Motion:X8}{motionLabel}, " + $"{GetSQLString(input[i].Message)}, " + $"{GetSQLString(input[i].TestString)}, " + $"{input[i].Min}, " + $"{input[i].Max}, " + $"{input[i].Min64}, " + $"{input[i].Max64}, " + $"{input[i].MinDbl}, " + $"{input[i].MaxDbl}, " + $"{input[i].Stat}{statLabel}, " + $"{input[i].Display}, " + $"{input[i].Amount}{amountLabel}, " + $"{input[i].Amount64}, " + $"{input[i].HeroXP64}, " + $"{input[i].Percent}, " + $"{input[i].SpellId}{spellIdLabel}, " + $"{input[i].WealthRating}, " + $"{input[i].TreasureClass}{treasureClassLabel}, " + $"{input[i].TreasureType}{treasureTypeLabel}, " + $"{input[i].PScript}{pScriptLabel}, " + $"{input[i].Sound}{soundLabel}, " + $"{input[i].DestinationType}{destinationTypeLabel}, " + $"{input[i].WeenieClassId}{weenieClassIdLabel}, " + $"{input[i].StackSize}, " + $"{input[i].Palette}{paletteLabel}, " + $"{input[i].Shade:0.######}, " + $"{input[i].TryToBond}, " + $"{(input[i].ObjCellId.HasValue ? "0x" : "")}{input[i].ObjCellId:X8}{telelocLabel}, " + $"{TrimNegativeZero(input[i].OriginX):0.######}, " + $"{TrimNegativeZero(input[i].OriginY):0.######}, " + $"{TrimNegativeZero(input[i].OriginZ):0.######}, " + $"{TrimNegativeZero(input[i].AnglesW):0.######}, " + $"{TrimNegativeZero(input[i].AnglesX):0.######}, " + $"{TrimNegativeZero(input[i].AnglesY):0.######}, " + $"{TrimNegativeZero(input[i].AnglesZ):0.######})"); }); ValuesWriter(input.Count, lineGenerator, writer); }
public void CreateSQLINSERTStatement(uint weenieClassID, IList <WeeniePropertiesEmote> input, StreamWriter writer) { foreach (var value in input) { writer.WriteLine(); writer.WriteLine("INSERT INTO `weenie_properties_emote` (`object_Id`, `category`, `probability`, `weenie_Class_Id`, `style`, `substyle`, `quest`, `vendor_Type`, `min_Health`, `max_Health`)"); var categoryLabel = Enum.GetName(typeof(EmoteCategory), value.Category); if (categoryLabel != null) { categoryLabel = $" /* {categoryLabel} */"; } string weenieClassIdLabel = null; if (WeenieNames != null && value.WeenieClassId.HasValue) { WeenieNames.TryGetValue(value.WeenieClassId.Value, out weenieClassIdLabel); if (weenieClassIdLabel != null) { weenieClassIdLabel = $" /* {weenieClassIdLabel} */"; } } string styleLabel = null; if (value.Style.HasValue) { styleLabel = Enum.GetName(typeof(MotionStance), value.Style.Value); if (styleLabel != null) { styleLabel = $" /* {styleLabel} */"; } } string substyleLabel = null; if (value.Substyle.HasValue) { substyleLabel = Enum.GetName(typeof(MotionCommand), value.Substyle.Value); if (substyleLabel != null) { substyleLabel = $" /* {substyleLabel} */"; } } string vendorTypeLabel = null; if (value.VendorType.HasValue) { vendorTypeLabel = Enum.GetName(typeof(VendorType), value.VendorType.Value); if (vendorTypeLabel != null) { vendorTypeLabel = $" /* {vendorTypeLabel} */"; } } var output = "VALUES (" + $"{weenieClassID}, " + $"{value.Category.ToString().PadLeft(2)}{categoryLabel}, " + $"{value.Probability.ToString("0.######", CultureInfo.InvariantCulture).PadLeft(6)}, " + $"{value.WeenieClassId}{weenieClassIdLabel}, " + $"{(value.Style.HasValue ? "0x" : "")}{value.Style:X8}{styleLabel}, " + $"{(value.Substyle.HasValue ? "0x" : "")}{value.Substyle:X8}{substyleLabel}, " + $"{GetSQLString(value.Quest)}, " + $"{value.VendorType}{vendorTypeLabel}, " + $"{value.MinHealth:0.######}, " + $"{value.MaxHealth:0.######}" + ");"; output = FixNullFields(output); writer.WriteLine(output); if (value.WeeniePropertiesEmoteAction != null && value.WeeniePropertiesEmoteAction.Count > 0) { writer.WriteLine(); writer.WriteLine("SET @parent_id = LAST_INSERT_ID();"); writer.WriteLine(); CreateSQLINSERTStatement(value.WeeniePropertiesEmoteAction.OrderBy(r => r.Order).ToList(), writer); } } }
private void CreateSQLINSERTStatement(IList <WeeniePropertiesEmoteAction> input, StreamWriter writer) { writer.WriteLine("INSERT INTO `weenie_properties_emote_action` (`emote_Id`, `order`, `type`, `delay`, `extent`, `motion`, `message`, `test_String`, `min`, `max`, `min_64`, `max_64`, `min_Dbl`, `max_Dbl`, " + "`stat`, `display`, `amount`, `amount_64`, `hero_X_P_64`, `percent`, `spell_Id`, `wealth_Rating`, `treasure_Class`, `treasure_Type`, `p_Script`, `sound`, `destination_Type`, `weenie_Class_Id`, `stack_Size`, `palette`, `shade`, `try_To_Bond`, " + "`obj_Cell_Id`, `origin_X`, `origin_Y`, `origin_Z`, `angles_W`, `angles_X`, `angles_Y`, `angles_Z`)"); var lineGenerator = new Func <int, string>(i => { string typeLabel = Enum.GetName(typeof(EmoteType), input[i].Type); if (typeLabel != null) { typeLabel = $" /* {typeLabel} */"; } string motionLabel = null; if (input[i].Motion.HasValue) { motionLabel = Enum.GetName(typeof(MotionCommand), input[i].Motion.Value); if (motionLabel != null) { motionLabel = $" /* {motionLabel} */"; } } string spellIdLabel = null; if (SpellNames != null && input[i].SpellId.HasValue) { SpellNames.TryGetValue((uint)input[i].SpellId.Value, out spellIdLabel); if (spellIdLabel != null) { spellIdLabel = $" /* {spellIdLabel} */"; } } string pScriptLabel = null; if (input[i].PScript.HasValue) { pScriptLabel = Enum.GetName(typeof(PlayScript), input[i].PScript.Value); if (pScriptLabel != null) { pScriptLabel = $" /* {pScriptLabel} */"; } } string soundLabel = null; if (input[i].Sound.HasValue) { soundLabel = Enum.GetName(typeof(Sound), input[i].Sound.Value); if (soundLabel != null) { soundLabel = $" /* {soundLabel} */"; } } string weenieClassIdLabel = null; if (input[i].WeenieClassId.HasValue && WeenieNames != null) { WeenieNames.TryGetValue(input[i].WeenieClassId.Value, out weenieClassIdLabel); if (weenieClassIdLabel != null) { weenieClassIdLabel = $" /* {weenieClassIdLabel} */"; } } string destinationTypeLabel = null; if (input[i].DestinationType.HasValue) { destinationTypeLabel = Enum.GetName(typeof(DestinationType), input[i].DestinationType.Value); if (destinationTypeLabel != null) { destinationTypeLabel = $" /* {destinationTypeLabel} */"; } } string telelocLabel = null; if (input[i].ObjCellId.HasValue && input[i].ObjCellId.Value > 0) { telelocLabel = $" /* @teleloc 0x{input[i].ObjCellId.Value:X8} [{input[i].OriginX.Value:F6} {input[i].OriginY.Value:F6} {input[i].OriginZ.Value:F6}] {input[i].AnglesW.Value:F6} {input[i].AnglesX.Value:F6} {input[i].AnglesY.Value:F6} {input[i].AnglesZ.Value:F6} */"; } return ("@parent_id, " + $"{input[i].Order.ToString().PadLeft(2)}, " + $"{input[i].Type.ToString().PadLeft(3)}{typeLabel}, " + $"{input[i].Delay}, " + $"{input[i].Extent}, " + $"{input[i].Motion}{motionLabel}, " + $"{GetSQLString(input[i].Message)}, " + $"{GetSQLString(input[i].TestString)}, " + $"{input[i].Min}, " + $"{input[i].Max}, " + $"{input[i].Min64}, " + $"{input[i].Max64}, " + $"{input[i].MinDbl}, " + $"{input[i].MaxDbl}, " + $"{input[i].Stat}, " + $"{input[i].Display}, " + $"{input[i].Amount}, " + $"{input[i].Amount64}, " + $"{input[i].HeroXP64}, " + $"{input[i].Percent}, " + $"{input[i].SpellId}{spellIdLabel}, " + $"{input[i].WealthRating}, " + $"{input[i].TreasureClass}, " + $"{input[i].TreasureType}, " + $"{input[i].PScript}{pScriptLabel}, " + $"{input[i].Sound}{soundLabel}, " + $"{input[i].DestinationType}{destinationTypeLabel}, " + $"{input[i].WeenieClassId}{weenieClassIdLabel}, " + $"{input[i].StackSize}, " + $"{input[i].Palette}, " + $"{input[i].Shade}, " + $"{input[i].TryToBond}, " + $"{input[i].ObjCellId}{telelocLabel}, " + $"{input[i].OriginX}, " + $"{input[i].OriginY}, " + $"{input[i].OriginZ}, " + $"{input[i].AnglesW}, " + $"{input[i].AnglesX}, " + $"{input[i].AnglesY}, " + $"{input[i].AnglesZ})"); }); ValuesWriter(input.Count, lineGenerator, writer); }
public void CreateSQLINSERTStatement(Spell input, StreamWriter writer) { var spellLineHdr = "INSERT INTO `spell` (`id`, `name`"; var spellLine = $"VALUES ({input.Id}, {GetSQLString(input.Name)}"; if (input.StatModType.HasValue) { spellLineHdr += ", `stat_Mod_Type`"; spellLine += $", {input.StatModType} /* {((EnchantmentTypeFlags)input.StatModType).ToString()} */"; } if (input.StatModKey.HasValue) { spellLineHdr += ", `stat_Mod_Key`"; spellLine += $", {input.StatModKey}"; if (input.StatModType.HasValue) { var smt = (EnchantmentTypeFlags)input.StatModType; if (smt.HasFlag(EnchantmentTypeFlags.Skill)) { if (Enum.IsDefined(typeof(Skill), (int)input.StatModKey)) { spellLine += $" /* {Enum.GetName(typeof(Skill), input.StatModKey)} */"; } } else if (smt.HasFlag(EnchantmentTypeFlags.Attribute)) { if (Enum.IsDefined(typeof(PropertyAttribute), (ushort)input.StatModKey)) { spellLine += $" /* {Enum.GetName(typeof(PropertyAttribute), input.StatModKey)} */"; } } else if (smt.HasFlag(EnchantmentTypeFlags.SecondAtt)) { if (Enum.IsDefined(typeof(PropertyAttribute2nd), (ushort)input.StatModKey)) { spellLine += $" /* {Enum.GetName(typeof(PropertyAttribute2nd), input.StatModKey)} */"; } } else if (smt.HasFlag(EnchantmentTypeFlags.Int)) { if (Enum.IsDefined(typeof(PropertyInt), (ushort)input.StatModKey)) { spellLine += $" /* {Enum.GetName(typeof(PropertyInt), input.StatModKey)} */"; } } else if (smt.HasFlag(EnchantmentTypeFlags.Float)) { if (Enum.IsDefined(typeof(PropertyFloat), (ushort)input.StatModKey)) { spellLine += $" /* {Enum.GetName(typeof(PropertyFloat), input.StatModKey)} */"; } } } } if (input.StatModVal.HasValue) { spellLineHdr += ", `stat_Mod_Val`"; spellLine += $", {input.StatModVal:0.######}"; } if (input.EType.HasValue) { spellLineHdr += ", `e_Type`"; spellLine += $", {input.EType} /* {Enum.GetName(typeof(DamageType), input.EType)} */"; } if (input.BaseIntensity.HasValue) { spellLineHdr += ", `base_Intensity`"; spellLine += $", {input.BaseIntensity}"; } if (input.Variance.HasValue) { spellLineHdr += ", `variance`"; spellLine += $", {input.Variance}"; } if (input.Wcid.HasValue) { spellLineHdr += ", `wcid`"; if (WeenieNames != null && input.Wcid.Value > 0 && WeenieNames.ContainsKey(input.Wcid.Value)) { spellLine += $", {input.Wcid} /* {WeenieNames[input.Wcid.Value]} */"; } else { spellLine += $", {input.Wcid}"; } } if (input.NumProjectiles.HasValue) { spellLineHdr += ", `num_Projectiles`"; spellLine += $", {input.NumProjectiles}"; } if (input.NumProjectilesVariance.HasValue) { spellLineHdr += ", `num_Projectiles_Variance`"; spellLine += $", {input.NumProjectilesVariance:0.######}"; } if (input.SpreadAngle.HasValue) { spellLineHdr += ", `spread_Angle`"; spellLine += $", {input.SpreadAngle:0.######}"; } if (input.VerticalAngle.HasValue) { spellLineHdr += ", `vertical_Angle`"; spellLine += $", {input.VerticalAngle:0.######}"; } if (input.DefaultLaunchAngle.HasValue) { spellLineHdr += ", `default_Launch_Angle`"; spellLine += $", {input.DefaultLaunchAngle:0.######}"; } if (input.NonTracking.HasValue) { spellLineHdr += ", `non_Tracking`"; spellLine += $", {input.NonTracking}"; } if (input.CreateOffsetOriginX.HasValue) { spellLineHdr += ", `create_Offset_Origin_X`"; spellLine += $", {input.CreateOffsetOriginX:0.######}"; } if (input.CreateOffsetOriginY.HasValue) { spellLineHdr += ", `create_Offset_Origin_Y`"; spellLine += $", {input.CreateOffsetOriginY:0.######}"; } if (input.CreateOffsetOriginZ.HasValue) { spellLineHdr += ", `create_Offset_Origin_Z`"; spellLine += $", {input.CreateOffsetOriginZ:0.######}"; } if (input.PaddingOriginX.HasValue) { spellLineHdr += ", `padding_Origin_X`"; spellLine += $", {input.PaddingOriginX:0.######}"; } if (input.PaddingOriginY.HasValue) { spellLineHdr += ", `padding_Origin_Y`"; spellLine += $", {input.PaddingOriginY:0.######}"; } if (input.PaddingOriginZ.HasValue) { spellLineHdr += ", `padding_Origin_Z`"; spellLine += $", {input.PaddingOriginZ:0.######}"; } if (input.DimsOriginX.HasValue) { spellLineHdr += ", `dims_Origin_X`"; spellLine += $", {input.DimsOriginX:0.######}"; } if (input.DimsOriginY.HasValue) { spellLineHdr += ", `dims_Origin_Y`"; spellLine += $", {input.DimsOriginY:0.######}"; } if (input.DimsOriginZ.HasValue) { spellLineHdr += ", `dims_Origin_Z`"; spellLine += $", {input.DimsOriginZ:0.######}"; } if (input.PeturbationOriginX.HasValue) { spellLineHdr += ", `peturbation_Origin_X`"; spellLine += $", {input.PeturbationOriginX:0.######}"; } if (input.PeturbationOriginY.HasValue) { spellLineHdr += ", `peturbation_Origin_Y`"; spellLine += $", {input.PeturbationOriginY:0.######}"; } if (input.PeturbationOriginZ.HasValue) { spellLineHdr += ", `peturbation_Origin_Z`"; spellLine += $", {input.PeturbationOriginZ:0.######}"; } if (input.ImbuedEffect.HasValue) { spellLineHdr += ", `imbued_Effect`"; spellLine += $", {input.ImbuedEffect} /* {Enum.GetName(typeof(ImbuedEffectType), input.ImbuedEffect)} */"; } if (input.SlayerCreatureType.HasValue) { spellLineHdr += ", `slayer_Creature_Type`"; spellLine += $", {input.SlayerCreatureType} /* {Enum.GetName(typeof(CreatureType), input.SlayerCreatureType)} */"; } if (input.SlayerDamageBonus.HasValue) { spellLineHdr += ", `slayer_Damage_Bonus`"; spellLine += $", {input.SlayerDamageBonus}"; } if (input.CritFreq.HasValue) { spellLineHdr += ", `crit_Freq`"; spellLine += $", {input.CritFreq}"; } if (input.CritMultiplier.HasValue) { spellLineHdr += ", `crit_Multiplier`"; spellLine += $", {input.CritMultiplier}"; } if (input.IgnoreMagicResist.HasValue) { spellLineHdr += ", `ignore_Magic_Resist`"; spellLine += $", {input.IgnoreMagicResist}"; } if (input.ElementalModifier.HasValue) { spellLineHdr += ", `elemental_Modifier`"; spellLine += $", {input.ElementalModifier}"; } if (input.DrainPercentage.HasValue) { spellLineHdr += ", `drain_Percentage`"; spellLine += $", {input.DrainPercentage:0.######}"; } if (input.DamageRatio.HasValue) { spellLineHdr += ", `damage_Ratio`"; spellLine += $", {input.DamageRatio}"; } if (input.DamageType.HasValue) { spellLineHdr += ", `damage_Type`"; spellLine += $", {(int)input.DamageType} /* {Enum.GetName(typeof(DamageType), input.DamageType)} */"; } if (input.Boost.HasValue) { spellLineHdr += ", `boost`"; spellLine += $", {input.Boost}"; } if (input.BoostVariance.HasValue) { spellLineHdr += ", `boost_Variance`"; spellLine += $", {input.BoostVariance}"; } if (input.Source.HasValue) { spellLineHdr += ", `source`"; spellLine += $", {(int)input.Source} /* {Enum.GetName(typeof(PropertyAttribute2nd), input.Source)} */"; } if (input.Destination.HasValue) { spellLineHdr += ", `destination`"; spellLine += $", {(int)input.Destination} /* {Enum.GetName(typeof(PropertyAttribute2nd), input.Destination)} */"; } if (input.Proportion.HasValue) { spellLineHdr += ", `proportion`"; spellLine += $", {input.Proportion}"; } if (input.LossPercent.HasValue) { spellLineHdr += ", `loss_Percent`"; spellLine += $", {input.LossPercent:0.######}"; } if (input.SourceLoss.HasValue) { spellLineHdr += ", `source_Loss`"; spellLine += $", {input.SourceLoss}"; } if (input.TransferCap.HasValue) { spellLineHdr += ", `transfer_Cap`"; spellLine += $", {input.TransferCap}"; } if (input.MaxBoostAllowed.HasValue) { spellLineHdr += ", `max_Boost_Allowed`"; spellLine += $", {input.MaxBoostAllowed}"; } if (input.TransferBitfield.HasValue) { spellLineHdr += ", `transfer_Bitfield`"; spellLine += $", {input.TransferBitfield} /* {((TransferFlags)input.TransferBitfield).ToString()} */"; } if (input.Index.HasValue) { spellLineHdr += ", `index`"; spellLine += $", {input.Index} /* {(input.Name.Contains("Tie") ? ("PortalLinkType." + (PortalLinkType)input.Index).ToString() : ("PortalRecallType." + (PortalRecallType)input.Index).ToString())} */"; } if (input.Link.HasValue) { spellLineHdr += ", `link`"; spellLine += $", {input.Link} /* PortalSummonType.{((PortalSummonType)input.Link).ToString()} */"; } if (input.PositionObjCellId.HasValue) { spellLineHdr += ", `position_Obj_Cell_ID`"; spellLine += $", 0x{input.PositionObjCellId:X8}"; } if (input.PositionOriginX.HasValue) { spellLineHdr += ", `position_Origin_X`"; spellLine += $", {TrimNegativeZero(input.PositionOriginX):0.######}"; } if (input.PositionOriginY.HasValue) { spellLineHdr += ", `position_Origin_Y`"; spellLine += $", {TrimNegativeZero(input.PositionOriginY):0.######}"; } if (input.PositionOriginZ.HasValue) { spellLineHdr += ", `position_Origin_Z`"; spellLine += $", {TrimNegativeZero(input.PositionOriginZ):0.######}"; } if (input.PositionAnglesW.HasValue) { spellLineHdr += ", `position_Angles_W`"; spellLine += $", {TrimNegativeZero(input.PositionAnglesW):0.######}"; } if (input.PositionAnglesX.HasValue) { spellLineHdr += ", `position_Angles_X`"; spellLine += $", {TrimNegativeZero(input.PositionAnglesX):0.######}"; } if (input.PositionAnglesY.HasValue) { spellLineHdr += ", `position_Angles_Y`"; spellLine += $", {TrimNegativeZero(input.PositionAnglesY):0.######}"; } if (input.PositionAnglesZ.HasValue) { spellLineHdr += ", `position_Angles_Z`"; spellLine += $", {TrimNegativeZero(input.PositionAnglesZ):0.######}"; } if (input.MinPower.HasValue) { spellLineHdr += ", `min_Power`"; spellLine += $", {input.MinPower}"; } if (input.MaxPower.HasValue) { spellLineHdr += ", `max_Power`"; spellLine += $", {input.MaxPower}"; } if (input.PowerVariance.HasValue) { spellLineHdr += ", `power_Variance`"; spellLine += $", {input.PowerVariance:0.######}"; } if (input.DispelSchool.HasValue) { spellLineHdr += ", `dispel_School`"; spellLine += $", {(int)input.DispelSchool} /* {Enum.GetName(typeof(MagicSchool), input.DispelSchool)} */"; } if (input.Align.HasValue) { spellLineHdr += ", `align`"; spellLine += $", {input.Align}"; } if (input.Number.HasValue) { spellLineHdr += ", `number`"; spellLine += $", {input.Number}"; } if (input.NumberVariance.HasValue) { spellLineHdr += ", `number_Variance`"; spellLine += $", {input.NumberVariance:0.######}"; } if (input.DotDuration.HasValue) { spellLineHdr += ", `dot_Duration`"; spellLine += $", {input.DotDuration}"; } spellLineHdr += ", `last_Modified`"; spellLine += $", '{input.LastModified:yyyy-MM-dd HH:mm:ss}'"; spellLineHdr += ")"; spellLine += ");"; spellLine = FixNullFields(spellLine); if (input.PositionObjCellId.HasValue && input.PositionOriginX.HasValue && input.PositionOriginY.HasValue && input.PositionOriginZ.HasValue && input.PositionAnglesX.HasValue && input.PositionAnglesY.HasValue && input.PositionAnglesZ.HasValue && input.PositionAnglesW.HasValue) { spellLine += Environment.NewLine + $"/* @teleloc 0x{input.PositionObjCellId.Value:X8} [{TrimNegativeZero(input.PositionOriginX.Value):F6} {TrimNegativeZero(input.PositionOriginY.Value):F6} {TrimNegativeZero(input.PositionOriginZ.Value):F6}] {TrimNegativeZero(input.PositionAnglesW.Value):F6} {TrimNegativeZero(input.PositionAnglesX.Value):F6} {TrimNegativeZero(input.PositionAnglesY.Value):F6} {TrimNegativeZero(input.PositionAnglesZ.Value):F6} */"; } writer.WriteLine(spellLineHdr); writer.WriteLine(spellLine); }