-
-
Save jarylc/3f6fc305466d4970deae16629469b3c2 to your computer and use it in GitHub Desktop.
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
diff --git a/src/Mirage/Patch/SpawnMirage.fs b/src/Mirage/Patch/SpawnMirage.fs | |
index cc20f5d..463e2b1 100644 | |
--- a/src/Mirage/Patch/SpawnMirage.fs | |
+++ b/src/Mirage/Patch/SpawnMirage.fs | |
@@ -112,7 +112,7 @@ type SpawnMirage() = | |
[<HarmonyPrefix>] | |
[<HarmonyPatch(typeof<PlayerControllerB>, "KillPlayerServerRpc")>] | |
- static member ``spawn mirage on player death``(__instance: PlayerControllerB) = | |
+ static member ``spawn mirage on player death``(__instance: PlayerControllerB, causeOfDeath: int, deathAnimation: int) = | |
handleResult <| monad' { | |
if __instance.IsHost then | |
// For whatever reason, KillPlayerServerRpc is invoked twice, per player death. | |
@@ -120,7 +120,8 @@ type SpawnMirage() = | |
let! playerTracker = getPlayerTracker "``spawn mirage on player death``" | |
if isPlayerTracked playerTracker __instance then | |
set PlayerTracker <| removePlayer playerTracker __instance | |
- if random.Next(1, 101) <= getConfig().spawnOnPlayerDeath then | |
+ let playerKilledByMasked = (causeOfDeath = (int) CauseOfDeath.Strangulation && deathAnimation = 4) | |
+ if playerKilledByMasked || (__instance.isPlayerAlone && causeOfDeath <> (int) CauseOfDeath.Gravity && random.Next(1, 101) <= getConfig().spawnOnPlayerDeath) then | |
let! maskPrefab = getMask "``spawn mirage on player death``" | |
let mask = UnityEngine.Object.Instantiate<GameObject>(maskPrefab.gameObject).GetComponent<HauntedMaskItem>() | |
mask.transform.localScale <- Vector3.zero | |
@@ -131,17 +132,11 @@ type SpawnMirage() = | |
mask.NetworkObject.Despawn() | |
} | |
- [<HarmonyPrefix>] | |
- [<HarmonyPatch(typeof<HauntedMaskItem>, "CreateMimicServerRpc")>] | |
- static member ``use mirage spawner instead of default create mimic server rpc``(__instance: HauntedMaskItem) = | |
- if __instance.IsHost && not __instance.previousPlayerHeldBy.isPlayerDead then | |
- __instance.previousPlayerHeldBy.KillPlayer(Vector3.zero, false, CauseOfDeath.Suffocation, __instance.maskTypeId) | |
- false | |
- | |
- [<HarmonyPrefix>] | |
+ [<HarmonyPostfix>] | |
[<HarmonyPatch(typeof<PlayerControllerB>, "SpawnDeadBody")>] | |
static member ``disable player corpse spawn``(__instance: PlayerControllerB) = | |
- not <| __instance.GetComponent<MirageSpawner>().IsSpawned() | |
+ if __instance.GetComponent<MirageSpawner>().IsSpawned() then | |
+ __instance.deadBody.DeactivateBody(false) // Allows TakeYourMaskOff to recover body | |
[<HarmonyPrefix>] | |
[<HarmonyPatch(typeof<MaskedPlayerEnemy>)>] | |
@@ -152,13 +147,15 @@ type SpawnMirage() = | |
[<HarmonyPostfix>] | |
[<HarmonyPatch(typeof<MaskedPlayerEnemy>, "Start")>] | |
static member ``remove mask texture and mimic a random player if enabled``(__instance: MaskedPlayerEnemy) = | |
- let player = __instance.mimickingPlayer | |
+ let mutable player = __instance.mimickingPlayer | |
if isNull player then | |
let round = StartOfRound.Instance | |
let players = round.allPlayerScripts | |
let playerId = random.Next <| round.connectedPlayersAmount + 1 | |
- let player = players[playerId] | |
- setMiragePlayer __instance player | |
+ player <- players[playerId] | |
+ | |
+ setMiragePlayer __instance player | |
+ | |
if not <| getConfig().enableMask then | |
__instance.GetComponentsInChildren<Transform>() | |
|> filter _.name.StartsWith("HeadMask") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment