Beispiel #1
0
        public static void Decompile()
        {
            var fTemplates = new Text(Path.Combine(Common.InputPath, "party_templates.txt"));
            var fSource    = new Win32FileWriter(Path.Combine(Common.OutputPath, "module_party_templates.py"));

            fSource.WriteLine(Header.Standard);
            fSource.WriteLine(Header.PartyTemplates);
            fTemplates.GetString();
            var iTemplates = fTemplates.GetInt();

            for (int i = 0; i < iTemplates; i++)
            {
                fSource.Write("  (\"{0}\", \"{1}\"", fTemplates.GetWord().Remove(0, 3), fTemplates.GetWord());

                var dwFlag = fTemplates.GetUInt64();
                fSource.Write(", {0}, {1}", DecompileFlags(dwFlag), fTemplates.GetInt());

                var iFaction = fTemplates.GetInt();
                if (iFaction >= 0 && iFaction < Common.Factions.Count)
                {
                    fSource.Write(", fac_{0}", Common.Factions[iFaction]);
                }
                else
                {
                    fSource.Write(", {0}", iFaction);
                }

                var dwPersonality = fTemplates.GetUInt();
                fSource.Write(", {0}, [", DecompilePersonality(dwPersonality));


                var sbTroopList = new StringBuilder(1024);
                for (int iStack = 0; iStack < 6; iStack++)
                {
                    var iTroop = fTemplates.GetInt();
                    if (-1 == iTroop)
                    {
                        continue;
                    }
                    var iMinTroops   = fTemplates.GetInt();
                    var iMaxTroops   = fTemplates.GetInt();
                    var dwMemberFlag = fTemplates.GetDWord();
                    sbTroopList.Append($"({(iTroop < Common.Troops.Count ? "trp_" + Common.Troops[iTroop] : iTroop.ToString(CultureInfo.GetCultureInfo("en-US")))}, {iMinTroops}, {iMaxTroops}{(dwMemberFlag == 1 ? ", pmf_is_prisoner" : "")}),");
                }
                if (sbTroopList.Length != 0)
                {
                    sbTroopList.Length--;
                }
                fSource.WriteLine("{0}]),", sbTroopList);
            }
            fSource.Write("]");
            fSource.Close();
            fTemplates.Close();

            Common.GenerateId("ID_party_templates.py", Common.PTemps, "pt");
        }
Beispiel #2
0
        public static void Decompile()
        {
            var fMenus  = new Text(Common.InputPath + "/menus.txt");
            var fSource = new Win32FileWriter(Common.OutputPath + "/module_game_menus.py");

            fSource.WriteLine(Header.Standard);
            fSource.WriteLine(Header.Menus);
            fMenus.GetString();
            int iMenus = fMenus.GetInt();

            for (int m = 0; m < iMenus; m++)
            {
                string strMenuID = fMenus.GetWord();
                fSource.Write("  (\"{0}\",", strMenuID.Remove(0, 5));

                ulong lMenuFlags = fMenus.GetUInt64();
                fSource.WriteLine(" {0},", DecompileFlags(lMenuFlags));

                string strMenuText = fMenus.GetWord();
                fSource.WriteLine("    \"{0}\",", strMenuText.Replace('_', ' '));

                fSource.WriteLine("    \"{0}\",", fMenus.GetWord());

                int iRecords = fMenus.GetInt();
                if (iRecords != 0)
                {
                    fSource.WriteLine("    [");
                    Common.PrintStatement(ref fMenus, ref fSource, iRecords, "      ");
                    fSource.WriteLine("    ],");
                }
                else
                {
                    fSource.WriteLine("    [],");
                }

                int iMenuOptions = fMenus.GetInt();

                fSource.WriteLine("    [");
                for (int i = 0; i < iMenuOptions; i++)
                {
                    string szMenuOption = fMenus.GetWord();
                    fSource.WriteLine("      (\"{0}\",", szMenuOption.Remove(0, 4));

                    iRecords = fMenus.GetInt();
                    if (iRecords != 0)
                    {
                        fSource.WriteLine("      [");
                        Common.PrintStatement(ref fMenus, ref fSource, iRecords, "        ");
                        fSource.WriteLine("      ],");
                    }
                    else
                    {
                        fSource.WriteLine("      [],");
                    }

                    string strMenuOptionText = fMenus.GetWord();
                    fSource.WriteLine("      \"{0}\",", strMenuOptionText);

                    iRecords = fMenus.GetInt();
                    if (iRecords != 0)
                    {
                        fSource.WriteLine("      [");
                        Common.PrintStatement(ref fMenus, ref fSource, iRecords, "        ");
                        fSource.WriteLine("      ]");
                    }
                    else
                    {
                        fSource.WriteLine("      []");
                    }

                    string strDoorName = fMenus.GetWord();
                    if (strDoorName != ".")
                    {
                        fSource.WriteLine(",\r\n      \"{0}\"", strDoorName);
                    }
                    fSource.Write("      ),\r\n");

                    if ((iMenuOptions - i - 1) != 0)
                    {
                        fSource.WriteLine();
                    }
                }
                fSource.WriteLine("    ],");

                if (iMenuOptions == 0)
                {
                    fSource.WriteLine("    [],");
                }

                fSource.WriteLine("  ),\r\n");
            }
            fSource.Write("]");
            fSource.Close();
            fMenus.Close();

            Common.GenerateId("ID_menus.py", Common.Menus, "menu");
        }
