public static void TrySetGender(ReadableTuple <int> tuple, StringBuilder builder, DbAttribute attribute, string defaultValue) { int key = tuple.GetKey <int>(); string val = tuple.GetValue <string>(attribute); if (key >= 1950 && key < 2000) { if (val == "0") { return; } } if (key == 2635) { if (val == "0") { return; } } if (val != "" && val != defaultValue && val != "-1") { builder.Append("\t"); builder.Append(attribute.AttributeName); builder.Append(": "); builder.AppendLine(val); } }
public override void ButtonClicked() { ReadableTuple <TKey> tuple = _tab.List.SelectedItem as ReadableTuple <TKey>; if (tuple == null) { return; } var dbMobs = _tab.GetMetaTable <int>(ServerDbs.Mobs); try { string name = ""; var tupleMob = dbMobs.TryGetTuple(tuple.GetKey <int>()); if (tupleMob != null) { name = tupleMob.GetValue <string>(ServerMobAttributes.KRoName); } _textBox.Text = name; } catch (Exception err) { ErrorHandler.HandleException(err); } }
private void _reload() { ID = _tuple.GetKey <int>(); Name = (string)_tuple.GetRawValue(ServerMobAttributes.KRoName.Index); DropOriginal = Int32.Parse(((string)_tuple.GetRawValue(_index + 1))); Drop = String.Format("{0:0.00} %", DropOriginal / 100f); MVP = _index < ServerMobAttributes.Drop1ID.Index ? "MVP" : ""; }
public static string GetSpriteFromViewId(int viewIdToFind, ViewIdTypes type, AbstractDb <int> db, ReadableTuple <int> tuple) { string error; Dictionary <int, string> idsToSprite; if (GetIdToSpriteTable(db, type, out idsToSprite, out error)) { if (error == PreviewHelper.ViewIdIncrease && tuple != null) { var itemKey = tuple.GetKey <int>(); if (itemKey >= 2101) { viewIdToFind = itemKey; } } if (viewIdToFind == 0 && tuple != null) { var itemKey = tuple.Key; if (itemKey == 2230 || itemKey == 2231 || itemKey == 5394) { return(PreviewHelper.SpriteNone); } } if (idsToSprite.ContainsKey(viewIdToFind)) { return(idsToSprite[viewIdToFind]); } } else { throw new Exception(error); } return(null); }
private void _miPaste_Click(object sender, RoutedEventArgs e) { try { if (_tab.List.SelectedItem == null) { return; } if (!Clipboard.ContainsText()) { return; } ReadableTuple <int> tuple = (ReadableTuple <int>)_tab.List.SelectedItem; string text = Clipboard.GetText(); StringBuilder builder = new StringBuilder(); string sid = tuple.GetKey <int>().ToString(CultureInfo.InvariantCulture); string name = tuple.GetStringValue(ServerMobAttributes.KRoName.Index); foreach (string line in text.Replace("\r", "").Split(new char[] { '\n' }, StringSplitOptions.RemoveEmptyEntries)) { string[] args = line.Split(','); if (args.Length < 5) { throw new Exception("Not enough arguments to parse the lines (invalid clipboard data)."); } builder.AppendLine(String.Join(",", new string[] { sid, name + "@" + args[1].Split('@')[1] }.Concat(args.Skip(2)).ToArray())); } string tempPath = TemporaryFilesManager.GetTemporaryFilePath("db_tmp_{0:0000}.txt"); File.WriteAllText(tempPath, builder.ToString()); AbstractDb <string> db; var isEnabled = _tab.GetDb <string>(ServerDbs.MobSkills2).IsEnabled; if (_tab.Settings.DbData == ServerDbs.Mobs || !isEnabled) { db = _tab.GetDb <string>(ServerDbs.MobSkills); } else { db = _tab.GetDb <string>(ServerDbs.MobSkills2); } var table = db.Table; try { table.Commands.Begin(); db.LoadFromClipboard(tempPath); } catch { table.Commands.CancelEdit(); } finally { table.Commands.EndEdit(); _tab.Update(); } } catch (Exception err) { ErrorHandler.HandleException(err); } }
public GroupCommand <TKey, ReadableTuple <TKey> > Generate <TKey>(ReadableTuple <TKey> item, ReadableTuple <int> tupleSource, AbstractDb <int> mobDb1, AbstractDb <int> mobDb2, AbstractDb <int> pet1, AbstractDb <int> pet2) { var description = item.GetValue <ParameterHolder>(ClientItemAttributes.Parameters).Values[ParameterHolderKeys.Description] ?? ""; description = ParameterHolder.ClearDescription(description); ParameterHolder holder = new ParameterHolder(); GroupCommand <TKey, ReadableTuple <TKey> > commands = GroupCommand <TKey, ReadableTuple <TKey> > .Make(); int numSlotC = _getInt(ClientItemAttributes.NumberOfSlots, item); int numSlotS = _getInt(ServerItemAttributes.NumberOfSlots, tupleSource); if (ProjectConfiguration.AutocompleteViewId) { int viewIdC = _getInt(ClientItemAttributes.ClassNumber, item); int viewIdS = _getInt(ServerItemAttributes.ClassNumber, tupleSource); if (viewIdC != viewIdS) { commands.Add(new ChangeTupleProperty <TKey, ReadableTuple <TKey> >(item, ClientItemAttributes.ClassNumber, viewIdS)); } } if (ProjectConfiguration.AutocompleteNumberOfSlot) { if (numSlotC != numSlotS) { commands.Add(new ChangeTupleProperty <TKey, ReadableTuple <TKey> >(item, ClientItemAttributes.NumberOfSlots, numSlotS)); } } if ((TypeType)tupleSource.GetValue <int>(ServerItemAttributes.Type) != TypeType.Card) { if (item.GetValue <bool>(ClientItemAttributes.IsCard)) { commands.Add(new ChangeTupleProperty <TKey, ReadableTuple <TKey> >(item, ClientItemAttributes.IsCard, false)); } } string idDisplayName = tupleSource.GetValue <string>(ServerItemAttributes.Name); if (_emptyFill(ClientItemAttributes.IdentifiedDisplayName, item) && ProjectConfiguration.AutocompleteIdDisplayName && _isNotNullDifferent(idDisplayName, ClientItemAttributes.IdentifiedDisplayName, item)) { commands.Add(new ChangeTupleProperty <TKey, ReadableTuple <TKey> >(item, ClientItemAttributes.IdentifiedDisplayName, idDisplayName)); } DbAttribute attribute; TypeType itemType = (TypeType)tupleSource.GetValue <int>(ServerItemAttributes.Type); if (itemType == TypeType.Weapon || itemType == TypeType.Armor) { if (itemType == TypeType.Armor && !ItemParser.IsArmorType(tupleSource)) { if (itemType == TypeType.Armor) { itemType = TypeType.Weapon; } else { itemType = TypeType.Armor; } } } // Weight: //holder = item.GetValue<ParameterHolder>(ClientItemAttributes.Parameters); // //switch (itemType) { // case TypeType.Weapon: // case TypeType.Ammo: // case TypeType.Armor: // case TypeType.Card: // case TypeType.PetEgg: // case TypeType.PetEquip: // case TypeType.UsableItem: // case TypeType.EtcItem: // case TypeType.HealingItem: // case TypeType.ShadowEquip: // case TypeType.UsableWithDelayed: // case TypeType.UsableWithDelayed2: // _autoAddWeight(tupleSource, holder); // break; //} DbAttribute equipLevelAttribute = ServerItemAttributes.EquipLevel; if (tupleSource.GetIntNoThrow(ServerItemAttributes.EquipLevelMin) > tupleSource.GetIntNoThrow(ServerItemAttributes.EquipLevel)) { equipLevelAttribute = ServerItemAttributes.EquipLevelMin; } switch (itemType) { case TypeType.Weapon: string type = _findWeaponType(tupleSource) ?? "Weapon"; holder.Values[ParameterHolderKeys.Class] = type; string unidentifiedResourceName = EncodingService.FromAnyToDisplayEncoding(_findWeaponUnidentifiedResource(tupleSource) ?? ""); attribute = ClientItemAttributes.UnidentifiedResourceName; if (_emptyFill(attribute, item) && ProjectConfiguration.AutocompleteUnResourceName && _isNotNullDifferent(unidentifiedResourceName, attribute, item)) { commands.Add(new ChangeTupleProperty <TKey, ReadableTuple <TKey> >(item, attribute, unidentifiedResourceName)); } string identifiedResourceName = item.GetStringValue(ClientItemAttributes.IdentifiedResourceName.Index); attribute = ClientItemAttributes.IdentifiedResourceName; if (String.IsNullOrEmpty(identifiedResourceName) && ProjectConfiguration.AutocompleteIdResourceName && _isNotNullDifferent(unidentifiedResourceName, attribute, item)) { commands.Add(new ChangeTupleProperty <TKey, ReadableTuple <TKey> >(item, attribute, unidentifiedResourceName)); } attribute = ClientItemAttributes.UnidentifiedDisplayName; if (_emptyFill(attribute, item) && ProjectConfiguration.AutocompleteUnDisplayName && _isNotNullDifferent(type, attribute, item)) { commands.Add(new ChangeTupleProperty <TKey, ReadableTuple <TKey> >(item, attribute, type)); } if (!tupleSource.GetValue <bool>(ServerItemAttributes.Refineable)) { if (!description.Contains("Impossible to refine") && !description.Contains("Cannot be upgraded") && !description.ToLower().Contains("rental item")) { description += "\r\nImpossible to refine this item."; } } if (tupleSource.GetValue <bool>(ServerItemAttributes.Refineable)) { if (description.Contains("Impossible to refine")) { description = description.Replace("Impossible to refine this item.", "").Trim('\r', '\n'); } } _autoAdd(ServerItemAttributes.Attack, ParameterHolderKeys.Attack, tupleSource, holder); _autoAddWeight(tupleSource, holder); _autoAdd(ServerItemAttributes.WeaponLevel, ParameterHolderKeys.WeaponLevel, tupleSource, holder); _autoAddJob(tupleSource, holder, _getInt(equipLevelAttribute, tupleSource)); _autoAddElement(tupleSource, holder); break; case TypeType.Ammo: type = _findAmmoType(tupleSource.GetStringValue(ServerItemAttributes.ApplicableJob.Index)) ?? "Ammunition"; holder.Values[ParameterHolderKeys.Class] = type; _autoAdd(ServerItemAttributes.Attack, ParameterHolderKeys.Attack, tupleSource, holder, -1); _autoAddWeight(tupleSource, holder); _autoAddElement(tupleSource, holder); break; case TypeType.Armor: int location = _getInt(ServerItemAttributes.Location, tupleSource); type = _findArmorType(location) ?? "Armor"; holder.Values[ParameterHolderKeys.Class] = type; unidentifiedResourceName = EncodingService.FromAnyToDisplayEncoding(_findArmorUnidentifiedResource(tupleSource, item) ?? ""); attribute = ClientItemAttributes.UnidentifiedResourceName; if (_emptyFill(attribute, item) && ProjectConfiguration.AutocompleteUnResourceName && _isNotNullDifferent(unidentifiedResourceName, attribute, item)) { commands.Add(new ChangeTupleProperty <TKey, ReadableTuple <TKey> >(item, attribute, unidentifiedResourceName)); } else { unidentifiedResourceName = item.GetValue <string>(ClientItemAttributes.UnidentifiedResourceName); } identifiedResourceName = item.GetStringValue(ClientItemAttributes.IdentifiedResourceName.Index); attribute = ClientItemAttributes.IdentifiedResourceName; if (String.IsNullOrEmpty(identifiedResourceName) && ProjectConfiguration.AutocompleteIdResourceName && _isNotNullDifferent(unidentifiedResourceName, attribute, item)) { commands.Add(new ChangeTupleProperty <TKey, ReadableTuple <TKey> >(item, attribute, unidentifiedResourceName)); } string unDisplayName = _findArmorUnidentifiedDisplayName(unidentifiedResourceName); attribute = ClientItemAttributes.UnidentifiedDisplayName; if (_emptyFill(attribute, item) && ProjectConfiguration.AutocompleteUnDisplayName && _isNotNullDifferent(unDisplayName, attribute, item)) { commands.Add(new ChangeTupleProperty <TKey, ReadableTuple <TKey> >(item, attribute, unDisplayName)); } if ((_getInt(ServerItemAttributes.Location, tupleSource) & 374) != 0) { if (!tupleSource.GetValue <bool>(ServerItemAttributes.Refineable)) { if (!description.Contains("Impossible to refine")) { description += "\r\nImpossible to refine this item."; } } if (tupleSource.GetValue <bool>(ServerItemAttributes.Refineable)) { if (description.Contains("Impossible to refine")) { description = description.Replace("Impossible to refine this item.", "").Trim('\r', '\n'); } } } _autoAdd(ServerItemAttributes.Defense, ParameterHolderKeys.Defense, tupleSource, holder); _autoAddEquippedOn(ServerItemAttributes.Location, ParameterHolderKeys.Location, tupleSource, holder); _autoAddWeight(tupleSource, holder); _autoAddJob(tupleSource, holder, _getInt(equipLevelAttribute, tupleSource)); break; case TypeType.Card: holder.Values[ParameterHolderKeys.Class] = "Card"; _autoAddCompound(ServerItemAttributes.Location, ParameterHolderKeys.CompoundOn, tupleSource, holder); _autoAdd(equipLevelAttribute, ParameterHolderKeys.RequiredLevel, tupleSource, holder, 1); _autoAddWeight(tupleSource, holder); if (!item.GetValue <bool>(ClientItemAttributes.IsCard)) { commands.Add(new ChangeTupleProperty <TKey, ReadableTuple <TKey> >(item, ClientItemAttributes.IsCard, true)); } if (String.IsNullOrEmpty(item.GetValue <string>(ClientItemAttributes.Illustration))) { commands.Add(new ChangeTupleProperty <TKey, ReadableTuple <TKey> >(item, ClientItemAttributes.Illustration, "sorry")); } if (String.IsNullOrEmpty(item.GetValue <string>(ClientItemAttributes.Affix))) { commands.Add(new ChangeTupleProperty <TKey, ReadableTuple <TKey> >(item, ClientItemAttributes.Affix, tupleSource.GetValue <string>(ServerItemAttributes.Name))); } const string CardResource = "À̸§¾ø´ÂÄ«µå"; unDisplayName = tupleSource.GetValue <string>(ServerItemAttributes.Name); attribute = ClientItemAttributes.UnidentifiedDisplayName; if (_emptyFill(attribute, item) && ProjectConfiguration.AutocompleteUnDisplayName && _isNotNullDifferent(unDisplayName, attribute, item)) { commands.Add(new ChangeTupleProperty <TKey, ReadableTuple <TKey> >(item, attribute, unDisplayName)); } unidentifiedResourceName = EncodingService.FromAnyToDisplayEncoding(CardResource); attribute = ClientItemAttributes.UnidentifiedResourceName; if (_emptyFill(attribute, item) && ProjectConfiguration.AutocompleteUnResourceName && _isNotNullDifferent(unidentifiedResourceName, attribute, item)) { commands.Add(new ChangeTupleProperty <TKey, ReadableTuple <TKey> >(item, attribute, unidentifiedResourceName)); } attribute = ClientItemAttributes.IdentifiedResourceName; if (_emptyFill(attribute, item) && ProjectConfiguration.AutocompleteIdResourceName && _isNotNullDifferent(unidentifiedResourceName, attribute, item)) { commands.Add(new ChangeTupleProperty <TKey, ReadableTuple <TKey> >(item, attribute, unidentifiedResourceName)); } break; case TypeType.PetEgg: holder.Values[ParameterHolderKeys.Class] = "Monster Egg"; _autoAddWeight(tupleSource, holder); break; case TypeType.PetEquip: holder.Values[ParameterHolderKeys.Class] = "Cute Pet Armor"; _autoAddWeight(tupleSource, holder); int id = item.GetKey <int>(); List <ReadableTuple <int> > tuples = pet1.Table.Tuples.Where(p => p.Value.GetValue <int>(ServerPetAttributes.EquipId) == id).Select(p => p.Value).Concat( pet2.Table.Tuples.Where(p => p.Value.GetValue <int>(ServerPetAttributes.EquipId) == id).Select(p => p.Value) ).ToList(); if (tuples.Count > 0) { // Try to retrieve the names List <string> values = new List <string>(); foreach (ReadableTuple <int> tuple in tuples) { var pid = tuple.GetKey <int>(); var pTuple = mobDb2.Table.TryGetTuple(pid) ?? mobDb1.Table.TryGetTuple(pid); if (pTuple != null) { values.Add(pTuple.GetValue <string>(ServerMobAttributes.KRoName)); } } if (values.Count > 0) { holder.Values[ParameterHolderKeys.ApplicablePet] = String.Join(", ", values.ToArray()); } } break; case TypeType.UsableItem: _autoAddPet(tupleSource, holder); _autoAddWeight(tupleSource, holder); _autoAddJobIfRestricted(tupleSource, holder); break; case TypeType.EtcItem: case TypeType.HealingItem: case TypeType.ShadowEquip: case TypeType.UsableWithDelayed: case TypeType.UsableWithDelayed2: _autoAddWeight(tupleSource, holder); _autoAddJobIfRestricted(tupleSource, holder); break; } _autoAdd(equipLevelAttribute, ParameterHolderKeys.RequiredLevel, tupleSource, holder, 1); holder.Values[ParameterHolderKeys.Description] = description == "" ? ProjectConfiguration.AutocompleteDescNotSet : description; var idDescription = holder.GenerateDescription(); if (ProjectConfiguration.AutocompleteIdDescription) { if (idDescription != item.GetValue <string>(ClientItemAttributes.IdentifiedDescription)) { commands.Add(new ChangeTupleProperty <TKey, ReadableTuple <TKey> >(item, ClientItemAttributes.IdentifiedDescription, idDescription)); } } var unDescription = item.GetValue <string>(ClientItemAttributes.UnidentifiedDescription); // unidentified switch (tupleSource.GetValue <TypeType>(ServerItemAttributes.Type)) { case TypeType.Ammo: case TypeType.EtcItem: case TypeType.HealingItem: case TypeType.PetEgg: case TypeType.UsableItem: case TypeType.UsableWithDelayed: case TypeType.UsableWithDelayed2: if (ProjectConfiguration.AutocompleteUnDescription && unDescription != idDescription) { commands.Add(new ChangeTupleProperty <TKey, ReadableTuple <TKey> >(item, ClientItemAttributes.UnidentifiedDescription, idDescription)); } string unDisplayName = tupleSource.GetValue <string>(ServerItemAttributes.Name); attribute = ClientItemAttributes.UnidentifiedDisplayName; if (_emptyFill(attribute, item) && ProjectConfiguration.AutocompleteUnDisplayName && _isNotNullDifferent(unDisplayName, attribute, item)) { commands.Add(new ChangeTupleProperty <TKey, ReadableTuple <TKey> >(item, attribute, unDisplayName)); } string unidentifiedResourceName = item.GetValue <string>(ClientItemAttributes.IdentifiedResourceName); if (String.IsNullOrEmpty(unidentifiedResourceName)) { unidentifiedResourceName = EncodingService.FromAnyToDisplayEncoding("Á¶°¢ÄÉÀÌÅ©"); // Cake } attribute = ClientItemAttributes.UnidentifiedResourceName; if (_emptyFill(attribute, item) && ProjectConfiguration.AutocompleteUnResourceName && _isNotNullDifferent(unidentifiedResourceName, attribute, item)) { commands.Add(new ChangeTupleProperty <TKey, ReadableTuple <TKey> >(item, attribute, unidentifiedResourceName)); } attribute = ClientItemAttributes.IdentifiedResourceName; if (_emptyFill(attribute, item) && ProjectConfiguration.AutocompleteIdResourceName && _isNotNullDifferent(unidentifiedResourceName, attribute, item)) { commands.Add(new ChangeTupleProperty <TKey, ReadableTuple <TKey> >(item, attribute, unidentifiedResourceName)); } break; case TypeType.Card: if (ProjectConfiguration.AutocompleteUnDescription && unDescription != idDescription) { commands.Add(new ChangeTupleProperty <TKey, ReadableTuple <TKey> >(item, ClientItemAttributes.UnidentifiedDescription, idDescription)); } break; default: if (ProjectConfiguration.AutocompleteUnDescription && unDescription != ProjectConfiguration.AutocompleteUnDescriptionFormat) { commands.Add(new ChangeTupleProperty <TKey, ReadableTuple <TKey> >(item, ClientItemAttributes.UnidentifiedDescription, ProjectConfiguration.AutocompleteUnDescriptionFormat)); } break; } if (commands.Commands.Count == 0) { return(null); } return(commands); }
public static void Writer2 <TKey>(ReadableTuple <TKey> item, ServerType destServer, StringBuilder builder, BaseDb db, List <string> aegisNames, List <string> names) { var itemCopy = new ReadableTuple <TKey>(item.GetKey <TKey>(), item.Attributes); itemCopy.Copy(item); item = itemCopy; int key = item.GetKey <int>(); if (destServer == ServerType.RAthena) { var itemDb = db.GetMeta <int>(ServerDbs.Items); ServerType source = DbPathLocator.GetServerType(); if (source == ServerType.Hercules) { List <string> constantsList = Constants.Keys.ToList(); Table <int, ReadableTuple <int> > table = db.GetMeta <int>(ServerDbs.Items); var tuple = item; var res2 = table.TryGetTuple(key); if (res2 != null) { string name = res2.GetValue(ServerItemAttributes.AegisName).ToString(); int low = Int32.MaxValue; int index = -1; for (int j = 0; j < Constants.Count; j++) { int dist = Methods.LevenshteinDistance(name, constantsList[j]); if (dist < low) { low = dist; index = j; } } string closestString = constantsList[index]; int groupId = Constants[closestString]; tuple.SetRawValue(0, groupId); } } Dictionary <int, ReadableTuple <int> > dico = (Dictionary <int, ReadableTuple <int> >)item.GetRawValue(1); key = item.GetKey <int>(); foreach (var pair in dico.OrderBy(p => p.Key)) { var dbTuple = itemDb.TryGetTuple(pair.Key); List <string> items = ServerItemGroupSubAttributes.AttributeList.Attributes.Select(p => pair.Value.GetValue <string>(p)).ToList(); RemoveDefaultValues(items); builder.AppendLine(key + "," + string.Join(",", items.ToArray()) + (dbTuple == null ? "" : "\t// " + dbTuple.GetValue(ServerItemAttributes.Name))); } builder.AppendLine(); } else if (destServer == ServerType.Hercules) { builder.AppendLine(ItemGroupParser.ToHerculesDbEntry(db, item.GetKey <int>(), aegisNames, names)); builder.AppendLine(); } }
public static void WriteEntryYaml(StringBuilder builder, ReadableTuple <int> tuple, MetaTable <int> itemDb, MetaTable <int> mobDb) { if (tuple != null) { string valueS; bool valueB; builder.AppendLine(" - Mob: " + DbIOUtils.Id2Name(mobDb, ServerMobAttributes.AegisName, tuple.GetKey <int>().ToString(CultureInfo.InvariantCulture))); if ((valueS = tuple.GetValue <string>(ServerPetAttributes.LureId)) != "" && valueS != "0") { builder.AppendLine(" TameItem: " + DbIOUtils.Id2Name(itemDb, ServerItemAttributes.AegisName, valueS)); } if ((valueS = tuple.GetValue <string>(ServerPetAttributes.EggId)) != "" && valueS != "0") { builder.AppendLine(" EggItem: " + DbIOUtils.Id2Name(itemDb, ServerItemAttributes.AegisName, valueS)); } if ((valueS = tuple.GetValue <string>(ServerPetAttributes.EquipId)) != "" && valueS != "0") { builder.AppendLine(" EquipItem: " + DbIOUtils.Id2Name(itemDb, ServerItemAttributes.AegisName, valueS)); } if ((valueS = tuple.GetValue <string>(ServerPetAttributes.FoodId)) != "" && valueS != "0") { builder.AppendLine(" FoodItem: " + DbIOUtils.Id2Name(itemDb, ServerItemAttributes.AegisName, valueS)); } builder.AppendLine(" Fullness: " + tuple.GetValue <int>(ServerPetAttributes.Fullness)); if ((valueS = tuple.GetValue <string>(ServerPetAttributes.HungryDelay)) != "60") { builder.AppendLine(" HungryDelay: " + valueS); } if ((valueS = tuple.GetValue <string>(ServerPetAttributes.HungerIncrease)) != "20") { builder.AppendLine(" HungerIncrease: " + valueS); } if ((valueS = tuple.GetValue <string>(ServerPetAttributes.IntimacyStart)) != "250") { builder.AppendLine(" IntimacyStart: " + valueS); } if ((valueS = tuple.GetValue <string>(ServerPetAttributes.IntimacyFed)) != "50") { builder.AppendLine(" IntimacyFed: " + valueS); } if ((valueS = tuple.GetValue <string>(ServerPetAttributes.IntimacyOverfed)) != "-100") { builder.AppendLine(" IntimacyOverfed: " + valueS); } if ((valueS = tuple.GetValue <string>(ServerPetAttributes.IntimacyHungry)) != "-5") { builder.AppendLine(" IntimacyHungry: " + valueS); } if ((valueS = tuple.GetValue <string>(ServerPetAttributes.IntimacyOwnerDie)) != "-20") { builder.AppendLine(" IntimacyOwnerDie: " + valueS); } builder.AppendLine(" CaptureRate: " + tuple.GetValue <int>(ServerPetAttributes.CaptureRate)); if ((valueB = tuple.GetValue <bool>(ServerPetAttributes.SpecialPerformance)) == false) { builder.AppendLine(" SpecialPerformance: false"); } if ((valueS = tuple.GetValue <string>(ServerPetAttributes.AttackRate)) != "" && valueS != "0") { builder.AppendLine(" AttackRate: " + valueS); } if ((valueS = tuple.GetValue <string>(ServerPetAttributes.RetaliateRate)) != "" && valueS != "0") { builder.AppendLine(" RetaliateRate: " + valueS); } if ((valueS = tuple.GetValue <string>(ServerPetAttributes.ChangeTargetRate)) != "" && valueS != "0") { builder.AppendLine(" ChangeTargetRate: " + valueS); } if ((valueB = tuple.GetValue <bool>(ServerPetAttributes.AllowAutoFeed)) == true) { builder.AppendLine(" AllowAutoFeed: true"); } if ((valueS = tuple.GetValue <string>(ServerPetAttributes.LoyalScript)) != "" && valueS != "{}") { builder.AppendLine(" Script: >"); builder.AppendLine(DbIOFormatting.ScriptFormatYaml(valueS, " ")); } if ((valueS = tuple.GetValue <string>(ServerPetAttributes.PetScript)) != "" && valueS != "{}") { builder.AppendLine(" SupportScript: >"); builder.AppendLine(DbIOFormatting.ScriptFormatYaml(valueS, " ")); } if ((valueS = tuple.GetValue <string>(ServerPetAttributes.Evolution)) != "" && valueS != "0") { builder.AppendLine(" Evolution:"); Evolution evolution = new Evolution(valueS); foreach (var evo in evolution.Targets) { builder.Append(" - Target: "); builder.AppendLine(DbIOUtils.Id2Name(mobDb, ServerMobAttributes.AegisName, evo.Target)); if (evo.ItemRequirements.Count > 0) { builder.AppendLine(" ItemRequirements:"); foreach (var item in evo.ItemRequirements) { builder.Append(" - Item: "); builder.AppendLine(DbIOUtils.Id2Name(itemDb, ServerItemAttributes.AegisName, item.Item1.ToString())); builder.Append(" Amount: "); builder.AppendLine(item.Item2.ToString(CultureInfo.InvariantCulture)); } } } } } }
public void Initialize(GTabSettings <TKey, TValue> settings) { Settings = settings; _displayGrid = new Grid(); _displayGrid.SetValue(Grid.ColumnProperty, 2); _displayGrid.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(1, GridUnitType.Auto) }); _displayGrid.ColumnDefinitions.Add(new ColumnDefinition()); _displayGrid.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(10) }); _displayGrid.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(1, GridUnitType.Auto) }); _displayGrid.ColumnDefinitions.Add(new ColumnDefinition()); if (Settings.DbData == ServerDbs.ClientItems || Settings.DbData == ServerDbs.Pet || Settings.DbData == ServerDbs.Pet2 || Settings.DbData == ServerDbs.Mobs || Settings.DbData == ServerDbs.Mobs2 || Settings.DbData == ServerDbs.MobGroups || Settings.DbData == ServerDbs.Items || Settings.DbData == ServerDbs.Items2) { _viewGrid.Children.Add(_displayGrid); } else { ScrollViewer sv = new ScrollViewer(); sv.SetValue(Grid.ColumnProperty, 2); sv.SetValue(ScrollViewer.VerticalScrollBarVisibilityProperty, ScrollBarVisibility.Auto); sv.Focusable = false; sv.Content = _displayGrid; _viewGrid.Children.Add(sv); } ProjectDatabase = settings.ClientDatabase; DbComponent = ProjectDatabase.GetDb <TKey>(settings.DbData); Table = Settings.Table; Header = Settings.TabName; Style = TryFindResource(settings.Style) as Style ?? Style; SearchEngine = settings.SearchEngine; SearchEngine.Init(_dbSearchPanel, this); Table.TableUpdated += new Table <TKey, TValue> .UpdateTableEventHandler(_table_TableUpdated); if (Settings.SearchEngine.SetupImageDataGetter != null) { ListViewDataTemplateHelper.GenerateListViewTemplateNew(_listView, new ListViewDataTemplateHelper.GeneralColumnInfo[] { new ListViewDataTemplateHelper.GeneralColumnInfo { Header = Settings.AttId.DisplayName, DisplayExpression = "[" + Settings.AttId.Index + "]", SearchGetAccessor = Settings.AttId.AttributeName, FixedWidth = Settings.AttIdWidth, TextAlignment = TextAlignment.Right, ToolTipBinding = "[" + Settings.AttId.Index + "]" }, new ListViewDataTemplateHelper.ImageColumnInfo { Header = "", DisplayExpression = "DataImage", SearchGetAccessor = Settings.AttId.AttributeName, FixedWidth = 26, MaxHeight = 24 }, new ListViewDataTemplateHelper.RangeColumnInfo { Header = Settings.AttDisplay.DisplayName, DisplayExpression = "[" + Settings.AttDisplay.Index + "]", SearchGetAccessor = Settings.AttDisplay.AttributeName, IsFill = true, ToolTipBinding = "[" + Settings.AttDisplay.Index + "]", MinWidth = 100, TextWrapping = TextWrapping.Wrap } }, new DatabaseItemSorter(Settings.AttributeList), new string[] { "Deleted", "{DynamicResource CellBrushRemoved}", "Modified", "{DynamicResource CellBrushModified}", "Added", "{DynamicResource CellBrushAdded}", "Normal", "{DynamicResource TextForeground}" }); } else { ListViewDataTemplateHelper.GenerateListViewTemplateNew(_listView, new ListViewDataTemplateHelper.GeneralColumnInfo[] { new ListViewDataTemplateHelper.GeneralColumnInfo { Header = Settings.AttId.DisplayName, DisplayExpression = "[" + Settings.AttId.Index + "]", SearchGetAccessor = Settings.AttId.AttributeName, FixedWidth = Settings.AttIdWidth, TextAlignment = TextAlignment.Right, ToolTipBinding = "[" + Settings.AttId.Index + "]" }, new ListViewDataTemplateHelper.RangeColumnInfo { Header = Settings.AttDisplay.DisplayName, DisplayExpression = "[" + Settings.AttDisplay.Index + "]", SearchGetAccessor = Settings.AttDisplay.AttributeName, IsFill = true, ToolTipBinding = "[" + Settings.AttDisplay.Index + "]", MinWidth = 100, TextWrapping = TextWrapping.Wrap } }, new DatabaseItemSorter(Settings.AttributeList), new string[] { "Deleted", "{DynamicResource CellBrushRemoved}", "Modified", "{DynamicResource CellBrushModified}", "Added", "{DynamicResource CellBrushAdded}", "Normal", "{DynamicResource TextForeground}" }); } if (!Settings.CanBeDelayed || Settings.AttributeList.Attributes.Any(p => p.IsSkippable)) { _deployTabControls(); } _initTableEvents(); if (Settings.ContextMenu != null) { if (Header is Control) { ((Control)Header).ContextMenu = Settings.ContextMenu; } } if (Settings.Loaded != null) { Settings.Loaded((GDbTabWrapper <TKey, ReadableTuple <TKey> >)(object) this, (GTabSettings <TKey, ReadableTuple <TKey> >)(object) Settings, ProjectDatabase.GetDb <TKey>(Settings.DbData)); } if (Settings.DisplayablePropertyMaker.OnTabVisible != null) { Settings.DisplayablePropertyMaker.OnTabVisible(this); } Loaded += delegate { TabControl parent = WpfUtilities.FindParentControl <TabControl>(this); if (parent != null) { parent.SelectionChanged += new SelectionChangedEventHandler(_parent_SelectionChanged); } }; _listView.PreviewMouseDown += delegate { _listView.Focus(); }; _listView.Loaded += delegate { try { if (IsVisible) { Keyboard.Focus(_listView); } } catch { } }; ApplicationShortcut.Link(ApplicationShortcut.Paste, () => ImportFromFile("clipboard"), _listView); ApplicationShortcut.Link(ApplicationShortcut.AdvancedPaste, () => ImportFromFile("clipboard", true), this); ApplicationShortcut.Link(ApplicationShortcut.AdvancedPaste2, () => ImportFromFile("clipboard", true), this); ApplicationShortcut.Link(ApplicationShortcut.Cut, () => _miCut_Click(null, null), _listView); ApplicationShortcut.Link(ApplicationShortcut.FromString("F3", "Search next empty ID"), () => { if (_listView.SelectedItems.Count > 0) { ReadableTuple <int> item = (_listView.SelectedItems[_listView.SelectedItems.Count - 1]) as ReadableTuple <int>; var original = item; if (item != null) { int id = item.Key; while (true) { id++; var idGeneric = (TKey)(object)id; var tuple = (ReadableTuple <int>)(object) Table.TryGetTuple(idGeneric); if (tuple == null && item != original && item != null) { TabNavigation.SelectList(DbComponent.DbSource, new TKey[] { item.GetKey <TKey>() }); break; } item = tuple; } } } }, _listView); }
public static void WriteEntry(BaseDb db, StringBuilder builder, ReadableTuple <int> tuple) { bool useExtendedJobs = db.Attached["ItemDb.UseExtendedJobs"] != null && (bool)db.Attached["ItemDb.UseExtendedJobs"]; builder.AppendLine("{"); builder.AppendLine("\tId: " + tuple.GetKey <int>().ToString(CultureInfo.InvariantCulture)); builder.AppendLine("\tAegisName: \"" + tuple.GetValue <string>(ServerItemAttributes.AegisName) + "\""); builder.AppendLine("\tName: \"" + tuple.GetValue <string>(ServerItemAttributes.Name) + "\""); DbIOFormatting.SetType(tuple, builder, ServerItemAttributes.Type); DbIOFormatting.TrySetIfNotDefault(tuple, builder, ServerItemAttributes.Buy, ""); DbIOFormatting.TrySetIfDefaultEmpty(tuple, builder, ServerItemAttributes.Sell, (tuple.GetIntNoThrow(ServerItemAttributes.Buy) / 2).ToString(CultureInfo.InvariantCulture)); DbIOFormatting.TrySetIfDefaultEmpty(tuple, builder, ServerItemAttributes.Weight, "0"); DbIOFormatting.TrySetIfDefaultEmpty(tuple, builder, ServerItemAttributes.Attack, "0"); DbIOFormatting.TrySetIfDefaultEmpty(tuple, builder, ServerItemAttributes.Matk, "0"); DbIOFormatting.TrySetIfDefaultEmpty(tuple, builder, ServerItemAttributes.Defense, "0"); DbIOFormatting.TrySetIfDefaultEmpty(tuple, builder, ServerItemAttributes.Range, "0"); DbIOFormatting.TrySetIfDefaultEmpty(tuple, builder, ServerItemAttributes.NumberOfSlots, "0"); if (useExtendedJobs) { DbIOFormatting.TrySetIfDefaultEmptyAddHexJobEx(tuple, builder, ServerItemAttributes.ApplicableJob, ""); } else { DbIOFormatting.TrySetIfDefaultEmptyAddHex(tuple, builder, ServerItemAttributes.ApplicableJob, ""); } DbIOFormatting.TrySetIfDefaultEmptyUpper(tuple, builder, ServerItemAttributes.Upper); DbIOFormatting.TrySetGender(tuple, builder, ServerItemAttributes.Gender, "2"); DbIOFormatting.TrySetIfDefaultLocation(tuple, builder, ServerItemAttributes.Location); DbIOFormatting.TrySetIfDefaultEmpty(tuple, builder, ServerItemAttributes.WeaponLevel, "0"); DbIOFormatting.TrySetIfDefaultEmpty(tuple, builder, ServerItemAttributes.EquipLevel, "0"); DbIOFormatting.TrySetIfRefineable(tuple, builder, ServerItemAttributes.Refineable, true); DbIOFormatting.TrySetIfDefaultEmpty(tuple, builder, ServerItemAttributes.ClassNumber, "0"); DbIOFormatting.TrySetIfDefaultBoolean(tuple, builder, ServerItemAttributes.BindOnEquip, false); DbIOFormatting.TrySetIfDefaultBoolean(tuple, builder, ServerItemAttributes.ForceSerial, false); DbIOFormatting.TrySetIfDefaultBoolean(tuple, builder, ServerItemAttributes.BuyingStore, false); DbIOFormatting.TrySetIfDefaultEmpty(tuple, builder, ServerItemAttributes.Delay, "0"); DbIOFormatting.TrySetIfDefaultBoolean(tuple, builder, ServerItemAttributes.KeepAfterUse, false); var tradeOverride = tuple.GetIntNoThrow(ServerItemAttributes.TradeOverride); var tradeFlag = tuple.GetIntNoThrow(ServerItemAttributes.TradeFlag); if (tradeOverride != 100 || tradeFlag != 0) { builder.AppendLine(" Trade: {"); if (tradeOverride != 100) { builder.AppendLine(" override: "+ tradeOverride); } if ((tradeFlag & (1 << 0)) == (1 << 0)) { builder.AppendLine(" nodrop: true"); } if ((tradeFlag & (1 << 1)) == (1 << 1)) { builder.AppendLine(" notrade: true"); } if ((tradeFlag & (1 << 2)) == (1 << 2)) { builder.AppendLine(" partneroverride: true"); } if ((tradeFlag & (1 << 3)) == (1 << 3)) { builder.AppendLine(" noselltonpc: true"); } if ((tradeFlag & (1 << 4)) == (1 << 4)) { builder.AppendLine(" nocart: true"); } if ((tradeFlag & (1 << 5)) == (1 << 5)) { builder.AppendLine(" nostorage: true"); } if ((tradeFlag & (1 << 6)) == (1 << 6)) { builder.AppendLine(" nogstorage: true"); } if ((tradeFlag & (1 << 7)) == (1 << 7)) { builder.AppendLine(" nomail: true"); } if ((tradeFlag & (1 << 8)) == (1 << 8)) { builder.AppendLine(" noauction: true"); } builder.AppendLine(" }"); } var nouseOverride = tuple.GetIntNoThrow(ServerItemAttributes.NoUseOverride); var nouseFlag = tuple.GetIntNoThrow(ServerItemAttributes.NoUseFlag); if (nouseOverride != 100 || nouseFlag != 0) { builder.AppendLine(" Nouse: {"); if (nouseOverride != 100) { builder.AppendLine(" override: "+ nouseOverride); } if ((nouseFlag & (1 << 0)) == (1 << 0)) { builder.AppendLine(" sitting: true"); } builder.AppendLine(" }"); } DbIOFormatting.TrySetIfDefaultEmptyBracket(tuple, builder, ServerItemAttributes.Stack, ""); DbIOFormatting.TrySetIfDefaultEmpty(tuple, builder, ServerItemAttributes.Sprite, "0"); DbIOFormatting.TrySetIfDefaultEmptyScript(tuple, builder, ServerItemAttributes.Script, ""); DbIOFormatting.TrySetIfDefaultEmptyScript(tuple, builder, ServerItemAttributes.OnEquipScript, ""); DbIOFormatting.TrySetIfDefaultEmptyScript(tuple, builder, ServerItemAttributes.OnUnequipScript, ""); builder.Append("},"); }
public static void TrySetIfRefineable(ReadableTuple <int> tuple, StringBuilder builder, DbAttribute attribute, bool defaultValue) { int type = tuple.GetValue <int>(ServerItemAttributes.Type); bool val = tuple.GetValue <bool>(attribute); if (type != 4 && type != 5) { if (val) { // This is not supposed to be allowed, but... we'll let it slide DbIOErrorHandler.Handle(StackTraceException.GetStrackTraceException(), "The refineable state on the item ID [" + tuple.GetKey <int>() + "] has been set to true but the item type is not an equipment. This is suspicious.", ErrorLevel.Warning); builder.AppendLine("\t" + attribute.AttributeName + ": true"); } return; } if (val != defaultValue) { builder.Append("\t"); builder.Append(attribute.AttributeName); builder.Append(": "); builder.AppendLine(val.ToString().ToLower()); } }
private static void _trySetIfRefineable(ReadableTuple<int> tuple, StringBuilder builder, DbAttribute attribute, bool defaultValue) { int type = tuple.GetValue<int>(ServerItemAttributes.Type); bool val = tuple.GetValue<bool>(attribute); if (type != 4 && type != 5) { if (val) { // This is not supposed to be allowed, but... we'll let it slide DbLoaderErrorHandler.Handle("The refineable status on the item ID [" + tuple.GetKey<int>() + "] has been set to true but the item type is not an equipment. This is suspicious.", ErrorLevel.Warning); builder.AppendLineUnix("\t" + attribute.AttributeName + ": true"); } return; } if (val != defaultValue) { builder.Append("\t"); builder.Append(attribute.AttributeName); builder.Append(": "); builder.AppendLineUnix(val.ToString().ToLower()); } }
private static void _trySetGender(ReadableTuple<int> tuple, StringBuilder builder, DbAttribute attribute, string defaultValue) { int key = tuple.GetKey<int>(); string val = tuple.GetValue<string>(attribute); if (key >= 1950 && key < 2000) { if (val == "0") return; } if (key == 2635) { if (val == "0") return; } if (val != "" && val != defaultValue && val != "-1") { builder.Append("\t"); builder.Append(attribute.AttributeName); builder.Append(": "); builder.AppendLineUnix(val); } }
public static void WriteEntryYaml <TKey>(StringBuilder builder, ReadableTuple <TKey> tuple, MetaTable <int> itemDb, MetaTable <int> mobDb) { if (tuple != null) { string valueS; int value; builder.AppendLine(" - Id: " + tuple.GetKey <int>()); if ((valueS = tuple.GetValue <string>(ServerQuestsAttributes.QuestTitle)) != "" && valueS != "0") { builder.AppendLine(" Title: " + DbIOUtils.QuoteCheck(valueS)); } if ((valueS = tuple.GetValue <string>(ServerQuestsAttributes.TimeLimitNew)) != "" && valueS != "0") { builder.AppendLine(" TimeLimit: " + valueS); } if (tuple.GetValue <int>(ServerQuestsAttributes.TargetId1) > 0 || tuple.GetValue <int>(ServerQuestsAttributes.TargetId2) > 0 || tuple.GetValue <int>(ServerQuestsAttributes.TargetId3) > 0) { builder.AppendLine(" Targets:"); for (int i = 0; i < 3; i++) { if ((valueS = tuple.GetValue <string>(ServerQuestsAttributes.TargetId1.Index + 2 * i)) != "" && valueS != "0") { builder.AppendLine(" - Mob: " + DbIOUtils.Id2Name(mobDb, ServerMobAttributes.AegisName, valueS)); if ((value = tuple.GetValue <int>(ServerQuestsAttributes.Val1.Index + 2 * i)) != 0) { builder.AppendLine(" Count: " + value); } if ((value = tuple.GetValue <int>(ServerQuestsAttributes.Id1.Index + i)) != 0) { builder.AppendLine(" Id: " + value); } if ((value = tuple.GetValue <int>(ServerQuestsAttributes.Race1.Index + i)) != 0) { builder.AppendLine(" Race: " + Constants.ToString <QuestRaceType>(value)); } if ((value = tuple.GetValue <int>(ServerQuestsAttributes.Size1.Index + i)) != 0) { builder.AppendLine(" Size: " + Constants.ToString <QuestSizeType>(value)); } if ((value = tuple.GetValue <int>(ServerQuestsAttributes.Element1.Index + i)) != 0) { builder.AppendLine(" Element: " + Constants.ToString <QuestElementType>(value)); } if ((value = tuple.GetValue <int>(ServerQuestsAttributes.MinLevel1.Index + i)) != 0) { builder.AppendLine(" MinLevel: " + value); } if ((value = tuple.GetValue <int>(ServerQuestsAttributes.MaxLevel1.Index + i)) != 0) { builder.AppendLine(" MaxLevel: " + value); } } } } if (tuple.GetValue <int>(ServerQuestsAttributes.NameId1) > 0 || tuple.GetValue <int>(ServerQuestsAttributes.NameId2) > 0 || tuple.GetValue <int>(ServerQuestsAttributes.NameId3) > 0) { builder.AppendLine(" Drops:"); for (int i = 0; i < 3; i++) { if ((valueS = tuple.GetValue <string>(ServerQuestsAttributes.MobId1.Index + 3 * i)) != "" && valueS != "0") { builder.AppendLine(" - Mob: " + DbIOUtils.Id2Name(mobDb, ServerMobAttributes.AegisName, valueS)); builder.AppendLine(" Item: " + DbIOUtils.Id2Name(itemDb, ServerItemAttributes.AegisName, tuple.GetValue <string>(ServerQuestsAttributes.NameId1.Index + 3 * i))); builder.AppendLine(" Rate: " + tuple.GetValue <string>(ServerQuestsAttributes.Rate1.Index + 3 * i)); if ((value = tuple.GetValue <int>(ServerQuestsAttributes.Count1.Index + i)) != 1) { builder.AppendLine(" Count: " + value); } } } } } }
public static void WriteEntry(BaseDb db, StringBuilder builder, ReadableTuple <int> tuple) { bool useConstants = db.Attached["MobDb.UseConstants"] != null && (bool)db.Attached["MobDb.UseConstants"]; builder.AppendLine("{"); builder.AppendLine("\tId: " + tuple.GetKey <int>().ToString(CultureInfo.InvariantCulture)); builder.AppendLine("\tSpriteName: \"" + tuple.GetValue <string>(ServerMobAttributes.AegisName) + "\""); builder.AppendLine("\tName: \"" + tuple.GetValue <string>(ServerMobAttributes.KRoName) + "\""); DbIOFormatting.TrySetIfNotDefault(tuple, builder, ServerMobAttributes.Lv, "1"); DbIOFormatting.TrySetIfNotDefault(tuple, builder, ServerMobAttributes.Hp, "1"); DbIOFormatting.TrySetIfNotDefault(tuple, builder, ServerMobAttributes.Sp, "0"); DbIOFormatting.TrySetIfNotDefault(tuple, builder, ServerMobAttributes.Exp, "0"); DbIOFormatting.TrySetIfNotDefault(tuple, builder, ServerMobAttributes.JExp, "0"); DbIOFormatting.TrySetIfNotDefault(tuple, builder, ServerMobAttributes.AttackRange, "1"); DbIOFormatting.TrySetAttack(tuple, builder); DbIOFormatting.TrySetIfNotDefault(tuple, builder, ServerMobAttributes.Def, "0"); DbIOFormatting.TrySetIfNotDefault(tuple, builder, ServerMobAttributes.Mdef, "0"); int stat = 0; for (int i = 0; i < 6; i++) { stat += tuple.GetIntNoThrow(ServerMobAttributes.Str.Index + i); } if (stat != 0) { builder.AppendLine(" Stats: {"); for (int i = 0; i < 6; i++) { stat = tuple.GetIntNoThrow(ServerMobAttributes.Str.Index + i); if (stat != 0) { builder.AppendLine(String.Format(" {0}: {1}", ServerMobAttributes.AttributeList[ServerMobAttributes.Str.Index + i].AttributeName, stat)); } } builder.AppendLine(" }"); } DbIOFormatting.TrySetIfNotDefault(tuple, builder, ServerMobAttributes.ViewRange, "1"); DbIOFormatting.TrySetIfNotDefault(tuple, builder, ServerMobAttributes.ChaseRange, "1"); DbIOFormatting.TrySetIfNotDefault(tuple, builder, ServerMobAttributes.Size, "1", useConstants, "Size_"); DbIOFormatting.TrySetIfNotDefault(tuple, builder, ServerMobAttributes.Race, "0", useConstants, "RC_"); int element = tuple.GetIntNoThrow(ServerMobAttributes.Element); int level = element / 10; int property = element - level * 10; level = level / 2; if (useConstants) { builder.AppendLine("\tElement: (\"" + SdeEditor.Instance.ProjectDatabase.IntToConstant(property, "Ele_") + "\", " + level + ")"); } else { builder.AppendLine("\tElement: (" + property + ", " + level + ")"); } int mode = tuple.GetIntNoThrow(ServerMobAttributes.Mode); if ((mode & 32767) != 0) { builder.AppendLine(" Mode: {"); if ((mode & (1 << 0)) == (1 << 0)) { builder.AppendLine(" CanMove: true"); } if ((mode & (1 << 1)) == (1 << 1)) { builder.AppendLine(" Looter: true"); } if ((mode & (1 << 2)) == (1 << 2)) { builder.AppendLine(" Aggressive: true"); } if ((mode & (1 << 3)) == (1 << 3)) { builder.AppendLine(" Assist: true"); } if ((mode & (1 << 4)) == (1 << 4)) { builder.AppendLine(" CastSensorIdle: true"); } if ((mode & (1 << 5)) == (1 << 5)) { builder.AppendLine(" Boss: true"); } if ((mode & (1 << 6)) == (1 << 6)) { builder.AppendLine(" Plant: true"); } if ((mode & (1 << 7)) == (1 << 7)) { builder.AppendLine(" CanAttack: true"); } if ((mode & (1 << 8)) == (1 << 8)) { builder.AppendLine(" Detector: true"); } if ((mode & (1 << 9)) == (1 << 9)) { builder.AppendLine(" CastSensorChase: true"); } if ((mode & (1 << 10)) == (1 << 10)) { builder.AppendLine(" ChangeChase: true"); } if ((mode & (1 << 11)) == (1 << 11)) { builder.AppendLine(" Angry: true"); } if ((mode & (1 << 12)) == (1 << 12)) { builder.AppendLine(" ChangeTargetMelee: true"); } if ((mode & (1 << 13)) == (1 << 13)) { builder.AppendLine(" ChangeTargetChase: true"); } if ((mode & (1 << 14)) == (1 << 14)) { builder.AppendLine(" TargetWeak: true"); } builder.AppendLine(" }"); } DbIOFormatting.TrySetIfNotDefault(tuple, builder, ServerMobAttributes.MoveSpeed, "0"); DbIOFormatting.TrySetIfNotDefault(tuple, builder, ServerMobAttributes.AttackDelay, "4000"); DbIOFormatting.TrySetIfNotDefault(tuple, builder, ServerMobAttributes.AttackMotion, "2000"); DbIOFormatting.TrySetIfNotDefault(tuple, builder, ServerMobAttributes.DamageMotion, "0"); DbIOFormatting.TrySetIfNotDefault(tuple, builder, ServerMobAttributes.MvpExp, "0"); stat = 0; for (int i = 0; i < 6; i += 2) { stat += tuple.GetIntNoThrow(ServerMobAttributes.Mvp1ID.Index + i); } if (stat != 0) { builder.AppendLine(" MvpDrops: {"); for (int i = 0; i < 6; i += 2) { stat = tuple.GetIntNoThrow(ServerMobAttributes.Mvp1ID.Index + i); if (stat != 0) { var ttuple = SdeDatabase.GetTuple(null, stat); if (ttuple != null) { builder.AppendLine(String.Format(" {0}: {1}", ttuple.GetStringValue(ServerItemAttributes.AegisName.Index), tuple.GetIntNoThrow(ServerMobAttributes.Mvp1ID.Index + i + 1))); } } } builder.AppendLine(" }"); } stat = 0; for (int i = 0; i < 18; i += 2) { stat += tuple.GetIntNoThrow(ServerMobAttributes.Drop1ID.Index + i); } if (stat != 0) { builder.AppendLine(" Drops: {"); for (int i = 0; i < 18; i += 2) { stat = tuple.GetIntNoThrow(ServerMobAttributes.Drop1ID.Index + i); if (stat != 0) { var ttuple = SdeDatabase.GetTuple(null, stat); if (ttuple != null) { builder.AppendLine(String.Format(" {0}: {1}", ttuple.GetStringValue(ServerItemAttributes.AegisName.Index), tuple.GetIntNoThrow(ServerMobAttributes.Drop1ID.Index + i + 1))); } } } stat = tuple.GetIntNoThrow(ServerMobAttributes.DropCardid); if (stat != 0) { var ttuple = SdeDatabase.GetTuple(null, stat); if (ttuple != null) { builder.AppendLine(String.Format(" {0}: {1}", ttuple.GetStringValue(ServerItemAttributes.AegisName.Index), tuple.GetIntNoThrow(ServerMobAttributes.DropCardper.Index))); } } builder.AppendLine(" }"); } builder.Append("},"); }
public static void WriteEntryYaml(StringBuilder builder, ReadableTuple <int> tuple, MetaTable <int> itemDb) { if (tuple != null) { builder.AppendLine(" - Id: " + tuple.GetKey <int>().ToString(CultureInfo.InvariantCulture)); builder.AppendLine(" AegisName: " + tuple.GetValue <string>(ServerMobAttributes.AegisName)); builder.AppendLine(" Name: " + DbIOUtils.QuoteCheck(tuple.GetValue <string>(ServerMobAttributes.IRoName))); if (tuple.GetValue <string>(ServerMobAttributes.IRoName) != tuple.GetValue <string>(ServerMobAttributes.KRoName)) { builder.AppendLine(" JapaneseName: " + DbIOUtils.QuoteCheck(tuple.GetValue <string>(ServerMobAttributes.KRoName))); } int value; //bool valueB; string valueS; //int type = 0; builder.AppendLine(" Level: " + tuple.GetValue <int>(ServerMobAttributes.Lv)); if ((value = tuple.GetValue <int>(ServerMobAttributes.Hp)) != 1) { builder.AppendLine(" Hp: " + value); } if ((value = tuple.GetValue <int>(ServerMobAttributes.Sp)) != 1) { builder.AppendLine(" Sp: " + value); } if ((value = tuple.GetValue <int>(ServerMobAttributes.Exp)) != 0) { builder.AppendLine(" BaseExp: " + value); } if ((value = tuple.GetValue <int>(ServerMobAttributes.JExp)) != 0) { builder.AppendLine(" JobExp: " + value); } if ((value = tuple.GetValue <int>(ServerMobAttributes.MvpExp)) != 0) { builder.AppendLine(" MvpExp: " + value); } if ((value = tuple.GetValue <int>(ServerMobAttributes.Atk1)) != 0) { builder.AppendLine(" Attack: " + value); } if ((value = tuple.GetValue <int>(ServerMobAttributes.Atk2)) != 0) { builder.AppendLine(" Attack2: " + value); } if ((value = tuple.GetValue <int>(ServerMobAttributes.Def)) != 0) { builder.AppendLine(" Defense: " + value); } if ((value = tuple.GetValue <int>(ServerMobAttributes.Mdef)) != 0) { builder.AppendLine(" MagicDefense: " + value); } if ((value = tuple.GetValue <int>(ServerMobAttributes.Str)) != 1) { builder.AppendLine(" Str: " + value); } if ((value = tuple.GetValue <int>(ServerMobAttributes.Agi)) != 1) { builder.AppendLine(" Agi: " + value); } if ((value = tuple.GetValue <int>(ServerMobAttributes.Vit)) != 1) { builder.AppendLine(" Vit: " + value); } if ((value = tuple.GetValue <int>(ServerMobAttributes.Int)) != 1) { builder.AppendLine(" Int: " + value); } if ((value = tuple.GetValue <int>(ServerMobAttributes.Dex)) != 1) { builder.AppendLine(" Dex: " + value); } if ((value = tuple.GetValue <int>(ServerMobAttributes.Luk)) != 1) { builder.AppendLine(" Luk: " + value); } if ((value = tuple.GetValue <int>(ServerMobAttributes.AttackRange)) != 0) { builder.AppendLine(" AttackRange: " + value); } if ((value = tuple.GetValue <int>(ServerMobAttributes.ViewRange)) != 0) { builder.AppendLine(" SkillRange: " + value); } if ((value = tuple.GetValue <int>(ServerMobAttributes.ChaseRange)) != 0) { builder.AppendLine(" ChaseRange: " + value); } //if ((value = tuple.GetValue<int>(ServerMobAttributes.Size)) != 0) { builder.AppendLine(" Size: " + Constants.ToString <SizeType>(tuple.GetValue <int>(ServerMobAttributes.Size))); //} builder.AppendLine(" Race: " + Constants.ToString <MobRaceType>(tuple.GetValue <int>(ServerMobAttributes.Race))); DbIOUtils.ExpandFlag <MobGroup2Type>(builder, tuple, "RaceGroups", ServerMobAttributes.RaceGroups, YamlParser.Indent4, YamlParser.Indent6); int elementLevel = tuple.GetValue <int>(ServerMobAttributes.Element) / 20; int element = tuple.GetValue <int>(ServerMobAttributes.Element) % 20; switch (element) { case 0: builder.AppendLine(" Element: Neutral"); break; case 1: builder.AppendLine(" Element: Water"); break; case 2: builder.AppendLine(" Element: Earth"); break; case 3: builder.AppendLine(" Element: Fire"); break; case 4: builder.AppendLine(" Element: Wind"); break; case 5: builder.AppendLine(" Element: Poison"); break; case 6: builder.AppendLine(" Element: Holy"); break; case 7: builder.AppendLine(" Element: Dark"); break; case 8: builder.AppendLine(" Element: Ghost"); break; case 9: builder.AppendLine(" Element: Undead"); break; } builder.AppendLine(" ElementLevel: " + elementLevel); if ((value = tuple.GetValue <int>(ServerMobAttributes.MoveSpeed)) != 0) { builder.AppendLine(" WalkSpeed: " + value); } if ((value = tuple.GetValue <int>(ServerMobAttributes.AttackDelay)) != 0) { builder.AppendLine(" AttackDelay: " + value); } if ((value = tuple.GetValue <int>(ServerMobAttributes.AttackMotion)) != 0) { builder.AppendLine(" AttackMotion: " + value); } if ((value = tuple.GetValue <int>(ServerMobAttributes.DamageMotion)) != 0) { builder.AppendLine(" DamageMotion: " + value); } if ((value = tuple.GetValue <int>(ServerMobAttributes.DamageTaken)) != 100) { builder.AppendLine(" DamageTaken: " + value); } long mode = FormatConverters.LongOrHexConverter(tuple.GetValue <string>(ServerMobAttributes.NewMode)); if ((mode & 0xB695) == 0xB695) { builder.AppendLine(" Ai: 26"); mode &= ~0xB695; } else if ((mode & 0x8084) == 0x8084) { builder.AppendLine(" Ai: 27"); mode &= ~0x8084; } else if ((mode & 0x7085) == 0x7085) { builder.AppendLine(" Ai: 08"); mode &= ~0x7085; } else if ((mode & 0x3885) == 0x3885) { builder.AppendLine(" Ai: 04"); mode &= ~0x3885; } else if ((mode & 0x3695) == 0x3695) { builder.AppendLine(" Ai: 21"); mode &= ~0x3695; } else if ((mode & 0x3295) == 0x3295) { builder.AppendLine(" Ai: 20"); mode &= ~0x3295; } else if ((mode & 0x3095) == 0x3095) { builder.AppendLine(" Ai: 09"); mode &= ~0x3095; } else if ((mode & 0x308D) == 0x308D) { builder.AppendLine(" Ai: 13"); mode &= ~0x308D; } else if ((mode & 0x2085) == 0x2085) { builder.AppendLine(" Ai: 05"); mode &= ~0x2085; } else if ((mode & 0x108B) == 0x108B) { builder.AppendLine(" Ai: 07"); mode &= ~0x108B; } else if ((mode & 0x1089) == 0x1089) { builder.AppendLine(" Ai: 03"); mode &= ~0x1089; } else if ((mode & 0xA1) == 0xA1) { builder.AppendLine(" Ai: 24"); mode &= ~0xA1; } else if ((mode & 0x91) == 0x91) { builder.AppendLine(" Ai: 17"); mode &= ~0x91; } else if ((mode & 0x84) == 0x84) { builder.AppendLine(" Ai: 10"); mode &= ~0x84; } else if ((mode & 0x83) == 0x83) { builder.AppendLine(" Ai: 02"); mode &= ~0x83; } else if ((mode & 0x81) == 0x81) { builder.AppendLine(" Ai: 01"); mode &= ~0x81; } else if ((mode & 0x1) == 0x1) { builder.AppendLine(" Ai: 25"); mode &= ~0x1; } if ((value = tuple.GetValue <int>(ServerMobAttributes.Class)) != 0) { builder.AppendLine(" Class: " + Constants.ToString <ClassType>(value)); } if (mode > 0) { builder.AppendLine(" Modes:"); if ((mode & 0x1) == 0x1) { builder.AppendLine(" CanMove: true"); } if ((mode & 0x80) == 0x80) { builder.AppendLine(" CanAttack: true"); } if ((mode & 0x40) == 0x40) { builder.AppendLine(" NoCast: true"); } if ((mode & 0x2) == 0x2) { builder.AppendLine(" Looter: true"); } if ((mode & 0x4) == 0x4) { builder.AppendLine(" Aggressive: true"); } if ((mode & 0x8) == 0x8) { builder.AppendLine(" Assist: true"); } if ((mode & 0x20) == 0x20) { builder.AppendLine(" NoRandomWalk: true"); } if ((mode & 0x200) == 0x200) { builder.AppendLine(" CastSensorChase: true"); } if ((mode & 0x10) == 0x10) { builder.AppendLine(" CastSensorIdle: true"); } if ((mode & 0x800) == 0x800) { builder.AppendLine(" Angry: true"); } if ((mode & 0x400) == 0x400) { builder.AppendLine(" ChangeChase: true"); } if ((mode & 0x1000) == 0x1000) { builder.AppendLine(" ChangeTargetMelee: true"); } if ((mode & 0x2000) == 0x2000) { builder.AppendLine(" ChangeTargetChase: true"); } if ((mode & 0x4000) == 0x4000) { builder.AppendLine(" TargetWeak: true"); } if ((mode & 0x8000) == 0x8000) { builder.AppendLine(" RandomTarget: true"); } if ((mode & 0x20000) == 0x20000) { builder.AppendLine(" IgnoreMagic: true"); } if ((mode & 0x10000) == 0x10000) { builder.AppendLine(" IgnoreMelee: true"); } if ((mode & 0x100000) == 0x100000) { builder.AppendLine(" IgnoreMisc: true"); } if ((mode & 0x40000) == 0x40000) { builder.AppendLine(" IgnoreRanged: true"); } if ((mode & 0x400000) == 0x400000) { builder.AppendLine(" TeleportBlock: true"); } if ((mode & 0x1000000) == 0x1000000) { builder.AppendLine(" FixedItemDrop: true"); } if ((mode & 0x2000000) == 0x2000000) { builder.AppendLine(" Detector: true"); } if ((mode & 0x200000) == 0x200000) { builder.AppendLine(" KnockBackImmune: true"); } if ((mode & 0x4000000) == 0x4000000) { builder.AppendLine(" StatusImmune: true"); } if ((mode & 0x8000000) == 0x8000000) { builder.AppendLine(" SkillImmune: true"); } if ((mode & 0x80000) == 0x80000) { builder.AppendLine(" Mvp: true"); } } int stat = 0; for (int i = 0; i < 6; i += 2) { stat += tuple.GetIntNoThrow(ServerMobAttributes.Mvp1ID.Index + i); } if (stat != 0) { builder.AppendLine(" MvpDrops:"); for (int i = 0; i < 6; i += 2) { valueS = tuple.GetValue <string>(ServerMobAttributes.Mvp1ID.Index + i); if (stat != 0 && valueS != "0" && valueS != "") { builder.AppendLine(" - Item: " + DbIOUtils.Id2Name(itemDb, ServerItemAttributes.AegisName, valueS)); builder.AppendLine(" Rate: " + tuple.GetValue <int>(ServerMobAttributes.Mvp1ID.Index + i + 1)); if ((valueS = tuple.GetValue <string>(ServerMobAttributes.Mvp1RandomOptionGroup.Index + (i / 2))) != "") { builder.AppendLine(" RandomOptionGroup: " + valueS); } } } } stat = 0; for (int i = 0; i < 20; i += 2) { stat += tuple.GetIntNoThrow(ServerMobAttributes.Drop1ID.Index + i); } if (stat != 0) { builder.AppendLine(" Drops:"); for (int i = 0; i < 20; i += 2) { valueS = tuple.GetValue <string>(ServerMobAttributes.Drop1ID.Index + i); if (stat != 0 && valueS != "0" && valueS != "") { builder.AppendLine(" - Item: " + DbIOUtils.Id2Name(itemDb, ServerItemAttributes.AegisName, valueS)); builder.AppendLine(" Rate: " + tuple.GetValue <int>(ServerMobAttributes.Drop1ID.Index + i + 1)); if ((valueS = tuple.GetValue <string>(ServerMobAttributes.Drop1Flags.Index + (i / 2))) != "" && valueS != null) { if (FormatConverters.BooleanConverter(valueS)) { builder.AppendLine(" StealProtected: true"); } } if ((valueS = tuple.GetValue <string>(ServerMobAttributes.Drop1RandomOptionGroup.Index + (i / 2))) != "") { builder.AppendLine(" RandomOptionGroup: " + valueS); } } } } } }
public static void WriteEntry(StringBuilder builder, ReadableTuple <int> tuple) { if (tuple != null) { string valueS; builder.AppendLine("{"); builder.AppendLine("\tid: " + tuple.GetKey <int>().ToString(CultureInfo.InvariantCulture)); builder.AppendLine("\tgroup: \"" + tuple.GetValue <string>(ServerCheevoAttributes.GroupId) + "\""); builder.AppendLine("\tname: \"" + tuple.GetValue <string>(ServerCheevoAttributes.Name) + "\""); string condition = tuple.GetValue <string>(ServerCheevoAttributes.Condition); if (!String.IsNullOrEmpty(condition)) { builder.AppendLine("\tcondition: \"" + condition.Trim('\t', ' ') + "\""); } if (!String.IsNullOrEmpty(valueS = tuple.GetValue <string>(ServerCheevoAttributes.Dependent))) { builder.AppendLine("\tdependent: [" + valueS.Replace(":", ", ") + "]"); } int rewardId = tuple.GetValue <int>(ServerCheevoAttributes.RewardId); int amountId = tuple.GetValue <int>(ServerCheevoAttributes.RewardAmount); string script = tuple.GetValue <string>(ServerCheevoAttributes.RewardScript); int titleId = tuple.GetValue <int>(ServerCheevoAttributes.RewardTitleId); if (rewardId > 0 || !String.IsNullOrEmpty(script) || titleId > 0) { builder.AppendLine("\treward: ("); builder.AppendLine("\t{"); if (rewardId > 0) { builder.AppendLine("\t\titemid: " + rewardId); } if (amountId > 1) { builder.AppendLine("\t\tamount: " + amountId); } if (!String.IsNullOrEmpty(script)) { builder.AppendLine("\t\tscript: \" " + script.Trim(' ') + " \""); } if (titleId > 0) { builder.AppendLine("\t\ttitleid: " + titleId); } builder.AppendLine("\t}"); builder.AppendLine("\t)"); } int count = 0; for (int i = 0; i < 10; i++) { count += (tuple.GetValue <int>(ServerCheevoAttributes.TargetId1.Index + i) != 0) ? 1 : 0; } if (count > 0) { int total = 0; builder.AppendLine("\ttarget: ("); for (int i = 0; i < 10; i += 2) { int mobId = tuple.GetValue <int>(ServerCheevoAttributes.TargetId1.Index + i); int targetCount = tuple.GetValue <int>(ServerCheevoAttributes.TargetId1.Index + i + 1); if (mobId != 0 || targetCount != 0) { builder.AppendLine("\t{"); if (mobId != 0) { builder.AppendLine("\t\tmobid: " + mobId); total++; } if (targetCount != 0) { builder.AppendLine("\t\tcount: " + targetCount); total++; } builder.AppendLine(total != count ? "\t}," : "\t}"); } } builder.AppendLine("\t)"); } builder.AppendLine("\tscore: " + tuple.GetValue <int>(ServerCheevoAttributes.Score)); builder.Append("},"); } }
public static void WriteEntry(StringBuilder builder, ReadableTuple <int> tuple) { if (tuple != null) { string valueS; builder.AppendLine("{"); builder.AppendLine("\tid: " + tuple.GetKey <int>().ToString(CultureInfo.InvariantCulture)); builder.AppendLine("\tgroup: \"" + tuple.GetValue <string>(ServerCheevoAttributes.GroupId) + "\""); builder.AppendLine("\tname: \"" + tuple.GetValue <string>(ServerCheevoAttributes.Name) + "\""); int count = 0; for (int i = 0; i < 5; i++) { count += String.IsNullOrEmpty(tuple.GetValue <string>(ServerCheevoAttributes.Parameter1.Index + i)) ? 0 : 1; } int paramsRequired = String.IsNullOrEmpty(tuple.GetValue <string>(ServerCheevoAttributes.ParamsRequired)) ? count : tuple.GetValue <int>(ServerCheevoAttributes.ParamsRequired); if (paramsRequired != count) { builder.AppendLine("\tparams_required: " + paramsRequired); } if (count > 0) { int total = 0; builder.AppendLine("\tparameter: ("); for (int i = 0; i < 5; i++) { if (!String.IsNullOrEmpty(valueS = tuple.GetValue <string>(ServerCheevoAttributes.Parameter1.Index + i))) { total++; builder.AppendLine("\t{"); string[] values = null; string op = null; string[] operators = { "==", ">=", "<=", ">", "<", "&" }; foreach (var ope in operators) { if (valueS.Contains(op = ope)) { values = valueS.Split(new string[] { op }, StringSplitOptions.None); break; } } if (values == null || values.Length != 2) { throw new Exception("Invalid parameter: " + i + " for the achievement ID " + tuple.Key); } builder.AppendLine("\t\tparam: \"" + values[0] + "\""); int id; if (Int32.TryParse(values[1], out id)) { builder.AppendLine("\t\tvalue: " + values[1]); } else { builder.AppendLine("\t\tvalue: \"" + values[1] + "\""); } builder.AppendLine("\t\toperator: \"" + op + "\""); builder.AppendLine(total != count ? "\t}," : "\t}"); } } builder.AppendLine("\t)"); } if (!String.IsNullOrEmpty(valueS = tuple.GetValue <string>(ServerCheevoAttributes.Dependent))) { builder.AppendLine("\tdependent: [" + valueS.Replace(":", ", ") + "]"); } int rewardId = tuple.GetValue <int>(ServerCheevoAttributes.RewardId); int amountId = tuple.GetValue <int>(ServerCheevoAttributes.RewardAmount); string script = tuple.GetValue <string>(ServerCheevoAttributes.RewardScript); int titleId = tuple.GetValue <int>(ServerCheevoAttributes.RewardTitleId); if (rewardId > 0 || !String.IsNullOrEmpty(script) || titleId > 0) { builder.AppendLine("\treward: ("); builder.AppendLine("\t{"); if (rewardId > 0) { builder.AppendLine("\t\titemid: " + rewardId); } if (amountId > 1) { builder.AppendLine("\t\tamount: " + amountId); } if (!String.IsNullOrEmpty(script)) { builder.AppendLine("\t\tscript: \" " + script.Trim(' ') + " \""); } if (titleId > 0) { builder.AppendLine("\t\ttitleid: " + titleId); } builder.AppendLine("\t}"); builder.AppendLine("\t)"); } count = 0; for (int i = 0; i < 10; i++) { count += (tuple.GetValue <int>(ServerCheevoAttributes.TargetId1.Index + i) != 0) ? 1 : 0; } if (count > 0) { int total = 0; builder.AppendLine("\ttarget: ("); for (int i = 0; i < 10; i += 2) { int mobId = tuple.GetValue <int>(ServerCheevoAttributes.TargetId1.Index + i); int targetCount = tuple.GetValue <int>(ServerCheevoAttributes.TargetId1.Index + i + 1); if (mobId != 0 || targetCount != 0) { builder.AppendLine("\t{"); if (mobId != 0) { builder.AppendLine("\t\tmobid: " + mobId); total++; } if (targetCount != 0) { builder.AppendLine("\t\tcount: " + targetCount); total++; } builder.AppendLine(total != count ? "\t}," : "\t}"); } } builder.AppendLine("\t)"); } builder.AppendLine("\tscore: " + tuple.GetValue <int>(ServerCheevoAttributes.Score)); builder.Append("},"); } }
public static void WriteEntryYaml(StringBuilder builder, ReadableTuple <int> tuple) { if (tuple != null) { string valueS; builder.AppendLine(" - Id: " + tuple.GetKey <int>().ToString(CultureInfo.InvariantCulture)); builder.AppendLine(" Group: \"" + tuple.GetValue <string>(ServerCheevoAttributes.GroupId) + "\""); builder.AppendLine(" Name: \"" + tuple.GetValue <string>(ServerCheevoAttributes.Name) + "\""); if (tuple.GetValue <string>(ServerCheevoAttributes.Map) != "") { builder.Append(" Map: \"" + tuple.GetValue <string>(ServerCheevoAttributes.Map) + "\""); } string condition = tuple.GetValue <string>(ServerCheevoAttributes.Condition); if (!String.IsNullOrEmpty(condition)) { builder.AppendLine(" Condition: \"" + condition.Trim('\t', ' ') + "\""); } if (!String.IsNullOrEmpty(valueS = tuple.GetValue <string>(ServerCheevoAttributes.Dependent))) { builder.AppendLine(" Dependent: [" + valueS.Replace(":", ", ") + "]"); } int rewardId = tuple.GetValue <int>(ServerCheevoAttributes.RewardId); int amountId = tuple.GetValue <int>(ServerCheevoAttributes.RewardAmount); string script = tuple.GetValue <string>(ServerCheevoAttributes.RewardScript); int titleId = tuple.GetValue <int>(ServerCheevoAttributes.RewardTitleId); if (rewardId > 0 || !String.IsNullOrEmpty(script) || titleId > 0) { builder.AppendLine(" Reward:"); if (rewardId > 0) { builder.AppendLine(" ItemID: " + rewardId); } if (amountId > 1) { builder.AppendLine(" Amount: " + amountId); } if (!String.IsNullOrEmpty(script)) { builder.AppendLine(" Script: \" " + script.Trim(' ') + " \""); } if (titleId > 0) { builder.AppendLine(" TitleID: " + titleId); } } int count = 0; for (int i = 0; i < 10; i++) { count += (tuple.GetValue <int>(ServerCheevoAttributes.TargetId1.Index + i) != 0) ? 1 : 0; } if (count > 0) { builder.AppendLine(" Target:"); for (int i = 0; i < 10; i += 2) { int mobId = tuple.GetValue <int>(ServerCheevoAttributes.TargetId1.Index + i); int targetCount = tuple.GetValue <int>(ServerCheevoAttributes.TargetId1.Index + i + 1); if (mobId != 0 || targetCount != 0) { bool addedList = false; if (mobId != 0) { builder.AppendLine(" - MobID: " + mobId); addedList = true; } if (targetCount != 0) { if (!addedList) { builder.AppendLine(" - Count: " + targetCount); } else { builder.AppendLine(" Count: " + targetCount); } } } } } builder.Append(" Score: " + tuple.GetValue <int>(ServerCheevoAttributes.Score)); } }
public override void ImportFromFile(string fileDefault = null, bool autoIncrement = false) { try { string file = fileDefault ?? PathRequest.OpenFileCde("filter", "All db files|*.conf;*.txt"); if (file == "clipboard") { if (!Clipboard.ContainsText()) { return; } file = TemporaryFilesManager.GetTemporaryFilePath("clipboard_{0:0000}.txt"); File.WriteAllText(file, Clipboard.GetText()); } if (file != null) { try { Table.Commands.Begin(); ProjectDatabase.GetDb <TKey>(Settings.DbData).LoadFromClipboard(file); } catch { Table.Commands.CancelEdit(); } finally { Table.Commands.EndEdit(); if (autoIncrement && typeof(TKey) == typeof(int)) { var cmds = Table.Commands.GetUndoCommands(); if (cmds.Count > 0) { var lastCmd = cmds.Last() as GroupCommand <TKey, TValue>; if (lastCmd != null) { if (lastCmd.Commands.Count > 0 && lastCmd.Commands.OfType <ChangeTupleProperties <TKey, TValue> >().Count() == 1) { var firstKey = lastCmd.Commands.First().Key; var tuple = new ReadableTuple <TKey>(firstKey, Table.AttributeList); var oldTuple = (ReadableTuple <TKey>)(object) Table.TryGetTuple(firstKey); tuple.Copy(oldTuple); tuple.Added = true; ProjectDatabase.Commands.Undo(); Table.Commands.AddTuple(tuple.GetKey <TKey>(), (TValue)(object)tuple, false, true, null); } } } } } _listView_SelectionChanged(this, null); } } catch (Exception err) { ErrorHandler.HandleException(err); } }
public static void WriteEntryYaml(StringBuilder builder, ReadableTuple <int> tuple, MetaTable <int> itemDb) { if (tuple != null) { int value; bool valueB; string valueS; builder.AppendLine(" - Id: " + tuple.GetKey <int>().ToString(CultureInfo.InvariantCulture)); if ((valueS = tuple.GetValue <string>(ServerSkillAttributes.Name)) != "") { builder.AppendLine(" Name: " + DbIOUtils.QuoteCheck(valueS)); } if ((valueS = tuple.GetValue <string>(ServerSkillAttributes.Desc)) != "") { builder.AppendLine(" Description: " + DbIOUtils.QuoteCheck(valueS)); } builder.AppendLine(" MaxLevel: " + tuple.GetValue <int>(ServerSkillAttributes.MaxLevel)); if ((value = tuple.GetValue <int>(ServerSkillAttributes.AttackType)) != 0) { builder.AppendLine(" Type: " + Constants.ToString <AttackTypeType>(value)); } if ((value = tuple.GetValue <int>(ServerSkillAttributes.SkillTargetType)) != 0) { builder.AppendLine(" TargetType: " + Constants.ToString <SkillTargetType>(value)); } DbIOUtils.ExpandFlag <SkillDamageType>(builder, tuple, "DamageFlags", ServerSkillAttributes.DamageFlags, YamlParser.Indent4, YamlParser.Indent6); DbIOUtils.ExpandFlag <SkillType2TypeNew>(builder, tuple, "Flags", ServerSkillAttributes.Inf2New, YamlParser.Indent4, YamlParser.Indent6); _expandList(builder, tuple, "Range", " - Level", "Size", ServerSkillAttributes.Range, YamlParser.Indent4, YamlParser.Indent8, "0", itemDb); if ((value = tuple.GetValue <int>(ServerSkillAttributes.HitMode)) != 0) { builder.AppendLine(" Hit: " + Constants.ToString <HitType>(value)); } _expandList(builder, tuple, "HitCount", " - Level", "Count", ServerSkillAttributes.HitCount, YamlParser.Indent4, YamlParser.Indent8, "0", itemDb); _expandList(builder, tuple, "Element", " - Level", "Element", ServerSkillAttributes.SkillElement, YamlParser.Indent4, YamlParser.Indent8, "Neutral", itemDb); _expandList(builder, tuple, "SplashArea", " - Level", "Area", ServerSkillAttributes.SplashArea, YamlParser.Indent4, YamlParser.Indent8, "0", itemDb); _expandList(builder, tuple, "ActiveInstance", " - Level", "Max", ServerSkillAttributes.ActiveInstance, YamlParser.Indent4, YamlParser.Indent8, "0", itemDb); _expandList(builder, tuple, "Knockback", " - Level", "Amount", ServerSkillAttributes.Knockback, YamlParser.Indent4, YamlParser.Indent8, "0", itemDb); if (tuple.GetValue <int>(ServerSkillAttributes.CopyFlags) > 0 || tuple.GetValue <int>(ServerSkillAttributes.CopyFlagsRemovedRequirement) > 0) { builder.AppendLine(" CopyFlags:"); DbIOUtils.ExpandFlag <SkillCopyType>(builder, tuple, "Skill", ServerSkillAttributes.CopyFlags, YamlParser.Indent6, YamlParser.Indent8); DbIOUtils.ExpandFlag <SkillCopyRemoveRequirementType>(builder, tuple, "RemoveRequirement", ServerSkillAttributes.CopyFlagsRemovedRequirement, YamlParser.Indent6, YamlParser.Indent8); } if (tuple.GetValue <int>(ServerSkillAttributes.NoNearNPCRange) > 0 || tuple.GetValue <int>(ServerSkillAttributes.NoNearNPCType) > 0) { builder.AppendLine(" NoNearNPC:"); if ((value = tuple.GetValue <int>(ServerSkillAttributes.NoNearNPCRange)) != 0) { builder.AppendLine(" AdditionalRange: " + value); } DbIOUtils.ExpandFlag <NoNearNpcType>(builder, tuple, "Type", ServerSkillAttributes.NoNearNPCType, YamlParser.Indent6, YamlParser.Indent8); } if ((valueB = tuple.GetValue <bool>(ServerSkillAttributes.CastInterrupt)) != false) { builder.AppendLine(" CastCancel: " + (valueB ? "true" : "false")); } if ((value = tuple.GetValue <int>(ServerSkillAttributes.CastDefenseReduction)) != 0) { builder.AppendLine(" CastDefenseReduction: " + value); } _expandList(builder, tuple, "CastTime", " - Level", "Time", ServerSkillAttributes.CastingTime, YamlParser.Indent4, YamlParser.Indent8, "0", itemDb); _expandList(builder, tuple, "AfterCastActDelay", " - Level", "Time", ServerSkillAttributes.AfterCastActDelay, YamlParser.Indent4, YamlParser.Indent8, "0", itemDb); _expandList(builder, tuple, "AfterCastWalkDelay", " - Level", "Time", ServerSkillAttributes.AfterCastWalkDelay, YamlParser.Indent4, YamlParser.Indent8, "0", itemDb); _expandList(builder, tuple, "Duration1", " - Level", "Time", ServerSkillAttributes.Duration1, YamlParser.Indent4, YamlParser.Indent8, "0", itemDb); _expandList(builder, tuple, "Duration2", " - Level", "Time", ServerSkillAttributes.Duration2, YamlParser.Indent4, YamlParser.Indent8, "0", itemDb); _expandList(builder, tuple, "Cooldown", " - Level", "Time", ServerSkillAttributes.Cooldown, YamlParser.Indent4, YamlParser.Indent8, "0", itemDb); _expandList(builder, tuple, "FixedCastTime", " - Level", "Time", ServerSkillAttributes.FixedCastTime, YamlParser.Indent4, YamlParser.Indent8, "0", itemDb); DbIOUtils.ExpandFlag <CastingFlags>(builder, tuple, "CastTimeFlags", ServerSkillAttributes.CastTimeFlags, YamlParser.Indent4, YamlParser.Indent6); DbIOUtils.ExpandFlag <CastingFlags>(builder, tuple, "CastDelayFlags", ServerSkillAttributes.CastDelayFlags, YamlParser.Indent4, YamlParser.Indent6); StringBuilder require = new StringBuilder(); _expandList(require, tuple, "HpCost", " - Level", "Amount", ServerSkillAttributes.RequireHpCost, YamlParser.Indent6, YamlParser.Indent10, "0", itemDb); _expandList(require, tuple, "SpCost", " - Level", "Amount", ServerSkillAttributes.RequireSpCost, YamlParser.Indent6, YamlParser.Indent10, "0", itemDb); _expandList(require, tuple, "HpRateCost", " - Level", "Amount", ServerSkillAttributes.RequireHpRateCost, YamlParser.Indent6, YamlParser.Indent10, "0", itemDb); _expandList(require, tuple, "SpRateCost", " - Level", "Amount", ServerSkillAttributes.RequireSpRateCost, YamlParser.Indent6, YamlParser.Indent10, "0", itemDb); _expandList(require, tuple, "MaxHpTrigger", " - Level", "Amount", ServerSkillAttributes.RequireMaxHpTrigger, YamlParser.Indent6, YamlParser.Indent10, "0", itemDb); _expandList(require, tuple, "ZenyCost", " - Level", "Amount", ServerSkillAttributes.RequireZenyCost, YamlParser.Indent6, YamlParser.Indent10, "0", itemDb); value = tuple.GetValue <int>(ServerSkillAttributes.RequireWeapons); if (value != 0xFFFFFF) { DbIOUtils.ExpandFlag <WeaponType>(require, tuple, "Weapon", ServerSkillAttributes.RequireWeapons, YamlParser.Indent6, YamlParser.Indent8); } DbIOUtils.ExpandFlag <AmmoType>(require, tuple, "Ammo", ServerSkillAttributes.RequireAmmoTypes, YamlParser.Indent6, YamlParser.Indent8); _expandList(require, tuple, "AmmoAmount", " - Level", "Amount", ServerSkillAttributes.RequireAmmoAmount, YamlParser.Indent6, YamlParser.Indent10, "0", itemDb); if ((value = tuple.GetValue <int>(ServerSkillAttributes.RequireState)) > 0) { valueS = ""; switch ((RequiredStateTypeNew)value) { case RequiredStateTypeNew.Hidden: valueS = "Hidden"; break; case RequiredStateTypeNew.Riding: valueS = "Riding"; break; case RequiredStateTypeNew.Falcon: valueS = "Falcon"; break; case RequiredStateTypeNew.Cart: valueS = "Cart"; break; case RequiredStateTypeNew.Shield: valueS = "Shield"; break; case RequiredStateTypeNew.RecoverWeightRate: valueS = "Recover_Weight_Rate"; break; case RequiredStateTypeNew.MoveEnable: valueS = "Move_Enable"; break; case RequiredStateTypeNew.Water: valueS = "Water"; break; case RequiredStateTypeNew.RidingDragon: valueS = "Ridingdragon"; break; case RequiredStateTypeNew.Warg: valueS = "Wug"; break; case RequiredStateTypeNew.Ridingwarg: valueS = "Ridingwug"; break; case RequiredStateTypeNew.Mado: valueS = "Mado"; break; case RequiredStateTypeNew.Elementalspirit: valueS = "Elementalspirit"; break; case RequiredStateTypeNew.Elementalspirit2: valueS = "Elementalspirit2"; break; case RequiredStateTypeNew.RidingPeco: valueS = "Peco"; break; case RequiredStateTypeNew.SunStance: valueS = "Sunstance"; break; case RequiredStateTypeNew.MoonStance: valueS = "Moonstance"; break; case RequiredStateTypeNew.StarsStance: valueS = "Starstance"; break; case RequiredStateTypeNew.UniverseStance: valueS = "Universestance"; break; default: valueS = ""; break; } require.Append(" State: "); require.AppendLine(valueS); } if ((valueS = tuple.GetValue <string>(ServerSkillAttributes.RequireStatuses)) != "" && valueS != "0") { var data = valueS.Split(':'); if (data.Length > 0) { require.AppendLine(" Status:"); foreach (var da in data) { require.Append(" "); require.Append(da); require.AppendLine(": true"); } } } //_DbIOUtils.ExpandFlag<AmmoType>(require, tuple, "Status", ServerSkillAttributes.RequireStatuses, YamlParser2.Indent6, YamlParser2.Indent8); _expandList(require, tuple, "SpiritSphereCost", " - Level", "Amount", ServerSkillAttributes.RequireSpiritSphereCost, YamlParser.Indent6, YamlParser.Indent10, "0", itemDb); _expandList(require, tuple, "ItemCost", " - Item", "Amount", ServerSkillAttributes.RequireItemCost, YamlParser.Indent6, YamlParser.Indent10, "0", itemDb); if ((valueS = tuple.GetValue <string>(ServerSkillAttributes.RequiredEquipment)) != "" && valueS != "0") { var data = valueS.Split(':'); require.AppendLine(" Equipment:"); foreach (var item in data) { require.Append(" "); require.Append(DbIOUtils.Id2Name(itemDb, ServerItemAttributes.AegisName, item)); require.AppendLine(": true"); } } //_expandList(require, tuple, "Equipment", "", "", ServerSkillAttributes.RequiredEquipment, YamlParser2.Indent6, YamlParser2.Indent8, "", itemDb); string requireData = require.ToString(); if (requireData != "") { builder.AppendLine(" Requires:"); builder.Append(requireData); } StringBuilder unit = new StringBuilder(); if ((valueS = tuple.GetValue <string>(ServerSkillAttributes.UnitId)) != "" && valueS != "0") { unit.Append(" Id: "); unit.AppendLine(valueS); } if ((valueS = tuple.GetValue <string>(ServerSkillAttributes.UnitAlternateId)) != "" && valueS != "0") { unit.Append(" AlternateId: "); unit.AppendLine(valueS); } _expandList(unit, tuple, "Layout", " - Level", "Size", ServerSkillAttributes.UnitLayout, YamlParser.Indent6, YamlParser.Indent10, "0", itemDb); _expandList(unit, tuple, "Range", " - Level", "Size", ServerSkillAttributes.UnitRange, YamlParser.Indent6, YamlParser.Indent10, "0", itemDb); if ((value = tuple.GetValue <int>(ServerSkillAttributes.UnitInterval)) != 0) { unit.Append(" Interval: "); unit.AppendLine(value.ToString(CultureInfo.InvariantCulture)); } if ((value = tuple.GetValue <int>(ServerSkillAttributes.UnitTarget)) != 0x3F0000) { unit.Append(" Target: "); var flag = FlagsManager.GetFlag <UnitTargetType>(); valueS = flag.Value2Name[value]; unit.AppendLine(valueS); } DbIOUtils.ExpandFlag <UnitFlagType>(unit, tuple, "Flag", ServerSkillAttributes.UnitFlag, YamlParser.Indent6, YamlParser.Indent8); string unitData = unit.ToString(); if (unitData != "") { builder.AppendLine(" Unit:"); builder.Append(unit); } } }