Skip to content
This repository has been archived by the owner on Feb 26, 2021. It is now read-only.

Commit

Permalink
Upgrade to smod 3.4.0 and add dropitems config
Browse files Browse the repository at this point in the history
  • Loading branch information
NeonWizard committed Apr 13, 2019
1 parent e318d46 commit 79f3804
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 13 deletions.
4 changes: 2 additions & 2 deletions TranquilizerGun/MiscEventHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class MiscEventHandler : IEventHandlerWaitingForPlayers, IEventHandlerRoundStart

public void OnWaitingForPlayers(WaitingForPlayersEvent ev)
{
if (!this.plugin.GetConfigBool("tranqgun_enable")) this.plugin.pluginManager.DisablePlugin(plugin);
if (!this.plugin.GetConfigBool("tranqgun_enable")) PluginManager.Manager.DisablePlugin(plugin);

plugin.ReloadConfig();
}
Expand Down Expand Up @@ -62,7 +62,7 @@ public void OnRoundStart(RoundStartEvent ev)
else if (sl == "surfacenuke")
{
Transform t = GameObject.Find("SCPSLNukeRoom/Table01 (2)").transform;
choices = new List<SpawnLocation>() { new SpawnLocation(t.position + Vector3.up*2.5f, Quaternion.identity) };
choices = new List<SpawnLocation>() { new SpawnLocation(t.position + Vector3.up * 2.5f, Quaternion.identity) };
}
else if (sl == "nuke")
{
Expand Down
25 changes: 14 additions & 11 deletions TranquilizerGun/TranqGunPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ namespace TranquilizerGun
name = "TranquilizerGun",
description = "Adds a tranquilizer gun with temporarily ragdolls players.",
id = "xyz.wizardlywonders.TranquilizerGun",
version = "1.2.1",
version = "1.2.2",
SmodMajor = 3,
SmodMinor = 3,
SmodMinor = 4,
SmodRevision = 0
)]
public class TranqGunPlugin : Plugin
Expand All @@ -34,6 +34,7 @@ public class TranqGunPlugin : Plugin
public static int ReserveAmmo { get; private set; }

public static float TranqDuration { get; private set; }
public static int DropItems { get; private set; }

public static List<string> SpawnLocations;

Expand All @@ -54,20 +55,21 @@ public override void Register()
Timing.Init(this);

// -- Register config
this.AddConfig(new ConfigSetting("tranqgun_enable", true, SettingType.BOOL, true, "Whether TranquilizerGun should be enabled on server start."));
this.AddConfig(new ConfigSetting("tranqgun_use_ghostmode", false, SettingType.BOOL, true, "Instead of teleporting players to the void, make them invisible for the duration of tranquilization. REQUIRES SM_ENABLE_GHOSTMODE"));
this.AddConfig(new ConfigSetting("tranqgun_enable", true, true, "Whether TranquilizerGun should be enabled on server start."));
this.AddConfig(new ConfigSetting("tranqgun_use_ghostmode", false, true, "Instead of teleporting players to the void, make them invisible for the duration of tranquilization. REQUIRES SM_ENABLE_GHOSTMODE"));

this.AddConfig(new ConfigSetting("tranqgun_damage", 0, SettingType.NUMERIC, true, "Damage dealt by the tranquilizer gun."));
this.AddConfig(new ConfigSetting("tranqgun_firerate", 3f, SettingType.FLOAT, true, "Time (in seconds) between each shot."));
this.AddConfig(new ConfigSetting("tranqgun_magazine", 1, SettingType.NUMERIC, true, "Amount of shots per magazine."));
this.AddConfig(new ConfigSetting("tranqgun_reserveammo", 2, SettingType.NUMERIC, true, "Default reserve ammo for each player."));
this.AddConfig(new ConfigSetting("tranqgun_damage", 0, true, "Damage dealt by the tranquilizer gun."));
this.AddConfig(new ConfigSetting("tranqgun_firerate", 3f, true, "Time (in seconds) between each shot."));
this.AddConfig(new ConfigSetting("tranqgun_magazine", 1, true, "Amount of shots per magazine."));
this.AddConfig(new ConfigSetting("tranqgun_reserveammo", 2, true, "Default reserve ammo for each player."));

this.AddConfig(new ConfigSetting("tranqgun_duration", 5f, SettingType.FLOAT, true, "Time (in seconds) the target is tranquilized for."));
this.AddConfig(new ConfigSetting("tranqgun_duration", 5f, true, "Time (in seconds) the target is tranquilized for."));
this.AddConfig(new ConfigSetting("tranqgun_dropitems", 0, true, "0: Don't drop items. 1: Drop currently held item. 2: Drop all items."));

this.AddConfig(new ConfigSetting("tranqgun_spawns", new string[] { "096chamber" }, true, SettingType.LIST, true, "Locations that the tranquilizer gun can spawn in."));
this.AddConfig(new ConfigSetting("tranqgun_spawns", new string[] { "096chamber" }, true, true, "Locations that the tranquilizer gun can spawn in."));

// -- Register events
this.AddEventHandlers(new MiscEventHandler(this), Smod2.Events.Priority.Low);
this.AddEventHandlers(new MiscEventHandler(this));

// -- Register weapon
this.Handler = new CustomWeaponHandler<TranquilizerGun>(TranqGunPlugin.TranqID)
Expand All @@ -93,6 +95,7 @@ public void ReloadConfig()
this.Handler.DefaultReserveAmmo = TranqGunPlugin.ReserveAmmo;

TranqGunPlugin.TranqDuration = GetConfigFloat("tranqgun_duration");
TranqGunPlugin.DropItems = GetConfigInt("tranqgun_dropitems");

TranqGunPlugin.SpawnLocations = new List<string>(GetConfigList("tranqgun_spawns"));
}
Expand Down
9 changes: 9 additions & 0 deletions TranquilizerGun/TranquilizerGun.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,15 @@ private IEnumerable<float> Tranquilize(Player p)
GameObject target = (GameObject)p.GetGameObject();
Vector loc = p.GetPosition();

// -- Drop item(s) if config is set
switch (TranqGunPlugin.DropItems)
{
case 1:
p.GetCurrentItem().Drop(); break;
case 2:
p.GetInventory().ForEach(x => x.Drop()); break;
}

// -- Make them ghostmoded if enabled
if (TranqGunPlugin.Ghostmode)
{
Expand Down

0 comments on commit 79f3804

Please sign in to comment.