Exemple #1
0
        private uint[] GetSkillCodes()
        {
            uint[] skillCodes = new uint[6];
            string tmp        = string.Empty;

            for (int i = 0; i < SkillHunter.Skillnames.Length - 6; i++)
            {
                for (int j = 0; j < groupBox_6_gb.Controls.Count; j++)
                {
                    Control num = groupBox_6_gb.Controls[j];
                    if (num.TabIndex == i && num.Name.Substring(num.Name.LastIndexOf('_') + 1).Equals("num"))
                    {
                        tmp += HexConverter.Dec2Hex((ulong)((NumericUpDown)num).Value).Substring(7);
                        j    = groupBox_6_gb.Controls.Count;
                    }
                }
            }
            tmp += "000000"; // maybe replace later if there are more than 42 skills possible 192 / 4 = 48
            for (int i = 5; i >= 0; i--)
            {
                skillCodes[i] = uint.Parse(HexConverter.Hex2Dec(ImportantMethods.ReverseString(tmp.Substring(i * 8, 8))).ToString());
            }
            //MessageBox.Show(skillCode);
            //IEnumerable<string> skillCodes = ImportantMethods.WholeChunks(skillCode, 8);
            //for (int i = 0; i < sss.Length; i++)
            //{
            //    sss[i] = skillCodes.GetEnumerator().Current;
            //    if (i < sss.Length - 1)
            //        skillCodes.GetEnumerator().MoveNext();
            //}
            //MessageBox.Show(HexConverter.Hex2Dec(sss[0]) + "|" + HexConverter.Hex2Dec(sss[1]) + "|" + HexConverter.Hex2Dec(sss[2]) + "|" + HexConverter.Hex2Dec(sss[3]) + "|" + HexConverter.Hex2Dec(sss[4]) + "|" + HexConverter.Hex2Dec(sss[5]));
            return(skillCodes);
        }
Exemple #2
0
        private void SetFirstLine(string line)
        {
            string[] lineData = line.Trim().Split();

            if (lineData.Length >= 10)
            {
                //ID = lineData[0];
                Name       = lineData[1].Replace('_', ' ');
                PluralName = lineData[2].Replace('_', ' ');

                DialogImage = lineData[3];

                Flags = lineData[4].Trim();
                if (ImportantMethods.IsNumericGZ(Flags))
                {
                    FlagsGZ = ulong.Parse(Flags);
                    Flags   = GetFlagsFromValues(HexConverter.Dec2Hex(FlagsGZ));
                }
                else
                {
                    FlagsGZ = GetFlagsGZFromString(Flags);
                }

                SetSceneCode(lineData[5]);

                SetReserved(lineData[6]);

                FactionID = int.Parse(lineData[7]);//if not ID/numeric --> ERROR!!!

                try
                {
                    UpgradeTroop1 = int.Parse(lineData[8]);
                }
                catch (Exception)
                {
                    UpgradeTroop1ErrorCode = lineData[8];
                    SendUpgradePathErrorMessage(1, UpgradeTroop1ErrorCode);
                }

                try
                {
                    UpgradeTroop2 = int.Parse(lineData[9]);
                }
                catch (Exception)
                {
                    UpgradeTroop2ErrorCode = lineData[9];
                    SendUpgradePathErrorMessage(2, UpgradeTroop2ErrorCode);
                }
            }
            else
            {
                SendErrorMessage(true);
            }
        }
