public static bool Prefix(FragGrenade __instance, ref bool __result) { Player thrower = Player.Get(__instance.thrower.gameObject); if (Tracking.PlayersWithSubclasses.ContainsKey(thrower) && Tracking.PlayersWithSubclasses[thrower].Abilities.Contains(AbilityType.HealGrenadeFrag)) { UnityEngine.Collider[] colliders = UnityEngine.Physics.OverlapSphere(__instance.transform.position, 4); Subclass.Instance.map.UpdateHealths(colliders, thrower, "HealGrenadeFragHealAmount"); return(false); } string str = (((Grenade)((EffectGrenade)__instance)).thrower != null) ? ((Grenade)((EffectGrenade)__instance)).thrower.hub.LoggedNameFromRefHub() : ((string)"(UNKNOWN)"); string[] textArray1 = new string[] { "Player ", (string)str, "'s ", (string)((Grenade)((EffectGrenade)__instance)).logName, " grenade exploded." }; ServerLogs.AddLog(ServerLogs.Modules.Logger, string.Concat((string[])textArray1), ServerLogs.ServerLogType.GameEvent, false); if (((EffectGrenade)__instance).serverGrenadeEffect != null) { Transform transform = ((Grenade)((EffectGrenade)__instance)).transform; Object.Instantiate <GameObject>(((EffectGrenade)__instance).serverGrenadeEffect, transform.position, transform.rotation); } Vector3 position = ((EffectGrenade)__instance).transform.position; int num = 0; Collider[] colliderArray = Physics.OverlapSphere(position, __instance.chainTriggerRadius, (int)__instance.damageLayerMask); int index = 0; while (index < colliderArray.Length) { Collider collider = colliderArray[index]; BreakableWindow component = collider.GetComponent <BreakableWindow>(); if (component != null) { if ((component.transform.position - position).sqrMagnitude <= __instance.sqrChainTriggerRadius) { component.ServerDamageWindow(500f); } } else { Door componentInParent = collider.GetComponentInParent <Door>(); if (componentInParent != null) { if ((!componentInParent.GrenadesResistant && (!componentInParent.commandlock && (!componentInParent.decontlock && !componentInParent.lockdown))) && ((componentInParent.transform.position - position).sqrMagnitude <= __instance.sqrChainTriggerRadius)) { componentInParent.DestroyDoor(true); } } else if (((__instance.chainLengthLimit == -1) || (__instance.chainLengthLimit > ((EffectGrenade)__instance).currentChainLength)) && ((__instance.chainConcurrencyLimit == -1) || (__instance.chainConcurrencyLimit > num))) { Pickup componentInChildren = collider.GetComponentInChildren <Pickup>(); if ((componentInChildren != null) && __instance.ChangeIntoGrenade(componentInChildren)) { num = (int)(num + 1); } } } index = (int)(index + 1); } Player pthrower = Player.Get(((EffectGrenade)__instance).thrower.gameObject); foreach (GameObject obj2 in PlayerManager.players) { if (!ServerConsole.FriendlyFire && ((obj2 != ((EffectGrenade)__instance).thrower.gameObject) && (!obj2.GetComponent <WeaponManager>().GetShootPermission(((EffectGrenade)__instance).throwerTeam, false))) && !Tracking.PlayerHasFFToPlayer(pthrower, Player.Get(obj2))) { Exiled.API.Features.Log.Debug($"Player {Player.Get(obj2)?.Nickname} could not be hurt from a grenade. Thrower has ff to player: {Tracking.PlayerHasFFToPlayer(pthrower, Player.Get(obj2))}", Subclass.Instance.Config.Debug); continue; } PlayerStats component = obj2.GetComponent <PlayerStats>(); if ((component != null) && component.ccm.InWorld) { float amount = (float)(__instance.damageOverDistance.Evaluate(Vector3.Distance(position, component.transform.position)) * (component.ccm.IsHuman() ? ConfigFile.ServerConfig.GetFloat("human_grenade_multiplier", 0.7f) : ConfigFile.ServerConfig.GetFloat("scp_grenade_multiplier", 1f))); if (amount > __instance.absoluteDamageFalloff) { Exiled.API.Features.Log.Debug($"Attempting to hurt player {Player.Get(obj2)?.Nickname} with a grenade", Subclass.Instance.Config.Debug); Transform[] grenadePoints = component.grenadePoints; index = 0; while (true) { if (index < grenadePoints.Length) { Transform transform = grenadePoints[index]; if (Physics.Linecast(position, transform.position, (int)__instance.hurtLayerMask)) { index = (int)(index + 1); continue; } component.HurtPlayer(new PlayerStats.HitInfo(amount, (((EffectGrenade)__instance).thrower != null) ? ((EffectGrenade)__instance).thrower.hub.LoggedNameFromRefHub() : ((string)"(UNKNOWN)"), DamageTypes.Grenade, ((EffectGrenade)__instance).thrower.hub.queryProcessor.PlayerId), obj2, false); } if (!component.ccm.IsAnyScp()) { ReferenceHub hub = ReferenceHub.GetHub(obj2); float duration = __instance.statusDurationOverDistance.Evaluate(Vector3.Distance(position, component.transform.position)); hub.playerEffectsController.EnableEffect(hub.playerEffectsController.GetEffect <Burned>(), duration, false); hub.playerEffectsController.EnableEffect(hub.playerEffectsController.GetEffect <Concussed>(), duration, false); } break; } } } } __result = true; return(false); }
public static bool Prefix(FragGrenade __instance, ref bool __result) { Player thrower = Player.Get(__instance.thrower.gameObject); Dictionary <Player, float> damages = new Dictionary <Player, float>(); Vector3 position = ((EffectGrenade)__instance).transform.position; int num = 0; Collider[] colliderArray = Physics.OverlapSphere(position, __instance.chainTriggerRadius, (int)__instance.damageLayerMask); int index = 0; foreach (GameObject obj2 in PlayerManager.players) { if (!ServerConsole.FriendlyFire && ((obj2 != ((EffectGrenade)__instance).thrower.gameObject) && (!obj2.GetComponent <WeaponManager>().GetShootPermission(((EffectGrenade)__instance).throwerTeam, false)))) { continue; } PlayerStats component = obj2.GetComponent <PlayerStats>(); if ((component != null) && component.ccm.InWorld) { float amount = (float)(__instance.damageOverDistance.Evaluate(Vector3.Distance(position, component.transform.position)) * (component.ccm.IsHuman() ? ConfigFile.ServerConfig.GetFloat("human_grenade_multiplier", 0.7f) : ConfigFile.ServerConfig.GetFloat("scp_grenade_multiplier", 1f))); damages.Add(Player.Get(obj2), amount); } } var ev = new ExplodingGrenadeEventArgs(thrower, damages, true, __instance.gameObject); Exiled.Events.Handlers.Map.OnExplodingGrenade(ev); if (!ev.IsAllowed) { return(false); } while (index < colliderArray.Length) { Collider collider = colliderArray[index]; BreakableWindow component = collider.GetComponent <BreakableWindow>(); if (component != null) { if ((component.transform.position - position).sqrMagnitude <= __instance.sqrChainTriggerRadius) { component.ServerDamageWindow(500f); } } else { DoorVariant componentInParent = collider.GetComponentInParent <DoorVariant>(); if (componentInParent != null && componentInParent is IDamageableDoor damageableDoor) { damageableDoor.ServerDamage(__instance.damageOverDistance.Evaluate(Vector3.Distance(position, componentInParent.transform.position)), DoorDamageType.Grenade); } else if (((__instance.chainLengthLimit == -1) || (__instance.chainLengthLimit > ((EffectGrenade)__instance).currentChainLength)) && ((__instance.chainConcurrencyLimit == -1) || (__instance.chainConcurrencyLimit > num))) { Pickup componentInChildren = collider.GetComponentInChildren <Pickup>(); if ((componentInChildren != null) && __instance.ChangeIntoGrenade(componentInChildren)) { num = (int)(num + 1); } } } index = (int)(index + 1); } foreach (var item in damages) { if (item.Value > __instance.absoluteDamageFalloff) { PlayerStats component = item.Key.GameObject.GetComponent <PlayerStats>(); Transform[] grenadePoints = component.grenadePoints; index = 0; while (true) { if (index < grenadePoints.Length) { Transform transform = grenadePoints[index]; if (Physics.Linecast(position, transform.position, (int)__instance.hurtLayerMask)) { index = (int)(index + 1); continue; } component.HurtPlayer(new PlayerStats.HitInfo(item.Value, (((EffectGrenade)__instance).thrower != null) ? ((EffectGrenade)__instance).thrower.hub.LoggedNameFromRefHub() : ((string)"(UNKNOWN)"), DamageTypes.Grenade, ((EffectGrenade)__instance).thrower.hub.queryProcessor.PlayerId), item.Key.GameObject, false); } if (!component.ccm.IsAnyScp()) { ReferenceHub hub = item.Key.ReferenceHub; float duration = __instance.statusDurationOverDistance.Evaluate(Vector3.Distance(position, component.transform.position)); hub.playerEffectsController.EnableEffect(hub.playerEffectsController.GetEffect <Burned>(), duration, false); hub.playerEffectsController.EnableEffect(hub.playerEffectsController.GetEffect <Concussed>(), duration, false); } break; } } } //if (Tracking.PlayersWithSubclasses.ContainsKey(thrower) && Tracking.PlayersWithSubclasses[thrower].Abilities.Contains(AbilityType.HealGrenadeFrag)) //{ // if (!Tracking.CanUseAbility(thrower, AbilityType.HealGrenadeFrag, Tracking.PlayersWithSubclasses[thrower])) // { // Tracking.DisplayCantUseAbility(thrower, AbilityType.HealGrenadeFrag, Tracking.PlayersWithSubclasses[thrower], "heal frag"); // } // else // { // Tracking.UseAbility(thrower, AbilityType.HealGrenadeFrag, Tracking.PlayersWithSubclasses[thrower]); // UnityEngine.Collider[] colliders = UnityEngine.Physics.OverlapSphere(__instance.transform.position, 4); // Subclass.Instance.map.UpdateHealths(colliders, thrower, "HealGrenadeFragHealAmount"); // return false; // } //} string str = (((Grenade)((EffectGrenade)__instance)).thrower != null) ? ((Grenade)((EffectGrenade)__instance)).thrower.hub.LoggedNameFromRefHub() : ((string)"(UNKNOWN)"); string[] textArray1 = new string[] { "Player ", (string)str, "'s ", (string)((Grenade)((EffectGrenade)__instance)).logName, " grenade exploded." }; ServerLogs.AddLog(ServerLogs.Modules.Logger, string.Concat((string[])textArray1), ServerLogs.ServerLogType.GameEvent, false); if (((EffectGrenade)__instance).serverGrenadeEffect != null) { Transform transform = ((Grenade)((EffectGrenade)__instance)).transform; Object.Instantiate <GameObject>(((EffectGrenade)__instance).serverGrenadeEffect, transform.position, transform.rotation); } __result = true; return(false); }