private static bool ServerKillPlayerPatch(PlayableScps.Scp173 __instance, ReferenceHub target) { try { var scp = __instance.GetPlayer(); var player = target.GetPlayer(); if (target == __instance.Hub || player.ClassManager.IsAnyScp() || player.ClassManager.CurClass == RoleType.Spectator) { return(false); } if (!SynapseExtensions.GetHarmPermission(scp, player)) { return(false); } SynapseController.Server.Events.Scp.InvokeScpAttack(scp, player, Api.Enum.ScpAttackType.Scp173_Snap, out var allow); return(allow); } catch (Exception e) { Synapse.Api.Logger.Get.Error($"Synapse-Event: ScpAttackEvent(Scp173) failed!!\n{e}"); return(true); } }
private static bool Interact(WorkstationController __instance, ReferenceHub ply, byte colliderId) { try { if (colliderId != __instance._activateCollder?.ColliderId || __instance.Status != 0) { return(false); } if (ply == null) { return(false); } var player = ply.GetPlayer(); var station = __instance.GetWorkStation(); if (station != null) { station.KnownUser = player; } Event.Get.Player.InvokePlayerStartWorkstation(player, station, out var allow); return(allow); } catch (Exception e) { Logger.Get.Error($"Synapse-Item: Connect Workstation Tablet failed!!\n{e}"); return(false); } }
private static bool DistanceChanged(SinkholeEnvironmentalHazard __instance, ReferenceHub player) { try { var synapseplayer = player.GetPlayer(); if (Vector3.Distance(synapseplayer.Position, __instance.transform.position) <= __instance.DistanceToBeAffected) { var allow = true; if (__instance.SCPImmune && !SynapseExtensions.CanHarmScp(synapseplayer, false) || synapseplayer.GodMode) { allow = false; } Synapse.Api.Events.EventHandler.Get.Player.InvokeSinkhole(synapseplayer, __instance, ref allow); if (allow) { synapseplayer.GiveEffect(Api.Enum.Effect.SinkHole); return(false); } } synapseplayer.GiveEffect(Api.Enum.Effect.SinkHole, 0); return(false); } catch (Exception e) { Logger.Get.Error($"Synapse-Event: PlayerWalkOnSinkholeEvent failed!!\n{e}"); return(true); } }
private static bool OnRange(TeslaGate __instance, out bool __result, ReferenceHub player) { __result = false; try { var synapseplayer = player.GetPlayer(); if (synapseplayer.Invisible) { return(false); } __result = __instance.InRange(synapseplayer.Position); if (__result) { Server.Get.Events.Map.InvokeTriggerTeslaEv(synapseplayer, __instance.GetTesla(), ref __result); } return(false); } catch (Exception e) { Logger.Get.Error($"Synapse-Event: TriggerTesla failed!!\n{e}"); return(true); } }
private static bool OnRoleChanged(ReferenceHub ply) { try { var player = ply.GetPlayer(); var args = player.setClassEventArgs; //If args is null he is SCP0492 and should not get any Items if (args == null) { return(false); } var inventory = ply.inventory; if (args.IsEscaping) { foreach (var item in player.Inventory.Items) { item.Despawn(); } } else { player.Inventory.Clear(); } foreach (var ammo in args.Ammo) { player.AmmoBox[ammo.Key] = ammo.Value; } foreach (var item in args.Items) { var itembase = player.VanillaInventory.ServerAddItem(item.ItemType, item.Serial); InventoryItemProvider.OnItemProvided?.Invoke(player.Hub, itembase); } if (args.IsEscaping) { foreach (var item in args.EscapeItems) { item.PickUp(player); } } return(false); } catch (Exception e) { Logger.Get.Error($"Synapse-Event: PlayerSetClass(Items) failed!!\n{e}"); return(true); } }
private static void Prefix(ReferenceHub __instance) { try { SynapseController.Server.Events.Player.InvokePlayerLeaveEvent(__instance.GetPlayer()); } catch (Exception e) { SynapseController.Server.Logger.Error($"Synapse-Event: PlayerLeave failed!!\n{e}"); } }
// ReSharper disable once InconsistentNaming public static bool Prefix(ReferenceHub __instance) { try { Events.InvokePlayerLeaveEvent(__instance.GetPlayer()); } catch (Exception e) { Log.Error($"Player Leave Event Error: {e}"); } return(true); }
private static bool CheckFF(out bool __result, ReferenceHub attacker, ReferenceHub victim, bool ignoreConfig = false) { try { __result = SynapseExtensions.GetHarmPermission(attacker.GetPlayer(), victim.GetPlayer(), ignoreConfig); return(false); } catch (Exception e) { Synapse.Api.Logger.Get.Error($"Synapse-API: GetShootPermission failed!!\n{e}\nStackTrace:\n{e.StackTrace}"); __result = true; return(true); } }
private static bool OnReset(ReferenceHub targetHub) { try { if (targetHub?.GetPlayer()?.LiteRoleSet == true) { return(false); } return(true); } catch (Exception ex) { Logger.Get.Error($"Synapse-Event: PlayerSetClass(EffetController) failed!!\n{ex}"); return(true); } }
private static bool OnReset(ReferenceHub ply) { try { if (ply?.GetPlayer().LiteRoleSet == true) { return(false); } return(true); } catch (Exception ex) { Logger.Get.Error($"Synapse-Event: PlayerSetClass(UsableItem) failed!!\n{ex}"); return(true); } }
private static void Prefix(ReferenceHub __instance) { try { var player = __instance.GetPlayer(); if (player.CustomRole != null) { player.CustomRole = null; } SynapseController.Server.Events.Player.InvokePlayerLeaveEvent(player); } catch (Exception e) { SynapseController.Server.Logger.Error($"Synapse-Event: PlayerLeave failed!!\n{e}\nStackTrace:\n{e.StackTrace}"); } }
private static bool DistanceChanged(TantrumEnvironmentalHazard __instance, ReferenceHub player) { try { if (player == null || __instance.DisableEffect || __instance._correctPosition == null) { return(false); } var synapseplayer = player.GetPlayer(); if (Vector3.Distance(player.transform.position, __instance._correctPosition.position) > __instance.DistanceToBeAffected) { return(false); } var allow = true; if ((__instance.SCPImmune && synapseplayer.Team == (int)Team.SCP) || !SynapseExtensions.CanHarmScp(synapseplayer, false) || synapseplayer.GodMode) { allow = false; } Synapse.Api.Events.EventHandler.Get.Player.InvokeTantrum(synapseplayer, __instance, ref allow); if (allow) { Synapse.Api.Logger.Get.Debug("ALLOW TANTRUM"); synapseplayer.PlayerEffectsController.EnableEffect <CustomPlayerEffects.Stained>(2f, false); } return(false); } catch (Exception ex) { Synapse.Api.Logger.Get.Error("Synapse-Event: PlayerWalkOnSinkholeEvent failed!!\n" + ex); return(true); } }
private static bool LockerInteractPatch(Locker __instance, ReferenceHub ply, byte colliderId) { try { if (colliderId >= __instance.Chambers.Length || !__instance.Chambers[colliderId].CanInteract) { return(false); } var player = ply.GetPlayer(); var flag = CheckPerms(player, __instance.Chambers[colliderId].RequiredPermissions); var item = player.ItemInHand; var lockerChamber = __instance.GetLocker().Chambers[colliderId]; if (item?.ItemCategory == ItemCategory.Keycard) { EventHandler.Get.Player.InvokePlayerItemUseEvent(player, item, Api.Events.SynapseEventArguments.ItemInteractState.Finalizing, ref flag); } EventHandler.Get.Map.InvokeLockerInteractEvent(player, lockerChamber, ref flag); if (flag) { lockerChamber.Open = !lockerChamber.Open; } else { __instance.RpcPlayDenied(colliderId); } return(false); } catch (Exception e) { Logger.Get.Error($"Synapse-Event: UseLocker failed!!\n{e}"); return(true); } }
private static bool OnInteract(Scp079Generator __instance, ReferenceHub ply, byte colliderId) { try { var gen = __instance.GetGenerator(); var player = ply.GetPlayer(); if (__instance._cooldownStopwatch.IsRunning && __instance._cooldownStopwatch.Elapsed.TotalSeconds < __instance._targetCooldown) { return(false); } if (colliderId != 0 && !gen.Open) { return(false); } __instance._cooldownStopwatch.Stop(); switch (colliderId) { case 0: if (!gen.Locked) { var allow = true; Server.Get.Events.Player.InvokePlayerGeneratorInteractEvent(player, gen, gen.Open ? GeneratorInteraction.CloseDoor : GeneratorInteraction.OpenDoor, ref allow); if (!allow) { return(false); } gen.Open = !gen.Open; __instance._targetCooldown = __instance._doorToggleCooldownTime; } else { if (!SynapseExtensions.CanHarmScp(player)) { __instance.RpcDenied(); return(false); } var items = new List <SynapseItem>(); if (player.ItemInHand.ID != -1) { items.Add(player.ItemInHand); } if (Server.Get.Configs.synapseConfiguration.RemoteKeyCard) { items.AddRange(player.Inventory.Items.Where(x => x != player.ItemInHand)); } var canOpen = false; foreach (var item in items.Where(x => x.ItemCategory == ItemCategory.Keycard)) { if ((item.ItemBase as KeycardItem).Permissions.HasFlagFast(__instance._requiredPermission)) { canOpen = true; Server.Get.Events.Player.InvokePlayerItemUseEvent(player, item, Api.Events.SynapseEventArguments.ItemInteractState.Finalizing, ref canOpen); break; } } Server.Get.Events.Player.InvokePlayerGeneratorInteractEvent(player, gen, GeneratorInteraction.Unlocked, ref canOpen); if (canOpen) { gen.Locked = false; } else { __instance.RpcDenied(); } __instance._targetCooldown = __instance._unlockCooldownTime; } break; case 1: if ((__instance.Activating || SynapseExtensions.CanHarmScp(player)) && !__instance.Engaged) { var allow = true; Server.Get.Events.Player.InvokePlayerGeneratorInteractEvent(player, gen, gen.Active ? GeneratorInteraction.Disabled : GeneratorInteraction.Activated, ref allow); if (!allow) { return(false); } __instance.Activating = !__instance.Activating; if (__instance.Activating) { __instance._leverStopwatch.Restart(); } __instance._targetCooldown = __instance._doorToggleCooldownTime; } break; case 2: if (__instance.Activating && !__instance.Engaged) { var allow = true; Server.Get.Events.Player.InvokePlayerGeneratorInteractEvent(player, gen, GeneratorInteraction.Disabled, ref allow); if (!allow) { return(false); } gen.Active = false; __instance._targetCooldown = __instance._unlockCooldownTime; } break; default: __instance._targetCooldown = 1; break; } __instance._cooldownStopwatch.Restart(); return(false); } catch (Exception e) { Logger.Get.Error($"Synapse-Event: PlayerGeneratorInteract event failed!!\n{e}"); return(true); } }
private static bool Prefix(DoorVariant __instance, ReferenceHub ply, byte colliderId) { try { if (!NetworkServer.active) { Debug.LogWarning("[Server] function 'System.Void Interactables.Interobjects.DoorUtils.DoorVariant::ServerInteract(ReferenceHub,System.Byte)' called on client"); return(false); } if (__instance.ActiveLocks > 0) { DoorLockMode mode = DoorLockUtils.GetMode((DoorLockReason)__instance.ActiveLocks); if ((!mode.HasFlagFast(DoorLockMode.CanClose) || !mode.HasFlagFast(DoorLockMode.CanOpen)) && (!mode.HasFlagFast(DoorLockMode.ScpOverride) || ply.characterClassManager.CurRole.team != Team.SCP) && (mode == DoorLockMode.FullLock || (__instance.TargetState && !mode.HasFlagFast(DoorLockMode.CanClose)) || (!__instance.TargetState && !mode.HasFlagFast(DoorLockMode.CanOpen)))) { __instance.LockBypassDenied(ply, colliderId); return(false); } } if (__instance.AllowInteracting(ply, colliderId)) { var player = ply.GetPlayer(); var flag = __instance.RequiredPermissions.CheckPermissions(player.VanillaInventory.curItem, ply); var cardaccess = false; var item = player.ItemInHand; if (item != null && item.ItemCategory == ItemCategory.Keycard) { EventHandler.Get.Player.InvokePlayerItemUseEvent(player, item, Api.Events.SynapseEventArguments.ItemInteractState.Finalizing, ref flag); } if (flag) { cardaccess = true; } else if (Server.Get.Configs.SynapseConfiguration.RemoteKeyCard) { foreach (var item2 in player.Inventory.Items.Where(x => x != item && x.ItemCategory == ItemCategory.Keycard)) { var allowcard = __instance.RequiredPermissions.CheckPermissions(item2.ItemType, ply); EventHandler.Get.Player.InvokePlayerItemUseEvent(player, item2, Api.Events.SynapseEventArguments.ItemInteractState.Finalizing, ref allowcard); if (allowcard) { cardaccess = true; break; } } } EventHandler.Get.Map.InvokeDoorInteractEvent(player, __instance.GetDoor(), ref cardaccess); if (ply.characterClassManager.CurClass == RoleType.Scp079 || cardaccess) { __instance.NetworkTargetState = !__instance.TargetState; __instance._triggerPlayer = ply; return(false); } __instance.PermissionsDenied(ply, colliderId); DoorEvents.TriggerAction(__instance, DoorAction.AccessDenied, ply); } return(false); } catch (Exception e) { Logger.Get.Error($"Synapse-Event: DoorInteract failed!!\n{e}"); return(true); } }
private static bool ChargePlayer(PlayableScps.Scp096 __instance, ReferenceHub player) { try { var scp = __instance.GetPlayer(); var target = player.GetPlayer(); if (!HitboxIdentity.CheckFriendlyFire(scp.Hub, target.Hub)) { return(false); } if (Physics.Linecast(scp.transform.position, player.transform.position, LayerMask.GetMask(new string[] { "Default", "Door", "Glass" }))) { return(false); } if (__instance._chargeHitTargets.Contains(player)) { return(false); } try { ev.Get.Scp.InvokeScpAttack(scp, target, Api.Enum.ScpAttackType.Scp096_Tear, out var allow); if (!allow) { return(false); } } catch (Exception e) { Synapse.Api.Logger.Get.Error($"Synapse-Event: ScpAttackEvent(Scp096-Charge) failed!!\n{e}"); } var flag = __instance._targets.Contains(player); var damage = flag ? 9696f : 40f; var flag2 = player.playerStats.DealDamage(new Scp096DamageHandler(__instance, damage, Scp096DamageHandler.AttackType.Charge)); __instance._chargeHitTargets.Add(player); if (flag2) { __instance._targets.Remove(player); Hitmarker.SendHitmarker(__instance.Hub, 1.35f); if (!__instance._chargeKilled) { __instance._chargeCooldownPenaltyAmount++; __instance._chargeKilled = true; } } if (flag) { __instance.EndChargeNextFrame(); } return(false); } catch (Exception e) { Synapse.Api.Logger.Get.Error($"Synapse-Event: Scp096AttackEvent(Charge) failed!!\n{e}"); return(true); } }
private static bool Pry(PlayableScps.Scp096 __instance) { try { if (!__instance.PryingGate) { return(false); } var num = Physics.OverlapSphereNonAlloc(__instance.Hub.playerMovementSync.RealModelPosition, 0.5f, PlayableScps.Scp096._sphereHits, LayerMask.GetMask(new string[] { "Hitbox" })); if (num <= 0) { return(false); } for (int i = 0; i < num; i++) { ReferenceHub componentInParent = PlayableScps.Scp096._sphereHits[i].gameObject.GetComponentInParent <ReferenceHub>(); if (componentInParent == null || componentInParent == __instance.Hub) { continue; } var scp = __instance.GetPlayer(); var target = componentInParent.GetPlayer(); if (!HitboxIdentity.CheckFriendlyFire(scp.Hub, target.Hub)) { continue; } try { ev.Get.Scp.InvokeScpAttack(scp, target, Api.Enum.ScpAttackType.Scp096_Tear, out var allow); if (!allow) { continue; } } catch (Exception e) { Synapse.Api.Logger.Get.Error($"Synapse-Event: ScpAttackEvent(Scp096-Charge) failed!!\n{e}"); } // if (__instance.Hub.playerStats.HurtPlayer(new PlayerStats.HitInfo(9696f, null, DamageTypes.Scp096, __instance.Hub.playerId, false), componentInParent.gameObject, false, true)) if (componentInParent.playerStats.DealDamage(new Scp096DamageHandler(__instance, 9696f, Scp096DamageHandler.AttackType.GateKill))) { if (__instance._targets.Contains(componentInParent)) { __instance._targets.Remove(componentInParent); } NetworkServer.SendToAll(default(PlayableScps.Messages.Scp096OnKillMessage), 0); } } if (Physics.Raycast(__instance.Hub.PlayerCameraReference.position, __instance.Hub.PlayerCameraReference.forward, 2f, LayerMask.GetMask(new string[] { "Default" }))) { __instance.EndChargeNextFrame(); } return(false); } catch (Exception e) { Synapse.Api.Logger.Get.Error($"Synapse-Event: Scp096AttackEvent(Pry) failed!!\n{e}"); return(true); } }
private static bool OnRoleChanged(ReferenceHub ply) { try { var player = ply.GetPlayer(); var args = player.setClassEventArgs; //If args is null he is SCP0492 and should not get any Items or Lite is active if (args == null) { return(false); } var inventory = ply.inventory; if (args.IsEscaping) { foreach (var item in player.Inventory.Items) { item.Despawn(); } } else { player.Inventory.Clear(); } foreach (var ammo in args.Ammo) { player.AmmoBox[ammo.Key] = ammo.Value; } foreach (var item in args.Items) { //TODO: Find a better solution item.ItemData["dur"] = item.Durabillity; var itembase = player.VanillaInventory.ServerAddItem(item.ItemType, item.Serial); InventoryItemProvider.OnItemProvided?.Invoke(player.Hub, itembase); if (!item.ItemData.ContainsKey("setup") && item.ItemData["dur"] is float dur) { item.Durabillity = dur; } } if (args.IsEscaping) { foreach (var item in args.EscapeItems) { item.PickUp(player); } } return(false); } catch (Exception e) { Logger.Get.Error($"Synapse-Event: PlayerSetClass(Items) failed!!\n{e}"); return(true); } }