Ejemplo n.º 1
0
 public PartyTemplate(string[] raw_data) : base(raw_data[0], ObjectType.PartyTemplate)
 {
     Name    = raw_data[1];
     FlagsGZ = ulong.Parse(raw_data[2]);
     SetFlagsString();
     MenuID      = int.Parse(raw_data[3]);
     FactionID   = int.Parse(raw_data[4]);
     Faction     = CodeReader.Factions[FactionID];
     Personality = int.Parse(raw_data[5]);
     for (int i = 0; i < Members.Length; i++)
     {
         Members[i] = PMember.DEFAULT_MEMBER;
     }
     for (int i = 0; i < Members.Length; i++)
     {
         if (!raw_data[(i * 4) + 6].Equals("-1"))
         {
             Members[i] = new PMember(CodeReader.GetStringArrayStartFromIndex(raw_data, (i * 4) + 6));
         }
         else
         {
             i = Members.Length;
         }
     }
 }
Ejemplo n.º 2
0
 public Party(string[] raw_data) : base(raw_data[3].Substring(2), ObjectType.Party)
 {
     Name    = raw_data[4];
     FlagsGZ = ulong.Parse(raw_data[5]);
     SetFlagsString();
     MenuID                = int.Parse(raw_data[6]);
     PartyTemplateID       = int.Parse(raw_data[7]);
     PartyTemplate         = CodeReader.PartyTemplates[PartyTemplateID];
     FactionID             = int.Parse(raw_data[8]);
     Faction               = CodeReader.Factions[FactionID];
     Personality           = int.Parse(raw_data[9]);  //was ulong before
     AIBehavior            = int.Parse(raw_data[11]); //was ulong before
     AITargetParty         = int.Parse(raw_data[12]); //was ulong before
     InitialCoordinates[0] = Math.Round(double.Parse(CodeReader.Repl_DotWComma(raw_data[14])), 6);
     InitialCoordinates[1] = Math.Round(double.Parse(CodeReader.Repl_DotWComma(raw_data[15])), 6);
     Members               = new PMember[int.Parse(raw_data[21])];
     for (int i = 0; i < Members.Length; i++)
     {
         Members[i] = new PMember(new string[] { raw_data[(i * 4) + 22], raw_data[(i * 4) + 23], raw_data[(i * 4) + 24], raw_data[(i * 4) + 25] });
     }
     PartyDirectionInDegrees = Math.Round(double.Parse(CodeReader.Repl_DotWComma(raw_data[raw_data.Length - 1])), 6);//this.degrees = degrees;
 }
