public static void RunKillTool(UnturnedPlayer Player, RaycastResult Raycast) { if (Raycast.ParentHasComponent <Player>()) { Player player = Raycast.TryGetEntity <Player>(); if (player.channel.owner.playerID.steamID.m_SteamID == Player.CSteamID.m_SteamID) { return; } player.life.askDamage(100, player.look.aim.forward, EDeathCause.KILL, ELimb.SKULL, Player.CSteamID, out _, true, ERagdollEffect.GOLD, true, true); } else if (Raycast.ParentHasComponent <Zombie>()) { Zombie zombie = Raycast.TryGetEntity <Zombie>(); zombie.killWithFireExplosion(); } else if (Raycast.ParentHasComponent <Animal>()) { Raycast.TryGetEntity <Animal>().askDamage(ushort.MaxValue, Vector3.one, out _, out _, false, true, ERagdollEffect.NONE); } }
public static void RunPointTool(UnturnedPlayer Player, PlayerSession Session, UnturnedPlayerEvents.PlayerGesture gesture) { if (Session.PointTool == PointToolMode.Destroy) { RaycastResult Raycast = RaycastUtility.RayCastPlayer(Player, RayMasks.BARRICADE | RayMasks.STRUCTURE | RayMasks.VEHICLE); if (Raycast.RaycastHit) { RunDestroyTool(Player, Raycast); } } else if (Session.PointTool == PointToolMode.Utility) { RaycastResult Raycast = RaycastUtility.RayCastPlayer(Player, RayMasks.BARRICADE | RayMasks.STRUCTURE | RayMasks.VEHICLE); if (Raycast.RaycastHit) { RunUtilityTool(Player, Raycast); } } else if (Session.PointTool == PointToolMode.Repair) { RaycastResult Raycast = RaycastUtility.RayCastPlayer(Player, RayMasks.BARRICADE | RayMasks.STRUCTURE | RayMasks.VEHICLE); if (Raycast.RaycastHit) { RunRepairTool(Player, Raycast); } } else if (Session.PointTool == PointToolMode.Kill) { RaycastResult CloseEnemyCheck = RaycastUtility.RayCastPlayer(Player, RayMasks.AGENT | RayMasks.ENEMY, 7); RaycastResult ClosePlayerCheck = RaycastUtility.RayCastPlayer(Player, RayMasks.PLAYER, 10); if (ClosePlayerCheck.RaycastHit && ClosePlayerCheck.ParentHasComponent <Player>() && ClosePlayerCheck.TryGetEntity <Player>().channel.owner.playerID.steamID.m_SteamID != Player.CSteamID.m_SteamID) { RunKillTool(Player, ClosePlayerCheck); } else if (CloseEnemyCheck.RaycastHit) { RunKillTool(Player, CloseEnemyCheck); } else { Vector3 RaycastSpot = Player.Player.look.aim.position + (Player.Player.look.aim.forward.normalized * 0.5f); RaycastResult Raycast = RaycastUtility.Raycast(RaycastSpot, Player.Player.look.aim.forward, RayMasks.ENEMY | RayMasks.PLAYER | RayMasks.AGENT); if (Raycast.RaycastHit) { RunKillTool(Player, Raycast); } } } else if (Session.PointTool == PointToolMode.Jump) { RaycastResult Raycast = RaycastUtility.RayCastPlayerAll(Player, 5000); if (Raycast.RaycastHit) { RunJumpTool(Player, Raycast, gesture); } } }
public static void RunUtilityTool(UnturnedPlayer Player, RaycastResult Raycast) { if (Raycast.ParentHasComponent <InteractableCharge>()) { Raycast.TryGetEntity <InteractableCharge>().detonate(Player.CSteamID); } if (Raycast.ParentHasComponent <InteractableFire>()) { var f = Raycast.TryGetEntity <InteractableFire>(); BarricadeManager.ServerSetFireLit(f, !f.isLit); } if (Raycast.ParentHasComponent <InteractableGenerator>()) { var f = Raycast.TryGetEntity <InteractableGenerator>(); BarricadeManager.ServerSetGeneratorPowered(f, !f.isPowered); } if (Raycast.ParentHasComponent <InteractableOven>()) { var f = Raycast.TryGetEntity <InteractableOven>(); BarricadeManager.ServerSetOvenLit(f, !f.isLit); } if (Raycast.ParentHasComponent <InteractableOxygenator>()) { var f = Raycast.TryGetEntity <InteractableOxygenator>(); BarricadeManager.ServerSetOxygenatorPowered(f, !f.isPowered); } if (Raycast.ParentHasComponent <InteractableSafezone>()) { var f = Raycast.TryGetEntity <InteractableSafezone>(); BarricadeManager.ServerSetSafezonePowered(f, !f.isPowered); } if (Raycast.ParentHasComponent <InteractableSpot>()) { var f = Raycast.TryGetEntity <InteractableSpot>(); BarricadeManager.ServerSetSpotPowered(f, !f.isPowered); } if (Raycast.ParentHasComponent <InteractableVehicle>()) { var f = Raycast.TryGetEntity <InteractableVehicle>(); VehicleManager.ServerForcePassengerIntoVehicle(Player.Player, f); } if (Raycast.ParentHasComponent <InteractableBed>()) { var f = Raycast.TryGetEntity <InteractableBed>(); if (f.owner.m_SteamID != 0) { UnturnedChat.Say(Player, "PointTool_Utility_Bed_ShowOwner".Translate($"{AdminToolsPlugin.Instance.GetPlayerName(f.owner.m_SteamID, "Unknown Player")} ({f.owner})")); } else { UnturnedChat.Say(Player, "PointTool_Utility_Bed_NotClaimed".Translate());; } } if (Raycast.ParentHasComponent <InteractableDoor>()) { var f = Raycast.TryGetEntity <InteractableDoor>(); SendOpenDoor(Raycast.BarricadePlant, Raycast.BarricadeX, Raycast.BarricadeY, Raycast.BarricadeIndex, f, Raycast.BarricadeRegion); } if (Raycast.ParentHasComponent <InteractableStorage>()) { InteractableStorage Storage = Raycast.TryGetEntity <InteractableStorage>(); Player.Player.inventory.updateItems(7, Storage.items); Player.Player.inventory.sendStorage(); } }