|
| 1 | +using Exiled.API.Enums; |
| 2 | +using Exiled.API.Features; |
| 3 | +using Exiled.CustomRoles.API.Features; |
| 4 | +using Exiled.API.Features.Attributes; |
| 5 | +using System.Collections.Generic; |
| 6 | +using PlayerRoles; |
| 7 | +using UnityEngine; |
| 8 | +using MEC; |
| 9 | +using Exiled.API.Extensions; |
| 10 | +using Exiled.Events.EventArgs.Player; |
| 11 | +using EvHandler = Exiled.Events.Handlers; |
| 12 | +using YamlDotNet.Serialization; |
| 13 | +using System.ComponentModel; |
| 14 | +using Exiled.API.Features.Spawn; |
| 15 | +using SCP_600V.Events; |
| 16 | + |
| 17 | +namespace SCP_600V.Extension |
| 18 | +{ |
| 19 | + /// <summary> |
| 20 | + /// the main component of the role acting as its basis |
| 21 | + /// </summary> |
| 22 | + [CustomRole(RoleTypeId.Tutorial)] |
| 23 | + internal class Scp600Base : CustomRole |
| 24 | + { |
| 25 | + public override string CustomInfo { get; set; } = "SCP-600V"; |
| 26 | + |
| 27 | + public override string Name { get; set; } = "SCP-600V"; |
| 28 | + |
| 29 | + public override int MaxHealth { get; set; } = 400; |
| 30 | + |
| 31 | + [Description("whether it will be shown next to the player's name that he is SCP-600V")] |
| 32 | + public bool VisibleScpName { get; set; } = true; |
| 33 | + |
| 34 | + [YamlIgnore] |
| 35 | + public override RoleTypeId Role { get; set; } = RoleTypeId.Tutorial; |
| 36 | + |
| 37 | + [Description("the initial appearance of the object during behavior (preferably left as it will follow among class D)")] |
| 38 | + public RoleTypeId StartAppearance { get; set; } = RoleTypeId.ClassD; |
| 39 | + |
| 40 | + public override string Description { get; set; } = "<color=\"purple\">Help other scp complete task</color>"; |
| 41 | + |
| 42 | + public override uint Id { get; set; } = 96; |
| 43 | + |
| 44 | + public override List<string> Inventory { get; set; } = new List<string>() { ItemType.KeycardScientist.ToString()}; |
| 45 | + |
| 46 | + public override string ConsoleMessage { get; set; } = "<color=\"green\">Your are spawned as</color> <color=\"red\">SCP-600V</color>"; |
| 47 | + [YamlIgnore] |
| 48 | + public RoleTypeId VisibledRole { get; set; } |
| 49 | + [YamlIgnore] |
| 50 | + public override bool KeepPositionOnSpawn { get; set; } |
| 51 | + [YamlIgnore] |
| 52 | + public override bool KeepRoleOnDeath { get; set; } = false; |
| 53 | + [YamlIgnore] |
| 54 | + public override bool KeepRoleOnChangingRole { get; set; } = false; |
| 55 | + [YamlIgnore] |
| 56 | + public override float SpawnChance { get; set; } |
| 57 | + [YamlIgnore] |
| 58 | + public override SpawnProperties SpawnProperties { get; set; } = new SpawnProperties(); |
| 59 | + [YamlIgnore] |
| 60 | + public override List<CustomAbility> CustomAbilities { get; set; } = new List<CustomAbility>(); |
| 61 | + [Description("will allow you to change the size of scp but personally I would not change")] |
| 62 | + public override Vector3 Scale { get; set; } = new Vector3(1, 1, 1); |
| 63 | + |
| 64 | + public override Dictionary<RoleTypeId, float> CustomRoleFFMultiplier { get; set; } = new Dictionary<RoleTypeId, float>() |
| 65 | + { |
| 66 | + { RoleTypeId.Scp049, 0 }, |
| 67 | + { RoleTypeId.Scp173, 0 }, |
| 68 | + { RoleTypeId.Scp096, 0 }, |
| 69 | + { RoleTypeId.Scp939, 0 }, |
| 70 | + { RoleTypeId.Scp0492, 0 }, |
| 71 | + { RoleTypeId.Scp106, 0 } |
| 72 | + }; |
| 73 | + public override Dictionary<AmmoType, ushort> Ammo { get; set; } = new Dictionary<AmmoType, ushort>() |
| 74 | + { |
| 75 | + { AmmoType.Nato9, 30 }, |
| 76 | + { AmmoType.Ammo44Cal, 0 }, |
| 77 | + { AmmoType.Nato556, 0 }, |
| 78 | + { AmmoType.Nato762, 0 }, |
| 79 | + { AmmoType.Ammo12Gauge, 0} |
| 80 | + }; |
| 81 | + public List<ItemType> DontUserItems { get; private set; } = new List<ItemType>() |
| 82 | + { |
| 83 | + ItemType.MicroHID |
| 84 | + }; |
| 85 | + |
| 86 | + public override void AddRole(Player player) |
| 87 | + { |
| 88 | + if (this.Role != RoleTypeId.None) |
| 89 | + { |
| 90 | + Vector3 pos = player.Position; |
| 91 | + player.Role.Set(this.Role, RoleSpawnFlags.None); |
| 92 | + Timing.CallDelayed(1f, () => |
| 93 | + { |
| 94 | + player.Position = pos; |
| 95 | + player.ClearInventory(); |
| 96 | + foreach (string PlyItem in this.Inventory) |
| 97 | + { |
| 98 | + this.TryAddItem(player, PlyItem); |
| 99 | + } |
| 100 | + foreach (AmmoType key in this.Ammo.Keys) |
| 101 | + { |
| 102 | + player.SetAmmo(key, this.Ammo[key]); |
| 103 | + } |
| 104 | + player.Health = (float)this.MaxHealth; |
| 105 | + player.MaxHealth = (float)this.MaxHealth; |
| 106 | + if (!player.RemoteAdminAccess | this.VisibleScpName) |
| 107 | + { |
| 108 | + player.RankName = "SCP-600V"; |
| 109 | + player.RankColor = Sai.Instance.Config.BadgeColor; |
| 110 | + } |
| 111 | + this.ShowMessage(player); |
| 112 | + this.TrackedPlayers.Add(player); |
| 113 | + this.RoleAdded(player); |
| 114 | + player.UniqueRole = this.Name; |
| 115 | + player.TryAddCustomRoleFriendlyFire(this.Name, this.CustomRoleFFMultiplier); |
| 116 | + player.Scale = this.Scale; |
| 117 | + if (this.VisibleScpName) |
| 118 | + { |
| 119 | + player.CustomInfo = $"{player.Nickname}\n{this.CustomInfo}"; |
| 120 | + player.InfoArea &= ~PlayerInfoArea.Role; |
| 121 | + } |
| 122 | + if (Sai.Instance.Config.CanBleading) |
| 123 | + { |
| 124 | + Timing.RunCoroutine(this.Hurting(player), $"{player.Id}-hurt"); |
| 125 | + } |
| 126 | + try |
| 127 | + { |
| 128 | + player.SessionVariables.Add("IsSCP600", null); |
| 129 | + player.SessionVariables.Add("IsScp", null); |
| 130 | + } |
| 131 | + catch |
| 132 | + { |
| 133 | + |
| 134 | + } |
| 135 | + }); |
| 136 | + Events.EventArg.SpawnedEventArgs e = new Events.EventArg.SpawnedEventArgs(player, pos, this.MaxHealth, (float)this.MaxHealth); |
| 137 | + new Scp600Handler().InvokeSpawned(e); |
| 138 | + } |
| 139 | + } |
| 140 | + protected override void RoleAdded(Player player) |
| 141 | + { |
| 142 | + Timing.CallDelayed(1f, () => |
| 143 | + { |
| 144 | + player.ChangeAppearance(this.StartAppearance, false, 0); |
| 145 | + this.VisibledRole = RoleTypeId.ClassD; |
| 146 | + }); |
| 147 | + base.RoleAdded(player); |
| 148 | + } |
| 149 | + protected override void RoleRemoved(Player player) |
| 150 | + { |
| 151 | + Log.Debug($"SCP-600V dead and role romoved to player: {player}"); |
| 152 | + try |
| 153 | + { |
| 154 | + player.SessionVariables.Remove("IsSCP600"); |
| 155 | + player.SessionVariables.Remove("IsScp"); |
| 156 | + Timing.KillCoroutines($"{player.Id}-hurt"); |
| 157 | + if (!player.RemoteAdminAccess) |
| 158 | + { |
| 159 | + player.RankName = string.Empty; |
| 160 | + player.RankColor = string.Empty; |
| 161 | + } |
| 162 | + } |
| 163 | + catch |
| 164 | + { |
| 165 | + |
| 166 | + } |
| 167 | + base.RoleRemoved(player); |
| 168 | + } |
| 169 | + protected override void SubscribeEvents() |
| 170 | + { |
| 171 | + EvHandler.Player.Died += this.OnDeath; |
| 172 | + EvHandler.Player.PickingUpItem += this.PickUpItems; |
| 173 | + base.SubscribeEvents(); |
| 174 | + } |
| 175 | + protected override void UnsubscribeEvents() |
| 176 | + { |
| 177 | + EvHandler.Player.Died -= this.OnDeath; |
| 178 | + EvHandler.Player.PickingUpItem -= this.PickUpItems; |
| 179 | + base.UnsubscribeEvents(); |
| 180 | + } |
| 181 | + public void OnDeath(DiedEventArgs e) |
| 182 | + { |
| 183 | + if (Check(e.Attacker) & e.Attacker != null & e.Player != null & e.Attacker != e.Player) |
| 184 | + { |
| 185 | + Debug.Log("Attacker is SCP600"); |
| 186 | + if (e.TargetOldRole != this.VisibledRole & e.TargetOldRole != RoleTypeId.None & e.TargetOldRole != RoleTypeId.Spectator) |
| 187 | + { |
| 188 | + this.VisibledRole = e.TargetOldRole; |
| 189 | + e.Attacker.ChangeAppearance(this.VisibledRole, false, 0); |
| 190 | + } |
| 191 | + } |
| 192 | + } |
| 193 | + public void PickUpItems(PickingUpItemEventArgs e) |
| 194 | + { |
| 195 | + if (e.Player != null & Check(e.Player) & this.DontUserItems.Contains(e.Pickup.Type)) |
| 196 | + { |
| 197 | + e.IsAllowed = false; |
| 198 | + } |
| 199 | + } |
| 200 | + public IEnumerator<float> Hurting(Player player) |
| 201 | + { |
| 202 | + for (; ; ) |
| 203 | + { |
| 204 | + yield return Timing.WaitForSeconds(5); |
| 205 | + player.Hurt(5f, DamageType.Bleeding); |
| 206 | + } |
| 207 | + } |
| 208 | + } |
| 209 | +} |
0 commit comments