Skip to content

Commit

Permalink
feat: p5 teleport
Browse files Browse the repository at this point in the history
  • Loading branch information
Clazex committed Jan 28, 2022
1 parent 2861056 commit 17f1f3c
Show file tree
Hide file tree
Showing 8 changed files with 106 additions and 1 deletion.
4 changes: 4 additions & 0 deletions GodSeekerPlus/GodSeekerPlus.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@
<HintPath>$(HKRefs)/UnityEngine.CoreModule.dll</HintPath>
<Private>false</Private>
</Reference>
<Reference Include="UnityEngine.Physics2DModule">
<HintPath>$(HKRefs)/UnityEngine.Physics2DModule.dll</HintPath>
<Private>false</Private>
</Reference>
<Reference Include="UnityEngine.UI">
<HintPath>$(HKRefs)/UnityEngine.UI.dll</HintPath>
<Private>false</Private>
Expand Down
2 changes: 2 additions & 0 deletions GodSeekerPlus/Imports.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@
global using Satchel.Futils;

global using UnityEngine;
global using UnityEngine.SceneManagement;

global using Module = GodSeekerPlus.Modules.Module;
global using Logger = GodSeekerPlus.Util.Logger;
global using Lang = Language.Language;
global using USceneManager = UnityEngine.SceneManagement.SceneManager;
1 change: 1 addition & 0 deletions GodSeekerPlus/Lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"Modules/NoNailDamage": "No Nail Damage",
"Modules/NoSpellDamage": "No Spell Damage",
"Modules/P5Health": "P5 Health",
"Modules/P5Teleport": "P5 Teleport",
"Modules/UnlockAllModes": "Unlock All Modes",
"Modules/UnlockEternalOrdeal": "Unlock Eternal Ordeal",
"Modules/UnlockPantheons": "Unlock Pantheons",
Expand Down
1 change: 1 addition & 0 deletions GodSeekerPlus/Lang/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"Modules/NoNailDamage": "取消骨钉伤害",
"Modules/NoSpellDamage": "取消法术伤害",
"Modules/P5Health": "五门血量",
"Modules/P5Teleport": "五门传送",
"Modules/UnlockAllModes": "解锁所有模式",
"Modules/UnlockEternalOrdeal": "解锁无尽折磨",
"Modules/UnlockPantheons": "解锁万神殿",
Expand Down
2 changes: 1 addition & 1 deletion GodSeekerPlus/Modules/BossChallenge/ActivateFury.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ private static IEnumerator UpdateState() {
yield return new WaitUntil(() => fsm.ActiveStateName == "In" || fsm.ActiveStateName == "Idle");

// Avoid evading roar
string sceneName = UnityEngine.SceneManagement.SceneManager.GetActiveScene().name;
string sceneName = USceneManager.GetActiveScene().name;
if (extraWaitScenes.ContainsKey(sceneName)) {
yield return new WaitForSeconds(extraWaitScenes[sceneName]);
yield return new WaitUntil(() => !Ref.HC.controlReqlinquished);
Expand Down
95 changes: 95 additions & 0 deletions GodSeekerPlus/Modules/QoL/P5Teleport.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
namespace GodSeekerPlus.Modules.QoL;

[Category(nameof(QoL))]
[ToggleableLevel(ToggleableLevel.ChangeScene)]
[DefaultEnabled]
internal sealed class P5Teleport : Module {
private static readonly MethodInfo activateFsmStateActions = typeof(FsmState)
.GetMethod(
"ActivateActions",
BindingFlags.Instance | BindingFlags.NonPublic
);

private protected override void Load() =>
USceneManager.activeSceneChanged += AddComponentToLever;

private protected override void Unload() =>
USceneManager.activeSceneChanged -= AddComponentToLever;

private void AddComponentToLever(Scene prev, Scene next) {
if (next.name == "GG_Atrium") {
next.GetGameObjectByName("gg_roof_door_pieces")
.Child("GG_door_caps", "gg_roof_lever")!
.AddComponent<TeleportOnDreamNail>();
}
}

private static IEnumerator Teleport() {
#region Pre-teleport effects

Ref.HC.RelinquishControl();
Fsm dreamNailFSM = Ref.HC.gameObject.LocateMyFSM("Dream Nail").Fsm;

(new[] { "Warp Effect", "Warp End" })
.ForEach(name => activateFsmStateActions.Invoke(
dreamNailFSM.GetState(name),
new object[] { 0 }
));

Ref.HC.gameObject.LocateMyFSM("Roar Lock")
.FsmVariables.FindFsmBool("No Roar")
.Value = false;
StaticVariableList.SetValue("skipRemoveDreamOrbs", true);

yield return new WaitForSeconds(2);

Ref.HC.FaceLeft();

#endregion

#region Substitute DGate data

string origDGateScene = Ref.PD.dreamGateScene;
float origDGateX = Ref.PD.dreamGateX;
float origDGateY = Ref.PD.dreamGateY;

Ref.PD.dreamGateScene = "GG_Atrium_Roof";
Ref.PD.dreamGateX = 105.6243f;
Ref.PD.dreamGateY = 73.4129f;

#endregion

// Do teleport
activateFsmStateActions.Invoke(
dreamNailFSM.GetState("New Scene"),
new object[] { 0 }
);

#region Restore DGate Data

// Restore this before scene loaded to prevent spawning DGate
Ref.PD.dreamGateScene = origDGateScene;

yield return new WaitWhile(() => Ref.PD.disablePause);
Ref.PD.dreamGateX = origDGateX;
Ref.PD.dreamGateY = origDGateY;

#endregion
}


private class TeleportOnDreamNail : MonoBehaviour {
public void OnTriggerEnter2D(Collider2D collision) {
if (collision.tag != "Dream Attack") {
return;
}

if (!Ref.PD.finalBossDoorUnlocked) {
return;
}

Logger.LogDebug("P5 teleport start");
StartCoroutine(Teleport());
}
}
}
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ Compatible with `Hollow Knight` 1.5.
+ **Fast Super Dash**: Buff Super Dash speed in Hall of Gods.
+ **Grey Prince Enter Short**: Force Grey Prince to use short enter, as when defeated last time.
+ **Memorize Bindings**: Memorize the Bindings selected last time, like difficulties in the Hall of Gods. Recommend using with Door Default Begin.
+ **P5 Teleport**: Allow using the Dream Nail towards the lever which is used to unlock Godhome Atrium Roof to teleport to beside the Pantheon of Hallownest.

- **Restrictions**:
+ **Force Overcharm**: Force entering the overcharmed state.
Expand Down
1 change: 1 addition & 0 deletions README.zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
+ **快速超级冲刺**:提升在诸神堂中的超级冲刺速度。
+ **灰色王子短入场**:强制灰色王子使用短入场,如同上一次击败之的效果。
+ **记住束缚**:记住上次选择的束缚,效果与诸神堂中的难度选择一样。建议与门默认开始一起使用。
+ **五门传送**:允许对着用于解锁神居中庭屋顶的拉杆使用梦之钉来传送到圣巢万神殿旁边。

- **限制**
+ **强制护符过载**:强制进入护符过载状态。
Expand Down

0 comments on commit 17f1f3c

Please sign in to comment.