public static void OldRefreshPlyModel(this CharacterClassManager ccm, GameObject player, RoleType classId = RoleType.None) { ReferenceHub hub = ReferenceHub.GetHub(player); hub.GetComponent <AnimationController>().OnChangeClass(); if (ccm.MyModel != null) { UnityEngine.Object.Destroy(ccm.MyModel); } Role role = ccm.Classes.SafeGet((classId < RoleType.Scp173) ? ccm.CurClass : classId); if (role.team != Team.RIP) { GameObject gameObject = UnityEngine.Object.Instantiate <GameObject>(role.model_player, ccm.gameObject.transform, true); gameObject.transform.localPosition = role.model_offset.position; gameObject.transform.localRotation = Quaternion.Euler(role.model_offset.rotation); gameObject.transform.localScale = role.model_offset.scale; ccm.MyModel = gameObject; AnimationController component = hub.GetComponent <AnimationController>(); if (ccm.MyModel.GetComponent <Animator>() != null) { component.animator = ccm.MyModel.GetComponent <Animator>(); } FootstepSync component2 = ccm.GetComponent <FootstepSync>(); FootstepHandler component3 = ccm.MyModel.GetComponent <FootstepHandler>(); if (component2 != null) { component2.FootstepHandler = component3; } if (component3 != null) { component3.FootstepSync = component2; component3.AnimationController = component; } if (ccm.isLocalPlayer) { if (ccm.MyModel.GetComponent <Renderer>() != null) { ccm.MyModel.GetComponent <Renderer>().enabled = false; } Renderer[] componentsInChildren = ccm.MyModel.GetComponentsInChildren <Renderer>(); for (int i = 0; i < componentsInChildren.Length; i++) { componentsInChildren[i].enabled = false; } foreach (Collider collider in ccm.MyModel.GetComponentsInChildren <Collider>()) { if (collider.name != "LookingTarget") { collider.enabled = false; } } } } ccm.GetComponent <CapsuleCollider>().enabled = (role.team != Team.RIP); if (ccm.MyModel != null) { ccm.GetComponent <WeaponManager>().hitboxes = ccm.MyModel.GetComponentsInChildren <HitboxIdentity>(true); } }
public static void Prefix(ReferenceHub __instance) { if (__instance.GetComponent <Player>() == null) { __instance.gameObject.AddComponent <Player>(); } if (__instance.GetComponent <Jail>() == null) { __instance.gameObject.AddComponent <Jail>(); } if (__instance.GetComponent <Scp106Controller>() == null) { __instance.gameObject.AddComponent <Scp106Controller>(); } try { Events.InvokeLoadComponents(__instance.gameObject); } catch (Exception e) { Log.Error($"LoadComponentsEvent Error: {e}"); } }
private IEnumerator <float> DelayBroadcast(ReferenceHub player) { yield return(MEC.Timing.WaitForSeconds(0.5f)); if (player.characterClassManager.CurClass == RoleType.Scp106) { player.GetComponent <Broadcast>().TargetAddElement(player.scp079PlayerScript.connectionToClient, StalkyConfigs.stalkBroadcast, 10U, false); player.GetComponent <GameConsoleTransmission>().SendToClient(player.GetComponent <Mirror.NetworkIdentity>().connectionToClient, StalkyConfigs.consoleInfo, "white"); } }
public void CheckUnmute(ReferenceHub ply) { if (notActualMutedPlayers.Contains(ply.GetComponent <ReferenceHub>().GetUserId())) { if (plugin.debug) { Log.Info("Unmuting player " + ply.GetComponent <ReferenceHub>().GetNickname() + " as they have no role."); } ply.GetComponent <ReferenceHub>().Unmute(); notActualMutedPlayers.RemoveAll((p) => p.Equals(ply.GetComponent <ReferenceHub>().GetUserId())); ply.GetComponent <ReferenceHub>().Broadcast(3, "[NoRoleMute] You have been unmuted.", false); } }
public static void Target096AttackSound(ReferenceHub target, ReferenceHub player) { NetworkWriter writer = NetworkWriterPool.GetWriter(); player.SendRpcWriter(target.GetComponent <Scp096PlayerScript>(), typeof(Scp096PlayerScript), "RpcSyncAudio", writer, 0); NetworkWriterPool.Recycle(writer); }
public static void AddRainbowController(ReferenceHub player) { var component = player.GetComponent <RainbowTagController>(); if (component != null) { return; } player.gameObject.AddComponent <RainbowTagController>(); }
public static void Spawn018(ReferenceHub player) { var gm = player.GetComponent <Grenades.GrenadeManager>(); var component = UnityEngine.Object.Instantiate(gm.availableGrenades[(int)GRENADE_ID.SCP018_NADE].grenadeInstance).GetComponent <Grenades.Scp018Grenade>(); component.InitData(gm, new Vector3(UnityEngine.Random.Range(0f, 1f), UnityEngine.Random.Range(0f, 1f), UnityEngine.Random.Range(0f, 1f)), new Vector3(UnityEngine.Random.Range(0f, 1f), UnityEngine.Random.Range(0f, 1f), UnityEngine.Random.Range(0f, 1f))); NetworkServer.Spawn(component.gameObject); }
private IEnumerator <float> BroadcastCurrentMods(ReferenceHub player) { yield return(Timing.WaitForSeconds(0.1f)); player.GetComponent <Broadcast>().TargetAddElement(player.characterClassManager.connectionToClient, "Current Round Modifier(s):", 5, Broadcast.BroadcastFlags.Normal); if (plugin.curMod.HasFlag(ModType.NONE) && plugin.enabledTypes.Contains(ModType.NONE)) { player.GetComponent <Broadcast>().TargetAddElement(player.characterClassManager.connectionToClient, plugin.translations[ModType.NONE], 5, Broadcast.BroadcastFlags.Normal); } else { foreach (ModType item in Enum.GetValues(typeof(ModType))) { if (plugin.curMod.HasFlag(item)) { player.GetComponent <Broadcast>().TargetAddElement(player.characterClassManager.connectionToClient, plugin.translations[item], 2, Broadcast.BroadcastFlags.Normal); } } //player.GetComponent<Broadcast>().TargetAddElement(player.characterClassManager.connectionToClient, plugin.curMod.ToString(), 5, false); } }
private static void Prefix(ReferenceHub __instance) { if (__instance.GetComponent <Player>() == null) { __instance.gameObject.AddComponent <Player>(); } try { SynapseController.Server.Events.Player.InvokeLoadComponentsEvent(__instance.gameObject); } catch (Exception e) { SynapseController.Server.Logger.Error($"Synapse-Event: LoadComponents failed!!\n{e}\nStackTrace:\n{e.StackTrace}"); } }
/// <summary> /// Sets the <see cref="ReferenceHub">player</see>'s scale. /// </summary> /// <param name="player"></param> public static void SetScale(this ReferenceHub player, float x, float y, float z) { try { player.transform.localScale = new Vector3(x, y, z); foreach (ReferenceHub target in GetHubs()) { SendSpawnMessage?.Invoke(null, new object[] { player.GetComponent <NetworkIdentity>(), target.GetConnection() }); } } catch (Exception exception) { Log.Error($"SetScale error: {exception}"); } }
public static void SpawnGrenade(Vector3 position, bool isFlash = false, float fusedur = -1, ReferenceHub player = null) { if (player == null) { player = ReferenceHub.GetHub(PlayerManager.localPlayer); } var gm = player.GetComponent <Grenades.GrenadeManager>(); Grenades.Grenade component = UnityEngine.Object.Instantiate(gm.availableGrenades[isFlash ? (int)GRENADE_ID.FLASH_NADE : (int)GRENADE_ID.FRAG_NADE].grenadeInstance).GetComponent <Grenades.Grenade>(); if (fusedur != -1) { component.fuseDuration = fusedur; } component.FullInitData(gm, position, Quaternion.Euler(component.throwStartAngle), Vector3.zero, component.throwAngularVelocity); NetworkServer.Spawn(component.gameObject); }
public static bool Prefix(PlayerPositionManager __instance) { if (EventPlugin.GhostmodePatchDisable) { return(true); } try { List <GameObject> players = PlayerManager.players; __instance.usedData = players.Count; if (__instance.receivedData == null || __instance.receivedData.Length < __instance.usedData) { __instance.receivedData = new PlayerPositionData[__instance.usedData * 2]; } for (int index = 0; index < __instance.usedData; ++index) { __instance.receivedData[index] = new PlayerPositionData(players[index]); } if (__instance.transmitBuffer == null || __instance.transmitBuffer.Length < __instance.usedData) { __instance.transmitBuffer = new PlayerPositionData[__instance.usedData * 2]; } foreach (GameObject gameObject in players) { CharacterClassManager component1 = gameObject.GetComponent <CharacterClassManager>(); Array.Copy(__instance.receivedData, __instance.transmitBuffer, __instance.usedData); if (component1.CurClass == RoleType.Scp096 || component1.CurClass == RoleType.Scp173) { for (int i = 0; i < __instance.usedData; i++) { ReferenceHub hub = Player.GetPlayer(__instance.transmitBuffer[i].playerID); if (hub.characterClassManager.CurClass != RoleType.Tutorial) { continue; } Scp049PlayerScript script = hub.GetComponent <Scp049PlayerScript>(); Vector3 fwd = script.plyCam.transform.forward; Vector3 pos = script.gameObject.transform.position; Vector3 position = component1.gameObject.transform.position; float angle = Vector3.Angle(fwd, (pos - position).normalized); Vector3 dir = (pos - position).normalized; Quaternion rot = Quaternion.LookRotation(dir); if (angle >= 100f) { float newAngle = Vector3.Angle(new Vector3(fwd.x, fwd.y + 180f, fwd.z), (pos - position).normalized); if (component1.CurClass == RoleType.Scp096 && EventPlugin.Scp096Fix || component1.CurClass == RoleType.Scp173 && EventPlugin.Scp173Fix) { __instance.transmitBuffer[i] = new PlayerPositionData(__instance.transmitBuffer[i].position, newAngle, __instance.transmitBuffer[i].playerID); } } } } if (component1.CurClass.Is939()) { for (int index = 0; index < __instance.usedData; ++index) { if (__instance.transmitBuffer[index].position.y < 800.0) { CharacterClassManager component2 = players[index].GetComponent <CharacterClassManager>(); if (component2.Classes.SafeGet(component2.CurClass).team != Team.SCP && component2.Classes.SafeGet(component2.CurClass).team != Team.RIP && !players[index] .GetComponent <Scp939_VisionController>() .CanSee(component1.GetComponent <Scp939PlayerScript>())) { __instance.transmitBuffer[index] = new PlayerPositionData(Vector3.up * 6000f, 0.0f, __instance.transmitBuffer[index].playerID); } } } } else if (component1.CurClass != RoleType.Scp079 && component1.CurClass != RoleType.Spectator) { for (int index = 0; index < __instance.usedData; ++index) { if (__instance.transmitBuffer[index].uses268 || EventPlugin.GhostedIds.Contains(__instance.transmitBuffer[index].playerID)) { __instance.transmitBuffer[index] = new PlayerPositionData(Vector3.up * 6000f, 0.0f, __instance.transmitBuffer[index].playerID); } } } if (EventPlugin.TargetGhost.ContainsKey(gameObject.GetPlayer())) { for (int i = 0; i < __instance.usedData; i++) { if (EventPlugin.TargetGhost[gameObject.GetPlayer()] .Contains(__instance.transmitBuffer[i].playerID)) { __instance.transmitBuffer[i] = new PlayerPositionData(Vector3.up * 6000f, 0.0f, __instance.transmitBuffer[i].playerID); } } } NetworkConnection networkConnection = component1.netIdentity.isLocalPlayer ? NetworkServer.localConnection : component1.netIdentity.connectionToClient; if (__instance.usedData <= 20) { networkConnection.Send( new PlayerPositionManager.PositionMessage(__instance.transmitBuffer, (byte)__instance.usedData, 0), 1); } else { byte part; for (part = 0; part < __instance.usedData / 20; ++part) { networkConnection.Send( new PlayerPositionManager.PositionMessage(__instance.transmitBuffer, 20, part), 1); } byte count = (byte)(__instance.usedData % (part * 20)); if (count > 0) { networkConnection.Send( new PlayerPositionManager.PositionMessage(__instance.transmitBuffer, count, part), 1); } } } return(false); } catch (Exception exception) { Log.Error($"GhostmodePatch error: {exception}"); return(true); } }
// Keep in mind, changes affecting this code // have a high breakage rate, so be careful when // updating or adding new things private static bool Prefix(PlayerPositionManager __instance) { try { if (++__instance._frame != __instance._syncFrequency) { return(false); } __instance._frame = 0; List <GameObject> players = PlayerManager.players; __instance._usedData = players.Count; if (__instance.ReceivedData == null || __instance.ReceivedData.Length < __instance._usedData) { __instance.ReceivedData = new PlayerPositionData[__instance._usedData * 2]; } for (int index = 0; index < __instance._usedData; ++index) { __instance.ReceivedData[index] = new PlayerPositionData(ReferenceHub.GetHub(players[index])); } if (__instance._transmitBuffer == null || __instance._transmitBuffer.Length < __instance._usedData) { __instance._transmitBuffer = new PlayerPositionData[__instance._usedData * 2]; } foreach (GameObject gameObject in players) { Player player = GetPlayerOrServer(gameObject); if (player == null || player.ReferenceHub.queryProcessor._ipAddress == "127.0.0.WAN") { continue; } Array.Copy(__instance.ReceivedData, __instance._transmitBuffer, __instance._usedData); if (player.Role.Is939()) { for (int index = 0; index < __instance._usedData; ++index) { if (__instance._transmitBuffer[index].position.y < 800f) { ReferenceHub hub2 = ReferenceHub.GetHub(__instance._transmitBuffer[index].playerID); if (hub2.characterClassManager.CurRole.team != Team.SCP && hub2.characterClassManager.CurRole.team != Team.RIP && !hub2 .GetComponent <Scp939_VisionController>() .CanSee(player.ReferenceHub.playerEffectsController.GetEffect <Visuals939>())) { MakeGhost(index, __instance._transmitBuffer); } } } } else if (player.Role != RoleType.Spectator && player.Role != RoleType.Scp079) { for (int index = 0; index < __instance._usedData; ++index) { PlayerPositionData ppd = __instance._transmitBuffer[index]; if (!ReferenceHub.TryGetHub(ppd.playerID, out ReferenceHub targetHub)) { continue; } Player currentTarget = GetPlayerOrServer(targetHub.gameObject); if (currentTarget == null) { continue; } Scp096 scp096 = player.ReferenceHub.scpsController.CurrentScp as Scp096; Vector3 vector3 = ppd.position - player.ReferenceHub.playerMovementSync.RealModelPosition; if (Math.Abs(vector3.y) > 35f) { MakeGhost(index, __instance._transmitBuffer); } else { float sqrMagnitude = vector3.sqrMagnitude; if (player.ReferenceHub.playerMovementSync.RealModelPosition.y < 800f) { if (sqrMagnitude >= 1764f) { if (!(sqrMagnitude < 4225f)) { MakeGhost(index, __instance._transmitBuffer); continue; } if (!(currentTarget.ReferenceHub.scpsController.CurrentScp is Scp096 scp) || !scp.EnragedOrEnraging) { MakeGhost(index, __instance._transmitBuffer); continue; } } } else if (sqrMagnitude >= 7225f) { MakeGhost(index, __instance._transmitBuffer); continue; // As the target is already ghosted } // The code below doesn't have to follow a ELSE statement! // Otherwise Scp268 won't be processed if (scp096 != null && scp096.EnragedOrEnraging && !scp096.HasTarget(currentTarget.ReferenceHub) && currentTarget.Team != Team.SCP) { #if DEBUG Log.Debug($"[Scp096@GhostModePatch] {player.UserId} can't see {currentTarget.UserId}"); #endif MakeGhost(index, __instance._transmitBuffer); } else if (currentTarget.ReferenceHub.playerEffectsController.GetEffect <Invisible>().IsEnabled) { bool flag2 = false; if (scp096 != null) { flag2 = scp096.HasTarget(currentTarget.ReferenceHub); } if (currentTarget != player && player.Role != RoleType.Scp079 && player.Role != RoleType.Spectator && !flag2) { MakeGhost(index, __instance._transmitBuffer); } } } } } // We do another FOR for the ghost things // because it's hard to do it without // whole code changes in the game code for (int z = 0; z < __instance._usedData; z++) { PlayerPositionData ppd = __instance._transmitBuffer[z]; // Do you remember the bug // when you can't pick up any item? // - Me too; // It was because for a reason // we made the source player // invisible to themself if (player.Id == ppd.playerID) { continue; } // If it's already has the ghost position if (ppd.position == GhostPos) { continue; } if (!ReferenceHub.TryGetHub(ppd.playerID, out ReferenceHub targetHub)) { continue; } Player target = GetPlayerOrServer(targetHub.gameObject); if (target == null || target.ReferenceHub.queryProcessor._ipAddress == "127.0.0.WAN") { continue; } // If for some reason the player/their ref hub is null if (target?.ReferenceHub == null) { continue; } if (target.IsInvisible || PlayerCannotSee(player, target.Id)) { MakeGhost(z, __instance._transmitBuffer); } // Rotate the player because // those movement checks are // in client-side else if (player.Role == RoleType.Scp173 && ((!Exiled.Events.Events.Instance.Config.CanTutorialBlockScp173 && target.Role == RoleType.Tutorial) || Scp173.TurnedPlayers.Contains(target))) { RotatePlayer(z, __instance._transmitBuffer, FindLookRotation(player.Position, target.Position)); } } if (player.ReferenceHub.characterClassManager.netIdentity != null) { NetworkConnection networkConnection = player.ReferenceHub.characterClassManager.netIdentity.isLocalPlayer ? NetworkServer.localConnection : player.ReferenceHub.characterClassManager.netIdentity.connectionToClient; if (__instance._usedData <= 20) { networkConnection.Send <PositionPPMMessage>( new PositionPPMMessage(__instance._transmitBuffer, (byte)__instance._usedData, 0), 1); } else { byte part; for (part = 0; part < __instance._usedData / 20; ++part) { networkConnection.Send <PositionPPMMessage>(new PositionPPMMessage(__instance._transmitBuffer, 20, part), 1); } byte count = (byte)(__instance._usedData % (part * 20)); if (count > 0) { networkConnection.Send <PositionPPMMessage>(new PositionPPMMessage(__instance._transmitBuffer, count, part), 1); } } } } return(false); } catch (Exception exception) { Log.Error($"GhostMode error: {exception}"); return(true); } }
public void CheckMute(ReferenceHub ply) { if (ply.GetComponent <ReferenceHub>().CheckPermission("norolemute.unmute") && notActualMutedPlayers.Contains(ply.GetComponent <ReferenceHub>().GetUserId()) && ply.GetComponent <ReferenceHub>().characterClassManager.NetworkMuted) { if (plugin.debug) { Log.Info("Player " + ply.GetComponent <ReferenceHub>().GetNickname() + " has a role, unmuting them."); } ply.GetComponent <ReferenceHub>().Unmute(); ply.GetComponent <ReferenceHub>().Broadcast(3, "[NoRoleMute] You have been unmuted.", false); notActualMutedPlayers.RemoveAll((p) => p.Equals(ply.GetComponent <ReferenceHub>().GetUserId())); } if (ply.GetComponent <ReferenceHub>().characterClassManager.NetworkMuted) { return; } if (!ply.GetComponent <ReferenceHub>().CheckPermission("norolemute.unmute") && !notActualMutedPlayers.Contains(ply.GetComponent <ReferenceHub>().GetUserId())) { if (plugin.debug) { Log.Info("Temp muting player " + ply.GetComponent <ReferenceHub>().GetNickname() + " as they have no role."); } ply.GetComponent <ReferenceHub>().Unmute(); ply.GetComponent <ReferenceHub>().Mute(); notActualMutedPlayers.Add(ply.GetComponent <ReferenceHub>().GetUserId()); ply.GetComponent <ReferenceHub>().Broadcast(3, "[NoRoleMute] You have been muted.", false); } if (ply.GetComponent <ReferenceHub>().CheckPermission("norolemute.unmute") && notActualMutedPlayers.Contains(ply.GetComponent <ReferenceHub>().GetUserId())) { if (plugin.debug) { Log.Info("Player " + ply.GetComponent <ReferenceHub>().GetNickname() + " has a role, unmuting them."); } ply.GetComponent <ReferenceHub>().Unmute(); ply.GetComponent <ReferenceHub>().Broadcast(3, "[NoRoleMute] You have been unmuted.", false); notActualMutedPlayers.RemoveAll((p) => p.Equals(ply.GetComponent <ReferenceHub>().GetUserId())); } }
IEnumerator <float> telPlayer(ReferenceHub p, Vector3 pos) { yield return(Timing.WaitForSeconds(0.4f)); p.GetComponent <PlyMovementSync>().OverridePosition(pos, 0f, false); }
public static void Broadcast(this ReferenceHub rh, ushort time, string message) => rh.GetComponent <Broadcast>().TargetAddElement(rh.scp079PlayerScript.connectionToClient, message, time, global::Broadcast.BroadcastFlags.Normal);
public static bool Prefix(PlayerPositionManager __instance) { try { List <GameObject> players = PlayerManager.players; __instance.usedData = players.Count; if (__instance.receivedData == null || __instance.receivedData.Length < __instance.usedData) { __instance.receivedData = new PlayerPositionData[__instance.usedData * 2]; } for (int index = 0; index < __instance.usedData; ++index) { __instance.receivedData[index] = new PlayerPositionData(players[index]); } if (__instance.transmitBuffer == null || __instance.transmitBuffer.Length < __instance.usedData) { __instance.transmitBuffer = new PlayerPositionData[__instance.usedData * 2]; } foreach (GameObject gameObject in players) { CharacterClassManager component1 = gameObject.GetComponent <CharacterClassManager>(); Array.Copy(__instance.receivedData, __instance.transmitBuffer, __instance.usedData); if (component1.CurClass == RoleType.Scp096 || component1.CurClass == RoleType.Scp173) { for (int i = 0; i < __instance.usedData; i++) { ReferenceHub hub = Plugin.GetPlayer(__instance.transmitBuffer[i].playerID.ToString()); if (hub.characterClassManager.CurClass != RoleType.Tutorial) { continue; } Scp049PlayerScript script = hub.GetComponent <Scp049PlayerScript>(); Vector3 fwd = script.plyCam.transform.forward; Vector3 pos = script.gameObject.transform.position; Vector3 position = component1.gameObject.transform.position; float angle = Vector3.Angle(fwd, (pos - position).normalized); Vector3 dir = (pos - position).normalized; Quaternion rot = Quaternion.LookRotation(dir); if (angle <= 80f) { __instance.transmitBuffer[i] = new PlayerPositionData(__instance.transmitBuffer[i].position, Quaternion.Inverse(rot).y, __instance.transmitBuffer[i].playerID, __instance.transmitBuffer[i].uses268); } } } if (component1.CurClass.Is939()) { for (int index = 0; index < __instance.usedData; ++index) { if (__instance.transmitBuffer[index].position.y < 800.0) { CharacterClassManager component2 = players[index].GetComponent <CharacterClassManager>(); if (component2.Classes.SafeGet(component2.CurClass).team != Team.SCP && component2.Classes.SafeGet(component2.CurClass).team != Team.RIP && !players[index] .GetComponent <Scp939_VisionController>() .CanSee(component1.GetComponent <Scp939PlayerScript>())) { __instance.transmitBuffer[index] = new PlayerPositionData(Vector3.up * 6000f, 0.0f, __instance.transmitBuffer[index].playerID); } } } } else if (component1.CurClass == RoleType.Scp096) { Scp096PlayerScript script = component1.GetComponent <Scp096PlayerScript>(); if (script.Networkenraged == Scp096PlayerScript.RageState.Enraged || script.Networkenraged == Scp096PlayerScript.RageState.Panic) { for (int i = 0; i < __instance.usedData; i++) { if (!Plugin.Scp096Targets.Contains(__instance.transmitBuffer[i].playerID)) { __instance.transmitBuffer[i] = new PlayerPositionData(Vector3.up * 6000f, 0f, __instance.transmitBuffer[i].playerID); } } } } else if (component1.CurClass != RoleType.Scp079 && component1.CurClass != RoleType.Spectator) { for (int index = 0; index < __instance.usedData; ++index) { if (__instance.transmitBuffer[index].uses268 || EXILED.EventPlugin.GhostedIds.Contains(__instance.transmitBuffer[index].playerID)) { __instance.transmitBuffer[index] = new PlayerPositionData(Vector3.up * 6000f, 0.0f, __instance.transmitBuffer[index].playerID); } } } NetworkConnection networkConnection = component1.netIdentity.isLocalPlayer ? NetworkServer.localConnection : component1.netIdentity.connectionToClient; if (__instance.usedData <= 20) { networkConnection.Send( new PlayerPositionManager.PositionMessage(__instance.transmitBuffer, (byte)__instance.usedData, 0), 1); } else { byte part; for (part = (byte)0; (int)part < __instance.usedData / 20; ++part) { networkConnection.Send( new PlayerPositionManager.PositionMessage(__instance.transmitBuffer, 20, part), 1); } byte count = (byte)(__instance.usedData % (part * 20)); if (count > 0) { networkConnection.Send( new PlayerPositionManager.PositionMessage(__instance.transmitBuffer, count, part), 1); } } } return(false); } catch (Exception e) { Plugin.Info($"TransmitData Error. {e}"); return(true); } }
private static bool Prefix(Scp049 __instance, byte num, GameObject go) { if (num == 2) { if (!__instance._interactRateLimit.CanExecute() || go == null) { return(false); } Ragdoll component = go.GetComponent <Ragdoll>(); if (component == null) { return(false); } ReferenceHub referenceHub = null; foreach (GameObject player in PlayerManager.players) { ReferenceHub hub = ReferenceHub.GetHub(player); if (hub.queryProcessor.PlayerId == component.owner.PlayerId) { referenceHub = hub; break; } } if (referenceHub == null) { return(false); } if (!__instance._recallInProgressServer || referenceHub.gameObject != __instance._recallObjectServer || __instance._recallProgressServer < 0.85f) { return(false); } if (referenceHub.characterClassManager.CurClass != RoleType.Spectator && !API.IsGhost(Player.Get(referenceHub))) { return(false); } var ev = new FinishingRecallEventArgs(Player.Get(referenceHub.gameObject), Player.Get(__instance.Hub.gameObject)); Exiled.Events.Handlers.Scp049.OnFinishingRecall(ev); if (!ev.IsAllowed) { return(false); } RoundSummary.changed_into_zombies++; referenceHub.characterClassManager.SetClassID(RoleType.Scp0492, CharacterClassManager.SpawnReason.Revived); referenceHub.GetComponent <PlayerStats>().Health = referenceHub.characterClassManager.Classes.Get(RoleType.Scp0492).maxHP; if (component.CompareTag("Ragdoll")) { NetworkServer.Destroy(component.gameObject); } __instance._recallInProgressServer = false; __instance._recallObjectServer = null; __instance._recallProgressServer = 0f; return(false); } else { return(true); } }
private static bool Prefix(PlayableScps.Scp049 __instance, byte num, GameObject go) { try { switch (num) { case 1: { if (!__instance._interactRateLimit.CanExecute()) { return(false); } if (go == null) { return(false); } Ragdoll component2 = go.GetComponent <Ragdoll>(); if (component2 == null) { Console.AddDebugLog("SCPCTRL", "SCP-049 | Request 'start recalling' rejected; provided object is not a dead body", MessageImportance.LessImportant); return(false); } if (!component2.allowRecall) { Console.AddDebugLog("SCPCTRL", "SCP-049 | Request 'start recalling' rejected; provided object can't be recalled", MessageImportance.LessImportant); return(false); } if (component2.CurrentTime > Scp049.ReviveEligibilityDuration) { Console.AddDebugLog("SCPCTRL", "SCP-049 | Request 'start recalling' rejected; provided object has decayed too far", MessageImportance.LessImportant); return(false); } // Removed useless FOREACH ReferenceHub referenceHub2 = ReferenceHub.GetHub(component2.owner.PlayerId); if (referenceHub2 == null) { Console.AddDebugLog("SCPCTRL", "SCP-049 | Request 'start recalling' rejected; target not found", MessageImportance.LessImportant); return(false); } bool flag = false; Rigidbody[] componentsInChildren = component2.GetComponentsInChildren <Rigidbody>(); for (int i = 0; i < componentsInChildren.Length; i++) { Console.AddDebugLog("SCPCTRL", "SCP-049 | Request 'start recalling' accepted", MessageImportance.LessImportant); if (Vector3.Distance(componentsInChildren[i].transform.position, __instance.Hub.PlayerCameraReference.transform.position) <= Scp049.ReviveDistance * 1.3f) { flag = true; referenceHub2.characterClassManager.NetworkDeathPosition = __instance.Hub.playerMovementSync.RealModelPosition; break; } } if (!flag) { Console.AddDebugLog("SCPCTRL", "SCP - 049 | Request 'start recalling' rejected; Distance was too great.", MessageImportance.LessImportant); break; } var ev = new StartingRecallEventArgs(API.Features.Player.Get(referenceHub2.gameObject), API.Features.Player.Get(__instance.Hub.gameObject)); Handlers.Scp049.OnStartingRecall(ev); if (!ev.IsAllowed) { return(false); } Console.AddDebugLog("SCPCTRL", "SCP-049 | Request 'start recalling' accepted", MessageImportance.LessImportant); __instance._recallObjectServer = referenceHub2.gameObject; __instance._recallProgressServer = 0f; __instance._recallInProgressServer = true; return(false); } case 2: { if (!__instance._interactRateLimit.CanExecute() || go == null) { return(false); } Ragdoll component = go.GetComponent <Ragdoll>(); if (component == null) { return(false); } ReferenceHub referenceHub = null; foreach (GameObject player in PlayerManager.players) { ReferenceHub hub = ReferenceHub.GetHub(player); if (hub.queryProcessor.PlayerId == component.owner.PlayerId) { referenceHub = hub; break; } } if (referenceHub == null) { Console.AddDebugLog("SCPCTRL", "SCP-049 | Request 'finish recalling' rejected; no target found", MessageImportance.LessImportant); return(false); } if (!__instance._recallInProgressServer || referenceHub.gameObject != __instance._recallObjectServer || __instance._recallProgressServer < 0.85f) { Console.AddDebugLog("SCPCTRL", "SCP-049 | Request 'finish recalling' rejected; Debug code: ", MessageImportance.LessImportant); Console.AddDebugLog("SCPCTRL", "SCP-049 | CONDITION#1 " + (__instance._recallInProgressServer ? "<color=green>PASSED</color>" : ("<color=red>ERROR</color> - " + __instance._recallInProgressServer)), MessageImportance.LessImportant, true); Console.AddDebugLog("SCPCTRL", "SCP-049 | CONDITION#2 " + ((referenceHub.gameObject == __instance._recallObjectServer) ? "<color=green>PASSED</color>" : string.Concat("<color=red>ERROR</color> - ", referenceHub.queryProcessor.PlayerId, "-", (__instance._recallObjectServer == null) ? "null" : ReferenceHub.GetHub(__instance._recallObjectServer).queryProcessor.PlayerId.ToString())), MessageImportance.LessImportant); Console.AddDebugLog("SCPCTRL", "SCP-049 | CONDITION#3 " + ((__instance._recallProgressServer >= 0.85f) ? "<color=green>PASSED</color>" : ("<color=red>ERROR</color> - " + __instance._recallProgressServer)), MessageImportance.LessImportant, true); return(false); } if (referenceHub.characterClassManager.CurClass != RoleType.Spectator) { return(false); } var ev = new FinishingRecallEventArgs(API.Features.Player.Get(referenceHub.gameObject), API.Features.Player.Get(__instance.Hub.gameObject)); Handlers.Scp049.OnFinishingRecall(ev); if (!ev.IsAllowed) { return(false); } Console.AddDebugLog("SCPCTRL", "SCP-049 | Request 'finish recalling' accepted", MessageImportance.LessImportant); RoundSummary.changed_into_zombies++; referenceHub.characterClassManager.SetClassID(RoleType.Scp0492); referenceHub.GetComponent <PlayerStats>().Health = referenceHub.characterClassManager.Classes.Get(RoleType.Scp0492).maxHP; if (component.CompareTag("Ragdoll")) { NetworkServer.Destroy(component.gameObject); } __instance._recallInProgressServer = false; __instance._recallObjectServer = null; __instance._recallProgressServer = 0f; return(false); } default: return(true); } return(false); } catch (Exception e) { Exiled.API.Features.Log.Error($"Exiled.Events.Patches.Events.Scp049.StartingAndFinishingRecall: {e}\n{e.StackTrace}"); return(true); } }
// Keep in mind, changes affecting this code // have a high breakage rate, so be careful when // updating or adding new things private static bool Prefix(PlayerPositionManager __instance) { try { if (!Round.IsStarted) { return(true); } if (++__instance._frame != __instance._syncFrequency) { return(false); } __instance._frame = 0; List <GameObject> players = PlayerManager.players; __instance._usedData = players.Count; if (__instance.ReceivedData is null || __instance.ReceivedData.Length < __instance._usedData) { __instance.ReceivedData = new PlayerPositionData[__instance._usedData * 2]; } for (int index = 0; index < __instance._usedData; ++index) { __instance.ReceivedData[index] = new PlayerPositionData(ReferenceHub.GetHub(players[index])); } if (__instance._transmitBuffer is null || __instance._transmitBuffer.Length < __instance._usedData) { __instance._transmitBuffer = new PlayerPositionData[__instance._usedData * 2]; } foreach (GameObject gameObject in players) { Player player = GetPlayerOrServer(gameObject); if (player is null || player.ReferenceHub.queryProcessor._ipAddress == "127.0.0.WAN") { continue; } Array.Copy(__instance.ReceivedData, __instance._transmitBuffer, __instance._usedData); if (player.Role.Type.Is939()) { for (int index = 0; index < __instance._usedData; ++index) { if (__instance._transmitBuffer[index].position.y < 800f) { ReferenceHub hub2 = ReferenceHub.GetHub(__instance._transmitBuffer[index].playerID); if (hub2.characterClassManager.CurRole.team != Team.SCP && hub2.characterClassManager.CurRole.team != Team.RIP && !hub2 .GetComponent <Scp939_VisionController>() .CanSee(player.ReferenceHub.playerEffectsController.GetEffect <Visuals939>())) { MakeGhost(index, __instance._transmitBuffer); } } } } else if (player.Role.Type != RoleType.Spectator && player.Role.Type != RoleType.Scp079) { for (int index = 0; index < __instance._usedData; ++index) { PlayerPositionData ppd = __instance._transmitBuffer[index]; if (!ReferenceHub.TryGetHub(ppd.playerID, out ReferenceHub targetHub)) { continue; } Player currentTarget = GetPlayerOrServer(targetHub.gameObject); if (currentTarget is null) { continue; } Scp096 scp096 = player.ReferenceHub.scpsController.CurrentScp as Scp096; Vector3 vector3 = ppd.position - player.ReferenceHub.playerMovementSync.RealModelPosition; if (Math.Abs(vector3.y) > 35f) { MakeGhost(index, __instance._transmitBuffer); } else { float sqrMagnitude = vector3.sqrMagnitude; if (player.ReferenceHub.playerMovementSync.RealModelPosition.y < 800f) { if (sqrMagnitude >= 1764f) { if (!(sqrMagnitude < 4225f)) { MakeGhost(index, __instance._transmitBuffer); continue; } if (!(currentTarget.ReferenceHub.scpsController.CurrentScp is Scp096 scp) || !scp.EnragedOrEnraging) { MakeGhost(index, __instance._transmitBuffer); continue; } } } else if (sqrMagnitude >= 7225f) { MakeGhost(index, __instance._transmitBuffer); continue; // As the target is already ghosted } // The code below doesn't have to follow a ELSE statement! // Otherwise Scp268 won't be processed if (scp096 is not null && scp096.EnragedOrEnraging && !scp096.HasTarget(currentTarget.ReferenceHub) && currentTarget.Role.Team != Team.SCP) { #if DEBUG Log.Debug($"[Scp096@GhostModePatch] {player.UserId} can't see {currentTarget.UserId}"); #endif MakeGhost(index, __instance._transmitBuffer); } else if (currentTarget.ReferenceHub.playerEffectsController.GetEffect <Invisible>().IsEnabled) { bool flag2 = false; if (scp096 is not null) { flag2 = scp096.HasTarget(currentTarget.ReferenceHub); } if (currentTarget != player && player.Role.Type != RoleType.Scp079 && player.Role.Type != RoleType.Spectator && !flag2) { MakeGhost(index, __instance._transmitBuffer); } } } } }
public static void Broadcast(this ReferenceHub rh, uint time, string message) => rh.GetComponent <Broadcast>().TargetAddElement(rh.scp079PlayerScript.connectionToClient, message, time, false);
public static void Broadcast(this ReferenceHub player, string message, uint time, bool monospaced = false) { player.GetComponent <Broadcast>().TargetAddElement(player.scp079PlayerScript.connectionToClient, message, time, monospaced); }
private static bool Prefix(PlayableScps.Scp049 __instance, byte num, GameObject go) { try { if (num == 2) { if (!__instance._interactRateLimit.CanExecute() || go == null) { return(false); } Ragdoll component = go.GetComponent <Ragdoll>(); if (component == null) { return(false); } ReferenceHub referenceHub = null; foreach (GameObject player in PlayerManager.players) { ReferenceHub hub = ReferenceHub.GetHub(player); if (hub.queryProcessor.PlayerId == component.owner.PlayerId) { referenceHub = hub; break; } } if (referenceHub == null) { Console.AddDebugLog("SCPCTRL", "SCP-049 | Request 'finish recalling' rejected; no target found", MessageImportance.LessImportant); return(false); } if (!__instance._recallInProgressServer || referenceHub.gameObject != __instance._recallObjectServer || __instance._recallProgressServer < 0.85f) { Console.AddDebugLog("SCPCTRL", "SCP-049 | Request 'finish recalling' rejected; Debug code: ", MessageImportance.LessImportant); Console.AddDebugLog("SCPCTRL", "SCP-049 | CONDITION#1 " + (__instance._recallInProgressServer ? "<color=green>PASSED</color>" : ("<color=red>ERROR</color> - " + __instance._recallInProgressServer)), MessageImportance.LessImportant, true); Console.AddDebugLog("SCPCTRL", "SCP-049 | CONDITION#2 " + ((referenceHub.gameObject == __instance._recallObjectServer) ? "<color=green>PASSED</color>" : string.Concat("<color=red>ERROR</color> - ", referenceHub.queryProcessor.PlayerId, "-", (__instance._recallObjectServer == null) ? "null" : ReferenceHub.GetHub(__instance._recallObjectServer).queryProcessor.PlayerId.ToString())), MessageImportance.LessImportant); Console.AddDebugLog("SCPCTRL", "SCP-049 | CONDITION#3 " + ((__instance._recallProgressServer >= 0.85f) ? "<color=green>PASSED</color>" : ("<color=red>ERROR</color> - " + __instance._recallProgressServer)), MessageImportance.LessImportant, true); return(false); } if (referenceHub.characterClassManager.CurClass != RoleType.Spectator) { return(false); } var ev = new FinishingRecallEventArgs(API.Features.Player.Get(referenceHub.gameObject), API.Features.Player.Get(__instance.Hub.gameObject)); Handlers.Scp049.OnFinishingRecall(ev); if (!ev.IsAllowed) { return(false); } Console.AddDebugLog("SCPCTRL", "SCP-049 | Request 'finish recalling' accepted", MessageImportance.LessImportant); RoundSummary.changed_into_zombies++; referenceHub.characterClassManager.SetClassID(RoleType.Scp0492); referenceHub.GetComponent <PlayerStats>().Health = referenceHub.characterClassManager.Classes.Get(RoleType.Scp0492).maxHP; if (component.CompareTag("Ragdoll")) { NetworkServer.Destroy(component.gameObject); } __instance._recallInProgressServer = false; __instance._recallObjectServer = null; __instance._recallProgressServer = 0f; return(false); } if (num != 1) { return(true); } { if (!__instance._interactRateLimit.CanExecute()) { return(false); } if (go == null) { return(false); } Ragdoll component2 = go.GetComponent <Ragdoll>(); if (component2 == null) { Console.AddDebugLog("SCPCTRL", "SCP-049 | Request 'start recalling' rejected; provided object is not a dead body", MessageImportance.LessImportant); return(false); } if (!component2.allowRecall) { Console.AddDebugLog("SCPCTRL", "SCP-049 | Request 'start recalling' rejected; provided object can't be recalled", MessageImportance.LessImportant); return(false); } ReferenceHub referenceHub2 = null; foreach (GameObject player2 in PlayerManager.players) { ReferenceHub hub2 = ReferenceHub.GetHub(player2); if (hub2 != null && hub2.queryProcessor.PlayerId == component2.owner.PlayerId) { referenceHub2 = hub2; break; } } if (referenceHub2 == null) { Console.AddDebugLog("SCPCTRL", "SCP-049 | Request 'start recalling' rejected; target not found", MessageImportance.LessImportant); return(false); } if (Vector3.Distance(component2.transform.position, __instance.Hub.PlayerCameraReference.transform.position) >= PlayableScps.Scp049.ReviveDistance * 1.3f) { return(false); } var ev = new StartingRecallEventArgs(API.Features.Player.Get(referenceHub2.gameObject), API.Features.Player.Get(__instance.Hub.gameObject)); Handlers.Scp049.OnStartingRecall(ev); if (!ev.IsAllowed) { return(false); } Console.AddDebugLog("SCPCTRL", "SCP-049 | Request 'start recalling' accepted", MessageImportance.LessImportant); __instance._recallObjectServer = referenceHub2.gameObject; __instance._recallProgressServer = 0f; __instance._recallInProgressServer = true; return(false); } } catch (Exception e) { Exiled.API.Features.Log.Error($"Exiled.Events.Patches.Events.Scp049.StartingAndFinishingRecall: {e}\n{e.StackTrace}"); return(true); } }
public static IEnumerator <float> _SetClass(ReferenceHub player, Subclass subclass) { List <int> indexesToRemove = new List <int>(); if (subclass.role != RoleType.NtfCadet) { player.characterClassManager.SetPlayersClass(subclass.role, player.gameObject); } yield return(Timing.WaitForSeconds(MTFplus.Instance.Configs.delay)); if (subclass.inventory.Count > 0) { player.inventory.items.Clear(); foreach (ItemType item in subclass.inventory) { player.inventory.AddNewItem(item); } } #if ItemManager for (int i = 0; i < 16; i++) { if (subclass.imInv[i] < 0) { continue; } if (!GrantCustomItem(player, subclass, subclass.imInv[i], i)) { MTFplus.Instance.Error("Custom item (ItemManager) with ID: " + subclass.imInv[i] + " doesn't exist/isn't installed!"); indexesToRemove.Add(i); // That's the index inside the inventory, and a coin was there as a placeholder } } #endif try { player.ammoBox.Networkamount = string.Concat(new string[] { subclass.ammo[0].ToString(), ":", subclass.ammo[1].ToString(), ":", subclass.ammo[2].ToString() }); } catch (Exception e) { EXILED.Plugin.Error("Bruh momento\n" + e); } #if ItemManager // Not even updated lol List <Smod2.API.Item> inv = player.GetInventory(); foreach (int i in indexesToRemove) { inv[i].Remove(); } #endif try { if (subclass.maxHP > 0) { player.playerStats.maxHP = subclass.maxHP; player.playerStats.SetHPAmount(subclass.maxHP); } if (!string.IsNullOrWhiteSpace(subclass.broadcast)) { player.GetComponent <Broadcast>().TargetAddElement(player.characterClassManager.connectionToClient, subclass.broadcast, 5u, false); } } catch (Exception e) { EXILED.Plugin.Error(e.ToString()); } }