diff --git a/Smod2/Smod2.csproj b/Smod2/Smod2.csproj
index 4a2355a..e5be3fd 100644
--- a/Smod2/Smod2.csproj
+++ b/Smod2/Smod2.csproj
@@ -7,7 +7,7 @@
{6B3C975A-CA75-4764-8192-E1D8EC8E6475}
Library
Properties
- ZombieSuicideHotline
+ Smod2
Smod2
v3.5
512
diff --git a/ZombieSuicideHotline/ZombieSuicideHotline.cs b/ZombieSuicideHotline/ZombieSuicideHotline.cs
index 5fc38d2..807c2c1 100644
--- a/ZombieSuicideHotline/ZombieSuicideHotline.cs
+++ b/ZombieSuicideHotline/ZombieSuicideHotline.cs
@@ -12,18 +12,17 @@ namespace ZombieSuicideHotline
name = "ZombieSuicideHotline",
description = "Respawns zombies that intentionally kill themselves.",
id = "patpeter.zombiesuicidehotline",
- version = "1.0-build17",
+ version = "1.0-build18",
SmodMajor = 2,
- SmodMinor = 0,
- SmodRevision = 0
+ SmodMinor = 2,
+ SmodRevision = 1
)]
class ZombieSuicideHotlinePlugin : Plugin
{
- public HashSet zombieSuicides = new HashSet();
- public HashSet deadDoctors = new HashSet();
- public TeamClass plagueDoctorClass = null;
- public TeamClass zombieClass = null;
- public Dictionary ClassList = new Dictionary();
+ internal bool duringRound = false;
+ internal HashSet scp049Kills = new HashSet();
+ internal HashSet zombieDisconnects = new HashSet();
+ internal Dictionary ClassList = new Dictionary();
public override void OnEnable()
{
@@ -33,16 +32,19 @@ public override void OnEnable()
public override void OnDisable()
{
+
}
public override void Register()
{
// Register Events
this.AddEventHandler(typeof(IEventRoundStart), new RoundStartHandler(this), Priority.Highest);
- this.AddEventHandler(typeof(IEventPlayerDie), new PlayerDieHandler(this), Priority.Highest);
- //this.AddEventHandler(typeof(IEventAssignTeam), new AssignTeamHandler(this), Priority.High);
- this.AddEventHandler(typeof(IEventSetClass), new SetClass1Handler(this), Priority.High);
- this.AddEventHandler(typeof(IEventSetClass), new SetClass2Handler(this), Priority.Normal);
+ this.AddEventHandler(typeof(IEventRoundEnd), new RoundEndHandler(this), Priority.Highest);
+ this.AddEventHandler(typeof(IEventPlayerJoin), new PlayerJoinHandler(this), Priority.Highest);
+ this.AddEventHandler(typeof(IEventPlayerLeave), new PlayerLeaveHandler(this), Priority.Highest);
+ this.AddEventHandler(typeof(IEventSetClass), new SetClassHandler(this), Priority.Highest);
+ this.AddEventHandler(typeof(IEventPlayerDie), new PlayerDieHandler(this), Priority.Highest);
+ this.AddEventHandler(typeof(IEventPlayerHurt), new PlayerHurtHandler(this), Priority.Highest);
// Register config settings
this.AddConfig(new Smod2.Config.ConfigSetting("zombie_suicide_hotline_enabled", true, Smod2.Config.SettingType.BOOL, true, "Enables or disables the zombie suicide hotline."));
}
diff --git a/ZombieSuicideHotline/ZombieSuicideHotlineEventHandler.cs b/ZombieSuicideHotline/ZombieSuicideHotlineEventHandler.cs
index db0f5c1..d9781b4 100644
--- a/ZombieSuicideHotline/ZombieSuicideHotlineEventHandler.cs
+++ b/ZombieSuicideHotline/ZombieSuicideHotlineEventHandler.cs
@@ -10,11 +10,14 @@ class RoundStartHandler : IEventRoundStart
public RoundStartHandler(Plugin plugin)
{
- this.plugin = (ZombieSuicideHotlinePlugin)plugin;
+ this.plugin = (ZombieSuicideHotlinePlugin) plugin;
}
public void OnRoundStart(Server server)
{
+ this.plugin.duringRound = true;
+ this.plugin.scp049Kills = new System.Collections.Generic.HashSet();
+ this.plugin.zombieDisconnects = new System.Collections.Generic.HashSet();
foreach (TeamClass teamClass in server.GetClasses())
{
this.plugin.ClassList.Add(teamClass.ClassType, teamClass);
@@ -22,190 +25,144 @@ public void OnRoundStart(Server server)
plugin.Info("ClassList SIZE " + this.plugin.ClassList.Count);
}
}
-
- class PlayerDieHandler : IEventPlayerDie
+ class RoundEndHandler : IEventRoundEnd
{
private ZombieSuicideHotlinePlugin plugin;
- public PlayerDieHandler(Plugin plugin)
+ public RoundEndHandler(Plugin plugin)
{
- this.plugin = (ZombieSuicideHotlinePlugin)plugin;
+ this.plugin = (ZombieSuicideHotlinePlugin) plugin;
}
- public void OnPlayerDie(Player player, Player killer, out bool spawnRagdoll)
+ public void OnRoundEnd(Server server, Round round)
{
- //plugin.Info("ZombieSuicideHotline OnPlayerDie");
- //plugin.Info(player.ToString());
- //plugin.Info(player.Class.Name);
- //plugin.Info(killer.ToString());
- //plugin.Info(killer.Class.Name);
- if (player.Class.ClassType == Classes.SCP_049_2)
- {
- //plugin.Info("ZombieSuicideHotline OnPlayerDie 049-2");
- //if (killer == null)
- //if (player == killer)
- if (player.SteamId == killer.SteamId)
- {
- spawnRagdoll = false;
-
- this.plugin.zombieSuicides.Add(player.SteamId);
- /*Vector position = null;
- if (this.plugin.SCPSpawnPoints.TryGetValue(Classes.SCP_049, out position))
- {
- plugin.Info("ZombieSuicideHotline OnPlayerDie RESPAWN");
- //player.ChangeClass(Classes.SCP_049_2, true, true);
- player.Teleport(position);
- }
- else
- {
- plugin.Info("SCP-049-2 SPAWNED WITHOUT SCP-049.");
- //player.ChangeClass(Classes.SCP_049_2, true, true);
- }*/
- }
- else
- {
- spawnRagdoll = true;
- }
- }
- else if (player.Class.ClassType == Classes.SCP_106)
- {
- plugin.Info("ZombieSuicideHotline Larry");
- spawnRagdoll = false;
- }
- else
+ this.plugin.duringRound = false;
+ foreach (TeamClass teamClass in server.GetClasses())
{
- plugin.Info("ZombieSuicideHotline Other");
- spawnRagdoll = true;
+ this.plugin.ClassList.Add(teamClass.ClassType, teamClass);
}
+ plugin.Info("ClassList SIZE " + this.plugin.ClassList.Count);
}
}
- /*class AssignTeamHandler : IEventAssignTeam
+ class PlayerJoinHandler : IEventPlayerJoin
{
private ZombieSuicideHotlinePlugin plugin;
- public AssignTeamHandler(Plugin plugin)
+ public PlayerJoinHandler(Plugin plugin)
{
- this.plugin = (ZombieSuicideHotlinePlugin)plugin;
+ this.plugin = (ZombieSuicideHotlinePlugin) plugin;
}
- public void OnAssignTeam(Player player, Teams team, out Teams teamOutput)
+ public void OnPlayerJoin(Player player)
{
- if (this.plugin.zombieSuicides.Contains(player.SteamId))
+ if (this.plugin.duringRound && this.plugin.zombieDisconnects.Contains(player.SteamId))
{
- plugin.Info("SUICIDE ZOMBIE FOUND " + player.ToString() + " " + player.Class.ToString());
- this.plugin.zombieSuicides.Remove(player.SteamId);
- TeamClass teamClass = null;
- if (this.plugin.ClassList.TryGetValue(Classes.SCP_049_2, out teamClass))
- {
- plugin.Info("ZOMBIE CLASS FOUND, SET FROM SPECTATOR TO ZOMBIE " + teamClass.ToString());
- teamOutput = teamClass.Team;
- } else
- {
- plugin.Info("ZOMBIE CLASS NOT FOUND");
- teamOutput = team;
- }
+ player.ChangeClass(Classes.SCP_049_2, true, true);
+ this.plugin.zombieDisconnects.Add(player.SteamId);
}
- else
+ }
+ }
+
+ class PlayerLeaveHandler : IEventPlayerLeave
+ {
+ private ZombieSuicideHotlinePlugin plugin;
+
+ public PlayerLeaveHandler(Plugin plugin)
+ {
+ this.plugin = (ZombieSuicideHotlinePlugin) plugin;
+ }
+
+ public void OnPlayerLeave(Player player)
+ {
+ if (this.plugin.duringRound && this.plugin.scp049Kills.Contains(player.SteamId))
{
- plugin.Info("NON-ZOMBIE ASSIGNED TEAM " + player.ToString() + " " + player.Class.ToString());
- teamOutput = team;
+ this.plugin.scp049Kills.Remove(player.SteamId);
+ this.plugin.zombieDisconnects.Add(player.SteamId);
}
}
- }*/
+ }
- class SetClass1Handler : IEventSetClass
+ class SetClassHandler : IEventSetClass
{
private ZombieSuicideHotlinePlugin plugin;
- public SetClass1Handler(Plugin plugin)
+ public SetClassHandler(Plugin plugin)
{
this.plugin = (ZombieSuicideHotlinePlugin)plugin;
}
public void OnSetClass(Player player, TeamClass teamclass, out TeamClass teamclassOutput)
{
- // Player's vector is spectator vector in this event
- /*switch (teamclass.ClassType)
- {
- case Classes.SCP_049:
- case Classes.SCP_096:
- case Classes.SCP_106:
- case Classes.SCP_173:
- this.plugin.SCPSpawnPoints.Add(player.Class.ClassType, player.GetPosition());
- break;
- }*/
-
- /*plugin.Info("PLAYER " + player.Name + " is changing class to " + teamclass.Name);
- if (teamclass.ClassType == Classes.SCP_049)
+ if (this.plugin.duringRound && this.plugin.scp049Kills.Contains(player.SteamId))
{
- this.plugin.plagueDoctorClass = teamclass;
- plugin.Info("PLAGUE DOCTOR ASSIGNED." + this.plugin.plagueDoctorClass.Name);
+ plugin.Info("Remove player from scp049Kills");
+ this.plugin.scp049Kills.Remove(player.SteamId);
+ teamclassOutput = teamclass;
}
- else if (teamclass.ClassType == Classes.SCP_049_2)
+ else
{
- this.plugin.zombieClass = teamclass;
- plugin.Info("ZOMBIE CLASS ASSIGNED." + this.plugin.zombieClass.Name);
+ plugin.Info("NOT RESPAWNING ZOMBIE");
+ teamclassOutput = teamclass;
}
+ }
+ }
- plugin.Info("ZOMBIE SUICIDES");
- foreach (string s in this.plugin.zombieSuicides)
- {
- plugin.Info(s);
- }
+ class PlayerDieHandler : IEventPlayerDie
+ {
+ private ZombieSuicideHotlinePlugin plugin;
- plugin.Info("DEAD DOCTORS");
- foreach (string s in this.plugin.zombieSuicides)
- {
- plugin.Info(s);
- }*/
+ public PlayerDieHandler(Plugin plugin)
+ {
+ this.plugin = (ZombieSuicideHotlinePlugin) plugin;
+ }
- if (this.plugin.zombieSuicides.Contains(player.SteamId))
+ public void OnPlayerDie(Player player, Player killer, out bool spawnRagdoll)
+ {
+ if (this.plugin.duringRound && killer.Class.ClassType == Classes.SCP_049)
{
- plugin.Info("RESPAWNING AS PLAGUE DOCTOR " //+ this.plugin.plagueDoctorClass.Name
- );
- //teamclassOutput.Team = Teams.SCP;
- //teamclassOutput.ClassType = Classes.SCP_049_2;
- this.plugin.zombieSuicides.Remove(player.SteamId);
- this.plugin.deadDoctors.Add(player.SteamId);
- teamclassOutput = this.plugin.ClassList[Classes.SCP_049]; //this.plugin.plagueDoctorClass;
+ this.plugin.scp049Kills.Add(player.SteamId);
+ spawnRagdoll = true;
}
- /*else if (this.plugin.deadDoctors.Contains(player.SteamId))
+ else if (player.Class.ClassType == Classes.SCP_106)
{
- plugin.Info("KILLING DOCTOR " + this.plugin.zombieClass.Name);
- //player.Damage(9999, DamageType.TESLA);
- this.plugin.deadDoctors.Remove(player.SteamId);
- teamclassOutput = this.plugin.ClassList[Classes.SCP_049_2]; //this.plugin.zombieClass;
- }*/
+ spawnRagdoll = false;
+ }
else
{
- plugin.Info("NOT RESPAWNING ZOMBIE");
- teamclassOutput = teamclass;
+ spawnRagdoll = true;
}
}
}
- class SetClass2Handler : IEventSetClass
+ class PlayerHurtHandler : IEventPlayerHurt
{
private ZombieSuicideHotlinePlugin plugin;
- public SetClass2Handler(Plugin plugin)
+ public PlayerHurtHandler(Plugin plugin)
{
- this.plugin = (ZombieSuicideHotlinePlugin)plugin;
+ this.plugin = (ZombieSuicideHotlinePlugin) plugin;
}
- public void OnSetClass(Player player, TeamClass teamclass, out TeamClass teamclassOutput)
+ public void OnPlayerHurt(Player player, Player attacker, float damage, out float damageOutput, DamageType type, out DamageType typeOutput)
{
- if (this.plugin.deadDoctors.Contains(player.SteamId))
+ switch (player.Class.ClassType)
{
- plugin.Info("KILLING DOCTOR " + this.plugin.zombieClass.Name);
- //player.Damage(9999, DamageType.TESLA);
- this.plugin.deadDoctors.Remove(player.SteamId);
- teamclassOutput = this.plugin.ClassList[Classes.SCP_049_2]; //this.plugin.zombieClass;
- } else
- {
- plugin.Info("NOT RESPAWNING DOCTOR");
- teamclassOutput = teamclass;
+ case Classes.SCP_049_2:
+ if (type == DamageType.TESLA)
+ {
+ typeOutput = DamageType.NONE;
+ damageOutput = 0f;
+ }
+ else
+ {
+ goto default;
+ }
+ break;
+ default:
+ typeOutput = type;
+ damageOutput = damage;
+ break;
}
}
}