Exemple #3
0
        public Faction(string[] raw_data) : base(raw_data[0].Split()[0].Replace("fac_", string.Empty), ObjectType.Faction)
        {
            string[] tmp = raw_data[0].Split();
            Name = tmp[1];
            if (ImportantMethods.IsNumericGZ(tmp[2]))
            {
                FlagsGZ = ulong.Parse(tmp[2]);
                SetFlags();
            }
            else
            {
                Flags = tmp[2].Replace('\t', ' ').Replace(" ", string.Empty);
                SetFlagsGZ();
            }

            if (ImportantMethods.IsNumericGZ(tmp[3]))
            {
                ColorCode = HexConverter.Dec2Hex(ulong.Parse(tmp[3])).Substring(2);
            }
            else if (tmp[3].StartsWith("0x"))
            {
                ColorCode = tmp[3].Substring(2);
            }
            else
            {
                ColorCode = tmp[3];
            }

            lastID++;
            id = lastID;

            string[] relationsString = raw_data[1].Split();
            Relations = new double[relationsString.Length];
            for (int i = 0; i < relationsString.Length; i++)
            {
                Relations[i] = double.Parse(CodeReader.Repl_DotWComma(relationsString[i]));
            }

            tmp = raw_data[2].Split();

            int x = int.Parse(tmp[0]);

            if (x > 0)
            {
                Ranks = new string[x];
                for (int i = 0; i < x; i++)
                {
                    Ranks[i] = tmp[i + 1];
                }
            }
        }
        private ushort GetPersonality()
        {
            string aggresiveness = HexConverter.Dec2Hex((ulong)aggressiveness_num.Value).TrimStart('0');
            string courage       = HexConverter.Dec2Hex((ulong)courage_num.Value).TrimStart('0');
            byte   bandit        = 0;

            if (banditness_cb.Checked)
            {
                bandit++;
            }
            string personality = "00000" + bandit + aggresiveness + courage;

            return(ushort.Parse(HexConverter.Hex2Dec(personality).ToString()));
        }
Exemple #5
0
        // Only the default 24 Skills
        private void StartUpDefault(string[] tempArray)// example: 274 131072 0 1 0 0
        {
            //read first set of values (if value is A then set it to 10)
            string hexString = HexConverter.Dec2Hex(tempArray[0]);

            HexConverter.ConvertSingleHexCodeToIntArray(hexString, out int[] hexValues);
            Skills[0] = hexValues[0];   //persuasion
            Skills[1] = hexValues[5];   //prisoner_management
            Skills[2] = hexValues[6];   //leadership
            Skills[3] = hexValues[7];   //trade

            //read second set of values
            hexString = HexConverter.Dec2Hex(tempArray[1]);
            HexConverter.ConvertSingleHexCodeToIntArray(hexString, out hexValues);
            Skills[4]  = hexValues[0];  //tactics
            Skills[5]  = hexValues[1];  //pathfinding
            Skills[6]  = hexValues[2];  //spotting
            Skills[7]  = hexValues[3];  //inventory_management
            Skills[8]  = hexValues[4];  //wound_treatment
            Skills[9]  = hexValues[5];  //surgery
            Skills[10] = hexValues[6];  //first_aid
            Skills[11] = hexValues[7];  //engineer

            //read third set of values
            hexString = HexConverter.Dec2Hex(tempArray[2]);
            HexConverter.ConvertSingleHexCodeToIntArray(hexString, out hexValues);
            Skills[12] = hexValues[0];  //horse_archery
            Skills[13] = hexValues[1];  //looting
            Skills[14] = hexValues[6];  //trainer
            Skills[15] = hexValues[7];  //tracking

            //read fourth set of values
            hexString = HexConverter.Dec2Hex(tempArray[3]);
            HexConverter.ConvertSingleHexCodeToIntArray(hexString, out hexValues);
            Skills[16] = hexValues[4];  //weapon_master
            Skills[17] = hexValues[5];  //shield
            Skills[18] = hexValues[6];  //athletics
            Skills[19] = hexValues[7];  //riding

            //read fifth set of values
            hexString = HexConverter.Dec2Hex(tempArray[4]);
            HexConverter.ConvertSingleHexCodeToIntArray(hexString, out hexValues);
            Skills[20] = hexValues[3];  //ironflesh
            Skills[21] = hexValues[4];  //power_strike
            Skills[22] = hexValues[5];  //power_throw
            Skills[23] = hexValues[6];  //power_draw
        }
        private void SetHexCode(int alpha = -1, int red = -1, int green = -1, int blue = -1)
        {
            if (alpha < 0)
            {
                alpha = (int)alpha_num.Value;
            }
            if (red < 0)
            {
                red = (int)red_num.Value;
            }
            if (green < 0)
            {
                green = (int)green_num.Value;
            }
            if (blue < 0)
            {
                blue = (int)blue_num.Value;
            }

            if (!colorOverrideMode)
            {
                if (hexColor_txt.Text.Length == 10)
                {
                    string hexCode = "0x";
                    hexCode          += HexConverter.Dec2Hex(alpha).Substring(6);
                    hexCode          += HexConverter.Dec2Hex(red).Substring(6);
                    hexCode          += HexConverter.Dec2Hex(green).Substring(6);
                    hexCode          += HexConverter.Dec2Hex(blue).Substring(6);
                    hexColor_txt.Text = hexCode;
                }
                else
                {
                    MessageBox.Show("ERROR - 0x9920 - COLOR_HEX_FORMAT", "ERROR");
                }
            }

            textColor_lbl.BackColor = Color.FromArgb(alpha, red, green, blue);
        }