Beispiel #3
0
        public static void Decompile()
        {
            var fSkins  = new Text(Common.InputPath + "/skins.txt");
            var fSource = new Win32FileWriter(Common.OutputPath + "/module_skins.py");

            fSource.WriteLine(Header.Standard);
            fSource.WriteLine(Header.Skins);
            fSkins.GetString();
            int iSkins = fSkins.GetInt();

            for (int s = 0; s < iSkins; s++)
            {
                fSource.WriteLine("  (\r\n    \"{0}\", {1},", fSkins.GetWord(), fSkins.GetInt());
                fSource.WriteLine("    \"{0}\", \"{1}\", \"{2}\",", fSkins.GetWord(), fSkins.GetWord(), fSkins.GetWord());
                fSource.WriteLine("    \"{0}\",\r\n    [", fSkins.GetWord());

                int iFaceKeys = fSkins.GetInt();
                for (int i = 0; i < iFaceKeys; i++)
                {
                    fSkins.GetWord();
                    double d1 = fSkins.GetDouble(), d2 = fSkins.GetDouble(), d3 = fSkins.GetDouble(), d4 = fSkins.GetDouble();
                    string strText = fSkins.GetWord();
                    fSource.WriteLine("      ({0}, {1}, {2}, {3}, \"{4}\"),", d1.ToString(CultureInfo.GetCultureInfo("en-US")), d2.ToString(CultureInfo.GetCultureInfo("en-US")),
                                      d3.ToString(CultureInfo.GetCultureInfo("en-US")), d4.ToString(CultureInfo.GetCultureInfo("en-US")), strText.Replace('_', ' '));
                }
                fSource.WriteLine("    ],");

                int iMeshesHair = fSkins.GetInt();
                fSource.Write("    [");
                for (int i = 0; i < iMeshesHair; i++)
                {
                    fSource.Write("\"{0}\"{1}", fSkins.GetWord(), i != iMeshesHair - 1 ? ", " : "");
                }
                fSource.WriteLine("],");

                int iMeshesBeard = fSkins.GetInt();
                fSource.Write("    [");
                for (int i = 0; i < iMeshesBeard; i++)
                {
                    fSource.Write("\"{0}\"{1}", fSkins.GetWord(), i != iMeshesBeard - 1 ? ", " : "");
                }
                fSource.WriteLine("],");

                for (int i = 0; i < 2; i++)
                {
                    int iTextures = fSkins.GetInt();
                    fSource.Write("    [");
                    for (int t = 0; t < iTextures; t++)
                    {
                        fSource.Write("\"{0}\"{1}", fSkins.GetWord(), t != iTextures - 1 ? ", " : "");
                    }
                    fSource.WriteLine("],");
                }

                int iTexturesFace = fSkins.GetInt();
                fSource.WriteLine("    [");
                for (int i = 0; i < iTexturesFace; i++)
                {
                    fSource.Write("      (\"{0}\", 0x{1:X}, ", fSkins.GetWord(), fSkins.GetDWord());
                    int iHairMats   = fSkins.GetInt();
                    int iHairColors = fSkins.GetInt();
                    for (int m = 0; m < iHairMats; m++)
                    {
                        fSource.Write("[\"{0}\"], ", fSkins.GetWord());
                    }
                    fSource.Write("[");
                    for (int c = 0; c < iHairColors; c++)
                    {
                        //fprintf( g_fOutput, " 0x%X,", GetDWord() );
                        fSource.Write("0x{0:x}{1}", fSkins.GetUInt64(), c != iHairColors - 1 ? ", " : "");
                    }
                    fSource.WriteLine("]),");
                }
                fSource.WriteLine("    ],");

                int iVoices = fSkins.GetInt();
                fSource.Write("    [");
                for (int v = 0; v < iVoices; v++)
                {
                    DWORD    dwFlag   = fSkins.GetDWord();
                    string[] strFlags = { "voice_die", "voice_hit", "voice_grunt", "voice_grunt_long", "voice_yell", "voice_warcry", "voice_victory", "voice_stun" };
                    if (dwFlag <= 7)
                    {
                        fSource.Write("({0},", strFlags[dwFlag]);
                    }
                    else
                    {
                        fSource.Write("({0},", dwFlag);
                    }

                    string strSound = fSkins.GetWord();
                    fSource.Write(" \"{0}\"){1}", strSound, v != iVoices - 1 ? "," : "");
                }
                fSource.WriteLine("],");

                string strSkeleton = fSkins.GetWord();
                fSource.WriteLine("    \"{0}\", {1},", strSkeleton, fSkins.GetWord());

                int ixParticleSystem1 = fSkins.GetInt(),
                    ixParticleSystem2 = fSkins.GetInt();
                fSource.WriteLine("    psys_{0}, psys_{1},", Common.ParticleSystems[ixParticleSystem1], Common.ParticleSystems[ixParticleSystem2]);

                int iConstraints = fSkins.GetInt();
                fSource.Write("    [");
                for (int i = 0; i < iConstraints; i++)
                {
                    double d1 = fSkins.GetDouble();
                    fSource.Write("\r\n      [{0},", d1.ToString(CultureInfo.GetCultureInfo("en-US")));

                    int    i1 = fSkins.GetInt();
                    string c1 = i1 == 1 ? "comp_greater_than" : i1 == -1 ? "comp_less_than" : "0";
                    if (c1 != "0")
                    {
                        fSource.Write(" {0}, ", c1);
                    }
                    else
                    {
                        fSource.Write(" {0}, ", i1);
                    }

                    int count = fSkins.GetInt();
                    for (int c = 0; c < count; c++)
                    {
                        double dc1 = fSkins.GetDouble();
                        int    ic1 = fSkins.GetInt();

                        fSource.Write("({0}, {1}){2}", dc1.ToString(CultureInfo.GetCultureInfo("en-US")), ic1, c != count - 1 ? "," : "");
                    }
                    fSource.Write("],");
                }
                fSource.WriteLine("\r\n  ]),\r\n");
            }
            fSource.Write("]");
            fSource.Close();
            fSkins.Close();
        }
