improve bloodfueled & serpents
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
using AdminToys;
|
||||
using CommandSystem;
|
||||
using CustomPlayerEffects;
|
||||
using HintServiceMeow.Core.Enum;
|
||||
@@ -9,16 +10,29 @@ using LabApi.Events.Handlers;
|
||||
using LabApi.Features.Permissions;
|
||||
using LabApi.Features.Wrappers;
|
||||
using MEC;
|
||||
using Mirror;
|
||||
using PlayerRoles;
|
||||
using UnityEngine;
|
||||
using LightSourceToy = LabApi.Features.Wrappers.LightSourceToy;
|
||||
using Logger = LabApi.Features.Console.Logger;
|
||||
using PrimitiveObjectToy = LabApi.Features.Wrappers.PrimitiveObjectToy;
|
||||
using Random = System.Random;
|
||||
|
||||
namespace CustomClasses;
|
||||
|
||||
public class SerpentsHandManager
|
||||
{
|
||||
public static bool IsSerpentsHand(Player player) => player.CustomInfo.Contains("SerpentsHand");
|
||||
public static bool IsSerpentsHand(Player player)
|
||||
{
|
||||
try
|
||||
{
|
||||
return player.CustomInfo.Contains("SerpentsHand");
|
||||
}
|
||||
catch
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private readonly CustomClasses _customClasses;
|
||||
public SerpentsHandManager(CustomClasses customClasses)
|
||||
@@ -114,8 +128,6 @@ public class SerpentsHandManager
|
||||
{
|
||||
yield return Timing.WaitForSeconds(1);
|
||||
|
||||
RoundSummary.singleton.ExtraTargets = Player.ReadyList.Count(IsSerpentsHand);
|
||||
|
||||
if (_customClasses.ClassManager.GetSpawnState(typeof(SerpentsHandConfig)) is not SerpentsHandState state) continue;
|
||||
|
||||
foreach (var player in Player.ReadyList)
|
||||
@@ -138,20 +150,64 @@ public class SerpentsHandManager
|
||||
}
|
||||
// ReSharper disable once IteratorNeverReturns
|
||||
}
|
||||
|
||||
public void SpawnSerpentWave()
|
||||
{
|
||||
var state = (SerpentsHandState)CustomClasses.Instance.ClassManager.GetSpawnState(typeof(SerpentsHandConfig));
|
||||
|
||||
var serpentsHandConfig = _customClasses.SerpentsHandConfig;
|
||||
|
||||
state.SetSpawned();
|
||||
state.SetWillSpawn();
|
||||
|
||||
var possibleLocations = (Vector3[])serpentsHandConfig.SpawnLocations.Clone();
|
||||
|
||||
possibleLocations.ShuffleListSecure();
|
||||
|
||||
var spawnLocation = possibleLocations[0];
|
||||
|
||||
foreach (var possibleLocation in possibleLocations)
|
||||
{
|
||||
if (Player.ReadyList.Any(p => (p.Position - possibleLocation).SqrMagnitudeIgnoreY() < 400))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
spawnLocation = possibleLocation;
|
||||
break;
|
||||
}
|
||||
|
||||
state.SpawnLocation = spawnLocation;
|
||||
|
||||
var light = LightSourceToy.Create(spawnLocation + new Vector3(0, 2, 0), Quaternion.identity);
|
||||
light.Color = Color.blue;
|
||||
light.Intensity = 3;
|
||||
light.Range = 40;
|
||||
|
||||
var spaceTimeHole = PrimitiveObjectToy.Create(spawnLocation + new Vector3(0, 2, 0), Quaternion.identity);
|
||||
spaceTimeHole.Color = new Color(44.7f, 73.7f, 83.1f, 0.5f);
|
||||
spaceTimeHole.Flags = PrimitiveFlags.Visible;
|
||||
spaceTimeHole.Scale *= 2;
|
||||
|
||||
Timing.CallDelayed(20, () =>
|
||||
{
|
||||
spaceTimeHole.Destroy();
|
||||
light.Destroy();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public sealed record SerpentsHandState: SpawnState
|
||||
{
|
||||
public bool HasSpawned => _hasSpawned || PanicDisable || Warhead.IsDetonated;
|
||||
public bool HasSpawned => _hasSpawned || Warhead.IsDetonated;
|
||||
public float ExtraChance;
|
||||
public int Points;
|
||||
public bool WillSpawn => _willSpawn && !PanicDisable && !Warhead.IsDetonated;
|
||||
public bool WillSpawn => _willSpawn && !Warhead.IsDetonated;
|
||||
|
||||
private bool _hasSpawned;
|
||||
private bool _willSpawn;
|
||||
|
||||
public bool PanicDisable;
|
||||
|
||||
public Vector3? SpawnLocation;
|
||||
|
||||
public override void Reset()
|
||||
{
|
||||
base.Reset();
|
||||
@@ -159,6 +215,7 @@ public sealed record SerpentsHandState: SpawnState
|
||||
ExtraChance = 0f;
|
||||
Points = 0;
|
||||
_willSpawn = false;
|
||||
SpawnLocation = null;
|
||||
}
|
||||
|
||||
public void SetSpawned()
|
||||
@@ -183,8 +240,10 @@ public sealed class SerpentsHandConfig : CustomClassConfig
|
||||
public override int MaxSpawns { get; set; } = int.MaxValue;
|
||||
public override RoleTypeId RequiredRole { get; set; } = RoleTypeId.Tutorial;
|
||||
public override ItemType[] Items { get; set; } = [ItemType.Painkillers, ItemType.Medkit, ItemType.ArmorCombat];
|
||||
|
||||
public const float BaseChance = 20f;
|
||||
|
||||
public const float BaseChance = 90f;
|
||||
|
||||
public readonly Vector3[] SpawnLocations = [new(0.22f, 300.96f, -0.31f), new(123.921f, 288.792f, 20.929f)];
|
||||
}
|
||||
|
||||
public class SerpentsHandHandler : SimpleAddItemHandler
|
||||
@@ -192,11 +251,13 @@ public class SerpentsHandHandler : SimpleAddItemHandler
|
||||
public override void HandleSpawn(Player player, CustomClassConfig config, Random random)
|
||||
{
|
||||
base.HandleSpawn(player, config, random);
|
||||
|
||||
var spawnLocation = ((SerpentsHandState)CustomClasses.Instance.ClassManager.GetSpawnState(
|
||||
typeof(SerpentsHandConfig))).SpawnLocation;
|
||||
if (spawnLocation !=
|
||||
null)
|
||||
CustomClasses.Instance.ClassManager.TeleportPlayerToAround(player, (Vector3)spawnLocation);
|
||||
|
||||
// player.Position = new Vector3(123.921f + (float)(random.NextDouble() * 2 - 1), 288.792f, 20.929f + (float)(random.NextDouble() * 2 - 1));
|
||||
|
||||
player.Position = new Vector3(0.22f + (float)(random.NextDouble() * 2 - 1), 300.96f, -0.31f + (float)(random.NextDouble() * 2 - 1));
|
||||
|
||||
ItemType[] guns = [ItemType.GunAK, ItemType.GunE11SR, ItemType.GunCrossvec];
|
||||
var gun = guns[random.Next(0, guns.Length-1)];
|
||||
var gunPickup = Pickup.Create(gun, Vector3.one);
|
||||
@@ -233,52 +294,37 @@ public class SerpentsHandHandler : SimpleAddItemHandler
|
||||
player.EnableEffect<MovementBoost>(20, 30);
|
||||
|
||||
player.SendBroadcast("You're a <color=#2E8B57>Serpent's Hand</color> member!", CustomClasses.BroadcastDuration);
|
||||
|
||||
player.EnableEffect<SpawnProtected>(1, 20f);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
[CommandHandler(typeof(RemoteAdminCommandHandler))]
|
||||
public class PanicDisableRemoteAdminCommand : ICommand
|
||||
{
|
||||
public string Command => "panicdisableserpentshand";
|
||||
public string[] Aliases => [];
|
||||
public string Description => "Panic disable Serpents Hand.";
|
||||
|
||||
public bool Execute(ArraySegment<string> arguments, ICommandSender sender, out string response)
|
||||
{
|
||||
var state = (SerpentsHandState)CustomClasses.Instance.ClassManager.GetSpawnState(typeof(SerpentsHandConfig));
|
||||
state.PanicDisable = true;
|
||||
|
||||
response = "Serpents Hand has been disabled.";
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
[CommandHandler(typeof(ClientCommandHandler))]
|
||||
public class PanicDisableCommand : ICommand
|
||||
public class SpawnSerpentsCommand : ICommand
|
||||
{
|
||||
public string Command => "panicdisableserpentshand";
|
||||
public string Command => "spsh";
|
||||
public string[] Aliases => [];
|
||||
public string Description => "Panic disable Serpents Hand.";
|
||||
public string Description => "Makes sure serpents hand spawns";
|
||||
|
||||
public bool Execute(ArraySegment<string> arguments, ICommandSender sender, out string response)
|
||||
{
|
||||
if (!Player.TryGet(sender, out var player))
|
||||
var executor = Player.Get(sender);
|
||||
if (executor == null)
|
||||
{
|
||||
response = "You must be a player to use this command!";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!player.HasPermissions("panicdisable.serpentshand") && player.UserId != "76561198372587687@steam")
|
||||
if (!executor.HasPermissions("customclasses.setcustomclass"))
|
||||
{
|
||||
response = "You must have the permission to use this command!";
|
||||
response = "You do not have permission to use this command!";
|
||||
return false;
|
||||
}
|
||||
|
||||
var state = (SerpentsHandState)CustomClasses.Instance.ClassManager.GetSpawnState(typeof(SerpentsHandConfig));
|
||||
state.PanicDisable = true;
|
||||
CustomClasses.Instance.SerpentsHandManager.SpawnSerpentWave();
|
||||
|
||||
response = "Serpents Hand has been disabled.";
|
||||
response = "success";
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user