Skip to content

Commit

Permalink
Merge pull request #9 from rayzerbrain/2.0
Browse files Browse the repository at this point in the history
2.0
  • Loading branch information
rayzerbrain authored Jan 8, 2022
2 parents 56563f0 + 0693b2a commit 0b3b86f
Show file tree
Hide file tree
Showing 9 changed files with 291 additions and 197 deletions.
45 changes: 1 addition & 44 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# Spectator-Shooting-Range
An SCP:SL Exiled 3.0 (3.0 ONLY) plugin implementing a shooting range for spectators. The range is located outside of the wall perpendicular to the escape tunnel, that is, the wall the MTF helicopter flies over.

This is a pretty early plugin of mine, the implementation is not the best and probably won't be updated, be forewarned.

### To install
If you are unfamiliar with installing Exiled plugins, do the following: on this page navigate to the releases link on the right side of the screen and download the latest .dll file. Then, Put this file in your Exiled\Plugins file with any other plugins you might have.

Expand All @@ -27,45 +25,4 @@ Make sure to keep the smae data type when changing the configuration, i.e. don't
The configurations that will appear in your [port number]-config.yml file allows you to do/change the following (values already present are default values upon implementation)
:


///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

Enable or disable the plugin

is_enabled: true

Player broadcast that appears when a player dies or joins as a spectator

death_greeting: To join the shooting range, type .range into your console(`)!

Time in seconds that the death_greeting is broadcasted for (default is 5)

death_greeting_time: 5

Player broadcast that appears when a player enters the shooting range

range_greeting: Welcome to the shooting range! Type .spectate into your console to return to spectator

Time in seconds that Range_greeting is broadcasted for (default is 5)

range_greeting_time: 5

Player broadcast that appears when everyone in the range is returned to spectator to spawn

returning_for_spawn_message: You will be respawning soon!

Distance each set of targets are away from each other (default is 16)

relative_target_distance: 16

Distance all targets are away from the shooting zone (default is 7)

absolute_target_distance: 7

Determines whether players with Remote Admin access are immune to the shooting range bounds (default is true)

ra_bounds_immunity: true

Determines whether players can talk in the shooting range (if enabled it is possible for spectators in the range to hear and talk to living players on the other side of the wall, this does not include players with RA access)

rangers_can_talk: true
//config data here
54 changes: 54 additions & 0 deletions Shooting-Range/API/RangeBoundaries.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
using Exiled.API.Features;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;

namespace ShootingRange.API
{
public class RangeBoundaries
{
public Vector3 spawn = new Vector3(218.5f, 999.1f, -43.0f);
int bigXBound = 237;
int smallXBound = 202;
int bigZBound = -28;
int smallZBound = -54;
int smallYBound = 970;
int bigYBound = 1000;

public RangeBoundaries() { }
public RangeBoundaries(int smallX, int smallZ, int bigX, int bigZ, int smallY, int bigY)
{
smallXBound = smallX;
smallZBound = smallZ;
bigXBound = bigX;
bigZBound = bigZ;
smallYBound = smallY;
bigYBound = bigY;
}
public RangeBoundaries(Vector4 spawn)
{
smallXBound = (int)(spawn.x - spawn.w);
smallZBound = (int)(spawn.z - spawn.w);
smallYBound = (int)(spawn.y - spawn.w);
bigXBound = (int)(spawn.x + spawn.w);
bigZBound = (int)(spawn.z + spawn.w);
bigYBound = (int)(spawn.y + spawn.w);

this.spawn = new Vector3(spawn.x, spawn.y, spawn.z);
}

public bool IsOnRange(Player plyr)
{
return plyr.Position.x < bigXBound
&& plyr.Position.x > smallXBound
&& plyr.Position.z > smallZBound
&& plyr.Position.z < bigZBound
&& plyr.Position.y < bigYBound
&& plyr.Position.y > smallYBound;
}

}
}
25 changes: 16 additions & 9 deletions Shooting-Range/Commands/Range.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
using Exiled.API.Extensions;
using MEC;
using System.Collections.Generic;
using Mirror;

namespace ShootingRange.Commands
{

[CommandHandler(typeof (ClientCommandHandler))]
class Range : ICommand
{
Expand All @@ -20,13 +20,18 @@ class Range : ICommand

public bool Execute(ArraySegment<string> arguments, ICommandSender sender, out string response)
{

Player player = Player.Get((CommandSender)sender);
if(player.Team.Equals(Team.RIP)&&Round.IsStarted)
Player player = Player.Get(sender);
if(player.Role.Equals(RoleType.Spectator)&&Round.IsStarted
&& !PluginMain.Instance.EventHandler.freshlyDead.Contains(player))
{
player.SetRole(RoleType.Tutorial);
player.Broadcast((ushort)ShootingRange.Instance.Config.Range_greeting_time, ShootingRange.Instance.Config.Range_greeting);
player.SetRole(RoleType.Tutorial, Exiled.API.Enums.SpawnReason.None);
player.Broadcast(PluginMain.Instance.Config.RangeGreeting);
Timing.RunCoroutine(EnteringRangeCoroutine(player));
if (!PluginMain.Instance.Config.Rangers_can_talk) //&& !player.RemoteAdminAccess)
{
player.IsMuted = true;
}

}
else
{
Expand All @@ -39,7 +44,8 @@ public bool Execute(ArraySegment<string> arguments, ICommandSender sender, out s
IEnumerator<float> EnteringRangeCoroutine(Player ranger)
{
yield return Timing.WaitForSeconds(.5f);
ranger.Position = new UnityEngine.Vector3((float)218.5, (float)999.1, (float)-43.0);
ranger.Position = PluginMain.Instance.EventHandler.curBounds.spawn;
PluginMain.Instance.EventHandler.rangerList.Add(ranger);
ranger.AddItem(ItemType.GunAK);
ranger.AddItem(ItemType.GunCOM18);
ranger.AddItem(ItemType.GunCrossvec);
Expand All @@ -49,8 +55,9 @@ IEnumerator<float> EnteringRangeCoroutine(Player ranger)
ranger.AddItem(ItemType.GunRevolver);
ranger.AddItem(ItemType.GunShotgun);
ranger.Health = 100000;

ranger.ChangeAppearance(RoleType.ChaosConscript);
}
}
}
}

}
16 changes: 15 additions & 1 deletion Shooting-Range/Commands/Spectate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

namespace ShootingRange.Commands
{

[CommandHandler(typeof(ClientCommandHandler))]
public class Spectate : ICommand
{
Expand All @@ -21,10 +22,23 @@ public bool Execute(ArraySegment<string> arguments, ICommandSender sender, out s
IEnumerator<float> SettingSpectatorCoroutine(Player spectatee)
{
yield return Timing.WaitForSeconds(.5f);
PluginMain.Instance.EventHandler.rangerList.Remove(spectatee);
spectatee.SetRole(RoleType.Spectator);
spectatee.IsMuted = false;
if(!PluginMain.Instance.Config.Rangers_can_talk && !PluginMain.Instance.EventHandler.mutedPlayers.IsEmpty())
{
foreach (Player plyr in PluginMain.Instance.EventHandler.mutedPlayers)
{
if(plyr.Equals(spectatee))
{
spectatee.IsMuted = true;
break;
}
}
}
}
Player player = Player.Get((CommandSender)sender);
if(ShootingRange.Instance.EventHandler.IsOnRange(player))
if(PluginMain.Instance.EventHandler.curBounds.IsOnRange(player))
{
player.ClearInventory(true);
Timing.RunCoroutine(SettingSpectatorCoroutine(player));
Expand Down
47 changes: 36 additions & 11 deletions Shooting-Range/Config.cs
Original file line number Diff line number Diff line change
@@ -1,27 +1,50 @@
using Exiled.API.Interfaces;
using Broadcast = Exiled.API.Features.Broadcast;
using System.ComponentModel;
using UnityEngine;
using System.Collections.Generic;

namespace ShootingRange
{
public class Config : IConfig
{
[Description("Indicates if the plugin is enabled or not")]

[Description("Indicates if the plugin is enabled or not. THIS IS FOR SPAWNING BENCHES, NOT ACTUAL SHOOTING RANGE")]
public bool IsEnabled { get; set; } = true;
[Description("Determines whether the default range will be used. If false, one of the below random coordinates will be chosen each round")]
public bool UseDefaultRange { get; set; } = true;
[Description("List of alternative range locations. The \"w\" will determine the radius of the sphere (rectangle) that forms the boundaries (one has been provided as an example, please don't actually use it)")]
public List<Vector4> OtherRangeLocations { get; set; } = new List<Vector4>()
{
{
Vector4.one
}
};

[Description("Player broadcast that appears when a player dies or joins as a spectator")]
public string Death_greeting { get; set; } = "To join the shooting range, type .range into your console(`)!";