Ejemplo n.º 3
0
        public Party(string[] source_data, bool hasDegree) : base(source_data[0], ObjectType.Party)
        {
            int curIdx = 0;

            Name = source_data[curIdx++];

            Flags = source_data[curIdx++];
            SetFlagsGZ();

            Menu = source_data[curIdx++];
            if (Menu.Equals("no_menu"))
            {
                MenuID = 0;
            }
            else
            {
                MenuID = CodeReader.GameMenus.IndexOf(Menu);
            }

            PartyTemplate   = source_data[curIdx++];
            PartyTemplateID = CodeReader.PartyTemplates.IndexOf(PartyTemplate);

            //faction = source_data[curIdx++];
            //if (faction.Equals("no_faction"))
            //    factionID = -1;
            //else
            FactionID = CodeReader.Factions.IndexOf(source_data[curIdx++]);

            string tmpS = source_data[curIdx++].Replace("soldier_personality", "aggressiveness_8|courage_9");

            tmpS = tmpS.Replace("merchant_personality", "aggressiveness_0|courage_7");
            tmpS = tmpS.Replace("escorted_merchant_personality", "aggressiveness_0|courage_11");
            tmpS = tmpS.Replace("bandit_personality", "aggressiveness_3|courage_8|banditness");

            int x = 0;

            string[] tmp = tmpS.Split('|');
            string[] tmp2;
            foreach (string s in tmp)
            {
                tmp2 = s.Trim().Split('_');
                if (tmp2[0].Equals("courage"))
                {
                    x |= int.Parse(tmp2[1]);
                }
                else if (tmp2[0].Equals("aggressiveness"))
                {
                    x |= int.Parse(tmp2[1]) << 4;
                }
                else if (tmp2[0].Equals("banditness"))
                {
                    x |= 0x0100;
                }
            }
            Personality = x;

            x   = 0;
            tmp = source_data[curIdx++].Split('|');
            foreach (string s in tmp)
            {
                for (int i = 0; i < AiBehaviors.Length; i++)
                {
                    if (AiBehaviors[i].Equals(s))
                    {
                        x |= i;
                        i  = AiBehaviors.Length;
                    }
                }
            }
            AIBehavior = x;

            tmp = new string[] { source_data[curIdx++] };
            x   = CodeReader.Parties.IndexOf(tmp[0]);
            if (x < 0)
            {
                x = 0;
            }
            AITargetParty = x;

            InitialCoordinates[0] = Math.Round(double.Parse(CodeReader.Repl_DotWComma(source_data[curIdx++].TrimStart('(', ' '))), 6);
            InitialCoordinates[1] = Math.Round(double.Parse(CodeReader.Repl_DotWComma(source_data[curIdx++].TrimEnd(')', ' '))), 6);

            x = 0;
            if (hasDegree)
            {
                x++;
            }
            x = (source_data.Length - (11 + x)) / 3;

            Members = new PMember[x];
            for (int i = 0; i < x; i++)
            {
                curIdx = 11 + i * 3;
                if (!ImportantMethods.IsNumericGZ(source_data[curIdx]))
                {
                    source_data[curIdx] = CodeReader.Troops.IndexOf(source_data[curIdx]).ToString();
                }
                curIdx += 2;
                if (source_data[curIdx].Equals("pmf_is_prisoner"))
                {
                    source_data[curIdx] = "1";
                }
                if (!ImportantMethods.IsNumericGZ(source_data[curIdx]))
                {
                    DisplayErrorMessage();
                }
                curIdx    -= 2;
                Members[i] = new PMember(new string[] { source_data[curIdx], source_data[curIdx++], source_data[curIdx++] });
            }

            if (hasDegree)
            {
                PartyDirectionInDegrees = Math.Round(double.Parse(CodeReader.Repl_DotWComma(source_data[source_data.Length - 1].TrimEnd(')', ' '))), 6);
            }
            else
            {
                PartyDirectionInDegrees = 0d;
            }
        }
Ejemplo n.º 4
0
        public PartyTemplate(string[] source_data, bool second) : base(source_data[0], ObjectType.Party)
        {
            int curIdx = 0;

            Name = source_data[curIdx++];

            Flags = source_data[curIdx++];
            SetFlagsGZ();

            string menuIDString = source_data[curIdx++];

            if (menuIDString.Equals("no_menu"))
            {
                MenuID = 0;
            }
            else
            {
                MenuID = CodeReader.GameMenus.IndexOf(menuIDString);
            }

            //faction = source_data[curIdx++];
            //if (faction.Equals("no_faction"))
            //    factionID = -1;
            //else
            FactionID = CodeReader.Factions.IndexOf(source_data[curIdx++]);

            string tmpS = source_data[curIdx++].Replace("soldier_personality", "aggressiveness_8|courage_9");

            tmpS = tmpS.Replace("merchant_personality", "aggressiveness_0|courage_7");
            tmpS = tmpS.Replace("escorted_merchant_personality", "aggressiveness_0|courage_11");
            tmpS = tmpS.Replace("bandit_personality", "aggressiveness_3|courage_8|banditness");

            int x = 0;

            string[] tmp = tmpS.Split('|');
            string[] tmp2;
            foreach (string s in tmp)
            {
                tmp2 = s.Trim().Split('_');
                if (tmp2[0].Equals("courage"))
                {
                    x |= int.Parse(tmp2[1]);
                }
                else if (tmp2[0].Equals("aggressiveness"))
                {
                    x |= int.Parse(tmp2[1]) << 4;
                }
                else if (tmp2[0].Equals("banditness"))
                {
                    x |= 0x0100;
                }
            }
            Personality = x;

            x = (source_data.Length - 11) / 3;

            Members = new PMember[x];
            for (int i = 0; i < x; i++)
            {
                curIdx = 11 + i * 3;
                if (!ImportantMethods.IsNumericGZ(source_data[curIdx]))
                {
                    source_data[curIdx] = CodeReader.Troops.IndexOf(source_data[curIdx]).ToString();
                }
                curIdx += 2;
                if (source_data[curIdx].Equals("pmf_is_prisoner"))
                {
                    source_data[curIdx] = "1";
                }
                if (!ImportantMethods.IsNumericGZ(source_data[curIdx]))
                {
                    DisplayErrorMessage();
                }
                curIdx    -= 2;
                Members[i] = new PMember(new string[] { source_data[curIdx], source_data[curIdx++], source_data[curIdx] });
            }
        }