-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Seperate patches into different classes (#119)
- Loading branch information
Showing
7 changed files
with
668 additions
and
571 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,193 @@ | ||
using UndertaleModLib; | ||
using UndertaleModLib.Decompiler; | ||
using static YAMS_LIB.ExtensionMethods; | ||
|
||
namespace YAMS_LIB.patches; | ||
|
||
public class AddInGameHints | ||
{ | ||
private static void PatchIceBeamHint(UndertaleData gmData, GlobalDecompileContext decompileContext, SeedObject seedObject) | ||
{ | ||
// Make log in lab always appear | ||
gmData.Code.ByName("gml_Room_rm_a7b04A_Create").ReplaceGMLInCode( "oControl.chozomessage >= 10", "true"); | ||
// Fix hint dissappearing when visiting room right after baby scan | ||
gmData.Code.ByName("gml_Object_oChozoLogMarker_Step_0").ReplaceGMLInCode( "instance_exists(oNotification)", "instance_exists(oNotification) && oNotification.log == 1"); | ||
// Change text to be hint | ||
gmData.Code.ByName("gml_Script_load_logs_list").AppendGMLInCode( $"lbl[44] = \"Ice Beam Hint\"; txt[44, 0] = \"{seedObject.Hints[HintLocationEnum.ChozoLabs]}\"; pic[44, 0] = bgLogImg44B"); | ||
// Remove second scanning | ||
gmData.Code.ByName("gml_Room_rm_a0h01_Create").ReplaceGMLInCode( "scan_log(44, get_text(\"Misc\", \"Translation\"), 180, 1)", "if (false) {}"); | ||
|
||
// Change minimap to include hint | ||
gmData.Code.ByName("gml_Script_map_init_01").ReplaceGMLInCode( "global.map[8, 22] = \"1210300\"", "global.map[8, 22] = \"12103W0\""); | ||
} | ||
|
||
private static void PatchWisdomSeptoggHints(UndertaleData gmData, GlobalDecompileContext decompileContext, SeedObject seedObject) | ||
{ | ||
// Prep work: | ||
// Increase log array size to 100 | ||
gmData.Code.ByName("gml_Script_sv6_add_logs").ReplaceGMLInCode( "repeat (50)", "repeat (100)"); | ||
gmData.Code.ByName("gml_Script_sv6_get_logs").ReplaceGMLInCode( "repeat (50)", "repeat (100)"); | ||
// Replace reset lists with simplified new array range | ||
gmData.Code.ByName("gml_Script_reset_logs").SubstituteGMLCode( """ | ||
var i = 99 | ||
repeat (100) | ||
{ | ||
global.log[i] = 0 | ||
i -= 1 | ||
} | ||
i = 7 | ||
repeat (8) | ||
{ | ||
global.trooperlog[i] = 0 | ||
i -= 1 | ||
} | ||
global.log[0] = 1 | ||
global.log[1] = 1 | ||
global.log[4] = 1 | ||
global.log[5] = 1 | ||
global.log[10] = 1 | ||
global.log[20] = 1 | ||
global.log[30] = 1 | ||
"""); | ||
// Another array extension | ||
gmData.Code.ByName("gml_Script_reset_logs_list").ReplaceGMLInCode( """ | ||
i = 49 | ||
repeat (50) | ||
""", """ | ||
i = 99 | ||
repeat (100) | ||
"""); | ||
// Add 7 new Hint logs to the new category 5 | ||
gmData.Code.ByName("gml_Script_create_log_category").ReplaceGMLInCode( "dlognum = 0", """ | ||
if (argument0 == 5) | ||
{ | ||
clognum = 7 | ||
min_log = 50 | ||
} | ||
dlognum = 0 | ||
"""); | ||
// Add categories | ||
gmData.Code.ByName("gml_Object_oLogScreen_Create_0").ReplaceGMLInCode( "create_log_category(category)", """ | ||
if (global.gotolog >= 50 && global.gotolog < 60) | ||
category = 5 | ||
create_log_category(category) | ||
"""); | ||
// This stuff is for the menu. The array thing might not be needed, but did it anyway, increasing by the same amount as the global.log arrays. | ||
gmData.Code.ByName("gml_Object_oLogScreenControl_Create_0").ReplaceGMLInCode( """ | ||
i = 59 | ||
repeat (60) | ||
""", """ | ||
i = 109 | ||
repeat (110) | ||
"""); | ||
gmData.Code.ByName("gml_Object_oLogScreenControl_Create_0").ReplaceGMLInCode( """ | ||
j += 1 | ||
create_log_label(cat[4]) | ||
create_log_entry(41) | ||
create_log_entry(42) | ||
create_log_entry(43) | ||
create_log_entry(45) | ||
""", """ | ||
if (global.log[41] > 0 || global.log[42] > 0 || global.log[43] > 0 || global.log[45] > 0) | ||
{ | ||
j += 1 | ||
create_log_label(cat[4]) | ||
create_log_entry(41) | ||
create_log_entry(42) | ||
create_log_entry(43) | ||
create_log_entry(45) | ||
} | ||
if (global.log[50] > 0 || global.log[51] > 0 || global.log[52] > 0 || global.log[53] > 0 || global.log[54] > 0 || global.log[55] > 0 || global.log[56] > 0) | ||
{ | ||
j += 1 | ||
create_log_label(cat[5]) | ||
create_log_entry(50) | ||
create_log_entry(51) | ||
create_log_entry(52) | ||
create_log_entry(53) | ||
create_log_entry(54) | ||
create_log_entry(55) | ||
create_log_entry(56) | ||
} | ||
"""); | ||
// Defines the new septogg hint entries | ||
gmData.Code.ByName("gml_Script_load_logs_list").AppendGMLInCode( $""" | ||
cat[5] = "DNA Hints" | ||
lbl[50] = "{seedObject.RoomObjects["rm_a0h13"].RegionName}" | ||
txt[50, 0] = "{seedObject.Hints[HintLocationEnum.SeptoggA0]}" | ||
pic[50, 0] = bgLogDNA0 | ||
lbl[51] = "{seedObject.RoomObjects["rm_a1b02"].RegionName}" | ||
txt[51, 0] = "{seedObject.Hints[HintLocationEnum.SeptoggA1]}" | ||
pic[51, 0] = bgLogDNA1 | ||
lbl[52] = "{seedObject.RoomObjects["rm_a2c05"].RegionName}" | ||
txt[52, 0] = "{seedObject.Hints[HintLocationEnum.SeptoggA2]}" | ||
pic[52, 0] = bgLogDNA2 | ||
lbl[53] = "{seedObject.RoomObjects["rm_a3b10"].RegionName}" | ||
txt[53, 0] = "{seedObject.Hints[HintLocationEnum.SeptoggA3]}" | ||
pic[53, 0] = bgLogDNA3 | ||
lbl[54] = "{seedObject.RoomObjects["rm_a4h03"].RegionName}" | ||
txt[54, 0] = "{seedObject.Hints[HintLocationEnum.SeptoggA4]}" | ||
pic[54, 0] = bgLogDNA4 | ||
lbl[55] = "{seedObject.RoomObjects["rm_a5c17"].RegionName}" | ||
txt[55, 0] = "{seedObject.Hints[HintLocationEnum.SeptoggA5]}" | ||
pic[55, 0] = bgLogDNA5 | ||
lbl[56] = "{seedObject.RoomObjects["rm_a6b02"].RegionName}" | ||
txt[56, 0] = "{seedObject.Hints[HintLocationEnum.SeptoggA6]}" | ||
pic[56, 0] = bgLogDNA6 | ||
"""); | ||
|
||
// Add wisdom septoggs into rooms | ||
var oWisdomSeptogg = gmData.GameObjects.ByName("oWisdomSeptogg"); | ||
|
||
// A0 | ||
gmData.Rooms.ByName("rm_a0h13").GameObjects.Add(CreateRoomObject(55, 194, oWisdomSeptogg)); | ||
gmData.Code.ByName("gml_Room_rm_a0h13_Create").AppendGMLInCode( "create_log_trigger(0, 50, 55, 194, -35, 1)"); | ||
// A1 | ||
gmData.Rooms.ByName("rm_a1b02").GameObjects.Add(CreateRoomObject(144, 670, oWisdomSeptogg)); | ||
gmData.Code.ByName("gml_Room_rm_a1b02_Create").AppendGMLInCode( "create_log_trigger(0, 51, 144, 670, -35, 1)"); | ||
// A2 | ||
gmData.Rooms.ByName("rm_a2c05").GameObjects.Add(CreateRoomObject(115, 310, oWisdomSeptogg)); | ||
gmData.Code.ByName("gml_Room_rm_a2c05_Create").AppendGMLInCode( "create_log_trigger(0, 52, 115, 310, -35, 1)"); | ||
// A3 | ||
gmData.Rooms.ByName("rm_a3b10").GameObjects.Add(CreateRoomObject(768, 396, oWisdomSeptogg)); | ||
gmData.Code.ByName("gml_Room_rm_a3b10_Create").AppendGMLInCode( "create_log_trigger(0, 53, 768, 396, -35, 1)"); | ||
// A4 | ||
gmData.Rooms.ByName("rm_a4h03").GameObjects.Add(CreateRoomObject(88, 523, oWisdomSeptogg)); | ||
gmData.Code.ByName("gml_Room_rm_a4h03_Create").AppendGMLInCode( "create_log_trigger(0, 54, 88, 523, -35, 1)"); | ||
// A5 | ||
gmData.Rooms.ByName("rm_a5c17").GameObjects.Add(CreateRoomObject(246, 670, oWisdomSeptogg)); | ||
gmData.Code.ByName("gml_Room_rm_a5c17_Create").AppendGMLInCode( "create_log_trigger(0, 55, 246, 670, -35, 1)"); | ||
// A6 | ||
gmData.Rooms.ByName("rm_a6b02").GameObjects.Add(CreateRoomObject(240, 400, oWisdomSeptogg)); | ||
gmData.Code.ByName("gml_Room_rm_a6b02_Create").AppendGMLInCode( "create_log_trigger(0, 56, 240, 400, -35, 1)"); | ||
|
||
|
||
// Change minimap to include hint | ||
// A0 | ||
gmData.Code.ByName("gml_Script_map_init_09").ReplaceGMLInCode( "global.map[41, 24] = \"2201100\"", "global.map[41, 24] = \"22011W0\""); | ||
|
||
// A1 | ||
gmData.Code.ByName("gml_Script_map_init_12").ReplaceGMLInCode( "global.map[58, 16] = \"0212200\"", "global.map[58, 16] = \"02122W0\""); | ||
|
||
// A2 | ||
gmData.Code.ByName("gml_Script_map_init_04").ReplaceGMLInCode( "global.map[24, 26] = \"0101200\"", "global.map[24, 26] = \"01012W0\""); | ||
|
||
// A3 | ||
gmData.Code.ByName("gml_Script_map_init_14").ReplaceGMLInCode( "global.map[63, 28] = \"0011200\"", "global.map[63, 28] = \"00112W0\""); | ||
|
||
// A4 | ||
gmData.Code.ByName("gml_Script_map_init_05").ReplaceGMLInCode( "global.map[32, 29] = \"0021200\"", "global.map[32, 29] = \"00212W0\""); | ||
|
||
// A5 | ||
gmData.Code.ByName("gml_Script_map_init_16").ReplaceGMLInCode( "global.map[69, 45] = \"0112300\"", "global.map[69, 45] = \"01123W0\""); | ||
|
||
// A6 | ||
gmData.Code.ByName("gml_Script_map_init_03").ReplaceGMLInCode( "global.map[20, 40] = \"0112100\"", "global.map[20, 40] = \"01121W0\""); | ||
} | ||
|
||
public static void Apply(UndertaleData gmData, GlobalDecompileContext decompileContext, SeedObject seedObject) | ||
{ | ||
PatchIceBeamHint(gmData, decompileContext, seedObject); | ||
PatchWisdomSeptoggHints(gmData, decompileContext, seedObject); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,145 @@ | ||
using UndertaleModLib; | ||
using UndertaleModLib.Decompiler; | ||
using UndertaleModLib.Models; | ||
using static YAMS_LIB.ExtensionMethods; | ||
|
||
namespace YAMS_LIB.patches; | ||
|
||
public class DoorLockRando | ||
{ | ||
public static void Apply(UndertaleData gmData, GlobalDecompileContext decompileContext, SeedObject seedObject) | ||
{ | ||
var characterVarsCode = gmData.Code.ByName("gml_Script_load_character_vars"); | ||
|
||
// Adjust global event array to be 700 | ||
characterVarsCode.ReplaceGMLInCode( """ | ||
i = 350 | ||
repeat (350) | ||
{ | ||
i -= 1 | ||
global.event[i] = 0 | ||
} | ||
""", """ | ||
i = 700 | ||
repeat (700) | ||
{ | ||
i -= 1 | ||
global.event[i] = 0 | ||
} | ||
"""); | ||
gmData.Code.ByName("gml_Script_sv6_add_events").ReplaceGMLInCode( "350", "700"); | ||
gmData.Code.ByName("gml_Script_sv6_get_events").ReplaceGMLInCode( "350", "700"); | ||
|
||
// Replace every normal, a4 and a8 door with an a5 door for consistency | ||
var a5Door = gmData.GameObjects.ByName("oDoorA5"); | ||
foreach (var room in gmData.Rooms) | ||
{ | ||
foreach (var door in room.GameObjects.Where(go => go.ObjectDefinition.Name.Content.StartsWith("oDoor"))) | ||
{ | ||
door.ObjectDefinition = a5Door; | ||
} | ||
} | ||
// Also fix depth value for them | ||
a5Door.Depth = -99; | ||
|
||
|
||
var doorEventIndex = 350; | ||
foreach ((var id, var doorLock) in seedObject.DoorLocks) | ||
{ | ||
bool found = false; | ||
foreach (var room in gmData.Rooms) | ||
{ | ||
foreach (var gameObject in room.GameObjects) | ||
{ | ||
if (gameObject.InstanceID != id) continue; | ||
|
||
if (!gameObject.ObjectDefinition.Name.Content.StartsWith("oDoor") && gameObject.ObjectDefinition.Name.Content != "oA2BigTurbine") | ||
throw new NotSupportedException($"The 'door' instance {id} is not actually a door!"); | ||
|
||
found = true; | ||
if (gameObject.CreationCode is null) | ||
{ | ||
var code = new UndertaleCode() { Name = gmData.Strings.MakeString($"gml_RoomCC_{room.Name.Content}_{id}_Create") }; | ||
gmData.Code.Add(code); | ||
gameObject.CreationCode = code; | ||
} | ||
|
||
string codeText = doorLock.Lock switch | ||
{ | ||
DoorLockType.Normal => "lock = 0; event = -1;", | ||
DoorLockType.Missile => $"lock = 1; originalLock = lock; event = {doorEventIndex};", | ||
DoorLockType.SuperMissile => $"lock = 2; originalLock = lock; event = {doorEventIndex};", | ||
DoorLockType.PBomb => $"lock = 3; originalLock = lock; event = {doorEventIndex};", | ||
DoorLockType.TempLocked => $"lock = 4; originalLock = lock; event = -1;", | ||
DoorLockType.Charge => $"lock = 5; originalLock = lock; event = -1;", | ||
DoorLockType.Wave => $"lock = 6; originalLock = lock; event = -1;", | ||
DoorLockType.Spazer => $"lock = 7; originalLock = lock; event = -1;", | ||
DoorLockType.Plasma => $"lock = 8; originalLock = lock; event = -1;", | ||
DoorLockType.Ice => $"lock = 9; originalLock = lock; event = -1;", | ||
DoorLockType.Bomb => "lock = 10; originalLock = lock; event = -1;", | ||
DoorLockType.Spider => "lock = 11; originalLock = lock; event = -1;", | ||
DoorLockType.Screw => "lock = 12; originalLock = lock; event = -1;", | ||
DoorLockType.TowerEnabled => "lock = 13; originalLock = lock; event = -1;", | ||
DoorLockType.TesterDead => "lock = 14; originalLock = lock; event = -1;", | ||
DoorLockType.GuardianDead => "lock = 15; originalLock = lock; event = -1;", | ||
DoorLockType.ArachnusDead => "lock = 16; originalLock = lock; event = -1;", | ||
DoorLockType.TorizoDead => "lock = 17; originalLock = lock; event = -1;", | ||
DoorLockType.SerrisDead => "lock = 18; originalLock = lock; event = -1;", | ||
DoorLockType.GenesisDead => "lock = 19; originalLock = lock; event = -1;", | ||
DoorLockType.QueenDead => "lock = 20; originalLock = lock; event = -1;", | ||
DoorLockType.EMPActivated => "lock = 21; originalLock = lock; event = -1;", | ||
DoorLockType.EMPA1 => "lock = 22; originalLock = lock; event = -1;", | ||
DoorLockType.EMPA2 => "lock = 23; originalLock = lock; event = -1;", | ||
DoorLockType.EMPA3 => "lock = 24; originalLock = lock; event = -1;", | ||
DoorLockType.EMPA5Tutorial => "lock = 25; originalLock = lock; event = -1;", | ||
DoorLockType.EMPA5RobotHome => "lock = 26; originalLock = lock; event = -1;", | ||
DoorLockType.EMPA5NearZeta => "lock = 27; originalLock = lock; event = -1;", | ||
DoorLockType.EMPA5BulletHell => "lock = 28; originalLock = lock; event = -1;", | ||
DoorLockType.EMPA5PipeHub => "lock = 29; originalLock = lock; event = -1;", | ||
DoorLockType.EMPA5RightExterior => "lock = 30; originalLock = lock; event = -1;", | ||
DoorLockType.Locked => "lock = 31; originalLock = lock; event = -1;", | ||
DoorLockType.A2WaterTurbine => $"eventToSet = {doorEventIndex};" + | ||
$"if (global.event[eventToSet] > 0)" + | ||
$"{{ if (!wasAlreadyDestroyed) {{ with (wall) instance_destroy(); }} instance_destroy();}} " + | ||
$"if (wasAlreadyDestroyed && global.event[eventToSet] < 1) global.event[eventToSet] = 1;", | ||
_ => throw new NotSupportedException($"Door {id} has an unsupported door lock ({doorLock.Lock})!") | ||
}; | ||
|
||
var waterTurbineObject = gmData.GameObjects.ByName("oA2BigTurbine"); | ||
if (gameObject.ObjectDefinition == waterTurbineObject && doorLock.Lock != DoorLockType.A2WaterTurbine) | ||
{ | ||
gameObject.ObjectDefinition = gmData.GameObjects.ByName("oDoorA5"); | ||
gameObject.X += (24 * (int)gameObject.ScaleX); | ||
gameObject.ScaleX *= -1; | ||
bool leftFacing = gameObject.ScaleX < 0; | ||
room.Tiles.Add(CreateRoomTile(gameObject.X - (leftFacing ? 8 : 24), gameObject.Y, -110, gmData.Backgrounds.ByName("tlDoor"), (leftFacing ? 0u : 32u), 0, 32, 64)); | ||
var tilesToDelete = room.Tiles.Where((t => (t is { X: 912, Y: 1584, SourceX: 48, SourceY: 304 } or { X: 928, Y: 1536, SourceX: 96, SourceY: 304 }))).ToList(); | ||
foreach (var tile in tilesToDelete) | ||
room.Tiles.Remove(tile); | ||
} | ||
|
||
if (gameObject.ObjectDefinition != waterTurbineObject && doorLock.Lock == DoorLockType.A2WaterTurbine) | ||
{ | ||
gameObject.ObjectDefinition = waterTurbineObject; | ||
gameObject.X += (24 * (int)gameObject.ScaleX); | ||
gameObject.ScaleX *= -1; | ||
if ((gameObject.X - 48) == 0) | ||
room.GameObjects.Add(CreateRoomObject(gameObject.X-72, gameObject.Y, gmData.GameObjects.ByName("oSolid1x4"))); | ||
else if ((gameObject.X + 48) == room.Width) | ||
room.GameObjects.Add(CreateRoomObject(gameObject.X+72, gameObject.Y, gmData.GameObjects.ByName("oSolid1x4"))); | ||
|
||
} | ||
|
||
gameObject.CreationCode.AppendGMLInCode( codeText); | ||
doorEventIndex++; | ||
break; | ||
} | ||
|
||
if (found) break; | ||
} | ||
|
||
if (!found) | ||
throw new NotSupportedException($"There is no door with ID {id}!"); | ||
} | ||
} | ||
} |
Oops, something went wrong.