Add config option "RespawnBossSeconds"

Fixes #813
This commit is contained in:
MarioE 2014-07-01 14:43:56 -04:00
parent 0701f5cf37
commit e2d826a157
4 changed files with 20 additions and 7 deletions

View file

@ -353,7 +353,10 @@ namespace TShockAPI
public bool LogRest = false;
[Description("The number of seconds a player must wait before being respawned.")]
public int RespawnSeconds = 3;
public int RespawnSeconds = 5;
[Description("The number of seconds a player must wait before being respawned if there is a boss nearby.")]
public int RespawnBossSeconds = 10;
[Description("Disables a player if this number of tiles is painted within 1 second.")]
public int TilePaintThreshold = 15;

View file

@ -2599,8 +2599,18 @@ namespace TShockAPI
return true;
}
args.Player.LastDeath = DateTime.Now;
args.Player.Dead = true;
args.Player.RespawnTimer = TShock.Config.RespawnSeconds;
foreach (NPC npc in Main.npc)
{
if (npc.active && (npc.boss || npc.type == 13 || npc.type == 14 || npc.type == 15) &&
Math.Abs(args.TPlayer.center().X - npc.center().X) + Math.Abs(args.TPlayer.center().Y - npc.center().Y) < 4000f)
{
args.Player.RespawnTimer = TShock.Config.RespawnBossSeconds;
break;
}
}
if (args.TPlayer.difficulty == 2 && TShock.Config.ServerSideCharacter && args.Player.IsLoggedIn)
{

View file

@ -214,10 +214,10 @@ namespace TShockAPI
public bool RequestedSection;
/// <summary>
/// The last time the player died.
/// </summary>
public DateTime LastDeath { get; set; }
/// <summary>
/// The player's respawn timer.
/// </summary>
public int RespawnTimer;
/// <summary>
/// Whether the player is dead or not.

View file

@ -782,7 +782,7 @@ namespace TShockAPI
player.PaintThreshold = 0;
}
if (player.Dead && (DateTime.Now - player.LastDeath).Seconds >= Config.RespawnSeconds && player.Difficulty != 2)
if (player.RespawnTimer > 0 && --player.RespawnTimer == 0 && player.Difficulty != 2)
{
player.Spawn();
}