Skip to content

Commit

Permalink
Merge pull request #22 from dargoncat/omegawarhead
Browse files Browse the repository at this point in the history
Omega核弹
  • Loading branch information
Griseo-bh3rd authored Oct 22, 2023
2 parents 012ed89 + 75206de commit 752147d
Show file tree
Hide file tree
Showing 9 changed files with 179 additions and 16 deletions.
33 changes: 33 additions & 0 deletions util/Commands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -247,4 +247,37 @@ public bool Execute(ArraySegment<string> arguments, ICommandSender sender, out s
return true;
}
}

[CommandHandler(typeof(RemoteAdminCommandHandler))]
public class Uaow : ICommand
{
public string Command => "uaow";

public string[] Aliases => Array.Empty<string>();

public string Description => "";

public bool Execute(ArraySegment<string> arguments, ICommandSender sender, out string response)
{
OmegaWarhead.ActivateOmega();
response = "Done!";
return true;
}
}
[CommandHandler(typeof(RemoteAdminCommandHandler))]
public class Usow : ICommand
{
public string Command => "usow";

public string[] Aliases => Array.Empty<string>();

public string Description => "";

public bool Execute(ArraySegment<string> arguments, ICommandSender sender, out string response)
{
OmegaWarhead.StopOmega();
response = "Done!";
return true;
}
}
}
3 changes: 2 additions & 1 deletion util/Gamemode.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Exiled.API.Features;
//Copyright (C) Silver Wolf 2023,All Rights Reserved.
using Exiled.API.Features;
using System;
using System.Collections.Generic;
using System.Linq;
Expand Down
7 changes: 4 additions & 3 deletions util/MainClass.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@ public class PluginConfig : IConfig
public bool EnableAutoCleanup { get; set; } = true;
[Description("每次自动清理的时间(以秒为单位)")]
public float Cleanuptime { get; set; } = 500;
[Description("是否启用系统核弹")]
public bool SystemWarheadEnabled { get; set; } = true;
[Description("系统核弹模式")]
public SystemWarheadMode SystemWarheadEnabled { get; set; } = SystemWarheadMode.Omega;
[Description("系统核弹触发时间")]
public float SystemWarheadTime { get; set; } = 1200;
[Description("系统核弹触发时公告")]
public string SystemWarheadBroadcast { get; set; } = "注意,系统核弹已经启动";
[Description("回合结束后是否自动引爆核弹")]
public bool DetonateOnRoundEnded { get; set; } = false;
public bool DetonateOnRoundEnded { get; set; } = true;
[Description("启用管理员预留位")]
public bool ReserveSlotEnabled { get; set; } = false;
[Description("管理员预留位数量")]
Expand All @@ -54,6 +54,7 @@ public class PluginConfig : IConfig
[Description("MySQL 连接字符串")]
public string MysqlConnectstring { get; set; } = "Server=127.0.0.1;Database=scp5;User=root;Password=awaawa;Charset=utf8";
}
public enum SystemWarheadMode : byte { none, Omega, Alpha }
public class UtilPlugin : Plugin<PluginConfig>
{
public override void OnEnabled()
Expand Down
6 changes: 4 additions & 2 deletions util/Music.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Exiled.API.Features;
//Copyright (C) Silver Wolf 2023,All Rights Reserved.
using Exiled.API.Features;
using Mirror;
using SCPSLAudioApi.AudioCore;
using System;
Expand Down Expand Up @@ -29,7 +30,7 @@ public override void Disconnect()
}
public class Music
{
public static void PlayMusic(string musicname, string name, int vol)
public static AudioPlayerBase PlayMusic(string musicname, string name, int vol)
{
GameObject gameObject = UnityEngine.Object.Instantiate<GameObject>(NetworkManager.singleton.playerPrefab);
System.Random rand = new System.Random();
Expand Down Expand Up @@ -58,6 +59,7 @@ public static void PlayMusic(string musicname, string name, int vol)
}
playerbase.Loop = false;
playerbase.Play(-1);
return playerbase;
}
}
}
115 changes: 115 additions & 0 deletions util/OmegaWarhead.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
//Copyright (C) Silver Wolf 2023,All Rights Reserved.
using Exiled.API.Features;
using Exiled.API.Features.Doors;
using MEC;
using Respawning;
using SCPSLAudioApi.AudioCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;

