Skip to content

Commit 84f759e

Browse files
authored
Merge pull request #99 from ModShardTeam/Dev
Merging Dev branch to main
2 parents 6dd3249 + 499d191 commit 84f759e

34 files changed

+2765
-1355
lines changed

Controls/SourceBar.xaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@
1717
RenderOptions.BitmapScalingMode="NearestNeighbor"
1818
RenderOptions.ClearTypeHint="Enabled"/>
1919
</Border>
20-
<Label Name="ModName" HorizontalAlignment="Left"
21-
Margin="16,16,0,0" VerticalAlignment="Top"
22-
Content="{Binding Name}" Foreground="White"
23-
FontSize="15" Style="{StaticResource xFont}"/>
20+
<TextBlock Name="ModName" HorizontalAlignment="Left"
21+
Margin="16,16,0,0" VerticalAlignment="Top"
22+
Text="{Binding Name}" Foreground="White"
23+
FontSize="15" Style="{StaticResource sFont}"/>
2424
<Button x:Name="CompileButton" Width="120" Height="39"
2525
VerticalAlignment="Bottom" HorizontalAlignment="Right"
2626
Margin="0,0,168,12" Padding="0" BorderBrush="Transparent"

DataLoader.cs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,16 @@ private static string ComputeChecksum(FileStream stream)
122122
private static bool CompareChecksum(FileStream stream)
123123
{
124124
string hash = ComputeChecksum(stream);
125-
const string hashGog = "6E37E076EDFDC25468195EC1FFA937A5";
126-
const string hashSteam = "392EE0E8C6A09A16DED58C5737ECF1B5";
127-
return hash == hashGog || hash == hashSteam;
125+
// Log.Information(hash); // uncomment to log the checksum of new versions and add to the array
126+
string[] checksums =
127+
{
128+
"6E37E076EDFDC25468195EC1FFA937A5", // GOG 0.8.2.10
129+
"392EE0E8C6A09A16DED58C5737ECF1B5", // Steam 0.8.2.10
130+
"5F91989CA7E2A2B1234B2CD2A6AF9821", // Steam 0.9.1.16-vm
131+
"2BD331F728428746FA337D6C7B67040A", // Steam 0.9.1.17-vm
132+
"6F9F1E29275EEF60E3A725ECA1033DF8" // Steam 0.9.1.18-vm
133+
};
134+
return checksums.Contains(hash);
128135
}
129136
private static bool LoadUmt(string filename)
130137
{
@@ -133,7 +140,7 @@ private static bool LoadUmt(string filename)
133140
{
134141
if(!CompareChecksum(stream))
135142
{
136-
Log.Warning("Checksum inconsistency, {{{0}}} is not vanilla.", filename);
143+
Log.Warning("Checksum inconsistency, {{{0}}} may not be vanilla or is a new version.", filename);
137144
}
138145
data = UndertaleIO.Read(
139146
stream, warning =>

Main.xaml.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
using System.Runtime.InteropServices;
1414
using ModShardLauncher.Mods;
1515
using System.Diagnostics;
16+
using UndertaleModLib.Models;
1617

1718
namespace ModShardLauncher
1819
{
@@ -36,6 +37,7 @@ public partial class Main : Window
3637
public const int SW_SHOW = 5;
3738
public static IntPtr handle;
3839
public string mslVersion;
40+
public string utmtlibVersion;
3941
//
4042
private const double DefaultWidth = 960; // Исходная ширина
4143
private const double DefaultHeight = 800; // Исходная высота
@@ -75,13 +77,14 @@ public Main()
7577
ProcessModule mainProcess = Msl.ThrowIfNull(Process.GetCurrentProcess().MainModule);
7678
string mainProcessName = Msl.ThrowIfNull(mainProcess.FileName);
7779
mslVersion = "v" + FileVersionInfo.GetVersionInfo(mainProcessName).FileVersion;
80+
utmtlibVersion = "v" + FileVersionInfo.GetVersionInfo(typeof(UndertaleCode).Assembly.Location).FileVersion;
7881
}
7982
catch (FileNotFoundException ex)
8083
{
8184
Log.Error(ex, "Cannot find the dll of ModShardLauncher");
8285
throw;
8386
}
84-
Log.Information("Launching msl {{{0}}}", mslVersion);
87+
Log.Information("Launching msl {{{0}}} using UTMT {{{1}}}", mslVersion, utmtlibVersion);
8588

8689
try
8790
{

ModLoader.cs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public static void ShowMessage(string msg)
3636
public static void Initalize()
3737
{
3838
Weapons = Msl.ThrowIfNull(GetTable("gml_GlobalScript_table_weapons"));
39-
WeaponDescriptions = Msl.ThrowIfNull(GetTable("gml_GlobalScript_table_weapons_text"));
39+
WeaponDescriptions = Msl.ThrowIfNull(GetTable("gml_GlobalScript_table_equipment"));
4040
}
4141
internal static void AddCredit(string modNameShort, string[] authors)
4242
{
@@ -175,6 +175,8 @@ public static void PatchMods()
175175
Disclaimers = new();
176176
List<ModFile> mods = ModInfos.Instance.Mods;
177177
Menus = new();
178+
179+
Stopwatch watch = Stopwatch.StartNew();
178180
foreach (ModFile mod in mods)
179181
{
180182
if (!mod.isEnabled) continue;
@@ -202,6 +204,10 @@ public static void PatchMods()
202204
Msl.AddDisclaimerRoom(Credits.Select(x => x.Item1).ToArray(), Credits.SelectMany(x => x.Item2).Distinct().ToArray());
203205
Msl.ChainDisclaimerRooms(Disclaimers);
204206
Msl.CreateMenu(Menus);
207+
208+
watch.Stop();
209+
long elapsedMs = watch.ElapsedMilliseconds;
210+
Log.Information("Patching lasts {{{0}}} ms", elapsedMs);
205211
}
206212
public static void LoadWeapon(Type type)
207213
{
@@ -226,8 +232,8 @@ public static void PatchFile()
226232
}
227233
internal static void PatchInnerFile()
228234
{
229-
if (Data.Code.All(x => x.Name.Content != "print"))
230-
Msl.AddInnerFunction("print");
235+
if (Data.Code.All(x => x.Name.Content != "msl_print"))
236+
Msl.AddInnerFunction("msl_print");
231237
if (Data.Code.All(x => x.Name.Content != "give"))
232238
Msl.AddInnerFunction("give");
233239
if (Data.Code.All(x => x.Name.Content != "SendMsg"))

ModShardLauncher.csproj

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,22 @@
99
<ApplicationIcon>ico.ico</ApplicationIcon>
1010
<EnableDefaultCompileItems>false</EnableDefaultCompileItems>
1111
<SatelliteResourceLanguages>zh-Hans</SatelliteResourceLanguages>
12-
<FileVersion>0.12.1.0</FileVersion>
12+
<FileVersion>0.13.1.0</FileVersion>
1313
</PropertyGroup>
1414

1515
<ItemGroup> <!-- Include the specific files to exclude the ones in the test folder -->
1616
<Compile Include="*.cs" Exclude="bin\**;obj\**;ModShardLauncherTest\**.*cs" />
17-
<Compile Include="ModUtils\TableUtils\ConsumParam.cs" />
18-
<Compile Include="ModUtils\TableUtils\Contract.cs" />
19-
<Compile Include="ModUtils\TableUtils\CreditsBackers.cs" />
20-
<Compile Include="ModUtils\TableUtils\EnemyBalance.cs" />
21-
<Compile Include="ModUtils\TableUtils\Potion.cs" />
22-
<Compile Include="ModUtils\TableUtils\SkillsStat.cs" />
17+
<Compile Include="ModUtils\TableUtils\Backers.cs" />
18+
<Compile Include="ModUtils\TableUtils\ContractsStats.cs" />
19+
<Compile Include="ModUtils\TableUtils\Drops.cs" />
20+
<Compile Include="ModUtils\TableUtils\DungeonsSpawn.cs" />
21+
<Compile Include="ModUtils\TableUtils\ItemStats.cs" />
22+
<Compile Include="ModUtils\TableUtils\MobsStats.cs" />
23+
<Compile Include="ModUtils\TableUtils\PotionsStats.cs" />
24+
<Compile Include="ModUtils\TableUtils\RecipesCook.cs" />
25+
<Compile Include="ModUtils\TableUtils\RecipesCraft.cs" />
26+
<Compile Include="ModUtils\TableUtils\SkillsStats.cs" />
27+
<Compile Include="ModUtils\TableUtils\SurfaceSpawn.cs" />
2328
<Compile Include="ModUtils\TableUtils\TableArmor.cs" />
2429
<Compile Include="ModUtils\TableUtils\TableUtils.cs" />
2530
<Compile Include="ModUtils\TableUtils\LocalizationUtils.cs" />
@@ -211,4 +216,11 @@
211216
<Copy SourceFiles="ModReference\netstandard.dll;ModReference\System.Collections.dll;ModReference\System.Runtime.dll;ModReference\System.Linq.dll;ModReference\System.ObjectModel.dll" DestinationFolder="$(OutDir)" />
212217
</Target>
213218

219+
<Target Name="CopyDevFiles" AfterTargets="Publish">
220+
<Copy SourceFiles="Resources\ExportRoom.csx" DestinationFolder="$(PublishDir)" />
221+
<Copy SourceFiles="Reference\UndertaleModLib.dll" DestinationFolder="$(PublishDir)" />
222+
<Copy SourceFiles="Reference\UndertaleModTool.dll" DestinationFolder="$(PublishDir)" />
223+
<Copy SourceFiles="$(OutputPath)ModShardLauncher.dll" DestinationFolder="$(PublishDir)" />
224+
</Target>
225+
214226
</Project>

ModUtils/CodeUtils.cs

Lines changed: 0 additions & 165 deletions
Original file line numberDiff line numberDiff line change
@@ -444,20 +444,6 @@ public static string Collect(this FileEnumerable<(Match, string)> fe)
444444
if (otherEnumerator.MoveNext())
445445
otherString = otherEnumerator.Current;
446446

447-
//TODO Delete (Necromancy)
448-
if (otherString == "var XP = math_round((")
449-
{
450-
otherString = "var XP = math_round(";
451-
}
452-
else if (otherString == "return 1")
453-
{
454-
otherString = "return false";
455-
}
456-
457-
//TODO Delete (UI+ 2.0.0)
458-
if (otherString == " is_activate = _notEmpty")
459-
otherString = "is_activate = _notEmpty";
460-
461447
foreach (string element in ienumerable)
462448
{
463449
if (m != Match.After && otherString != null && element.Contains(otherString))
@@ -471,16 +457,6 @@ public static string Collect(this FileEnumerable<(Match, string)> fe)
471457
m = Match.After;
472458
}
473459

474-
//TODO Delete (CraftableArrows)
475-
if(otherString == " select = 1")
476-
{
477-
otherString = " select = true";
478-
}
479-
else if(otherString == " global.inv_select = 1")
480-
{
481-
otherString = " global.inv_select = true";
482-
}
483-
484460
}
485461
else
486462
{
@@ -633,12 +609,6 @@ public static string Collect(this FileEnumerable<(Match, string)> fe)
633609
if (otherUntilEnumerator.MoveNext())
634610
otherUntilString = otherUntilEnumerator.Current;
635611

636-
//TODO Delete (ArtifactKnowledge)
637-
if(otherUntilString == " _create_exit = 1")
638-
{
639-
otherUntilString = " _create_exit = true";
640-
}
641-
642612
foreach ((Match m, string element) in ienumerable.MatchFrom(otherfrom))
643613
{
644614
if (m == Match.Before || m == Match.Matching)
@@ -973,141 +943,6 @@ public static IEnumerable<string> Apply(this IEnumerable<string> ienumerable, Fu
973943
/// </summary>
974944
public static FileEnumerable<string> Apply(this FileEnumerable<string> fe, Func<IEnumerable<string>, IEnumerable<string>> iterator)
975945
{
976-
//TODO Delete SpeedShard
977-
#region SpeedShard
978-
if (fe.header.fileName == "gml_GlobalScript_scr_loot_chestRemoteBastion")
979-
{
980-
var newEnumerable = new List<string>
981-
{
982-
"var _temp_local_var_2;",
983-
"function scr_loot_chestRemoteBastion() //gml_Script_scr_loot_chestRemoteBastion",
984-
"{",
985-
" var lvl = 1;",
986-
" var min_lvl = scr_globaltile_dungeon_get(\"mob_lvl_min\");",
987-
" var max_lvl = scr_globaltile_dungeon_get(\"mob_lvl_max\");",
988-
" var tier = floor(((max_lvl + min_lvl) / 2));",
989-
" lootScriptShowData(tier);",
990-
" var predicat = scr_loot_allweapon();",
991-
" with (o_player)",
992-
" lvl = (scr_atr(\"LVL\") + random_range(0, 4));",
993-
" var _temp_local_var_2 = tier;",
994-
" with (scr_inventory_add_item(o_inv_moneybag))",
995-
" ds_map_replace(data, \"Stack\", (300 + irandom_range(300, 600)));",
996-
" if scr_chance_value(50)",
997-
" scr_inventory_add_weapon(scr_find_weapon_params(15, 25, scr_loot_weapon()));",
998-
" else if scr_chance_value(50)",
999-
" scr_inventory_add_weapon(scr_find_weapon_params(15, 25, scr_loot_armor()));",
1000-
" if scr_chance_value(75)",
1001-
" scr_inventory_add_item(choose(3050, 3086));",
1002-
" if scr_chance_value(100)",
1003-
" {",
1004-
" var gems = choose(3016, 3014, 3017, 3013);",
1005-
" var precious = choose(2951, 2952, 2953);",
1006-
" var goods = choose(2963, 2964, 2966, 2961);",
1007-
" scr_inventory_add_item(choose(gems, precious, goods));",
1008-
" }",
1009-
" if scr_chance_value(50)",
1010-
" scr_inventory_add_item(choose(3243, 4570, 340, 579, 2609), id, -4, 1, -4, 1, 1);",
1011-
" else",
1012-
" {",
1013-
" with (scr_inventory_add_weapon(choose(\"Jarl Blade\", \"Royal Sword\", \"Relict Blade\", \"Guard Broadsword\", \"Decorated Saber\", \"Ancient Scimitar\", \"Gilded Axe\", \"Feudal Axe\", \"Decorated Flanged Mace\", \"Decorated Warhammer\", \"Ornate Greatsword\", \"Espadon\", \"Faceless Spear\", \"Decorated Voulge\", \"Ornate Longaxe\", \"Exquisite Grandmace\", \"Relict Polehammer\", \"Decorated Longbow\", \"Relic Bow\", \"Guard Crossbow\", \"Orient Staff\", \"Relict Staff\", \"Hermit Staff\", \"Guardian Shield\", \"Sun Shield\", \"Uroboros Shield\", \"Engraved Boots\", \"Decorated Barbute\", \"Joust Bascinet\", \"Joust Topfhelm\", \"Pigfaced Bascinet\", \"Decorated Sallet\", \"Mastercrafted Sallet\", \"Hermit Circlet\", \"Royal Ranger Gambeson\", \"Ceremonial Cuirass\", \"Vagabond Knight Armor\", \"Joust Armor\", \"Hermit Ring\"), (6 << 0)))",
1014-
" scr_inv_atr_set(\"Duration\", irandom_range(35, 60));",
1015-
" }",
1016-
" scr_random_speech(\"containerRich\");",
1017-
"}"
1018-
};
1019-
1020-
return new FileEnumerable<string>(fe.header, iterator(newEnumerable));
1021-
}
1022-
else if (fe.header.fileName == "gml_GlobalScript_scr_loot_chestRemoteCrypt")
1023-
{
1024-
var newEnumerable = new List<string>
1025-
{
1026-
"var _temp_local_var_2;",
1027-
"function scr_loot_chestRemoteCrypt() //gml_Script_scr_loot_chestRemoteCrypt",
1028-
"{",
1029-
" var lvl = 1;",
1030-
" var min_lvl = scr_globaltile_dungeon_get(\"mob_lvl_min\");",
1031-
" var max_lvl = scr_globaltile_dungeon_get(\"mob_lvl_max\");",
1032-
" var tier = floor(((max_lvl + min_lvl) / 2));",
1033-
" lootScriptShowData(tier);",
1034-
" var predicat = scr_loot_allweapon();",
1035-
" with (o_player)",
1036-
" lvl = (scr_atr(\"LVL\") + random_range(0, 4));",
1037-
" var _temp_local_var_2 = tier;",
1038-
" with (scr_inventory_add_item(o_inv_moneybag))",
1039-
" ds_map_replace(data, \"Stack\", (300 + irandom_range(300, 600)));",
1040-
" if scr_chance_value(50)",
1041-
" scr_inventory_add_weapon(scr_find_weapon_params(15, 25, scr_loot_weapon()));",
1042-
" else if scr_chance_value(50)",
1043-
" scr_inventory_add_weapon(scr_find_weapon_params(15, 25, scr_loot_armor()));",
1044-
" if scr_chance_value(75)",
1045-
" scr_inventory_add_item(choose(3050, 3086));",
1046-
" if scr_chance_value(100)",
1047-
" {",
1048-
" var gems = choose(3016, 3014, 3017, 3013);",
1049-
" var precious = choose(2951, 2952, 2953);",
1050-
" var goods = choose(2963, 2964, 2966, 2961);",
1051-
" scr_inventory_add_item(choose(gems, precious, goods));",
1052-
" }",
1053-
" if scr_chance_value(50)",
1054-
" scr_inventory_add_item(choose(6365, 818, 1579, 104, 822, 2609), id, -4, 1, -4, 1, 1);",
1055-
" else",
1056-
" {",
1057-
" with (scr_inventory_add_weapon(choose(\"Jarl Blade\", \"Royal Sword\", \"Relict Blade\", \"Guard Broadsword\", \"Decorated Saber\", \"Ancient Scimitar\", \"Gilded Axe\", \"Feudal Axe\", \"Decorated Flanged Mace\", \"Decorated Warhammer\", \"Ornate Greatsword\", \"Espadon\", \"Faceless Spear\", \"Decorated Voulge\", \"Ornate Longaxe\", \"Exquisite Grandmace\", \"Relict Polehammer\", \"Decorated Longbow\", \"Relic Bow\", \"Guard Crossbow\", \"Orient Staff\", \"Relict Staff\", \"Hermit Staff\", \"Guardian Shield\", \"Sun Shield\", \"Uroboros Shield\", \"Engraved Boots\", \"Decorated Barbute\", \"Joust Bascinet\", \"Joust Topfhelm\", \"Pigfaced Bascinet\", \"Decorated Sallet\", \"Mastercrafted Sallet\", \"Hermit Circlet\", \"Royal Ranger Gambeson\", \"Ceremonial Cuirass\", \"Vagabond Knight Armor\", \"Joust Armor\", \"Druid Robe\", \"Hermit Ring\"), (6 << 0)))",
1058-
" scr_inv_atr_set(\"Duration\", irandom_range(35, 60));",
1059-
" }",
1060-
" scr_random_speech(\"containerRich\");",
1061-
"}"
1062-
};
1063-
1064-
return new FileEnumerable<string>(fe.header, iterator(newEnumerable));
1065-
}
1066-
else if (fe.header.fileName == "gml_GlobalScript_scr_loot_chestRemoteCatacombs")
1067-
{
1068-
var newEnumerable = new List<string>
1069-
{
1070-
"var _temp_local_var_2;",
1071-
"function scr_loot_chestRemoteCatacombs() //gml_Script_scr_loot_chestRemoteCatacombs",
1072-
"{",
1073-
" var lvl = 1;",
1074-
" var min_lvl = scr_globaltile_dungeon_get(\"mob_lvl_min\");",
1075-
" var max_lvl = scr_globaltile_dungeon_get(\"mob_lvl_max\");",
1076-
" var tier = floor(((max_lvl + min_lvl) / 2));",
1077-
" lootScriptShowData(tier);",
1078-
" var predicat = scr_loot_allweapon();",
1079-
" with (o_player)",
1080-
" lvl = (scr_atr(\"LVL\") + random_range(0, 4));",
1081-
" var _temp_local_var_2 = tier;",
1082-
" with (scr_inventory_add_item(o_inv_moneybag))",
1083-
" ds_map_replace(data, \"Stack\", (300 + irandom_range(300, 600)));",
1084-
" if scr_chance_value(25)",
1085-
" scr_inventory_add_weapon(scr_find_weapon_params(15, 25, scr_loot_weapon()));",
1086-
" else if scr_chance_value(25)",
1087-
" scr_inventory_add_weapon(scr_find_weapon_params(15, 25, scr_loot_armor()));",
1088-
" if scr_chance_value(50)",
1089-
" scr_inventory_add_item(choose(3050, 3086));",
1090-
" if scr_chance_value(100)",
1091-
" {",
1092-
" var gems = choose(3016, 3014, 3017, 3013);",
1093-
" var precious = choose(2951, 2952, 2953);",
1094-
" var goods = choose(2963, 2964, 2966, 2961);",
1095-
" scr_inventory_add_item(choose(gems, precious, goods));",
1096-
" }",
1097-
" if scr_chance_value(50)",
1098-
" scr_inventory_add_item(choose(818, 104, 6365, 579, 2609), id, -4, 1, -4, 1, 1);",
1099-
" else",
1100-
" {",
1101-
" with (scr_inventory_add_weapon(choose(\"Jarl Blade\", \"Royal Sword\", \"Relict Blade\", \"Guard Broadsword\", \"Decorated Saber\", \"Ancient Scimitar\", \"Gilded Axe\", \"Feudal Axe\", \"Decorated Flanged Mace\", \"Decorated Warhammer\", \"Ornate Greatsword\", \"Espadon\", \"Faceless Spear\", \"Decorated Voulge\", \"Ornate Longaxe\", \"Exquisite Grandmace\", \"Relict Polehammer\", \"Decorated Longbow\", \"Relic Bow\", \"Guard Crossbow\", \"Orient Staff\", \"Relict Staff\", \"Guardian Shield\", \"Sun Shield\", \"Uroboros Shield\", \"Engraved Boots\", \"Decorated Barbute\", \"Joust Bascinet\", \"Joust Topfhelm\", \"Pigfaced Bascinet\", \"Decorated Sallet\", \"Mastercrafted Sallet\", \"Royal Ranger Gambeson\", \"Ceremonial Cuirass\", \"Vagabond Knight Armor\", \"Druid Robe\", \"Hermit Ring\"), (6 << 0)))",
1102-
" scr_inv_atr_set(\"Duration\", irandom_range(35, 60));",
1103-
" }",
1104-
" scr_random_speech(\"containerRich\");",
1105-
"}"
1106-
};
1107-
1108-
return new FileEnumerable<string>(fe.header, iterator(newEnumerable));
1109-
}
1110-
#endregion
1111946
return new(fe.header, fe.ienumerable.Apply(iterator));
1112947
}
1113948
/// <summary>

0 commit comments

Comments
 (0)