public static List<FOCommon.Worldmap.EncounterGroup.EncounterGroup> LoadNew(List<string> lines)
        {
            List<FOCommon.Worldmap.EncounterGroup.EncounterGroup> Groups = new List<FOCommon.Worldmap.EncounterGroup.EncounterGroup>();

            int groupId = 0;
            EncounterGroup Group = null;
            foreach (string line in lines)
            {

                if (line.StartsWith("*")) // Npc data
                {
                    string[] parts = line.Split('|');
                    string[] param = parts[0].Split(',');

                    EncounterNpc NpcObj = new EncounterNpc(Int32.Parse(param[1]), Int32.Parse(param[2]), param[3], Int32.Parse(param[4]), param[5] == "1" ? true : false,
                        Int32.Parse(param[6]), Int32.Parse(param[7]), Int32.Parse(param[8]));

                    for (int i = 1; i < parts.Length; i++)
                    {
                        string[] npcData = parts[i].Split(',');
                        if (Int32.Parse(npcData[0]) == (int)GroupFormatData.Item)
                        {
                            EncounterItem item = new EncounterItem(Int32.Parse(npcData[1]), Int32.Parse(npcData[2]), Int32.Parse(npcData[3]), Int32.Parse(npcData[4]));
                            NpcObj.AddItem(item);
                        }
                        else if (Int32.Parse(npcData[0]) == (int)GroupFormatData.Perk)
                        {
                            EncounterPerk perk = new EncounterPerk(npcData[1], Int32.Parse(npcData[2]), Int32.Parse(npcData[3]), Int32.Parse(npcData[4]));
                            NpcObj.Perks.Add(perk);
                        }
                    }
                    Group.Npcs.Add(NpcObj);
                }
                else // Group data
                {
                    if (String.IsNullOrEmpty(line) || line.Length < 5)
                        continue;

                    string[] param = line.Split(',');

                    float quantityDay = (float)double.Parse(param[7], NumberStyles.Any, ci);
                    float quantityNight = (float)double.Parse(param[8], NumberStyles.Any, ci);

                    Group = new FOCommon.Worldmap.EncounterGroup.EncounterGroup(param[0], Int32.Parse(param[1]), Int32.Parse(param[2]),
                          Int32.Parse(param[3]), Int32.Parse(param[4]), Int32.Parse(param[5]), Int32.Parse(param[6]), quantityDay, quantityNight, Int32.Parse(param[9]), Int32.Parse(param[10]));

                    if (Group != null)
                    {
                        Group.Id = groupId++;
                        Groups.Add(Group);
                    }
                }
            }

            return Groups;
        }
        private void lstNpcs_SelectionChanged(object sender, EventArgs e)
        {
            EncounterNpc Npc = (EncounterNpc)lstNpcs.SelectedObject;
            if (Npc == null)
                return;

            if (CurrentNpc == Npc)
                return;

            if (CurrentNpc != null)
                SaveCurrentNpc();

            CurrentNpc = Npc;
            RefreshItems();
            RefreshArmor();
            RefreshPerks();

            numDialog.Value = Npc.Dialog.Id;
            cmbScript.Text = Npc.Script;
            numProto.Value = Npc.Proto.Id;
            numNpcRatio.Value = Npc.Ratio;
            chkDead.Checked = Npc.Dead;
        }
 private void btnAddNpc_Click(object sender, EventArgs e)
 {
     EncounterNpc Npc = new EncounterNpc(Decimal.ToInt32(numProto.Value), Decimal.ToInt32(numDialog.Value), cmbScript.Text, Decimal.ToInt32(numNpcRatio.Value), chkDead.Checked,
         GetArmorPid(), GetHelmPid(), GetForcedCrType());
     if (lstNpcItems.Items.Count > 0)
     {
         foreach (Object o in lstNpcItems.Objects)
         {
             EncounterItem item = (EncounterItem)o;
             Npc.AddItem(item);
         }
     }
     CurrentGroup.Npcs.Add(Npc);
     CurrentGroup.NpcCount++;
     RefreshNpcList();
 }
        public static List<FOCommon.Worldmap.EncounterGroup.EncounterGroup> LoadOld(List<string> lines)
        {
            List<FOCommon.Worldmap.EncounterGroup.EncounterGroup> Groups = new List<FOCommon.Worldmap.EncounterGroup.EncounterGroup>();
            int groupId = 0;

            foreach (string line in lines)
            {
                string[] partsdel = { "|||" };
                string[] npcsdel = { "||" };
                string[] parts = line.Split(partsdel, StringSplitOptions.RemoveEmptyEntries);

                string[] npcs;
                if (parts.Length == 2)
                    npcs = parts[1].Split(npcsdel, StringSplitOptions.RemoveEmptyEntries);
                else
                    npcs = new string[0];

                string[] param = parts[0].Split(',');

                float quantityDay = (float)double.Parse(param[7], NumberStyles.Any, ci);
                float quantityNight = (float)double.Parse(param[8], NumberStyles.Any, ci);

                FOCommon.Worldmap.EncounterGroup.EncounterGroup Group = new FOCommon.Worldmap.EncounterGroup.EncounterGroup(param[0], Int32.Parse(param[1]), Int32.Parse(param[2]),
                      Int32.Parse(param[3]), Int32.Parse(param[4]), Int32.Parse(param[5]), Int32.Parse(param[6]), quantityDay, quantityNight, Int32.Parse(param[9]), Int32.Parse(param[10]));

                Group.Id = groupId++;

                foreach (string npc in npcs)
                {
                    string[] npcparts = npc.Split('|');
                    string[] npcparams = npcparts[0].Split(',');

                    // Convert
                    EncounterNpc NpcObj = new EncounterNpc(Int32.Parse(npcparams[0]), Int32.Parse(npcparams[1]), npcparams[2], Int32.Parse(npcparams[3]),npcparams[4] == "1" ? true : false,
                        -1, -1, -1);

                    for (int i = 1; i < npcparts.Length; i++)
                    {
                        string[] itemparam = npcparts[i].Split(',');
                        EncounterItem item = new EncounterItem(Int32.Parse(itemparam[0]), Int32.Parse(itemparam[1]), Int32.Parse(itemparam[2]), Int32.Parse(itemparam[3]));
                        NpcObj.AddItem(item);
                    }

                    Group.Npcs.Add(NpcObj);
                }
                Groups.Add(Group);
            }
            return Groups;
        }