namespace UtilPlugin
{
public class OmegaWarhead
{
public static List<Player> Helikopter = new List<Player>();
public static List<Player> Shelted = new List<Player>();
public static List<CoroutineHandle> coroutines = new List<CoroutineHandle>();
public static bool OmegaActivated = false;
public static AudioPlayerBase playerBase;
public static void StopOmega()
{
if (OmegaActivated)
{
foreach (CoroutineHandle coroutineHandle in coroutines) Timing.KillCoroutines(coroutineHandle);
playerBase.Stoptrack(true);
Cassie.Message("pitch_0.9 Omega Warhead detonation stopped");
foreach (Room room in Room.List) room.ResetColor();
OmegaActivated = false;
}
}
public static void ActivateOmega()
{
if (OmegaActivated)
{
return;
}
Warhead.Stop();
Warhead.IsLocked = true;
PluginAPI.Core.Server.SendBroadcast("<b><color=red>OMEGA核弹已启用.</color></b>\n请搭乘撤离直升机或前往地下掩体逃生.", 20);
OmegaActivated = true;
Shelted.Clear();
Helikopter.Clear();
foreach (Room room in Room.List)
{
room.Color = Color.cyan;
}
playerBase = Music.PlayMusic("Omega", "Omega核弹警报", 70);
coroutines.Clear();
coroutines.Add(Timing.CallDelayed(150, () => {
foreach(Door door in Door.List)
{
switch (door.Type)
{
case Exiled.API.Enums.DoorType.CheckpointEzHczA:
case Exiled.API.Enums.DoorType.CheckpointEzHczB:
case Exiled.API.Enums.DoorType.CheckpointLczA:
case Exiled.API.Enums.DoorType.CheckpointLczB:
case Exiled.API.Enums.DoorType.GateA:
case Exiled.API.Enums.DoorType.GateB:
door.IsOpen = true;
door.Lock(120, Exiled.API.Enums.DoorLockType.Warhead);
break;
}
}
PluginAPI.Core.Server.SendBroadcast("Door opened", 3, Broadcast.BroadcastFlags.AdminChat);
}));
coroutines.Add(Timing.CallDelayed(165, () => {
PluginAPI.Core.Server.SendBroadcast("撤离直升机将在12秒后到达", 12);
RespawnEffectsController.ExecuteAllEffects(RespawnEffectsController.EffectType.Selection, SpawnableTeamType.NineTailedFox);
}));
coroutines.Add(Timing.CallDelayed(177, () =>
{
foreach (Player player in Player.List)
{
if (player.CurrentRoom.RoomName == MapGeneration.RoomName.EzEvacShelter)
{
Shelted.Add(player);
player.EnableEffect(Exiled.API.Enums.EffectType.Ensnared, 5);
player.EnableEffect(Exiled.API.Enums.EffectType.Flashed, 5);
}
Vector3 Helikopterpos = new Vector3(126, 995, -44);
if (Vector3.Distance(player.Position, Helikopterpos) <= 12)
{
player.Broadcast(4, "You escaped in the helicopter.");
Helikopter.Add(player);
player.EnableEffect(Exiled.API.Enums.EffectType.Ensnared, 12);
player.EnableEffect(Exiled.API.Enums.EffectType.Flashed, 12);
}
}
PluginAPI.Core.Server.SendBroadcast($"{Helikopter.Count} player fly and {Shelted.Count} player shelted", 3, Broadcast.BroadcastFlags.AdminChat);
}));
coroutines.Add(Timing.CallDelayed(184, () =>
{
foreach(Player player in Player.List)
{
if (!Helikopter.Contains(player) && !Shelted.Contains(player))
{
player.Kill("在Omega核弹中蒸发");
}
}
foreach(Player player in Shelted)
{
player.Teleport(new Vector3(29.7f, 992.2f, -25.3f));
}
foreach (Room room in Room.List)
{
room.Color = Color.blue;
}
}));
}
}
}
3 changes: 2 additions & 1 deletion util/RainbowTag.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Exiled.API.Features;
//Copyright (C) Silver Wolf 2023,All Rights Reserved.
using Exiled.API.Features;
using MEC;
using System;
using System.Collections.Generic;
Expand Down
22 changes: 15 additions & 7 deletions util/SystemWarhead.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ public static void OnRoundStarted()
}
public static void Register()
{
if (UtilPlugin.Instance.Config.SystemWarheadEnabled)
if (UtilPlugin.Instance.Config.SystemWarheadEnabled != SystemWarheadMode.none)
{
Exiled.Events.Handlers.Server.RoundStarted += SystemWarhead.OnRoundStarted;
Exiled.Events.Handlers.Server.RestartingRound += SystemWarhead.OnRoundFinished;
Exiled.Events.Handlers.Server.RoundStarted += OnRoundStarted;
Exiled.Events.Handlers.Server.RestartingRound += OnRoundFinished;
}
else
{
Exiled.Events.Handlers.Server.RoundStarted -= SystemWarhead.OnRoundStarted;
Exiled.Events.Handlers.Server.RestartingRound -= SystemWarhead.OnRoundFinished;
Exiled.Events.Handlers.Server.RoundStarted -= OnRoundStarted;
Exiled.Events.Handlers.Server.RestartingRound -= OnRoundFinished;
}
if (UtilPlugin.Instance.Config.DetonateOnRoundEnded)
{
Expand All @@ -41,13 +41,14 @@ public static void Register()
if (true)
{
Voting.Register(new VotingEvent { Action = () => Detonate(false), Name = "sw", Description = "启动系统核[60%]", VotingDes = "系统核弹", Votingpercent = 0.55, AcceptBroadcast = "系统核弹已经启动", CheckBeforeVoting = () => { return true; }, OnVotingEnded = () => { return (double)Voting.AcceptPlayer.Count / (Voting.AcceptPlayer.Count + Voting.AgainstPlayer.Count) >= 0.6; } });
Voting.Register(new VotingEvent { Action = () => ServerConsole.EnterCommand("aow"), Name = "omega", Description = "启动Omega核弹", VotingDes = "启动Omega核弹", AcceptBroadcast = "Omega核弹已启动", CheckBeforeVoting = () => true, OnVotingEnded = () => { return (double)Voting.AcceptPlayer.Count / (Voting.AcceptPlayer.Count + Voting.AgainstPlayer.Count) >= 0.7; } });
Voting.Register(new VotingEvent { Action = () => OmegaWarhead.ActivateOmega(), Name = "omega", Description = "启动Omega核弹", VotingDes = "启动Omega核弹", AcceptBroadcast = "Omega核弹已启动", CheckBeforeVoting = () => true, OnVotingEnded = () => { return (double)Voting.AcceptPlayer.Count / (Voting.AcceptPlayer.Count + Voting.AgainstPlayer.Count) >= 0.7; } });
}
}

public static void OnRoundEnded(RoundEndedEventArgs roundEndedEventArgs)
{
Timing.CallDelayed(5, () => { Warhead.Detonate(); });
OmegaWarhead.StopOmega();
}

public static void OnRoundFinished()
Expand All @@ -57,7 +58,14 @@ public static void OnRoundFinished()
public static IEnumerator<float> SystemWarheadwaiter(float time)
{
yield return Timing.WaitForSeconds(time);
Detonate();
if (UtilPlugin.Instance.Config.SystemWarheadEnabled == SystemWarheadMode.Alpha)
{
Detonate();
}
else
{
OmegaWarhead.ActivateOmega();
}
}
public static void Detonate(bool sendbroadcast = true)
{
Expand Down
1 change: 1 addition & 0 deletions util/UtilPlugin.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@
<Compile Include="Music.cs" />
<Compile Include="Gamemode.cs" />
<Compile Include="MainClass.cs" />
<Compile Include="OmegaWarhead.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="RainbowTag.cs" />
<Compile Include="ReserveSlot.cs" />
Expand Down
5 changes: 3 additions & 2 deletions util/Voting.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Exiled.API.Features;
//Copyright (C) Silver Wolf 2023,All Rights Reserved.
using Exiled.API.Features;
using Exiled.Events.EventArgs.Server;
using MEC;
using System;
Expand Down Expand Up @@ -67,7 +68,7 @@ public static void OnVotingEnded(VotingEvent votingEvent)
if (votingEvent.OnVotingEnded() || Accepted)
{
votingEvent.Action();
PluginAPI.Core.Server.SendBroadcast($"<size=24><color=green>「投票通过」</color>{votingEvent.AcceptBroadcast}</size>", 5, Broadcast.BroadcastFlags.Normal, true);
PluginAPI.Core.Server.SendBroadcast($"<size=24><color=green>「投票通过」</color>{votingEvent.AcceptBroadcast}</size>", 5, Broadcast.BroadcastFlags.Normal);
}
else
{
Expand Down

0 comments on commit 752147d

Please sign in to comment.