New Features For the new Release! Config options to enable the spread of creep in hardmode. This means users can disable the corruption or the hallow from spreading. This allows server owners the chance to play on hardmode without it ruining their worlds. This does require the new TerrariaServer but the only change is the addition of a hook, which I believe does not require the increment of an API version attribute.

This commit is contained in:
Zack Piispanen 2012-04-18 00:46:30 -04:00
parent 88f1ebf15e
commit c81cd39fb3
3 changed files with 30 additions and 1 deletions

View file

@ -216,7 +216,11 @@ namespace TShockAPI
[Description("Allow Ice placement even when user does not have canbuild")] public bool AllowIce = false;
public static ConfigFile Read(string path)
[Description("Allows corrutption to spread when a world is hardmode.")] public bool AllowCorruptionCreep = true;
[Description("Allows hallow to spread when a world is hardmode.")] public bool AllowHallowCreep = true;
public static ConfigFile Read(string path)
{
if (!File.Exists(path))
return new ConfigFile();

View file

@ -203,6 +203,7 @@ namespace TShockAPI
GameHooks.PostInitialize += OnPostInit;
GameHooks.Update += OnUpdate;
GameHooks.HardUpdate += OnHardUpdate;
ServerHooks.Connect += OnConnect;
ServerHooks.Join += OnJoin;
ServerHooks.Leave += OnLeave;
@ -281,6 +282,7 @@ namespace TShockAPI
GameHooks.PostInitialize -= OnPostInit;
GameHooks.Update -= OnUpdate;
GameHooks.HardUpdate -= OnHardUpdate;
ServerHooks.Connect -= OnConnect;
ServerHooks.Join -= OnJoin;
ServerHooks.Leave -= OnLeave;
@ -623,6 +625,29 @@ namespace TShockAPI
Config.MaxSlots, Netplay.serverListenIP, Config.ServerPort, Version);
}
private void OnHardUpdate( HardUpdateEventArgs args )
{
if (args.Handled)
return;
if (!Config.AllowCorruptionCreep && ( args.Type == 23 || args.Type == 25 || args.Type == 0 ||
args.Type == 112 || args.Type == 23 || args.Type == 32 ) )
{
args.Handled = true;
Console.WriteLine("{0} has been prevented from creeping to {1}, {2}", args.Type, args.X, args.Y);
return;
}
if (!Config.AllowHallowCreep && (args.Type == 109 || args.Type == 117 || args.Type == 116 ) )
{
args.Handled = true;
Console.WriteLine("{0} has been prevented from creeping to {1}, {2}", args.Type, args.X, args.Y);
return;
}
Console.WriteLine("{0} has creeped to {1}, {2}", args.Type, args.X, args.Y);
}
private void OnConnect(int ply, HandledEventArgs handler)
{
var player = new TSPlayer(ply);