Beispiel #4
0
        public static void Decompile()
        {
            var fFloraKinds = new Text(Path.Combine(Common.InputPath, "flora_kinds.txt"));
            var fSource     = new Win32FileWriter(Path.Combine(Common.OutputPath, "module_flora_kinds.py"));

            fSource.WriteLine(Header.Standard);
            fSource.WriteLine(Header.Flora);

            var iFloraKinds = fFloraKinds.GetInt();

            for (int f = 0; f < iFloraKinds; f++)
            {
                var strId      = fFloraKinds.GetWord();
                var dwFlag     = fFloraKinds.GetUInt64();
                var iNumMeshes = fFloraKinds.GetInt();

                fSource.Write("  (\"{0}\", {1}, [", strId, DecompileFlags(dwFlag));

                //string strMeshesList = "";
                if (IsTree(dwFlag))
                {
                    for (int m = 0; m < iNumMeshes; m++)
                    {
                        string strMeshName             = fFloraKinds.GetWord(),
                               strMeshCollision        = fFloraKinds.GetWord(),
                               strAlternativeMeshName  = fFloraKinds.GetWord(), //fFloraKinds.GetInt().ToString(CultureInfo.GetCultureInfo("en-US")),
                               strAlternativeCollision = fFloraKinds.GetWord(); //fFloraKinds.GetInt().ToString(CultureInfo.GetCultureInfo("en-US"));
                        //System.Windows.MessageBox.Show(strAlternativeMeshName, strAlternativeCollision);
                        fSource.Write("(\"{0}\", \"{1}\",(\"{2}\",\"{3}\")){4}", strMeshName, strMeshCollision,
                                      strAlternativeMeshName, strAlternativeCollision, m == iNumMeshes - 1 ? "" : ",");
                    }
                }
                else
                {
                    for (int m = 0; m < iNumMeshes; m++)
                    {
                        fSource.Write("[\"{0}\", \"{1}\"]{2}", fFloraKinds.GetWord(), fFloraKinds.GetWord(), m == iNumMeshes - 1 ? "" : ",");
                    }
                }
                fSource.WriteLine("]),");
            }
            fSource.Write(@"]
def save_fauna_kinds():
  file = open(export_dir + ""Data/flora_kinds.txt"",""w"")
  file.write(""%d\n""%len(fauna_kinds))
  for fauna_kind in fauna_kinds:
    meshes_list = fauna_kind[2]
    file.write(""%s %d %d\n""%(fauna_kind[0], (dword_mask & fauna_kind[1]), len(meshes_list)))
    for m in meshes_list:
      file.write("" %s ""%(m[0]))
      if (len(m) > 1):
        file.write("" %s\n""%(m[1]))
      else:
        file.write("" 0\n"")
      if ( fauna_kind[1] & (fkf_tree|fkf_speedtree) ):  #if this fails make sure that you have entered the alternative tree definition (NOT FUNCTIONAL in Warband)
        speedtree_alternative = m[2]
        file.write("" %s %s\n""%(speedtree_alternative[0], speedtree_alternative[1]))
    if ( fauna_kind[1] & fkf_has_colony_props ):
      file.write("" %s %s\n""%(fauna_kind[3], fauna_kind[4]))
  file.close()

def two_to_pow(x):
  result = 1
  for i in xrange(x):
    result = result * 2
  return result

fauna_mask = 0x80000000000000000000000000000000
low_fauna_mask =             0x8000000000000000
def save_python_header():
  file = open(""./fauna_codes.py"",""w"")
  for i_fauna_kind in xrange(len(fauna_kinds)):
    file.write(""%s_1 = 0x""%(fauna_kinds[i_fauna_kind][0]))
    file.write(""%x\n""%(fauna_mask | two_to_pow(i_fauna_kind)))
    file.write(""%s_2 = 0x""%(fauna_kinds[i_fauna_kind][0]))
    file.write(""%x\n""%(fauna_mask | ((low_fauna_mask|two_to_pow(i_fauna_kind)) << 64)))
    file.write(""%s_3 = 0x""%(fauna_kinds[i_fauna_kind][0]))
    file.write(""%x\n""%(fauna_mask | ((low_fauna_mask|two_to_pow(i_fauna_kind)) << 64) | two_to_pow(i_fauna_kind)))
  file.close()

print ""Exporting flora data...""
save_fauna_kinds()");
            fSource.Close();
            fFloraKinds.Close();
        }
Beispiel #5
0
        public static void Decompile()
        {
            var fItems  = new Text(Common.InputPath + "/item_kinds1.txt");
            var fSource = new Win32FileWriter(Common.OutputPath + "/module_items.py");

            fSource.WriteLine(Header.Standard);
            fSource.WriteLine(Header.Items);
            fItems.GetString();
            int iItems = fItems.GetInt();

            for (int i = 0; i < iItems; i++)
            {
                string strItemID = fItems.GetWord().Remove(0, 4);
                fSource.Write("  [\"{0}\"", strItemID);
                fItems.GetWord(); // skip second name

                string strItemName = fItems.GetWord();
                fSource.Write(",\"{0}\", [", strItemName);

                int iMeshes = fItems.GetInt();
                //if (iMeshes != 0)
                //    source.Write(", [");

                string strMeshes = "";
                for (int m = 0; m < iMeshes; m++)
                {
                    string  strMeshName = fItems.GetWord();
                    DWORD64 dwMeshBits  = fItems.GetUInt64();
                    strMeshes = strMeshes + $"(\"{strMeshName}\", {DecompileMeshesImodBits(dwMeshBits)}),";
                }
                if (strMeshes.Length > 0)
                {
                    strMeshes = strMeshes.Remove(strMeshes.Length - 1, 1);
                }

                fSource.Write("{0}]", strMeshes);

                DWORD64 dwItemFlags = fItems.GetUInt64();
                ulong   lItemCaps   = fItems.GetUInt64();

                BYTE bType;

                fSource.Write(", {0}, {1},", DecompileFlags(dwItemFlags, out bType), DecompileCapabilities(lItemCaps));
                int iCost = fItems.GetInt();

                //items.GetWord();
                DWORD64 dwImodBits = fItems.GetUInt64();

                string   strItemStats = "weight(" + fItems.GetDouble().ToString(CultureInfo.GetCultureInfo("en-US")) + ")";
                string[] strStats     = { "abundance", "head_armor",  "body_armor",    "leg_armor", "difficulty",    "hit_points",
                                          "spd_rtng",      "shoot_speed", "weapon_length", "max_ammo",  "thrust_damage", "swing_damage" };
                for (int v = 0; v < 12; v++)
                {
                    int iValue = fItems.GetInt();

                    string strState = strStats[v];

                    if (bType == HORSE_TYPE && strState == "shoot_speed")
                    {
                        strState = "horse_speed";
                    }
                    else if (bType == HORSE_TYPE && strState == "spd_rtng")
                    {
                        strState = "horse_maneuver";
                    }
                    else if (bType == GOODS_TYPE && strState == "head_armor")
                    {
                        strState = "food_quality";
                    }
                    else if ((bType == BOW_TYPE || bType == CROSSBOW_TYPE || bType == MUSKET_TYPE || bType == PISTOL_TYPE) && strState == "leg_armor")
                    {
                        strState = "accuracy";
                    }
                    else if (bType == SHIELD_TYPE && strState == "weapon_length")
                    {
                        strState = "shield_width";
                    }
                    else if (bType == SHIELD_TYPE && strState == "shoot_speed")
                    {
                        strState = "shield_height";
                    }

                    if (iValue != 0)
                    {
                        if (v >= 10)
                        {
                            int    iDamage       = iValue & 0xFF;
                            int    iDamageType   = (iValue - iDamage) >> 8;
                            string strDamageType = "";
                            switch (iDamageType)
                            {
                            case 0:
                                strDamageType = "cut";
                                break;

                            case 1:
                                strDamageType = "pierce";
                                break;

                            case 2:
                                strDamageType = "blunt";
                                break;
                            }
                            if (bType == HORSE_TYPE && strState == "thrust_damage" && iDamageType == 0)
                            {
                                strItemStats = strItemStats + $"|horse_charge({iDamage})";
                            }
                            else
                            {
                                strItemStats = strItemStats + $"|{strState}({iDamage}, {strDamageType})";
                            }
                        }
                        else
                        {
                            strItemStats = strItemStats + $"|{strState}({iValue})";
                        }
                    }
                }
                fSource.Write("{0}, {1}, {2}", iCost, strItemStats, DecompileImodBits(dwImodBits));

                int    iFactions      = fItems.GetInt();
                string strFactionList = "";
                for (int f = 0; f < iFactions; f++)
                {
                    int iFaction = fItems.GetInt();
                    strFactionList += "fac_" + Common.Factions[iFaction] + ",";
                }
                if (strFactionList != "")
                {
                    strFactionList = strFactionList.Remove(strFactionList.Length - 1, 1);
                }

                int iTriggers = fItems.GetInt();
                if (iTriggers != 0)
                {
                    fSource.Write(", [\r\n    ");
                    for (int t = 0; t < iTriggers; t++)
                    {
                        double dInterval = fItems.GetDouble();
                        fSource.WriteLine("({0}, [", Common.GetTriggerParam(dInterval));

                        int iRecords = fItems.GetInt();
                        //memcpy(indention, "      ", 7);
                        Common.PrintStatement(ref fItems, ref fSource, iRecords, "      ");

                        fSource.Write("    ]),\r\n   ");
                    }
                    fSource.Write("]");
                }
                else
                {
                    fSource.Write(", []");
                }

                if (iFactions != 0)
                {
                    fSource.WriteLine(", [{0}]],", strFactionList);
                }
                else
                {
                    fSource.WriteLine("],");
                }
            }
            fSource.Write("]");
            fSource.Close();
            fItems.Close();

            Common.GenerateId("ID_items.py", Common.Items, "itm");
        }
Beispiel #6
0
        public static void Decompile()
        {
            var fTroops = new Text(Common.InputPath + "/troops.txt");
            var fSource = new Win32FileWriter(Common.OutputPath + "/module_troops.py");

            fSource.WriteLine(Header.Standard);
            fSource.WriteLine(Header.Troops);

            for (int s = 0; s < Common.Skins.Length; s++)
            {
                fSource.WriteLine("tf_" + Common.Skins[s] + " = " + s);
            }

            fSource.WriteLine("\r\ntroops = [");

            fTroops.GetString();
            int iTroops = fTroops.GetInt();

            var aUpList = new List <object>();

            for (int t = 0; t < iTroops; t++)
            {
                fSource.Write("  [\"{0}\", \"{1}\", \"{2}\",", fTroops.GetWord().Remove(0, 4), fTroops.GetWord().Replace('_', ' '), fTroops.GetWord().Replace('_', ' '));
                fTroops.GetWord();

                DWORD dwFlag = fTroops.GetDWord();
                fSource.Write(" {0},", DecompileFlags(dwFlag));

                DWORD dwScene = fTroops.GetDWord();
                fSource.Write(" {0},", dwScene == 0 ? "0" : GetScene(dwScene));

                fSource.Write(" {0},", fTroops.GetWord()); // reserved "0"

                int iFaction = fTroops.GetInt();
                if (iFaction > 0 && iFaction < Common.Factions.Length)
                {
                    fSource.WriteLine(" fac_{0},", Common.Factions[iFaction]);
                }
                else
                {
                    fSource.WriteLine(" {0},", iFaction);
                }

                int iUp1 = fTroops.GetInt();
                int iUp2 = fTroops.GetInt();

                /*if (iUp1 != 0 && iUp2 != 0)
                 *  strUpList.Add(
                 *      $"upgrade2(troops,\"{Common.Troops[t]}\",\"{Common.Troops[iUp1]}\",\"{Common.Troops[iUp2]}\")");
                 * else if (iUp1 != 0 && iUp2 == 0)
                 *  strUpList.Add($"upgrade(troops,\"{Common.Troops[t]}\",\"{Common.Troops[iUp1]}\")");
                 */
                if (iUp1 != 0 && iUp2 != 0)
                {
                    aUpList.Add(new Upgrade2(t, iUp1, iUp2));
                }
                else if (iUp1 != 0 && iUp2 == 0)
                {
                    aUpList.Add(new Upgrade(t, iUp1));
                }

                string strItemList = "";
                for (int i = 0; i < 64; i++)
                {
                    int iItem = fTroops.GetInt();
                    fTroops.GetInt(); //skip 0
                    if (-1 == iItem)
                    {
                        continue;
                    }
                    strItemList += iItem < Common.Items.Length ? $"itm_{Common.Items[iItem]}," : $"{iItem},";
                }
                if (strItemList.Length > 0)
                {
                    strItemList = strItemList.Remove(strItemList.Length - 1, 1);
                }
                fSource.WriteLine("  [{0}],", strItemList);

                int iStregth      = fTroops.GetInt(),
                    iAgility      = fTroops.GetInt(),
                    iIntelligence = fTroops.GetInt(),
                    iCharisma     = fTroops.GetInt(),
                    iLevel        = fTroops.GetInt();

                fSource.Write("  strength({0})|agility({1})|intellect({2})|charisma({3})|level({4}), ", iStregth, iAgility, iIntelligence, iCharisma, iLevel);

                var iWP = new int[7];
                for (int i = 0; i < 7; i++)
                {
                    iWP[i] = fTroops.GetInt();
                }

                if (iWP[0] == iWP[1] && iWP[1] == iWP[2] && iWP[2] == iWP[3] && iWP[3] == iWP[4] && iWP[4] == iWP[5])
                {
                    fSource.Write("wp({0}){1},", iWP[0], iWP[6] == 0 ? "" : "|wp_firearm(" + iWP[6] + ")");
                }
                else if (iWP[0] == iWP[1] && iWP[1] == iWP[2])
                {
                    fSource.Write("wpe({0},{1},{2},{3}){4},", iWP[0], iWP[3], iWP[4], iWP[5], iWP[6] == 0 ? "" : "|wp_firearm(" + iWP[6] + ")");
                }
                else
                {
                    fSource.Write("wpex({0},{1},{2},{3},{4},{5}){6},", iWP[0], iWP[1], iWP[2], iWP[3], iWP[4], iWP[5], iWP[6] == 0 ? "" : "|wp_firearm(" + iWP[6] + ")");
                }

                var strKnow = new StringBuilder("");
                for (int x = 0; x < 6; x++)
                {
                    DWORD dword = fTroops.GetDWord();
                    if (dword == 0)
                    {
                        continue;
                    }
                    for (int q = 0; q < 8; q++)
                    {
                        DWORD dwKnow = 0xF & (dword >> (q * 4));

                        /*if (dwKnow != 0 && dwKnow <= 8)
                         *  strKnow = strKnow + String.Format("knows_{0}_{1}|", Common.Skills[x * 8 + q], dwKnow);
                         * else*/
                        if (dwKnow != 0 && (x << 3) + q < Common.Skills.Length)
                        {
                            strKnow.Append($"knows_{Common.Skills[(x << 3) + q]}_{dwKnow}|");
                        }
                    }
                }
                if (strKnow.Length == 0)
                {
                    strKnow.Append('0');
                }
                else
                {
                    strKnow.Length--;
                }
                //strKnow = strKnow.Length == 0 ? "0" : strKnow.Remove(strKnow.Length - 1, 1);
                fSource.Write(" {0},", strKnow);

                string strFase =
                    $"0x{fTroops.GetUInt64():x16}{fTroops.GetUInt64():x16}{fTroops.GetUInt64():x16}{fTroops.GetUInt64():x16}, 0x{fTroops.GetUInt64():x16}{fTroops.GetUInt64():x16}{fTroops.GetUInt64():x16}{fTroops.GetUInt64():x16}";
                if (Common.SelectedMode == Mode.Caribbean)
                {
                    fTroops.GetWord();
                }
                fSource.WriteLine("{0}],", strFase);
            }

            fSource.WriteLine("]");
            foreach (var t in aUpList.Select(up => up.ToString()).Where(t => !String.IsNullOrEmpty(t)))
            {
                fSource.WriteLine(t);
            }
            fSource.Close();
            fTroops.Close();

            Common.GenerateId("ID_troops.py", Common.Troops, "trp");
        }