[Description("Time in seconds that the death_greeting is broadcasted for (default is 5)")]
public int Death_greeting_time { get; set; } = 5;
[Description("Player broadcast that appears when a player dies or joins as a spectator")]
public Exiled.API.Features.Broadcast DeathBroadcast { get; set; } = new Exiled.API.Features.Broadcast()
{
Duration = 5,
Content = "Type .range to join the shooting range",
Show = true
};

[Description("Player broadcast that appears when a player enters the shooting range")]
public string Range_greeting { get; set; } = "Welcome to the shooting range! Type .spectate into your console to return to spectator";

[Description("Time in seconds that Range_greeting is broadcasted for (default is 5)")]
public int Range_greeting_time { get; set; } = 5;
public Exiled.API.Features.Broadcast RangeGreeting { get; set; } = new Exiled.API.Features.Broadcast()
{
Duration = 5,
Content = "Welcome to the shooting range! Type .spectate into your console to return (you will be returned automatically for respawns, but you may be affected by an afk detecter)",
Show = true
};

[Description("Player broadcast that appears when everyone in the range is returned to spectator to spawn")]
public string Returning_for_spawn_message { get; set; } = "You will be respawning soon!";
public Exiled.API.Features.Broadcast RespawnBroadcast { get; set; } = new Exiled.API.Features.Broadcast
{
Duration = 5,
Content = "You will be respawning soon!",
Show = true
};

[Description("Distance each set of targets are away from each other (default is 16)")]
public int Relative_target_distance { get; set; } = 16;
Expand All @@ -30,8 +53,10 @@ public class Config : IConfig
public int Absolute_target_distance { get; set; } = 7;

[Description("Determines whether players with Remote Admin access are immune to the shooting range bounds (default is true)")]
public bool RA_bounds_immunity { get; set; } = true;
public bool Ra_bounds_immunity { get; set; } = false;

[Description("Determines whether players can talk in the shooting range (if enabled it is possible for them to hear and talk to living players on the other side of the wall, players with Remote Admin access are exempt from this)")]
public bool Rangers_can_talk { get; set; } = true;

}
}
Loading

0 comments on commit 0b3b86f

Please sign in to comment.