Exemple #7
0
        // All known 48 skills (maybe more available)
        private void StartUpAll(string[] tmpArray)// example: 274 131072 0 1 0 0
        {
            //read first set of values (if value is A then set it to 10)
            string hexString = HexConverter.Dec2Hex(tmpArray[0]);

            HexConverter.ConvertSingleHexCodeToIntArray(hexString, out int[] hexValues);
            Skills[0] = hexValues[0];   //persuasion | - - - X - - -
            Skills[1] = hexValues[1];   //reserved_IV | - - - X - - -
            Skills[2] = hexValues[2];   //reserved_III | - - - X - - -
            Skills[3] = hexValues[3];   //reserved_II | - - - X - - -
            Skills[4] = hexValues[4];   //reserved_I | - - - X - - -
            Skills[5] = hexValues[5];   //prisoner_management | - - - X - - -
            Skills[6] = hexValues[6];   //leadership | - - - X - - -
            Skills[7] = hexValues[7];   //trade | - - - X - - -

            //read second set of values
            hexString = HexConverter.Dec2Hex(tmpArray[1]);
            HexConverter.ConvertSingleHexCodeToIntArray(hexString, out hexValues);
            Skills[8]  = hexValues[0];  //tactics | - - - X - - -
            Skills[9]  = hexValues[1];  //pathfinding | - - - X - - -
            Skills[10] = hexValues[2];  //spotting | - - - X - - -
            Skills[11] = hexValues[3];  //inventory_management | - - - X - - -
            Skills[12] = hexValues[4];  //wound_treatment | - - - X - - -
            Skills[13] = hexValues[5];  //surgery | - - - X - - -
            Skills[14] = hexValues[6];  //first_aid | - - - X - - -
            Skills[15] = hexValues[7];  //engineer | - - - X - - -

            //read third set of values
            hexString = HexConverter.Dec2Hex(tmpArray[2]);
            HexConverter.ConvertSingleHexCodeToIntArray(hexString, out hexValues);
            Skills[16] = hexValues[0];  //horse_archery | - - - X - - -
            Skills[17] = hexValues[1];  //looting | - - - X - - -
            Skills[18] = hexValues[2];  //reserved_VIII | - - - X - - -
            Skills[19] = hexValues[3];  //reserved_VII | - - - X - - -
            Skills[20] = hexValues[4];  //reserved_VI | - - - X - - -
            Skills[21] = hexValues[5];  //reserved_V | - - - X - - -
            Skills[22] = hexValues[6];  //trainer | - - - X - - -
            Skills[23] = hexValues[7];  //tracking | - - - X - - -

            //read fourth set of values
            hexString = HexConverter.Dec2Hex(tmpArray[3]);
            HexConverter.ConvertSingleHexCodeToIntArray(hexString, out hexValues);
            Skills[24] = hexValues[0];  //reserved_XII
            Skills[25] = hexValues[1];  //reserved_XI
            Skills[26] = hexValues[2];  //reserved_X
            Skills[27] = hexValues[3];  //reserved_IV | - - - X - - -
            Skills[28] = hexValues[4];  //weapon_master | - - - X - - -
            Skills[29] = hexValues[5];  //shield | - - - X - - -
            Skills[30] = hexValues[6];  //athletics | - - - X - - -
            Skills[31] = hexValues[7];  //riding | - - - X - - -

            //read fifth set of values
            hexString = HexConverter.Dec2Hex(tmpArray[4]);
            HexConverter.ConvertSingleHexCodeToIntArray(hexString, out hexValues);
            Skills[32] = hexValues[0];  //reserved_XVI ?
            Skills[33] = hexValues[1];  //reserved_XV | - - - X - - -
            Skills[34] = hexValues[2];  //reserved_XIV | - - - X - - -
            Skills[35] = hexValues[3];  //ironflesh | - - - X - - -
            Skills[36] = hexValues[4];  //power_strike | - - - X - - -
            Skills[37] = hexValues[5];  //power_throw | - - - X - - -
            Skills[38] = hexValues[6];  //power_draw | - - - X - - -
            Skills[39] = hexValues[7];  //reserved_XIII

            //read sixth set of values
            hexString = HexConverter.Dec2Hex(tmpArray[5]);
            HexConverter.ConvertSingleHexCodeToIntArray(hexString, out hexValues);
            Skills[40] = hexValues[0];  //reserved_XVII
            Skills[41] = hexValues[1];  //reserved_XVIII

            if (hexString.Length <= 2)
            {
                return;
            }

            Skills[42] = hexValues[2];  //reserved_XIX ???
            Skills[43] = hexValues[3];  //reserved_XX ???
            Skills[44] = hexValues[4];  //reserved_XXI ???
            Skills[45] = hexValues[5];  //reserved_XXII ???
            Skills[46] = hexValues[6];  //reserved_XXIII ???
            Skills[47] = hexValues[7];  //reserved_XXIV ???
        }
        protected override void SetupType(Skriptum type)
        {
            base.SetupType(type);

            Party party = (Party)type;

            name_txt.Text = party.Name;

            #region GROUP2 - Flags

            List <string> flags    = new List <string>(party.Flags.Split('|'));
            List <string> mapicons = new List <string>(CodeReader.MapIcons);

            map_icon_cbb.SelectedIndex = mapicons.IndexOf(flags[0]);

            if (flags.Contains("pf_label_large"))
            {
                large_label_rb.Checked = true;
            }
            else if (flags.Contains("pf_label_medium"))
            {
                medium_label_rb.Checked = true;
            }
            else if (flags.Contains("pf_label_small"))
            {
                small_label_rb.Checked = true;
            }
            if (flags.Contains("pf_no_label"))
            {
                no_label_rb.Checked = true;
            }

            Control c;
            string  nameEnd;
            bool    found = false;
            foreach (string flag in flags)
            {
                for (int i = 0; i < groupBox_1_gb.Controls.Count; i++)
                {
                    c       = groupBox_1_gb.Controls[i];
                    nameEnd = GetNameEndOfControl(c);
                    if (flag.Equals("pf_" + c.Name.Remove(c.Name.LastIndexOf('_'))))
                    {
                        if (nameEnd.Equals("rb"))
                        {
                            ((RadioButton)c).Checked = true;
                        }
                        else
                        {
                            ((CheckBox)c).CheckState = CheckState.Checked;
                        }
                        found = true;
                    }
                    else if (flag.Contains("carries_"))
                    {
                        string f = flag.Substring(flag.IndexOf('(') + 1).Split(')')[0];
                        if (flag.Contains("goods"))
                        {
                            carries_goods_txt.Text = f;
                        }
                        else
                        {
                            carries_gold_txt.Text = f;
                        }
                        found = true;
                    }
                    if (found)
                    {
                        i = groupBox_1_gb.Controls.Count;
                    }
                }
            }

            #endregion

            #region GROUP3

            menuID_cbb.SelectedIndex         = party.MenuID;
            party_template_cbb.SelectedIndex = party.PartyTemplateID;
            faction_cbb.SelectedIndex        = party.FactionID;
            ai_bhvr_cbb.SelectedIndex        = party.AIBehavior;
            ai_target_p_cbb.SelectedIndex    = party.AITargetParty;

            #endregion

            #region GROUP4

            char[] personality = HexConverter.Dec2Hex(party.Personality).ToString().Substring(5).ToCharArray();
            courage_num.Value        = int.Parse(personality[0].ToString());
            aggressiveness_num.Value = int.Parse(personality[1].ToString());
            if (personality[2] != '0')
            {
                banditness_cb.CheckState = CheckState.Checked;
            }
            double[] coords = party.InitialCoordinates;
            x_axis_txt.Text = CodeReader.Repl_CommaWDot(coords[0].ToString());
            y_axis_txt.Text = CodeReader.Repl_CommaWDot(coords[1].ToString());
            direction_in_degrees_txt.Text = CodeReader.Repl_CommaWDot(party.PartyDirectionInDegrees.ToString());

            #endregion

            #region Stack Troops - GROUP5

            memberValues.Clear();
            stack_troops_lb.Items.Clear();
            if (party.Members.Length > 0)
            {
                foreach (PMember member in party.Members)
                {
                    stack_troops_lb.Items.Add(member.Troop);
                    int[] values = new int[3];
                    values[0] = member.MinimumTroops;
                    values[1] = member.MaximumTroops;
                    values[2] = member.Flags;
                    memberValues.Add(values);
                }
                if (party.Members.Length > 0)
                {
                    stack_troops_lb.SelectedIndex = 0;
                }
            }

            #endregion
        }
