private static void ParseNpc(string[] parts, StringBuilder sb, WorldProvider provider) { // Name,Mobile Type,Level,Gender,Race,AttrMin,AttrMax,CanAttack,Currency,SkillGroup, // Markup,Markdown,Droppable Items,OnEnterMsg,Keywords,Responses if (parts != null && parts.Length > 0) { string name = parts[0]; string type = parts[1]; string level = parts[2]; string gender = parts[3]; string race = parts[4]; string attrMin = parts[5]; string attrMax = parts[6]; string canAttack = parts[7]; string currency = parts[8]; string skillGroup = parts[9]; string markup = parts[10]; string markdown = parts[11]; string drpItems = parts[12]; string onEnterMsg = parts[13]; string keywords = parts[14]; string responses = parts[15]; string formattedName = FormatName(name); List <string> dropItems = new List <string>(); if (!String.IsNullOrEmpty(drpItems.Replace("\"", "").Trim())) { dropItems.AddRange(drpItems.Replace("\"", "").Split(',').Select(i => i.Trim())); } Type t = Type.GetType(String.Concat("Perenthia.", type)); Npc npc = provider.GetTemplate(t, name) as Npc; if (npc == null) { npc = Activator.CreateInstance(t) as Npc; } npc.Properties.IsTemplateCollection = true; npc.World = provider.World; npc.TemplateID = 0; npc.Name = name; npc.Level = Convert.ToInt32(level); npc.AttributeMinimum = Convert.ToInt32(attrMin); npc.AttributeMaximum = Convert.ToInt32(attrMax); npc.MobileType = (MobileTypes)Enum.Parse(typeof(MobileTypes), type, true); npc.Skills.AddRange(GetSkillGroup(skillGroup).Skills); npc.GenerateStats(); foreach (var item in dropItems) { npc.AddDroppableItem(item); } //sb.AppendFormat("\t\t#region {0}", formattedName).AppendLine(); //sb.AppendFormat("\t\tpublic static Npc {0}", formattedName).AppendLine(); //sb.Append("\t\t{").AppendLine(); //sb.Append("\t\t\tget").AppendLine().Append("\t\t\t{ ").AppendLine(); //sb.AppendFormat("\t\t\t\treturn new Npc(\"{0}\", \"{1}\", {2}, {3}, {4}, MobileTypes.{5}, new {6}SkillGroup())", // name, String.Empty, level, attrMin, attrMax, type, skillGroup).AppendLine(); //sb.Append("\t\t\t\t{ ").AppendLine(); // Default properties not in constructor. //int propCount = 0; if (!String.IsNullOrEmpty(gender)) { npc.Gender = (Gender)Enum.Parse(typeof(Gender), gender, true); //sb.AppendFormat("\t\t\t\t\tGender = Gender.{0}", gender); //propCount++; } if (!String.IsNullOrEmpty(race.Trim())) { npc.Race = race; //if (propCount > 0) sb.Append(",").AppendLine(); //sb.AppendFormat("\t\t\t\t\tRace = {0}Race.RaceName", race.Trim()); //propCount++; } if (!String.IsNullOrEmpty(currency)) { npc.Currency = new Currency(Convert.ToInt32(currency)); //if (propCount > 0) sb.Append(",").AppendLine(); //sb.AppendFormat("\t\t\t\t\tCurrency = new Currency({0})", currency); //propCount++; } if (!String.IsNullOrEmpty(canAttack)) { npc.CanAttack = false; //if (propCount > 0) sb.Append(",").AppendLine(); //sb.AppendFormat("\t\t\t\t\tCanAttack = {0}", canAttack.ToLower()); //propCount++; } if (!String.IsNullOrEmpty(markup)) { npc.MarkupPercentage = Convert.ToDouble(markup); //if (propCount > 0) sb.Append(",").AppendLine(); //sb.AppendFormat("\t\t\t\t\tMarkupPercentage = {0}", markup); //propCount++; } if (!String.IsNullOrEmpty(markdown)) { npc.MarkdownPercentage = Convert.ToDouble(markdown); //if (propCount > 0) sb.Append(",").AppendLine(); //sb.AppendFormat("\t\t\t\t\tMarkdownPercentage = {0}", markdown); //propCount++; } if (!String.IsNullOrEmpty(onEnterMsg)) { npc.OnEnterMessage = onEnterMsg.Replace("\"", ""); //if (propCount > 0) sb.Append(",").AppendLine(); //sb.AppendFormat("\t\t\t\t\tOnEnterMessage = \"{0}\"", onEnterMsg); //propCount++; } //sb.AppendLine().Append("\t\t\t\t};").AppendLine(); //sb.Append("\t\t\t}").AppendLine(); //sb.Append("\t\t}").AppendLine(); //sb.Append("\t\t#endregion").AppendLine().AppendLine(); provider.SaveActor <Npc>(npc); } }