public static void Decompile() { var fPostfx = new Text(Common.InputPath + "/postfx.txt"); var fSource = new Win32FileWriter(Common.OutputPath + "/module_postfx.py"); fSource.WriteLine(Header.Standard); fSource.WriteLine(Header.Postfx); fPostfx.GetString(); int iPostFXs = fPostfx.GetInt(); for (int i = 0; i < iPostFXs; i++) { fSource.Write(" (\"{0}\"", fPostfx.GetWord().Remove(0, 4)); DWORD dwFlag = fPostfx.GetDWord(); if (dwFlag == 1) { fSource.Write(", fxf_highhdr"); } else { fSource.Write(", {0}", dwFlag); } int iOpType = fPostfx.GetInt(); fSource.Write(", {0},", iOpType); for (int p = 0; p < 3; p++) { double d1 = fPostfx.GetDouble(), d2 = fPostfx.GetDouble(), d3 = fPostfx.GetDouble(), d4 = fPostfx.GetDouble(); fSource.Write(" [{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")), p < 2 ? "," : ""); } fSource.WriteLine("),"); } fSource.Write("]"); fSource.Close(); fPostfx.Close(); //Common.GenerateId("ID_postfx_params.py", Common.PostfxParams, "pfx"); }
public static void Decompile() { var fSceneProps = new Text(Common.InputPath + "/scene_props.txt"); var fSource = new Win32FileWriter(Common.OutputPath + "/module_scene_props.py"); fSource.WriteLine(Header.Standard); fSource.WriteLine(Header.SceneProps); fSceneProps.GetString(); int iSceneProps = fSceneProps.GetInt(); for (int i = 0; i < iSceneProps; i++) { string strID = fSceneProps.GetWord(); DWORD dwFlag = fSceneProps.GetUInt(); fSceneProps.GetInt(); fSource.Write(" (\"{0}\", {1}, \"{2}\", \"{3}\", [", strID.Remove(0, 4), DecompileFlags(dwFlag), fSceneProps.GetWord(), fSceneProps.GetWord()); int iTriggers = fSceneProps.GetInt(); for (int t = 0; t < iTriggers; t++) { double dInterval = fSceneProps.GetDouble(); fSource.Write("\r\n ({0},[\r\n", Common.GetTriggerParam(dInterval)); int iRecords = fSceneProps.GetInt(); if (iRecords != 0) { Common.PrintStatement(ref fSceneProps, ref fSource, iRecords, " "); } fSource.WriteLine(" ]),"); } fSource.WriteLine(iTriggers > 0 ? " ]),\r\n" : "]),\r\n"); } fSource.Write("]"); fSource.Close(); fSceneProps.Close(); Common.GenerateId("ID_scene_props.py", Common.SceneProps, "spr"); }
public static void Decompile() { var fMusic = new Text(Path.Combine(Common.InputPath, "music.txt")); var fSource = new Win32FileWriter(Path.Combine(Common.OutputPath, "module_music.py")); fSource.WriteLine(Header.Standard); fSource.WriteLine(Header.Music); var iTracks = fMusic.GetInt(); for (int t = 0; t < iTracks; t++) { var strTrack = fMusic.GetWord(); var dwTrackFlags = fMusic.GetUInt(); var dwContinueFlags = fMusic.GetUInt(); var strTrackId = strTrack.Length >= 4 ? strTrack.Remove(strTrack.Length - 4, 4) : strTrack; fSource.WriteLine(" (\"{0}\", \"{1}\", {2}, {3}),", strTrackId, strTrack, DecompileFlags(dwTrackFlags), DecompileFlags(dwContinueFlags ^ dwTrackFlags)); } fSource.Write("]"); fSource.Close(); fMusic.Close(); Common.GenerateId("ID_music.py", Common.Music, "track"); }
public static string[] Initialize() { var fID = new Text(Common.InputPath + "/presentations.txt"); fID.GetString(); int n = fID.GetInt(); var aPresentations = new string[n]; for (int i = 0; i < n; i++) { aPresentations[i] = fID.GetWord().Remove(0, 6); //idPresentations[i - 1] = presentation.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)[0].Remove(0, 6); //var numEvents = Convert.ToInt32(presentation.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)[3]); fID.GetWord(); fID.GetWord(); var iEvents = fID.GetInt(); while (iEvents != 0) { fID.GetWord(); int iRecords = fID.GetInt(); if (iRecords != 0) { for (int r = 0; r < iRecords; r++) { fID.GetWord(); int iParams = fID.GetInt(); for (int p = 0; p < iParams; p++) { fID.GetWord(); } } } iEvents--; } //idFile.ReadLine(); //idFile.ReadLine(); } fID.Close(); return(aPresentations); }
public static string[] Initialize() { if (!File.Exists(Path.Combine(Common.InputPath, "presentations.txt"))) { return(Array.Empty <string>()); } var fId = new Text(Path.Combine(Common.InputPath, "presentations.txt")); fId.GetString(); int n = fId.GetInt(); var aPresentations = new string[n]; for (int i = 0; i < n; i++) { aPresentations[i] = fId.GetWord().Remove(0, 6); fId.GetWord(); fId.GetWord(); var iEvents = fId.GetInt(); while (iEvents != 0) { fId.GetWord(); int iRecords = fId.GetInt(); if (iRecords != 0) { for (int r = 0; r < iRecords; r++) { fId.GetWord(); int iParams = fId.GetInt(); for (int p = 0; p < iParams; p++) { fId.GetWord(); } } } iEvents--; } } fId.Close(); return(aPresentations); }
public static void Decompile() { var fScripts = new Text(Path.Combine(Common.InputPath, "scripts.txt")); var fSource = new Win32FileWriter(Path.Combine(Common.OutputPath, "module_scripts.py")); fSource.WriteLine(Header.Standard); fSource.WriteLine(Header.Scripts); fScripts.GetString(); int iScripts = fScripts.GetInt(); for (int s = 0; s < iScripts; s++) { fSource.Write(" (\"{0}\",\r\n [\r\n", fScripts.GetWord()); fScripts.GetInt(); int iRecords = fScripts.GetInt(); Common.PrintStatement(ref fScripts, ref fSource, iRecords, " "); fSource.Write(" ]),\r\n\r\n"); } fSource.Write("]"); fSource.Close(); fScripts.Close(); Common.GenerateId("ID_scripts.py", Common.Procedures, "script"); }
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(); }
public static void Decompile() { var fParties = new Text(Common.InputPath + "/parties.txt"); var fSource = new Win32FileWriter(Common.OutputPath + "/module_parties.py"); fSource.WriteLine(Header.Standard); fSource.WriteLine(Header.Parties); fParties.GetString(); int iParties = fParties.GetInt(); fParties.GetInt(); for (int i = 0; i < iParties; i++) { fParties.GetInt(); fParties.GetInt(); fParties.GetInt(); fSource.Write(" (\"{0}\", \"{1}\", {2}", fParties.GetWord().Remove(0, 2), fParties.GetWord().Replace('_', ' '), DecompileFlags(fParties.GetDWord())); int iMenu = fParties.GetInt(); fSource.Write(", {0}", iMenu == 0 ? "no_menu" : "mnu_" + Common.Menus[iMenu]); int iParty = fParties.GetInt(); fSource.Write(", {0}", iParty == 0 ? "pt_none" : "pt_" + Common.PTemps[iParty]); int iFaction = fParties.GetInt(); fSource.Write(", {0}", "fac_" + Common.Factions[iFaction]); int iPersonality = fParties.GetInt(); fParties.GetInt(); fSource.Write(", {0}", iPersonality); int iAIbehaviour = fParties.GetInt(); fParties.GetInt(); string[] strAIbehaviours = { "ai_bhvr_hold", "ai_bhvr_travel_to_party", "ai_bhvr_patrol_location", "ai_bhvr_patrol_party", "ai_bhvr_attack_party", "ai_bhvr_avoid_party", "ai_bhvr_travel_to_point", "ai_bhvr_negotiate_party","ai_bhvr_in_town", "ai_bhvr_travel_to_ship", "ai_bhvr_escort_party", "ai_bhvr_driven_by_party" }; fSource.Write(", {0}", iAIbehaviour <= 11 ? strAIbehaviours[iAIbehaviour] : iAIbehaviour.ToString(CultureInfo.GetCultureInfo("en-US"))); int iAITargetParty = fParties.GetInt(); fSource.Write(", {0}", iAITargetParty); double dX = fParties.GetDouble(), dY = fParties.GetDouble(); fSource.Write(", ({0}, {1}), [", dX.ToString(CultureInfo.GetCultureInfo("en-US")), dY.ToString(CultureInfo.GetCultureInfo("en-US"))); fParties.GetDouble(); fParties.GetDouble(); fParties.GetDouble(); fParties.GetDouble(); fParties.GetDouble(); int iRecords = fParties.GetInt(); for (int j = 0; j < iRecords; j++) { int iTroop = fParties.GetInt(); int iNumTroops = fParties.GetInt(); fParties.GetInt(); int iFlag = fParties.GetInt(); fSource.Write("(trp_{0}, {1}, {2}){3}", Common.Troops[iTroop], iNumTroops, iFlag == 1 ? "pmf_is_prisoner" : "0", j == (iRecords - 1) ? "" : ","); } fSource.Write("]"); double dAngle = fParties.GetDouble(); if (Math.Abs(dAngle) > 0.0000001) { fSource.Write(", {0}", (Math.Round(dAngle * (180 / Math.PI))).ToString(CultureInfo.GetCultureInfo("en-US"))); } fSource.WriteLine("),"); } fSource.Write("]"); fSource.Close(); fParties.Close(); Common.GenerateId("ID_parties.py", Common.Parties, "p"); }
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"); }
public static string[] Initialize() { if (!File.Exists(Path.Combine(Common.InputPath, "menus.txt"))) { return(Array.Empty <string>()); } var fId = new Text(Path.Combine(Common.InputPath, "menus.txt")); fId.GetString(); var n = Convert.ToInt32(fId.GetString(), CultureInfo.GetCultureInfo("en-US")); var aMenus = new string[n]; for (int i = 0; i < n; i++) { string strId = fId.GetWord(); aMenus[i] = strId.Remove(0, 5); fId.GetWord(); fId.GetWord(); fId.GetWord(); var iRecords = fId.GetInt(); if (iRecords != 0) { for (int r = 0; r < iRecords; r++) { fId.GetWord(); var iParams = fId.GetInt(); for (int p = 0; p < iParams; p++) { fId.GetWord(); } } } var iMenuOptions = fId.GetInt(); for (int j = 0; j < iMenuOptions; j++) { fId.GetWord(); iRecords = fId.GetInt(); if (iRecords != 0) { for (int r = 0; r < iRecords; r++) { fId.GetWord(); var iParams = fId.GetInt(); for (int p = 0; p < iParams; p++) { fId.GetWord(); } } } fId.GetWord(); iRecords = fId.GetInt(); if (iRecords != 0) { for (int r = 0; r < iRecords; r++) { fId.GetWord(); var iParams = fId.GetInt(); for (int p = 0; p < iParams; p++) { fId.GetWord(); } } } fId.GetWord(); } //idFile.ReadLine(); } fId.Close(); return(aMenus); }
public static string[] Initialize() { if (!File.Exists(Path.Combine(Common.InputPath, "skins.txt"))) { return(Array.Empty <string>()); } var fId = new Text(Path.Combine(Common.InputPath, "skins.txt")); fId.GetString(); int n = fId.GetInt(); var aSkins = new string[n]; for (int i = 0; i < n; i++) { aSkins[i] = fId.GetWord(); fId.GetInt(); fId.GetWord(); fId.GetWord(); fId.GetWord(); fId.GetWord(); int iFaceKeys = fId.GetInt(); for (int j = 0; j < iFaceKeys; j++) { fId.GetWord(); fId.GetWord(); fId.GetWord(); fId.GetWord(); fId.GetWord(); fId.GetWord(); } int iMeshesHair = fId.GetInt(); for (int j = 0; j < iMeshesHair; j++) { fId.GetWord(); } int iMeshesBeard = fId.GetInt(); for (int j = 0; j < iMeshesBeard; j++) { fId.GetWord(); } for (int j = 0; j < 2; j++) { int iTextures = fId.GetInt(); for (int t = 0; t < iTextures; t++) { fId.GetWord(); } } int iTexturesFace = fId.GetInt(); for (int j = 0; j < iTexturesFace; j++) { fId.GetWord(); fId.GetWord(); int iHairMats = fId.GetInt(); int iHairColors = fId.GetInt(); for (int m = 0; m < iHairMats; m++) { fId.GetWord(); } for (int c = 0; c < iHairColors; c++) { fId.GetWord(); } } int iVoices = fId.GetInt(); for (int v = 0; v < iVoices; v++) { fId.GetWord(); fId.GetWord(); } fId.GetWord(); fId.GetWord(); fId.GetWord(); fId.GetWord(); int iConstraints = fId.GetInt(); for (int j = 0; j < iConstraints; j++) { fId.GetWord(); fId.GetWord(); int count = fId.GetInt(); for (int c = 0; c < count; c++) { fId.GetWord(); fId.GetWord(); } } } fId.Close(); return(aSkins); }
public static string[] Initialize() { var fID = new Text(Common.InputPath + "/mission_templates.txt"); fID.GetString(); int n = Convert.ToInt32(fID.GetString()); var aMissionTemplates = new string[n]; for (int i = 0; i < n; i++) { fID.GetWord(); aMissionTemplates[i] = fID.GetWord(); fID.GetWord(); fID.GetWord(); fID.GetWord(); int iSpawnRecords = fID.GetInt(); for (int j = 0; j < iSpawnRecords; j++) { fID.GetWord(); fID.GetWord(); fID.GetWord(); fID.GetWord(); fID.GetWord(); int iItems = fID.GetInt(); for (int k = 0; k < iItems; k++) { //source.Write("{0},", Common.Items[mt.GetInt()]); fID.GetWord(); } } int iTriggers = fID.GetInt(); for (int t = 0; t < iTriggers; t++) { fID.GetWord(); fID.GetWord(); fID.GetWord(); int iRecords = fID.GetInt(); for (int r = 0; r < iRecords; r++) { fID.GetWord(); int iParams = fID.GetInt(); for (int p = 0; p < iParams; p++) { fID.GetWord(); } } iRecords = fID.GetInt(); for (int r = 0; r < iRecords; r++) { fID.GetWord(); int iParams = fID.GetInt(); for (int p = 0; p < iParams; p++) { fID.GetWord(); } } } } fID.Close(); return(aMissionTemplates); }
public static string[] Initialize() { if (!File.Exists(Path.Combine(Common.InputPath, "mission_templates.txt"))) { return(Array.Empty <string>()); } var fId = new Text(Path.Combine(Common.InputPath, "mission_templates.txt")); fId.GetString(); int n = Convert.ToInt32(fId.GetString(), CultureInfo.GetCultureInfo("en-US")); var aMissionTemplates = new string[n]; for (int i = 0; i < n; i++) { fId.GetWord(); aMissionTemplates[i] = fId.GetWord(); fId.GetWord(); fId.GetWord(); fId.GetWord(); int iSpawnRecords = fId.GetInt(); for (int j = 0; j < iSpawnRecords; j++) { fId.GetWord(); fId.GetWord(); fId.GetWord(); fId.GetWord(); fId.GetWord(); int iItems = fId.GetInt(); for (int k = 0; k < iItems; k++) { fId.GetWord(); } } int iTriggers = fId.GetInt(); for (int t = 0; t < iTriggers; t++) { fId.GetWord(); fId.GetWord(); fId.GetWord(); int iRecords = fId.GetInt(); for (int r = 0; r < iRecords; r++) { fId.GetWord(); int iParams = fId.GetInt(); for (int p = 0; p < iParams; p++) { fId.GetWord(); } } iRecords = fId.GetInt(); for (int r = 0; r < iRecords; r++) { fId.GetWord(); int iParams = fId.GetInt(); for (int p = 0; p < iParams; p++) { fId.GetWord(); } } } } fId.Close(); return(aMissionTemplates); }
public static void Decompile() { var fGroundSpecs = new Text(Path.Combine(Common.InputPath, "ground_specs.txt")); var fSource = new Win32FileWriter(Path.Combine(Common.OutputPath, "module_ground_specs.py")); fSource.WriteLine(Header.Standard); fSource.WriteLine(Header.GroundSpecs); int n = GetLexemsInFile(Path.Combine(Common.InputPath, "ground_specs.txt")) >> 3; // / 8; for (int i = 0; i < n; i++) { var strId = fGroundSpecs.GetWord(); var dwFlag = fGroundSpecs.GetUInt(); var strMaterial = fGroundSpecs.GetWord(); var dblUVScale = fGroundSpecs.GetDouble(); var strMultitexMaterialName = fGroundSpecs.GetWord(); double dColor1 = fGroundSpecs.GetDouble(), dColor2 = fGroundSpecs.GetDouble(), dColor3 = fGroundSpecs.GetDouble(); var sbFlag = new StringBuilder(64); string[] strFlags = { "gtf_overlay", "gtf_dusty", "gtf_has_color" }; DWORD[] dwFlags = { 1, 2, 4 }; for (int j = 0; j < dwFlags.Length; j++) { if ((dwFlag & dwFlags[j]) == 0) { continue; } dwFlag ^= dwFlags[j]; sbFlag.Append(strFlags[j]); sbFlag.Append('|'); } if (sbFlag.Length == 0) { sbFlag.Append('0'); } else { sbFlag.Length--; } fSource.WriteLine(" (\"{0}\", {1}, \"{2}\", {3}, \"{4}\", ({5}, {6}, {7})),", strId, sbFlag, strMaterial, dblUVScale.ToString(CultureInfo.GetCultureInfo("en-US")), strMultitexMaterialName, dColor1.ToString(CultureInfo.GetCultureInfo("en-US")), dColor2.ToString(CultureInfo.GetCultureInfo("en-US")), dColor3.ToString(CultureInfo.GetCultureInfo("en-US"))); } fSource.WriteLine(@"] def write_vec(file,vec): file.write("" %f %f %f ""%vec) def save_ground_specs(): file = open(export_dir + ""Data/ground_specs.txt"",""w"") for ground_spec in ground_specs: file.write("" %s %d %s %f %s""%(ground_spec[0],ground_spec[1],ground_spec[2],ground_spec[3],ground_spec[4])) if (ground_spec[1] & gtf_has_color): file.write("" %f %f %f""%ground_spec[5]) file.write(""\n"") file.close() def save_c_header(): file = open(export_dir + ""ground_spec_codes.h"",""w"") file.write(""#ifndef _GROUND_SPEC_CODES_H\n"") file.write(""#define _GROUND_SPEC_CODES_H\n\n"") file.write(""typedef enum {\n"") for ground_spec in ground_specs: file.write("" ground_%s,\n""%ground_spec[0]) file.write(""}Ground_spec_codes;\n"") file.write(""const int num_ground_specs = %d;\n""%(len(ground_specs))) file.write(""\n\n"") file.write(""\n#endif\n"") file.close() def save_python_header(): file = open(""./header_ground_types.py"",""w"") for ig in xrange(len(ground_specs)): ground_spec = ground_specs[ig] file.write(""ground_%s = %d\n""%(ground_spec[0], ig)) file.write(""\n\n"") file.close() print ""Exporting ground_spec data..."" save_ground_specs() save_c_header() save_python_header()"); fSource.Close(); fGroundSpecs.Close(); }
public static void Decompile() { var fFactions = new Text(Path.Combine(Common.InputPath, "factions.txt")); var fSource = new Win32FileWriter(Path.Combine(Common.OutputPath, "module_factions.py")); fSource.WriteLine(Header.Standard); fSource.WriteLine(Header.Factions); fFactions.GetString(); var iFactions = fFactions.GetInt(); for (int f = 0; f < iFactions; f++) { var strFacId = fFactions.GetWord(); if (strFacId == "0") { strFacId = fFactions.GetWord(); } var strFacName = fFactions.GetWord(); fSource.Write(" (\"{0}\", \"{1}\",", strFacId.Remove(0, 4), strFacName); var sbFlags = new StringBuilder(64); var dwFlags = fFactions.GetUInt(); var iRating = (int)(dwFlags & 0xFF00) >> 8; if (iRating != 0) { sbFlags.Append($"max_player_rating({100 - iRating})"); } if ((dwFlags & 1) != 0) { if (sbFlags.Length > 0) { sbFlags.Append('|'); } sbFlags.Append("ff_always_hide_label"); } if (sbFlags.Length == 0) { sbFlags.Append('0'); } fSource.Write(" {0}, 0.0, [", sbFlags); var dwColor = fFactions.GetUInt(); var sbRelations = new StringBuilder(1024); for (int r = 0; r < iFactions; r++) { var rRelation = fFactions.GetDouble(); if (Math.Abs(rRelation) > 0.000001) { sbRelations.Append($"(\"{Common.Factions[r]}\", {rRelation.ToString(CultureInfo.GetCultureInfo("en-US"))}),"); } } if (sbRelations.Length != 0) { sbRelations.Length--; } fSource.Write("{0}], []", sbRelations); if (dwColor != 0xAAAAAA) { fSource.Write(", 0x{0:X}", dwColor); } fSource.WriteLine("),"); } fSource.Write("]"); fSource.Close(); fFactions.Close(); Common.GenerateId("ID_factions.py", Common.Factions, "fac"); }
public static string[] Initialize() { var fID = new Text(Common.InputPath + "/skins.txt"); fID.GetString(); int n = fID.GetInt(); var aSkins = new string[n]; for (int i = 0; i < n; i++) { aSkins[i] = fID.GetWord(); fID.GetInt(); fID.GetWord(); fID.GetWord(); fID.GetWord(); fID.GetWord(); int iFaceKeys = fID.GetInt(); for (int j = 0; j < iFaceKeys; j++) { fID.GetWord(); fID.GetWord(); fID.GetWord(); fID.GetWord(); fID.GetWord(); fID.GetWord(); } int iMeshesHair = fID.GetInt(); for (int j = 0; j < iMeshesHair; j++) { fID.GetWord(); } int iMeshesBeard = fID.GetInt(); for (int j = 0; j < iMeshesBeard; j++) { fID.GetWord(); } for (int j = 0; j < 2; j++) { int iTextures = fID.GetInt(); for (int t = 0; t < iTextures; t++) { fID.GetWord(); } } int iTexturesFace = fID.GetInt(); for (int j = 0; j < iTexturesFace; j++) { fID.GetWord(); fID.GetWord(); int iHairMats = fID.GetInt(); int iHairColors = fID.GetInt(); for (int m = 0; m < iHairMats; m++) { fID.GetWord(); } for (int c = 0; c < iHairColors; c++) { fID.GetWord(); } } int iVoices = fID.GetInt(); for (int v = 0; v < iVoices; v++) { fID.GetWord(); fID.GetWord(); } fID.GetWord(); fID.GetWord(); fID.GetWord(); fID.GetWord(); int iConstraints = fID.GetInt(); for (int j = 0; j < iConstraints; j++) { fID.GetWord(); fID.GetWord(); int count = fID.GetInt(); for (int c = 0; c < count; c++) { fID.GetWord(); fID.GetWord(); } } } fID.Close(); return(aSkins); }
public static string[] Initialize() { var fID = new Text(Common.InputPath + "/menus.txt"); fID.GetString(); int n = Convert.ToInt32(fID.GetString()); var aMenus = new string[n]; for (int i = 0; i < n; i++) { string strID = fID.GetWord(); aMenus[i] = strID.Remove(0, 5); fID.GetWord(); fID.GetWord(); fID.GetWord(); int iRecords = fID.GetInt(); if (iRecords != 0) { for (int r = 0; r < iRecords; r++) { fID.GetWord(); int iParams = fID.GetInt(); for (int p = 0; p < iParams; p++) { fID.GetWord(); } } } int iMenuOptions = fID.GetInt(); for (int j = 0; j < iMenuOptions; j++) { fID.GetWord(); iRecords = fID.GetInt(); if (iRecords != 0) { for (int r = 0; r < iRecords; r++) { fID.GetWord(); int iParams = fID.GetInt(); for (int p = 0; p < iParams; p++) { fID.GetWord(); } } } fID.GetWord(); iRecords = fID.GetInt(); if (iRecords != 0) { for (int r = 0; r < iRecords; r++) { fID.GetWord(); int iParams = fID.GetInt(); for (int p = 0; p < iParams; p++) { fID.GetWord(); } } } fID.GetWord(); } //idFile.ReadLine(); } fID.Close(); return(aMenus); }
public static void Decompile() { var fMissionTemplates = new Text(Path.Combine(Common.InputPath, "mission_templates.txt")); var fSource = new Win32FileWriter(Path.Combine(Common.OutputPath, "module_mission_templates.py")); fSource.WriteLine(Header.Standard); fSource.WriteLine(Header.MissionTemplates); fMissionTemplates.GetString(); int iMissionTemplates = fMissionTemplates.GetInt(); for (int m = 0; m < iMissionTemplates; m++) { fMissionTemplates.GetWord(); fSource.Write(" (\"{0}\",", fMissionTemplates.GetWord()); var dwFlag = fMissionTemplates.GetDWord(); var sbFlag = new StringBuilder(256); string[] strFlags = { "mtf_arena_fight", "mtf_battle_mode", "mtf_commit_casualties", "mtf_no_blood", "mtf_synch_inventory" }; DWORD[] dwFlags = { 0x00000001, 0x00000002, 0x00000010, 0x00000100, 0x00010000 }; for (int i = 0; i < dwFlags.Length; i++) { if ((dwFlag & dwFlags[i]) == 0) { continue; } dwFlag ^= dwFlags[i]; sbFlag.Append(strFlags[i]); sbFlag.Append('|'); } if (sbFlag.Length == 0) { sbFlag.Append('0'); } else { sbFlag.Length--; } fSource.Write(" {0},", sbFlag.ToString()); var iType = fMissionTemplates.GetInt(); var strType = ""; if (iType == 8) { strType = "charge"; } else if (iType == 10) { strType = "charge_with_ally"; } if (strType.Length > 0) { fSource.WriteLine(" {0},", strType); } else { fSource.WriteLine(" {0},", iType); } fSource.WriteLine(" \"{0}\",\r\n [", fMissionTemplates.GetWord().Replace('_', ' ')); var iSpawnRecords = fMissionTemplates.GetInt(); for (int i = 0; i < iSpawnRecords; i++) { var iNum = fMissionTemplates.GetInt(); var dwSpawnFlag = fMissionTemplates.GetDWord(); var dwAlterFlag = fMissionTemplates.GetDWord(); var dwAIFlag = fMissionTemplates.GetDWord(); var iTroops = fMissionTemplates.GetInt(); var iItems = fMissionTemplates.GetInt(); fSource.Write(" ({0}, {1}, {2}", iNum, DecompileSpawnFlags(dwSpawnFlag), DecompileAlterFlags(dwAlterFlag)); if (dwAIFlag == 0x00000010) { fSource.Write(", aif_start_alarmed"); } else { fSource.Write(", {0}", dwAIFlag); } fSource.Write(", {0}, [", iTroops); var itemsList = new int[iItems]; for (int j = 0; j < iItems; j++) { itemsList[j] = fMissionTemplates.GetInt(); } fSource.WriteLine("{0}]),", String.Join(",", itemsList.Select(t => t <Common.Items.Count && t> -1 ? $"itm_{Common.Items[t]}" : t.ToString(CultureInfo.GetCultureInfo("en-US"))))); } fSource.WriteLine(" ],\r\n ["); int iTriggers = fMissionTemplates.GetInt(); for (int i = 0; i < iTriggers; i++) { fSource.Write(" ("); for (int j = 0; j < 3; j++) { double dInterval = fMissionTemplates.GetDouble(); fSource.Write("{0}, ", Common.GetTriggerParam(dInterval)); } fSource.Write("\r\n ["); int iConditionRecords = fMissionTemplates.GetInt(); if (iConditionRecords != 0) { fSource.WriteLine(); Common.PrintStatement(ref fMissionTemplates, ref fSource, iConditionRecords, " "); fSource.Write(" "); } fSource.Write("],\r\n ["); iConditionRecords = fMissionTemplates.GetInt(); if (iConditionRecords != 0) { fSource.WriteLine(); Common.PrintStatement(ref fMissionTemplates, ref fSource, iConditionRecords, " "); fSource.Write(" "); } fSource.Write("]),\r\n\r\n"); } fSource.Write(" ]),\r\n\r\n"); } fSource.Write("]"); fSource.Close(); fMissionTemplates.Close(); Common.GenerateId("ID_mission_templates.py", Common.MissionTemplates, "mst"); }
public static void Decompile() { var fFactions = new Text(Common.InputPath + "/factions.txt"); var fSource = new Win32FileWriter(Common.OutputPath + "/module_factions.py"); fSource.WriteLine(Header.Standard); fSource.WriteLine(Header.Factions); fFactions.GetString(); int iFactions = fFactions.GetInt(); for (int f = 0; f < iFactions; f++) { string strFacID = fFactions.GetWord(); if (strFacID == "0") { strFacID = fFactions.GetWord(); } string strFacName = fFactions.GetWord(); fSource.Write(" (\"{0}\", \"{1}\",", strFacID.Remove(0, 4), strFacName); string strFlags = ""; DWORD dwFlags = fFactions.GetUInt(); int iRating = ((int)(dwFlags & 0xFF00)) >> 8; if (iRating != 0) { strFlags = $"max_player_rating({100 - iRating})"; } if ((dwFlags & 1) != 0) { if (strFlags != "") { strFlags = strFlags + "|"; } strFlags += "ff_always_hide_label"; } if (strFlags == "") { strFlags = "0"; } fSource.Write(" {0}, 0.0, [", strFlags); DWORD dwColor = fFactions.GetUInt(); string strRelations = ""; for (int r = 0; r < iFactions; r++) { double rRelation = fFactions.GetDouble(); if (Math.Abs(rRelation) > 0.000001) { strRelations += $"(\"{Common.Factions[r]}\", {rRelation.ToString(CultureInfo.GetCultureInfo("en-US"))}),"; } } if (strRelations != "") { strRelations = strRelations.Remove(strRelations.Length - 1, 1); } fSource.Write("{0}], []", strRelations); if (dwColor != 0xAAAAAA) { fSource.Write(", 0x{0:X}", dwColor); } fSource.WriteLine("),"); } fSource.Write("]"); fSource.Close(); fFactions.Close(); Common.GenerateId("ID_factions.py", Common.Factions, "fac"); }
public static string[] Initialize() { if (!File.Exists(Path.Combine(Common.InputPath, "map_icons.txt"))) { return(Array.Empty <string>()); } var fId = new Text(Path.Combine(Common.InputPath, "map_icons.txt")); fId.GetString(); var n = Convert.ToInt32(fId.GetString(), CultureInfo.GetCultureInfo("en-US")); var aMapIcons = new string[n]; for (int i = 0; i < n; i++) { aMapIcons[i] = fId.GetWord(); fId.GetWord(); fId.GetWord(); fId.GetWord(); fId.GetWord(); fId.GetWord(); fId.GetWord(); fId.GetWord(); var iTriggers = fId.GetInt(); for (int t = 0; t < iTriggers; t++) { fId.GetWord(); var iRecords = fId.GetInt(); if (iRecords != 0) { for (int r = 0; r < iRecords; r++) { fId.GetWord(); var iParams = fId.GetInt(); for (int p = 0; p < iParams; p++) { fId.GetWord(); } } } } } fId.Close(); return(aMapIcons); }
public static void PrintStatement(ref Text fInput, ref Win32FileWriter fOutput, int iRecords, string strDefaultIndentation) { int indentations = 0; for (int r = 0; r < iRecords; r++) { long iOpCode = fInput.GetInt64(); string strPrefixNeg = ""; if ((iOpCode & 0x80000000) != 0) { strPrefixNeg = "neg|"; iOpCode ^= 0x80000000; } string strPrefixThisOrNext = ""; if ((iOpCode & 0x40000000) != 0) { strPrefixThisOrNext = "this_or_next|"; iOpCode ^= 0x40000000; } var op = FindOperator((int)(iOpCode & 0xFFFF)); if (iOpCode == 4 || iOpCode == 6 || iOpCode == 7 || iOpCode == 11 || iOpCode == 12 || iOpCode == 15 || iOpCode == 16 || iOpCode == 17 || iOpCode == 18) indentations++; if (iOpCode == 3) indentations--; var strIdentations = iOpCode == 4 || iOpCode == 5 || iOpCode == 6 || iOpCode == 7 || iOpCode == 11 || iOpCode == 12 || iOpCode == 15 || iOpCode == 16 || iOpCode == 17 || iOpCode == 18 ? GetIndentations(indentations - 1) : GetIndentations(indentations); string strOpCode = null; if (strPrefixNeg != "" && iOpCode >= 30 && iOpCode <= 32) { switch (iOpCode) { case 30: strOpCode = "lt"; break; case 31: strOpCode = "neq"; break; case 32: strOpCode = "le"; break; } fOutput.Write("{0}{1}({2}{3}", strIdentations, strDefaultIndentation, strPrefixThisOrNext, strOpCode); } else { /*try { strOpCode = Operations[iOpCode]; } catch (Exception) { strOpCode = Convert.ToString(iOpCode); }*/ //strOpCode = Operations.ContainsKey(iOpCode) ? Operations[iOpCode] : // CustomOperations.HaveCommand((int)(iOpCode & 0x1FFF)) ? CustomOperations.GetCommandName((int)(iOpCode & 0x1FFF)) : Convert.ToString(iOpCode); strOpCode = op.Value; fOutput.Write("{0}{1}({2}{3}{4}", strIdentations, strDefaultIndentation, strPrefixNeg, strPrefixThisOrNext, strOpCode); } int iParams = fInput.GetInt(); for (int p = 0; p < iParams; p++) { string strParam = fInput.GetWord(); fOutput.Write(", {0}", op.GetParameter(p, strParam)); } fOutput.WriteLine("),"); } }
public static string[] Initialize() { var fID = new Text(Common.InputPath + "/map_icons.txt"); fID.GetString(); int n = Convert.ToInt32(fID.GetString()); var aMapIcons = new string[n]; for (int i = 0; i < n; i++) { aMapIcons[i] = fID.GetWord(); fID.GetWord(); fID.GetWord(); fID.GetWord(); fID.GetWord(); fID.GetWord(); fID.GetWord(); fID.GetWord(); int iTriggers = fID.GetInt(); for (int t = 0; t < iTriggers; t++) { //idFile.GetString(); fID.GetWord(); int iRecords = fID.GetInt(); if (iRecords != 0) { for (int r = 0; r < iRecords; r++) { fID.GetWord(); int iParams = fID.GetInt(); for (int p = 0; p < iParams; p++) { fID.GetWord(); } } } } } fID.Close(); return(aMapIcons); }
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"); }
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(); }
public static void Decompile() { var fDialogs = new Text(Common.InputPath + "/conversation.txt"); var fSource = new Win32FileWriter(Common.OutputPath + "/module_dialogs.py"); fSource.WriteLine(Header.Standard); fSource.WriteLine(Header.Dialogs); fDialogs.GetString(); int iDialogs = fDialogs.GetInt(); for (int t = 0; t < iDialogs; t++) { fDialogs.GetWord(); DWORD dwDialogPartner = fDialogs.GetUInt(); int iStartingDialogState = fDialogs.GetInt(); var sbDialogPartner = new StringBuilder(256); string[] strRepeatsPrefix = { "repeat_for_factions", "repeat_for_parties", "repeat_for_troops", "repeat_for_100", "repeat_for_1000" }; uint iRepeat = (dwDialogPartner & 0x00007000) >> 12; if (iRepeat != 0) { sbDialogPartner.Append(strRepeatsPrefix[iRepeat - 1]); sbDialogPartner.Append('|'); } string[] strPartnerPrefix = { "plyr", "party_tpl", "auto_proceed", "multi_line" }; int[] iPartnerPrefix = { 0x00010000, 0x00020000, 0x00040000, 0x00080000 }; for (int i = 0; i < 4; i++) { if ((iPartnerPrefix[i] & dwDialogPartner) != 0) { sbDialogPartner.Append(strPartnerPrefix[i]); sbDialogPartner.Append('|'); } } DWORD dwPartner = dwDialogPartner & 0x00000FFF; if (dwPartner == 0x00000FFF) { sbDialogPartner.Append("anyone|"); } else if (dwPartner != 0) { sbDialogPartner.Append(dwPartner < Common.Troops.Length ? "trp_" + Common.Troops[dwPartner] + "|" : $"{dwPartner}|"); } DWORD dwOther = (dwDialogPartner & 0xFFF00000) >> 20; if (dwOther != 0) { sbDialogPartner.Append(dwOther < Common.Troops.Length ? "other(trp_" + Common.Troops[dwOther] + ")|" : $"other({dwOther})|"); } if (sbDialogPartner.Length == 0) { sbDialogPartner.Append('0'); } else { sbDialogPartner.Length--; } fSource.Write(" [{0}, \"{1}\",\r\n [", sbDialogPartner, Common.DialogStates[iStartingDialogState]); int iRecords = fDialogs.GetInt(); if (iRecords != 0) { fSource.WriteLine(); Common.PrintStatement(ref fDialogs, ref fSource, iRecords, " "); fSource.WriteLine(" ],"); } else { fSource.WriteLine("],"); } string strDialogText = fDialogs.GetWord(); fSource.WriteLine(" \"{0}\",", strDialogText.Replace('_', ' ')); int iEndingDialogState = fDialogs.GetInt(); fSource.Write(" \"{0}\",\r\n [", Common.DialogStates[iEndingDialogState]); iRecords = fDialogs.GetInt(); if (iRecords != 0) { fSource.WriteLine(); Common.PrintStatement(ref fDialogs, ref fSource, iRecords, " "); fSource.Write(" ]"); } else { fSource.Write("]"); } string strVoiceOver = fDialogs.GetWord(); if (strVoiceOver.Trim() != "NO_VOICEOVER") { fSource.Write(",\r\n [\"{0}\"]", strVoiceOver); } fSource.WriteLine("],\r\n"); } fSource.Write("]"); fSource.Close(); fDialogs.Close(); }
public static void Decompile() { var fMissionTemplates = new Text(Common.InputPath + "/mission_templates.txt"); var fSource = new Win32FileWriter(Common.OutputPath + "/module_mission_templates.py"); fSource.WriteLine(Header.Standard); fSource.WriteLine(Header.MissionTemplates); fMissionTemplates.GetString(); int iMissionTemplates = fMissionTemplates.GetInt(); for (int m = 0; m < iMissionTemplates; m++) { fMissionTemplates.GetWord(); fSource.Write(" (\"{0}\",", fMissionTemplates.GetWord()); DWORD dwFlag = fMissionTemplates.GetDWord(); string strFlag = ""; string[] strFlags = { "mtf_arena_fight", "mtf_battle_mode", "mtf_commit_casualties", "mtf_no_blood", "mtf_synch_inventory" }; DWORD[] dwFlags = { 0x00000001, 0x00000002, 0x00000010, 0x00000100, 0x00010000 }; for (int i = 0; i < dwFlags.Length; i++) { if ((dwFlag & dwFlags[i]) != 0) { dwFlag ^= dwFlags[i]; strFlag += strFlags[i] + "|"; } } /*for (int i = dwFlags.Length - 1; i >= 0; i--) * { * if (dwFlag >= dwFlags[i]) * { * strFlag = strFlag + strFlags[i] + "|"; * } * }*/ strFlag = strFlag == "" ? "0" : strFlag.Remove(strFlag.Length - 1, 1); /*var sbFlag = new StringBuilder(256); * string[] strFlags = { "mtf_arena_fight", "mtf_battle_mode", "mtf_commit_casualties", "mtf_no_blood", "mtf_synch_inventory" }; * DWORD[] dwFlags = { 0x00000001, 0x00000002, 0x00000010, 0x00000100, 0x00010000 }; * for (int i = 0; i < dwFlags.Length; i++) * { * if ((dwFlag & dwFlags[i]) != 0) * { * dwFlag ^= dwFlags[i]; * sbFlag.Append(strFlags[i]); * sbFlag.Append('|'); * } * } * if (sbFlag.Length == 0) * sbFlag.Append('0'); * else * sbFlag.Length--;*/ fSource.Write(" {0},", strFlag); int iType = fMissionTemplates.GetInt(); string strType = ""; if (iType == 8) { strType = "charge"; } else if (iType == 10) { strType = "charge_with_ally"; } if (strType != "") { fSource.WriteLine(" {0},", strType); } else { fSource.WriteLine(" {0},", iType); } fSource.WriteLine(" \"{0}\",\r\n [", fMissionTemplates.GetWord().Replace('_', ' ')); int iSpawnRecords = fMissionTemplates.GetInt(); for (int i = 0; i < iSpawnRecords; i++) { int iNum = fMissionTemplates.GetInt(); DWORD dwSpawnFlag = fMissionTemplates.GetDWord(); DWORD dwAlterFlag = fMissionTemplates.GetDWord(); DWORD dwAIFlag = fMissionTemplates.GetDWord(); int iTroops = fMissionTemplates.GetInt(); int iItems = fMissionTemplates.GetInt(); fSource.Write(" ({0}, {1}, {2}", iNum, DecompileSpawnFlags(dwSpawnFlag), DecompileAlterFlags(dwAlterFlag)); if (dwAIFlag == 0x00000010) { fSource.Write(", aif_start_alarmed"); } else { fSource.Write(", {0}", dwAIFlag); } fSource.Write(", {0}, [", iTroops); string strItemList = ""; for (int j = 0; j < iItems; j++) { //fSource.Write("{0},", Common.Items[fMissionTemplates.GetInt()]); strItemList = strItemList + $"itm_{Common.Items[fMissionTemplates.GetInt()]},"; } if (strItemList.Length > 0) { strItemList = strItemList.Remove(strItemList.Length - 1, 1); } fSource.WriteLine("{0}]),", strItemList); } fSource.WriteLine(" ],\r\n ["); int iTriggers = fMissionTemplates.GetInt(); for (int i = 0; i < iTriggers; i++) { fSource.Write(" ("); for (int j = 0; j < 3; j++) { double dInterval = fMissionTemplates.GetDouble(); fSource.Write("{0}, ", Common.GetTriggerParam(dInterval)); } fSource.Write("\r\n ["); int iConditionRecords = fMissionTemplates.GetInt(); if (iConditionRecords != 0) { fSource.WriteLine(); Common.PrintStatement(ref fMissionTemplates, ref fSource, iConditionRecords, " "); fSource.Write(" "); } fSource.Write("],\r\n ["); iConditionRecords = fMissionTemplates.GetInt(); if (iConditionRecords != 0) { fSource.WriteLine(); Common.PrintStatement(ref fMissionTemplates, ref fSource, iConditionRecords, " "); fSource.Write(" "); } fSource.Write("]),\r\n\r\n"); } fSource.Write(" ]),\r\n\r\n"); } fSource.Write("]"); fSource.Close(); fMissionTemplates.Close(); Common.GenerateId("ID_mission_templates.py", Common.MissionTemplates, "mst"); }
public static void Decompile() { var fScenes = new Text(Common.InputPath + "/scenes.txt"); var fSource = new Win32FileWriter(Common.OutputPath + "/module_scenes.py"); fSource.WriteLine(Header.Standard); fSource.WriteLine(Header.Scenes); fScenes.GetString(); int iScenes = fScenes.GetInt(); for (int iS = 0; iS < iScenes; iS++) { fScenes.GetWord(); fSource.Write(" (\"{0}\"", fScenes.GetWord()); DWORD dwFlag = fScenes.GetDWord(); fSource.Write(", {0}, \"{1}\", \"{2}\"", DecompileFlags(dwFlag), fScenes.GetWord(), fScenes.GetWord()); double d1 = fScenes.GetDouble(), d2 = fScenes.GetDouble(); fSource.Write(", ({0}, {1})", d1.ToString(CultureInfo.GetCultureInfo("en-US")), d2.ToString(CultureInfo.GetCultureInfo("en-US"))); d1 = fScenes.GetDouble(); d2 = fScenes.GetDouble(); fSource.Write(", ({0}, {1})", d1.ToString(CultureInfo.GetCultureInfo("en-US")), d2.ToString(CultureInfo.GetCultureInfo("en-US"))); fSource.Write(", {0}, \"{1}\",[", fScenes.GetDouble().ToString(CultureInfo.GetCultureInfo("en-US")), fScenes.GetWord()); int iPassages = fScenes.GetInt(); for (int i = 0; i < iPassages; i++) { int iScene = fScenes.GetInt(); if (iScene == 100000) { fSource.Write("\"exit\""); } //else if (iScene == 0) // fprintf(g_fOutput, "\"\""); else { fSource.Write("\"{0}\"", Common.Scenes[iScene]); } if (i < (iPassages - 1)) { fSource.Write(", "); } } fSource.Write("], ["); int iChestTroops = fScenes.GetInt(); for (int i = 0; i < iChestTroops; i++) { int iTroop = fScenes.GetInt(); if (iTroop < Common.Troops.Length) { fSource.Write("\"{0}\"", Common.Troops[iTroop]); } else { fSource.Write("{0}", iTroop); } if (i < (iChestTroops - 1)) { fSource.Write(", "); } } fSource.Write("]"); string strTerrain = fScenes.GetWord(); if (strTerrain != "0") { fSource.Write(", \"{0}\"", strTerrain); } fSource.WriteLine("),"); } fSource.Write("]"); fSource.Close(); fScenes.Close(); Common.GenerateId("ID_scenes.py", Common.Scenes, "scn"); }
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"); }