Exemple #9
0
        private void SetFlags()
        {
            string flags = string.Empty;
            ulong  tmpU  = FlagsGZ;

            char[] cc = HexConverter.Dec2Hex_16CHARS(FlagsGZ).ToCharArray();

            if (cc.Length > 7)
            {
                if (cc[cc.Length - 1] == '1')
                {
                    flags += "|mnf_join_battle";
                    tmpU  -= 0x1;
                }

                if (cc[cc.Length - 2] == '1')
                {
                    flags += "|mnf_auto_enter";
                    tmpU  -= 0x10;
                }

                if (cc[cc.Length - 3] == '1')
                {
                    flags += "|mnf_enable_hot_keys";
                    tmpU  -= 0x100;
                }
                else if (cc[cc.Length - 3] == '2')
                {
                    flags += "|mnf_disable_all_keys";
                    tmpU  -= 0x200;
                }
                else if (cc[cc.Length - 3] == '3')
                {
                    flags += "|mnf_enable_hot_keys|mnf_disable_all_keys";
                    tmpU  -= 0x300;
                }

                if (cc[cc.Length - 4] == '1')
                {
                    flags += "|mnf_scale_picture";
                    tmpU  -= 0x1000;
                }
            }

            if (tmpU > 0)
            {
                string tmp = HexConverter.Dec2Hex(tmpU >> 32);
                TextColor = Color.FromArgb(byte.Parse(HexConverter.Hex2Dec(tmp.Substring(0, 2)).ToString()),
                                           byte.Parse(HexConverter.Hex2Dec(tmp.Substring(2, 2)).ToString()),
                                           byte.Parse(HexConverter.Hex2Dec(tmp.Substring(4, 2)).ToString()),
                                           byte.Parse(HexConverter.Hex2Dec(tmp.Substring(6, 2)).ToString()));
                flags += "|menu_text_color(0x" + tmp + ')';
            }

            if (flags.Equals(string.Empty))
            {
                flags = FlagsGZ.ToString();
            }
            else
            {
                flags = flags.TrimStart('|');
            }

            Flags = flags;
        }
        private void Generate_header_btn_Click(object sender, EventArgs e)
        {
            byte shift    = byte.Parse(shift_txt.Text);
            int  minValue = int.Parse(minHeaderValue_txt.Text);
            int  maxValue = int.Parse(maxHeaderValue_txt.Text);

            using (StreamWriter wr = new StreamWriter(CodeReader.FILES_PATH + "header_mb_decompiler.py", true))
            {
                wr.WriteLine();
                for (int i = minValue; i < maxValue + 1; i++)
                {
                    wr.WriteLine(exampleHeaderCode_txt.Text.Replace("VAR_INT", i.ToString()).Replace("VAR_HEX", HexConverter.Dec2Hex(i << shift)).ToLower());
                }
            }
        }